@@ -0,0 +1,2308 @@
+package konoha.asm;%0A%0Aimport java.lang.reflect.Type;%0Aimport java.util.Arrays;%0A%0Aimport konoha.script.Functor;%0Aimport konoha.script.Syntax;%0A%0Aimport org.objectweb.asm.Handle;%0Aimport org.objectweb.asm.commons.GeneratorAdapter;%0A%0A/**%0A * pseudo prototype for representing indy target%0A * %0A * @author skgchxngsxyz-osx%0A */%0Apublic class DynamicMember extends Prototype %7B%0A%09private final Syntax syntax;%0A%0A%09private static Type%5B%5D newParamTypes(int paramSize) %7B%0A%09%09Type%5B%5D types = new Type%5BparamSize%5D;%0A%09%09Arrays.fill(types, Object.class);%0A%09%09return types;%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 * @param syntax%0A%09 * @param name%0A%09 * @param paramSize%0A%09 *            not contains receiver%0A%09 */%0A%09DynamicMember(Syntax syntax, String name, int paramSize) %7B%0A%09%09/**%0A%09%09 * param types contains receiver%0A%09%09 */%0A%09%09super(%22dummy%22, Object.class, name, newParamTypes(paramSize + 1));%0A%09%09this.syntax = syntax;%0A%09%7D%0A%0A%09public static Functor newIndexGetter(String methodName) %7B%0A%09%09Syntax s = Syntax.Indexer;%0A%09%09return new Functor(s, new DynamicMember(s, methodName, 1));%0A%09%7D%0A%0A%09public static Functor newIndexSetter(String methodName) %7B%0A%09%09Syntax s = Syntax.SetIndexer;%0A%09%09return new Functor(s, new DynamicMember(s, methodName, 2));%0A%09%7D%0A%0A%09public static Functor newGetter(String fieldName) %7B%0A%09%09Syntax s = Syntax.Getter;%0A%09%09return new Functor(s, new DynamicMember(s, fieldName, 0));%0A%09%7D%0A%0A%09public static Functor newSetter(String fieldName) %7B%0A%09%09Syntax s = Syntax.Setter;%0A%09%09return new Functor(s, new DynamicMember(s, fieldName, 1));%0A%09%7D%0A%0A%09@Override%0A%09public void push(GeneratorAdapter adapter) %7B%0A%09%09Handle handle = null;%0A%09%09if (this.syntax == Syntax.Indexer %7C%7C this.syntax == Syntax.SetIndexer) %7B%0A%09%09%09handle = DynamicCallSite.bsmInstanceMethodHandle;%0A%09%09%7D else if (this.syntax == Syntax.Getter) %7B%0A%09%09%09handle = DynamicCallSite.bsmGetterHandle;%0A%09%09%7D else if (this.syntax == Syntax.Setter) %7B%0A%09%09%09handle = DynamicCallSite.bsmSetterHandle;%0A%09%09%7D else %7B%0A%09%09%09throw new RuntimeException(%22unsupported dynamic invocation: %22 + this.syntax);%0A%09%09%7D%0A%0A%09%09org.objectweb.asm.Type returnType = org.objectweb.asm.Type.getType(Object.class);%0A%09%09int paramSize = this.paramTypes.length;%0A%09%09org.objectweb.asm.Type%5B%5D paramTypes = new org.objectweb.asm.Type%5BparamSize%5D;%0A%09%09Arrays.fill(paramTypes, returnType);%0A%09%09adapter.invokeDynamic(this.name, org.objectweb.asm.Type.getMethodType(returnType, paramTypes).getDescriptor(), handle);%0A%09%7D%0A%7D%0A

add DynamicMember