Builtin is no more, final conversions done
All preloading where it needs to be (some)tests for the preload split compiler test remembered binary tests (usually just run on travis)
This commit is contained in:
parent
8af17a69ea
commit
1ee01622c3
@ -16,7 +16,7 @@ module Mom
|
||||
|
||||
# lazily instantiate the compiler for init function
|
||||
def init_compiler
|
||||
@init_compilers ||= create_init_compiler
|
||||
@init_compilers ||= MomCollection.create_init_compiler
|
||||
end
|
||||
|
||||
# Return all compilers, namely the MethodCompilers passed in, plus the
|
||||
@ -47,8 +47,8 @@ module Mom
|
||||
# - load fist message, set up Space as receiver
|
||||
# - call main, ie set up message for that etc
|
||||
# - exit (exit_sequence) which passes a machine int out to c
|
||||
def create_init_compiler
|
||||
compiler = self.class.compiler_for(:Object,:__init__ ,{})
|
||||
def self.create_init_compiler
|
||||
compiler = compiler_for(:Object,:__init__ ,{})
|
||||
compiler._reset_for_init # no return, just for init
|
||||
compiler.add_code Init.new("missing")
|
||||
return compiler
|
||||
|
@ -24,8 +24,10 @@ class RubyXC < Thor
|
||||
rescue
|
||||
fail MalformattedArgumentError , "No such file #{file}"
|
||||
end
|
||||
code = get_preload + ruby
|
||||
|
||||
compiler = RubyX::RubyXCompiler.new(extract_options)
|
||||
linker = compiler.ruby_to_binary(ruby, :interpreter)
|
||||
linker = compiler.ruby_to_binary(code, :interpreter)
|
||||
|
||||
puts "interpreting #{file}"
|
||||
|
||||
|
@ -105,5 +105,8 @@ module Vool
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Word)
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
":#{@value}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,6 @@ module Vool
|
||||
{
|
||||
"Object.get" => "def get_internal_word(at); X.get_internal_word;end",
|
||||
"Object.missing" => "def method_missing(at); X.method_missing;end",
|
||||
"Object.init" => "def __init__(at); X.init;end",
|
||||
"Object.exit" => "def exit; X.exit;end",
|
||||
"Integer.div4" => "def div4; X.div4;end",
|
||||
"Integer.div10" => "def div10; X.div10;end",
|
||||
@ -32,7 +31,7 @@ module Vool
|
||||
"Word.put" => "def putstring(at); X.putstring;end",
|
||||
"Word.set" => "def set_internal_byte(at, val); X.set_internal_byte;end",
|
||||
"Word.get" => "def get_internal_byte(at); X.get_internal_byte;end",
|
||||
"Space.main" => "def main(args);return;end",
|
||||
"Space.main" => "def main(args);return nil;end",
|
||||
}
|
||||
end
|
||||
def self.builtin_code
|
||||
|
@ -3,10 +3,6 @@ require_relative "../helper"
|
||||
module Elf
|
||||
|
||||
class FullTest < MiniTest::Test
|
||||
DEBUG = false
|
||||
|
||||
def setup
|
||||
end
|
||||
|
||||
def in_space(input)
|
||||
"class Space; #{input} ; end"
|
||||
|
@ -49,8 +49,9 @@ module Mains
|
||||
|
||||
def run_code(input , name )
|
||||
puts "Compiling #{name}.o" if DEBUG
|
||||
code = Vool::Builtin.builtin_code + input
|
||||
|
||||
linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( input , :arm )
|
||||
linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( code , :arm )
|
||||
writer = Elf::ObjectWriter.new(linker)
|
||||
|
||||
writer.save "mains.o"
|
||||
|
@ -4,18 +4,19 @@ module Mom
|
||||
module Builtin
|
||||
class TestObjectInitRisc < BootTest
|
||||
def setup
|
||||
super
|
||||
@method = get_compiler("Object",:init)
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
get_compiler("Space",:main)
|
||||
@method = MomCollection.create_init_compiler
|
||||
end
|
||||
def test_mom_length
|
||||
assert_equal :__init__ , @method.callable.name
|
||||
assert_equal 7 , @method.mom_instructions.length
|
||||
assert_equal 2 , @method.mom_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 31 , @method.to_risc.risc_instructions.length
|
||||
assert_equal 19 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -99,7 +99,7 @@ module Ruby
|
||||
assert_equal "'string'" , compile_const( "'string'")
|
||||
end
|
||||
def test_sym
|
||||
assert_equal "'symbol'" , compile_const( ":symbol")
|
||||
assert_equal ":symbol" , compile_const( ":symbol")
|
||||
end
|
||||
def test_nil
|
||||
assert_equal "nil" , compile_const( "nil")
|
||||
|
11
test/rubyx/test_compile.rb
Normal file
11
test/rubyx/test_compile.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliCompile < MiniTest::Test
|
||||
|
||||
def test_compile
|
||||
assert_output(/compiling/) {RubyXC.start(["compile" , "--preload","test/mains/source/add__4.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
11
test/rubyx/test_execute.rb
Normal file
11
test/rubyx/test_execute.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliExecute < MiniTest::Test
|
||||
|
||||
def test_execute
|
||||
assert_output(/Running/) {RubyXC.start(["execute" ,"--preload", "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
11
test/rubyx/test_interpret.rb
Normal file
11
test/rubyx/test_interpret.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliInterpret < MiniTest::Test
|
||||
|
||||
def test_interpret
|
||||
assert_output(/interpreting/) {RubyXC.start(["interpret" ,"--preload", "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
@ -13,21 +13,5 @@ module RubyX
|
||||
def test_file_fail
|
||||
assert_output(nil , /No such file/) {RubyXC.start(["compile" , "hi"])}
|
||||
end
|
||||
def test_file_open
|
||||
assert_output(/compiling/) {RubyXC.start(["compile" , "test/mains/source/add__4.rb"])}
|
||||
#File.delete "add__4.o"
|
||||
end
|
||||
def test_interpret
|
||||
assert_output(/interpreting/) {RubyXC.start(["interpret" , "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
def test_execute
|
||||
assert_output(/Running/) {RubyXC.start(["execute" , "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
def test_stats
|
||||
out, err = capture_io {RubyXC.start(["stats" , "test/mains/source/add__4.rb"])}
|
||||
assert out.include?("Space") , out
|
||||
assert out.include?("Total") , out
|
||||
assert out.include?("Objects=") , out
|
||||
end
|
||||
end
|
||||
end
|
||||
|
14
test/rubyx/test_stats.rb
Normal file
14
test/rubyx/test_stats.rb
Normal file
@ -0,0 +1,14 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliStats < MiniTest::Test
|
||||
|
||||
def test_stats
|
||||
out, err = capture_io {RubyXC.start(["stats" ,"--preload", "test/mains/source/add__4.rb"])}
|
||||
assert out.include?("Space") , out
|
||||
assert out.include?("Total") , out
|
||||
assert out.include?("Objects=") , out
|
||||
end
|
||||
end
|
||||
end
|
@ -6,7 +6,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@code = Macro.boot_methods({})
|
||||
@code = Builtin.boot_methods({})
|
||||
end
|
||||
def as_ruby
|
||||
@ruby = Ruby::RubyCompiler.compile(@code)
|
||||
|
@ -7,6 +7,9 @@ module Mom
|
||||
@a = arg
|
||||
@b = b
|
||||
end
|
||||
def to_risc(compiler)
|
||||
Risc.label("some" , "thing")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,6 +33,10 @@ module Vool
|
||||
assert_equal Vool::IntegerConstant , @ins.b.class
|
||||
assert_equal 1 , @ins.b.value
|
||||
end
|
||||
def test_to_risc
|
||||
comp = @compiler.to_risc
|
||||
assert_equal Risc::MethodCompiler , comp.class
|
||||
assert_equal :main , comp.callable.name
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user