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
|
# set the method into the message
|
||||||
def build_message_data( builder )
|
def build_message_data( builder )
|
||||||
builder.build do
|
builder.build do
|
||||||
space! << Parfait.object_space
|
space? << Parfait.object_space
|
||||||
next_message! << space[:next_message]
|
next_message? << space[:next_message]
|
||||||
|
|
||||||
#FIXME in a multithreaded future this should be done using lock free compare and swap.
|
#FIXME in a multithreaded future this should be done using lock free compare and swap.
|
||||||
next_message_reg! << next_message[:next_message]
|
next_message_reg! << next_message[:next_message]
|
||||||
@ -75,14 +75,6 @@ module Mom
|
|||||||
next_message[:caller] << message
|
next_message[:caller] << message
|
||||||
next_message[:method] << callable
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,9 +39,16 @@ module Risc
|
|||||||
reg = Risc.label( @source , "#{name}_#{object_id}")
|
reg = Risc.label( @source , "#{name}_#{object_id}")
|
||||||
@source_used = true
|
@source_used = true
|
||||||
else
|
else
|
||||||
raise "Must create (with !) before using #{name}" unless name[-1] == "!"
|
last_char = name[-1]
|
||||||
name = name[0 ... -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 )
|
type = infer_type(name )
|
||||||
reg = @compiler.use_reg( type.object_class.name ).set_builder(self)
|
reg = @compiler.use_reg( type.object_class.name ).set_builder(self)
|
||||||
end
|
end
|
||||||
@ -130,7 +137,7 @@ module Risc
|
|||||||
to.set_builder( self ) # esecially div10 comes in without having used builder
|
to.set_builder( self ) # esecially div10 comes in without having used builder
|
||||||
from.set_builder( self ) # not named regs, different regs ==> silent errors
|
from.set_builder( self ) # not named regs, different regs ==> silent errors
|
||||||
build do
|
build do
|
||||||
space! << Parfait.object_space
|
space? << Parfait.object_space
|
||||||
to << space[:next_integer]
|
to << space[:next_integer]
|
||||||
integer_2! << to[:next_integer]
|
integer_2! << to[:next_integer]
|
||||||
space[:next_integer] << integer_2
|
space[:next_integer] << integer_2
|
||||||
|
@ -25,6 +25,17 @@ module Risc
|
|||||||
def test_caller_reg
|
def test_caller_reg
|
||||||
assert_equal :Message , @builder.infer_type(:caller_reg).class_name
|
assert_equal :Message , @builder.infer_type(:caller_reg).class_name
|
||||||
end
|
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
|
def test_caller_tmp
|
||||||
assert_equal :Message , @builder.infer_type(:caller_tmp).class_name
|
assert_equal :Message , @builder.infer_type(:caller_tmp).class_name
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user