Open MiranDMC opened 3 months ago
Optimizing out unused branch is not so trivial, considering fact there can be label inside. Then there is no way to simply be sure the code inside is never used. Cases like that can be compiled as jump over the "unused" branch.
here is a solution
if is(version_alpha, 0)
then
[...]
:is
// 0@ first value
// 1@ second value
int 0@, 1@
0@ = 0@ ^ 1@
if 0@ == 0
then cleo_return 1 true
else cleo_return 1 false
end
cleo_return 0
here is a solution
if is(version_alpha, 0) then [...] :is // 0@ first value // 1@ second value int 0@, 1@ 0@ = 0@ ^ 1@ if 0@ == 0 then cleo_return 1 true else cleo_return 1 false end cleo_return 0
if equals(version_alpha, 0)
[...]
function equals(a: int, b: int)
return a == b
end
Currently code below won't compile:
as there is no opcode handling
imm int == imm int
operation.Operation on constant values like that should be performed during compilation time. Then
if
condition with constants becomes special case, likewhile true
currently is. One thing leads to another and the result is thatif
blocks would be actually be able to include just one side of the branch, making them effectively analogue of C's#ifdef
macros.Request very simple on the surface, but I think not that much more complicated to implement. Multi-condition
if
and switch statements needs some extra logic during compilation, but all those seems to be just simple checks.