/** * Helper method to add a new method to a ClassNode. Depending on the shouldBeSynthetic flag the * call will either be made to ClassNode.addSyntheticMethod() or ClassNode.addMethod(). If a non-synthetic method * is to be added the ACC_SYNTHETIC modifier is removed if it has been accidentally supplied. */ protected MethodNode addMethod(ClassNode node, boolean shouldBeSynthetic, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { if (shouldBeSynthetic) { return node.addSyntheticMethod(name, modifiers, returnType, parameters, exceptions, code); } else { return node.addMethod(name, modifiers & ~ACC_SYNTHETIC, returnType, parameters, exceptions, code); } }
new Parameter(ClassHelper.OBJECT_TYPE, "args") }; MethodNode method = classNode.addSyntheticMethod( "this$dist$invoke$" + objectDistance, ACC_PUBLIC + ACC_SYNTHETIC, new Parameter(ClassHelper.OBJECT_TYPE, "value") }; method = classNode.addSyntheticMethod( "this$dist$set$" + objectDistance, ACC_PUBLIC + ACC_SYNTHETIC, new Parameter(ClassHelper.STRING_TYPE, "name") }; method = classNode.addSyntheticMethod( "this$dist$get$" + objectDistance, ACC_PUBLIC + ACC_SYNTHETIC,
staticMetaClassField.setSynthetic(true); node.addSyntheticMethod( "$getStaticMetaClass", ACC_PROTECTED,
node.addSyntheticMethod( name, mods, ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, methodCode);
/** * Helper method to add a new method to a ClassNode. Depending on the shouldBeSynthetic flag the * call will either be made to ClassNode.addSyntheticMethod() or ClassNode.addMethod(). If a non-synthetic method * is to be added the ACC_SYNTHETIC modifier is removed if it has been accidentally supplied. */ protected void addMethod(ClassNode node, boolean shouldBeSynthetic, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { if (shouldBeSynthetic) { node.addSyntheticMethod(name, modifiers, returnType, parameters, exceptions, code); } else { node.addMethod(name, modifiers & ~ACC_SYNTHETIC, returnType, parameters, exceptions, code); } }
/** * Helper method to add a new method to a ClassNode. Depending on the shouldBeSynthetic flag the * call will either be made to ClassNode.addSyntheticMethod() or ClassNode.addMethod(). If a non-synthetic method * is to be added the ACC_SYNTHETIC modifier is removed if it has been accidentally supplied. */ private void addMethod(ClassNode node, boolean shouldBeSynthetic, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { if (shouldBeSynthetic) { node.addSyntheticMethod(name,modifiers,returnType,parameters,exceptions,code); } else { node.addMethod(name,modifiers&~ACC_SYNTHETIC,returnType,parameters,exceptions,code); } }
new Parameter(ClassHelper.OBJECT_TYPE, "args") }; MethodNode method = classNode.addSyntheticMethod( "this$dist$invoke$" + objectDistance, ACC_PUBLIC + ACC_SYNTHETIC, new Parameter(ClassHelper.OBJECT_TYPE, "value") }; method = classNode.addSyntheticMethod( "this$dist$set$" + objectDistance, ACC_PUBLIC + ACC_SYNTHETIC, new Parameter(ClassHelper.STRING_TYPE, "name") }; method = classNode.addSyntheticMethod( "this$dist$get$" + objectDistance, ACC_PUBLIC + ACC_SYNTHETIC,
staticMetaClassField.setSynthetic(true); node.addSyntheticMethod( "$getStaticMetaClass", ACC_PROTECTED,
staticMetaClassField.setSynthetic(true); node.addSyntheticMethod( "$getStaticMetaClass", ACC_PROTECTED, node.addSyntheticMethod( "getMetaClass", ACC_PUBLIC | ACC_SYNTHETIC, node.addSyntheticMethod( "setMetaClass", ACC_PUBLIC, blockScope.putReferencedLocalVariable(vMethods); blockScope.putReferencedLocalVariable(vArguments); node.addSyntheticMethod( "invokeMethod", ACC_PUBLIC, node.addSyntheticMethod( "getProperty", ACC_PUBLIC, node.addSyntheticMethod( "setProperty", ACC_PUBLIC,
EmptyStatement.INSTANCE); node.addSyntheticMethod( "getMetaClass", ACC_PUBLIC, node.addSyntheticMethod( "setMetaClass", ACC_PUBLIC, node.addSyntheticMethod( "invokeMethod", ACC_PUBLIC, node.addSyntheticMethod( "getProperty", ACC_PUBLIC, }); node.addSyntheticMethod( "setProperty", ACC_PUBLIC,
staticMetaClassField.setSynthetic(true); node.addSyntheticMethod( "$getStaticMetaClass", ACC_PROTECTED,
String name = SWAP_INIT; BlockStatement methodCode = new BlockStatement(); node.addSyntheticMethod( name, mods, ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, methodCode);