public static RubyModule getNthScopeModule(StaticScope scope, int depth) { int n = depth; while (n > 0) { scope = scope.getEnclosingScope(); if (scope.getScopeType() != null) { n--; } } return scope.getModule(); }
/** * Get parent module/class that this module represents */ @Override public RubyModule getEnclosingModule(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return context.getCurrentScope().getStaticScope().getModule(); }
protected static RubyModule getRubyClass(final Ruby runtime) { ThreadContext context = runtime.getCurrentContext(); StaticScope scope = context.getCurrentScope().getStaticScope(); RubyModule rubyClass = scope.getModule(); return rubyClass; }
protected static RubyModule getRubyClass(final Ruby runtime) { ThreadContext context = runtime.getCurrentContext(); StaticScope scope = context.getCurrentScope().getStaticScope(); RubyModule rubyClass = scope.getModule(); return rubyClass; }
public void preMethodNoFrameAndDummyScope(RubyModule clazz, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushScope(staticScope.getDummyScope()); pushRubyClass(implementationClass); }
public void preMethodBacktraceDummyScope(RubyModule clazz, String name, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushScope(staticScope.getDummyScope()); pushRubyClass(implementationClass); }
public final IRubyObject getConstant(ThreadContext context, StaticScope scope, String name, int index) { IRubyObject value = getValue(context, scope, name, index); // We can callsite cache const_missing if we want return value != null ? value : scope.getModule().callMethod(context, "const_missing", context.runtime.fastNewSymbol(name)); }
public IRubyObject setConstant(String internedName, IRubyObject result) { RubyModule module; if ((module = getModule()) != null) { module.setConstant(internedName, result); return result; } // TODO: wire into new exception handling mechanism throw result.getRuntime().newTypeError("no class/module to define constant"); }
public final IRubyObject getConstant(ThreadContext context, StaticScope scope, String name, int index) { IRubyObject value = getValue(context, scope, name, index); // We can callsite cache const_missing if we want return value != null ? value : scope.getModule().callMethod(context, "const_missing", context.runtime.fastNewSymbol(name)); }
public void preMethodScopeOnly(RubyModule clazz, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushScope(DynamicScope.newDynamicScope(staticScope)); pushRubyClass(implementationClass); }
protected RubyModule getRubyClass(Ruby runtime) { ThreadContext context = runtime.getCurrentContext(); StaticScope scope = context.getCurrentScope().getStaticScope(); RubyModule rubyClass = scope.getModule(); return rubyClass; }
public void preMethodBacktraceDummyScope(RubyModule clazz, String name, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushScope(staticScope.getDummyScope()); pushRubyClass(implementationClass); }
public IRubyObject setConstant(String internedName, IRubyObject result) { RubyModule module; if ((module = getModule()) != null) { module.setConstant(internedName, result); return result; } // TODO: wire into new exception handling mechanism throw result.getRuntime().newTypeError("no class/module to define constant"); }
public final IRubyObject getConstant(ThreadContext context, StaticScope scope, String name, int index) { IRubyObject value = getValue(context, scope, name, index); // We can callsite cache const_missing if we want return value != null ? value : scope.getModule().callMethod(context, "const_missing", context.runtime.fastNewSymbol(name)); }
public final IRubyObject getConstant(ThreadContext context, StaticScope scope, String name, int index) { IRubyObject value = getValue(context, scope, name, index); // We can callsite cache const_missing if we want return value != null ? value : scope.getModule().callMethod(context, "const_missing", context.runtime.fastNewSymbol(name)); }
@Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { StaticScope staticScope = scope.getStaticScope(); return staticScope != null ? staticScope.getModule() : context.runtime.getClass(scope.getName()); }
public void preMethodFrameAndDummyScope(RubyModule clazz, String name, IRubyObject self, Block block, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushCallFrame(clazz, name, self, block); pushScope(staticScope.getDummyScope()); pushRubyClass(implementationClass); }
public void preMethodFrameAndDummyScope(RubyModule clazz, String name, IRubyObject self, Block block, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushCallFrame(clazz, name, self, block); pushScope(staticScope.getDummyScope()); pushRubyClass(implementationClass); }
public void preMethodFrameAndScope(RubyModule clazz, String name, IRubyObject self, Block block, StaticScope staticScope) { RubyModule implementationClass = staticScope.getModule(); // FIXME: This is currently only here because of some problems with IOOutputStream writing to a "bare" runtime without a proper scope if (implementationClass == null) { implementationClass = clazz; } pushCallFrame(clazz, name, self, block); pushScope(DynamicScope.newDynamicScope(staticScope)); pushRubyClass(implementationClass); }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { IRubyObject value = getValue(context); // We can callsite cache const_missing if we want return value != null ? value : context.getCurrentScope().getStaticScope().getModule().callMethod(context, "const_missing", runtime.fastNewSymbol(name)); }