slightly changing built return logic

very tempted to add immediately, but bigger change
This commit is contained in:
Torsten Ruger 2018-04-07 00:35:54 +03:00
parent dd0d162ebf
commit db55ec3fd6
4 changed files with 19 additions and 19 deletions

View File

@ -36,7 +36,7 @@ module Mom
def build_with(builder)
from = method_source
risc = builder.build { typed_method << from }
build_message_data(builder)
risc << build_message_data(builder)
builder.compiler.reset_regs
return risc
end

View File

@ -25,9 +25,16 @@ module Risc
end
def build(&block)
@built = nil
instance_eval(&block)
return built
return @built
end
def build_and_add(&block)
risc = build(&block)
@compiler.add_code(risc)
end
def add_instruction(ins)
if(@built)
@built << ins

View File

@ -47,17 +47,17 @@ module Risc
compiler = Risc::MethodCompiler.create_method(:Object,:__init__ ,
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
builder = Risc::Builder.new(compiler)
risc = builder.build do
builder.build_and_add do
space << Parfait.object_space
message << space[:first_message]
next_message << message[:next_message]
space[:first_message] << next_message
end
risc = Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder )
compiler.add_code(risc)
Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder )
builder.build do
builder.build_and_add do
message << message[:next_message]
message[:receiver] << space
end

View File

@ -9,6 +9,12 @@ module Risc
compiler = Risc::MethodCompiler.new( init )
@builder = Builder.new(compiler)
end
def test_has_build
assert @builder.respond_to?(:build)
end
def test_has_attribute
assert_nil @builder.built
end
def test_alloc_space
reg = @builder.space
assert_equal RiscValue , reg.class
@ -60,17 +66,4 @@ module Risc
assert_equal :r0 , built.array.symbol
end
end
class TestBuilderNoBoot < MiniTest::Test
def setup
@builder = Builder.new(nil)
end
def test_has_build
assert_nil @builder.build{ }
end
def test_has_attribute
assert_nil @builder.built
end
end
end