v4 Control Flow

Why control flow now?

  • expressions are not enough
  • loops require jump topology and branch patching

for-loop model

  • execute init once
  • evaluate cond before each body pass
  • body -> post -> cond
  • break and continue are loop-specific edges

Scope rule

  • loop init scope covers cond/body/post
  • scope exits with loop

Short-circuit lowering

  • && skips RHS on falsey LHS
  • || skips RHS on truthy LHS
  • use boolean result semantics for expression value

patching discipline

  • track loop metadata on a stack
  • patch break -> loop end
  • patch continue -> post/next-iteration point

Correctness checks

  • every conditional or logical jump target patched
  • nested loops resolve to nearest loop
  • precedence: && above ||

Checks to verify

  • false && sideEffect() does not call sideEffect
  • true || sideEffect() does not call sideEffect
  • explicit break exits only current loop
1 / 1
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.