Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.
43 changes: 43 additions & 0 deletions smalltalksrc/VMMaker-Tools/SpurByteLayout.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Class {
#name : #SpurByteLayout,
#superclass : #SpurLayout,
#category : #'VMMaker-Tools-imageInspector'
}

{ #category : #accessing }
SpurByteLayout >> asLocalByteArray [
| localByteArray |
localByteArray := ByteArray new: self byteSize .
1 to: localByteArray size do: [ :i |
localByteArray byteAt: i put: (self at: i).
].
^ localByteArray
]

{ #category : #accessing }
SpurByteLayout >> at: anInteger [

" ToDo: consider inst vars "
| slotIndex byteIndex |
slotIndex := (anInteger - 1) // self wordSize .
byteIndex := (anInteger - 1) % self wordSize .
^ (self slotAt: slotIndex + 1) at: byteIndex + 1
]

{ #category : #accessing }
SpurByteLayout >> objectPrintOn: aStream [
aStream nextPutAll: self object asLocalByteArray asString
]

{ #category : #accessing }
SpurByteLayout >> slotAt: anInteger [

| bodyAddress |
self assert: anInteger > 0 description: 'Index must be greater than 0'.
self assert: self numberOfSlots >= anInteger description: 'Index Out of Bounds'.

bodyAddress := self address + self headerSize + ((anInteger - 1) * self wordSize).

^ self memory copyFrom: bodyAddress to: bodyAddress + self wordSize + (0 - 1)

]
113 changes: 113 additions & 0 deletions smalltalksrc/VMMaker-Tools/SpurClass.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Class {
#name : #SpurClass,
#superclass : #SpurObject,
#category : #'VMMaker-Tools-imageInspector'
}

{ #category : #'accessing - instance variables' }
SpurClass >> allInstanceVariableNames [
^ (1 to: self numberOfSlots) collect: [ :index | self slotAt: index ] .
]

{ #category : #'as yet unclassified' }
SpurClass >> classFormat [
^ self slotAt: self slotIndexForClassFormat
]

{ #category : #accessing }
SpurClass >> className [
"We assume this is a byteSymbol here"
^ self image printByteSymbol: (self slotAt: self slotIndexForClassName)

" ] on: Error
do: [ (self slotAt: self slotIndexForMetaclassSoleInstance ) asSpurClass className , ' class'] "

]

{ #category : #'gt-inspector-extension' }
SpurClass >> gtInspectorLayoutIn: composite [
^ composite table
title: 'asd';
display: [
{
'self' -> self .
'superclass' -> self spSuperclass .
'format:' -> self classFormat .
'instSpec' -> self instSpec .
'instSize' -> self instSize} ];
column: 'Key' evaluated: [:each | each key ];
column: 'Value' evaluated: [ :each | each value ];
send: #value

]

{ #category : #'accessing-header' }
SpurClass >> instSize [
"Answer the number of named instance variables
(as opposed to indexed variables) of the receiver.
Above Cog Spur the class format is
<5 bits inst spec><16 bits inst size>"
^self classFormat bitAnd: 16rFFFF
]

{ #category : #'accessing-header' }
SpurClass >> instSpec [
^ (self classFormat bitShift: -16) bitAnd: 16r1F
]

{ #category : #accessing }
SpurClass >> methodDictionary [

^ SpurMethodDictionary on: (self slotAt: self slotIndexForMethodDictionary) address image: self image
]

{ #category : #'accessing - instance variables' }
SpurClass >> printOn: aStream [
aStream nextPutAll: self className
"aStream nextPutAll: self className"

]

{ #category : #constants }
SpurClass >> slotIndexForClassFormat [
^ 3
]

{ #category : #constants }
SpurClass >> slotIndexForClassName [
self flag: '4 for Candle'.
^ "4" 7
]

{ #category : #constants }
SpurClass >> slotIndexForMetaclassInstanceVariableNames [
self flag: '5 for Candle'.
^ "5" 0
]

{ #category : #constants }
SpurClass >> slotIndexForMetaclassSoleInstance [
self flag: '4 for Candle'.

^ "4" 6
]

{ #category : #constants }
SpurClass >> slotIndexForMethodDictionary [

^ 2
]

{ #category : #constants }
SpurClass >> slotIndexForSuperclass [
^ 1
]

{ #category : #accessing }
SpurClass >> spSuperclass [
| superclassOrNil |
superclassOrNil := self slotAt: self slotIndexForSuperclass.
^ superclassOrNil spIsNil
ifTrue: [ superclassOrNil ]
ifFalse: [ superclassOrNil asSpurClass ]
]
11 changes: 11 additions & 0 deletions smalltalksrc/VMMaker-Tools/SpurCompiledMethodLayout.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class {
#name : #SpurCompiledMethodLayout,
#superclass : #SpurLayout,
#category : #'VMMaker-Tools-imageInspector'
}

{ #category : #testing }
SpurCompiledMethodLayout >> isCompiledMethod [

^ true
]
5 changes: 5 additions & 0 deletions smalltalksrc/VMMaker-Tools/SpurEmptyLayout.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #SpurEmptyLayout,
#superclass : #SpurLayout,
#category : #'VMMaker-Tools-imageInspector'
}
Loading