diff --git a/bosk-core/src/main/java/io/vena/bosk/bytecode/ClassBuilder.java b/bosk-core/src/main/java/io/vena/bosk/bytecode/ClassBuilder.java index eead0dcc..54f6f70f 100644 --- a/bosk-core/src/main/java/io/vena/bosk/bytecode/ClassBuilder.java +++ b/bosk-core/src/main/java/io/vena/bosk/bytecode/ClassBuilder.java @@ -7,8 +7,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @@ -65,8 +63,6 @@ public final class ClassBuilder { private ClassWriter classWriter = null; private MethodBuilder currentMethod = null; - private final List curriedValues = new ArrayList<>(); - /** * @param className The simple name of the generated class; * the actual name will be given the prefix GENERATED_ to identify it as not corresponding to any source file @@ -183,17 +179,13 @@ public LocalVariable popToLocal(Type type) { * Emit code to push the given object on the operand stack. * * @param name purely descriptive; doesn't need to be unique - * @param type + * @param type the static type of the value (because the dynamic type might not + * be accessible from the generated class) */ public void pushObject(String name, Object object, Class type) { type.cast(object); String fullName = "CallSite_" + CALL_SITE_COUNT.incrementAndGet() + "_" + name; - CurriedValue result = new CurriedValue( - fullName, - Type.getDescriptor(type), - object); - curriedValues.add(result); CALL_SITES_BY_NAME.put(fullName, new ConstantCallSite(MethodHandles.constant(type, object))); LOGGER.warn("{} = {} {}", fullName, type.getSimpleName(), object); @@ -208,8 +200,8 @@ public void pushObject(String name, Object object, Class type) { )); */ methodVisitor().visitInvokeDynamicInsn( - result.name(), - "()" + result.typeDescriptor(), + fullName, + "()" + Type.getDescriptor(type), CONSTANT_CALL_SITE ); } @@ -392,7 +384,7 @@ public Class loadThemBytes(String dottyName, byte[] b) { private static final AtomicLong CALL_SITE_COUNT = new AtomicLong(0); private static final Map CALL_SITES_BY_NAME = new ConcurrentHashMap<>(); - public static CallSite constantCallSite(MethodHandles.Lookup lookup, String name, MethodType methodType) { + public static CallSite constantCallSite(MethodHandles.Lookup __, String name, MethodType ___) { LOGGER.warn("constantCallSite({})", name); return CALL_SITES_BY_NAME.remove(name); } diff --git a/bosk-core/src/main/java/io/vena/bosk/bytecode/CurriedValue.java b/bosk-core/src/main/java/io/vena/bosk/bytecode/CurriedValue.java deleted file mode 100644 index 7eaace94..00000000 --- a/bosk-core/src/main/java/io/vena/bosk/bytecode/CurriedValue.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.vena.bosk.bytecode; - -import lombok.Value; - -@Value -public class CurriedValue { - String name; - String typeDescriptor; - Object value; -}