put everything into register module (avoid clashes)
This commit is contained in:
parent
d94af2a724
commit
a14a0de9d1
@ -1,6 +1,7 @@
|
|||||||
require_relative '../helper'
|
require_relative '../helper'
|
||||||
|
|
||||||
module ExpressionHelper
|
module Register
|
||||||
|
module ExpressionHelper
|
||||||
|
|
||||||
def check
|
def check
|
||||||
Register.machine.boot unless Register.machine.booted
|
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 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
class_type.send(:private_add_instance_variable, name , type)
|
class_type.send(:private_add_instance_variable, name , type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Statements
|
module Statements
|
||||||
include AST::Sexp
|
include AST::Sexp
|
||||||
include Compiling
|
include Compiling
|
||||||
|
|
||||||
@ -60,4 +61,5 @@ module Statements
|
|||||||
end
|
end
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
class TestAssignStatement < MiniTest::Test
|
class TestAssignStatement < MiniTest::Test
|
||||||
include Statements
|
include Statements
|
||||||
|
|
||||||
def test_assign_op
|
def test_assign_op
|
||||||
@ -96,5 +96,5 @@ class TestAssignStatement < MiniTest::Test
|
|||||||
assert_equal SlotToReg , get.class
|
assert_equal SlotToReg , get.class
|
||||||
assert_equal 1 + 1, get.index , "Get to args index must be offset, not #{get.index}"
|
assert_equal 1 + 1, get.index , "Get to args index must be offset, not #{get.index}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
|
module Register
|
||||||
|
|
||||||
class TestBasic < MiniTest::Test
|
class TestBasic < MiniTest::Test
|
||||||
include ExpressionHelper
|
include ExpressionHelper
|
||||||
include AST::Sexp
|
include AST::Sexp
|
||||||
|
|
||||||
@ -36,4 +37,5 @@ class TestBasic < MiniTest::Test
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ require_relative 'helper'
|
|||||||
require_relative "test_call_expression"
|
require_relative "test_call_expression"
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
class TestCallStatement < MiniTest::Test
|
class TestCallStatement < MiniTest::Test
|
||||||
include Statements
|
include Statements
|
||||||
|
|
||||||
def test_call_constant_int
|
def test_call_constant_int
|
||||||
@ -50,14 +50,14 @@ class TestCallStatement < MiniTest::Test
|
|||||||
|
|
||||||
def _test_call_puts
|
def _test_call_puts
|
||||||
@input = <<HERE
|
@input = <<HERE
|
||||||
class Space
|
class Space
|
||||||
int puts(Word str)
|
int puts(Word str)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
int main()
|
int main()
|
||||||
puts("Hello")
|
puts("Hello")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
||||||
RegToSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
|
RegToSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
|
||||||
@ -67,5 +67,5 @@ HERE
|
|||||||
assert_equal RegToSlot , set.class
|
assert_equal RegToSlot , set.class
|
||||||
assert_equal 9, set.index , "Set to message must be offset, not #{set.index}"
|
assert_equal 9, set.index , "Set to message must be offset, not #{set.index}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
class TestClassStatements < MiniTest::Test
|
class TestClassStatements < MiniTest::Test
|
||||||
include Statements
|
include Statements
|
||||||
|
|
||||||
def class_def
|
def class_def
|
||||||
@ -27,5 +27,5 @@ class TestClassStatements < MiniTest::Test
|
|||||||
# @expect = [Label, SlotToReg,SlotToReg,RegToSlot,Label,FunctionReturn]
|
# @expect = [Label, SlotToReg,SlotToReg,RegToSlot,Label,FunctionReturn]
|
||||||
# check
|
# check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
class TestIfStatement < MiniTest::Test
|
class TestIfStatement < MiniTest::Test
|
||||||
include Statements
|
include Statements
|
||||||
|
|
||||||
def test_if_basicr
|
def test_if_basicr
|
||||||
@ -31,5 +31,5 @@ class TestIfStatement < MiniTest::Test
|
|||||||
Label,Label, FunctionReturn]
|
Label,Label, FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
class TestReturnStatement < MiniTest::Test
|
class TestReturnStatement < MiniTest::Test
|
||||||
include Statements
|
include Statements
|
||||||
|
|
||||||
def test_return_int
|
def test_return_int
|
||||||
@ -40,5 +40,5 @@ class TestReturnStatement < MiniTest::Test
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user