use of de.mirkosertic.bytecoder.core.BytecodeMethodSignature in project Bytecoder by mirkosertic.
the class WASMSSAWriter method writeNewArray.
private void writeNewArray(Value aValue) {
String theMethodName = WASMWriterUtils.toMethodName(BytecodeObjectTypeRef.fromRuntimeClass(MemoryManager.class), "newArray", new BytecodeMethodSignature(BytecodeObjectTypeRef.fromRuntimeClass(Address.class), new BytecodeTypeRef[] { BytecodePrimitiveTypeRef.INT, BytecodePrimitiveTypeRef.INT, BytecodePrimitiveTypeRef.INT }));
print("(call $");
print(theMethodName);
// UNUSED argument
print(" (i32.const 0) ");
// Length
withDeeperIndent().writeValue(aValue);
// We also need the runtime class
print(" (get_global $jlrArray__runtimeClass)");
// Plus the vtable index
print(" (i32.const ");
print(idResolver.resolveVTableMethodByType(BytecodeObjectTypeRef.fromRuntimeClass(Array.class)));
print(")");
println(")");
}
use of de.mirkosertic.bytecoder.core.BytecodeMethodSignature in project Bytecoder by mirkosertic.
the class JSSSAWriter method print.
private void print(InvokeVirtualMethodExpression aValue) {
String theMethodName = aValue.getMethodName();
BytecodeMethodSignature theSignature = aValue.getSignature();
List<Value> theIncomingData = aValue.incomingDataFlows();
Value theTarget = theIncomingData.get(0);
List<Value> theArguments = theIncomingData.subList(1, theIncomingData.size());
BytecodeVirtualMethodIdentifier theMethodIdentifier = linkerContext.getMethodCollection().identifierFor(theMethodName, theSignature);
if (Objects.equals(aValue.getMethodName(), "invokeWithMagicBehindTheScenes")) {
print("(");
} else {
print(theTarget);
print(".");
print(JSWriterUtils.toMethodName(theMethodName, theSignature));
print("(");
}
print(theTarget);
for (Value theArgument : theArguments) {
print(",");
print(theArgument);
}
print(")");
}
use of de.mirkosertic.bytecoder.core.BytecodeMethodSignature in project Bytecoder by mirkosertic.
the class CompileTarget method compileToJS.
public CompileResult compileToJS(CompileOptions aOptions, Class aClass, String aMethodName, BytecodeMethodSignature aSignature) {
BytecodeLinkerContext theLinkerContext = new BytecodeLinkerContext(bytecodeLoader, aOptions.getLogger());
BytecodeLinkedClass theClassLinkedCass = theLinkerContext.resolveClass(BytecodeObjectTypeRef.fromRuntimeClass(Class.class));
theClassLinkedCass.resolveConstructorInvocation(new BytecodeMethodSignature(BytecodePrimitiveTypeRef.VOID, new BytecodeTypeRef[] {}));
// Lambda handling
BytecodeLinkedClass theCallsite = theLinkerContext.resolveClass(BytecodeObjectTypeRef.fromRuntimeClass(VM.ImplementingCallsite.class));
theCallsite.resolveVirtualMethod("invokeExact", new BytecodeMethodSignature(BytecodeObjectTypeRef.fromRuntimeClass(Object.class), new BytecodeTypeRef[] { new BytecodeArrayTypeRef(BytecodeObjectTypeRef.fromRuntimeClass(Object.class), 1) }));
BytecodeObjectTypeRef theTypeRef = BytecodeObjectTypeRef.fromRuntimeClass(aClass);
BytecodeLinkedClass theClass = theLinkerContext.resolveClass(theTypeRef);
BytecodeMethod theMethod = theClass.getBytecodeClass().methodByNameAndSignatureOrNull(aMethodName, aSignature);
if (theMethod.getAccessFlags().isStatic()) {
theClass.resolveStaticMethod(aMethodName, aSignature);
} else {
theClass.resolveVirtualMethod(aMethodName, aSignature);
}
// Before code generation we have to make sure that all abstract method implementations are linked correctly
aOptions.getLogger().info("Resolving abstract method hierarchy");
theLinkerContext.resolveAbstractMethodsInSubclasses();
return backend.generateCodeFor(aOptions, theLinkerContext, aClass, aMethodName, aSignature);
}
Aggregations