Set Attribute Begin Arguments Property

When LW Python is in the "begin_expr" state and the "Expression" is a "Set Attribute" statement, then push the statement value into the "Arguments" stack.

if the following are true:
  • expression state at time t = "begin_expr"
  • the expression at time t = obj.key = value

then arguments stack at time (t + 1) = [ [ obj, [ value, [ ] ] ], arguments stack at time t ]

Normally, the "Expression" is a function call (or it can be converted into a function call) and LW Python would push all of the arguments into the "Arguments" stack. However, when it processes a "Set Attribute" statement, it assumes that the object and the attribute are already processed and leaves them alone, evaluating only the "value" on the right. For example, if the following are true:

  • expression state at time 27 = "begin_expr"
  • the expression at time 27 = self."first_name" = first_name

then arguments stack at time (27 + 1) = [ [ first_name, [ ] ], arguments stack at time 27 ]

Try stepping through the simulator to see LW Python push "first_name" into the "Arguemnts" stack.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments