Introduce JumpLabels instead of manually correct jump positions
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
e64256b65f
commit
7182024342
12 changed files with 485 additions and 381 deletions
|
|
@ -3,60 +3,81 @@ source: tests/file_tests.rs
|
|||
expression: emit
|
||||
input_file: tests/cases/if_else_if.nomo
|
||||
---
|
||||
[
|
||||
LoadFromContextToSlot {
|
||||
name: "test" (6..10),
|
||||
slot: VariableSlot {
|
||||
VMInstructions {
|
||||
labels: {
|
||||
LabelSlot {
|
||||
index: 2,
|
||||
}: 7,
|
||||
LabelSlot {
|
||||
index: 4,
|
||||
}: 14,
|
||||
LabelSlot {
|
||||
index: 0,
|
||||
}: 14,
|
||||
},
|
||||
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: "\n " (13..18),
|
||||
},
|
||||
AppendContent {
|
||||
content: "Not Hello World! :C" (18..37),
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n" (37..38),
|
||||
},
|
||||
Jump {
|
||||
jump: 9,
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n " (13..18),
|
||||
},
|
||||
LoadFromContextToSlot {
|
||||
name: "another_test" (49..61),
|
||||
slot: VariableSlot {
|
||||
index: 1,
|
||||
AppendContent {
|
||||
content: "\n " (13..18),
|
||||
},
|
||||
},
|
||||
JumpIfNotTrue {
|
||||
emit_slot: VariableSlot {
|
||||
index: 1,
|
||||
AppendContent {
|
||||
content: "Not Hello World! :C" (18..37),
|
||||
},
|
||||
jump: 5,
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n " (64..69),
|
||||
},
|
||||
AppendContent {
|
||||
content: "Hello World!" (69..81),
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n" (81..82),
|
||||
},
|
||||
Jump {
|
||||
jump: 2,
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n " (64..69),
|
||||
},
|
||||
NoOp,
|
||||
]
|
||||
AppendContent {
|
||||
content: "\n" (37..38),
|
||||
},
|
||||
Jump {
|
||||
jump: LabelSlot {
|
||||
index: 0,
|
||||
},
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n " (13..18),
|
||||
},
|
||||
LoadFromContextToSlot {
|
||||
name: "another_test" (49..61),
|
||||
slot: VariableSlot {
|
||||
index: 3,
|
||||
},
|
||||
},
|
||||
JumpIfNotTrue {
|
||||
emit_slot: VariableSlot {
|
||||
index: 3,
|
||||
},
|
||||
jump: LabelSlot {
|
||||
index: 4,
|
||||
},
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n " (64..69),
|
||||
},
|
||||
AppendContent {
|
||||
content: "Hello World!" (69..81),
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n" (81..82),
|
||||
},
|
||||
Jump {
|
||||
jump: LabelSlot {
|
||||
index: 0,
|
||||
},
|
||||
},
|
||||
AppendContent {
|
||||
content: "\n " (64..69),
|
||||
},
|
||||
NoOp,
|
||||
],
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue