move type resolution to compiler
from risc_value. also unite mock compilers
This commit is contained in:
@ -1,21 +1,6 @@
|
||||
require_relative '../helper'
|
||||
|
||||
module Mom
|
||||
class CompilerMock
|
||||
# resolve a symbol to a type. Allowed symbols are :frame , :receiver and arguments
|
||||
# which return the respective types, otherwise nil
|
||||
def resolve_type( name )
|
||||
return nil
|
||||
end
|
||||
def use_reg( type )
|
||||
Risc.tmp_reg(type )
|
||||
end
|
||||
def reset_regs
|
||||
|
||||
end
|
||||
def add_constant(c)
|
||||
end
|
||||
end
|
||||
class InstructionMock < Instruction
|
||||
end
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ module Mom
|
||||
class TestSlotDefinitionConstant < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@compiler = CompilerMock.new
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = SlotDefinition.new(StringConstant.new("hi") , [])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ module Mom
|
||||
class TestSlotDefinitionKnown1 < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@compiler = CompilerMock.new
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = SlotDefinition.new(:message , :caller)
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ module Mom
|
||||
class TestSlotDefinitionKnown2 < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@compiler = CompilerMock.new
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = SlotDefinition.new(:message , [:caller , :type])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
end
|
||||
|
@ -11,11 +11,11 @@ module Mom
|
||||
end
|
||||
def test_fail_on_right
|
||||
@load = SlotLoad.new( [:message, :caller] , [:receiver,:type] )
|
||||
assert_raises {@load.to_risc(CompilerMock.new)}
|
||||
assert_raises {@load.to_risc(Risc::FakeCompiler.new)}
|
||||
end
|
||||
def test_fail_on_left_long
|
||||
@load = SlotLoad.new( [:message, :caller , :type] , [:receiver,:type] )
|
||||
assert_raises {@load.to_risc(CompilerMock.new)}
|
||||
assert_raises {@load.to_risc(Risc::FakeCompiler.new)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Mom
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@load = SlotLoad.new( [:message, :caller] , [:message,:type] )
|
||||
@compiler = CompilerMock.new
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Mom
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@load = SlotLoad.new( [:message, :caller, :type] , [:message, :caller , :type] )
|
||||
@compiler = CompilerMock.new
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user