Achieve 100% Core Extensions compliance, 261 tests

Implement 25+ Core Extension words:
- VALUE/TO, DEFER/IS/ACTION-OF, :NONAME
- CASE/OF/ENDOF/ENDCASE, ?DO, AGAIN
- PARSE, PARSE-NAME, S\", C", HOLDS, BUFFER:
- 2>R, 2R>, 2R@, U>, .R, U.R, PAD, ERASE, UNUSED
- REFILL, SOURCE-ID, MARKER (stub)

Fix panic on invalid memory access (bounds check in FIND).
Rewrite FIND/WORD host functions for inline operation.
Add BeginAgain IR variant and codegen.

Three word sets at 100%: Core, Core Extensions, Exception.
This commit is contained in:
2026-03-30 22:19:49 +02:00
parent b52b4a79ce
commit 7507b1f164
6 changed files with 2014 additions and 12 deletions
+8
View File
@@ -436,6 +436,13 @@ fn emit_op(f: &mut Function, op: &IrOp) {
.instruction(&Instruction::End);
}
IrOp::BeginAgain { body } => {
f.instruction(&Instruction::Loop(BlockType::Empty));
emit_body(f, body);
f.instruction(&Instruction::Br(0))
.instruction(&Instruction::End);
}
IrOp::BeginWhileRepeat { test, body } => {
f.instruction(&Instruction::Block(BlockType::Empty));
f.instruction(&Instruction::Loop(BlockType::Empty));
@@ -702,6 +709,7 @@ fn count_needed_locals(ops: &[IrOp]) -> u32 {
IrOp::Rot | IrOp::Tuck => max = max.max(4),
IrOp::DoLoop { body, .. } => max = max.max(count_needed_locals(body)),
IrOp::BeginUntil { body } => max = max.max(count_needed_locals(body)),
IrOp::BeginAgain { body } => max = max.max(count_needed_locals(body)),
IrOp::BeginWhileRepeat { test, body } => {
max = max
.max(count_needed_locals(test))
+8
View File
@@ -193,6 +193,14 @@ impl Dictionary {
self.latest
}
/// Read the link field (previous word address) at a word entry.
pub fn read_link(&self, word_addr: u32) -> u32 {
if (word_addr + 4) as usize > self.memory.len() {
return 0;
}
self.read_u32_unchecked(word_addr)
}
/// Allocate n bytes at HERE (like Forth's ALLOT).
pub fn allot(&mut self, n: u32) -> WaferResult<u32> {
let new_here = self
+4
View File
@@ -84,6 +84,10 @@ pub enum IrOp {
BeginUntil {
body: Vec<IrOp>,
},
/// BEGIN ... AGAIN (infinite loop)
BeginAgain {
body: Vec<IrOp>,
},
/// BEGIN ... WHILE ... REPEAT
BeginWhileRepeat {
test: Vec<IrOp>,
+1504 -7
View File
File diff suppressed because it is too large Load Diff