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
index = get_register(@instruction.index)
end
value = object.internal_object_get( index )
value = object.get_internal( index )
#value = value.object_id unless value.is_a? Fixnum
set_register( @instruction.register , value )
true
@ -134,7 +134,7 @@ module Interpreter
def execute_SetSlot
value = object_for( @instruction.register )
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)
true
end
@ -152,7 +152,7 @@ module Interpreter
def execute_FunctionReturn
object = object_for( @instruction.register )
link = object.internal_object_get( @instruction.index )
link = object.get_internal( @instruction.index )
@instruction = link
# we jump back to the call instruction. so it is as if the call never happened and we continue
true

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ class AddTest < MiniTest::Test
assert_equal Register::FunctionReturn , ret.class
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
end

View File

@ -17,11 +17,11 @@ class TestLayout < MiniTest::Test
assert_equal @mess.next_message , @mess.get_instance_variable(:next_message)
index = @mess.get_layout.variable_index :next_message
assert_equal 2 , index
assert_equal @mess.next_message , @mess.internal_object_get(index)
assert_equal @mess.next_message , @mess.get_internal(index)
end
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
def test_inspect
@ -38,7 +38,7 @@ class TestLayout < MiniTest::Test
def test_layout_length
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
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_offset
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
def test_layout_methods
@ -106,7 +106,7 @@ class TestLayout < MiniTest::Test
message_ind = Register.resolve_index( :message , :receiver )
assert_equal 3 , message_ind
@mess.receiver = 55
assert_equal 55 , @mess.internal_object_get(message_ind)
assert_equal 55 , @mess.get_internal(message_ind)
end
def test_object_layout
@ -115,6 +115,6 @@ class TestLayout < MiniTest::Test
def test_remove_me
layout = @mess.get_layout
assert_equal layout , @mess.internal_object_get(1)
assert_equal layout , @mess.get_internal(1)
end
end

View File

@ -48,7 +48,7 @@ class TestList < MiniTest::Test
@list.push :one
assert_equal 1 , @list.get_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
def test_list_inspect
@list.set(1,1)
@ -71,7 +71,7 @@ class TestList < MiniTest::Test
end
def test_one_set1
assert_equal 2 , @list.set(1,2)
assert_equal 1 , @list.internal_object_get(2)
assert_equal 1 , @list.get_internal(2)
end
def test_set1_len
@list.set(1,1)

View File

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

View File

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