private void implementConstructor(ClassNode shimClassNode) { MethodNode mn = new MethodNode(ACC_PUBLIC, CONSTRUCTOR_NAME, NOTHING_TO_VOID, null, null); InstructionBuilder builder = newBuilder(mn); builder.loadThis().invokeConstructor(PlasticClassHandleShim.class).returnResult(); shimClassNode.methods.add(mn); }
private void implementConstructor(ClassNode shimClassNode) { MethodNode mn = new MethodNode(ACC_PUBLIC, CONSTRUCTOR_NAME, NOTHING_TO_VOID, null, null); InstructionBuilder builder = newBuilder(mn); builder.loadThis().invokeConstructor(PlasticClassHandleShim.class).returnResult(); shimClassNode.methods.add(mn); }
builder.loadArgument(1); builder.loadArgument(2); builder.invokeConstructor(AbstractMethodInvocation.class, Object.class, InstanceContext.class, MethodInvocationBundle.class);
builder.loadArgument(1); builder.loadArgument(2); builder.invokeConstructor(AbstractMethodInvocation.class, Object.class, InstanceContext.class, MethodInvocationBundle.class);
constructorBuilder.invokeConstructor(superClassName, StaticContext.class.getName(), InstanceContext.class.getName()); } else constructorBuilder.loadThis().invokeConstructor(superClassName);
constructorBuilder.invokeConstructor(superClassName, StaticContext.class.getName(), InstanceContext.class.getName()); } else constructorBuilder.loadThis().invokeConstructor(superClassName);
builder.invokeConstructor(invocationClassName, constructorTypes);
builder.invokeConstructor(invocationClassName, constructorTypes);
private Type implementListConstructor(InstructionBuilder builder, Tree listNode) { // First, create an empty instance of ArrayList int count = listNode.getChildCount(); builder.newInstance(ArrayList.class); builder.dupe().loadConstant(count).invokeConstructor(ArrayList.class, int.class); for (int i = 0; i < count; i++) { builder.dupe(); // the ArrayList Type expressionType = implementSubexpression(builder, null, listNode.getChild(i)); boxIfPrimitive(builder, GenericsUtils.asClass(expressionType)); // Add the value to the array, then pop off the returned boolean builder.invoke(ArrayListMethods.ADD).pop(); } return ArrayList.class; }
private Type implementMapConstructor(InstructionBuilder builder, Tree mapNode) { int count = mapNode.getChildCount(); builder.newInstance(HashMap.class); builder.dupe().loadConstant(count).invokeConstructor(HashMap.class, int.class); for (int i = 0; i < count; i += 2) { builder.dupe(); //build the key: Type keyType = implementSubexpression(builder, null, mapNode.getChild(i)); boxIfPrimitive(builder, GenericsUtils.asClass(keyType)); //and the value: Type valueType = implementSubexpression(builder, null, mapNode.getChild(i + 1)); boxIfPrimitive(builder, GenericsUtils.asClass(valueType)); //put the value into the array, then pop off the returned object. builder.invoke(HashMapMethods.PUT).pop(); } return HashMap.class; }