removed blocks and moved to labels

somewhat easier to understand the code as a linked list
relatively painless change, considering
This commit is contained in:
Torsten Ruger
2015-10-23 21:27:36 +03:00
parent f1f56f0d4e
commit 57f37ec023
22 changed files with 281 additions and 370 deletions

View File

@ -6,25 +6,25 @@ module Soml
branch_type , condition , statements = *statement
condition = condition.first
# this is where the while ends and both branches meet
merge = @method.source.new_block("while merge")
# this comes after the current and beofre the merge
start = @method.source.new_block("while_start" )
@method.source.current start
add_code start = Register::Label.new(statement , "while_start" )
cond = process(condition)
reset_regs
process(condition)
branch_class = Object.const_get "Register::Is#{branch_type.capitalize}"
# this is where the while ends and both branches meet
merge = Register::Label.new(statement , "while_merge")
add_code branch_class.new( condition , merge )
last = process_all(statements).last
reset_regs
process_all(statements)
# unconditionally branch to the start
add_code Register::Branch.new(statement,start)
# continue execution / compiling at the merge block
@method.source.current merge
last
add_code merge
nil # statements don't return anything
end
end
end