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();
|
execute.endMethod();
|
||||||
|
|
||||||
// Write all functions:
|
// Write all functions:
|
||||||
|
|
||||||
for (SFunction function : functions) {
|
for (SFunction function : functions) {
|
||||||
function.write(writer, expressions);
|
function.write(writer, expressions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write a static field with Handle (function reference) for every function:
|
||||||
if (!functions.isEmpty()) {
|
if (!functions.isEmpty()) {
|
||||||
// write a reference to each function
|
|
||||||
for (SFunction function : functions) {
|
for (SFunction function : functions) {
|
||||||
writer.visitField(Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC,
|
writer.visitField(Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC,
|
||||||
"handle$" + function.name + "$" + function.parameters.size(),
|
function.getHandleStaticFieldName(),
|
||||||
Type.getDescriptor(MethodHandle.class),
|
Type.getDescriptor(MethodHandle.class),
|
||||||
null,
|
null,
|
||||||
null).visitEnd();
|
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);
|
WriterConstants.CLINIT, writer, expressions);
|
||||||
for (SFunction function : functions) {
|
for (SFunction function : functions) {
|
||||||
Handle handle = new Handle(Opcodes.H_INVOKESTATIC,
|
final Handle handle = new Handle(Opcodes.H_INVOKESTATIC,
|
||||||
CLASS_TYPE.getInternalName(),
|
CLASS_TYPE.getInternalName(),
|
||||||
function.name,
|
function.name,
|
||||||
function.method.method.getDescriptor(),
|
function.method.method.getDescriptor(),
|
||||||
false);
|
false);
|
||||||
clinit.push(handle);
|
clinit.push(handle);
|
||||||
clinit.putStatic(CLASS_TYPE,
|
clinit.putStatic(CLASS_TYPE,
|
||||||
"handle$" + function.name + "$" + function.parameters.size(),
|
function.getHandleStaticFieldName(),
|
||||||
Type.getType(MethodHandle.class));
|
Type.getType(MethodHandle.class));
|
||||||
}
|
}
|
||||||
clinit.returnValue();
|
clinit.returnValue();
|
||||||
clinit.endMethod();
|
clinit.endMethod();
|
||||||
}
|
}
|
||||||
// End writing the class and store the generated bytes.
|
|
||||||
|
|
||||||
|
// End writing the class and store the generated bytes:
|
||||||
writer.visitEnd();
|
writer.visitEnd();
|
||||||
bytes = writer.toByteArray();
|
bytes = writer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue