use of de.mirkosertic.bytecoder.core.BytecodeLinkedClass in project Bytecoder by mirkosertic.
the class JSSSAWriter method print.
private void print(InstanceOfExpression aValue) {
Value theValue = aValue.incomingDataFlows().get(0);
print("(");
print(theValue);
print(" == null ? false : ");
print(theValue);
print(".instanceOf(");
BytecodeUtf8Constant theConstant = aValue.getType().getConstant();
if (!theConstant.stringValue().startsWith("[")) {
BytecodeLinkedClass theLinkedClass = linkerContext.isLinkedOrNull(aValue.getType().getConstant());
print(JSWriterUtils.toClassName(theLinkedClass.getClassName()));
} else {
BytecodeLinkedClass theLinkedClass = linkerContext.resolveClass(BytecodeObjectTypeRef.fromRuntimeClass(Array.class));
print(JSWriterUtils.toClassName(theLinkedClass.getClassName()));
}
print(")");
print(")");
}
use of de.mirkosertic.bytecoder.core.BytecodeLinkedClass 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