Add mom boot options
and remove a lot of stale parfait boots from tests (from before using rubyxc)
This commit is contained in:
parent
1539904ee2
commit
2c681bf2e5
@ -26,7 +26,7 @@ module Mom
|
||||
#
|
||||
# We create an empty main for init to jump to, if no code is compiled, that just returns
|
||||
# See Builtin directory readme and module
|
||||
def self.boot_functions()
|
||||
def self.boot_functions( options = {})
|
||||
# TODO go through the virtual parfait layer and adjust function names
|
||||
# to what they really are
|
||||
compilers = []
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
module Mom
|
||||
# boot bubiltin function (subject to change)
|
||||
def self.boot!
|
||||
Builtin.boot_functions
|
||||
def self.boot!(options = {})
|
||||
Builtin.boot_functions(options)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,6 +42,5 @@ module Mom
|
||||
Risc::RiscCollection.new(riscs)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -15,7 +15,7 @@ end
|
||||
# See risc/Readme
|
||||
module Risc
|
||||
# module method to reset, and init
|
||||
def self.boot!
|
||||
def self.boot!(options = {})
|
||||
Position.clear_positions
|
||||
end
|
||||
end
|
||||
|
@ -19,11 +19,18 @@ thus "typing" the syntax tree, and making it concrete.
|
||||
|
||||
## to Vool
|
||||
|
||||
In our nice layers, we are ont the way down to Vool, a simplified version of oo.
|
||||
In our nice layers, we are on the way down to Vool, a simplified version of oo.
|
||||
|
||||
It has proven handy to have this layer, so the code for transforming each object
|
||||
is in the class representing that object. (As one does in oo, again imho).
|
||||
|
||||
## compile_time_expansions
|
||||
|
||||
We do some expansions at compile time that are in fact methods calls in real ruby.
|
||||
|
||||
First among those will be require (+ require_relative) , but attribute readers
|
||||
will surely follow.
|
||||
|
||||
## Parfait objects
|
||||
|
||||
The compilation process ends up creating (parfait) objects to represent
|
||||
|
@ -25,13 +25,14 @@ module RubyX
|
||||
#
|
||||
class RubyXCompiler
|
||||
|
||||
attr_reader :vool
|
||||
attr_reader :vool , :options
|
||||
|
||||
# initialize boots Parfait and Risc (ie load Builin)
|
||||
def initialize(options)
|
||||
@options = options
|
||||
Parfait.boot!(options[:parfait] || {})
|
||||
Mom.boot!
|
||||
Risc.boot!
|
||||
Mom.boot!(options[:mom] || {})
|
||||
Risc.boot!(options[:risc] || {})
|
||||
end
|
||||
|
||||
# The highest level function creates binary code for the given ruby code
|
||||
|
@ -32,7 +32,6 @@ module Mom
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
|
||||
@collection = @comp.to_risc()
|
||||
end
|
||||
|
@ -7,8 +7,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Risc.boot!
|
||||
@compiler = compile_first_method( send_method )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_block( "local = 5" )
|
||||
end
|
||||
def test_block_compiles
|
||||
@ -31,7 +30,6 @@ module VoolBlocks
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||
end
|
||||
def test_class_compiles
|
||||
@ -49,7 +47,6 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_block( "arg = 5")
|
||||
end
|
||||
|
||||
@ -67,7 +64,6 @@ module VoolBlocks
|
||||
class TestAssignMomToInstance < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
end
|
||||
def test_assigns_const
|
||||
@ins = compile_first_block( "@a = 5")
|
||||
|
@ -5,8 +5,6 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Mom::Builtin.boot_functions
|
||||
@ins = compile_first_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,6 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_block( "while(@a) ; @a = 5 ; end")
|
||||
end
|
||||
|
||||
|
@ -7,8 +7,6 @@ module Vool
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Mom.boot!
|
||||
@compiler = compile_first_method( send_method )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "5.div8")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,8 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Risc.boot!
|
||||
@compiler = compile_first_method( "a = main(1 + 2);return a" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "local = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
@ -34,7 +33,6 @@ module Vool
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "@a = 5 ; local = @a;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
@ -48,7 +46,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "arg = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -6,7 +6,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -6,7 +6,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "unless(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -6,7 +6,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "@a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "return 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
@ -42,7 +41,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "return 5.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "while(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -6,7 +6,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "return yield(1)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
@ -70,7 +69,6 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "return yield(some.extra.calls)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user