use of de.mirkosertic.bytecoder.ssa.Value in project Bytecoder by mirkosertic.
the class WASMSSAWriter method writeInitVariableExpression.
private void writeInitVariableExpression(VariableAssignmentExpression aExpression) {
Variable theVariable = aExpression.getVariable();
Value theNewValue = aExpression.getValue();
if (theNewValue instanceof PHIExpression) {
return;
}
if (isStackVariable(theVariable)) {
switch(theVariable.resolveType().resolve()) {
case DOUBLE:
case FLOAT:
{
print("(f32.store offset=");
break;
}
case UNKNOWN:
throw new IllegalStateException();
default:
{
print("(i32.store offset=");
break;
}
}
print(stackOffsetFor(theVariable));
println(" (get_local $SP)");
WASMSSAWriter theChild = withDeeperIndent();
theChild.writeValue(theNewValue);
println();
println(")");
} else {
println(";; setting local variable with type " + theVariable.resolveType().resolve() + " with value of type " + theNewValue.resolveType().resolve());
print("(set_local $");
print(theVariable.getName());
println();
WASMSSAWriter theChild = withDeeperIndent();
theChild.writeValue(theNewValue);
println();
println(")");
}
}
use of de.mirkosertic.bytecoder.ssa.Value 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.ssa.Value in project Bytecoder by mirkosertic.
the class WASMSSAWriter method writeInvokeStaticValue.
private void writeInvokeStaticValue(InvokeStaticMethodExpression aValue) {
print("(call $");
print(WASMWriterUtils.toMethodName(aValue.getClassName(), aValue.getMethodName(), aValue.getSignature()));
// UNUSED Argument
print(" (i32.const 0)");
List<Value> theArguments = aValue.incomingDataFlows();
for (Value theValue : theArguments) {
print(" ");
writeValue(theValue);
}
print(")");
}
use of de.mirkosertic.bytecoder.ssa.Value in project Bytecoder by mirkosertic.
the class JSSSAWriter method print.
private void print(NewMultiArrayExpression aValue) {
BytecodeTypeRef theType = aValue.getType();
Object theDefaultValue = theType.defaultValue();
String theStrDefault = theDefaultValue != null ? theDefaultValue.toString() : "null";
print("bytecoder.newMultiArray(");
print("[");
List<Value> theDimensions = aValue.incomingDataFlows();
for (int i = 0; i < theDimensions.size(); i++) {
if (i > 0) {
print(",");
}
print(theDimensions.get(i));
}
print("]");
print(",");
print(theStrDefault);
print(")");
}
use of de.mirkosertic.bytecoder.ssa.Value in project Bytecoder by mirkosertic.
the class JSSSAWriter method print.
private void print(ArrayEntryExpression aValue) {
List<Value> theIncomingData = aValue.incomingDataFlows();
Value theArray = theIncomingData.get(0);
Value theIndex = theIncomingData.get(1);
print(theArray);
printArrayIndexReference(theIndex);
}
Aggregations