add jump for else statement
This commit is contained in:
@@ -38,12 +38,12 @@ size_t translate_parsed_if(Translated *translated, DArray *parsedIf) {
|
|||||||
} else {
|
} else {
|
||||||
translate_parsed(translated, condition->content);
|
translate_parsed(translated, condition->content);
|
||||||
push_instruction_byte(translated, OP_POP_SCOPE);
|
push_instruction_byte(translated, OP_POP_SCOPE);
|
||||||
jump_after_body_positions[i] = 0;
|
push_instruction_byte(translated, OP_JUMP);
|
||||||
|
jump_after_body_positions[i] = push_instruction_code(translated, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint64_t i = 0; i < parsedIf->size; i++) {
|
for (uint64_t i = 0; i < parsedIf->size; i++) {
|
||||||
if (jump_after_body_positions[i])
|
set_instruction_code(translated, jump_after_body_positions[i],
|
||||||
set_instruction_code(translated, jump_after_body_positions[i],
|
|
||||||
translated->bytecode.size);
|
translated->bytecode.size);
|
||||||
}
|
}
|
||||||
free(jump_after_body_positions);
|
free(jump_after_body_positions);
|
||||||
|
|||||||
5
test.ar
5
test.ar
@@ -59,7 +59,8 @@ let a,
|
|||||||
sum = a,
|
sum = a,
|
||||||
another,
|
another,
|
||||||
another_function(),
|
another_function(),
|
||||||
just_null_here
|
just_null_here,
|
||||||
|
x
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@ else term.log("bruh")
|
|||||||
|
|
||||||
mm=x/2/4/2/4354/534/534//534//3422*404203420234+3432423324&&430234230||4320423040230423^384239423043024923%4432042304920.3432423423
|
mm=x/2/4/2/4354/534/534//534//3422*404203420234+3432423324&&430234230||4320423040230423^384239423043024923%4432042304920.3432423423
|
||||||
|
|
||||||
let x = [
|
let X = [
|
||||||
'hello world',
|
'hello world',
|
||||||
'wow',
|
'wow',
|
||||||
10
|
10
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# SPDX-FileCopyrightText: 2025 William Bell
|
# SPDX-FileCopyrightText: 2025 William Bell
|
||||||
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
let y = 1
|
let y = 1
|
||||||
let term = y
|
|
||||||
|
|
||||||
let x = do
|
let x = do
|
||||||
y
|
do
|
||||||
return term
|
return y
|
||||||
|
x
|
||||||
|
return y
|
||||||
Reference in New Issue
Block a user