-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for interop hash entries to PolyglotInspector
- Loading branch information
Showing
4 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/fieldHashEntries.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fields | ||
fieldHashEntries | ||
|
||
^ (self newFieldForType: #misc key: #hashes) | ||
name: 'hash entries'; emphasizeName; | ||
valueGetter: [ :o | self hashEntriesOf: o ]; printValueAsIs; | ||
yourself |
19 changes: 19 additions & 0 deletions
19
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/hashEntriesOf..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
helpers | ||
hashEntriesOf: anObject | ||
| size | | ||
^ (size := (Interop getHashSize: anObject)) < 100 ifTrue: [ | iterator | | ||
iterator := Interop getHashEntriesIterator: anObject. | ||
Text streamContents: [ :aStream | | ||
[ Interop hasIteratorNextElement: iterator ] whileTrue: [ | next key value | | ||
next := Interop getIteratorNextElement: iterator. | ||
key := next at: 1. | ||
value := next at: 2. | ||
aStream | ||
withAttributes: { PluggableTextAttribute evalBlock: [ key inspect ]. TextColor color: Color gray } | ||
do: [ aStream nextPutAll: key printString ]; | ||
nextPutAll: ' -> '; | ||
withAttributes: { PluggableTextAttribute evalBlock: [ value inspect ]. TextEmphasis italic } | ||
do: [ aStream nextPutAll: '', value printString ]; | ||
cr; cr | ||
] ]] | ||
ifFalse: [ 'Hash size: ', size, ' (too many entries to display)' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters