use of de.mirkosertic.bytecoder.core.BytecodeTypeRef in project Bytecoder by mirkosertic.
the class JSWriterUtils method toMethodName.
public static String toMethodName(String aMethodName, BytecodeMethodSignature aSignature) {
String theName = typeRefToString(aSignature.getReturnType());
theName += aMethodName.replace("<", "").replace(">", "");
for (BytecodeTypeRef theTypeRef : aSignature.getArguments()) {
theName += typeRefToString(theTypeRef);
}
return theName;
}
use of de.mirkosertic.bytecoder.core.BytecodeTypeRef 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