no continue

This commit is contained in:
Chris Wanstrath 2025-10-05 20:26:21 -07:00
parent 0e387fcfe1
commit c0ef5f55eb
3 changed files with 2 additions and 5 deletions

View File

@ -100,7 +100,6 @@ type CallFrame = {
returnAddress: number // Where to resume after RETURN returnAddress: number // Where to resume after RETURN
returnScope: Scope // Scope to restore after RETURN returnScope: Scope // Scope to restore after RETURN
isBreakTarget: boolean // Can be targeted by BREAK isBreakTarget: boolean // Can be targeted by BREAK
continueAddress?: number // Where to jump for CONTINUE
} }
``` ```
@ -602,7 +601,7 @@ All of these should throw errors:
### Break/Continue Semantics ### Break/Continue Semantics
- BREAK unwinds to frame that called the iterator function - BREAK unwinds to frame that called the iterator function
- Multiple nested function calls: break exits all of them until reaching marked frame - Multiple nested function calls: break exits all of them until reaching marked frame
- CONTINUE requires explicit continueAddress in frame (set by compiler for loops) - CONTINUE is implemented by the compiler using JUMPs
### Exception Unwinding ### Exception Unwinding
- THROW unwinds call stack to handler's depth, not just to handler - THROW unwinds call stack to handler's depth, not just to handler

View File

@ -4,5 +4,4 @@ export type Frame = {
returnAddress: number returnAddress: number
returnScope: Scope returnScope: Scope
isBreakTarget: boolean isBreakTarget: boolean
continueAddress?: number
} }

View File

@ -350,8 +350,7 @@ export class VM {
this.callStack.push({ this.callStack.push({
returnAddress: this.pc, returnAddress: this.pc,
returnScope: this.scope, returnScope: this.scope,
isBreakTarget: false, isBreakTarget: false
continueAddress: undefined
}) })
this.scope = new Scope(fn.parentScope) this.scope = new Scope(fn.parentScope)