v4 Bytecode

Why hard

  • control-flow introduces jump targets and patching
  • wrong jump target can pass many tests and still fail edge cases

for lowering

  • init
  • cond before each iteration
  • body
  • post
  • jump back to condition point
  • exit label + scope cleanup

break / continue

  • both initially emit placeholder jumps
  • patch against current loop context
  • loop context stack handles nesting

Short-circuit

  • && jumps on falsey before evaluating RHS
  • || jumps on truthy before evaluating RHS
  • falsey rule remains false / nil

Contract checks

  • every jump resolved
  • every expression leaves expected stack value
  • loop scopes are correctly entered/exited
  • nested loops patch independently

Practical checks

  • break skips post and body
  • continue goes to post/next-iteration path
  • omitted loop clauses remain deterministic
1 / 1
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.