use of de.mirkosertic.bytecoder.core.BytecodeResolvedFields in project Bytecoder by mirkosertic.
the class WASMSSAWriter method writePutFieldExpression.
private void writePutFieldExpression(PutFieldExpression aExpression) {
WASMMemoryLayouter.MemoryLayout theLayout = memoryLayouter.layoutFor(BytecodeObjectTypeRef.fromUtf8Constant(aExpression.getField().getClassIndex().getClassConstant().getConstant()));
int theMemoryOffset = theLayout.offsetForInstanceMember(aExpression.getField().getNameAndTypeIndex().getNameAndType().getNameIndex().getName().stringValue());
BytecodeLinkedClass theLinkedClass = linkerContext.resolveClass(BytecodeObjectTypeRef.fromUtf8Constant(aExpression.getField().getClassIndex().getClassConstant().getConstant()));
BytecodeResolvedFields theInstanceFields = theLinkedClass.resolvedFields();
BytecodeResolvedFields.FieldEntry theField = theInstanceFields.fieldByName(aExpression.getField().getNameAndTypeIndex().getNameAndType().getNameIndex().getName().stringValue());
switch(TypeRef.toType(theField.getValue().getTypeRef()).resolve()) {
case DOUBLE:
case FLOAT:
print("(f32.store offset=");
break;
default:
print("(i32.store offset=");
break;
}
print(theMemoryOffset);
println();
List<Value> theIncomingData = aExpression.incomingDataFlows();
WASMSSAWriter theChild = withDeeperIndent();
theChild.writeValue(theIncomingData.get(0));
theChild.writeValue(theIncomingData.get(1));
println(")");
}
use of de.mirkosertic.bytecoder.core.BytecodeResolvedFields in project Bytecoder by mirkosertic.
the class WASMSSAWriter method writeGetFieldValue.
private void writeGetFieldValue(GetFieldExpression aValue) {
BytecodeLinkedClass theLinkedClass = linkerContext.resolveClass(BytecodeObjectTypeRef.fromUtf8Constant(aValue.getField().getClassIndex().getClassConstant().getConstant()));
WASMMemoryLayouter.MemoryLayout theLayout = memoryLayouter.layoutFor(BytecodeObjectTypeRef.fromUtf8Constant(aValue.getField().getClassIndex().getClassConstant().getConstant()));
int theMemoryOffset = theLayout.offsetForInstanceMember(aValue.getField().getNameAndTypeIndex().getNameAndType().getNameIndex().getName().stringValue());
String theFieldName = aValue.getField().getNameAndTypeIndex().getNameAndType().getNameIndex().getName().stringValue();
BytecodeResolvedFields theInstanceFields = theLinkedClass.resolvedFields();
BytecodeResolvedFields.FieldEntry theField = theInstanceFields.fieldByName(theFieldName);
if (theField.getValue().getAccessFlags().isStatic()) {
throw new IllegalStateException("Field " + theFieldName + " is static!");
}
switch(TypeRef.toType(theField.getValue().getTypeRef()).resolve()) {
case DOUBLE:
case FLOAT:
print("(f32.load offset=");
break;
default:
print("(i32.load offset=");
break;
}
print(theMemoryOffset);
println();
WASMSSAWriter theChild = withDeeperIndent();
theChild.writeValue(aValue.incomingDataFlows().get(0));
println(")");
}
use of de.mirkosertic.bytecoder.core.BytecodeResolvedFields in project Bytecoder by mirkosertic.
the class OpenCLCompileBackend method fillInputOutputs.
private void fillInputOutputs(BytecodeLinkerContext aContext, BytecodeLinkedClass aKernelClass, ExpressionList aExpressionList, OpenCLInputOutputs aInputOutputs) {
BytecodeResolvedFields theInstanceFields = aKernelClass.resolvedFields();
theInstanceFields.streamForInstanceFields().forEach(aEntry -> {
aInputOutputs.registerReadFrom(aEntry);
aInputOutputs.registerWriteTo(aEntry);
});
}
Aggregations