public void preMultiAssign(int head, boolean args) { // arrayish object is on stack, call utility and unpack if (head == 1 && args) { invokeUtilityMethod("arraySlice1N", sig(IRubyObject[].class, IRubyObject.class)); method.dup(); method.pushInt(1); method.aaload(); method.swap(); method.pushInt(0); method.aaload(); } else if (head == 1 && !args) { invokeUtilityMethod("arraySlice1", sig(IRubyObject.class, IRubyObject.class)); } else { throw new RuntimeException("invalid preMultiAssign args: " + head + ", " + args); } }
public void preMultiAssign(int head, boolean args) { // arrayish object is on stack, call utility and unpack if (head == 1 && args) { invokeUtilityMethod("arraySlice1N", sig(IRubyObject[].class, IRubyObject.class)); method.dup(); method.pushInt(1); method.aaload(); method.swap(); method.pushInt(0); method.aaload(); } else if (head == 1 && !args) { invokeUtilityMethod("arraySlice1", sig(IRubyObject.class, IRubyObject.class)); } else { throw new RuntimeException("invalid preMultiAssign args: " + head + ", " + args); } }
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(); }