fix mom tests
and always have a list inside a class
This commit is contained in:
@ -9,10 +9,14 @@ module RubyX
|
||||
vool
|
||||
end
|
||||
|
||||
def self.ruby_to_mom( ruby_source )
|
||||
vool = self.ruby_to_vool(ruby_source)
|
||||
vool.to_mom(nil)
|
||||
end
|
||||
|
||||
def self.ruby_to_binary(source , platform = :arm)
|
||||
machine = Risc.machine.boot
|
||||
vool = self.ruby_to_vool(source)
|
||||
vool.to_mom(nil).class
|
||||
ruby_to_mom(source)
|
||||
machine.translate(platform)
|
||||
machine.position_all
|
||||
machine.create_binary
|
||||
|
@ -4,11 +4,22 @@ module Vool
|
||||
attr_reader :clazz
|
||||
|
||||
def initialize( name , supe , body)
|
||||
@name , @super_class_name , @body = name , supe , body
|
||||
@name , @super_class_name = name , supe
|
||||
case body
|
||||
when MethodStatement
|
||||
@body = Statements.new([body])
|
||||
when Statements
|
||||
@body = body
|
||||
when nil
|
||||
@body = Statements.new([])
|
||||
else
|
||||
raise "what body #{body}"
|
||||
end
|
||||
end
|
||||
|
||||
def normalize
|
||||
ClassStatement.new(@name , @super_class_name, @body&.normalize )
|
||||
meths = body.statements.collect{|meth| meth.normalize}
|
||||
ClassStatement.new(@name , @super_class_name, Statements.new(meths) )
|
||||
end
|
||||
|
||||
def to_mom( _ )
|
||||
|
@ -30,7 +30,7 @@ module Vool
|
||||
|
||||
# create mom instructions
|
||||
def to_mom( method )
|
||||
raise "Empty list ? #{statements.length}" unless @statements[0]
|
||||
raise "Empty list ? #{statements.length}" if empty?
|
||||
flat = @statements.shift.to_mom(method)
|
||||
while( nekst = @statements.shift )
|
||||
flat.append nekst.to_mom(method)
|
||||
|
Reference in New Issue
Block a user