More cleanup
This commit is contained in:
parent
65352face2
commit
c08b45a277
|
@ -166,4 +166,8 @@ public class SFunction extends AStatement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getHandleStaticFieldName() {
|
||||
return "handle$" + name + "$" + parameters.size();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,38 +154,37 @@ public final class SSource extends AStatement {
|
|||
execute.endMethod();
|
||||
|
||||
// Write all functions:
|
||||
|
||||
for (SFunction function : functions) {
|
||||
function.write(writer, expressions);
|
||||
}
|
||||
|
||||
// Write a static field with Handle (function reference) for every function:
|
||||
if (!functions.isEmpty()) {
|
||||
// write a reference to each function
|
||||
for (SFunction function : functions) {
|
||||
writer.visitField(Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC,
|
||||
"handle$" + function.name + "$" + function.parameters.size(),
|
||||
function.getHandleStaticFieldName(),
|
||||
Type.getDescriptor(MethodHandle.class),
|
||||
null,
|
||||
null).visitEnd();
|
||||
}
|
||||
MethodWriter clinit = new MethodWriter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC,
|
||||
final MethodWriter clinit = new MethodWriter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC,
|
||||
WriterConstants.CLINIT, writer, expressions);
|
||||
for (SFunction function : functions) {
|
||||
Handle handle = new Handle(Opcodes.H_INVOKESTATIC,
|
||||
final Handle handle = new Handle(Opcodes.H_INVOKESTATIC,
|
||||
CLASS_TYPE.getInternalName(),
|
||||
function.name,
|
||||
function.method.method.getDescriptor(),
|
||||
false);
|
||||
clinit.push(handle);
|
||||
clinit.putStatic(CLASS_TYPE,
|
||||
"handle$" + function.name + "$" + function.parameters.size(),
|
||||
function.getHandleStaticFieldName(),
|
||||
Type.getType(MethodHandle.class));
|
||||
}
|
||||
clinit.returnValue();
|
||||
clinit.endMethod();
|
||||
}
|
||||
// End writing the class and store the generated bytes.
|
||||
|
||||
// End writing the class and store the generated bytes:
|
||||
writer.visitEnd();
|
||||
bytes = writer.toByteArray();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue