rename internal get/set functions

mainly because the salaam parser chokes on internal…
This commit is contained in:
Torsten Ruger 2015-11-07 17:40:59 +02:00
parent 8aabff6b37
commit 37928b8591
11 changed files with 39 additions and 39 deletions

View File

@ -125,7 +125,7 @@ module Interpreter
else else
index = get_register(@instruction.index) index = get_register(@instruction.index)
end end
value = object.internal_object_get( index ) value = object.get_internal( index )
#value = value.object_id unless value.is_a? Fixnum #value = value.object_id unless value.is_a? Fixnum
set_register( @instruction.register , value ) set_register( @instruction.register , value )
true true
@ -134,7 +134,7 @@ module Interpreter
def execute_SetSlot def execute_SetSlot
value = object_for( @instruction.register ) value = object_for( @instruction.register )
object = object_for( @instruction.array ) object = object_for( @instruction.array )
object.internal_object_set( @instruction.index , value ) object.set_internal( @instruction.index , value )
trigger(:object_changed, @instruction.array , @instruction.index) trigger(:object_changed, @instruction.array , @instruction.index)
true true
end end
@ -152,7 +152,7 @@ module Interpreter
def execute_FunctionReturn def execute_FunctionReturn
object = object_for( @instruction.register ) object = object_for( @instruction.register )
link = object.internal_object_get( @instruction.index ) link = object.get_internal( @instruction.index )
@instruction = link @instruction = link
# we jump back to the call instruction. so it is as if the call never happened and we continue # we jump back to the call instruction. so it is as if the call never happened and we continue
true true

View File

@ -154,7 +154,7 @@ module Parfait
end end
define_method :get_length do define_method :get_length do
r = internal_object_get( offset ) #one for layout r = get_internal( offset ) #one for layout
r.nil? ? 0 : r r.nil? ? 0 : r
end end
@ -166,7 +166,7 @@ module Parfait
grow_to(index) grow_to(index)
end end
# start one higher than offset, which is where the length is # start one higher than offset, which is where the length is
internal_object_set( index + offset, value) set_internal( index + offset, value)
end end
# set the value at index. # set the value at index.
@ -176,7 +176,7 @@ module Parfait
ret = nil ret = nil
if(index <= self.get_length) if(index <= self.get_length)
# start one higher than offset, which is where the length is # start one higher than offset, which is where the length is
ret = internal_object_get(index + offset ) ret = get_internal(index + offset )
end end
ret ret
end end
@ -187,14 +187,14 @@ module Parfait
return if old_length >= len return if old_length >= len
# raise "bounds error at #{len}" if( len + offset > 16 ) # raise "bounds error at #{len}" if( len + offset > 16 )
# be nice to use the indexed_length , but that relies on booted space # be nice to use the indexed_length , but that relies on booted space
internal_object_set( offset , len) #one for layout set_internal( offset , len) #one for layout
end end
define_method :shrink_to do | len| define_method :shrink_to do | len|
raise "Only positive lenths, #{len}" if len < 0 raise "Only positive lenths, #{len}" if len < 0
old_length = self.get_length old_length = self.get_length
return if old_length <= len return if old_length <= len
internal_object_set( offset , len) set_internal( offset , len)
end end
end end

View File

@ -74,8 +74,8 @@ module Parfait
raise "Use variable_index instead" raise "Use variable_index instead"
end end
# index of the variable when using internal_object_get # index of the variable when using get_internal
# (internal_object_get is 1 based and 1 is always the layout) # (get_internal is 1 based and 1 is always the layout)
def variable_index name def variable_index name
has = super_index(name) has = super_index(name)
return nil unless has return nil unless has

View File

