Restore Line After Method Call Property
If LW Python has finished executing a method body, then return to the call site.
if the following are true:
- the line at time t = i
- the tab at time t = j
- statement at line i, tab k = s
- k < j
- value at (j - 1) in map (Control Map at time t) = pair ("method", mname)
- stack at time t = [ program context with variables: varis and expression state: (expression state with parent stack: parent_stack arguments: arg_stack values: value_stack line: line tab: tab) and control map: control_map, rest ]
then the line at time (t + 1) = line
if the following are true:
- the line at time 50 = 6
- the tab at time 50 = 2
- statement at line 6, tab 1 =
def age_in_months(self):
- value at (2 - 1) in map (Control Map at time 50) = pair ("method", "__init__")
- stack at time 50 = [ program context with variables: [ ] and expression state: (expression state with parent stack: [ ] arguments: [ ] values: [ ] line: 8 tab: 0) and control map: [ entry 0: (pair ("class", "Person")), [ ] ], [ ] ]
then the line at time (50 + 1) = 8
Try stepping through the simulator to see LW Python jump back to the constructor call after the method is completed.
Code Editor
LW Python State
Current Line | 1 | Current Tab | 0 | Time | 0 |
LW Python Simulator
Comments
Please log in to add comments