Add compiling of the else-block
This commit is contained in:
parent
b6a38101f7
commit
50bd615767
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
local test = 10
|
local test = 11
|
||||||
if test == 10 then
|
if test == 10 then
|
||||||
print("first")
|
print("first")
|
||||||
elseif test == 11 then
|
elseif test == 11 then
|
||||||
|
|||||||
@ -423,11 +423,16 @@ impl Statement {
|
|||||||
0,
|
0,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
let block_instructions = if_part.1.compile(state, scope);
|
let if_block_instructions = if_part.1.compile(state, scope);
|
||||||
|
let else_block_instructions = else_block.compile(state, scope);
|
||||||
instructions.push(PreInstr::Instr(Instruction::Jmp(
|
instructions.push(PreInstr::Instr(Instruction::Jmp(
|
||||||
block_instructions.len() as i32
|
if_block_instructions.len() as i32 + 1,
|
||||||
)));
|
)));
|
||||||
instructions.extend(block_instructions);
|
instructions.extend(if_block_instructions);
|
||||||
|
instructions.push(PreInstr::Instr(Instruction::Jmp(
|
||||||
|
else_block_instructions.len() as i32,
|
||||||
|
)));
|
||||||
|
instructions.extend(else_block_instructions);
|
||||||
}
|
}
|
||||||
Statement::Expression(expr) => {
|
Statement::Expression(expr) => {
|
||||||
let (instr, _) = expr.kind.compile(state, scope, None);
|
let (instr, _) = expr.kind.compile(state, scope, None);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user