@Override public void CurrentScope(CurrentScope currentscope) { jvmMethod().loadStaticScope(); }
@Override public void CurrentScope(CurrentScope currentscope) { jvmMethod().loadStaticScope(); }
@Override public void Filename(Filename filename) { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("getFileNameStringFromScope", sig(RubyString.class, ThreadContext.class, StaticScope.class)); }
@Override public void Filename(Filename filename) { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("getFileNameStringFromScope", sig(RubyString.class, ThreadContext.class, StaticScope.class)); }
@Override public void PushBindingInstr(PushBindingInstr pushbindinginstr) { jvm.method().loadStaticScope(); jvm.method().adapter.invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class)); jvmStoreLocal(DYNAMIC_SCOPE); // TODO push }
@Override public void PushBindingInstr(PushBindingInstr pushbindinginstr) { jvm.method().loadStaticScope(); jvm.method().adapter.invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class)); jvmStoreLocal(DYNAMIC_SCOPE); // TODO push }
@Override public void ScopeModule(ScopeModule scopemodule) { jvmMethod().loadStaticScope(); jvmAdapter().pushInt(scopemodule.getScopeModuleDepth()); jvmAdapter().invokestatic(p(Helpers.class), "getNthScopeModule", sig(RubyModule.class, StaticScope.class, int.class)); }
@Override public void ArgScopeDepthInstr(ArgScopeDepthInstr instr) { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("getArgScopeDepth", sig(RubyFixnum.class, ThreadContext.class, StaticScope.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ArgScopeDepthInstr(ArgScopeDepthInstr instr) { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("getArgScopeDepth", sig(RubyFixnum.class, ThreadContext.class, StaticScope.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ScopeModule(ScopeModule scopemodule) { jvmMethod().loadStaticScope(); jvmAdapter().pushInt(scopemodule.getScopeModuleDepth()); jvmAdapter().invokestatic(p(Helpers.class), "getNthScopeModule", sig(RubyModule.class, StaticScope.class, int.class)); }
@Override public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) { IRScope scope = jvm.methodData().scope; if (scope.isScriptScope() && scope.getRootLexicalScope() != null) { // script scope, so we don't push a new scope; instead we push the top-level scope it provides jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("prepareScriptScope", sig(DynamicScope.class, ThreadContext.class, StaticScope.class)); jvmStoreLocal(DYNAMIC_SCOPE); return; } else { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmAdapter().invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class)); jvmAdapter().dup(); jvmStoreLocal(DYNAMIC_SCOPE); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void pushScope(org.jruby.runtime.DynamicScope)")); } }
@Override public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) { IRScope scope = jvm.methodData().scope; if (scope.isScriptScope() && scope.getRootLexicalScope() != null) { // script scope, so we don't push a new scope; instead we push the top-level scope it provides jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("prepareScriptScope", sig(DynamicScope.class, ThreadContext.class, StaticScope.class)); jvmStoreLocal(DYNAMIC_SCOPE); return; } else { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmAdapter().invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class)); jvmAdapter().dup(); jvmStoreLocal(DYNAMIC_SCOPE); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void pushScope(org.jruby.runtime.DynamicScope)")); } }
private void checkArity(int required, int opt, boolean rest, boolean receivesKeywords, int restKey) { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().loadArgs(); // TODO: pack these, e.g. in a constant pool String jvmAdapter().ldc(required); jvmAdapter().ldc(opt); jvmAdapter().ldc(rest); jvmAdapter().ldc(receivesKeywords); jvmAdapter().ldc(restKey); jvmMethod().loadSelfBlock(); jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "checkArity", sig(void.class, ThreadContext.class, StaticScope.class, Object[].class, int.class, int.class, boolean.class, boolean.class, int.class, Block.class)); }
private void checkArity(int required, int opt, boolean rest, boolean receivesKeywords, int restKey) { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().loadArgs(); // TODO: pack these, e.g. in a constant pool String jvmAdapter().ldc(required); jvmAdapter().ldc(opt); jvmAdapter().ldc(rest); jvmAdapter().ldc(receivesKeywords); jvmAdapter().ldc(restKey); jvmMethod().loadSelfBlock(); jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "checkArity", sig(void.class, ThreadContext.class, StaticScope.class, Object[].class, int.class, int.class, boolean.class, boolean.class, int.class, Block.class)); }
protected void emitVarargsMethodWrapper(IRScope scope, String variableName, String specificName, Signature variableSignature, Signature specificSignature) { jvm.pushmethod(variableName, scope, variableSignature, false); IRBytecodeAdapter m = jvmMethod(); // check arity org.jruby.runtime.Signature scopeSig = scope.getStaticScope().getSignature(); checkArity(scopeSig.required(), scopeSig.opt(), scopeSig.hasRest(), scopeSig.hasKwargs(), scopeSig.keyRest()); // push leading args m.loadContext(); m.loadStaticScope(); m.loadSelf(); // unwrap specific args if (scopeSig.required() > 0) { for (int i = 0; i < scopeSig.required(); i++) { m.loadArgs(); jvmAdapter().pushInt(i); jvmAdapter().aaload(); } } // push trailing args m.loadBlock(); m.loadFrameClass(); m.loadFrameName(); // invoke specific-arity version and return Method specificMethod = new Method(specificName, Type.getType(specificSignature.type().returnType()), IRRuntimeHelpers.typesFromSignature(specificSignature)); jvmAdapter().invokestatic(m.getClassData().clsName, specificName, specificMethod.getDescriptor()); jvmAdapter().areturn(); jvm.popmethod(); }
protected void emitVarargsMethodWrapper(IRScope scope, String variableName, String specificName, Signature variableSignature, Signature specificSignature) { jvm.pushmethod(variableName, scope, variableSignature, false); IRBytecodeAdapter m = jvmMethod(); // check arity org.jruby.runtime.Signature scopeSig = scope.getStaticScope().getSignature(); checkArity(scopeSig.required(), scopeSig.opt(), scopeSig.hasRest(), scopeSig.hasKwargs(), scopeSig.keyRest()); // push leading args m.loadContext(); m.loadStaticScope(); m.loadSelf(); // unwrap specific args if (scopeSig.required() > 0) { for (int i = 0; i < scopeSig.required(); i++) { m.loadArgs(); jvmAdapter().pushInt(i); jvmAdapter().aaload(); } } // push trailing args m.loadBlock(); m.loadFrameClass(); m.loadFrameName(); // invoke specific-arity version and return Method specificMethod = new Method(specificName, Type.getType(specificSignature.type().returnType()), IRRuntimeHelpers.typesFromSignature(specificSignature)); jvmAdapter().invokestatic(m.getClassData().clsName, specificName, specificMethod.getDescriptor()); jvmAdapter().areturn(); jvm.popmethod(); }