author | Claus Gittinger <cg@exept.de> |
Fri, 12 Jul 1996 10:43:55 +0200 | |
changeset 297 | 7affb1798230 |
parent 296 | 999d5fdf0bde |
child 298 | 118648c3b590 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
45 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Parser subclass:#ByteCodeCompiler |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
14 |
instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
15 |
maxStackDepth relocList' |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
16 |
classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
17 |
STCCompilationIncludes STCCompilationOptions STCCompilation |
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
18 |
ShareCode STCKeepCIntermediate' |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
19 |
poolDictionaries:'' |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
20 |
category:'System-Compiler' |
0 | 21 |
! |
22 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
23 |
!ByteCodeCompiler class methodsFor:'documentation'! |
3 | 24 |
|
141 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
128
diff
changeset
|
37 |
! |
20 | 38 |
|
3 | 39 |
documentation |
40 |
" |
|
19 | 41 |
This class performs compilation into ByteCodes. |
42 |
First, parsing is done using superclass methods, |
|
43 |
then the parse-tree is converted into an array of symbolic codes |
|
44 |
and a relocation table; |
|
45 |
these two are finally combined into a byteArray of the codes. |
|
0 | 46 |
|
19 | 47 |
(the intermediate step through symbolic codes is for debugging |
48 |
only - it will vanish) |
|
49 |
||
50 |
There are many dependencies to the run-time-system (especially the |
|
51 |
interpreter) in here - be careful when playing around ... |
|
0 | 52 |
|
259 | 53 |
[Instance variables:] |
0 | 54 |
|
259 | 55 |
codeBytes <ByteArry> bytecodes |
56 |
codeIndex <SmallInteger> next index to put into code array |
|
57 |
litArray <OrderedCollection> literals |
|
58 |
stackDelta <SmallInteger> return value of byteCodeFor: |
|
59 |
extra <Symbol> return value of byteCodeFor: |
|
60 |
lineno <Boolean> return value of byteCodeFor: |
|
61 |
extraLiteral <Symbol> return value of byteCodeFor: |
|
62 |
maxStackDepth <SmallInteger> stack need of method |
|
63 |
relocList <Array> used temporary for relocation |
|
19 | 64 |
|
259 | 65 |
[Class variables:] |
19 | 66 |
|
259 | 67 |
JumpToAbsJump <Dictionary> internal table to map opcodes |
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
68 |
|
259 | 69 |
SequenceNumber <Integer> counting intermediate stc-compiled |
70 |
objects (for unique o-file naming) |
|
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
71 |
|
259 | 72 |
STCCompilationDefines passed to stc as command line arguments |
73 |
STCCompilationIncludes |
|
74 |
STCCompilationOptions |
|
75 |
<String> |
|
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
76 |
|
259 | 77 |
STCCompilation <Symbol> #always, #primitiveOnly or #never |
78 |
controls when stc compilation is wanted |
|
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
79 |
|
259 | 80 |
ShareCode <Boolean> reuse byteArrays for common (simple) code sequences |
81 |
This is normally a 'good' optimization, |
|
82 |
expect if you plan to modify the byteCodes. |
|
263 | 83 |
|
84 |
[author:] |
|
85 |
Claus Gittinger |
|
86 |
||
3 | 87 |
" |
98 | 88 |
! ! |
89 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
90 |
!ByteCodeCompiler class methodsFor:'initialization'! |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
91 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
92 |
initialize |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
93 |
ShareCode := true. |
295 | 94 |
STCKeepCIntermediate := false. |
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
95 |
|
295 | 96 |
"Modified: 9.7.1996 / 14:52:34 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
97 |
! ! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
98 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
99 |
!ByteCodeCompiler class methodsFor:'compiling methods'! |
98 | 100 |
|
0 | 101 |
compile:methodText forClass:classToCompileFor |
102 |
"compile a source-string for a method in classToCompileFor" |
|
103 |
||
104 |
^ self compile:methodText |
|
45 | 105 |
forClass:classToCompileFor |
106 |
inCategory:'others' |
|
107 |
notifying:nil |
|
108 |
install:true |
|
109 |
skipIfSame:false |
|
110 |
silent:false |
|
0 | 111 |
! |
112 |
||
113 |
compile:aString forClass:aClass inCategory:cat |
|
114 |
"compile a source-string for a method in classToCompileFor. |
|
115 |
The method will get cat as category" |
|
116 |
||
117 |
^ self compile:aString |
|
45 | 118 |
forClass:aClass |
119 |
inCategory:cat |
|
120 |
notifying:nil |
|
121 |
install:true |
|
122 |
skipIfSame:false |
|
123 |
silent:false |
|
0 | 124 |
! |
125 |
||
84 | 126 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
0 | 127 |
"compile a source-string for a method in classToCompileFor. |
84 | 128 |
errors are forwarded to requestor. |
0 | 129 |
The method will get cat as category" |
130 |
||
131 |
^ self compile:aString |
|
45 | 132 |
forClass:aClass |
133 |
inCategory:cat |
|
84 | 134 |
notifying:requestor |
45 | 135 |
install:true |
136 |
skipIfSame:false |
|
137 |
silent:false |
|
0 | 138 |
! |
139 |
||
141 | 140 |
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install |
141 |
"compile a source-string for a method in classToCompileFor. |
|
142 |
The install-argument controls if the method is to be installed into the |
|
143 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
144 |
Errors are forwarded to requestor. The method will get cat as category" |
|
145 |
||
146 |
^ self compile:aString |
|
147 |
forClass:aClass |
|
148 |
inCategory:cat |
|
149 |
notifying:requestor |
|
150 |
install:install |
|
151 |
skipIfSame:false |
|
152 |
silent:false |
|
153 |
! |
|
154 |
||
155 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
|
156 |
install:install skipIfSame:skipIfSame |
|
157 |
"compile a source-string for a method in classToCompileFor. |
|
158 |
The install-argument controls if the method is to be installed into the |
|
159 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
160 |
Errors are forwarded to requestor. The method will get cat as category. |
|
161 |
If skipIsSame is true, and the source is the same as an existing |
|
162 |
methods source, this is a noop (for fast fileIn)." |
|
163 |
||
164 |
^ self compile:aString |
|
165 |
forClass:aClass |
|
166 |
inCategory:cat |
|
167 |
notifying:requestor |
|
168 |
install:install |
|
169 |
skipIfSame:skipIfSame |
|
170 |
silent:false |
|
171 |
! |
|
172 |
||
84 | 173 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
174 |
install:install skipIfSame:skipIfSame silent:silent |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
175 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
176 |
^ self |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
177 |
compile:aString |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
178 |
forClass:aClass |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
179 |
inCategory:cat |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
180 |
notifying:requestor |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
181 |
install:install |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
182 |
skipIfSame:skipIfSame |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
183 |
silent:silent |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
184 |
foldConstants:true |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
185 |
! |
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
186 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
187 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
188 |
install:install skipIfSame:skipIfSame silent:silent foldConstants:fold |
20 | 189 |
|
190 |
"the basic workhorse method for compiling: |
|
0 | 191 |
compile a source-string for a method in classToCompileFor. |
84 | 192 |
errors are forwarded to requestor (report on Transcript and return |
193 |
#Error, if requestor is nil). |
|
0 | 194 |
|
20 | 195 |
The new method will get cat as category. |
196 |
If install is true, the method will go into the classes method-table, |
|
197 |
otherwise the method is simply returned (for anonymous methods). |
|
0 | 198 |
If skipIsSame is true, and the source is the same as an existing |
20 | 199 |
methods source, this is a noop (for fast fileIn). |
200 |
The argument, silent controls if errors are to be reported." |
|
0 | 201 |
|
54 | 202 |
|compiler newMethod tree lits symbolicCodeArray oldMethod lazy silencio |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
203 |
sourceFile sourceStream newSource primNr pos sel keptOldCode msg answer| |
0 | 204 |
|
205 |
aString isNil ifTrue:[^ nil]. |
|
54 | 206 |
silencio := silent or:[Smalltalk silentLoading == true]. |
0 | 207 |
|
19 | 208 |
"lazy compilation is EXPERIMENTAL" |
209 |
lazy := (LazyCompilation == true) and:[install]. |
|
210 |
||
0 | 211 |
"create a compiler, let it parse and create the parsetree" |
212 |
||
54 | 213 |
compiler := self for:(ReadStream on:aString) in:aClass. |
84 | 214 |
compiler parseForCode. |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
215 |
fold ifFalse:[compiler foldConstants:nil]. |
84 | 216 |
compiler notifying:requestor. |
54 | 217 |
silent ifTrue:[ |
218 |
"/ compiler ignoreErrors. |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
219 |
compiler ignoreWarnings |
54 | 220 |
]. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
221 |
"/ compiler nextToken. |
0 | 222 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
223 |
compiler parseError:'syntax error in method specification'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
224 |
tree := #Error |
0 | 225 |
] ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
226 |
lazy ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
227 |
"check if same source" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
228 |
(skipIfSame and:[(sel := compiler selector) notNil]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
229 |
oldMethod := aClass compiledMethodAt:sel. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
230 |
oldMethod notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
231 |
oldMethod source = aString ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
232 |
oldMethod isInvalid ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
233 |
silencio ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
234 |
Transcript showCR:(' unchanged: ',aClass name,' ',compiler selector) |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
235 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
236 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
237 |
same. however, category may be different |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
238 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
239 |
(cat notNil and:[cat ~= oldMethod category]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
240 |
oldMethod category:cat. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
241 |
oldMethod changed:#category. |
191 | 242 |
"/ aClass updateRevisionString. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
243 |
aClass addChangeRecordForMethodCategory:oldMethod category:cat. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
244 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
245 |
^ oldMethod |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
246 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
247 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
248 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
249 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
250 |
tree := compiler parseMethodBody. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
251 |
compiler tree:tree. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
252 |
] |
0 | 253 |
]. |
254 |
||
255 |
(compiler errorFlag or:[tree == #Error]) ifTrue:[ |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
256 |
compiler showErrorMessageForClass:aClass. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
257 |
^ #Error |
0 | 258 |
]. |
259 |
||
191 | 260 |
sel := compiler selector. |
19 | 261 |
"if no error and also no selector ..." |
90 | 262 |
sel isNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
263 |
"... it was just a comment or other empty stuff" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
264 |
^ nil |
0 | 265 |
]. |
266 |
||
191 | 267 |
lazy ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
268 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
269 |
freak-out support ... |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
270 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
271 |
(compiler hasNonOptionalPrimitiveCode |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
272 |
or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode]) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
273 |
or:[STCCompilation == #always and:[sel ~~ #doIt]]]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
274 |
newMethod := compiler |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
275 |
compileToMachineCode:aString |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
276 |
forClass:aClass |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
277 |
inCategory:cat |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
278 |
notifying:requestor |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
279 |
install:install |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
280 |
skipIfSame:skipIfSame |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
281 |
silent:silent. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
282 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
283 |
newMethod == #Error ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
284 |
compiler showErrorMessageForClass:aClass. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
285 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
286 |
]. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
287 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
288 |
(newMethod == #CannotLoad) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
289 |
newMethod := compiler trappingStubMethodFor:aString inCategory:cat. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
290 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
291 |
keptOldCode := false. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
292 |
install ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
293 |
"/ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
294 |
"/ be very careful with existing methods |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
295 |
"/ (otherwise, you could easily make your system unusable in systems which cannot load) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
296 |
"/ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
297 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
298 |
oldMethod := aClass compiledMethodAt:sel |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
299 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
300 |
(oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
301 |
answer := Dialog |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
302 |
confirm:'installation of binary code is not possible or disabled. |
97 | 303 |
|
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
304 |
Shall I use the old methods functionality |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
305 |
or instead create a dummy trap method for it ? |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
306 |
|
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
307 |
Hint: |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
308 |
if that method is needed by the system, you better leave the |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
309 |
original functionality in the system. |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
310 |
|
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
311 |
Close this warnBox to abort the compilation. |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
312 |
' |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
313 |
yesLabel:'trap code' |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
314 |
noLabel:'keep old'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
315 |
answer isNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
316 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
317 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
318 |
answer == false ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
319 |
newMethod code:(oldMethod code). |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
320 |
keptOldCode := true. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
321 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
322 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
323 |
aClass addSelector:sel withMethod:newMethod |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
324 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
325 |
Transcript show:'*** '. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
326 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
327 |
Transcript show:(sel ,' ') |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
328 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
329 |
keptOldCode ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
330 |
msg := 'not really compiled - method still shows previous behavior'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
331 |
] ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
332 |
msg := 'not compiled to machine code - created a stub instead.'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
333 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
334 |
Transcript showCR:msg. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
335 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
336 |
^ newMethod |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
337 |
]. |
19 | 338 |
]. |
339 |
||
54 | 340 |
" |
341 |
EXPERIMENTAL: quick loading |
|
342 |
only create a lazyMethod, which has no byteCode and will |
|
343 |
compile itself when first called. |
|
344 |
" |
|
19 | 345 |
lazy ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
346 |
newMethod := LazyMethod new. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
347 |
(ClassCategoryReader sourceMode == #sourceReference) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
348 |
sourceFile := ObjectMemory nameForSources. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
349 |
sourceFile notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
350 |
sourceStream := sourceFile asFilename appendingWriteStream. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
351 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
352 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
353 |
sourceStream isNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
354 |
newMethod source:aString. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
355 |
] ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
356 |
sourceStream setToEnd. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
357 |
pos := sourceStream position. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
358 |
sourceStream nextChunkPut:aString. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
359 |
sourceStream close. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
360 |
newMethod sourceFilename:sourceFile position:pos. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
361 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
362 |
newMethod category:cat. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
363 |
Project notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
364 |
newMethod package:(Project currentPackageName) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
365 |
]. |
19 | 366 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
367 |
aClass addSelector:sel withLazyMethod:newMethod. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
368 |
^ newMethod |
19 | 369 |
]. |
370 |
||
90 | 371 |
(primNr := compiler primitiveNumber) isNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
372 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
373 |
produce symbolic code first |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
374 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
375 |
symbolicCodeArray := compiler genSymbolicCode. |
90 | 376 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
377 |
(symbolicCodeArray == #Error) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
378 |
Transcript show:' '. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
379 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
380 |
Transcript show:(sel ,' ') |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
381 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
382 |
Transcript showCR:'translation error'. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
383 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
384 |
]. |
0 | 385 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
386 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
387 |
take this, producing bytecode |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
388 |
(someone willin' to make machine code :-) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
389 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
390 |
((compiler genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
391 |
Transcript show:' '. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
392 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
393 |
Transcript show:(sel ,' ') |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
394 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
395 |
Transcript showCR:'relocation error - must be simplified'. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
396 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
397 |
]. |
0 | 398 |
]. |
399 |
||
54 | 400 |
" |
401 |
finally create the new method-object |
|
402 |
" |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
403 |
newMethod := compiler createMethod. |
90 | 404 |
primNr notNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
405 |
newMethod code:(compiler checkForPrimitiveCode:primNr). |
78 | 406 |
] ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
407 |
newMethod byteCode:(compiler code). |
78 | 408 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
409 |
"/ newMethod numberOfMethodVars:(compiler numberOfMethodVars). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
410 |
"/ newMethod numberOfMethodArgs:(compiler numberOfMethodArgs). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
411 |
"/ newMethod stackSize:(compiler maxStackDepth). |
19 | 412 |
|
54 | 413 |
" |
414 |
if there where any corrections, install the updated source |
|
415 |
" |
|
90 | 416 |
(newSource := compiler correctedSource) notNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
417 |
newMethod source:newSource |
19 | 418 |
] ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
419 |
newMethod source:aString. |
19 | 420 |
]. |
0 | 421 |
newMethod category:cat. |
54 | 422 |
Project notNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
423 |
newMethod package:(Project currentPackageName) |
54 | 424 |
]. |
0 | 425 |
|
426 |
install ifTrue:[ |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
427 |
aClass addSelector:sel withMethod:newMethod |
0 | 428 |
]. |
429 |
||
54 | 430 |
silencio ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
431 |
Transcript showCR:(' compiled: ', aClass name,' ', sel) |
0 | 432 |
]. |
433 |
||
434 |
^ newMethod |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
435 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
436 |
"Created: 29.10.1995 / 19:59:36 / cg" |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
437 |
"Modified: 18.5.1996 / 16:39:55 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
438 |
"Modified: 24.6.1996 / 12:41:13 / stefan" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
439 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
440 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
441 |
compile:methodText forClass:classToCompileFor notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
442 |
"compile a source-string for a method in classToCompileFor. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
443 |
Errors are forwarded to requestor." |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
444 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
445 |
^ self compile:methodText |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
446 |
forClass:classToCompileFor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
447 |
inCategory:'others' |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
448 |
notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
449 |
install:true |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
450 |
skipIfSame:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
451 |
silent:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
452 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
453 |
|
141 | 454 |
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock |
455 |
"name alias for ST-80 compatibility" |
|
456 |
||
457 |
|m| |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
458 |
|
141 | 459 |
m := self |
460 |
compile:textOrStream |
|
461 |
forClass:aClass |
|
462 |
inCategory:'others' |
|
463 |
notifying:requestor |
|
464 |
install:true |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
465 |
skipIfSame:false |
141 | 466 |
silent:false. |
467 |
m == #Error ifTrue:[ |
|
468 |
^ exceptionBlock value |
|
469 |
]. |
|
470 |
^ m |
|
471 |
||
0 | 472 |
! ! |
473 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
474 |
!ByteCodeCompiler class methodsFor:'constants'! |
15 | 475 |
|
476 |
byteCodeFor:aSymbol |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
477 |
"returns the numeric code for some symbolic bytecodes." |
15 | 478 |
|
25 | 479 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
480 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
481 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
482 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
483 |
(aSymbol == #retTop) ifTrue:[^ 0]. |
|
484 |
||
15 | 485 |
(aSymbol == #push0) ifTrue:[^120]. |
486 |
(aSymbol == #push1) ifTrue:[^121]. |
|
487 |
(aSymbol == #push2) ifTrue:[^139]. |
|
488 |
(aSymbol == #pushMinus1) ifTrue:[^122]. |
|
489 |
(aSymbol == #pushNil) ifTrue:[^ 10]. |
|
490 |
(aSymbol == #pushTrue) ifTrue:[^ 11]. |
|
491 |
(aSymbol == #pushFalse) ifTrue:[^ 12]. |
|
492 |
(aSymbol == #pushSelf) ifTrue:[^ 15]. |
|
493 |
self error |
|
494 |
! ! |
|
495 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
496 |
!ByteCodeCompiler class methodsFor:'stc compilation defaults'! |
54 | 497 |
|
141 | 498 |
canCreateMachineCode |
499 |
"return true, if compilation to machine code is supported. |
|
500 |
Currently, all SYSV4 and Linux systems do so; |
|
501 |
REAL/IX, AIX and HPUX do not (due to the need for dynamic loading |
|
502 |
of object files, which is not supported by those). |
|
503 |
MIPS ULTRIX is almost finished, but not yet released. |
|
124 | 504 |
|
141 | 505 |
However, if no compiler is around (i.e. the demo distribution), |
506 |
there is no chance ..." |
|
507 |
||
508 |
|canDo| |
|
509 |
||
510 |
ObjectFileLoader isNil ifTrue:[^ false]. |
|
511 |
ObjectFileLoader canLoadObjectFiles ifFalse:[^ false]. |
|
512 |
||
513 |
"/ no chance, if no stc is available |
|
514 |
^ self incrementalStcPath notNil |
|
124 | 515 |
|
516 |
" |
|
141 | 517 |
Compiler canCreateMachineCode |
518 |
" |
|
519 |
||
520 |
"Modified: 13.9.1995 / 15:15:11 / claus" |
|
521 |
! |
|
522 |
||
523 |
incrementalStcPath |
|
524 |
"return the path to the stc command for incremental method compilation, |
|
525 |
or nil if not found." |
|
526 |
||
527 |
|f| |
|
528 |
||
529 |
(f := self stcPathOf:'stc') notNil ifTrue:[^ f]. |
|
530 |
^ self stcPathOf:'demostc' |
|
531 |
||
532 |
" |
|
533 |
Compiler incrementalStcPath |
|
534 |
" |
|
535 |
||
536 |
"Created: 13.9.1995 / 14:36:36 / claus" |
|
537 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
|
538 |
! |
|
539 |
||
540 |
stcCompilation |
|
541 |
"return the flag which controls compilation to machine code. |
|
542 |
If #always, methods are always compiled to machine code (which takes |
|
543 |
longer, but provides faster code). If #none, methods are never compiled |
|
544 |
to machine code, instead for non-primitive ones, compilation is to bytecode |
|
545 |
and for primitive ones, a trapping stub is generated. |
|
546 |
Anything else lets the compiler compile to bytecode, |
|
547 |
except for methods containing primitive code. |
|
548 |
This can be set from your private.rc file or from a workspace |
|
549 |
for selective compilation to machine code." |
|
124 | 550 |
|
141 | 551 |
^ STCCompilation |
54 | 552 |
|
553 |
" |
|
141 | 554 |
Compiler stcCompilation |
124 | 555 |
" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
556 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
557 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
558 |
stcCompilation:how |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
559 |
"set the flag which controls compilation to machine code. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
560 |
If #always, methods are always compiled to machine code (which takes |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
561 |
longer, but provides faster code). If #none, methods are never compiled |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
562 |
to machine code, instead for non-primitive ones, compilation is to bytecode |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
563 |
and for primitive ones, a trapping stub is generated. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
564 |
Anything else lets the compiler compile to bytecode, |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
565 |
except for methods containing primitive code. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
566 |
This can be set from your private.rc file or from a workspace |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
567 |
for selective compilation to machine code." |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
568 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
569 |
|ret| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
570 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
571 |
ret := STCCompilation. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
572 |
STCCompilation := how. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
573 |
^ ret |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
574 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
575 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
576 |
Compiler stcCompilation:#always |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
577 |
Compiler stcCompilation:#never |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
578 |
Compiler stcCompilation:#default |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
579 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
580 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
581 |
|
141 | 582 |
stcCompilationDefines |
583 |
"return the defines used with stc compilation" |
|
584 |
||
585 |
^ STCCompilationDefines |
|
586 |
! |
|
587 |
||
588 |
stcCompilationDefines:aString |
|
589 |
"define the flags (for example, additional -D defines) |
|
590 |
to be used when compiling to machine code. |
|
591 |
These are passed to stc. Can be set from your private.rc file." |
|
592 |
||
593 |
STCCompilationDefines := aString |
|
594 |
||
595 |
" |
|
596 |
Compiler stcCompilationDefines:'-DVGL -DDEBUG' |
|
597 |
" |
|
598 |
! |
|
599 |
||
600 |
stcCompilationIncludes |
|
601 |
"return the includes used with stc compilation" |
|
602 |
||
603 |
^ STCCompilationIncludes |
|
604 |
! |
|
605 |
||
606 |
stcCompilationIncludes:aString |
|
607 |
"define the include directories via additional -I flags. |
|
608 |
These are passed to stc. Can be set in your private.rc file" |
|
609 |
||
610 |
STCCompilationIncludes := aString |
|
611 |
||
612 |
" |
|
613 |
Compiler stcCompilationIncludes:'-I/usr/local/include -I../../include' |
|
614 |
Compiler stcCompilationIncludes:(Compiler stcCompilationIncludes , ' -I../../libxt') |
|
615 |
" |
|
616 |
! |
|
617 |
||
124 | 618 |
stcCompilationOptions |
619 |
"return the options used with stc compilation" |
|
620 |
||
621 |
^ STCCompilationOptions |
|
622 |
! |
|
623 |
||
141 | 624 |
stcCompilationOptions:aString |
625 |
"define the compilation options |
|
626 |
to be used when compiling to machine code. |
|
627 |
These are passed to stc. Can be set from your private.rc file." |
|
101 | 628 |
|
141 | 629 |
STCCompilationOptions := aString |
101 | 630 |
|
631 |
" |
|
141 | 632 |
Compiler stcCompilationOptions:'+optinline' |
101 | 633 |
" |
634 |
! |
|
635 |
||
141 | 636 |
stcPath |
637 |
"return the path to the stc command, or nil if not found." |
|
638 |
||
639 |
^ self stcPathOf:'stc' |
|
640 |
||
641 |
" |
|
642 |
Compiler stcPath |
|
643 |
" |
|
644 |
||
645 |
"Modified: 13.9.1995 / 14:37:26 / claus" |
|
646 |
! |
|
647 |
||
120 | 648 |
stcPathOf:command |
649 |
"return the path to an stc command, or nil if not found." |
|
101 | 650 |
|
651 |
|f| |
|
97 | 652 |
|
120 | 653 |
((f := '../../stc' asFilename construct:command)) isExecutable ifTrue:[ |
101 | 654 |
^ f pathName |
655 |
]. |
|
126 | 656 |
^ OperatingSystem pathOfCommand:command |
97 | 657 |
|
658 |
" |
|
120 | 659 |
Compiler stcPathOf:'stc' |
660 |
" |
|
661 |
||
662 |
"Created: 13.9.1995 / 14:37:16 / claus" |
|
54 | 663 |
! ! |
664 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
665 |
!ByteCodeCompiler methodsFor:'ST-80 compatibility'! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
666 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
667 |
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
668 |
"name alias for ST-80 compatibility" |
0 | 669 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
670 |
^ self class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
671 |
compile:textOrStream |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
672 |
in:aClass |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
673 |
notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
674 |
ifFail:exceptionBlock |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
675 |
"/ |m| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
676 |
"/ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
677 |
"/ m := self class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
678 |
"/ compile:textOrStream |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
679 |
"/ forClass:aClass |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
680 |
"/ inCategory:'no category' |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
681 |
"/ notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
682 |
"/ install:true |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
683 |
"/ skipIfSame:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
684 |
"/ silent:false. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
685 |
"/ m == #Error ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
686 |
"/ ^ exceptionBlock value |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
687 |
"/ ]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
688 |
"/ ^ m |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
689 |
! ! |
0 | 690 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
691 |
!ByteCodeCompiler methodsFor:'accessing'! |
0 | 692 |
|
693 |
code |
|
3 | 694 |
"return the bytecode array - only valid after code-generation" |
0 | 695 |
|
49 | 696 |
^ codeBytes |
0 | 697 |
! |
698 |
||
141 | 699 |
literalArray |
700 |
"return the literal array - only valid after parsing" |
|
701 |
||
702 |
^ litArray |
|
703 |
! |
|
704 |
||
0 | 705 |
maxStackDepth |
706 |
"return the stack-need of the method - only valid after code-generation" |
|
707 |
||
708 |
^ maxStackDepth |
|
709 |
! ! |
|
710 |
||
711 |
!ByteCodeCompiler methodsFor:'code generation'! |
|
712 |
||
141 | 713 |
absJumpFromJump:code |
714 |
"given a jump-symbolic code, return corresponding absolute jump" |
|
0 | 715 |
|
141 | 716 |
JumpToAbsJump isNil ifTrue:[ |
717 |
JumpToAbsJump := IdentityDictionary new. |
|
718 |
JumpToAbsJump at:#jump put:#jumpabs. |
|
719 |
JumpToAbsJump at:#trueJump put:#trueJumpabs. |
|
720 |
JumpToAbsJump at:#falseJump put:#falseJumpabs. |
|
721 |
JumpToAbsJump at:#nilJump put:#nilJumpabs. |
|
722 |
JumpToAbsJump at:#notNilJump put:#notNilJumpabs. |
|
723 |
JumpToAbsJump at:#eqJump put:#eqJumpabs. |
|
724 |
JumpToAbsJump at:#notEqJump put:#notEqJumpabs. |
|
725 |
JumpToAbsJump at:#zeroJump put:#zeroJumpabs. |
|
726 |
JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs. |
|
727 |
JumpToAbsJump at:#makeBlock put:#makeBlockabs. |
|
0 | 728 |
]. |
141 | 729 |
^ JumpToAbsJump at:code |
0 | 730 |
! |
731 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
732 |
addLiteral:anObject |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
733 |
"add a literal to the literalArray - watch for and eliminate |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
734 |
duplicates. return the index of the literal in the Array" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
735 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
736 |
|index class| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
737 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
738 |
litArray isNil ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
739 |
litArray := Array with:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
740 |
^ 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
741 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
742 |
index := litArray identityIndexOf:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
743 |
(index == 0) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
744 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
745 |
reuse constants if same value and same class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
746 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
747 |
class := anObject class. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
748 |
((class == Float) |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
749 |
or:[class == Fraction]) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
750 |
index := litArray indexOf:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
751 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
752 |
((index == 0) or:[(litArray at:index) class ~~ class]) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
753 |
litArray := litArray copyWith:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
754 |
^ litArray size |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
755 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
756 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
757 |
^ index |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
758 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
759 |
|
141 | 760 |
addReloc:symIndex |
761 |
"remember to relocate offset at symIndex later ..." |
|
3 | 762 |
|
141 | 763 |
relocList isNil ifTrue:[ |
764 |
relocList := OrderedCollection new. |
|
1 | 765 |
]. |
141 | 766 |
relocList add:symIndex |
1 | 767 |
! |
768 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
769 |
appendByte:aByte |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
770 |
"append a byte to the code-Array, checking for byte-range (debug-only)" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
771 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
772 |
|idx "{Class: SmallInteger }"| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
773 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
774 |
idx := codeIndex. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
775 |
(aByte between:0 and:255) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
776 |
codeBytes at:idx put:aByte. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
777 |
codeIndex := idx + 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
778 |
] ifFalse:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
779 |
self error:'byte range error'. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
780 |
errorFlag := #Error |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
781 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
782 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
783 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
784 |
appendByteCodeFor:codeSymbol |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
785 |
"append the byteCode for an instructionSymbol to the code-Array" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
786 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
787 |
|idx "{Class: SmallInteger }"| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
788 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
789 |
idx := codeIndex. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
790 |
codeBytes at:idx put:(self byteCodeFor:codeSymbol). |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
791 |
codeIndex := idx + 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
792 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
793 |
|
141 | 794 |
appendEmptyByte |
795 |
"append an empty byte to the code-Array" |
|
3 | 796 |
|
141 | 797 |
|idx "{Class: SmallInteger }"| |
3 | 798 |
|
141 | 799 |
idx := codeIndex. |
800 |
codeBytes at:idx put:0. |
|
801 |
codeIndex := idx + 1 |
|
45 | 802 |
! |
803 |
||
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
804 |
appendEmptyLong |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
805 |
"append an empty long (4 bytes) to the code-Array" |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
806 |
|
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
807 |
|idx "{Class: SmallInteger }"| |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
808 |
|
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
809 |
idx := codeIndex. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
810 |
codeBytes at:idx put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
811 |
codeBytes at:idx+1 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
812 |
codeBytes at:idx+2 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
813 |
codeBytes at:idx+3 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
814 |
codeIndex := idx + 4 |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
815 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
816 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
817 |
appendEmptyShort |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
818 |
"append an empty short (2 bytes) to the code-Array" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
819 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
820 |
|idx "{Class: SmallInteger }"| |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
821 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
822 |
idx := codeIndex. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
823 |
codeBytes at:idx put:0. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
824 |
codeBytes at:idx+1 put:0. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
825 |
codeIndex := idx + 2 |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
826 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
827 |
|
0 | 828 |
appendSignedByte:aByte |
829 |
"append a signedbyte (as in jump-offsets) to the code-Array, |
|
830 |
check range and report an error if invalid" |
|
831 |
||
49 | 832 |
|b "{Class: SmallInteger }" |
833 |
idx "{Class: SmallInteger }"| |
|
0 | 834 |
|
49 | 835 |
idx := codeIndex. |
0 | 836 |
b := aByte. |
837 |
(b >= 0) ifTrue:[ |
|
45 | 838 |
(b > 127) ifTrue:[ |
839 |
self error:'jump-range error'. |
|
840 |
errorFlag := #Error |
|
841 |
]. |
|
49 | 842 |
codeBytes at:idx put:b |
0 | 843 |
] ifFalse:[ |
45 | 844 |
(b < -128) ifTrue:[ |
845 |
self error:'jump-range error'. |
|
846 |
errorFlag := #Error |
|
847 |
]. |
|
49 | 848 |
b := 256 + b |
0 | 849 |
]. |
49 | 850 |
codeBytes at:idx put:b. |
851 |
codeIndex := idx + 1 |
|
0 | 852 |
! |
853 |
||
46 | 854 |
appendSignedWord:aWord |
855 |
"append a signed word to the code-Array, |
|
856 |
check range and report an error if invalid" |
|
857 |
||
49 | 858 |
|w "{Class: SmallInteger }"| |
46 | 859 |
|
860 |
w := aWord. |
|
861 |
(w >= 0) ifTrue:[ |
|
862 |
(w > 16r7FFFF) ifTrue:[ |
|
863 |
self error:'word-range error'. |
|
864 |
errorFlag := #Error |
|
865 |
]. |
|
866 |
] ifFalse:[ |
|
867 |
(w < 16r-8000) ifTrue:[ |
|
868 |
self error:'word-range error'. |
|
869 |
errorFlag := #Error |
|
870 |
]. |
|
871 |
w := (16r10000 + w). |
|
872 |
]. |
|
873 |
self appendWord:w |
|
874 |
! |
|
875 |
||
141 | 876 |
appendWord:aWord |
877 |
"append an unsigned word (low-high) to the code-Array, |
|
878 |
checking for word-range (debug-only)" |
|
879 |
||
880 |
|idx "{Class: SmallInteger }"| |
|
881 |
||
882 |
idx := codeIndex. |
|
883 |
(aWord between:0 and:16rFFFF) ifTrue:[ |
|
884 |
codeBytes at:idx put:(aWord bitAnd:16rFF). |
|
885 |
idx := idx + 1. |
|
886 |
codeBytes at:idx put:(aWord bitShift:-8). |
|
887 |
codeIndex := idx + 1 |
|
888 |
] ifFalse:[ |
|
889 |
self error:'word range error'. |
|
890 |
errorFlag := #Error |
|
891 |
] |
|
892 |
! |
|
893 |
||
0 | 894 |
byteCodeFor:aSymbol |
895 |
"given a symbolic instruction, return the corresponding bytecode. |
|
896 |
as a side-effect, leave number of bytes pushed/popped by this instr. |
|
897 |
in stackDelta, and, if the instruction needs extra arguments, leave |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
898 |
this info in extra. Also lineno is set to true, if this code has line |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
899 |
information and extraLiteral is set if any hidden send is performed by it." |
0 | 900 |
|
901 |
"standard bytecodes" |
|
902 |
||
903 |
(aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10]. |
|
904 |
(aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11]. |
|
905 |
(aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12]. |
|
906 |
(aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14]. |
|
105 | 907 |
(aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14]. |
0 | 908 |
(aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15]. |
909 |
(aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16]. |
|
910 |
||
911 |
(aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30]. |
|
912 |
(aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31]. |
|
913 |
(aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32]. |
|
914 |
(aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33]. |
|
915 |
(aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34]. |
|
1 | 916 |
(aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42]. |
917 |
(aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128]. |
|
0 | 918 |
|
919 |
(aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0]. |
|
920 |
(aSymbol == #retSelf) ifTrue:[^5]. |
|
921 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
922 |
(aSymbol == #==) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 45]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
923 |
(aSymbol == #~~) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 46]. |
0 | 924 |
|
925 |
(aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50]. |
|
926 |
(aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51]. |
|
927 |
(aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52]. |
|
928 |
(aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53]. |
|
929 |
(aSymbol == #jump) ifTrue:[extra := #offset. ^ 54]. |
|
1 | 930 |
(aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55]. |
0 | 931 |
(aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56]. |
932 |
(aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57]. |
|
933 |
(aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58]. |
|
934 |
(aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59]. |
|
935 |
||
54 | 936 |
(aSymbol == #lineno) ifTrue:[lineno := true. ^ 8]. |
937 |
||
106 | 938 |
(aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19]. |
939 |
(aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
940 |
(aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
117 | 941 |
(aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13]. |
0 | 942 |
|
943 |
(aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18]. |
|
944 |
(aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47]. |
|
945 |
||
117 | 946 |
(aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37]. |
947 |
(aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38]. |
|
948 |
(aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39]. |
|
0 | 949 |
|
117 | 950 |
(aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35]. |
951 |
(aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35]. |
|
952 |
||
953 |
(aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40]. |
|
954 |
(aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 40]. |
|
247 | 955 |
(aSymbol == #pushSpecialGlobal) ifTrue:[stackDelta := 1. extra := #index. ^ 200]. |
117 | 956 |
|
1 | 957 |
(aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129]. |
0 | 958 |
|
117 | 959 |
(aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176]. |
960 |
(aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177]. |
|
105 | 961 |
|
0 | 962 |
"optimized bytecodes" |
963 |
||
964 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
|
965 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
966 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
967 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
968 |
(aSymbol == #retNum) ifTrue:[extra := #number. ^ 127]. |
|
25 | 969 |
(aSymbol == #homeRetTop) ifTrue:[^ 7]. |
0 | 970 |
|
46 | 971 |
(aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17]. |
0 | 972 |
(aSymbol == #push0) ifTrue:[stackDelta := 1. ^120]. |
973 |
(aSymbol == #push1) ifTrue:[stackDelta := 1. ^121]. |
|
3 | 974 |
(aSymbol == #push2) ifTrue:[stackDelta := 1. ^139]. |
0 | 975 |
(aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122]. |
976 |
||
106 | 977 |
(aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21]. |
978 |
(aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22]. |
|
979 |
(aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23]. |
|
980 |
(aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24]. |
|
0 | 981 |
|
106 | 982 |
(aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180]. |
983 |
(aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181]. |
|
984 |
(aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182]. |
|
985 |
(aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183]. |
|
986 |
(aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184]. |
|
987 |
(aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185]. |
|
988 |
(aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186]. |
|
989 |
(aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187]. |
|
0 | 990 |
|
106 | 991 |
(aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25]. |
992 |
(aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26]. |
|
993 |
(aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27]. |
|
994 |
(aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28]. |
|
995 |
(aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29]. |
|
0 | 996 |
|
997 |
(aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80]. |
|
998 |
(aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81]. |
|
999 |
(aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82]. |
|
1000 |
(aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83]. |
|
1001 |
(aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84]. |
|
1002 |
(aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85]. |
|
1003 |
||
1004 |
(aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86]. |
|
1005 |
(aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87]. |
|
1006 |
(aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88]. |
|
1007 |
(aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89]. |
|
1008 |
||
1009 |
(aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90]. |
|
1010 |
(aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91]. |
|
1011 |
(aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92]. |
|
1012 |
(aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93]. |
|
1013 |
(aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94]. |
|
1014 |
(aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95]. |
|
1015 |
(aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96]. |
|
1016 |
(aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97]. |
|
1017 |
(aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98]. |
|
1018 |
(aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99]. |
|
1019 |
||
1020 |
(aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100]. |
|
1021 |
(aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101]. |
|
1022 |
(aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102]. |
|
1023 |
(aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103]. |
|
1024 |
(aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104]. |
|
1025 |
(aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105]. |
|
1026 |
||
1027 |
(aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110]. |
|
1028 |
(aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111]. |
|
1029 |
(aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112]. |
|
1030 |
(aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113]. |
|
1031 |
(aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114]. |
|
1032 |
(aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115]. |
|
1033 |
(aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116]. |
|
1034 |
(aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117]. |
|
1035 |
(aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118]. |
|
1036 |
(aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119]. |
|
1037 |
||
103 | 1038 |
(aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222]. |
1039 |
(aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223]. |
|
1040 |
(aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224]. |
|
1041 |
(aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225]. |
|
1042 |
(aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226]. |
|
1043 |
(aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227]. |
|
1044 |
(aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228]. |
|
1045 |
(aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229]. |
|
1046 |
||
0 | 1047 |
(aSymbol == #retMethodVar1) ifTrue:[^160]. |
1048 |
(aSymbol == #retMethodVar2) ifTrue:[^161]. |
|
1049 |
(aSymbol == #retMethodVar3) ifTrue:[^162]. |
|
1050 |
(aSymbol == #retMethodVar4) ifTrue:[^163]. |
|
1051 |
(aSymbol == #retMethodVar5) ifTrue:[^164]. |
|
1052 |
(aSymbol == #retMethodVar6) ifTrue:[^165]. |
|
1053 |
||
1054 |
(aSymbol == #retInstVar1) ifTrue:[^166]. |
|
1055 |
(aSymbol == #retInstVar2) ifTrue:[^167]. |
|
1056 |
(aSymbol == #retInstVar3) ifTrue:[^168]. |
|
1057 |
(aSymbol == #retInstVar4) ifTrue:[^169]. |
|
1058 |
(aSymbol == #retInstVar5) ifTrue:[^170]. |
|
1059 |
(aSymbol == #retInstVar6) ifTrue:[^171]. |
|
1060 |
(aSymbol == #retInstVar7) ifTrue:[^172]. |
|
1061 |
(aSymbol == #retInstVar8) ifTrue:[^173]. |
|
1062 |
||
1063 |
(aSymbol == #retMethodArg1) ifTrue:[^174]. |
|
1064 |
(aSymbol == #retMethodArg2) ifTrue:[^175]. |
|
1065 |
||
1066 |
(aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140]. |
|
1067 |
(aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141]. |
|
1068 |
(aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142]. |
|
1069 |
(aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143]. |
|
1070 |
||
1 | 1071 |
(aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43]. |
1072 |
(aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44]. |
|
0 | 1073 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1074 |
(aSymbol == #=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^130]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1075 |
(aSymbol == #+) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^131]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1076 |
(aSymbol == #~=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^132]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1077 |
(aSymbol == #-) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^133]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1078 |
(aSymbol == #*) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^230]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1079 |
(aSymbol == #class) ifTrue:[extraLiteral := aSymbol. ^134]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1080 |
(aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. ^106]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1081 |
(aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. ^107]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1082 |
(aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. ^108]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1083 |
(aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. ^109]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1084 |
(aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. ^154]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1085 |
(aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. ^155]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1086 |
(aSymbol == #at:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^135]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1087 |
(aSymbol == #at:put:)ifTrue:[lineno := true. stackDelta := -2. extraLiteral := aSymbol. ^136]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1088 |
(aSymbol == #bitAnd:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^137]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1089 |
(aSymbol == #bitOr:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^138]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1090 |
(aSymbol == #plus1) ifTrue:[lineno := true. extraLiteral := #+. ^123]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1091 |
(aSymbol == #minus1) ifTrue:[lineno := true. extraLiteral := #-. ^124]. |
0 | 1092 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1093 |
(aSymbol == #incMethodVar) ifTrue:[lineno := true. extraLiteral := #+. extra := #index. ^125]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1094 |
(aSymbol == #decMethodVar) ifTrue:[lineno := true. extraLiteral := #-. extra := #index. ^126]. |
0 | 1095 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1096 |
(aSymbol == #eq0) ifTrue:[extraLiteral := #==. ^48]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1097 |
(aSymbol == #ne0) ifTrue:[extraLiteral := #~~. ^49]. |
0 | 1098 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1099 |
(aSymbol == #>) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 145]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1100 |
(aSymbol == #>=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 146]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1101 |
(aSymbol == #<) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 147]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1102 |
(aSymbol == #<=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 148]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1103 |
(aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 149]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1104 |
(aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 150]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1105 |
(aSymbol == #value) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 151]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1106 |
(aSymbol == #value:) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 152]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1107 |
(aSymbol == #value:value:) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -2. ^ 178]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1108 |
(aSymbol == #size) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 153]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1109 |
(aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 158]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1110 |
(aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 159]. |
0 | 1111 |
(aSymbol == #mk0Block) ifTrue:[^ 156]. |
1112 |
(aSymbol == #mkNilBlock) ifTrue:[^ 157]. |
|
1113 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1114 |
(aSymbol == #gt0) ifTrue:[lineno := true. extraLiteral := #>. ^ 212]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1115 |
(aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. extraLiteral := #>. ^ 208]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1116 |
(aSymbol == #basicNew) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 211]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1117 |
(aSymbol == #new) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 213]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1118 |
(aSymbol == #basicNew:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 214]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1119 |
(aSymbol == #new:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 215]. |
103 | 1120 |
|
217 | 1121 |
(aSymbol == #pushBlockVar1) ifTrue:[stackDelta := 1. ^ 232]. |
1122 |
(aSymbol == #pushBlockVar2) ifTrue:[stackDelta := 1. ^ 233]. |
|
1123 |
(aSymbol == #pushBlockVar3) ifTrue:[stackDelta := 1. ^ 234]. |
|
1124 |
(aSymbol == #storeBlockVar1) ifTrue:[stackDelta := -1. ^ 235]. |
|
1125 |
(aSymbol == #storeBlockVar2) ifTrue:[stackDelta := -1. ^ 236]. |
|
1126 |
(aSymbol == #storeBlockVar3) ifTrue:[stackDelta := -1. ^ 237]. |
|
1127 |
||
0 | 1128 |
(aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190]. |
1129 |
(aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191]. |
|
1130 |
(aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192]. |
|
1131 |
(aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193]. |
|
1132 |
(aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194]. |
|
1 | 1133 |
(aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195]. |
0 | 1134 |
(aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196]. |
1135 |
(aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197]. |
|
1 | 1136 |
(aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198]. |
1137 |
(aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199]. |
|
0 | 1138 |
|
1139 |
(aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144]. |
|
1140 |
||
76 | 1141 |
(aSymbol == #isNil) ifTrue:[^ 188]. |
1142 |
(aSymbol == #notNil) ifTrue:[^ 189]. |
|
1143 |
(aSymbol == #not) ifTrue:[lineno := true. ^ 179]. |
|
110 | 1144 |
(aSymbol == #&) ifTrue:[lineno := true. ^ 216]. |
1145 |
(aSymbol == #|) ifTrue:[lineno := true. ^ 217]. |
|
76 | 1146 |
|
117 | 1147 |
(aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
1148 |
(aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
|
1149 |
(aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219]. |
|
1150 |
(aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219]. |
|
1151 |
(aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201]. |
|
1152 |
||
1153 |
(aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205]. |
|
1154 |
(aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207]. |
|
1155 |
(aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204]. |
|
1156 |
(aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
1157 |
(aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
106 | 1158 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1159 |
(aSymbol == #top) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1160 |
(aSymbol == #bottom) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1161 |
(aSymbol == #left) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1162 |
(aSymbol == #right) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1163 |
|
217 | 1164 |
(aSymbol == #blockRef) ifTrue:[stackDelta := 0. ^ 238]. |
1165 |
||
0 | 1166 |
self error:'invalid code symbol'. |
1167 |
errorFlag := #Error |
|
117 | 1168 |
|
1169 |
"Modified: 3.9.1995 / 12:58:47 / claus" |
|
217 | 1170 |
"Modified: 1.3.1996 / 00:09:50 / cg" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1171 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1172 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1173 |
checkForCommonCode:symbolicCodeArray |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1174 |
"hook to return the code for common code sequences. |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1175 |
This reduces the in-memory number of byteArrays somewhat. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1176 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1177 |
Not yet fully implemented - just an idea ... theres certainly more to do here |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1178 |
(does it make sense to scan all methods, collect code in a set and unify things |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1179 |
automatically in the background - or upon request ?)" |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1180 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1181 |
|sz insn1| |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1182 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1183 |
(sz := symbolicCodeArray size) == 2 ifTrue:[ |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1184 |
"/ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1185 |
"/ a very common sequence: return the first literal |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1186 |
"/ |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1187 |
(insn1 := symbolicCodeArray at:1) == #pushLit1 ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1188 |
(symbolicCodeArray at:2) == #retTop ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1189 |
^ #[222 0] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1190 |
] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1191 |
] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1192 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1193 |
sz == 1 ifTrue:[ |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1194 |
"/ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1195 |
"/ another common sequence: return the receiver |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1196 |
"/ |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1197 |
(insn1 := symbolicCodeArray at:1) == #retSelf ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1198 |
^ #[5] |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1199 |
]. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1200 |
insn1 == #retTrue ifTrue:[ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1201 |
^ #[2] |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1202 |
]. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1203 |
insn1 == #retFalse ifTrue:[ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1204 |
^ #[3] |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1205 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1206 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1207 |
^ nil |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1208 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1209 |
|
141 | 1210 |
checkForPrimitiveCode:nr |
1211 |
"return the code for an ST-80 primitive method. |
|
1212 |
Since many primitives available on ST-80 should also be available |
|
1213 |
somewhere in ST/X, this may work for many primitive numbers. |
|
1214 |
However, more information is needed and more things to be added below. |
|
1215 |
||
1216 |
This was added to allow emulation of (some) ST-80 |
|
1217 |
primitives (to fileIn RemoteInvocation & Monitor41 packages)" |
|
1218 |
||
1219 |
|cls sel| |
|
1220 |
||
1221 |
(nr == 75) ifTrue:[ cls := Object. sel := #identityHash ]. |
|
1222 |
(nr == 110) ifTrue:[ cls := Object. sel := #== ]. |
|
1223 |
(nr == 111) ifTrue:[ cls := Object. sel := #class ]. |
|
1224 |
" |
|
1225 |
should add more here, to be able to fileIn ST-80 methods |
|
1226 |
containing primitive calls (who gives me the numbers ... ?) |
|
1227 |
" |
|
1228 |
cls notNil ifTrue:[ |
|
1229 |
^ (cls compiledMethodAt:sel) code |
|
1230 |
]. |
|
1231 |
^ nil |
|
1232 |
! |
|
1233 |
||
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1234 |
createMethod |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1235 |
|newMethod i| |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1236 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1237 |
newMethod := Method new:(litArray size). |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1238 |
litArray notNil ifTrue:[ |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1239 |
newMethod literals:litArray |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1240 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1241 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1242 |
newMethod numberOfMethodVars:(self numberOfMethodVars). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1243 |
newMethod numberOfMethodArgs:(self numberOfMethodArgs). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1244 |
newMethod stackSize:(self maxStackDepth). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1245 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1246 |
primitiveResource notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1247 |
newMethod setResourceFlag |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1248 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1249 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1250 |
^ newMethod |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1251 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1252 |
"Created: 18.5.1996 / 16:33:17 / cg" |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1253 |
"Modified: 18.5.1996 / 16:41:31 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1254 |
"Modified: 24.6.1996 / 12:32:50 / stefan" |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1255 |
! |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1256 |
|
141 | 1257 |
genByteCodeFrom:symbolicCodeArray |
1258 |
"convert symbolicCode into bytecodes" |
|
1259 |
||
1260 |
|symIndex "{Class: SmallInteger }" |
|
1261 |
codeSize "{Class: SmallInteger }" |
|
1262 |
symCodeSize "{Class: SmallInteger }" |
|
1263 |
index addr |
|
1264 |
codeSymbol nargs needRetry |
|
1265 |
stackDepth relocInfo level nvars round t| |
|
1266 |
||
1267 |
symbolicCodeArray isNil ifTrue:[^ self]. |
|
1268 |
||
1269 |
round := 0. |
|
1270 |
needRetry := true. |
|
1271 |
symCodeSize := symbolicCodeArray size. |
|
192
5f5ecdcffc67
share common byteCodes - just an idea and more is needed for most compact code
Claus Gittinger <cg@exept.de>
parents:
191
diff
changeset
|
1272 |
ShareCode ifTrue:[ |
280 | 1273 |
codeBytes := self checkForCommonCode:symbolicCodeArray. |
1274 |
codeBytes notNil ifTrue:[ |
|
1275 |
^ self |
|
1276 |
]. |
|
192
5f5ecdcffc67
share common byteCodes - just an idea and more is needed for most compact code
Claus Gittinger <cg@exept.de>
parents:
191
diff
changeset
|
1277 |
]. |
141 | 1278 |
codeSize := symCodeSize. |
1279 |
||
1280 |
[needRetry] whileTrue:[ |
|
280 | 1281 |
stackDepth := 0. |
1282 |
maxStackDepth := 0. |
|
141 | 1283 |
|
280 | 1284 |
codeBytes := ByteArray uninitializedNew:codeSize. |
1285 |
relocInfo := Array basicNew:(codeSize + 1). |
|
1286 |
symIndex := 1. |
|
1287 |
codeIndex := 1. |
|
141 | 1288 |
|
280 | 1289 |
needRetry := false. |
1290 |
round := round + 1. |
|
141 | 1291 |
|
280 | 1292 |
[symIndex <= symCodeSize] whileTrue:[ |
1293 |
relocInfo at:symIndex put:codeIndex. |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1294 |
|
280 | 1295 |
codeSymbol := symbolicCodeArray at:symIndex. |
1296 |
symIndex := symIndex + 1. |
|
1297 |
stackDelta := 0. |
|
1298 |
extra := extraLiteral := nil. |
|
1299 |
lineno := false. |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1300 |
|
280 | 1301 |
self appendByteCodeFor:codeSymbol. |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1302 |
|
280 | 1303 |
extraLiteral notNil ifTrue:[ |
1304 |
self addLiteral:extraLiteral |
|
1305 |
]. |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1306 |
|
280 | 1307 |
lineno ifTrue:[ |
1308 |
self appendByte:((symbolicCodeArray at:symIndex) min:255). |
|
1309 |
symIndex := symIndex + 1 |
|
1310 |
]. |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1311 |
|
280 | 1312 |
extra notNil ifTrue:[ |
1313 |
(extra == #number) ifTrue:[ |
|
1314 |
index := symbolicCodeArray at:symIndex. |
|
1315 |
symIndex := symIndex + 1. |
|
1316 |
self appendSignedByte:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1317 |
|
280 | 1318 |
] ifFalse:[ (extra == #number16) ifTrue:[ |
1319 |
index := symbolicCodeArray at:symIndex. |
|
1320 |
symIndex := symIndex + 2. |
|
1321 |
self appendSignedWord:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1322 |
|
280 | 1323 |
] ifFalse:[ (extra == #unsigned16) ifTrue:[ |
1324 |
index := symbolicCodeArray at:symIndex. |
|
1325 |
symIndex := symIndex + 2. |
|
1326 |
self appendWord:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1327 |
|
280 | 1328 |
] ifFalse:[ (extra == #index) ifTrue:[ |
1329 |
index := symbolicCodeArray at:symIndex. |
|
1330 |
symIndex := symIndex + 1. |
|
1331 |
self appendByte:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1332 |
|
280 | 1333 |
] ifFalse:[ (extra == #lit) ifTrue:[ |
1334 |
index := self addLiteral:(symbolicCodeArray at:symIndex). |
|
1335 |
symIndex := symIndex + 1. |
|
1336 |
self appendByte:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1337 |
|
280 | 1338 |
] ifFalse:[ (extra == #speciallit) ifTrue:[ |
1339 |
index := self addLiteral:(symbolicCodeArray at:symIndex). |
|
1340 |
index > 255 ifTrue:[ |
|
1341 |
self parseError:'too many globals (' , |
|
1342 |
(symbolicCodeArray at:symIndex) , |
|
1343 |
' index=' , index printString , |
|
1344 |
') in method - please simplify'. |
|
1345 |
^ #Error |
|
1346 |
]. |
|
1347 |
symIndex := symIndex + 1. |
|
1348 |
self appendByte:index. |
|
1349 |
self appendEmptyShort. "space for inline-generation" |
|
1350 |
self appendEmptyLong. "space for inline-address" |
|
1351 |
symIndex := symIndex + 6 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1352 |
|
280 | 1353 |
] ifFalse:[ (extra == #speciallitS) ifTrue:[ |
1354 |
index := symbolicCodeArray at:symIndex. |
|
1355 |
symIndex := symIndex + 1. |
|
1356 |
self appendByte:index. |
|
1357 |
self appendEmptyShort. "space for inline-generation" |
|
1358 |
self appendEmptyLong. "space for inline-address" |
|
1359 |
symIndex := symIndex + 6 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1360 |
|
280 | 1361 |
] ifFalse:[ (extra == #speciallitL) ifTrue:[ |
1362 |
index := symbolicCodeArray at:symIndex. |
|
1363 |
symIndex := symIndex + 2. |
|
1364 |
self appendWord:index. |
|
1365 |
self appendEmptyShort. "space for inline-generation" |
|
1366 |
self appendEmptyLong. "space for inline-address" |
|
1367 |
symIndex := symIndex + 6 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1368 |
|
280 | 1369 |
] ifFalse:[ (extra == #offset) ifTrue:[ |
1370 |
relocInfo at:symIndex put:codeIndex. |
|
1371 |
self addReloc:symIndex. |
|
1372 |
symIndex := symIndex + 1. |
|
1373 |
self appendByte:0 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1374 |
|
280 | 1375 |
] ifFalse:[ (extra == #indexLevel) ifTrue:[ |
1376 |
index := symbolicCodeArray at:symIndex. |
|
1377 |
symIndex := symIndex + 1. |
|
1378 |
self appendByte:index. |
|
1379 |
level := symbolicCodeArray at:symIndex. |
|
1380 |
symIndex := symIndex + 1. |
|
1381 |
self appendByte:level |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1382 |
|
280 | 1383 |
] ifFalse:[ (extra == #offsetNvarNarg) ifTrue:[ |
1384 |
relocInfo at:symIndex put:codeIndex. |
|
1385 |
self addReloc:symIndex. |
|
1386 |
symIndex := symIndex + 1. |
|
1387 |
self appendEmptyByte. |
|
1388 |
nvars := symbolicCodeArray at:symIndex. |
|
1389 |
symIndex := symIndex + 1. |
|
1390 |
self appendByte:nvars. |
|
1391 |
level := symbolicCodeArray at:symIndex. |
|
1392 |
symIndex := symIndex + 1. |
|
1393 |
self appendByte:level |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1394 |
|
280 | 1395 |
] ifFalse:[ (extra == #absoffset) ifTrue:[ |
1396 |
relocInfo at:symIndex put:codeIndex. |
|
1397 |
self addReloc:symIndex. |
|
1398 |
addr := symbolicCodeArray at:symIndex. |
|
1399 |
symIndex := symIndex + 1. |
|
1400 |
self appendByte:(addr bitAnd:16rFF). |
|
1401 |
self appendByte:((addr bitShift:-8) bitAnd:16rFF). |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1402 |
|
280 | 1403 |
] ifFalse:[ (extra == #absoffsetNvarNarg) ifTrue:[ |
1404 |
relocInfo at:symIndex put:codeIndex. |
|
1405 |
self addReloc:symIndex. |
|
1406 |
addr := symbolicCodeArray at:symIndex. |
|
1407 |
symIndex := symIndex + 1. |
|
1408 |
self appendByte:(addr bitAnd:16rFF). |
|
1409 |
self appendByte:((addr bitShift:-8) bitAnd:16rFF). |
|
1410 |
nvars := symbolicCodeArray at:symIndex. |
|
1411 |
symIndex := symIndex + 1. |
|
1412 |
self appendByte:nvars. |
|
1413 |
level := symbolicCodeArray at:symIndex. |
|
1414 |
symIndex := symIndex + 1. |
|
1415 |
self appendByte:level |
|
141 | 1416 |
|
280 | 1417 |
] ifFalse:[ (extra == #special) ifTrue:[ |
1418 |
((codeSymbol == #send) |
|
1419 |
or:[codeSymbol == #sendSelf |
|
1420 |
or:[codeSymbol == #superSend |
|
1421 |
or:[codeSymbol == #hereSend]]]) ifTrue:[ |
|
1422 |
index := symbolicCodeArray at:symIndex. |
|
1423 |
symIndex := symIndex + 1. |
|
1424 |
nargs := symbolicCodeArray at:symIndex. |
|
1425 |
symIndex := symIndex + 1. |
|
1426 |
self appendByte:nargs. |
|
1427 |
self appendByte:index. |
|
141 | 1428 |
|
280 | 1429 |
(codeSymbol == #superSend |
1430 |
or:[codeSymbol == #hereSend]) ifTrue:[ |
|
1431 |
index := symbolicCodeArray at:symIndex. |
|
1432 |
symIndex := symIndex + 1. |
|
1433 |
self appendByte:index |
|
1434 |
]. |
|
1435 |
stackDelta := nargs negated. |
|
1436 |
codeSymbol == #sendSelf ifTrue:[ |
|
1437 |
stackDelta := stackDelta + 1 |
|
1438 |
] |
|
1439 |
] ifFalse:[ |
|
1440 |
(codeSymbol == #sendDrop) ifTrue:[ |
|
1441 |
index := symbolicCodeArray at:symIndex. |
|
1442 |
symIndex := symIndex + 1. |
|
1443 |
nargs := symbolicCodeArray at:symIndex. |
|
1444 |
symIndex := symIndex + 1. |
|
1445 |
self appendByte:nargs. |
|
1446 |
self appendByte:index. |
|
1447 |
stackDelta := (nargs + 1) negated |
|
1448 |
] |
|
1449 |
] |
|
141 | 1450 |
|
280 | 1451 |
] ifFalse:[ (extra == #specialL) ifTrue:[ |
1452 |
((codeSymbol == #sendL) |
|
1453 |
or:[codeSymbol == #sendSelfL |
|
1454 |
or:[codeSymbol == #superSendL |
|
1455 |
or:[codeSymbol == #hereSendL]]]) ifTrue:[ |
|
1456 |
index := symbolicCodeArray at:symIndex. |
|
1457 |
symIndex := symIndex + 2. |
|
1458 |
nargs := symbolicCodeArray at:symIndex. |
|
1459 |
symIndex := symIndex + 1. |
|
1460 |
self appendByte:nargs. |
|
1461 |
self appendWord:index. |
|
1462 |
(codeSymbol == #superSendL |
|
1463 |
or:[codeSymbol == #hereSendL]) ifTrue:[ |
|
1464 |
index := symbolicCodeArray at:symIndex. |
|
1465 |
symIndex := symIndex + 2. |
|
1466 |
self appendWord:index. |
|
1467 |
]. |
|
1468 |
stackDelta := nargs negated. |
|
1469 |
codeSymbol == #sendSelfL ifTrue:[ |
|
1470 |
stackDelta := stackDelta + 1 |
|
1471 |
] |
|
1472 |
] |
|
1473 |
] ifFalse:[ (extra == #specialSend) ifTrue:[ |
|
1474 |
index := symbolicCodeArray at:symIndex. |
|
1475 |
symIndex := symIndex + 1. |
|
1476 |
self appendByte:index. |
|
1477 |
]]]]]]]]]]]]]]]] |
|
1478 |
]. |
|
141 | 1479 |
|
280 | 1480 |
stackDepth := stackDepth + stackDelta. |
1481 |
(stackDepth > maxStackDepth) ifTrue:[ |
|
1482 |
maxStackDepth := stackDepth |
|
1483 |
] |
|
1484 |
]. |
|
1485 |
relocInfo at:symIndex put:codeIndex. |
|
141 | 1486 |
|
280 | 1487 |
needRetry ifFalse:[ |
1488 |
" |
|
1489 |
now relocate - returns true if ok, false if we have to do it again |
|
1490 |
(when short jumps have been changed to long jumps) |
|
1491 |
" |
|
1492 |
relocList notNil ifTrue:[ |
|
1493 |
needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not. |
|
1494 |
" |
|
1495 |
if returned with false, a relative jump was made into |
|
1496 |
an absolute jump - need to start over with one more byte space |
|
1497 |
" |
|
1498 |
needRetry ifTrue:[ |
|
1499 |
relocList := nil. |
|
1500 |
codeSize := codeSize + 1. |
|
1501 |
] |
|
1502 |
] |
|
1503 |
] ifTrue:[ |
|
1504 |
'compiling again ...' infoPrintCR. |
|
1505 |
] |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1506 |
]. |
141 | 1507 |
"code printNL." |
1508 |
^ errorFlag |
|
1509 |
||
1510 |
"Modified: 3.9.1995 / 12:59:43 / claus" |
|
280 | 1511 |
"Modified: 20.5.1996 / 10:31:20 / cg" |
141 | 1512 |
! |
1513 |
||
1514 |
genSymbolicCode |
|
1515 |
"traverse the parse-tree producing symbolicCode - return the codeArray" |
|
1516 |
||
1517 |
|codeStream code thisStatement lastStatement| |
|
1518 |
||
1519 |
litArray := nil. |
|
1520 |
codeStream := WriteStream on:(OrderedCollection new:100). |
|
1521 |
||
1522 |
thisStatement := tree. |
|
1523 |
[thisStatement notNil] whileTrue:[ |
|
1524 |
lastStatement := thisStatement. |
|
1525 |
thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
1526 |
thisStatement := thisStatement nextStatement |
|
1527 |
]. |
|
1528 |
(lastStatement isNil or:[lastStatement isReturnNode not]) |
|
1529 |
ifTrue:[ |
|
1530 |
"not a return - add retSelf" |
|
1531 |
" |
|
1532 |
if the last statement was a send for side-effect, |
|
1533 |
replace the previous drop by a retSelf |
|
1534 |
" |
|
1535 |
lastStatement notNil ifTrue:[ |
|
1536 |
((code := codeStream contents) notNil |
|
1537 |
and:[code size > 0 |
|
1538 |
and:[code last == #drop]]) ifTrue:[ |
|
1539 |
codeStream position:(codeStream position - 1). |
|
1540 |
codeStream nextPut:#retSelf |
|
1541 |
] |
|
1542 |
]. |
|
1543 |
codeStream nextPut:#retSelf |
|
1544 |
]. |
|
1545 |
^ codeStream contents |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1546 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1547 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1548 |
hasLineNumber:sel |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1549 |
"return true, if special send code needs lineNr" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1550 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1551 |
(sel == #==) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1552 |
(sel == #~~) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1553 |
(sel == #class) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1554 |
(sel == #isNil) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1555 |
(sel == #notNil) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1556 |
^ true |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1557 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1558 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1559 |
isBuiltIn1ArgSelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1560 |
"return true, if selector sel is built-in. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1561 |
(i.e. there is a single bytecode for it)" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1562 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1563 |
(sel == #at:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1564 |
(sel == #value:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1565 |
(sel == #bitAnd:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1566 |
(sel == #bitOr:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1567 |
(sel == #new:) ifTrue:[^ true]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1568 |
(sel == #basicNew:) ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1569 |
"/ this one is critical - some redefine it |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1570 |
receiver isGlobal ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1571 |
(#('String' 'ByteArray' 'Array' |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1572 |
'Point' 'Rectangle' 'Object') |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1573 |
includes:receiver name) ifTrue:[^ true]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1574 |
]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1575 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1576 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1577 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1578 |
"Created: 17.4.1996 / 22:33:13 / cg" |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1579 |
"Modified: 17.4.1996 / 22:38:08 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1580 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1581 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1582 |
isBuiltIn2ArgSelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1583 |
"return true, if selector sel is built-in. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1584 |
(i.e. there is a single bytecode for it)" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1585 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1586 |
(sel == #at:put:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1587 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1588 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1589 |
"Created: 17.4.1996 / 22:33:16 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1590 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1591 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1592 |
isBuiltInBinarySelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1593 |
sel == #== ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1594 |
sel == #~~ ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1595 |
sel == #= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1596 |
sel == #~= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1597 |
sel == #+ ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1598 |
sel == #- ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1599 |
sel == #< ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1600 |
sel == #<= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1601 |
sel == #> ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1602 |
sel == #>= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1603 |
sel == #* ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1604 |
sel == #& ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1605 |
sel == #| ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1606 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1607 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1608 |
"Created: 17.4.1996 / 22:34:27 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1609 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1610 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1611 |
isBuiltInUnarySelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1612 |
"return true, if unary selector sel is built-in. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1613 |
(i.e. there is a single bytecode for it)" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1614 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1615 |
(sel == #peek) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1616 |
(sel == #value) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1617 |
(sel == #next) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1618 |
(sel == #class) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1619 |
(sel == #size) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1620 |
(sel == #x) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1621 |
(sel == #y) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1622 |
(sel == #width) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1623 |
(sel == #height) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1624 |
(sel == #origin) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1625 |
(sel == #extent) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1626 |
(sel == #asInteger) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1627 |
(sel == #rounded) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1628 |
(sel == #isNil) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1629 |
(sel == #notNil) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1630 |
(sel == #not) ifTrue:[^ true]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1631 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1632 |
(sel == #new) ifTrue:[^ true]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1633 |
(sel == #basicNew) ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1634 |
"/ this one is critical - some redefine it |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1635 |
receiver isGlobal ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1636 |
(#('String' 'ByteArray' 'Array' |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1637 |
'Point' 'Rectangle' 'Object') |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1638 |
includes:receiver name) ifTrue:[^ true]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1639 |
]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1640 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1641 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1642 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1643 |
"Created: 17.4.1996 / 22:32:16 / cg" |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1644 |
"Modified: 17.4.1996 / 22:38:14 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1645 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1646 |
|
247 | 1647 |
isSpecialGlobalSymbol:nm |
1648 |
"return true, if unary selector sel is a special selector" |
|
1649 |
||
1650 |
^ #(Array String FloatArray DoubleArray |
|
1651 |
Point Symbol Smalltalk Processor) includesIdentical:nm |
|
1652 |
||
1653 |
"Created: 13.4.1996 / 20:15:35 / cg" |
|
1654 |
"Modified: 13.4.1996 / 20:24:01 / cg" |
|
1655 |
! |
|
1656 |
||
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1657 |
isSpecialSendSelector:sel |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1658 |
"return true, if unary selector sel is a special selector" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1659 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1660 |
(sel == #top) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1661 |
(sel == #bottom) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1662 |
(sel == #left) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1663 |
(sel == #right) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1664 |
^ false |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1665 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1666 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1667 |
moveGlobalsToFront |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1668 |
"move all global-literals to the front of the literal array. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1669 |
This may be the last chance to compile the method, since |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1670 |
for globals, the maximum literal index is 255 - while for normal |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1671 |
literals its a stress-less 65535" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1672 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1673 |
litArray isNil ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1674 |
^ self error:'oops compiler botch'. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1675 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1676 |
litArray sort:[:a :b | "a < b -> #(a b)" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1677 |
(a isMemberOf:Symbol) ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1678 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1679 |
(b isMemberOf:Symbol) ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1680 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1681 |
(a at:1) isUppercase ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1682 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1683 |
(b at:1) isUppercase ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1684 |
ifTrue:[a < b]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1685 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1686 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1687 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1688 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1689 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1690 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1691 |
#(#A #c #B #D #E #a #b #F) |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1692 |
sort:[:a :b | |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1693 |
(a isMemberOf:Symbol) ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1694 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1695 |
(b isMemberOf:Symbol) ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1696 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1697 |
(a at:1) isUppercase ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1698 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1699 |
(b at:1) isUppercase ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1700 |
ifTrue:[(a < b)]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1701 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1702 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1703 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1704 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1705 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1706 |
" |
141 | 1707 |
! |
1708 |
||
1709 |
relocateWith:symbolicCodeArray relocInfo:relocInfo |
|
1710 |
"helper for genByteCodeFrom - relocate code using relocInfo. |
|
1711 |
if relocation fails badly (due to long relative jumps) patch |
|
1712 |
symbolicCode to use absolute jumps instead and return false |
|
1713 |
(genByteCodeFrom will then try again). Otherwise return true. |
|
1714 |
Also, on the fly, jumps to jumps and jumps to return are handled." |
|
1715 |
||
1716 |
|delta "{Class: SmallInteger }" |
|
1717 |
codePos "{Class: SmallInteger }" |
|
1718 |
opCodePos "{Class: SmallInteger }" |
|
1719 |
codeOffset "{Class: SmallInteger }" |
|
1720 |
symOffset |
|
1721 |
opcode "{Class: SmallInteger }" |
|
1722 |
dstOpcode jumpTarget |
|
1723 |
jumpCode deleteSet| |
|
1724 |
||
1725 |
deleteSet := OrderedCollection new. |
|
1726 |
relocList do:[:sIndex | |
|
1727 |
"have to relocate symCode at sIndex ..." |
|
1728 |
symOffset := symbolicCodeArray at:sIndex. "the target in the symbolic code" |
|
1729 |
codePos := relocInfo at:sIndex. "position of the offet in byte code" |
|
1730 |
codeOffset := relocInfo at:symOffset. "position of the target in byte code" |
|
1731 |
delta := codeOffset - codePos - 1. |
|
1732 |
opCodePos := codePos - 1. |
|
1733 |
opcode := codeBytes at:opCodePos. |
|
1734 |
||
1735 |
(opcode between:190 and:199) ifTrue:[ |
|
1736 |
"an absolute jump/makeBlock" |
|
1737 |
||
1738 |
codeBytes at:codePos put:(codeOffset bitAnd:16rFF). |
|
1739 |
codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8) |
|
1740 |
] ifFalse:[ |
|
1741 |
"get jump-code from long and vlong codes" |
|
1742 |
(opcode between:50 and:59) ifFalse:[ |
|
1743 |
(opcode between:60 and:69) ifTrue:[ |
|
1744 |
opcode := opcode - 10 |
|
1745 |
] ifFalse:[ |
|
1746 |
(opcode between:70 and:79) ifTrue:[ |
|
1747 |
opcode := opcode - 20 |
|
1748 |
] ifFalse:[ |
|
1749 |
self error:'invalid code to relocate' |
|
1750 |
] |
|
1751 |
]. |
|
1752 |
]. |
|
1753 |
||
1754 |
"optimize jump to return and jump to jump" |
|
1755 |
||
1756 |
(opcode == 54) ifTrue:[ |
|
1757 |
"a jump" |
|
1758 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
1759 |
||
1760 |
(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[ |
|
1761 |
"a jump to a return - put in the return instead jump" |
|
1762 |
||
1763 |
symbolicCodeArray at:(sIndex - 1) put:dstOpcode. |
|
1764 |
symbolicCodeArray at:sIndex put:dstOpcode. |
|
1765 |
codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode). |
|
1766 |
delta := 0. |
|
1767 |
deleteSet add:sIndex. |
|
1768 |
||
1769 |
" |
|
1770 |
'jump to return at: ' print. (sIndex - 1) printNL. |
|
1771 |
" |
|
1772 |
] ifFalse:[ |
|
1773 |
(dstOpcode == #jump) ifTrue:[ |
|
1774 |
"jump to jump to be done soon" |
|
1775 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
1776 |
" |
|
1777 |
'jump to jump at: ' print. (sIndex - 1) print. |
|
1778 |
' newTarget:' print. jumpTarget printNL. |
|
1779 |
" |
|
1780 |
||
1781 |
symbolicCodeArray at:sIndex put:jumpTarget. |
|
1782 |
symOffset := jumpTarget. |
|
1783 |
codeOffset := relocInfo at:symOffset. |
|
1784 |
delta := codeOffset - codePos - 1. |
|
1785 |
||
1786 |
"continue with new delta" |
|
1787 |
] |
|
1788 |
] |
|
1789 |
]. |
|
1790 |
(#(50 51 52 53 56 57 58 59) includes:opcode) ifTrue:[ |
|
1791 |
"a conditional jump" |
|
1792 |
||
1793 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
1794 |
(dstOpcode == #jump) ifTrue:[ |
|
1795 |
"conditional jump to unconditional jump" |
|
1796 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
1797 |
" |
|
1798 |
'cond jump to jump at: ' print. (sIndex - 1) print. |
|
1799 |
' newTarget:' print. jumpTarget printNL. |
|
1800 |
" |
|
1801 |
||
1802 |
symbolicCodeArray at:sIndex put:jumpTarget. |
|
1803 |
symOffset := jumpTarget. |
|
1804 |
codeOffset := relocInfo at:symOffset. |
|
1805 |
delta := codeOffset - codePos - 1. |
|
1806 |
||
1807 |
"continue with new delta" |
|
1808 |
]. |
|
1809 |
]. |
|
1810 |
||
1811 |
(delta >= 0) ifTrue:[ |
|
1812 |
(delta > 127) ifTrue:[ |
|
1813 |
(opcode between:50 and:59) ifFalse:[ |
|
1814 |
self error:'invalid code to relocate' |
|
1815 |
] ifTrue:[ |
|
1816 |
(delta > 255) ifTrue:[ |
|
1817 |
"change jmp into vljmp ..." |
|
1818 |
codeBytes at:opCodePos put:(opcode + 20). |
|
1819 |
delta := delta - 256 |
|
1820 |
] ifFalse:[ |
|
1821 |
"change jmp into ljmp ..." |
|
1822 |
codeBytes at:opCodePos put:(opcode + 10). |
|
1823 |
delta := delta - 128 |
|
1824 |
]. |
|
1825 |
(delta > 127) ifTrue:[ |
|
1826 |
"change symbolic into a jump absolute and fail" |
|
1827 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
1828 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
1829 |
symbolicCodeArray at:sIndex put:symOffset. |
|
1830 |
" |
|
1831 |
'change short into abs jump' printNL. |
|
1832 |
" |
|
1833 |
deleteSet do:[:d | relocList remove:d]. |
|
1834 |
^ false |
|
1835 |
] |
|
1836 |
]. |
|
1837 |
]. |
|
1838 |
codeBytes at:codePos put:delta |
|
1839 |
] ifFalse:[ |
|
1840 |
(delta < -128) ifTrue:[ |
|
1841 |
(opcode between:50 and:59) ifFalse:[ |
|
1842 |
self error:'invalid code to relocate' |
|
1843 |
] ifTrue:[ |
|
1844 |
(delta < -256) ifTrue:[ |
|
1845 |
"change jmp into vljmp ..." |
|
1846 |
codeBytes at:opCodePos put:(opcode + 20). |
|
1847 |
delta := delta + 256 |
|
1848 |
] ifFalse:[ |
|
1849 |
"change jmp into ljmp ..." |
|
1850 |
codeBytes at:opCodePos put:(opcode + 10). |
|
1851 |
delta := delta + 128 |
|
1852 |
]. |
|
1853 |
(delta < -128) ifTrue:[ |
|
1854 |
"change symbolic into a jump absolute and fail" |
|
1855 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
1856 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
1857 |
symbolicCodeArray at:sIndex put:symOffset. |
|
1858 |
" |
|
1859 |
'change short into abs jump' printNL. |
|
1860 |
" |
|
1861 |
deleteSet do:[:d | relocList remove:d]. |
|
1862 |
^ false |
|
1863 |
] |
|
1864 |
] |
|
1865 |
]. |
|
1866 |
codeBytes at:codePos put:(256 + delta) |
|
1867 |
] |
|
1868 |
] |
|
1869 |
]. |
|
1870 |
(errorFlag == #Error) ifTrue:[ |
|
1871 |
self error:'relocation range error' |
|
1872 |
]. |
|
1873 |
^ true |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1874 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1875 |
|
247 | 1876 |
specialGlobalCodeFor:aSymbol |
1877 |
aSymbol == #Array ifTrue:[^ 0]. |
|
1878 |
aSymbol == #String ifTrue:[^ 1]. |
|
1879 |
aSymbol == #FloatArray ifTrue:[^ 2]. |
|
1880 |
aSymbol == #DoubleArray ifTrue:[^ 3]. |
|
1881 |
aSymbol == #Point ifTrue:[^ 4]. |
|
1882 |
aSymbol == #Symbol ifTrue:[^ 5]. |
|
1883 |
aSymbol == #Smalltalk ifTrue:[^ 6]. |
|
1884 |
aSymbol == #Processor ifTrue:[^ 7]. |
|
1885 |
||
1886 |
self error:'invalid special global symbol'. |
|
1887 |
errorFlag := #Error |
|
1888 |
! |
|
1889 |
||
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1890 |
specialSendCodeFor:aSymbol |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1891 |
aSymbol == #top ifTrue:[^ 0]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1892 |
aSymbol == #bottom ifTrue:[^ 1]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1893 |
aSymbol == #left ifTrue:[^ 2]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1894 |
aSymbol == #right ifTrue:[^ 3]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1895 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1896 |
self error:'invalid special send symbol'. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1897 |
errorFlag := #Error |
0 | 1898 |
! ! |
49 | 1899 |
|
1900 |
!ByteCodeCompiler methodsFor:'machine code generation'! |
|
1901 |
||
1902 |
compileToMachineCode:aString forClass:aClass inCategory:cat |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1903 |
notifying:requestor install:install skipIfSame:skipIfSame silent:silent |
49 | 1904 |
"this is called to compile primitive code. |
1905 |
This is EXPERIMENTAL and going to be changed to raise an error, |
|
1906 |
an redefined in subclasses which can do it (either by direct compilation, or by calling |
|
1907 |
the external stc do do it. |
|
1908 |
For a description of the arguments, see compile:forClass....." |
|
1909 |
||
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1910 |
|stFileName stream handle address flags command oFileName |
120 | 1911 |
initName newMethod ok status className sep class stcPath |
214
683adf870f54
oops - couldn't compile for Object (no superclass)
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
1912 |
errorStream errorMessages eMsg m supers| |
96 | 1913 |
|
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
1914 |
ObjectFileLoader isNil ifTrue:[^ #CannotLoad]. |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
1915 |
STCCompilation == #never ifTrue:[^ #CannotLoad]. |
120 | 1916 |
(stcPath := self class incrementalStcPath) isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1917 |
self parseError:'no stc compiler available - cannot create machine code' position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1918 |
^ #CannotLoad |
120 | 1919 |
]. |
54 | 1920 |
|
1921 |
SequenceNumber isNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1922 |
SequenceNumber := 0. |
54 | 1923 |
]. |
1924 |
SequenceNumber := SequenceNumber + 1. |
|
49 | 1925 |
|
54 | 1926 |
initName := 'ttt' , SequenceNumber printString. |
1927 |
stFileName := initName , '.st'. |
|
1928 |
stream := stFileName asFilename writeStream. |
|
187 | 1929 |
stream isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1930 |
self parseError:'cannot create temporary sourcefile for compilation'. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1931 |
^ #CannotLoad |
187 | 1932 |
]. |
97 | 1933 |
sep := stream class chunkSeparator. |
49 | 1934 |
|
101 | 1935 |
class := aClass. |
1936 |
class isMeta ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1937 |
class := aClass soleInstance |
101 | 1938 |
]. |
235
8dde5344f785
oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents:
230
diff
changeset
|
1939 |
supers := class allSuperclasses. |
214
683adf870f54
oops - couldn't compile for Object (no superclass)
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
1940 |
supers notNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1941 |
supers reverseDo:[:cls| |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1942 |
cls ~~ Object ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1943 |
cls isLoaded ifFalse:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1944 |
^ #CannotLoad |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1945 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1946 |
cls fileOutDefinitionOn:stream. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1947 |
stream nextPut:sep; cr. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1948 |
] |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1949 |
] |
54 | 1950 |
]. |
101 | 1951 |
class fileOutDefinitionOn:stream. |
96 | 1952 |
stream nextPut:sep; cr. |
54 | 1953 |
|
101 | 1954 |
class fileOutPrimitiveDefinitionsOn:stream. |
49 | 1955 |
|
96 | 1956 |
stream nextPut:sep. |
235
8dde5344f785
oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents:
230
diff
changeset
|
1957 |
className := class name. |
96 | 1958 |
|
235
8dde5344f785
oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents:
230
diff
changeset
|
1959 |
stream nextPutAll:className. |
49 | 1960 |
aClass isMeta ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1961 |
stream nextPutAll:' class'. |
49 | 1962 |
]. |
96 | 1963 |
stream nextPutAll:' methodsFor:'''; nextPutAll:cat; nextPutAll:''''. |
296
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
1964 |
stream nextPut:sep; cr. |
49 | 1965 |
|
296
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
1966 |
stream nextPutAll:'"{ Line: 0 }"'; cr; |
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
1967 |
nextChunkPut:aString; |
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
1968 |
space; nextPut:sep. |
96 | 1969 |
|
49 | 1970 |
stream close. |
1971 |
||
1972 |
" |
|
1973 |
call stc to compile it |
|
1974 |
" |
|
94 | 1975 |
oFileName := './' , initName , '.o'. |
1976 |
oFileName asFilename delete. |
|
49 | 1977 |
|
150 | 1978 |
flags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName . |
124 | 1979 |
STCCompilationDefines notNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1980 |
flags := STCCompilationDefines , ' ' , flags |
124 | 1981 |
]. |
1982 |
STCCompilationIncludes notNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1983 |
flags := STCCompilationIncludes , ' ' , flags |
124 | 1984 |
]. |
1985 |
STCCompilationOptions notNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1986 |
flags := STCCompilationOptions , ' ' , flags |
54 | 1987 |
]. |
1988 |
||
101 | 1989 |
command := stcPath , ' ' , flags , ' -c ' , stFileName. |
54 | 1990 |
"/ command printNL. |
1991 |
||
215 | 1992 |
self activityNotification:'compiling'. |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
1993 |
ok := OperatingSystem executeCommand:command onError:[:stat| |
296
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
1994 |
status := stat. |
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
1995 |
false |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
1996 |
]. |
101 | 1997 |
|
120 | 1998 |
"for debugging - leave c intermediate" |
1999 |
STCKeepCIntermediate == true ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2000 |
command := stcPath , ' ' , flags , ' -C ' , stFileName. |
280 | 2001 |
'executing: ' infoPrint. command infoPrintCR. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2002 |
OperatingSystem executeCommand:command |
49 | 2003 |
]. |
2004 |
||
94 | 2005 |
oFileName asFilename exists ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2006 |
ok ifFalse:[ |
280 | 2007 |
'oops - system says it failed - but o-file is there ...' infoPrintCR. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2008 |
ok := true |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2009 |
] |
94 | 2010 |
] ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2011 |
ok := false |
94 | 2012 |
]. |
2013 |
||
54 | 2014 |
ok ifFalse:[ |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2015 |
status couldNotExecute ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2016 |
eMsg := 'oops, no STC - cannot create machine code' |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2017 |
] ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2018 |
errorStream := 'errorOutput' asFilename readStream. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2019 |
errorStream notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2020 |
errorMessages := errorStream contents. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2021 |
errorMessages notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2022 |
errorMessages := errorMessages asStringCollection. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2023 |
errorMessages size > 20 ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2024 |
errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2025 |
]. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2026 |
"/ errorMessages := errorMessages collect:[:line | |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2027 |
"/ (line startsWith:(stFileName , ':')) ifTrue:[ |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2028 |
"/ 'Line: ' , (line copyFrom:(stFileName size + 2)) |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2029 |
"/ ] ifFalse:[ |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2030 |
"/ line |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2031 |
"/ ] |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2032 |
"/ ]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2033 |
errorMessages := errorMessages asString |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2034 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2035 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2036 |
errorMessages isNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2037 |
errorMessages := '' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2038 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2039 |
eMsg := ('STC / CC error during compilation:\\',errorMessages) withCRs. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2040 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2041 |
'errorOutput' asFilename remove. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2042 |
self parseError:eMsg position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2043 |
OperatingSystem removeFile:stFileName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2044 |
^ #Error |
120 | 2045 |
]. |
2046 |
||
297 | 2047 |
'errorOutput' asFilename remove. |
2048 |
||
120 | 2049 |
(ObjectFileLoader notNil |
2050 |
and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2051 |
self parseError:'no dynamic load configured - cannot load machine code' position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2052 |
OperatingSystem removeFile:stFileName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2053 |
^ #CannotLoad |
54 | 2054 |
]. |
2055 |
||
215 | 2056 |
" |
2057 |
if required, make a shared or otherwise loadable object file for it |
|
2058 |
" |
|
2059 |
self activityNotification:'linking'. |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2060 |
oFileName := ObjectFileLoader createLoadableObjectFor:initName. |
49 | 2061 |
|
2062 |
" |
|
2063 |
load the objectfile |
|
2064 |
" |
|
215 | 2065 |
self activityNotification:'loading'. |
109 | 2066 |
handle := ObjectFileLoader loadDynamicObject:oFileName. |
49 | 2067 |
handle isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2068 |
OperatingSystem removeFile:stFileName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2069 |
OperatingSystem removeFile:oFileName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2070 |
self parseError:'dynamic load failed - cannot create machine code' position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2071 |
^ #CannotLoad |
49 | 2072 |
]. |
280 | 2073 |
"/ ('handle is ' , handle printString) infoPrintCR. |
49 | 2074 |
|
54 | 2075 |
address := ObjectFileLoader getFunction:'__' , initName , '_Init' from:handle. |
49 | 2076 |
address isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2077 |
address := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2078 |
address isNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2079 |
(ObjectFileLoader getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2080 |
ObjectFileLoader listUndefinedSymbolsIn:handle. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2081 |
eMsg := 'undefined symbols in primitive code'. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2082 |
] ifFalse:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2083 |
eMsg := initName , '_Init() lookup failed' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2084 |
]. |
125 | 2085 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2086 |
ObjectFileLoader unloadDynamicObject:handle. |
125 | 2087 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2088 |
OperatingSystem removeFile:stFileName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2089 |
OperatingSystem removeFile:oFileName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2090 |
self parseError:(eMsg , ' - cannot create machine code') position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2091 |
^ #CannotLoad |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2092 |
] |
49 | 2093 |
]. |
2094 |
||
280 | 2095 |
"/ ('init at ' , address printString) infoPrintCR. |
54 | 2096 |
|
156 | 2097 |
m := ObjectFileLoader |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2098 |
callInitFunctionAt:address |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2099 |
specialInit:true |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2100 |
forceOld:true |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2101 |
interruptable:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2102 |
argument:2 |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2103 |
identifyAs:handle |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2104 |
returnsObject:true. |
49 | 2105 |
|
54 | 2106 |
" |
2107 |
did it work ? |
|
2108 |
" |
|
96 | 2109 |
newMethod := aClass compiledMethodAt:selector. |
54 | 2110 |
newMethod notNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2111 |
m ~~ newMethod ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2112 |
'BCOMPILER: oops - loaded method installed itself elsewhere' errorPrintNL. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2113 |
]. |
156 | 2114 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2115 |
newMethod source:aString. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2116 |
Project notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2117 |
newMethod package:(Project currentPackageName) |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2118 |
]. |
160
5e01f0113d6e
dont forget package-info in compiled methods
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
2119 |
|
162 | 2120 |
"/ aClass updateRevisionString. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2121 |
aClass addChangeRecordForMethod:newMethod. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2122 |
(silent or:[Smalltalk silentLoading == true]) ifFalse:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2123 |
Transcript showCR:(' compiled: ', className,' ',selector,' - machine code') |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2124 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2125 |
ObjectMemory flushCaches. |
120 | 2126 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2127 |
OperatingSystem removeFile:stFileName. |
120 | 2128 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2129 |
handle method:newMethod. |
120 | 2130 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2131 |
"/ check for obsolete loaded objects and unload them |
120 | 2132 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2133 |
ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle | |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2134 |
anotherHandle isMethodHandle ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2135 |
anotherHandle method isNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2136 |
ObjectFileLoader unloadObjectFile:anotherHandle pathName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2137 |
OperatingSystem removeFile:anotherHandle pathName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2138 |
] |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2139 |
] |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2140 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2141 |
^ newMethod. |
54 | 2142 |
]. |
2143 |
||
120 | 2144 |
OperatingSystem removeFile:stFileName. |
2145 |
OperatingSystem removeFile:oFileName. |
|
54 | 2146 |
self parseError:'dynamic load failed' position:1. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2147 |
^ #CannotLoad |
49 | 2148 |
|
2149 |
" |
|
2150 |
|m| |
|
2151 |
||
2152 |
Object subclass:#Test |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2153 |
instanceVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2154 |
classVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2155 |
poolDictionaries:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2156 |
category:'tests'. |
49 | 2157 |
m := ByteCodeCompiler |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2158 |
compile:'foo ^ ''hello''' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2159 |
forClass:Test |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2160 |
inCategory:'tests' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2161 |
notifying:nil |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2162 |
install:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2163 |
skipIfSame:false. |
49 | 2164 |
m inspect |
2165 |
" |
|
2166 |
" |
|
2167 |
|m| |
|
2168 |
||
2169 |
Object subclass:#Test |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2170 |
instanceVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2171 |
classVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2172 |
poolDictionaries:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2173 |
category:'tests'. |
49 | 2174 |
m := ByteCodeCompiler |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2175 |
compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2176 |
forClass:Test |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2177 |
inCategory:'tests' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2178 |
notifying:nil |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2179 |
install:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2180 |
skipIfSame:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2181 |
silent:false. |
49 | 2182 |
m inspect |
2183 |
" |
|
120 | 2184 |
|
2185 |
"Modified: 14.9.1995 / 22:33:04 / claus" |
|
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2186 |
"Modified: 28.12.1995 / 15:52:48 / stefan" |
297 | 2187 |
"Modified: 12.7.1996 / 10:02:25 / cg" |
97 | 2188 |
! |
2189 |
||
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2190 |
createLoadableObjectFor:baseFileName |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2191 |
|osType oFileName soFileName| |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2192 |
|
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2193 |
osType := OperatingSystem getOSType. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2194 |
osType = 'irix' ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2195 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2196 |
link it to a shared object |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2197 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2198 |
oFileName := './' , baseFileName , '.o'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2199 |
soFileName := './' , baseFileName , '.so'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2200 |
OperatingSystem removeFile:soFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2201 |
OperatingSystem executeCommand:'ld -shared -all -o ' , soFileName , ' ' , oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2202 |
OperatingSystem removeFile:oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2203 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2204 |
]. |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2205 |
osType = 'sys5_4' ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2206 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2207 |
link it to a shared object |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2208 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2209 |
oFileName := './' , baseFileName , '.o'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2210 |
soFileName := './' , baseFileName , '.so'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2211 |
OperatingSystem removeFile:soFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2212 |
OperatingSystem executeCommand:'ld -G -o ' , soFileName , ' ' , oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2213 |
OperatingSystem removeFile:oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2214 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2215 |
]. |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2216 |
osType = 'linux' ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2217 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2218 |
link it to a shared object |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2219 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2220 |
oFileName := './' , baseFileName , '.o'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2221 |
soFileName := './' , baseFileName , '.so'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2222 |
OperatingSystem removeFile:soFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2223 |
OperatingSystem executeCommand:'ld -shared -o ' , soFileName , ' ' , oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2224 |
OperatingSystem removeFile:oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2225 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2226 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2227 |
^ oFileName |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2228 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2229 |
"Created: 3.1.1996 / 16:04:45 / cg" |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2230 |
"Modified: 14.6.1996 / 11:16:46 / stefan" |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2231 |
! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2232 |
|
97 | 2233 |
trappingStubMethodFor:aString inCategory:cat |
2234 |
"return a stub method which traps and reports an error whenever |
|
2235 |
called." |
|
2236 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2237 |
|newMethod| |
97 | 2238 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2239 |
newMethod := Method new:(litArray size). |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2240 |
litArray notNil ifTrue:[ |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2241 |
newMethod literals:litArray |
97 | 2242 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2243 |
|
124 | 2244 |
newMethod makeUncompiled. |
97 | 2245 |
newMethod numberOfMethodVars:(self numberOfMethodVars). |
2246 |
newMethod numberOfMethodArgs:(self numberOfMethodArgs). |
|
2247 |
newMethod source:aString. |
|
2248 |
newMethod category:cat. |
|
2249 |
Project notNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2250 |
newMethod package:(Project currentPackageName) |
97 | 2251 |
]. |
2252 |
^ newMethod |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2253 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2254 |
"Modified: 18.5.1996 / 16:39:12 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2255 |
"Modified: 24.6.1996 / 12:28:24 / stefan" |
49 | 2256 |
! ! |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2257 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2258 |
!ByteCodeCompiler class methodsFor:'documentation'! |
148 | 2259 |
|
2260 |
version |
|
297 | 2261 |
^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.84 1996-07-12 08:43:55 cg Exp $' |
148 | 2262 |
! ! |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2263 |
ByteCodeCompiler initialize! |