finish the idea behind #8, conditionally creating variables
by using space? , the ? makes for conditional creation of the variable This is especially useful for constants (ie space)
This commit is contained in:
parent
01752aab05
commit
1dabe0fda1
@ -64,8 +64,8 @@ module Mom
|
||||
# set the method into the message
|
||||
def build_message_data( builder )
|
||||
builder.build do
|
||||
space! << Parfait.object_space
|
||||
next_message! << space[:next_message]
|
||||
space? << Parfait.object_space
|
||||
next_message? << space[:next_message]
|
||||
|
||||
#FIXME in a multithreaded future this should be done using lock free compare and swap.
|
||||
next_message_reg! << next_message[:next_message]
|
||||
@ -75,14 +75,6 @@ module Mom
|
||||
next_message[:caller] << message
|
||||
next_message[:method] << callable
|
||||
|
||||
# type << callable[:arguments_type]
|
||||
# named_list << next_message[:arguments]
|
||||
# named_list[:type] << type
|
||||
#
|
||||
# type << callable[:frame_type]
|
||||
# named_list << next_message[:frame]
|
||||
# named_list[:type] << type
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,9 +39,16 @@ module Risc
|
||||
reg = Risc.label( @source , "#{name}_#{object_id}")
|
||||
@source_used = true
|
||||
else
|
||||
raise "Must create (with !) before using #{name}" unless name[-1] == "!"
|
||||
last_char = name[-1]
|
||||
name = name[0 ... -1]
|
||||
#raise "name exists before being created #{name}" if @names.has_key?(name)
|
||||
if last_char == "!" or last_char == "?"
|
||||
if @names.has_key?(name)
|
||||
return @names[name] if last_char == "?"
|
||||
raise "Name exists before creating it #{name}#{last_char}"
|
||||
end
|
||||
else
|
||||
raise "Must create (with ! or ?) before using #{name}#{last_char}"
|
||||
end
|
||||
type = infer_type(name )
|
||||
reg = @compiler.use_reg( type.object_class.name ).set_builder(self)
|
||||
end
|
||||
@ -130,7 +137,7 @@ module Risc
|
||||
to.set_builder( self ) # esecially div10 comes in without having used builder
|
||||
from.set_builder( self ) # not named regs, different regs ==> silent errors
|
||||
build do
|
||||
space! << Parfait.object_space
|
||||
space? << Parfait.object_space
|
||||
to << space[:next_integer]
|
||||
integer_2! << to[:next_integer]
|
||||
space[:next_integer] << integer_2
|
||||
|
@ -25,6 +25,17 @@ module Risc
|
||||
def test_caller_reg
|
||||
assert_equal :Message , @builder.infer_type(:caller_reg).class_name
|
||||
end
|
||||
def test_define_twice
|
||||
@builder.caller_reg!
|
||||
assert_raises{ @builder.caller_reg! }
|
||||
end
|
||||
def test_define_conditionally_first
|
||||
assert_equal :r1 , @builder.caller_reg?.symbol
|
||||
end
|
||||
def test_define_conditionally_again
|
||||
first = @builder.caller_reg!
|
||||
assert_equal first , @builder.caller_reg?
|
||||
end
|
||||
def test_caller_tmp
|
||||
assert_equal :Message , @builder.infer_type(:caller_tmp).class_name
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user