diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementAssignment.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementAssignment.java index 99de0693f..f5c11305a 100644 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementAssignment.java +++ b/src/main/java/dk/camelot64/kickc/model/statements/StatementAssignment.java @@ -90,7 +90,7 @@ public class StatementAssignment extends StatementBase implements StatementLValu public String toString(Program program, boolean aliveInfo) { return super.idxString() + - lValue.toString(program) + " ← " + + lValue.toString(program) + " = " + (rValue1 == null ? "" : rValue1.toString(program) + " ") + (operator == null ? "" : operator + " ") + rValue2.toString(program) + diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java index 6747016eb..aabd6c45b 100644 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java +++ b/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java @@ -89,7 +89,7 @@ public class StatementCall extends StatementBase implements StatementLValue, Sta res.append(super.idxString()); if(lValue != null) { res.append(lValue.toString(program)); - res.append(" ← "); + res.append(" = "); } res.append("call "); if(procedure != null) { diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementCallFinalize.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementCallFinalize.java index 6979bd46a..08031755d 100644 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementCallFinalize.java +++ b/src/main/java/dk/camelot64/kickc/model/statements/StatementCallFinalize.java @@ -61,7 +61,7 @@ public class StatementCallFinalize extends StatementBase implements StatementLVa res.append(super.idxString()); if(lValue != null) { res.append(lValue.toString(program)); - res.append(" ← "); + res.append(" = "); } res.append("callfinalize "); if(procedure != null) { diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementCallPointer.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementCallPointer.java index ca7761da8..4fd098cee 100644 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementCallPointer.java +++ b/src/main/java/dk/camelot64/kickc/model/statements/StatementCallPointer.java @@ -80,7 +80,7 @@ public class StatementCallPointer extends StatementBase implements StatementLVal res.append(super.idxString()); if(lValue != null) { res.append(lValue.toString(program)); - res.append(" ← "); + res.append(" = "); } res.append("call "); res.append(procedure.toString(program) + " "); diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementPhiBlock.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementPhiBlock.java index a01bfefeb..08a3bae91 100644 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementPhiBlock.java +++ b/src/main/java/dk/camelot64/kickc/model/statements/StatementPhiBlock.java @@ -81,9 +81,14 @@ public class StatementPhiBlock extends StatementBase { for(PhiVariable phiVariable : variables) { s.append(super.idxString()); s.append(phiVariable.getVariable().toString(program)); - s.append(" ← phi("); + s.append(" = phi("); + boolean first = true; for(PhiRValue phiRValue : phiVariable.getValues()) { - s.append(" "); + if(first) + s.append(" "); + else + s.append(", "); + first = false; s.append(phiRValue.getPredecessor().toString(null)); s.append("/"); RValue rValue = phiRValue.getrValue(); diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Label.java b/src/main/java/dk/camelot64/kickc/model/symbols/Label.java index 7a8034cda..6b89fe254 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Label.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Label.java @@ -96,7 +96,7 @@ public class Label implements Symbol { if(program == null) { return getFullName(); } else { - return "(" + getType().getTypeName() + ") " + getFullName(); + return getType().getTypeName() + " " + getFullName(); } } diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java b/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java index 3951a05cf..993da8676 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java @@ -256,9 +256,7 @@ public class Procedure extends Scope { if(interruptType != null) { res.append("interrupt(").append(interruptType).append(")"); } - res.append("(").append(getType().getTypeName()).append(") "); - res.append(getFullName()); - res.append("("); + res.append(getType().getTypeName()).append(" ").append(getFullName()).append("("); boolean first = true; if(parameterNames != null) { for(Variable parameter : getParameters()) { diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java b/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java index e3e40505e..7e94ba86d 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java @@ -370,7 +370,7 @@ public abstract class Scope implements Symbol, Serializable { Variable symVar = (Variable) symbol; if(!onlyVars || symVar.isVariable()) { // Output if not instructed to only output variables - or if it is a variable - res.append(symbol.toString(program)); + res.append(symVar.typeString() + " " + symVar.toString()); if(symVar.isArray()) { res.append("["); if(symVar.getArraySize() != null) { diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java b/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java index 9853a2ca3..f70abcd37 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java @@ -629,13 +629,22 @@ public class Variable implements Symbol { @Override public String toString() { - return toString(null); + return getFullName(); } @Override public String toString(Program program) { - return new StringBuilder() - .append("(") + return toString(); + } + + /** + * Get a string describing the type of the variable + * + * @return The type as a string + */ + public String typeString() { + final StringBuilder print = new StringBuilder(); + print .append(isKindConstant() ? "const " : "") .append(isNoModify() ? "nomodify " : "") .append(isVolatile() ? "volatile " : "") @@ -643,8 +652,8 @@ public class Variable implements Symbol { .append(isToVolatile() ? "to_volatile " : "") .append(getType().getTypeName()) .append(isKindIntermediate() ? "~" : "") - .append(") ") - .append(getFullName()).toString(); + ; + return print.toString(); } @Override diff --git a/src/main/java/dk/camelot64/kickc/model/values/ConstantChar.java b/src/main/java/dk/camelot64/kickc/model/values/ConstantChar.java index ed72e3f70..e0e61783d 100644 --- a/src/main/java/dk/camelot64/kickc/model/values/ConstantChar.java +++ b/src/main/java/dk/camelot64/kickc/model/values/ConstantChar.java @@ -65,11 +65,7 @@ public class ConstantChar implements ConstantEnumerable { @Override public String toString(Program program) { String enc = (encoding.equals(StringEncoding.SCREENCODE_MIXED)) ? "" : encoding.suffix; - if(program == null) { - return "'" + value + "'" + enc; - } else { - return "(" + SymbolType.BYTE.getTypeName() + ") " + "'" + value + "'" + enc; - } + return "'" + value + "'" + enc; } } diff --git a/src/main/java/dk/camelot64/kickc/model/values/ConstantInteger.java b/src/main/java/dk/camelot64/kickc/model/values/ConstantInteger.java index 16c45039b..8ab1a4931 100644 --- a/src/main/java/dk/camelot64/kickc/model/values/ConstantInteger.java +++ b/src/main/java/dk/camelot64/kickc/model/values/ConstantInteger.java @@ -57,11 +57,7 @@ public class ConstantInteger implements ConstantEnumerable { @Override public String toString(Program program) { - if(program == null) { - return AsmFormat.getAsmNumber(number); - } else { - return "(" + getType(program.getScope()).getTypeName() + ") " + AsmFormat.getAsmNumber(number); - } + return AsmFormat.getAsmNumber(number); } @Override diff --git a/src/main/java/dk/camelot64/kickc/model/values/PointerDereferenceIndexed.java b/src/main/java/dk/camelot64/kickc/model/values/PointerDereferenceIndexed.java index 8393e4710..7ae7fb3d6 100644 --- a/src/main/java/dk/camelot64/kickc/model/values/PointerDereferenceIndexed.java +++ b/src/main/java/dk/camelot64/kickc/model/values/PointerDereferenceIndexed.java @@ -37,7 +37,10 @@ public class PointerDereferenceIndexed implements PointerDereference { @Override public String toString(Program program) { - return "*(" + pointer.toString(program) + " + " + index.toString(program) + ')'; + String pointerString = pointer.toString(program); + if(!pointerString.matches("[a-zA-Z0-9:#$]*")) + pointerString = "(" + pointerString + ")"; + return pointerString + "[" + index.toString(program) + ']'; } }