1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-29 18:49:42 +00:00

Working on log output readability. #534

This commit is contained in:
jespergravgaard 2020-10-05 09:31:16 +02:00
parent e3cd22ecab
commit f117db148d
12 changed files with 34 additions and 27 deletions

View File

@ -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) +

View File

@ -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) {

View File

@ -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) {

View File

@ -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) + " ");

View File

@ -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()) {
if(first)
s.append(" ");
else
s.append(", ");
first = false;
s.append(phiRValue.getPredecessor().toString(null));
s.append("/");
RValue rValue = phiRValue.getrValue();

View File

@ -96,7 +96,7 @@ public class Label implements Symbol {
if(program == null) {
return getFullName();
} else {
return "(" + getType().getTypeName() + ") " + getFullName();
return getType().getTypeName() + " " + getFullName();
}
}

View File

@ -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()) {

View File

@ -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) {

View File

@ -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

View File

@ -65,11 +65,7 @@ public class ConstantChar implements ConstantEnumerable<Character> {
@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;
}
}
}

View File

@ -57,11 +57,7 @@ public class ConstantInteger implements ConstantEnumerable<Long> {
@Override
public String toString(Program program) {
if(program == null) {
return AsmFormat.getAsmNumber(number);
} else {
return "(" + getType(program.getScope()).getTypeName() + ") " + AsmFormat.getAsmNumber(number);
}
}
@Override

View File

@ -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) + ']';
}
}