Implement core Forth runtime: dictionary, codegen, outer interpreter, REPL

- Dictionary: linked-list word headers in simulated linear memory with
  create/find/reveal, case-insensitive lookup, IMMEDIATE flag support
- WASM codegen: IR-to-WASM translation via wasm-encoder with full
  validation; all stack, arithmetic, comparison, logic, memory, control
  flow, and return stack operations; wasmtime execution tests
- Outer interpreter: tokenizer, number parsing (decimal/$hex/#dec/%bin),
  interpret/compile dispatch, control structures (IF/ELSE/THEN,
  BEGIN/UNTIL, BEGIN/WHILE/REPEAT), RECURSE, comments, string output
- 40+ primitive words registered via JIT-compiled WASM modules linked
  to shared memory/globals/table
- Interactive REPL with rustyline, piped input, and file execution
- 145 tests passing across dictionary, codegen, and runtime
This commit is contained in:
2026-03-29 22:48:37 +02:00
parent 14d37c603b
commit c548f17f1e
5 changed files with 2798 additions and 33 deletions
+1389 -11
View File
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -297,9 +297,7 @@ impl Dictionary {
/// Toggle the IMMEDIATE flag on the most recent word.
pub fn toggle_immediate(&mut self) -> WaferResult<()> {
if self.latest == 0 && self.here == DICTIONARY_BASE {
return Err(WaferError::CompileError(
"no word defined yet".to_string(),
));
return Err(WaferError::CompileError("no word defined yet".to_string()));
}
let flags_addr = (self.latest + 4) as usize;
if flags_addr >= self.memory.len() {
+1326 -8
View File
File diff suppressed because it is too large Load Diff