@@ -23,92 +23,60 @@ final class JSONToTLA private (
2323 val constantDefns : Map [String , String ],
2424 val modelValues : Set [String ]
2525):
26- def renameLabel (mpcalName : String , labelName : String ): JSONToTLA =
26+ def copy (
27+ modelName : String = modelName,
28+ destDir : os.Path = destDir,
29+ tlaExtends : List [String ] = tlaExtends,
30+ actionRenamings : Map [String , String ] = actionRenamings,
31+ mpcalVariableDefns : Map [String , MPCalVariable ] = mpcalVariableDefns,
32+ modelVariableDefns : Set [String ] = modelVariableDefns,
33+ constantDefns : Map [String , String ] = constantDefns,
34+ modelValues : Set [String ] = modelValues
35+ ): JSONToTLA =
2736 new JSONToTLA (
2837 modelName = modelName,
2938 destDir = destDir,
3039 tlaExtends = tlaExtends,
31- actionRenamings = actionRenamings.updated(mpcalName, labelName) ,
40+ actionRenamings = actionRenamings,
3241 mpcalVariableDefns = mpcalVariableDefns,
3342 modelVariableDefns = modelVariableDefns,
3443 constantDefns = constantDefns,
3544 modelValues = modelValues
3645 )
3746
47+ def renameLabel (mpcalName : String , labelName : String ): JSONToTLA =
48+ copy(actionRenamings = actionRenamings.updated(modelName, labelName))
49+
3850 def modelVariable (name : String ): JSONToTLA =
39- new JSONToTLA (
40- modelName = modelName,
41- destDir = destDir,
42- tlaExtends = tlaExtends,
43- actionRenamings = actionRenamings,
44- mpcalVariableDefns = mpcalVariableDefns,
45- modelVariableDefns = modelVariableDefns + name,
46- constantDefns = constantDefns,
47- modelValues = modelValues
48- )
51+ copy(modelVariableDefns = modelVariableDefns + name)
4952
5053 def mpcalLocal (mpcalName : String , tlaName : String ): JSONToTLA =
51- new JSONToTLA (
52- modelName = modelName,
53- destDir = destDir,
54- tlaExtends = tlaExtends,
55- actionRenamings = actionRenamings,
54+ copy(
5655 mpcalVariableDefns =
5756 mpcalVariableDefns.updated(mpcalName, MPCalVariable .Local (tlaName)),
58- modelVariableDefns = modelVariableDefns + tlaName,
59- constantDefns = constantDefns,
60- modelValues = modelValues
57+ modelVariableDefns = modelVariableDefns + tlaName
6158 )
6259
6360 def mpcalGlobal (mpcalName : String , tlaName : String ): JSONToTLA =
64- new JSONToTLA (
65- modelName = modelName,
66- destDir = destDir,
67- tlaExtends = tlaExtends,
68- actionRenamings = actionRenamings,
61+ copy(
6962 mpcalVariableDefns =
7063 mpcalVariableDefns.updated(mpcalName, MPCalVariable .Global (tlaName)),
71- modelVariableDefns = modelVariableDefns + tlaName,
72- constantDefns = constantDefns,
73- modelValues = modelValues
64+ modelVariableDefns = modelVariableDefns + tlaName
7465 )
7566
7667 def mpcalMacro (mpcalName : String , tlaOperatorPrefix : String ): JSONToTLA =
77- new JSONToTLA (
78- modelName = modelName,
79- destDir = destDir,
80- tlaExtends = tlaExtends,
81- actionRenamings = actionRenamings,
82- mpcalVariableDefns = mpcalVariableDefns
83- .updated(mpcalName, MPCalVariable .Mapping (tlaOperatorPrefix)),
84- modelVariableDefns = modelVariableDefns,
85- constantDefns = constantDefns,
86- modelValues = modelValues
68+ copy(mpcalVariableDefns =
69+ mpcalVariableDefns.updated(
70+ mpcalName,
71+ MPCalVariable .Mapping (tlaOperatorPrefix)
72+ )
8773 )
8874
8975 def tlaConstant (name : String , value : String ): JSONToTLA =
90- new JSONToTLA (
91- modelName = modelName,
92- destDir = destDir,
93- tlaExtends = tlaExtends,
94- actionRenamings = actionRenamings,
95- mpcalVariableDefns = mpcalVariableDefns,
96- modelVariableDefns = modelVariableDefns,
97- constantDefns = constantDefns.updated(name, value),
98- modelValues = modelValues
99- )
76+ copy(constantDefns = constantDefns.updated(name, value))
10077
10178 def modelValue (name : String ): JSONToTLA =
102- new JSONToTLA (
103- modelName = modelName,
104- destDir = destDir,
105- tlaExtends = tlaExtends,
106- actionRenamings = actionRenamings,
107- mpcalVariableDefns = mpcalVariableDefns,
108- modelVariableDefns = modelVariableDefns,
109- constantDefns = constantDefns,
110- modelValues = modelValues + name
111- )
79+ copy(modelValues = modelValues + name)
11280
11381 private def getLabelNameFromValue (value : String ): String =
11482 val mpcalLabelName = value.stripPrefix(" \" " ).stripSuffix(" \" " )
0 commit comments