@ -56,16 +56,16 @@ module Parfait
def set_layout(layout) def set_layout(layout)
# puts "Layout was set for #{self.class}" # puts "Layout was set for #{self.class}"
raise "Nil layout" unless layout raise "Nil layout" unless layout
internal_object_set(LAYOUT_INDEX , layout) set_internal(LAYOUT_INDEX , layout)
end end
# so we can keep the raise in get_layout # so we can keep the raise in get_layout
def has_layout? def has_layout?
! internal_object_get(LAYOUT_INDEX).nil? ! get_internal(LAYOUT_INDEX).nil?
end end
def get_layout() def get_layout()
l = internal_object_get(LAYOUT_INDEX) l = get_internal(LAYOUT_INDEX)
#puts "get layout for #{self.class} returns #{l.class}" #puts "get layout for #{self.class} returns #{l.class}"
raise "No layout #{self.object_id}:#{self.class} " unless l raise "No layout #{self.object_id}:#{self.class} " unless l
return l return l
@ -84,13 +84,13 @@ module Parfait
index = instance_variable_defined(name) index = instance_variable_defined(name)
#puts "getting #{name} at #{index}" #puts "getting #{name} at #{index}"
return nil if index == nil return nil if index == nil
return internal_object_get(index) return get_internal(index)
end end
def set_instance_variable name , value def set_instance_variable name , value
index = instance_variable_defined(name) index = instance_variable_defined(name)
return nil if index == nil return nil if index == nil
return internal_object_set(index , value) return set_internal(index , value)
end end
def instance_variable_defined name def instance_variable_defined name

View File

@ -82,7 +82,7 @@ module Parfait
def set_char at , char def set_char at , char
raise "char not fixnum #{char.class}" unless char.kind_of? Fixnum raise "char not fixnum #{char.class}" unless char.kind_of? Fixnum
index = range_correct_index(at) index = range_correct_index(at)
internal_object_set( index + 2, char ) set_internal( index + 2, char )
end end
# get the character at the given index # get the character at the given index
@ -91,7 +91,7 @@ module Parfait
#the return "character" is an integer #the return "character" is an integer
def get_char at def get_char at
index = range_correct_index(at) index = range_correct_index(at)
return internal_object_get(index + 2 ) return get_internal(index + 2 )
end end
# private method to calculate negative indexes into positives # private method to calculate negative indexes into positives

View File

@ -74,11 +74,11 @@ module Parfait
end end
# 1 -based index # 1 -based index
def internal_object_get(index) def get_internal(index)
@memory[index] @memory[index]
end end
# 1 -based index # 1 -based index
def internal_object_set(index , value) def set_internal(index , value)
raise "failed init for #{self.class}" unless @memory raise "failed init for #{self.class}" unless @memory
@memory[index] = value @memory[index] = value
value value

View File

@ -39,7 +39,7 @@ class AddTest < MiniTest::Test
assert_equal Register::FunctionReturn , ret.class assert_equal Register::FunctionReturn , ret.class
object = @interpreter.object_for( ret.register ) object = @interpreter.object_for( ret.register )
link = object.internal_object_get( ret.index ) link = object.get_internal( ret.index )
assert_equal Register::Label , link.class assert_equal Register::Label , link.class
end end

View File

@ -17,11 +17,11 @@ class TestLayout < MiniTest::Test
assert_equal @mess.next_message , @mess.get_instance_variable(:next_message) assert_equal @mess.next_message , @mess.get_instance_variable(:next_message)
index = @mess.get_layout.variable_index :next_message index = @mess.get_layout.variable_index :next_message
assert_equal 2 , index assert_equal 2 , index
assert_equal @mess.next_message , @mess.internal_object_get(index) assert_equal @mess.next_message , @mess.get_internal(index)
end end
def test_layout_index def test_layout_index
assert_equal @mess.get_layout , @mess.internal_object_get(Parfait::LAYOUT_INDEX) , "mess" assert_equal @mess.get_layout , @mess.get_internal(Parfait::LAYOUT_INDEX) , "mess"
end end
def test_inspect def test_inspect
@ -38,7 +38,7 @@ class TestLayout < MiniTest::Test
def test_layout_length def test_layout_length
assert_equal 9 , @mess.get_layout.instance_length , @mess.get_layout.inspect assert_equal 9 , @mess.get_layout.instance_length , @mess.get_layout.inspect
assert_equal 18 , @mess.get_layout.internal_object_get(4) assert_equal 18 , @mess.get_layout.get_internal(4)
end end
def test_layout_length_index def test_layout_length_index
@ -46,7 +46,7 @@ class TestLayout < MiniTest::Test
assert_equal 4 , @mess.get_layout.get_layout.get_offset assert_equal 4 , @mess.get_layout.get_layout.get_offset
assert_equal 4 , @mess.get_layout.get_offset assert_equal 4 , @mess.get_layout.get_offset
assert_equal 8 , @mess.get_layout.get_layout.indexed_length assert_equal 8 , @mess.get_layout.get_layout.indexed_length
assert_equal 8 , @mess.get_layout.get_layout.internal_object_get(4) assert_equal 8 , @mess.get_layout.get_layout.get_internal(4)
end end
def test_layout_methods def test_layout_methods
@ -106,7 +106,7 @@ class TestLayout < MiniTest::Test
message_ind = Register.resolve_index( :message , :receiver ) message_ind = Register.resolve_index( :message , :receiver )
assert_equal 3 , message_ind assert_equal 3 , message_ind
@mess.receiver = 55 @mess.receiver = 55
assert_equal 55 , @mess.internal_object_get(message_ind) assert_equal 55 , @mess.get_internal(message_ind)
end end
def test_object_layout def test_object_layout
@ -115,6 +115,6 @@ class TestLayout < MiniTest::Test
def test_remove_me def test_remove_me
layout = @mess.get_layout layout = @mess.get_layout
assert_equal layout , @mess.internal_object_get(1) assert_equal layout , @mess.get_internal(1)
end end
end end

View File

@ -48,7 +48,7 @@ class TestList < MiniTest::Test
@list.push :one @list.push :one
assert_equal 1 , @list.get_length assert_equal 1 , @list.get_length
assert_equal 1 , @list.indexed_length assert_equal 1 , @list.indexed_length
assert_equal 1 , @list.internal_object_get(Parfait::LAYOUT_INDEX + 1) assert_equal 1 , @list.get_internal(Parfait::LAYOUT_INDEX + 1)
end end
def test_list_inspect def test_list_inspect
@list.set(1,1) @list.set(1,1)
@ -71,7 +71,7 @@ class TestList < MiniTest::Test
end end
def test_one_set1 def test_one_set1
assert_equal 2 , @list.set(1,2) assert_equal 2 , @list.set(1,2)
assert_equal 1 , @list.internal_object_get(2) assert_equal 1 , @list.get_internal(2)
end end
def test_set1_len def test_set1_len
@list.set(1,1) @list.set(1,1)

View File

@ -29,11 +29,11 @@ class TestMessage < MiniTest::Test
end end
def test_push3 def test_push3
@mess.push :name @mess.push :name
assert_equal 1 , @mess.internal_object_get(9) assert_equal 1 , @mess.get_internal(9)
end end
def test_get_internal def test_get_internal
@mess.push :name @mess.push :name
assert_equal :name , @mess.internal_object_get(10) assert_equal :name , @mess.get_internal(10)
end end
def test_get def test_get

View File

@ -14,36 +14,36 @@ class TestObject < MiniTest::Test
end end
def test_empty_object_doesnt_return def test_empty_object_doesnt_return
assert_equal nil , @object.internal_object_get(3) assert_equal nil , @object.get_internal(3)
end end
def test_one_set1 def test_one_set1
assert_equal 1 , @object.internal_object_set(1,1) assert_equal 1 , @object.set_internal(1,1)
end end
def test_one_set2 def test_one_set2
assert_equal :some , @object.internal_object_set(2,:some) assert_equal :some , @object.set_internal(2,:some)
end end
def test_two_sets def test_two_sets
assert_equal 1 , @object.internal_object_set(1,1) assert_equal 1 , @object.set_internal(1,1)
assert_equal :some , @object.internal_object_set(1,:some) assert_equal :some , @object.set_internal(1,:some)
end end
def test_one_get1 def test_one_get1
test_one_set1 test_one_set1
assert_equal 1 , @object.internal_object_get(1) assert_equal 1 , @object.get_internal(1)
end end
def test_one_get2 def test_one_get2
test_one_set2 test_one_set2
assert_equal :some , @object.internal_object_get(2) assert_equal :some , @object.get_internal(2)
end end
def test_many_get def test_many_get
shouldda = { 1 => :one , 2 => :two , 3 => :three} shouldda = { 1 => :one , 2 => :two , 3 => :three}
shouldda.each do |k,v| shouldda.each do |k,v|
@object.internal_object_set(k,v) @object.set_internal(k,v)
end end
shouldda.each do |k,v| shouldda.each do |k,v|
assert_equal v , @object.internal_object_get(k) assert_equal v , @object.get_internal(k)
end end
end end
end end