-
Notifications
You must be signed in to change notification settings - Fork 71
/
Object.extension.st
193 lines (146 loc) · 5.72 KB
/
Object.extension.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
Extension { #name : #Object }
{ #category : #'*VMMaker-translation support' }
Object >> asIf: aClass var: aString [
|index|
index := aClass allInstVarNames
indexOf: aString
ifAbsent: [self error: 'must use instVar name'].
^self instVarAt: index
]
{ #category : #'*VMMaker-translation support' }
Object >> asIf: aClass var: aString asValue: someClass [
^(self asIf: aClass var: aString) asValue: someClass
]
{ #category : #'*VMMaker-translation support' }
Object >> asIf: aClass var: aString put: aValue [
|index|
index := aClass allInstVarNames
indexOf: aString
ifAbsent: [self error: 'must use instVar name'].
^self instVarAt: index put: aValue
]
{ #category : #'*VMMaker-translation support' }
Object >> asOop: aClass [
(self class isVariable and: [self class instSize > 0])
ifTrue: [self error: 'cannot auto-coerce indexable objects with named instance variables'].
(aClass ccgCanConvertFrom: self)
ifFalse: [self error: 'incompatible object for this coercion'].
^(Notification new tag: #getSimulator; signal)
ifNotNil: [:simulator| aClass ccg: simulator generateCoerceToOopFrom: self on: nil]
ifNil: [self]
]
{ #category : #'*VMMaker-translation support' }
Object >> asValue: aClass [
^self
]
{ #category : #'*VMMaker-translation support' }
Object >> cCoerce: value to: cType [
"Type coercion for translation only; just return the value when running in Smalltalk."
^ value
]
{ #category : #'*VMMaker-plugin generation' }
Object class >> ccg: cg generateCoerceToOopFrom: aNode on: aStream [
"N.B. The is used both for generation and simulation so answer the result (for interpretation)"
^ (aNode asCASTExpressionIn: cg) prettyPrintOn: aStream
]
{ #category : #'*VMMaker-plugin generation' }
Object class >> ccg: cg generateCoerceToValueFrom: aNode on: aStream [
"N.B. The could be used both for generation and simulation so answer the result (for interpretation)"
^ (aNode asCASTExpressionIn: cg) prettyPrintOn: aStream
]
{ #category : #'*VMMaker-plugin generation' }
Object class >> ccg: cg prolog: aBlock expr: aString index: anInteger [
^cg ccgLoad: aBlock expr: aString asKindOf: self from: anInteger
]
{ #category : #'*VMMaker-plugin generation' }
Object class >> ccgCanConvertFrom: anObject [
^anObject isKindOf: self
]
{ #category : #'*VMMaker-plugin generation' }
Object class >> ccgDeclareCForVar: aSymbolOrString [
^'sqInt ', aSymbolOrString
]
{ #category : #'*VMMaker-translation support' }
Object >> debugCode: aBlock [
"Sending this message tells the code generator that there is debug code in
aBlock. Debug code will be be generated only, if the correponding flag
has been set by TestCodeGenerator>>generateDebugCode:.
In ST simulation just perform the debug code."
false ifTrue: [aBlock value]
]
{ #category : #'*VMMaker-testing' }
Object >> isCArray [
"Answer a boolean indicating whether the receiver responds to the CArray interface"
^false
]
{ #category : #'*VMMaker-translation support' }
Object >> isCObjectAccessor [
^ false
]
{ #category : #'*VMMaker-translation support' }
Object >> isInterpreterPlugin [
^false
]
{ #category : #'*VMMaker-translation support' }
Object >> isTParseNode [
^false
]
{ #category : #'*VMMaker-testing' }
Object >> isVMSimulationAddress [
"Answer a boolean indicating whether the receiver is a kind of address in the VM simulation"
^false
]
{ #category : #'*VMMaker-message handling' }
Object >> perform: aSymbol with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject [
"Send the selector, aSymbol, to the receiver with the given arguments.
Fail if the number of arguments expected by the selector is not five.
Primitive. Optional. See Object documentation whatIsAPrimitive."
<primitive: 83>
^ self perform: aSymbol withArguments: { firstObject. secondObject. thirdObject. fourthObject. fifthObject }
]
{ #category : #'*VMMaker-message handling' }
Object >> perform: aSymbol with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject with: sixthObject [
"Send the selector, aSymbol, to the receiver with the given arguments.
Fail if the number of arguments expected by the selector is not six.
Primitive. Optional. See Object documentation whatIsAPrimitive."
<primitive: 83>
^ self perform: aSymbol withArguments: { firstObject. secondObject. thirdObject. fourthObject. fifthObject. sixthObject }
]
{ #category : #'*VMMaker-translation support' }
Object >> returnTypeC: typeString [
"For translation only; noop when running in Smalltalk."
]
{ #category : #'*VMMaker-translation support' }
Object >> stAt: index [
"Simulation of generateStAt:on:indent:"
^(Notification new tag: #getInterpreter; signal)
ifNotNil: [:interpreter| interpreter stObject: self at: index]
ifNil: [self at: index]
]
{ #category : #'*VMMaker-translation support' }
Object >> stAt: index put: value [
"Simulation of generateStAtPut:on:indent:"
^(Notification new tag: #getInterpreter; signal)
ifNotNil: [:interpreter| interpreter stObject: self at: index put: value]
ifNil: [self at: index put: value]
]
{ #category : #'*VMMaker-translation support' }
Object >> stSize [
^self size
]
{ #category : #'*VMMaker-translation support' }
Object >> suppressFailureGuards: failureGuardFlag [
"For translation only; noop when running in Smalltalk."
]
{ #category : #'*VMMaker-translation support' }
Object >> touch: something [
"For translation only; eliminated by CCodeGenerator. Used to squash unused varable warnings."
]
{ #category : #'*VMMaker-translation support' }
Object >> var: varSymbol type: typeString [
"For translation only; noop when running in Smalltalk."
]
{ #category : #'*VMMaker-translation support' }
Object >> var: varSymbol type: typeString array: array [
"For translation only; noop when running in Smalltalk."
]