3 ms·
It's a transform on the instruction set. If you have the following instruction set for a tree walking interpreter (Scala syntax) enum Expr: case Add(lef
by noelwelsh 2mo ago
It's a transform on the instruction set. If you have the following instruction set for a tree walking interpreter (Scala syntax)
enum Expr:
case Add(left: Expr, right: Expr)
case Lit(val: Double)
the corresponding stack machine instruction set is
enum Expr:
case Add
case Lit(val: Double)
The transformation in this direction is purely syntactic: where you see that a case has a parameter of type Expr in the instruction set, you simply remove that parameter for the corresponding stack machine instruction.
The transformation in the other direction is not purely syntactic as you have to know that, e.g., Add gets two parameters from the stack and add those parameters back in.
- derdi 2mo agoGot it, thank you! I had read your "remove any occurrence of the expression type in the tree-walking AST" as removing nodes from the AST, but in some sense it's about removing edges, as in, the references from one operation to others.