Skip to content

Commit 7b7af48

Browse files
committed
Updated variable names for clarity
1 parent 99bbd34 commit 7b7af48

File tree

22 files changed

+410
-447
lines changed

22 files changed

+410
-447
lines changed

framec/src/frame_c/visitors/python_visitor.rs

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -690,30 +690,14 @@ impl PythonVisitor {
690690
if system_node.get_first_state().is_some() {
691691
self.newline();
692692
self.add_code(&format!(
693-
"def __transition(self, compartment: '{}Compartment'):",
693+
"def __transition(self, next_compartment: '{}Compartment'):",
694694
self.system_name
695695
));
696696
self.indent();
697697
self.newline();
698-
self.add_code("self.__next_compartment = compartment");
698+
self.add_code("self.__next_compartment = next_compartment");
699699
self.outdent();
700700

701-
// self.newline();
702-
// self.newline();
703-
// self.add_code(&format!(
704-
// "def __do_transition(self, next_compartment: '{}Compartment'):",
705-
// self.system_name
706-
// ));
707-
//
708-
// self.indent();
709-
// self.newline();
710-
// self.add_code("self.__router(FrameEvent(\"<\", self.__compartment.exit_args))");
711-
// self.newline();
712-
// self.add_code("self.__compartment = next_compartment");
713-
// self.newline();
714-
// self.add_code("self.__router(FrameEvent(\">\", self.__compartment.enter_args))");
715-
// self.outdent();
716-
717701
if self.generate_state_stack {
718702
self.newline();
719703
self.newline();
@@ -1113,14 +1097,14 @@ impl PythonVisitor {
11131097
// -- Enter Arguments --
11141098
self.newline();
11151099
self.add_code(&format!(
1116-
"compartment = {}Compartment('{}')",
1100+
"next_compartment = {}Compartment('{}')",
11171101
self.system_name, state_ref_code
11181102
));
11191103
// self.newline();
11201104

11211105
if transition_expr_node.forward_event {
11221106
self.newline();
1123-
self.add_code("compartment.forward_event = __e");
1107+
self.add_code("next_compartment.forward_event = __e");
11241108
}
11251109

11261110
// self.newline();
@@ -1159,7 +1143,7 @@ impl PythonVisitor {
11591143
expr_t.accept_to_string(self, &mut expr);
11601144
self.newline();
11611145
self.add_code(&format!(
1162-
"compartment.enter_args[\"{}\"] = {}",
1146+
"next_compartment.enter_args[\"{}\"] = {}",
11631147
p.name, expr
11641148
));
11651149
}
@@ -1207,7 +1191,7 @@ impl PythonVisitor {
12071191
expr_t.accept_to_string(self, &mut expr);
12081192
self.newline();
12091193
self.add_code(&format!(
1210-
"compartment.state_args[\"{}\"] = {}",
1194+
"next_compartment.state_args[\"{}\"] = {}",
12111195
param_symbol.name, expr
12121196
));
12131197
}
@@ -1253,7 +1237,7 @@ impl PythonVisitor {
12531237
initalizer_value_expr_t.accept_to_string(self, &mut expr_code);
12541238
self.newline();
12551239
self.add_code(&format!(
1256-
"compartment.state_vars[\"{}\"] = {}",
1240+
"next_compartment.state_vars[\"{}\"] = {}",
12571241
var_decl_node.name, expr_code
12581242
));
12591243
}
@@ -1266,7 +1250,7 @@ impl PythonVisitor {
12661250
}
12671251

12681252
self.newline();
1269-
self.add_code("self.__transition(compartment)");
1253+
self.add_code("self.__transition(next_compartment)");
12701254
}
12711255

12721256
//* --------------------------------------------------------------------- *//
@@ -1350,15 +1334,15 @@ impl PythonVisitor {
13501334
}
13511335
}
13521336

1353-
self.add_code("compartment = self.__state_stack_pop()");
1337+
self.add_code("next_compartment = self.__state_stack_pop()");
13541338
self.newline();
13551339

13561340
if transition_expr_node.forward_event {
1357-
self.add_code("compartment.forward_event = __e");
1341+
self.add_code("next_compartment.forward_event = __e");
13581342
self.newline();
13591343
}
13601344

1361-
self.add_code("self.__transition(compartment)");
1345+
self.add_code("self.__transition(next_compartment)");
13621346
}
13631347

13641348
//* --------------------------------------------------------------------- *//

framec_tests/python/src/basic/basic.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
1+
# Emitted from framec_v0.11.0
22

33

44

55
from framelang.framelang import FrameEvent
66

77

8-
# Emitted from framec_v0.11.0
98

109
class FrameEvent:
1110
def __init__(self, message, parameters):
@@ -59,8 +58,8 @@ def __basic_state_S0(self, __e):
5958
return
6059
elif __e._message == "A":
6160
# ooh
62-
compartment = BasicCompartment('__basic_state_S1')
63-
self.__transition(compartment)
61+
next_compartment = BasicCompartment('__basic_state_S1')
62+
self.__transition(next_compartment)
6463
return
6564

6665
# ----------------------------------------
@@ -75,8 +74,8 @@ def __basic_state_S1(self, __e):
7574
return
7675
elif __e._message == "B":
7776
# aah
78-
compartment = BasicCompartment('__basic_state_S0')
79-
self.__transition(compartment)
77+
next_compartment = BasicCompartment('__basic_state_S0')
78+
self.__transition(next_compartment)
8079
return
8180

8281
# ===================== Actions Block =================== #
@@ -126,8 +125,8 @@ def __router(self, __e):
126125
elif self.__compartment.state == '__basic_state_S1':
127126
self.__basic_state_S1(__e)
128127

129-
def __transition(self, compartment: 'BasicCompartment'):
130-
self.__next_compartment = compartment
128+
def __transition(self, next_compartment: 'BasicCompartment'):
129+
self.__next_compartment = next_compartment
131130

132131
def state_info(self):
133132
return self.__compartment.state

framec_tests/python/src/branch/branch.py

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
1+
# Emitted from framec_v0.11.0
22

33

44

55
from framelang.framelang import FrameEvent
66

77

8-
# Emitted from framec_v0.11.0
98

109
class FrameEvent:
1110
def __init__(self, message, parameters):
@@ -79,28 +78,28 @@ def OnInt(self,i: int):
7978

8079
def __branch_state_I(self, __e):
8180
if __e._message == "A":
82-
compartment = BranchCompartment('__branch_state_SimpleIf')
83-
self.__transition(compartment)
81+
next_compartment = BranchCompartment('__branch_state_SimpleIf')
82+
self.__transition(next_compartment)
8483
return
8584
elif __e._message == "B":
86-
compartment = BranchCompartment('__branch_state_NegatedIf')
87-
self.__transition(compartment)
85+
next_compartment = BranchCompartment('__branch_state_NegatedIf')
86+
self.__transition(next_compartment)
8887
return
8988
elif __e._message == "C":
90-
compartment = BranchCompartment('__branch_state_Precedence')
91-
self.__transition(compartment)
89+
next_compartment = BranchCompartment('__branch_state_Precedence')
90+
self.__transition(next_compartment)
9291
return
9392
elif __e._message == "D":
94-
compartment = BranchCompartment('__branch_state_NestedIf')
95-
self.__transition(compartment)
93+
next_compartment = BranchCompartment('__branch_state_NestedIf')
94+
self.__transition(next_compartment)
9695
return
9796
elif __e._message == "E":
98-
compartment = BranchCompartment('__branch_state_GuardedTransition')
99-
self.__transition(compartment)
97+
next_compartment = BranchCompartment('__branch_state_GuardedTransition')
98+
self.__transition(next_compartment)
10099
return
101100
elif __e._message == "F":
102-
compartment = BranchCompartment('__branch_state_NestedGuardedTransition')
103-
self.__transition(compartment)
101+
next_compartment = BranchCompartment('__branch_state_NestedGuardedTransition')
102+
self.__transition(next_compartment)
104103
return
105104

106105
# ----------------------------------------
@@ -124,12 +123,12 @@ def __branch_state_SimpleIf(self, __e):
124123
self.log_do("else 2")
125124

126125
if __e._parameters["b"]:
127-
compartment = BranchCompartment('__branch_state_F1')
128-
self.__transition(compartment)
126+
next_compartment = BranchCompartment('__branch_state_F1')
127+
self.__transition(next_compartment)
129128
return
130129
else:
131-
compartment = BranchCompartment('__branch_state_F2')
132-
self.__transition(compartment)
130+
next_compartment = BranchCompartment('__branch_state_F2')
131+
self.__transition(next_compartment)
133132
return
134133

135134
return
@@ -146,13 +145,13 @@ def __branch_state_SimpleIf(self, __e):
146145

147146
if __e._parameters["i"] == 7:
148147
self.log_do("== 7")
149-
compartment = BranchCompartment('__branch_state_F1')
150-
self.__transition(compartment)
148+
next_compartment = BranchCompartment('__branch_state_F1')
149+
self.__transition(next_compartment)
151150
return
152151
else:
153152
self.log_do("!= 7")
154-
compartment = BranchCompartment('__branch_state_F2')
155-
self.__transition(compartment)
153+
next_compartment = BranchCompartment('__branch_state_F2')
154+
self.__transition(next_compartment)
156155
return
157156

158157
return
@@ -178,12 +177,12 @@ def __branch_state_NegatedIf(self, __e):
178177
self.log_do("else 2")
179178

180179
if not (__e._parameters["b"]):
181-
compartment = BranchCompartment('__branch_state_F1')
182-
self.__transition(compartment)
180+
next_compartment = BranchCompartment('__branch_state_F1')
181+
self.__transition(next_compartment)
183182
return
184183
else:
185-
compartment = BranchCompartment('__branch_state_F2')
186-
self.__transition(compartment)
184+
next_compartment = BranchCompartment('__branch_state_F2')
185+
self.__transition(next_compartment)
187186
return
188187

189188
return
@@ -200,13 +199,13 @@ def __branch_state_NegatedIf(self, __e):
200199

201200
if not (__e._parameters["i"] != 7):
202201
self.log_do("== 7")
203-
compartment = BranchCompartment('__branch_state_F1')
204-
self.__transition(compartment)
202+
next_compartment = BranchCompartment('__branch_state_F1')
203+
self.__transition(next_compartment)
205204
return
206205
else:
207206
self.log_do("!= 7")
208-
compartment = BranchCompartment('__branch_state_F2')
209-
self.__transition(compartment)
207+
next_compartment = BranchCompartment('__branch_state_F2')
208+
self.__transition(next_compartment)
210209
return
211210

212211
return
@@ -247,8 +246,8 @@ def __branch_state_NestedIf(self, __e):
247246
self.log_do("> 0")
248247
if __e._parameters["i"] < 100:
249248
self.log_do("< 100")
250-
compartment = BranchCompartment('__branch_state_F1')
251-
self.__transition(compartment)
249+
next_compartment = BranchCompartment('__branch_state_F1')
250+
self.__transition(next_compartment)
252251
return
253252
else:
254253
self.log_do(">= 100")
@@ -259,8 +258,8 @@ def __branch_state_NestedIf(self, __e):
259258
self.log_do("> -10")
260259
else:
261260
self.log_do("<= -10")
262-
compartment = BranchCompartment('__branch_state_F2')
263-
self.__transition(compartment)
261+
next_compartment = BranchCompartment('__branch_state_F2')
262+
self.__transition(next_compartment)
264263
return
265264

266265

@@ -273,8 +272,8 @@ def __branch_state_GuardedTransition(self, __e):
273272
if __e._message == "OnInt":
274273
if __e._parameters["i"] > 100:
275274
self.log_do("-> $F1")
276-
compartment = BranchCompartment('__branch_state_F1')
277-
self.__transition(compartment)
275+
next_compartment = BranchCompartment('__branch_state_F1')
276+
self.__transition(next_compartment)
278277
return
279278
else:
280279
pass
@@ -283,13 +282,13 @@ def __branch_state_GuardedTransition(self, __e):
283282
pass
284283
else:
285284
self.log_do("-> $F2")
286-
compartment = BranchCompartment('__branch_state_F2')
287-
self.__transition(compartment)
285+
next_compartment = BranchCompartment('__branch_state_F2')
286+
self.__transition(next_compartment)
288287
return
289288

290289
self.log_do("-> $F3")
291-
compartment = BranchCompartment('__branch_state_F3')
292-
self.__transition(compartment)
290+
next_compartment = BranchCompartment('__branch_state_F3')
291+
self.__transition(next_compartment)
293292
return
294293

295294
# ----------------------------------------
@@ -300,8 +299,8 @@ def __branch_state_NestedGuardedTransition(self, __e):
300299
if __e._parameters["i"] > 10:
301300
if __e._parameters["i"] > 100:
302301
self.log_do("-> $F1")
303-
compartment = BranchCompartment('__branch_state_F1')
304-
self.__transition(compartment)
302+
next_compartment = BranchCompartment('__branch_state_F1')
303+
self.__transition(next_compartment)
305304
return
306305
else:
307306
pass
@@ -310,16 +309,16 @@ def __branch_state_NestedGuardedTransition(self, __e):
310309
pass
311310
else:
312311
self.log_do("-> $F2")
313-
compartment = BranchCompartment('__branch_state_F2')
314-
self.__transition(compartment)
312+
next_compartment = BranchCompartment('__branch_state_F2')
313+
self.__transition(next_compartment)
315314
return
316315

317316
else:
318317
pass
319318

320319
self.log_do("-> $F3")
321-
compartment = BranchCompartment('__branch_state_F3')
322-
self.__transition(compartment)
320+
next_compartment = BranchCompartment('__branch_state_F3')
321+
self.__transition(next_compartment)
323322
return
324323

325324
# ----------------------------------------
@@ -403,8 +402,8 @@ def __router(self, __e):
403402
elif self.__compartment.state == '__branch_state_F3':
404403
self.__branch_state_F3(__e)
405404

406-
def __transition(self, compartment: 'BranchCompartment'):
407-
self.__next_compartment = compartment
405+
def __transition(self, next_compartment: 'BranchCompartment'):
406+
self.__next_compartment = next_compartment
408407

409408
def state_info(self):
410409
return self.__compartment.state

framec_tests/python/src/change_state/change_state.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
2-
31
# Emitted from framec_v0.11.0
42

3+
54
class FrameEvent:
65
def __init__(self, message, parameters):
76
self._message = message
@@ -131,8 +130,8 @@ def __router(self, __e):
131130
elif self.__compartment.state == '__changestatesm_state_S4':
132131
self.__changestatesm_state_S4(__e)
133132

134-
def __transition(self, compartment: 'ChangeStateSmCompartment'):
135-
self.__next_compartment = compartment
133+
def __transition(self, next_compartment: 'ChangeStateSmCompartment'):
134+
self.__next_compartment = next_compartment
136135

137136
def __change_state(self, new_compartment: 'ChangeStateSmCompartment'):
138137
self.__compartment = new_compartment

0 commit comments

Comments
 (0)