From 46ffa81633c6f98b9f45944e885a12beb2a2b2dc Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Sun, 15 Oct 2017 22:39:50 +0200 Subject: [PATCH] Added operator precedence to constant printing - avoiding unnecesary perenthesis --- .../dk/camelot64/kickc/asm/AsmFragment.java | 4 +- .../java/dk/camelot64/kickc/icl/Operator.java | 93 +++++++++++- .../passes/ParseTreeConstantEvaluator.java | 4 +- .../Pass1GenerateStatementSequence.java | 18 +-- .../Pass2ConstantAdditionElimination.java | 20 +-- .../passes/Pass2UnaryNotSimplification.java | 2 +- .../kickc/passes/Pass4CodeGeneration.java | 28 ++-- .../dk/camelot64/kickc/test/TestIclJson.java | 136 ------------------ .../dk/camelot64/kickc/test/ref/bresenham.asm | 4 +- .../dk/camelot64/kickc/test/ref/bresenham.log | 24 ++-- .../camelot64/kickc/test/ref/bresenhamarr.asm | 2 +- .../camelot64/kickc/test/ref/bresenhamarr.log | 12 +- .../camelot64/kickc/test/ref/constantmin.asm | 2 +- .../camelot64/kickc/test/ref/constantmin.log | 12 +- .../camelot64/kickc/test/ref/flipper-rex2.asm | 4 +- .../camelot64/kickc/test/ref/flipper-rex2.log | 32 ++--- 16 files changed, 174 insertions(+), 223 deletions(-) delete mode 100644 src/main/java/dk/camelot64/kickc/test/TestIclJson.java diff --git a/src/main/java/dk/camelot64/kickc/asm/AsmFragment.java b/src/main/java/dk/camelot64/kickc/asm/AsmFragment.java index bab20e064..f55c42721 100644 --- a/src/main/java/dk/camelot64/kickc/asm/AsmFragment.java +++ b/src/main/java/dk/camelot64/kickc/asm/AsmFragment.java @@ -394,7 +394,9 @@ public class AsmFragment { } } else if (boundValue instanceof Constant) { Constant boundConst = (Constant) boundValue; - return new AsmParameter(Pass4CodeGeneration.getConstantValueAsm(program, boundConst, false), SymbolTypeBasic.BYTE.equals(boundConst.getType(program.getScope()))); + String constantValueAsm = Pass4CodeGeneration.getConstantValueAsm(program, boundConst, 99); + boolean constantValueZp = SymbolTypeBasic.BYTE.equals(boundConst.getType(program.getScope())); + return new AsmParameter(constantValueAsm, constantValueZp); } else if (boundValue instanceof Label) { String param = ((Label) boundValue).getLocalName().replace('@', 'b').replace(':', '_').replace("$", "_"); return new AsmParameter(param, false); diff --git a/src/main/java/dk/camelot64/kickc/icl/Operator.java b/src/main/java/dk/camelot64/kickc/icl/Operator.java index 4afb3d920..a0b33e699 100644 --- a/src/main/java/dk/camelot64/kickc/icl/Operator.java +++ b/src/main/java/dk/camelot64/kickc/icl/Operator.java @@ -8,25 +8,106 @@ public class Operator { private String operator; - @JsonCreator - public Operator( - @JsonProperty("operator") String operator) { + private int precedence; + + private Type type; + + public Operator(String operator, Type type, int precedence) { this.operator = operator; + this.precedence = precedence; } + public static Operator getBinary(String op) { + switch (op) { + case "+": + return PLUS; + case "-": + return MINUS; + case "*": + return MULTIPLY; + case "/": + return DIVIDE; + case "==": + return EQ; + case "!=": + return NEQ; + case "<": + return LT; + case "<=": + return LE; + case ">": + return GT; + case ">=": + return GE; + case "*idx": + return STAR_IDX; + default: + throw new RuntimeException("Unknown operator " + op); + } + } + + public static Operator getUnary(String op) { + switch (op) { + case "+": + return UNARY_PLUS; + case "-": + return UNARY_MINUS; + case "++": + return INCREMENT; + case "--": + return DECREMENT; + case "!": + return NOT; + case "*": + return STAR; + default: + throw new RuntimeException("Unknown operator " + op); + } + } + + public static enum Type { + UNARY, BINARY + } + + public static Operator INCREMENT = new Operator("++", Type.UNARY, 1); + public static Operator DECREMENT = new Operator("--", Type.UNARY, 1); + public static Operator UNARY_PLUS = new Operator("+", Type.UNARY, 2); + public static Operator UNARY_MINUS = new Operator("-", Type.UNARY, 2); + public static Operator NOT = new Operator("!", Type.UNARY, 2); + public static Operator STAR = new Operator("*", Type.UNARY, 2); + public static Operator STAR_IDX = new Operator("*idx", Type.BINARY, 2); + public static Operator MULTIPLY = new Operator("*", Type.BINARY, 3); + public static Operator DIVIDE = new Operator("/", Type.BINARY, 3); + public static Operator PLUS = new Operator("+", Type.BINARY, 4); + public static Operator MINUS = new Operator("-", Type.BINARY, 4); + public static Operator LT = new Operator("<", Type.BINARY, 6); + public static Operator LE = new Operator("<=", Type.BINARY, 6); + public static Operator GT = new Operator(">", Type.BINARY, 6); + public static Operator GE = new Operator(">=", Type.BINARY, 6); + public static Operator EQ = new Operator("==", Type.BINARY, 7); + public static Operator NEQ = new Operator("!=", Type.BINARY, 7); + public String getOperator() { return operator; } + public int getPrecedence() { + return precedence; + } + @Override public String toString() { - return operator ; + return operator; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Operator operator1 = (Operator) o; return operator != null ? operator.equals(operator1.operator) : operator1.operator == null; } diff --git a/src/main/java/dk/camelot64/kickc/passes/ParseTreeConstantEvaluator.java b/src/main/java/dk/camelot64/kickc/passes/ParseTreeConstantEvaluator.java index 887cf1a66..10fcecbd7 100644 --- a/src/main/java/dk/camelot64/kickc/passes/ParseTreeConstantEvaluator.java +++ b/src/main/java/dk/camelot64/kickc/passes/ParseTreeConstantEvaluator.java @@ -78,7 +78,7 @@ public class ParseTreeConstantEvaluator extends KickCBaseVisitor { public Constant visitExprUnary(KickCParser.ExprUnaryContext ctx) { Constant sub = visit(ctx.expr()); String op = ((TerminalNode)ctx.getChild(0)).getSymbol().getText(); - Operator operator = new Operator(op); + Operator operator = Operator.getUnary(op); return calculateUnary(operator, sub); } @@ -87,7 +87,7 @@ public class ParseTreeConstantEvaluator extends KickCBaseVisitor { Constant left = this.visit(ctx.expr(0)); Constant right = this.visit(ctx.expr(1)); String op = ((TerminalNode)ctx.getChild(1)).getSymbol().getText(); - Operator operator = new Operator(op); + Operator operator = Operator.getBinary(op); return calculateBinary(operator, left, right); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java index 35250ca37..204fe0165 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java @@ -84,7 +84,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { PrePostModifierHandler.addPreModifiers(this, ctx.expr()); RValue rValue = (RValue) this.visit(ctx.expr()); VariableRef notExprVar = getCurrentSymbols().addVariableIntermediate().getRef(); - sequence.addStatement(new StatementAssignment(notExprVar, null, new Operator("!"), rValue)); + sequence.addStatement(new StatementAssignment(notExprVar, null, Operator.NOT, rValue)); PrePostModifierHandler.addPostModifiers(this, ctx.expr()); Label elseJumpLabel = getCurrentSymbols().addLabelIntermediate(); @@ -234,7 +234,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { // Add increment ConstantInteger beyondLastVal; if(rangeFirst.getNumber()>rangeLast.getNumber()) { - Statement stmtInc = new StatementAssignment(lValue.getRef(), new Operator("--"), lValue.getRef()); + Statement stmtInc = new StatementAssignment(lValue.getRef(), Operator.DECREMENT, lValue.getRef()); sequence.addStatement(stmtInc); if(rangeLast.getNumber()==0) { beyondLastVal = new ConstantInteger(255); @@ -242,7 +242,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { beyondLastVal = new ConstantInteger(rangeLast.getNumber()-1); } } else { - Statement stmtInc = new StatementAssignment(lValue.getRef(), new Operator("++"), lValue.getRef()); + Statement stmtInc = new StatementAssignment(lValue.getRef(), Operator.INCREMENT, lValue.getRef()); sequence.addStatement(stmtInc); if(rangeLast.getNumber()==255) { beyondLastVal = new ConstantInteger(0); @@ -254,7 +254,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { // Add condition i { RValue left = (RValue) this.visit(ctx.expr(0)); RValue right = (RValue) this.visit(ctx.expr(1)); String op = ((TerminalNode) ctx.getChild(1)).getSymbol().getText(); - Operator operator = new Operator(op); + Operator operator = Operator.getBinary(op); VariableIntermediate tmpVar = getCurrentSymbols().addVariableIntermediate(); VariableRef tmpVarRef = tmpVar.getRef(); Statement stmt = new StatementAssignment(tmpVarRef, left, operator, right); @@ -507,7 +507,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { public RValue visitExprUnary(KickCParser.ExprUnaryContext ctx) { RValue child = (RValue) this.visit(ctx.expr()); String op = ((TerminalNode) ctx.getChild(0)).getSymbol().getText(); - Operator operator = new Operator(op); + Operator operator = Operator.getUnary(op); VariableIntermediate tmpVar = getCurrentSymbols().addVariableIntermediate(); VariableRef tmpVarRef = tmpVar.getRef(); Statement stmt = new StatementAssignment(tmpVarRef, operator, child); @@ -594,7 +594,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { public Void visitExprPostMod(KickCParser.ExprPostModContext ctx) { RValue child = (RValue) mainParser.visit(ctx.expr()); String op = ((TerminalNode) ctx.getChild(1)).getSymbol().getText(); - Operator operator = new Operator(op); + Operator operator = Operator.getUnary(op); PrePostModifier modifier = new PrePostModifier(child, operator); postMods.add(modifier); return null; @@ -604,7 +604,7 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { public Void visitExprPreMod(KickCParser.ExprPreModContext ctx) { RValue child = (RValue) mainParser.visit(ctx.expr()); String op = ((TerminalNode) ctx.getChild(0)).getSymbol().getText(); - Operator operator = new Operator(op); + Operator operator = Operator.getUnary(op); PrePostModifier modifier = new PrePostModifier(child, operator); preMods.add(modifier); return null; diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantAdditionElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantAdditionElimination.java index 4c9ed5fd9..e4139908d 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantAdditionElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantAdditionElimination.java @@ -64,7 +64,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { if(pointerDereferenceIndexed.getPointer() instanceof Constant && pointerDereferenceIndexed.getIndex() instanceof Constant) { Constant ptrConstant = (Constant) pointerDereferenceIndexed.getPointer(); Constant idxConstant = (Constant) pointerDereferenceIndexed.getIndex(); - Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), idxConstant); + Constant newPtr = new ConstantBinary(ptrConstant, Operator.PLUS, idxConstant); assignment.setlValue(new PointerDereferenceSimple(newPtr)); getLog().append("Consolidated assigned array index constant in assignment " + assignment.getlValue()); return true; @@ -74,7 +74,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { Constant consolidated = consolidateSubConstants(variable); if (consolidated != null) { Constant ptrConstant = (Constant) pointerDereferenceIndexed.getPointer(); - Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), consolidated); + Constant newPtr = new ConstantBinary(ptrConstant, Operator.PLUS, consolidated); pointerDereferenceIndexed.setPointer(newPtr); getLog().append("Consolidated assigned array index constant in assignment " + assignment.getlValue()); return true; @@ -87,9 +87,9 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { if (assignment.getrValue1() instanceof Constant && assignment.getrValue2() instanceof Constant) { Constant ptrConstant = (Constant) assignment.getrValue1(); Constant idxConstant = (Constant) assignment.getrValue2(); - Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), idxConstant); + Constant newPtr = new ConstantBinary(ptrConstant, Operator.PLUS, idxConstant); assignment.setrValue1(null); - assignment.setOperator(new Operator("*")); + assignment.setOperator(Operator.STAR); assignment.setrValue2(newPtr); getLog().append("Consolidated referenced array index constant in assignment " + assignment.getlValue()); return true; @@ -99,7 +99,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { Constant consolidated = consolidateSubConstants(variable); if (consolidated != null) { Constant ptrConstant = (Constant) assignment.getrValue1(); - Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), consolidated); + Constant newPtr = new ConstantBinary(ptrConstant, Operator.PLUS, consolidated); assignment.setrValue1(newPtr); getLog().append("Consolidated referenced array index constant in assignment " + assignment.getlValue()); return true; @@ -114,7 +114,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { Constant consolidated = consolidateSubConstants(variable); if (consolidated != null) { Constant const1 = (Constant) assignment.getrValue1(); - assignment.setrValue1(new ConstantBinary(const1, new Operator("+"), consolidated)); + assignment.setrValue1(new ConstantBinary(const1, Operator.PLUS, consolidated)); getLog().append("Consolidated constant in assignment " + assignment.getlValue()); return true; } @@ -123,7 +123,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { Constant consolidated = consolidateSubConstants(variable); if (consolidated != null) { Constant const2 = (Constant) assignment.getrValue2(); - Constant newNumber = new ConstantBinary(consolidated, new Operator("+"), const2); + Constant newNumber = new ConstantBinary(consolidated, Operator.PLUS, const2); assignment.setrValue2(newNumber); // Handling of negative consolidated numbers? getLog().append("Consolidated constant in assignment " + assignment.getlValue()); @@ -170,7 +170,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { if (const1 != null) { result = const1; if (const2 != null) { - result = new ConstantBinary(const1, new Operator("+"), const2); + result = new ConstantBinary(const1, Operator.PLUS, const2); } } else if (const2 != null) { result = const2; @@ -188,7 +188,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { assignment.setrValue2(assignment.getrValue1()); assignment.setOperator(null); assignment.setrValue1(null); - return new ConstantUnary(new Operator("-"), constant); + return new ConstantUnary(Operator.MINUS, constant); } else { Constant const1 = null; if (assignment.getrValue1() instanceof VariableRef) { @@ -202,7 +202,7 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization { if (const1 != null) { result = const1; if (const2 != null) { - result = new ConstantBinary(const1, new Operator("-"),const2); + result = new ConstantBinary(const1, Operator.MINUS,const2); } } else if (const2 != null) { result = const2; diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2UnaryNotSimplification.java b/src/main/java/dk/camelot64/kickc/passes/Pass2UnaryNotSimplification.java index 6a602e019..293dc1980 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass2UnaryNotSimplification.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2UnaryNotSimplification.java @@ -96,7 +96,7 @@ public class Pass2UnaryNotSimplification extends Pass2SsaOptimization { */ private void createInverse(String newOperator, StatementAssignment assignment, StatementAssignment tempAssignment) { assignment.setrValue1(tempAssignment.getrValue1()); - assignment.setOperator(newOperator==null?null:new Operator(newOperator)); + assignment.setOperator(newOperator==null?null:Operator.getBinary(newOperator)); assignment.setrValue2(tempAssignment.getrValue2()); getLog().append("Inversing boolean not "+assignment.toString(getProgram()) +" from "+tempAssignment.toString(getProgram())); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index 8845da401..08fb01ac5 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -91,7 +91,7 @@ public class Pass4CodeGeneration { for (ConstantVar constantVar : scopeConstants) { String asmName = constantVar.getAsmName() == null ? constantVar.getLocalName() : constantVar.getAsmName(); if (asmName != null && !added.contains(asmName)) { - asm.addConstant(asmName.replace("#", "_").replace("$", "_"), getConstantValueAsm(program, constantVar.getValue(), false)); + asm.addConstant(asmName.replace("#", "_").replace("$", "_"), getConstantValueAsm(program, constantVar.getValue(), 99)); added.add(asmName); } } @@ -101,11 +101,11 @@ public class Pass4CodeGeneration { * Get ASM code for a constant value * * @param value The constant value - * @param subOperator is this generated inside another operator (needing a parenthesis) + * @param precedence The precedence of the outer expression operator. Used to generate perenthesis when needed. * * @return The ASM string representing the constant value */ - public static String getConstantValueAsm(Program program, Constant value, boolean subOperator) { + public static String getConstantValueAsm(Program program, Constant value, int precedence) { if (value instanceof ConstantRef) { value = program.getScope().getConstant((ConstantRef) value); } @@ -117,19 +117,23 @@ public class Pass4CodeGeneration { return String.format("$%x", ((ConstantInteger) value).getNumber()); } else if (value instanceof ConstantUnary) { ConstantUnary unary = (ConstantUnary) value; + Operator operator = unary.getOperator(); + boolean parenthesis = operator.getPrecedence()>precedence; return - (subOperator ? "(" : "") + - unary.getOperator().getOperator() + - getConstantValueAsm(program, unary.getOperand(), true) + - (subOperator ? ")" : ""); + (parenthesis ? "(" : "") + + operator.getOperator() + + getConstantValueAsm(program, unary.getOperand(), operator.getPrecedence()) + + (parenthesis? ")" : ""); } else if (value instanceof ConstantBinary) { ConstantBinary binary = (ConstantBinary) value; + Operator operator = binary.getOperator(); + boolean parenthesis = operator.getPrecedence()>precedence; return - (subOperator ? "(" : "") + - getConstantValueAsm(program, binary.getLeft(), true) + - binary.getOperator().getOperator() + - getConstantValueAsm(program, binary.getRight(), true) + - (subOperator ? ")" : ""); + (parenthesis? "(" : "") + + getConstantValueAsm(program, binary.getLeft(), operator.getPrecedence()) + + operator.getOperator() + + getConstantValueAsm(program, binary.getRight(), operator.getPrecedence()) + + (parenthesis? ")" : ""); } else { throw new RuntimeException("Constant type not supported " + value); } diff --git a/src/main/java/dk/camelot64/kickc/test/TestIclJson.java b/src/main/java/dk/camelot64/kickc/test/TestIclJson.java deleted file mode 100644 index e2e9f33df..000000000 --- a/src/main/java/dk/camelot64/kickc/test/TestIclJson.java +++ /dev/null @@ -1,136 +0,0 @@ -package dk.camelot64.kickc.test; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.ObjectWriter; -import dk.camelot64.kickc.CompileLog; -import dk.camelot64.kickc.Compiler; -import dk.camelot64.kickc.icl.*; -import dk.camelot64.kickc.icl.jackson.IclJacksonFactory; -import dk.camelot64.kickc.parser.KickCParser; -import junit.framework.TestCase; -import org.antlr.v4.runtime.ANTLRInputStream; - -import java.io.IOException; -import java.util.ArrayList; - -/** Test JSON serialization of the KickC ICL */ -public class TestIclJson extends TestCase { - - public void testJsonVariable() throws IOException { - VariableUnversioned v1 = new VariableUnversioned("v1", null, SymbolTypeBasic.BYTE); - String json = "{\"@type\":\"variable_unversioned\",\"name\":\"v1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":0,\"inferredType\":false}"; - assertJsonSerialization(v1, json, Variable.class); - } - - public void testJsonScopeSimple() throws IOException { - Scope scope = new ProgramScope(); - VariableUnversioned v1 = scope.addVariable("v1", SymbolTypeBasic.BYTE); - v1.createVersion(); - scope.addVariableIntermediate(); - scope.addVariable("v2", new SymbolTypePointer(SymbolTypeBasic.BYTE)); - scope.addVariable("v3", new SymbolTypeArray(SymbolTypeBasic.WORD, 4)); - scope.addLabel("main"); - scope.addLabelIntermediate(); - String json = "{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"v1\":{\"@type\":\"variable_unversioned\",\"name\":\"v1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"v1#0\":{\"@type\":\"variable_versioned\",\"name\":\"v1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"v1\",\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"var\"},\"inferredType\":false},\"v2\":{\"@type\":\"variable_unversioned\",\"name\":\"v2\",\"type\":{\"@type\":\"pointer\",\"elementType\":{\"@type\":\"basic\",\"typeName\":\"byte\"}},\"nextVersionNumber\":0,\"inferredType\":false},\"v3\":{\"@type\":\"variable_unversioned\",\"name\":\"v3\",\"type\":{\"@type\":\"array\",\"elementType\":{\"@type\":\"basic\",\"typeName\":\"word\"},\"size\":4},\"nextVersionNumber\":0,\"inferredType\":false},\"main\":{\"@type\":\"label\",\"name\":\"main\",\"intermediate\":false},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true}},\"intermediateVarCount\":1,\"intermediateLabelCount\":2,\"allocation\":null,\"liveRangeVariables\":null,\"liveRangeEquivalenceClassSet\":null,\"variableRegisterWeights\":null}"; - assertJsonSerialization(scope, json, Scope.class); - } - - public void testJsonScopeProcedure() throws IOException { - Scope scope = new ProgramScope(); - Procedure procedure = scope.addProcedure("main", SymbolTypeBasic.VOID); - procedure.addVariable("v2", SymbolTypeBasic.BYTE); - ArrayList parameters = new ArrayList<>(); - parameters.add(new VariableUnversioned("p1", procedure, SymbolTypeBasic.BYTE)); - parameters.add(new VariableUnversioned("p2", procedure, SymbolTypeBasic.BOOLEAN)); - procedure.setParameters(parameters); - String json = "{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"main\":{\"@type\":\"procedure\",\"name\":\"main\",\"parameterNames\":[\"p1\",\"p2\"],\"symbols\":{\"v2\":{\"@type\":\"variable_unversioned\",\"name\":\"v2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":0,\"inferredType\":false},\"p1\":{\"@type\":\"variable_unversioned\",\"name\":\"p1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":0,\"inferredType\":false},\"p2\":{\"@type\":\"variable_unversioned\",\"name\":\"p2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"boolean\"},\"nextVersionNumber\":0,\"inferredType\":false}},\"intermediateVarCount\":0,\"intermediateLabelCount\":1,\"returnType\":{\"@type\":\"basic\",\"typeName\":\"void\"}}},\"intermediateVarCount\":0,\"intermediateLabelCount\":1,\"allocation\":null,\"liveRangeVariables\":null,\"liveRangeEquivalenceClassSet\":null,\"variableRegisterWeights\":null}"; - assertJsonSerialization(scope, json, Scope.class); - } - - public void testJsonStmtAssignment() throws IOException { - VariableUnversioned v1 = new VariableUnversioned("v1", null, SymbolTypeBasic.BYTE); - VariableUnversioned v2 = new VariableUnversioned("v2", null, SymbolTypeBasic.BYTE); - VariableUnversioned v3 = new VariableUnversioned("v3", null, SymbolTypeBasic.BYTE); - StatementAssignment statement = new StatementAssignment(v1.getRef(), v2.getRef(), new Operator("+"), v3.getRef()); - String json = "{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"v1\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"v2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"v3\"},\"index\":null}"; - assertJsonSerialization(statement, json, Statement.class); - } - - public void testJsonStmtCondJump() throws IOException { - VariableUnversioned v1 = new VariableUnversioned("v1", null, SymbolTypeBasic.BYTE); - VariableUnversioned v2 = new VariableUnversioned("v2", null, SymbolTypeBasic.BYTE); - Label l1 = new Label("l1", null, false); - Statement statement = new StatementConditionalJump(v1.getRef(), new Operator("+"), v2.getRef(), l1.getRef()); - String json = "{\"@type\":\"cond\",\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"v1\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"v2\"},\"destination\":{\"@type\":\"labelref\",\"fullName\":\"l1\"},\"index\":null}"; - assertJsonSerialization(statement, json, Statement.class); - } - - - public void testJsonStmtPhiBlock() throws IOException { - VariableUnversioned v1 = new VariableUnversioned("v1", null, SymbolTypeBasic.BYTE); - VariableUnversioned v2 = new VariableUnversioned("v2", null, SymbolTypeBasic.BYTE); - VariableUnversioned v3 = new VariableUnversioned("v3", null, SymbolTypeBasic.BYTE); - Label b1 = new Label("B1", false); - Label b2 = new Label("B2", false); - StatementPhiBlock statement = new StatementPhiBlock(); - StatementPhiBlock.PhiVariable phiVariable = statement.addPhiVariable(v1.getRef()); - phiVariable.setrValue(b1.getRef(), v2.getRef()); - phiVariable.setrValue(b2.getRef(), v3.getRef()); - String json = "{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"v1\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"B1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"v2\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"B2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"v3\"}}]}],\"index\":null}"; - assertJsonSerialization(statement, json, Statement.class); - } - - public void testJsonCode() throws IOException { - String minProgram = "byte b=0;byte c=b;"; - Compiler compiler = new Compiler(); - CompileLog log = new CompileLog(); - KickCParser.FileContext file = compiler.pass0ParseInput(new ANTLRInputStream(minProgram), log); - Program program = compiler.pass1GenerateSSA(file, log); - String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"b\":{\"@type\":\"variable_unversioned\",\"name\":\"b\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"c\":{\"@type\":\"variable_unversioned\",\"name\":\"c\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"b#0\":{\"@type\":\"variable_versioned\",\"name\":\"b#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"c#0\":{\"@type\":\"variable_versioned\",\"name\":\"c#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"c\",\"inferredType\":false}},\"intermediateVarCount\":0,\"intermediateLabelCount\":1,\"allocation\":null,\"liveRangeVariables\":null,\"liveRangeEquivalenceClassSet\":null,\"variableRegisterWeights\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"b#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"c#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"b#0\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null,\"dominators\":null,\"loopSet\":null,\"callGraph\":null}}"; - assertJsonSerialization(program, json, Program.class); - } - - public void testJsonCodeSumFunction() throws IOException { - String minProgram = "byte s1=sum(1,2);\n" + - "byte s2=sum(9,13);\n" + - "byte sum(byte a, byte b) {\n" + - " return a+b;\n" + - "}\n"; - Compiler compiler = new Compiler(); - CompileLog log = new CompileLog(); - KickCParser.FileContext file = compiler.pass0ParseInput(new ANTLRInputStream(minProgram), log); - Program program = compiler.pass1GenerateSSA(file, log); - String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"s1\":{\"@type\":\"variable_unversioned\",\"name\":\"s1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"s2\":{\"@type\":\"variable_unversioned\",\"name\":\"s2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"sum\":{\"@type\":\"procedure\",\"name\":\"sum\",\"parameterNames\":[\"a\",\"b\"],\"symbols\":{\"@return\":{\"@type\":\"label\",\"name\":\"@return\",\"intermediate\":false},\"return\":{\"@type\":\"variable_unversioned\",\"name\":\"return\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":7,\"inferredType\":false},\"a\":{\"@type\":\"variable_unversioned\",\"name\":\"a\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"b\":{\"@type\":\"variable_unversioned\",\"name\":\"b\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"a#0\":{\"@type\":\"variable_versioned\",\"name\":\"a#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#0\":{\"@type\":\"variable_versioned\",\"name\":\"b#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#0\":{\"@type\":\"variable_versioned\",\"name\":\"return#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#1\":{\"@type\":\"variable_versioned\",\"name\":\"a#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#1\":{\"@type\":\"variable_versioned\",\"name\":\"b#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#1\":{\"@type\":\"variable_versioned\",\"name\":\"return#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#2\":{\"@type\":\"variable_versioned\",\"name\":\"return#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#3\":{\"@type\":\"variable_versioned\",\"name\":\"return#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#4\":{\"@type\":\"variable_versioned\",\"name\":\"return#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#5\":{\"@type\":\"variable_versioned\",\"name\":\"return#5\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#2\":{\"@type\":\"variable_versioned\",\"name\":\"a#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#2\":{\"@type\":\"variable_versioned\",\"name\":\"b#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#6\":{\"@type\":\"variable_versioned\",\"name\":\"return#6\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false}},\"intermediateVarCount\":1,\"intermediateLabelCount\":2,\"returnType\":{\"@type\":\"basic\",\"typeName\":\"byte\"}},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"@3\":{\"@type\":\"label\",\"name\":\"@3\",\"intermediate\":true},\"s1#0\":{\"@type\":\"variable_versioned\",\"name\":\"s1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s1\",\"inferredType\":false},\"s2#0\":{\"@type\":\"variable_versioned\",\"name\":\"s2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s2\",\"inferredType\":false}},\"intermediateVarCount\":2,\"intermediateLabelCount\":4,\"allocation\":null,\"liveRangeVariables\":null,\"liveRangeEquivalenceClassSet\":null,\"variableRegisterWeights\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":2},\"index\":null},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true,\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"}}]}],\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":9},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":13},\"index\":null},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true,\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@3\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"}}]}],\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"}}]}],\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum::@return\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"}}]}],\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"},\"index\":null},{\"@type\":\"return\",\"value\":null,\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@RETURN\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null,\"dominators\":null,\"loopSet\":null,\"callGraph\":null}}"; - assertJsonSerialization(program, json, Program.class); - } - - - public void testJsonCodeFib() throws IOException { - String minProgram = "byte n1 = 0; byte n2 = 1; byte i = 12; byte fib = 0; while(i>0) { fib = n1 + n2; n1 = n2; n2 = fib; i = i - 1; }"; - Compiler compiler = new Compiler(); - CompileLog log = new CompileLog(); - KickCParser.FileContext file = compiler.pass0ParseInput(new ANTLRInputStream(minProgram), log); - Program program = compiler.pass1GenerateSSA(file, log); - String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"n1\":{\"@type\":\"variable_unversioned\",\"name\":\"n1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":4,\"inferredType\":false},\"n2\":{\"@type\":\"variable_unversioned\",\"name\":\"n2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":4,\"inferredType\":false},\"i\":{\"@type\":\"variable_unversioned\",\"name\":\"i\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":4,\"inferredType\":false},\"fib\":{\"@type\":\"variable_unversioned\",\"name\":\"fib\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":2,\"inferredType\":false},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"boolean\"},\"inferredType\":true},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"$2\":{\"@type\":\"variable_intermediate\",\"name\":\"$2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"n1#0\":{\"@type\":\"variable_versioned\",\"name\":\"n1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#0\":{\"@type\":\"variable_versioned\",\"name\":\"n2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#0\":{\"@type\":\"variable_versioned\",\"name\":\"i#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"fib#0\":{\"@type\":\"variable_versioned\",\"name\":\"fib#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"fib\",\"inferredType\":false},\"fib#1\":{\"@type\":\"variable_versioned\",\"name\":\"fib#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"fib\",\"inferredType\":false},\"n1#1\":{\"@type\":\"variable_versioned\",\"name\":\"n1#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#1\":{\"@type\":\"variable_versioned\",\"name\":\"n2#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#1\":{\"@type\":\"variable_versioned\",\"name\":\"i#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"i#2\":{\"@type\":\"variable_versioned\",\"name\":\"i#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"n1#2\":{\"@type\":\"variable_versioned\",\"name\":\"n1#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#2\":{\"@type\":\"variable_versioned\",\"name\":\"n2#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#3\":{\"@type\":\"variable_versioned\",\"name\":\"i#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"n1#3\":{\"@type\":\"variable_versioned\",\"name\":\"n1#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#3\":{\"@type\":\"variable_versioned\",\"name\":\"n2#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false}},\"intermediateVarCount\":3,\"intermediateLabelCount\":7,\"allocation\":null,\"liveRangeVariables\":null,\"liveRangeEquivalenceClassSet\":null,\"variableRegisterWeights\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"i#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":12},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"fib#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#0\"}}]}],\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"i#2\"},\"operator\":{\"operator\":\">\"},\"rValue2\":{\"@type\":\"integer\",\"number\":0},\"index\":null},{\"@type\":\"cond\",\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"destination\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"callSuccessor\":null},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#3\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#3\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#2\"}}]}],\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"n1#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"fib#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n1#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n2#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"fib#1\"},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$2\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"i#3\"},\"operator\":{\"operator\":\"-\"},\"rValue2\":{\"@type\":\"integer\",\"number\":1},\"index\":null},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"i#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$2\"},\"index\":null}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null,\"dominators\":null,\"loopSet\":null,\"callGraph\":null}}"; - assertJsonSerialization(program, json, Program.class); - } - - - public static void assertJsonSerialization( - Object object, - String json, - Class deserializeClass) throws IOException { - ObjectMapper jsonMapper = IclJacksonFactory.getMapper(); - ObjectWriter jsonWriter = jsonMapper.writer(); - String serialized = jsonWriter.writeValueAsString(object); - System.out.println(serialized); - TestCase.assertEquals("Serialized Object and Reference Serialized", json, serialized); - ObjectReader reader = jsonMapper.readerFor(deserializeClass); - Object deserialized = reader.readValue(json); - TestCase.assertEquals("Deserialized Object and Reference Object", object, deserialized); - Object redeserialized = reader.readValue(serialized); - TestCase.assertEquals("Re-serialized Object and Reference Object", object, redeserialized); - } - -} diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.asm b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.asm index 2236ad946..9c137489b 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.asm @@ -14,9 +14,9 @@ main: { ldx #yd/$2 lda #$0 sta x - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 b1: ldy #$0 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log index 8eaaaffb1..6aebd27a4 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log @@ -1462,9 +1462,9 @@ main: { lda #$0 sta x //SEG10 [2] phi (byte*) main::cursor#3 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 -- zpptrby1=cowo1 - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 jmp b1 //SEG11 [2] phi from main::@2 to main::@1 @@ -1603,9 +1603,9 @@ main: { lda #$0 sta x //SEG10 [2] phi (byte*) main::cursor#3 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 -- zpptrby1=cowo1 - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 jmp b1 //SEG11 [2] phi from main::@2 to main::@1 @@ -1708,9 +1708,9 @@ main: { lda #$0 sta x //SEG10 [2] phi (byte*) main::cursor#3 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 -- zpptrby1=cowo1 - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 jmp b1 //SEG11 [2] phi from main::@2 to main::@1 @@ -1806,9 +1806,9 @@ main: { lda #$0 sta x //SEG10 [2] phi (byte*) main::cursor#3 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 -- zpptrby1=cowo1 - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 jmp b1 //SEG11 [2] phi from main::@2 to main::@1 @@ -1898,9 +1898,9 @@ main: { lda #$0 sta x //SEG10 [2] phi (byte*) main::cursor#3 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 -- zpptrby1=cowo1 - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 //SEG11 [2] phi from main::@2 to main::@1 //SEG12 [2] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy @@ -2032,9 +2032,9 @@ main: { lda #$0 sta x //SEG10 [2] phi (byte*) main::cursor#3 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 -- zpptrby1=cowo1 - lda #<(SCREEN+($0*$28))+$0 + lda #(SCREEN+($0*$28))+$0 + lda #>SCREEN+$0*$28+$0 sta cursor+$1 //SEG11 [2] phi from main::@2 to main::@1 //SEG12 [2] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm b/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm index cd3158886..36d5a02b0 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm @@ -10,7 +10,7 @@ sta y ldy #yd/$2 ldx #$0 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.log b/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.log index 46dd0405a..4b99edbd9 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.log @@ -1195,7 +1195,7 @@ b1_from_bbegin: lda #$0 sta x //SEG6 [0] phi (word) idx#3 = (byte) 0+(byte) 0*(byte) 40 -- zpwo1=coby1 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 @@ -1322,7 +1322,7 @@ b1_from_bbegin: //SEG5 [0] phi (byte) x#2 = (byte) 0 -- xby=coby1 ldx #$0 //SEG6 [0] phi (word) idx#3 = (byte) 0+(byte) 0*(byte) 40 -- zpwo1=coby1 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 @@ -1420,7 +1420,7 @@ bbegin: //SEG5 [0] phi (byte) x#2 = (byte) 0 -- xby=coby1 ldx #$0 //SEG6 [0] phi (word) idx#3 = (byte) 0+(byte) 0*(byte) 40 -- zpwo1=coby1 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 @@ -1511,7 +1511,7 @@ ASSEMBLER //SEG5 [0] phi (byte) x#2 = (byte) 0 -- xby=coby1 ldx #$0 //SEG6 [0] phi (word) idx#3 = (byte) 0+(byte) 0*(byte) 40 -- zpwo1=coby1 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 @@ -1598,7 +1598,7 @@ ASSEMBLER //SEG5 [0] phi (byte) x#2 = (byte) 0 -- xby=coby1 ldx #$0 //SEG6 [0] phi (word) idx#3 = (byte) 0+(byte) 0*(byte) 40 -- zpwo1=coby1 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 @@ -1725,7 +1725,7 @@ FINAL CODE //SEG5 [0] phi (byte) x#2 = (byte) 0 -- xby=coby1 ldx #$0 //SEG6 [0] phi (word) idx#3 = (byte) 0+(byte) 0*(byte) 40 -- zpwo1=coby1 - lda #$0+($0*$28) + lda #$0+$0*$28 sta idx lda #$0 sta idx+$1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/constantmin.asm b/src/main/java/dk/camelot64/kickc/test/ref/constantmin.asm index 103a7cfd2..3edab720d 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/constantmin.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/constantmin.asm @@ -2,7 +2,7 @@ .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 jsr main main: { lda #STAR diff --git a/src/main/java/dk/camelot64/kickc/test/ref/constantmin.log b/src/main/java/dk/camelot64/kickc/test/ref/constantmin.log index c9e91aa13..4d6298be9 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/constantmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/constantmin.log @@ -645,7 +645,7 @@ INITIAL ASM .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 //SEG1 @begin bbegin: //SEG2 [0] call main param-assignment [ ] @@ -717,7 +717,7 @@ ASSEMBLER .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 //SEG1 @begin bbegin: //SEG2 [0] call main param-assignment [ ] @@ -765,7 +765,7 @@ ASSEMBLER .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 //SEG1 @begin bbegin: //SEG2 [0] call main param-assignment [ ] @@ -814,7 +814,7 @@ ASSEMBLER .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 //SEG1 @begin //SEG2 [0] call main param-assignment [ ] jsr main @@ -856,7 +856,7 @@ ASSEMBLER .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 //SEG1 @begin //SEG2 [0] call main param-assignment [ ] jsr main @@ -917,7 +917,7 @@ FINAL CODE .const STAR = $51 .const VIC = $d000 .const RED = $2 - .const BGCOL = (VIC+($10*$2))+$1 + .const BGCOL = VIC+$10*$2+$1 //SEG1 @begin //SEG2 [0] call main param-assignment [ ] jsr main diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm index f479f0c67..d37fd2449 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm @@ -28,9 +28,9 @@ plot: { .label y = 4 lda #$10 sta y - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 ldx #$0 b1: diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log index 3eb387bc1..a62b31d62 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log @@ -4380,9 +4380,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- zpby1=coby1 lda #$0 @@ -4738,9 +4738,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0 @@ -5006,9 +5006,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0 @@ -5254,9 +5254,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0 @@ -5483,9 +5483,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0 @@ -5700,9 +5700,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0 @@ -5915,9 +5915,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0 @@ -6220,9 +6220,9 @@ plot: { lda #$10 sta y //SEG35 [15] phi (byte*) plot::line#2 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 -- zpptrby1=cowo1 - lda #SCREEN+(($5*$28)+$c) + lda #>SCREEN+$5*$28+$c sta line+$1 //SEG36 [15] phi (byte) plot::i#3 = (byte) 0 -- xby=coby1 ldx #$0