put everything into register module (avoid clashes)

This commit is contained in:
Torsten Ruger 2017-01-03 22:37:25 +02:00
parent d94af2a724
commit a14a0de9d1
7 changed files with 318 additions and 314 deletions

View File

@ -1,6 +1,7 @@
require_relative '../helper'
module ExpressionHelper
module Register
module ExpressionHelper
def check
Register.machine.boot unless Register.machine.booted
@ -18,9 +19,9 @@ module ExpressionHelper
class_type = Parfait.object_space.get_class_by_name(:Space).instance_type
class_type.send(:private_add_instance_variable, name , type)
end
end
end
module Statements
module Statements
include AST::Sexp
include Compiling
@ -60,4 +61,5 @@ module Statements
end
ret
end
end
end

View File

@ -1,7 +1,7 @@
require_relative 'helper'
module Register
class TestAssignStatement < MiniTest::Test
class TestAssignStatement < MiniTest::Test
include Statements
def test_assign_op
@ -96,5 +96,5 @@ class TestAssignStatement < MiniTest::Test
assert_equal SlotToReg , get.class
assert_equal 1 + 1, get.index , "Get to args index must be offset, not #{get.index}"
end
end
end
end

View File

@ -1,7 +1,8 @@
require_relative "helper"
module Register
class TestBasic < MiniTest::Test
class TestBasic < MiniTest::Test
include ExpressionHelper
include AST::Sexp
@ -36,4 +37,5 @@ class TestBasic < MiniTest::Test
check
end
end
end

View File

@ -2,7 +2,7 @@ require_relative 'helper'
require_relative "test_call_expression"
module Register
class TestCallStatement < MiniTest::Test
class TestCallStatement < MiniTest::Test
include Statements
def test_call_constant_int
@ -50,14 +50,14 @@ class TestCallStatement < MiniTest::Test
def _test_call_puts
@input = <<HERE
class Space
int puts(Word str)
class Space
int puts(Word str)
return str
end
int main()
end
int main()
puts("Hello")
end
end
end
end
HERE
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
@ -67,5 +67,5 @@ HERE
assert_equal RegToSlot , set.class
assert_equal 9, set.index , "Set to message must be offset, not #{set.index}"
end
end
end
end

View File

@ -1,7 +1,7 @@
require_relative 'helper'
module Register
class TestClassStatements < MiniTest::Test
class TestClassStatements < MiniTest::Test
include Statements
def class_def
@ -27,5 +27,5 @@ class TestClassStatements < MiniTest::Test
# @expect = [Label, SlotToReg,SlotToReg,RegToSlot,Label,FunctionReturn]
# check
end
end
end
end

View File

@ -1,7 +1,7 @@
require_relative 'helper'
module Register
class TestIfStatement < MiniTest::Test
class TestIfStatement < MiniTest::Test
include Statements
def test_if_basicr
@ -31,5 +31,5 @@ class TestIfStatement < MiniTest::Test
Label,Label, FunctionReturn]
check
end
end
end
end

View File

@ -1,7 +1,7 @@
require_relative 'helper'
module Register
class TestReturnStatement < MiniTest::Test
class TestReturnStatement < MiniTest::Test
include Statements
def test_return_int
@ -40,5 +40,5 @@ class TestReturnStatement < MiniTest::Test
check
end
end
end
end