Change Mom to SlotMachine

rather large commit, but essentially a simple rename
Rationale in docs and blogs
This commit is contained in:
2019-10-03 20:55:41 +03:00
parent fd8a3e9cc5
commit c43436f35a
170 changed files with 481 additions and 480 deletions

View File

@ -9,14 +9,14 @@ module RubyX
options = RubyX.default_test_options.merge(options)
RubyXCompiler.new(options).ruby_to_vool(input)
end
def ruby_to_mom(input , options = {})
def ruby_to_slot(input , options = {})
options = RubyX.default_test_options.merge(options)
RubyXCompiler.new(options).ruby_to_mom(input)
RubyXCompiler.new(options).ruby_to_slot(input)
end
def compile_in_test( input , options = {})
vool = ruby_to_vool(in_Test(input) , options)
vool.to_parfait
vool.to_mom(nil)
vool.to_slot(nil)
itest = Parfait.object_space.get_class_by_name(:Test)
assert itest
itest

View File

@ -10,10 +10,10 @@ On the way there, we start by Testing and moving the old ones. Since we want to
to test some methods even after the move, without parsing/processing the whole of parfait
we have to have a method of "injecting" the single? methods.
## Mom level
## SlotMachine level
There a re two test levels to every method. Mom being the first, where we basically just
see if the right Mom instruction has been generated
There a re two test levels to every method. SlotMachine being the first, where we basically just
see if the right SlotMachine instruction has been generated
## Risc

View File

@ -4,10 +4,10 @@ module RubyX
module MacroHelper
def setup
whole ="class Space;def main(arg);return;end;end;" + source
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(whole)
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(whole)
@mom.method_compilers
assert_equal Mom::MomCollection , @mom.class
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::SlotCollection , @mom.class
assert_equal SlotMachine::MethodCompiler , compiler.class
end
def compiler
@mom.method_compilers.last_compiler

View File

@ -15,15 +15,15 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal op , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_op
assert_equal Mom::Comparison , compiler.mom_instructions.next.class
assert_equal op , compiler.mom_instructions.next.operator
assert_equal SlotMachine::Comparison , compiler.slot_instructions.next.class
assert_equal op , compiler.slot_instructions.next.operator
end
def test_risc
assert_equal len , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :div10 , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Div10 , compiler.mom_instructions.next.class
assert_equal SlotMachine::Div10 , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 70 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :div4 , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Div4 , compiler.mom_instructions.next.class
assert_equal SlotMachine::Div4 , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 41 , compiler.to_risc.risc_instructions.length

View File

@ -14,15 +14,15 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal op , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_op
assert_equal Mom::IntOperator , compiler.mom_instructions.next.class
assert_equal op , compiler.mom_instructions.next.operator
assert_equal SlotMachine::IntOperator , compiler.slot_instructions.next.class
assert_equal op , compiler.slot_instructions.next.operator
end
def test_risc
assert_equal 42 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :exit , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Exit , compiler.mom_instructions.next.class
assert_equal SlotMachine::Exit , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 40 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :get_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalWord , compiler.mom_instructions.next.class
assert_equal SlotMachine::GetInternalWord , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 18 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :__init , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Init , compiler.mom_instructions.next.class
assert_equal SlotMachine::Init , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 31 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :method_missing , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::MethodMissing , compiler.mom_instructions.next.class
assert_equal SlotMachine::MethodMissing , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 15 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :set_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::SetInternalWord , compiler.mom_instructions.next.class
assert_equal SlotMachine::SetInternalWord , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 19 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :get_internal_byte , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalByte , compiler.mom_instructions.next.class
assert_equal SlotMachine::GetInternalByte , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 41 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :putstring , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Putstring , compiler.mom_instructions.next.class
assert_equal SlotMachine::Putstring , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 44 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :set_internal_byte , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::SetInternalByte , compiler.mom_instructions.next.class
assert_equal SlotMachine::SetInternalByte , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 20 , compiler.to_risc.risc_instructions.length

View File

@ -8,7 +8,7 @@ Since we need Parfait in the runtime, we need to parse it and compile it.
And since it is early days, we expect errors at every level during this process, which
means testing every layer for every file.
Rather than create parfait tests for every layer (ie in the vool/mom/risc directories)
Rather than create parfait tests for every layer (ie in the vool/slot_machine/risc directories)
we have one file per parfait file here. Each file tests all layers.
The usual workflow is to start with a new file and create tests for vool, mom, risc,binary

View File

@ -27,9 +27,9 @@ module RubyX
assert_equal :Data4 , vool[2].name
assert_equal :Data8 , vool[3].name
end
def test_mom
mom = @compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
def test_slot
mom = @compiler.ruby_to_slot source
assert_equal SlotMachine::SlotCollection , mom.class
end
def test_risc
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)

View File

@ -25,12 +25,12 @@ module RubyX
assert_equal :Data4 , vool[2].name
assert_equal :Data8 , vool[3].name
end
def test_mom
def test_slot
vool = @compiler.ruby_to_vool source
vool.to_parfait
#puts vool
mom = vool.to_mom(nil)
assert_equal Mom::MomCollection , mom.class
mom = vool.to_slot(nil)
assert_equal SlotMachine::SlotCollection , mom.class
end
def est_risc
risc = compiler.ruby_to_risc source

View File

@ -18,9 +18,9 @@ module RubyX
assert_equal Vool::ClassExpression , vool.class
assert_equal :Object , vool.name
end
def test_mom
mom = compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
def test_slot
mom = compiler.ruby_to_slot source
assert_equal SlotMachine::SlotCollection , mom.class
end
def test_risc
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)

View File

@ -1,24 +1,24 @@
require_relative "helper"
module RubyX
class TestRubyXCompilerMom < MiniTest::Test
class TestRubyXCompilerSlotMachine < MiniTest::Test
include ScopeHelper
include RubyXHelper
def test_creates_class_without_deriviation
ruby_to_mom "class Testing ; end"
ruby_to_slot "class Testing ; end"
clazz = Parfait.object_space.get_class_by_name(:Testing)
assert clazz , "No classes created"
assert_equal :Object , clazz.super_class_name
end
def test_creates_class_deriviation
mom = ruby_to_mom "class Testing ; end"
mom = ruby_to_slot "class Testing ; end"
assert mom , "No classes created"
end
def test_creates_class_with_deriviation
ruby_to_mom "class Test2 < List ;end"
ruby_to_slot "class Test2 < List ;end"
clazz = Parfait.object_space.get_class_by_name(:Test2)
assert clazz, "No classes created"
assert_equal :List , clazz.super_class_name