adding the blocks to virtual machine and store instructions in array not list

This commit is contained in:
Torsten Ruger
2014-08-13 11:59:51 +03:00
parent c2ae184e6e
commit 200228a33d
16 changed files with 196 additions and 207 deletions

View File

@@ -3,12 +3,12 @@ module Ast
# attr_reader :condition, :body
def compile method , message
start = Virtual::Label.new("while_start")
method.add start
method.add_code start
is = condition.compile(method,message)
branch = Virtual::ImplicitBranch.new "while"
merge = Virtual::Label.new(branch.name)
branch.other = merge #false jumps to end of while
method.add branch
method.add_code branch
last = is
body.each do |part|
last = part.compile(method,message )