use rubyc_compiler as instance
not as before class methods so we can carry the state around
This commit is contained in:
parent
1505df894a
commit
22b1fea587
@ -2,24 +2,30 @@ require_relative "ruby_compiler"
|
||||
|
||||
module RubyX
|
||||
class RubyXCompiler
|
||||
attr_reader :source
|
||||
|
||||
def self.ruby_to_vool( ruby_source )
|
||||
vool = RubyCompiler.compile( ruby_source )
|
||||
def initialize(source)
|
||||
@source = source
|
||||
end
|
||||
|
||||
def ruby_to_vool
|
||||
vool = RubyCompiler.compile( source )
|
||||
vool = vool.normalize
|
||||
vool
|
||||
end
|
||||
|
||||
def self.ruby_to_mom( ruby_source )
|
||||
vool = self.ruby_to_vool(ruby_source)
|
||||
def ruby_to_mom
|
||||
vool = ruby_to_vool
|
||||
vool.to_mom(nil)
|
||||
end
|
||||
|
||||
def self.ruby_to_binary(source , platform = :arm)
|
||||
def ruby_to_binary(platform = :arm)
|
||||
Parfait.boot!
|
||||
machine = Risc.machine.boot
|
||||
mom = ruby_to_mom(source)
|
||||
#mom.translate(platform)
|
||||
machine.translate(platform)
|
||||
mom = ruby_to_mom
|
||||
puts "MOM #{mom.class}"
|
||||
mom.translate(platform)
|
||||
#machine.translate(platform)
|
||||
machine.position_all
|
||||
machine.create_binary
|
||||
end
|
||||
|
@ -8,13 +8,14 @@ module RubyX
|
||||
end
|
||||
def ruby_to_risc(input , platform)
|
||||
mom = ruby_to_mom(input)
|
||||
puts "MOM #{mom.class}"
|
||||
mom.translate(platform)
|
||||
end
|
||||
def ruby_to_vool(input)
|
||||
RubyXCompiler.ruby_to_vool(input)
|
||||
RubyXCompiler.new(input).ruby_to_vool
|
||||
end
|
||||
def ruby_to_mom(input)
|
||||
RubyXCompiler.ruby_to_mom(input)
|
||||
RubyXCompiler.new(input).ruby_to_mom
|
||||
end
|
||||
def compile_in_test input
|
||||
vool = ruby_to_vool in_Test(input)
|
||||
|
@ -22,7 +22,7 @@ module MomCompile
|
||||
include ScopeHelper
|
||||
|
||||
def compile_mom(input)
|
||||
statements = RubyX::RubyXCompiler.ruby_to_vool input
|
||||
statements = RubyX::RubyXCompiler.new(input).ruby_to_vool
|
||||
res = statements.to_mom(nil)
|
||||
assert_equal Parfait::Class , statements.clazz.class , statements
|
||||
@method = statements.clazz.get_method(:main)
|
||||
@ -31,7 +31,12 @@ module MomCompile
|
||||
end
|
||||
def compile_first_method( input )
|
||||
res = compile_mom( as_test_main( input ))
|
||||
res.clazz.instance_methods.first.compile_to_mom(res.clazz.instance_type)
|
||||
method = res.clazz.instance_methods.first
|
||||
compile_to_mom(method , res.clazz.instance_type)
|
||||
end
|
||||
def compile_to_mom(method , for_type)
|
||||
typed_method = create_typed_method(for_type)
|
||||
source.to_mom( typed_method )
|
||||
end
|
||||
|
||||
def check_array( should , is )
|
||||
|
Loading…
x
Reference in New Issue
Block a user