private static Type[] toTypes(Class[] params) { Type[] types = new Type[params.length]; for (int i = 0; i < types.length; i++) { types[i] = Type.getType(params[i]); } return types; }
private static Type[] toTypes(Class[] params) { Type[] types = new Type[params.length]; for (int i = 0; i < types.length; i++) { types[i] = Type.getType(params[i]); } return types; }
private Type[] getType(Class[] parameterTypes) { Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = Type.getType(parameterTypes[i]); } return result; }
private static Type[] getType(Class[] parameterTypes) { Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = Type.getType(parameterTypes[i]); } return result; }
private void generateProxyMethods(Class superClass, Map<MethodKey, MethodData> methods, Type selfType, ClassVisitor cw, GeneratorAdapter clazzInit) { for (MethodData md: methods.values()) { Type superClassType = Type.getType(superClass); generateProxyMethod(selfType, superClassType, cw, clazzInit, md); } }
private static void generateProxyMethods(Class superClass, Map<MethodKey, MethodData> methods, Type selfType, ClassVisitor cw, GeneratorAdapter clazzInit) { for (MethodData md: methods.values()) { Type superClassType = Type.getType(superClass); generateProxyMethod(selfType, superClassType, cw, clazzInit, md); } }
public static final Type[] typesFromSignature(Signature signature) { Type[] types = new Type[signature.argCount()]; for (int i = 0; i < signature.argCount(); i++) { types[i] = Type.getType(signature.argType(i)); } return types; }
@Override public void PopBindingInstr(PopBindingInstr popbindinginstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void popScope()")); }
@Override public void PopMethodFrameInstr(PopMethodFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postMethodFrameOnly()")); }
@Override public void PushBackrefFrameInstr(PushBackrefFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preBackrefMethod()")); }
@Override public void PopBackrefFrameInstr(PopBackrefFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postBackrefMethod()")); }
@Override public void PushBackrefFrameInstr(PushBackrefFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preBackrefMethod()")); }
public MethodData(IRBytecodeAdapter method, IRScope scope, Signature signature, int specificArity) { this.method = method; this.scope = scope; this.signature = signature; this.specificArity = specificArity; // incoming arguments for (int i = 0; i < signature.argCount(); i++) { local("$" + signature.argName(i), Type.getType(signature.argType(i))); } // TODO: this should go into the PushBinding instruction local("$dynamicScope"); }
public JavaProxyClass newProxyClass(final Ruby runtime, ClassDefiningClassLoader loader, String targetClassName, Class superClass, Class[] interfaces, Set<String> names) throws InvocationTargetException { if (targetClassName == null) { targetClassName = targetClassName(superClass); } validateArgs(runtime, targetClassName, superClass); Type selfType = Type.getType('L' + toInternalClassName(targetClassName) + ';'); Map<MethodKey, MethodData> methods = collectMethods(superClass, interfaces, names); return generate(loader, targetClassName, superClass, interfaces, methods, selfType); }
@Override public void PopBackrefFrameInstr(PopBackrefFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postBackrefMethod()")); }
@Override public void BlockGivenInstr(BlockGivenInstr blockGivenInstr) { jvm.method().loadRuntime(); visit(blockGivenInstr.getBlockArg()); jvm.method().invokeVirtual(Type.getType(Block.class), Method.getMethod("boolean isGiven()")); jvm.method().invokeVirtual(Type.getType(Ruby.class), Method.getMethod("org.jruby.RubyBoolean newBoolean(boolean)")); jvmStoreLocal(blockGivenInstr.getResult()); }
@Override public void BlockGivenInstr(BlockGivenInstr blockGivenInstr) { jvm.method().loadRuntime(); visit(blockGivenInstr.getBlockArg()); jvm.method().invokeVirtual(Type.getType(Block.class), Method.getMethod("boolean isGiven()")); jvm.method().invokeVirtual(Type.getType(Ruby.class), Method.getMethod("org.jruby.RubyBoolean newBoolean(boolean)")); jvmStoreLocal(blockGivenInstr.getResult()); }
public void pushmethod(String name, IRScope scope, Signature signature, boolean specificArity) { Method m = new Method(name, Type.getType(signature.type().returnType()), IRRuntimeHelpers.typesFromSignature(signature)); SkinnyMethodAdapter adapter = new SkinnyMethodAdapter(cls, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, m.getName(), m.getDescriptor(), null, null); methodStack.push( new MethodData( new IRBytecodeAdapter6(adapter, signature, this), scope, signature, specificArity ? scope.getStaticScope().getSignature().required() : -1) ); } }
@Override public void CheckArgsArrayArityInstr(CheckArgsArrayArityInstr checkargsarrayarityinstr) { jvmMethod().loadContext(); visit(checkargsarrayarityinstr.getArgsArray()); jvmAdapter().pushInt(checkargsarrayarityinstr.required); jvmAdapter().pushInt(checkargsarrayarityinstr.opt); jvmAdapter().pushBoolean(checkargsarrayarityinstr.rest); jvmMethod().invokeStatic(Type.getType(Helpers.class), Method.getMethod("void irCheckArgsArrayArity(org.jruby.runtime.ThreadContext, org.jruby.RubyArray, int, int, boolean)")); }
@Override public void ConstMissingInstr(ConstMissingInstr constmissinginstr) { visit(constmissinginstr.getReceiver()); jvm.method().adapter.checkcast("org/jruby/RubyModule"); jvm.method().loadContext(); jvm.method().adapter.ldc("const_missing"); jvm.method().pushSymbol(constmissinginstr.getMissingConst()); jvm.method().invokeVirtual(Type.getType(RubyModule.class), Method.getMethod("org.jruby.runtime.builtin.IRubyObject callMethod(org.jruby.runtime.ThreadContext, java.lang.String, org.jruby.runtime.builtin.IRubyObject)")); }