fixed, nay, hacked list problem

lists were in object space but not liked due to
equality returning true
This commit is contained in:
Torsten Ruger 2015-06-08 11:52:56 +02:00
parent 5b3045e42a
commit 0122585b3b
3 changed files with 11 additions and 2 deletions

View File

@ -140,6 +140,14 @@ module Parfait
end end
return true return true
end end
# above, correct, implementation causes problems in the machine object space
# because when a second empty (newly created) list is added, it is not actually
# added as it exists already. TODO, but hack with below identity function
def == other
self.object_id == other.object_id
end
#many basic List functions can not be defined in ruby, such as #many basic List functions can not be defined in ruby, such as
# get/set/length/add/delete # get/set/length/add/delete
# so they must be defined as CompiledMethods in Builtin::Kernel # so they must be defined as CompiledMethods in Builtin::Kernel

View File

@ -54,6 +54,7 @@ module Register
begin begin
link link
all= @machine.objects.sort{|a,b| a.position <=> b.position} all= @machine.objects.sort{|a,b| a.position <=> b.position}
# debugging loop accesses all positions to force an error if it's not set
all.each do |objekt| all.each do |objekt|
puts "Linked #{objekt.class}(#{objekt.object_id.to_s(16)}) at #{objekt.position.to_s(16)} / #{objekt.word_length.to_s(16)}" puts "Linked #{objekt.class}(#{objekt.object_id.to_s(16)}) at #{objekt.position.to_s(16)} / #{objekt.word_length.to_s(16)}"
objekt.position objekt.position

View File

@ -3,8 +3,8 @@ require_relative "type"
module Positioned module Positioned
def position def position
if @position.nil? if @position.nil?
str = "IN machine #{Virtual.machine.objects.include?(self)}\n" str = "IN machine #{Virtual.machine.objects.include?(self)}, at #{self.object_id.to_s(16)}\n"
raise str + "position not set for #{self.class} at #{word_length} for #{self.inspect[0...100]}" raise str + "position not set for #{self.class} len #{word_length} for #{self.inspect[0...100]}"
end end
@position @position
end end