From 37928b8591ad425bc19410825fbc87a9653de884 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 7 Nov 2015 17:40:59 +0200 Subject: [PATCH] rename internal get/set functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mainly because the salaam parser chokes on internal… --- lib/interpreter/interpreter.rb | 6 +++--- lib/parfait/indexed.rb | 10 +++++----- lib/parfait/layout.rb | 4 ++-- lib/parfait/object.rb | 10 +++++----- lib/parfait/word.rb | 4 ++-- lib/register/parfait_adapter.rb | 4 ++-- test/interpreter/test_add.rb | 2 +- test/parfait_ruby/test_layout.rb | 12 ++++++------ test/parfait_ruby/test_list.rb | 4 ++-- test/parfait_ruby/test_message.rb | 4 ++-- test/parfait_ruby/test_object.rb | 18 +++++++++--------- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/interpreter/interpreter.rb b/lib/interpreter/interpreter.rb index 660d1314..79d31253 100644 --- a/lib/interpreter/interpreter.rb +++ b/lib/interpreter/interpreter.rb @@ -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 diff --git a/lib/parfait/indexed.rb b/lib/parfait/indexed.rb index 7e90678f..84e27851 100644 --- a/lib/parfait/indexed.rb +++ b/lib/parfait/indexed.rb @@ -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 diff --git a/lib/parfait/layout.rb b/lib/parfait/layout.rb index 0b9c269d..b9d49301 100644 --- a/lib/parfait/layout.rb +++ b/lib/parfait/layout.rb @@ -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 diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 5a682542..02849af6 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -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 diff --git a/lib/parfait/word.rb b/lib/parfait/word.rb index 706782b4..78fd3b82 100644 --- a/lib/parfait/word.rb +++ b/lib/parfait/word.rb @@ -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 diff --git a/lib/register/parfait_adapter.rb b/lib/register/parfait_adapter.rb index d35e2bc7..9fa05029 100644 --- a/lib/register/parfait_adapter.rb +++ b/lib/register/parfait_adapter.rb @@ -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 diff --git a/test/interpreter/test_add.rb b/test/interpreter/test_add.rb index c0e8e491..463acd5c 100644 --- a/test/interpreter/test_add.rb +++ b/test/interpreter/test_add.rb @@ -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 diff --git a/test/parfait_ruby/test_layout.rb b/test/parfait_ruby/test_layout.rb index 45c828a1..160fa0de 100644 --- a/test/parfait_ruby/test_layout.rb +++ b/test/parfait_ruby/test_layout.rb @@ -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 diff --git a/test/parfait_ruby/test_list.rb b/test/parfait_ruby/test_list.rb index 2474865c..a7d9d5d2 100644 --- a/test/parfait_ruby/test_list.rb +++ b/test/parfait_ruby/test_list.rb @@ -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) diff --git a/test/parfait_ruby/test_message.rb b/test/parfait_ruby/test_message.rb index 1cf75458..3b791a14 100644 --- a/test/parfait_ruby/test_message.rb +++ b/test/parfait_ruby/test_message.rb @@ -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 diff --git a/test/parfait_ruby/test_object.rb b/test/parfait_ruby/test_object.rb index 5b5eda86..94e8c8a0 100644 --- a/test/parfait_ruby/test_object.rb +++ b/test/parfait_ruby/test_object.rb @@ -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