Skip to content
Snippets Groups Projects
Commit a4f6b584 authored by hansen's avatar hansen
Browse files

added renamer to trace printer

parent fc2af107
No related branches found
No related tags found
No related merge requests found
...@@ -121,6 +121,7 @@ public class TLC4B { ...@@ -121,6 +121,7 @@ public class TLC4B {
tlc4b.printResults(results, false); tlc4b.printResults(results, false);
//System.out.println(results.getTrace()); //System.out.println(results.getTrace());
System.exit(0); System.exit(0);
} }
} }
......
...@@ -49,24 +49,28 @@ public class TracePrinter { ...@@ -49,24 +49,28 @@ public class TracePrinter {
this.trace = trace; this.trace = trace;
this.tlcOutputInfo = tlcOutputInfo; this.tlcOutputInfo = tlcOutputInfo;
setup();
}
private void setup() {
constants = new ArrayList<OpDeclNode>(); constants = new ArrayList<OpDeclNode>();
variables = new ArrayList<OpDeclNode>(); variables = new ArrayList<OpDeclNode>();
for (int i = 0; i < TLCState.vars.length; i++) { for (int i = 0; i < TLCState.vars.length; i++) {
String id = TLCState.vars[i].getName().toString(); String tlaName = TLCState.vars[i].getName().toString();
if (tlcOutputInfo.constants.contains(id)) { String bName = tlcOutputInfo.getBName(tlaName);
if (tlcOutputInfo.constants.contains(bName)) {
constants.add(TLCState.vars[i]); constants.add(TLCState.vars[i]);
} else { } else {
variables.add(TLCState.vars[i]); variables.add(TLCState.vars[i]);
} }
} }
evalTrace(); evalTrace();
} }
public TracePrinter(TLCState initialState, TLCOutputInfo tlcOutputInfo) { public TracePrinter(TLCState initialState, TLCOutputInfo tlcOutputInfo) {
this.initialState = initialState; this.initialState = initialState;
this.tlcOutputInfo = tlcOutputInfo; this.tlcOutputInfo = tlcOutputInfo;
evalTrace(); setup();
} }
public StringBuilder getTrace() { public StringBuilder getTrace() {
...@@ -103,10 +107,11 @@ public class TracePrinter { ...@@ -103,10 +107,11 @@ public class TracePrinter {
expression.append(" & "); expression.append(" & ");
} }
UniqueString var = constants.get(i).getName(); UniqueString var = constants.get(i).getName();
String bName = tlcOutputInfo.getBName(var.toString());
BType type = tlcOutputInfo.getBType(var.toString()); BType type = tlcOutputInfo.getBType(var.toString());
String value = parseValue(state.lookup(var), type) String value = parseValue(state.lookup(var), type)
.toString(); .toString();
expression.append(var).append(" = ").append(value); expression.append(bName).append(" = ").append(value);
} }
} }
expression.append("\n"); expression.append("\n");
...@@ -122,9 +127,10 @@ public class TracePrinter { ...@@ -122,9 +127,10 @@ public class TracePrinter {
expression.append(" & "); expression.append(" & ");
} }
UniqueString var = variables.get(i).getName(); UniqueString var = variables.get(i).getName();
String bName = tlcOutputInfo.getBName(var.toString());
BType type = tlcOutputInfo.getBType(var.toString()); BType type = tlcOutputInfo.getBType(var.toString());
String value = parseValue(state.lookup(var), type).toString(); String value = parseValue(state.lookup(var), type).toString();
expression.append(var).append(" = ").append(value); expression.append(bName).append(" = ").append(value);
} }
return expression; return expression;
} }
...@@ -165,13 +171,20 @@ public class TracePrinter { ...@@ -165,13 +171,20 @@ public class TracePrinter {
res.append(")"); res.append(")");
return res; return res;
} else if (type instanceof FunctionType) { } else if (type instanceof FunctionType) {
if(((TupleValue) val).elems.length == 0){
res.append("{}");
return res;
}else{
BType subtype = ((FunctionType) type).getRange(); BType subtype = ((FunctionType) type).getRange();
res.append("["); res.append("[");
System.out.println();
res.append(parseEnumerationValue(((TupleValue) val).elems, res.append(parseEnumerationValue(((TupleValue) val).elems,
subtype)); subtype));
res.append("]"); res.append("]");
return res; return res;
} }
}
return null; return null;
case RECORDVALUE: { case RECORDVALUE: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment