add the ! syntax to create variables in builder, fix #8

now a variable has to be created before being used
thus it is save to develop contracts where a certain name
must exist in the scope
Maybe the syntax starts getting a bit weird, but at least the ! is a common symbol in ruby
This commit is contained in:
Torsten Ruger
2018-08-14 19:39:46 +03:00
parent 0bf008b351
commit 37461a1727
9 changed files with 68 additions and 60 deletions

View File

@ -36,16 +36,16 @@ module Mom
def build_with(builder)
case from = method_source
when Parfait::CallableMethod
builder.build { callable << from }
builder.build { callable! << from }
when Parfait::CacheEntry
builder.build do
cache_entry << from
callable << cache_entry[:cached_method]
cache_entry! << from
callable! << cache_entry[:cached_method]
end
when Integer
builder.build do
arguments << message[:arguments]
callable << arguments[ from ]
arguments! << message[:arguments]
callable! << arguments[ from ]
end
else
raise "unknown source #{method_source.class}:#{method_source}"
@ -64,11 +64,11 @@ 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]
next_message_reg! << next_message[:next_message]
space[:next_message] << next_message_reg
message[:next_message] << next_message