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