1
1
Class {
2
- #name : #AcDSLCodeBuffer ,
2
+ #name : #AcDSLCodeObject ,
3
3
#superclass : #Object ,
4
4
#instVars : [
5
5
' address' ,
@@ -9,25 +9,25 @@ Class {
9
9
}
10
10
11
11
{ #category : #' instance creation' }
12
- AcDSLCodeBuffer class >> new [
12
+ AcDSLCodeObject class >> new [
13
13
" return an initialized instance"
14
14
15
15
^ self basicNew initialize.
16
16
17
17
]
18
18
19
19
{ #category : #accessing }
20
- AcDSLCodeBuffer >> address [
20
+ AcDSLCodeObject >> address [
21
21
^ address
22
22
]
23
23
24
24
{ #category : #accessing }
25
- AcDSLCodeBuffer >> bytes [
25
+ AcDSLCodeObject >> bytes [
26
26
^ ByteArray streamContents: [ :s | instructions do: [:i | i emitOn: s ] ]
27
27
]
28
28
29
29
{ #category : #utilities }
30
- AcDSLCodeBuffer >> disassembleOn: aStream [
30
+ AcDSLCodeObject >> disassembleOn: aStream [
31
31
| pc |
32
32
33
33
pc := address.
@@ -45,12 +45,12 @@ AcDSLCodeBuffer >> disassembleOn: aStream [
45
45
]
46
46
47
47
{ #category : #utilities }
48
- AcDSLCodeBuffer >> disassembled [
48
+ AcDSLCodeObject >> disassembled [
49
49
^ String streamContents: [ :s | self disassembleOn: s. ].
50
50
]
51
51
52
52
{ #category : #relocation }
53
- AcDSLCodeBuffer >> fixupBranchTargets [
53
+ AcDSLCodeObject >> fixupBranchTargets [
54
54
| locations insnAddr |
55
55
56
56
" Pass 1 - collect all labels and their (relative) addresses:"
@@ -69,7 +69,7 @@ AcDSLCodeBuffer >> fixupBranchTargets [
69
69
]
70
70
71
71
{ #category : #relocation }
72
- AcDSLCodeBuffer >> fixupBranchTargetsUsing: locations [
72
+ AcDSLCodeObject >> fixupBranchTargetsUsing: locations [
73
73
| insnAddr |
74
74
75
75
insnAddr := address.
@@ -92,7 +92,7 @@ AcDSLCodeBuffer >> fixupBranchTargetsUsing: locations [
92
92
]
93
93
94
94
{ #category : #inspecting }
95
- AcDSLCodeBuffer >> gtInspectorInstructionsIn: composite [
95
+ AcDSLCodeObject >> gtInspectorInstructionsIn: composite [
96
96
< gtInspectorPresentationOrder: 60 >
97
97
98
98
^ composite fastTable
@@ -128,23 +128,23 @@ AcDSLCodeBuffer >> gtInspectorInstructionsIn: composite [
128
128
]
129
129
130
130
{ #category : #initialization }
131
- AcDSLCodeBuffer >> initialize [
131
+ AcDSLCodeObject >> initialize [
132
132
address := 0 .
133
133
instructions := OrderedCollection new .
134
134
]
135
135
136
136
{ #category : #accessing }
137
- AcDSLCodeBuffer >> instructions [
137
+ AcDSLCodeObject >> instructions [
138
138
^ instructions
139
139
]
140
140
141
141
{ #category : #relocation }
142
- AcDSLCodeBuffer >> relocateTo: newAddress with: ignored [
142
+ AcDSLCodeObject >> relocateTo: newAddress with: ignored [
143
143
address := newAddress.
144
144
]
145
145
146
146
{ #category : #accessing }
147
- AcDSLCodeBuffer >> relocations [
147
+ AcDSLCodeObject >> relocations [
148
148
| addr relocs |
149
149
150
150
addr := address.
@@ -158,3 +158,10 @@ AcDSLCodeBuffer >> relocations [
158
158
].
159
159
^ relocs
160
160
]
161
+
162
+ { #category : #accessing }
163
+ AcDSLCodeObject >> size [
164
+ " Return the size of code in bytes"
165
+
166
+ ^ instructions inject: 0 into: [:size :insn | size + (insn bitWidth // 8 ) ]
167
+ ]
0 commit comments