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:
@@ -8,10 +8,10 @@ license.workspace = true
|
||||
[dependencies]
|
||||
wasm-encoder = { workspace = true }
|
||||
wasmparser = { workspace = true }
|
||||
wasmtime = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = { workspace = true }
|
||||
insta = { workspace = true }
|
||||
wasmtime = { workspace = true }
|
||||
|
||||
+1389
-11
File diff suppressed because it is too large
Load Diff
@@ -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
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user