gets the if coded, but test fail die to instruction being a graph now

This commit is contained in:
Torsten Ruger
2014-07-16 20:16:40 +03:00
parent 4185758532
commit ba15f352db
2 changed files with 50 additions and 4 deletions

View File

@ -3,12 +3,27 @@ module Ast
# attr_reader :cond, :if_true, :if_false
def compile frame , method
is = cond.compile(frame , method)
# is.is_false(frame,method)
# is.is_false(frame,method)
# TODO should/will use different branches for different conditions.
branch = Virtual::ImplicitBranch.new
method.add branch
last = is
if_true.each do |part|
last = part.compile(frame,method )
raise part.inspect if last.nil?
end
label = Virtual::Label.new
method.add label
branch.swap
method.current = branch
if_false.each do |part|
last = part.compile(frame,method )
raise part.inspect if last.nil?
end
method.add label
branch.swap
method.current = label
#TODO should return the union of the true and false types
last
end
def old