public BodyCompiler startMethod(String rubyName, String javaName, CompilerCallback args, StaticScope scope, ASTInspector inspector, int scopeIndex) { RootScopedBodyCompiler methodCompiler = new MethodBodyCompiler(this, rubyName, javaName, inspector, scope, scopeIndex); methodCompiler.beginMethod(args, scope); return methodCompiler; }
@Override public void performReturn() { if (inRescue) { // returning from rescue, clear $! clearErrorInfo(); } // normal return for method body. return jump for within a begin/rescue/ensure if (inNestedMethod) { loadThreadContext(); invokeUtilityMethod("throwReturnJump", sig(IRubyObject.class, IRubyObject.class, ThreadContext.class)); } else { method.areturn(); } }
@Override protected void createVariableCompiler() { if (inspector == null) { variableCompiler = new HeapBasedVariableCompiler(this, method, scope, specificArity, StandardASMCompiler.ARGS_INDEX, getFirstTempIndex()); } else if (inspector.hasClosure() || inspector.hasScopeAwareMethods()) { variableCompiler = new HeapBasedVariableCompiler(this, method, scope, specificArity, StandardASMCompiler.ARGS_INDEX, getFirstTempIndex()); } else { variableCompiler = new StackBasedVariableCompiler(this, method, scope, specificArity, StandardASMCompiler.ARGS_INDEX, getFirstTempIndex()); } }
@Override public void issueRedoEvent() { if (currentLoopLabels != null) { issueLoopRedo(); } else if (inNestedMethod) { invokeUtilityMethod("redoJump", sig(IRubyObject.class)); } else { // in method body with no containing loop, issue jump error // load runtime and value, issue jump error loadRuntime(); invokeUtilityMethod("redoLocalJumpError", sig(IRubyObject.class, Ruby.class)); } }
@Override public void issueBreakEvent(CompilerCallback value) { if (currentLoopLabels != null) { value.call(this); issueLoopBreak(); } else if (inNestedMethod) { loadThreadContext(); value.call(this); invokeUtilityMethod("breakJump", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class)); } else { // in method body with no containing loop, issue jump error // load runtime and value, issue jump error loadRuntime(); value.call(this); invokeUtilityMethod("breakLocalJumpError", sig(IRubyObject.class, Ruby.class, IRubyObject.class)); } }
method.aload(3); method.pushInt(scope.getRequiredArgs()); invokeUtilityMethod("checkArgumentCount", sig(void.class, ThreadContext.class, IRubyObject[].class, int.class)); loadThis(); loadThreadContext(); loadSelf(); for (int i = 0; i < scope.getRequiredArgs(); i++) { method.aload(StandardASMCompiler.ARGS_INDEX); method.invokestatic(script.getClassname(), methodName, getSignature()); method.areturn(); method.end();
@Override public void issueNextEvent(CompilerCallback value) { if (currentLoopLabels != null) { value.call(this); issueLoopNext(); } else if (inNestedMethod) { value.call(this); invokeUtilityMethod("nextJump", sig(IRubyObject.class, IRubyObject.class)); } else { // in method body with no containing loop, issue jump error // load runtime and value, issue jump error loadRuntime(); value.call(this); invokeUtilityMethod("nextLocalJumpError", sig(IRubyObject.class, Ruby.class, IRubyObject.class)); } }
public BodyCompiler startFileMethod(CompilerCallback args, StaticScope scope, ASTInspector inspector) { MethodBodyCompiler methodCompiler = new MethodBodyCompiler(this, "__file__", "__file__", inspector, scope, 0); assert reservedIndex == 0 : "__file__ scope index was not zero"; methodCompiler.beginMethod(args, scope); method.end(); if (methodCompiler.isSpecificArity()) {
method.aload(3); method.pushInt(scope.getRequiredArgs()); invokeUtilityMethod("checkArgumentCount", sig(void.class, ThreadContext.class, IRubyObject[].class, int.class)); loadThis(); loadThreadContext(); loadSelf(); for (int i = 0; i < scope.getRequiredArgs(); i++) { method.aload(StandardASMCompiler.ARGS_INDEX); method.invokestatic(script.getClassname(), methodName, getSignature()); method.areturn(); method.end();
@Override public void issueBreakEvent(CompilerCallback value) { if (currentLoopLabels != null) { value.call(this); issueLoopBreak(); } else if (inNestedMethod) { loadThreadContext(); value.call(this); invokeUtilityMethod("breakJump", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class)); } else { // in method body with no containing loop, issue jump error // load runtime and value, issue jump error loadRuntime(); value.call(this); invokeUtilityMethod("breakLocalJumpError", sig(IRubyObject.class, Ruby.class, IRubyObject.class)); } }
@Override public void issueRedoEvent() { if (currentLoopLabels != null) { issueLoopRedo(); } else if (inNestedMethod) { invokeUtilityMethod("redoJump", sig(IRubyObject.class)); } else { // in method body with no containing loop, issue jump error // load runtime and value, issue jump error loadRuntime(); invokeUtilityMethod("redoLocalJumpError", sig(IRubyObject.class, Ruby.class)); } }
@Override public void issueNextEvent(CompilerCallback value) { if (currentLoopLabels != null) { value.call(this); issueLoopNext(); } else if (inNestedMethod) { value.call(this); invokeUtilityMethod("nextJump", sig(IRubyObject.class, IRubyObject.class)); } else { // in method body with no containing loop, issue jump error // load runtime and value, issue jump error loadRuntime(); value.call(this); invokeUtilityMethod("nextLocalJumpError", sig(IRubyObject.class, Ruby.class, IRubyObject.class)); } }
public BodyCompiler startFileMethod(CompilerCallback args, StaticScope scope, ASTInspector inspector) { MethodBodyCompiler methodCompiler = new MethodBodyCompiler(this, "__file__", "__file__", inspector, scope, 0); assert reservedIndex == 0 : "__file__ scope index was not zero"; methodCompiler.beginMethod(args, scope); method.end(); if (methodCompiler.isSpecificArity()) {
@Override public void performReturn() { if (inRescue) { // returning from rescue, clear $! clearErrorInfo(); } // normal return for method body. return jump for within a begin/rescue/ensure if (inNestedMethod) { loadThreadContext(); invokeUtilityMethod("throwReturnJump", sig(IRubyObject.class, IRubyObject.class, ThreadContext.class)); } else { method.areturn(); } }
@Override protected void createVariableCompiler() { if (inspector == null) { variableCompiler = new HeapBasedVariableCompiler(this, method, scope, specificArity, StandardASMCompiler.ARGS_INDEX, getFirstTempIndex()); } else if (inspector.hasClosure() || inspector.hasScopeAwareMethods()) { variableCompiler = new HeapBasedVariableCompiler(this, method, scope, specificArity, StandardASMCompiler.ARGS_INDEX, getFirstTempIndex()); } else { variableCompiler = new StackBasedVariableCompiler(this, method, scope, specificArity, StandardASMCompiler.ARGS_INDEX, getFirstTempIndex()); } }
public BodyCompiler startMethod(String rubyName, String javaName, CompilerCallback args, StaticScope scope, ASTInspector inspector, int scopeIndex) { RootScopedBodyCompiler methodCompiler = new MethodBodyCompiler(this, rubyName, javaName, inspector, scope, scopeIndex); methodCompiler.beginMethod(args, scope); return methodCompiler; }