public String emitScope(IRScope scope, String name, int arity) { this.currentScope = scope; name = name + scope.getLineNumber(); jvm.pushmethod(name, arity); Tuple<Instr[], Map<Integer,Label[]>> t = scope.prepareForCompilation(); Instr[] instrs = t.a; Map<Integer, Label[]> jumpTable = t.b; IRBytecodeAdapter m = jvm.method(); for (int i = 0; i < instrs.length; i++) { Instr instr = instrs[i]; if (jumpTable.get(i) != null) { for (Label label : jumpTable.get(i)) m.mark(jvm.methodData().getLabel(label)); } visit(instr); } jvm.popmethod(); return name; }
public String emitScope(IRScope scope, String name, int arity) { this.currentScope = scope; name = name + scope.getLineNumber(); jvm.pushmethod(name, arity); Tuple<Instr[], Map<Integer,Label[]>> t = scope.prepareForCompilation(); Instr[] instrs = t.a; Map<Integer, Label[]> jumpTable = t.b; IRBytecodeAdapter m = jvm.method(); for (int i = 0; i < instrs.length; i++) { Instr instr = instrs[i]; if (jumpTable.get(i) != null) { for (Label label : jumpTable.get(i)) m.mark(jvm.methodData().getLabel(label)); } visit(instr); } jvm.popmethod(); return name; }
jvm.pushmethod(name, scope, signature, specificArity);
jvm.pushmethod(name, scope, signature, specificArity);
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(); }