Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/tlc2/overrides/BagsExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static Value foldBag(final OpValue op, final Value base, final Value bag)
throw new EvalException(EC.TLC_MODULE_ARGUMENT_ERROR,
new String[] { "third", "FoldBag", "bag", Values.ppr(bag.toString()) });
}
bfcn = bfcn.snapshot();

final Value[] domain = bfcn.getDomainAsValues();
final Value[] values = bfcn.values;
Expand Down
3 changes: 2 additions & 1 deletion modules/tlc2/overrides/CBOR.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ private void value(final Value v) {
}
}

private void function(final FcnRcdValue f) {
private void function(final FcnRcdValue fcn) {
final FcnRcdValue f = fcn.snapshot();
final Value form = functionValue(f);
if (form instanceof TupleValue) {
array(((TupleValue) form).elems);
Expand Down
2 changes: 1 addition & 1 deletion modules/tlc2/overrides/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static BoolValue IsInjective(final Value val) {
final Value fcn = val.toFcnRcd();
if (fcn instanceof FcnRcdValue) {
// Input e.g. [a |-> 1, b |-> 2] or [x \in BOOLEAN |-> x]
return isInjectiveNonDestructive(((FcnRcdValue) fcn).values);
return isInjectiveNonDestructive(((FcnRcdValue) fcn).snapshot().values);
}
throw new EvalException(EC.TLC_MODULE_ONE_ARGUMENT_ERROR,
new String[] { "IsInjective", "function", Values.ppr(val.toString()) });
Expand Down
3 changes: 2 additions & 1 deletion modules/tlc2/overrides/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ public static Value ioEnvExecTemplate(final Value env, final Value commandTempla
return runProcess(getEnv(environment), command);
}

private static Map<String, String> getEnv(final RecordValue environment) {
private static Map<String, String> getEnv(final RecordValue env) {
// Convert record of environment variables to what ProcessBuilder works with.
final RecordValue environment = env.snapshot();
final Map<String, String> penv = new HashMap<>();
for (int i = 0; i < environment.size(); i++) {
final UniqueString name = environment.names[i];
Expand Down
28 changes: 15 additions & 13 deletions modules/tlc2/overrides/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,19 @@ private static JsonElement getObjectNode(IValue value) throws IOException {
* @return the converted {@code JsonElement}
*/
private static JsonElement getObjectNode(FcnRcdValue value) throws IOException {
if (isValidSequence(value)) {
return getArrayNode(value);
final FcnRcdValue fcn = value.snapshot();
if (isValidSequence(fcn)) {
return getArrayNode(fcn);
}

final Value[] domain = value.getDomainAsValues();
final Value[] domain = fcn.getDomainAsValues();
JsonObject jsonObject = new JsonObject();
for (int i = 0; i < domain.length; i++) {
Value domainValue = domain[i];
if (domainValue instanceof StringValue) {
jsonObject.add(((StringValue) domainValue).val.toString(), getNode(value.values[i]));
jsonObject.add(((StringValue) domainValue).val.toString(), getNode(fcn.values[i]));
} else {
jsonObject.add(domainValue.toString(), getNode(value.values[i]));
jsonObject.add(domainValue.toString(), getNode(fcn.values[i]));
}
}
return jsonObject;
Expand All @@ -289,9 +290,10 @@ private static JsonElement getObjectNode(FcnRcdValue value) throws IOException {
* @return the converted {@code JsonElement}
*/
private static JsonElement getObjectNode(RecordValue value) throws IOException {
final RecordValue rcd = value.snapshot();
JsonObject jsonObject = new JsonObject();
for (int i = 0; i < value.names.length; i++) {
jsonObject.add(value.names[i].toString(), getNode(value.values[i]));
for (int i = 0; i < rcd.names.length; i++) {
jsonObject.add(rcd.names[i].toString(), getNode(rcd.values[i]));
}
return jsonObject;
}
Expand Down Expand Up @@ -353,14 +355,14 @@ private static JsonElement getArrayNode(TupleValue value) throws IOException {
* @return the converted {@code JsonElement}
*/
private static JsonElement getArrayNode(FcnRcdValue value) throws IOException {
if (!isValidSequence(value)) {
return getObjectNode(value);
final FcnRcdValue fcn = value.snapshot();
if (!isValidSequence(fcn)) {
return getObjectNode(fcn);
}

value.normalize();
JsonArray jsonArray = new JsonArray(value.values.length);
for (int i = 0; i < value.values.length; i++) {
jsonArray.add(getNode(value.values[i]));
JsonArray jsonArray = new JsonArray(fcn.values.length);
for (int i = 0; i < fcn.values.length; i++) {
jsonArray.add(getNode(fcn.values[i]));
}
return jsonArray;
}
Expand Down
7 changes: 4 additions & 3 deletions modules/tlc2/overrides/SVG.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static Value SVGElemToString(Value elem) throws Exception {
if(attrs == null){
throw new Exception("Was unable to convert element to a record: " + attrsVal.toString());
}
attrs = attrs.snapshot();
String attrStr = "";
for (UniqueString us : attrs.names) {
attrStr += " ";
Expand All @@ -96,13 +97,13 @@ public static Value SVGElemToString(Value elem) throws Exception {
children = tv.elems;
} else if (childrenVal instanceof RecordValue) {
RecordValue rv = (RecordValue) childrenVal.toRcd();
children = rv.values;
children = rv.snapshot().values;
} else if (childrenVal instanceof FcnRcdValue) {
FcnRcdValue fcv = (FcnRcdValue) childrenVal.toFcnRcd();
children = fcv.values;
children = fcv.snapshot().values;
} else if (childrenVal instanceof FcnLambdaValue) {
FcnRcdValue fcv = (FcnRcdValue) childrenVal.toFcnRcd();
children = fcv.values;
children = fcv.snapshot().values;
} else {
throw new Exception("Was unable to convert element to a tuple or (function) record: " + childrenVal.toString());
}
Expand Down
2 changes: 1 addition & 1 deletion modules/tlc2/overrides/SequencesExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static Value longestCommonPrefix(final Value val) {
set.normalize();

final ValueVec elems = set.elems;
if (set.elems.isEmpty()) {
if (elems.isEmpty()) {
throw new EvalException(EC.TLC_MODULE_ONE_ARGUMENT_ERROR,
new String[] { "LongestCommonPrefix", "non-empty set", Values.ppr(val.toString()) });
}
Expand Down
Loading