ObjectDumper>>example

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ObjectDumper>>example

Nicolas Petton
Hi,

ObjectDumper>>example makes smalltalk crash:

GNU Smalltalk ready

st> ObjectDumper example
Must print true without errors.
"Global garbage collection... done"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... done, heap grown"
"Global garbage collection... Erreur de segmentation (core dumped)


Cheers!

Nico

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ObjectDumper>>example

Paolo Bonzini-2
nico wrote:
> Hi,
>
> ObjectDumper>>example makes smalltalk crash:

Infinite recursion in SequenceableCollection>>#hash...

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ObjectDumper>>example

Paolo Bonzini-2
In reply to this post by Nicolas Petton
Fixed with the attached patch.

Thanks!

Paolo

diff --git a/kernel/IdentDict.st b/kernel/IdentDict.st
index d9e41ea..3e7130d 100644
--- a/kernel/IdentDict.st
+++ b/kernel/IdentDict.st
@@ -53,6 +53,24 @@ comparision message == to determine equivalence of indices.'>
  ^anObject identityHash
     ]
 
+    findElementIndex: anObject [
+        "Tries to see where anObject can be placed as an indexed variable.
+ As soon as nil is found, the index of that slot is answered.
+ anObject also comes from an indexed variable."
+
+        <category: 'private methods'>
+        | index size element |
+        self beConsistent.
+
+        "Sorry for the lack of readability, but I want speed... :-)"
+        index := (anObject identityHash scramble bitAnd: (size := self primSize) - 1) + 1.
+  
+        [(element := self primAt: index) isNil
+            ifTrue: [^index].
+        index == size ifTrue: [index := 1] ifFalse: [index := index + 1]]
+                repeat
+    ]
+
     findIndex: anObject [
  "Tries to see if anObject exists as an indexed variable. As soon as nil
  or anObject is found, the index of that slot is answered"

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk