slightly changing built return logic
very tempted to add immediately, but bigger change
This commit is contained in:
parent
dd0d162ebf
commit
db55ec3fd6
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user