Restore Tab 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 tab at time (t + 1) = tab

After a method body has completed, LW Python restores the tab number that was stored in the "Stack." For example, 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 tab at time (50 + 1) = 0

Try stepping through the simulator to see LW Python jump back to tab 0 after the method is completed.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments