**Eval** — returns value
```rust
match node {
ParseNode::IntLit(val) =>
*val,
ParseNode::BinaryOp {
op, left, right
} => {
let l = eval(left, env);
let r = eval(right, env);
match op {
Add => l.wrapping_add(r),
// ...
}
}
}
```
**Compile** — returns asm
```rust
match node {
ParseNode::IntLit(val) => {
// emit push constant
}
ParseNode::BinaryOp {
op, left, right
} => {
code += &compile(left);
code += &compile(right);
// emit pop, op, store
}
}
```
---
## Key Differences
| Aspect | Eval | Compile |
|---|---|---|
| Output | `u32` value | `String` of assembly |
| Variables | HashMap lookup | Push register |
| Operations | Computed in Rust | Emitted as instructions |
| Intermediate values | Rust variables | Program stack |
| Environment | `HashMap