Add a noop if no whitespace is emitted to have something to jump to
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
59f92e31fe
commit
e0e84ede1c
6 changed files with 16 additions and 11 deletions
|
|
@ -37,6 +37,7 @@ pub fn execute(
|
|||
let instr = instructions.get(ip).unwrap();
|
||||
|
||||
match instr {
|
||||
Instruction::NoOp => (),
|
||||
Instruction::AppendContent { content } => output.push_str(content),
|
||||
Instruction::LoadFromContextToSlot { name, slot } => {
|
||||
let value = global_context
|
||||
|
|
@ -53,12 +54,11 @@ pub fn execute(
|
|||
Instruction::PushScope { inherit_parent: _ } => todo!(),
|
||||
Instruction::Abort => return Err(EvaluationError::ExplicitAbort),
|
||||
Instruction::JumpIfNotTrue { emit_slot, jump } => {
|
||||
let jump = if *jump == 0 { 1 } else { *jump };
|
||||
let dont_jump = scopes.get(emit_slot).unwrap().as_bool().unwrap();
|
||||
if dont_jump {
|
||||
// We are done
|
||||
} else {
|
||||
let (new_ip, overflow) = ip.overflowing_add_signed(jump);
|
||||
let (new_ip, overflow) = ip.overflowing_add_signed(*jump);
|
||||
|
||||
if overflow {
|
||||
return Err(EvaluationError::InstructionPointerOverflow);
|
||||
|
|
@ -69,8 +69,7 @@ pub fn execute(
|
|||
}
|
||||
}
|
||||
Instruction::Jump { jump } => {
|
||||
let jump = if *jump == 0 { 1 } else { *jump };
|
||||
let (new_ip, overflow) = ip.overflowing_add_signed(jump);
|
||||
let (new_ip, overflow) = ip.overflowing_add_signed(*jump);
|
||||
|
||||
if overflow {
|
||||
return Err(EvaluationError::InstructionPointerOverflow);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue