From 9c499c7a198118827b3be4bedc67ac4f24e3388f Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 12 Apr 2017 11:53:02 +0300 Subject: [PATCH] actually start doing something in to_mom though still dummy --- lib/mom/instruction.rb | 2 ++ lib/mom/slot_load.rb | 6 ++++++ lib/vool/statements/assignment_statement.rb | 3 +++ test/mom/test_assignment.rb | 10 +++++++-- test/vool/to_mom/test_assignemnt.rb | 24 +++++++++++++++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 lib/mom/slot_load.rb create mode 100644 test/vool/to_mom/test_assignemnt.rb diff --git a/lib/mom/instruction.rb b/lib/mom/instruction.rb index 72030c11..5782d144 100644 --- a/lib/mom/instruction.rb +++ b/lib/mom/instruction.rb @@ -5,3 +5,5 @@ module Mom end end + +require_relative "slot_load" diff --git a/lib/mom/slot_load.rb b/lib/mom/slot_load.rb new file mode 100644 index 00000000..267c12d6 --- /dev/null +++ b/lib/mom/slot_load.rb @@ -0,0 +1,6 @@ +module Mom + + class SlotLoad < Instruction + end + +end diff --git a/lib/vool/statements/assignment_statement.rb b/lib/vool/statements/assignment_statement.rb index cd55ac1a..36fcd523 100644 --- a/lib/vool/statements/assignment_statement.rb +++ b/lib/vool/statements/assignment_statement.rb @@ -14,6 +14,9 @@ module Vool def add_local( array ) array << @name end + def to_mom( method ) + Mom::SlotLoad.new + end end class InstanceAssignment < Assignment # used to collect type information diff --git a/test/mom/test_assignment.rb b/test/mom/test_assignment.rb index b6545196..2da5fafe 100644 --- a/test/mom/test_assignment.rb +++ b/test/mom/test_assignment.rb @@ -4,8 +4,14 @@ module Mom class TestAssignemnt < MiniTest::Test include CompilerHelper - def test_class_exists - assert Instruction.new + def setup + Risc.machine.boot end + + def compile_first input + lst = Vool::VoolCompiler.compile in_Space( input ) + lst.to_mom( nil ) + end + end end diff --git a/test/vool/to_mom/test_assignemnt.rb b/test/vool/to_mom/test_assignemnt.rb new file mode 100644 index 00000000..8bc16b86 --- /dev/null +++ b/test/vool/to_mom/test_assignemnt.rb @@ -0,0 +1,24 @@ +require_relative "helper" + +module Vool + class TestAssignemnt < MiniTest::Test + include CompilerHelper + + def setup + Risc.machine.boot + end + + def compile_first_method input + lst = VoolCompiler.compile as_main( input ) + assert_equal Parfait::Class , lst.clazz.class , input + method = lst.clazz.get_method(:main) + assert method + lst.to_mom( nil ).first + end + + def test_class_compiles + meth = compile_first_method( "a = 5") + assert_equal Mom::SlotLoad , meth.first.class , meth + end + end +end