Skip to content

Commit

Permalink
Implement DOMAIN operator
Browse files Browse the repository at this point in the history
  • Loading branch information
will62794 committed Jun 29, 2022
1 parent 806197a commit 30f4151
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
12 changes: 12 additions & 0 deletions js/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,18 @@ function evalBoundPrefix(node, ctx){
let symbol = node.children[0];
let rhs = node.children[1];
evalLog("evalBoundPrefix: ", node.type, ", ", node.text, `, prefix symbol: '${symbol.type}' `, "ctx:", ctx);

// DOMAIN.
if(symbol.type === "domain"){
evalLog("DOMAIN op");
evalLog(rhs);
let rhsVal = evalExpr(rhs, ctx)[0]["val"];
evalLog("rhsVal: ", rhsVal);
let domainVal = new SetValue(rhsVal.getDomain());
evalLog("domain val: ", domainVal);
return [ctx.withVal(domainVal)];
}

if(symbol.type === "powerset"){
evalLog("POWERSET op");
evalLog(rhs);
Expand Down
1 change: 1 addition & 0 deletions specs/with_state_graphs/tla_expr_eval.tla
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Init == exprs = [
head2 |-> Head(<<3,2,1>>),
tail1 |-> Tail(<<1,2,3>>),
tail2 |-> Tail(<<1>>),
domain1 |-> DOMAIN [a |-> 1, b |-> 2, c |-> 3],
case1 |-> CASE TRUE -> 3 [] FALSE -> 5,
case2 |-> CASE FALSE -> 3 [] TRUE -> 5,
case3 |-> CASE FALSE -> 3 [] FALSE -> 5 [] TRUE -> 7,
Expand Down
23 changes: 20 additions & 3 deletions specs/with_state_graphs/tla_expr_eval.tla.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"states": [
{
"fp": 787083421091669876,
"fp": 9222512163447704883,
"val": {
"exprs": {
"#type": "record",
Expand Down Expand Up @@ -67,6 +67,23 @@
"#type": "tup",
"#value": []
},
"domain1": {
"#type": "set",
"#value": [
{
"#type": "string",
"#value": "a"
},
{
"#type": "string",
"#value": "b"
},
{
"#type": "string",
"#value": "c"
}
]
},
"case1": {
"#type": "int",
"#value": 3
Expand Down Expand Up @@ -335,8 +352,8 @@
],
"edges": [
[
787083421091669876,
787083421091669876
9222512163447704883,
9222512163447704883
]
]
}

0 comments on commit 30f4151

Please sign in to comment.