update spec

This commit is contained in:
Chris Wanstrath 2025-10-05 21:09:56 -07:00
parent db4f332472
commit 0a7a3dcfdb

14
SPEC.md
View File

@ -61,7 +61,7 @@ type Bytecode = {
type Instruction = { type Instruction = {
op: OpCode op: OpCode
operand?: number | string | { positional: number; named: number } operand?: number | string
} }
type Constant = type Constant =
@ -526,7 +526,9 @@ LOAD 'mkdir'
PUSH 'src/bin' # positional arg PUSH 'src/bin' # positional arg
PUSH 'recursive' # name PUSH 'recursive' # name
PUSH true # value PUSH true # value
CALL { positional: 1, named: 1 } PUSH 1 # positionalCount
PUSH 1 # namedCount
CALL
``` ```
### Tail Recursive Function ### Tail Recursive Function
@ -549,12 +551,16 @@ recurse:
LOAD 'n' LOAD 'n'
LOAD 'acc' LOAD 'acc'
MUL MUL
TAIL_CALL 2 # No stack growth! PUSH 2 # positionalCount
PUSH 0 # namedCount
TAIL_CALL # No stack growth!
main: main:
LOAD 'factorial' LOAD 'factorial'
PUSH 5 PUSH 5
PUSH 1 PUSH 1
CALL 2 PUSH 2 # positionalCount
PUSH 0 # namedCount
CALL
``` ```
## Error Conditions ## Error Conditions