Fix ruby normalising to_vool

So that vool layer never has complex conditions or returns
Start with while, next if, return and assign
This commit is contained in:
2019-08-16 14:09:56 +03:00
parent 84b9811e55
commit c213cf874b
10 changed files with 40 additions and 31 deletions

View File

@ -2,6 +2,10 @@ module Vool
class IvarAssignment < Assignment
def to_s(depth = 0)
"@#{super(depth)}"
end
def to_mom( compiler )
to = Mom::SlotDefinition.new(:message ,[ :receiver , @name])
from = @value.slot_definition(compiler)

View File

@ -36,7 +36,6 @@ module Vool
# - Setting up the next message, with receiver, arguments, and (importantly) return address
# - a CachedCall , or a SimpleCall, depending on wether the receiver type can be determined
def to_mom( compiler )
puts "Compiling #{self.to_s}"
@receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)
if(@receiver.ct_type)
method = @receiver.ct_type.resolve_method(self.name)

View File

@ -33,6 +33,9 @@ module Vool
def shift
@statements.shift
end
def pop
@statements.pop
end
# to_mom all the statements. Append subsequent ones to the first, and return the
# first.

View File

@ -14,6 +14,7 @@ module Vool
cond_label = Mom::Label.new(self, "cond_label_#{object_id.to_s(16)}")
codes = cond_label
codes << @hoisted.to_mom(compiler) if @hoisted
codes << @condition.to_mom(compiler) if @condition.is_a?(SendStatement)
codes << Mom::TruthCheck.new(condition.slot_definition(compiler) , merge_label)
codes << @body.to_mom(compiler)
codes << Mom::Jump.new(cond_label)