Skip to content

Commit 7acb614

Browse files
committed
Convert TLCExt!Trace operator info an Evaluation.
This depends on TLC commit tlaplus/tlaplus@245a888
1 parent 907a872 commit 7acb614

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

modules/tlc2/overrides/TLCExt.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,22 @@ public synchronized static Value pickSuccessor(final Tool tool, final ExprOrOpAr
135135
}
136136
}
137137

138-
@TLAPlusOperator(identifier = "Trace", module = "TLCExt", minLevel = 1, warn = false)
139-
public synchronized static Value getTrace() throws IOException {
138+
@Evaluation(definition = "Trace", module = "TLCExt", minLevel = 1, warn = false)
139+
public synchronized static Value getTrace(final Tool tool, final ExprOrOpArgNode[] args, final Context c,
140+
final TLCState s0, final TLCState s1, final int control, final CostModel cm) throws IOException {
140141
final ModelChecker mc = (ModelChecker) TLCGlobals.mainChecker;
141142
final ConcurrentTLCTrace traceFile = mc.trace;
142143

143-
// If Trace operator is evaluated during the next-state relation, it will return
144-
// the state from which the next state is generated.
145-
final TLCState currentState = IdThread.getCurrentState();
146-
if (currentState == null) {
147-
return new TupleValue(new Value[0]);
144+
if (s0.isInitial()) {
145+
return new TupleValue(new Value[] { new RecordValue(s0) });
148146
}
149147

150-
if (currentState.isInitial()) {
151-
return new TupleValue(new Value[] { new RecordValue(currentState) });
152-
}
153-
154-
final TLCStateInfo[] trace = traceFile.getTrace(currentState);
148+
final TLCStateInfo[] trace = traceFile.getTrace(s0);
155149
final Value[] values = new Value[trace.length + 1];
156150
for (int j = 0; j < (trace.length); j++) {
157151
values[j] = new RecordValue(trace[j].state);
158152
}
159-
values[values.length - 1] = new RecordValue(currentState);
153+
values[values.length - 1] = new RecordValue(s0);
160154
return new TupleValue(values);
161155
}
162156
}

tests/GH005/TLCExtTrace.tla

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---- MODULE TLCExtTrace ----
22

3-
EXTENDS Integers, TLC, TLCExt
3+
EXTENDS Integers, TLCExt, Sequences
44

55
VARIABLE x
66

77
Spec == x = 1 /\ [][x < 10 /\ x' = x + 1]_x
88

9-
Inv == \/ x = 1
10-
\/ PrintT(<<Trace, x>>)
9+
\* Assert that Trace is the sequence of states up to the current value of x.
10+
Inv == /\ Len(Trace) = x
11+
/\ \A i \in 1..x : Trace[i].x = i /\ DOMAIN Trace[i] = {"x"}
1112

1213
==================================
13-

0 commit comments

Comments
 (0)