Search in sources :

Example 1 with PHIExpression

use of de.mirkosertic.bytecoder.ssa.PHIExpression 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(")");
    }
}
Also used : Variable(de.mirkosertic.bytecoder.ssa.Variable) PHIExpression(de.mirkosertic.bytecoder.ssa.PHIExpression) StringValue(de.mirkosertic.bytecoder.ssa.StringValue) ByteValue(de.mirkosertic.bytecoder.ssa.ByteValue) Value(de.mirkosertic.bytecoder.ssa.Value) ClassReferenceValue(de.mirkosertic.bytecoder.ssa.ClassReferenceValue) FloatValue(de.mirkosertic.bytecoder.ssa.FloatValue) NullValue(de.mirkosertic.bytecoder.ssa.NullValue) DoubleValue(de.mirkosertic.bytecoder.ssa.DoubleValue) IntegerValue(de.mirkosertic.bytecoder.ssa.IntegerValue) LongValue(de.mirkosertic.bytecoder.ssa.LongValue) ShortValue(de.mirkosertic.bytecoder.ssa.ShortValue)

Aggregations

ByteValue (de.mirkosertic.bytecoder.ssa.ByteValue)1 ClassReferenceValue (de.mirkosertic.bytecoder.ssa.ClassReferenceValue)1 DoubleValue (de.mirkosertic.bytecoder.ssa.DoubleValue)1 FloatValue (de.mirkosertic.bytecoder.ssa.FloatValue)1 IntegerValue (de.mirkosertic.bytecoder.ssa.IntegerValue)1 LongValue (de.mirkosertic.bytecoder.ssa.LongValue)1 NullValue (de.mirkosertic.bytecoder.ssa.NullValue)1 PHIExpression (de.mirkosertic.bytecoder.ssa.PHIExpression)1 ShortValue (de.mirkosertic.bytecoder.ssa.ShortValue)1 StringValue (de.mirkosertic.bytecoder.ssa.StringValue)1 Value (de.mirkosertic.bytecoder.ssa.Value)1 Variable (de.mirkosertic.bytecoder.ssa.Variable)1