An AST interpreter that accepts stepping operations
Metacello new
baseline: 'DebuggableASTInterpreter';
repository: 'github://carolahp/DebuggableASTInterpreter';
load.
Metacello new
baseline: 'DebuggableASTInterpreter';
repository: 'github://carolahp/DebuggableASTInterpreter';
load: #Debugger.
Execute the following code in a playground with a doIt
to test the debugger.
(DASTSpecDebugger on: (DASTSession debug: 'MyObject new doStuff')) openWithFullView
That is not yet synchronized with the master branch.
Metacello new
baseline: 'DebuggableASTInterpreter';
repository: 'github://carolahp/DebuggableASTInterpreter';
load: #Overlay.
In a playground, instanciate an interpreter and initialize it with the program you want it to interpret (here: Point x: 1 y: 2
)
interpreter := DASTInterpreter new.
interpreter initializeWithProgram: (RBParser parseExpression: 'Point x: 1 y: 2').
You can see the stack of AST nodes the current context still has to interpret by inspecting: interpreter currentContext nodes
. The nodes will be interpreted from last to first.
Node stack:
You can see the value stack of the current context (where the interpreter pushes the values of the AST nodes it interprets) by inspecting: interpreter currentContext stack
. It is empty at the moment because nothing has been evaluated yet.
Evaluate interpreter stepInto
3 times to evaluate the receiver and arguments of the #x:y: message being interpreted.
New node stack:
New value stack:
Finally, the message send itself is ready to be interpreted. If you evaluate interpreter stepOver
, the interpreter will pop the receiver and arguments from the value stack, evaluate the message send completely, and push its value on the value stack.
New node stack:
New value stack:
As you can see, the value of the message send is the point it created: (1@2)
Inspecting the interpreter shows its evaluation stack. The source code of each element in the stack is highlighted accordingly to its evaluation step. It is necessary to refresh the inspector by hand after each step operation.