public void emit(IRMethod method) { String name = emitScope(method, method.getName(), method.getCallArgs().length); // push a method handle for binding purposes jvm.method().pushHandle(jvm.clsData().clsName, name, method.getStaticScope().getRequiredArgs()); }
public void emit(IRMethod method) { String name = emitScope(method, method.getName(), method.getCallArgs().length); // push a method handle for binding purposes jvm.method().pushHandle(jvm.clsData().clsName, name, method.getStaticScope().getRequiredArgs()); }
public static void initiateNonLocalReturn(ThreadContext context, IRScope scope, IRMethod methodToReturnFrom, IRubyObject returnValue) { if (scope instanceof IRClosure) { if (methodToReturnFrom == null) { // SSS FIXME: As Tom correctly pointed out, this is not correct. The example that breaks this code is: // // jruby -X-CIR -e "Thread.new { Proc.new { return }.call }.join" // // This should report a LocalJumpError, not a ThreadError. // // The right fix would involve checking the closure to see who it is associated with. // If it is a thread-body, it would be a ThreadError. If not, it would be a local-jump-error // This requires having access to the block -- same requirement as in handleBreakJump. if (context.getThread() == context.runtime.getThreadService().getMainThread()) { throw IRException.RETURN_LocalJumpError.getException(context.runtime); } else { throw context.runtime.newThreadError("return can't jump across threads"); } } // Cannot return from the call that we have long since exited. if (!context.scopeExistsOnCallStack(methodToReturnFrom.getStaticScope())) { if (isDebug()) LOG.info("in scope: " + scope + ", raising unexpected return local jump error"); throw IRException.RETURN_LocalJumpError.getException(context.runtime); } } // methodtoReturnFrom will not be null for explicit returns from class/module/sclass bodies throw IRReturnJump.create(methodToReturnFrom, returnValue); }
public static void initiateNonLocalReturn(ThreadContext context, IRScope scope, IRMethod methodToReturnFrom, IRubyObject returnValue) { if (scope instanceof IRClosure) { if (methodToReturnFrom == null) { // SSS FIXME: As Tom correctly pointed out, this is not correct. The example that breaks this code is: // // jruby -X-CIR -e "Thread.new { Proc.new { return }.call }.join" // // This should report a LocalJumpError, not a ThreadError. // // The right fix would involve checking the closure to see who it is associated with. // If it is a thread-body, it would be a ThreadError. If not, it would be a local-jump-error // This requires having access to the block -- same requirement as in handleBreakJump. if (context.getThread() == context.runtime.getThreadService().getMainThread()) { throw IRException.RETURN_LocalJumpError.getException(context.runtime); } else { throw context.runtime.newThreadError("return can't jump across threads"); } } // Cannot return from the call that we have long since exited. if (!context.scopeExistsOnCallStack(methodToReturnFrom.getStaticScope())) { if (isDebug()) LOG.info("in scope: " + scope + ", raising unexpected return local jump error"); throw IRException.RETURN_LocalJumpError.getException(context.runtime); } } // methodtoReturnFrom will not be null for explicit returns from class/module/sclass bodies throw IRReturnJump.create(methodToReturnFrom, returnValue); }
private void emitWithSignatures(IRMethod method, JVMVisitorMethodContext context, String name) { context.setBaseName(name); Signature specificSig = signatureFor(method, true); if (specificSig == null) { // only varargs, so use name as is context.setVariableName(name); Signature signature = signatureFor(method, false); emitScope(method, name, signature, false, true); context.addNativeSignature(-1, signature.type()); } else { String specificName = name; context.setSpecificName(specificName); emitScope(method, specificName, specificSig, true, true); context.addNativeSignature(method.getStaticScope().getSignature().required(), specificSig.type()); // specific arity path, so mangle the dummy varargs wrapper String variableName = name + JavaNameMangler.VARARGS_MARKER; context.setVariableName(variableName); emitVarargsMethodWrapper(method, variableName, specificName, METHOD_SIGNATURE_VARARGS, specificSig); context.addNativeSignature(-1, METHOD_SIGNATURE_VARARGS.type()); } }
private void emitWithSignatures(IRMethod method, JVMVisitorMethodContext context, String name) { context.setBaseName(name); Signature specificSig = signatureFor(method, true); if (specificSig == null) { // only varargs, so use name as is context.setVariableName(name); Signature signature = signatureFor(method, false); emitScope(method, name, signature, false, true); context.addNativeSignature(-1, signature.type()); } else { String specificName = name; context.setSpecificName(specificName); emitScope(method, specificName, specificSig, true, true); context.addNativeSignature(method.getStaticScope().getSignature().required(), specificSig.type()); // specific arity path, so mangle the dummy varargs wrapper String variableName = name + JavaNameMangler.VARARGS_MARKER; context.setVariableName(variableName); emitVarargsMethodWrapper(method, variableName, specificName, METHOD_SIGNATURE_VARARGS, specificSig); context.addNativeSignature(-1, METHOD_SIGNATURE_VARARGS.type()); } }
@Override public void DefineInstanceMethodInstr(DefineInstanceMethodInstr defineinstancemethodinstr) { IRMethod method = defineinstancemethodinstr.getMethod(); StaticScope scope = method.getStaticScope(); if (scope.getRequiredArgs() > 3 || scope.getRestArg() >= 0 || scope.getOptionalArgs() != 0) { throw new RuntimeException("can't compile variable method: " + this);
@Override public void DefineInstanceMethodInstr(DefineInstanceMethodInstr defineinstancemethodinstr) { IRMethod method = defineinstancemethodinstr.getMethod(); StaticScope scope = method.getStaticScope(); if (scope.getRequiredArgs() > 3 || scope.getRestArg() >= 0 || scope.getOptionalArgs() != 0) { throw new RuntimeException("can't compile variable method: " + this);