update readme

This commit is contained in:
Chris Wanstrath 2025-10-05 21:57:08 -07:00
parent 0270424f9b
commit b4e5d16da4

102
README.md
View File

@ -7,99 +7,29 @@ It's where Shrimp live.
bun install
bun test
## TODO (tests)
## Features
### Stack Operations
- [x] PUSH
- [x] POP
- [x] DUP
### Variables
- [x] LOAD
- [x] STORE
### Arithmetic
- [x] ADD
- [x] SUB
- [x] MUL
- [x] DIV
- [x] MOD
### Comparison
- [x] EQ
- [x] NEQ
- [x] LT
- [x] GT
- [x] LTE
- [x] GTE
### Logical
- [x] NOT
- [x] AND pattern (using JUMP_IF_FALSE for short-circuiting)
- [x] OR pattern (using JUMP_IF_TRUE for short-circuiting)
### Control Flow
- [x] JUMP
- [x] JUMP_IF_FALSE
- [x] JUMP_IF_TRUE
- [x] BREAK
- [x] CONTINUE
### Exception Handling
- [x] PUSH_TRY
- [x] PUSH_FINALLY
- [x] POP_TRY
- [x] THROW
### Functions
- [x] MAKE_FUNCTION
- [x] CALL
- [x] TAIL_CALL
- [x] RETURN
### Arrays
- [x] MAKE_ARRAY
- [x] ARRAY_GET
- [x] ARRAY_SET
- [x] ARRAY_LEN
### Dictionaries
- [x] MAKE_DICT
- [x] DICT_GET
- [x] DICT_SET
- [x] DICT_HAS
### TypeScript Interop
- [x] CALL_NATIVE
### Special
- [x] HALT
## Test Status
**91 tests passing** covering:
- All stack operations (PUSH, POP, DUP)
- All arithmetic operations (ADD, SUB, MUL, DIV, MOD)
- All comparison operations (EQ, NEQ, LT, GT, LTE, GTE)
- Stack operations (PUSH, POP, DUP)
- Arithmetic operations (ADD, SUB, MUL, DIV, MOD)
- Comparison operations (EQ, NEQ, LT, GT, LTE, GTE)
- Logical operations (NOT, AND/OR patterns with short-circuiting)
- Variable operations (LOAD, STORE)
- Control flow with **relative jumps** (JUMP, JUMP_IF_FALSE, JUMP_IF_TRUE, BREAK, CONTINUE)
- All array operations (MAKE_ARRAY, ARRAY_GET, ARRAY_SET, ARRAY_PUSH, ARRAY_LEN)
- All dictionary operations (MAKE_DICT, DICT_GET, DICT_SET, DICT_HAS)
- Array operations (MAKE_ARRAY, ARRAY_GET, ARRAY_SET, ARRAY_PUSH, ARRAY_LEN)
- Dictionary operations (MAKE_DICT, DICT_GET, DICT_SET, DICT_HAS)
- Function operations (MAKE_FUNCTION, CALL, TAIL_CALL, RETURN) with parameter binding
- **Variadic functions** with positional rest parameters (`...rest`)
- **Named arguments (kwargs)** that collect unmatched named args into a dict (`@kwargs`)
- **Mixed positional and named arguments** with proper priority binding
- **Tail call optimization** with unbounded recursion (10,000+ iterations without stack overflow)
- Variadic functions with positional rest parameters (`...rest`)
- Named arguments (kwargs) that collect unmatched named args into a dict (`@named`)
- Mixed positional and named arguments with proper priority binding
- Tail call optimization with unbounded recursion (10,000+ iterations without stack overflow)
- Exception handling (PUSH_TRY, PUSH_FINALLY, POP_TRY, THROW) with nested try/finally blocks and call stack unwinding
- Native function interop (CALL_NATIVE) with sync and async functions
- HALT instruction
## Design Decisions
- **Relative jumps**: All JUMP instructions use PC-relative offsets instead of absolute addresses, making bytecode position-independent
- **Simple truthiness**: Only `null` and `false` are falsy (unlike JavaScript where `0`, `""`, etc. are also falsy)
- **Short-circuiting via compiler**: No AND/OR opcodes—compilers use JUMP patterns for proper short-circuit evaluation
- **Variadic parameters**: Functions can collect remaining positional arguments into an array using `...rest` syntax
- **Named parameters (kwargs)**: Functions can collect unmatched named arguments into a dict using `@kwargs` syntax
- **Argument binding priority**: Named args can bind to regular params first, with unmatched ones going to `@kwargs`
- Relative jumps: All JUMP instructions use PC-relative offsets instead of absolute addresses, making bytecode position-independent
- Truthiness: Only `null` and `false` are falsy (unlike JavaScript where `0`, `""`, etc. are also falsy)
- Short-circuiting via compiler: No AND/OR opcodes—compilers use JUMP patterns for proper short-circuit evaluation
- Variadic parameters: Functions can collect remaining positional arguments into an array using `...rest` syntax
- Named parameters: Functions can collect unmatched named arguments into a dict using `@named` syntax
- Argument binding priority: Named args bind to regular params first, with unmatched ones going to `@named`