Introduce JumpLabels instead of manually correct jump positions

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-11 15:50:05 +01:00
parent e64256b65f
commit 7182024342
12 changed files with 485 additions and 381 deletions

View file

@ -3,38 +3,52 @@ source: tests/file_tests.rs
expression: emit
input_file: tests/cases/trim_whitespace.nomo
---
[
LoadFromContextToSlot {
name: "test" (6..10),
slot: VariableSlot {
VMInstructions {
labels: {
LabelSlot {
index: 2,
}: 7,
LabelSlot {
index: 0,
}: 7,
},
instructions: [
LoadFromContextToSlot {
name: "test" (6..10),
slot: VariableSlot {
index: 1,
},
},
},
JumpIfNotTrue {
emit_slot: VariableSlot {
index: 0,
JumpIfNotTrue {
emit_slot: VariableSlot {
index: 1,
},
jump: LabelSlot {
index: 2,
},
},
jump: 5,
},
AppendContent {
content: "Hello" (19..24),
},
AppendContent {
content: " " (24..25),
},
LoadFromContextToSlot {
name: "stuff" (29..34),
slot: VariableSlot {
index: 1,
AppendContent {
content: "Hello" (19..24),
},
},
EmitFromSlot {
slot: VariableSlot {
index: 1,
AppendContent {
content: " " (24..25),
},
},
Jump {
jump: 1,
},
NoOp,
]
LoadFromContextToSlot {
name: "stuff" (29..34),
slot: VariableSlot {
index: 3,
},
},
EmitFromSlot {
slot: VariableSlot {
index: 3,
},
},
Jump {
jump: LabelSlot {
index: 0,
},
},
NoOp,
],
}