author | Claus Gittinger <cg@exept.de> |
Thu, 13 Aug 1998 13:51:05 +0200 | |
changeset 758 | b15651486dce |
parent 751 | 4f112db52253 |
child 768 | 07fcee0355e3 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
45 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Parser subclass:#ByteCodeCompiler |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
14 |
instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral |
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
15 |
maxStackDepth relocList methodTempVars numTemp maxNumTemp' |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
16 |
classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
17 |
STCCompilationIncludes STCCompilationOptions STCCompilation |
407 | 18 |
ShareCode STCKeepSTIntermediate STCKeepCIntermediate |
704 | 19 |
STCModulePath CCCompilationOptions CC STC ListCompiledMethods |
751 | 20 |
STCKeepOIntermediate Verbose' |
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 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
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 |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
50 |
only - it may vanish in future releases) |
19 | 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 |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
57 |
codeBytes <ByteArry> bytecodes |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
58 |
codeIndex <SmallInteger> next index to put into code array |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
59 |
litArray <OrderedCollection> literals |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
60 |
stackDelta <SmallInteger> return value of byteCodeFor: |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
61 |
extra <Symbol> return value of byteCodeFor: |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
62 |
lineno <Boolean> return value of byteCodeFor: |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
63 |
extraLiteral <Symbol> return value of byteCodeFor: |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
64 |
maxStackDepth <SmallInteger> stack need of method |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
65 |
relocList <Array> used temporary for relocation |
19 | 66 |
|
259 | 67 |
[Class variables:] |
19 | 68 |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
69 |
JumpToAbsJump <Dictionary> internal table to map opcodes |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
70 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
71 |
SequenceNumber <Integer> counting intermediate stc-compiled |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
72 |
objects (for unique o-file naming) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
73 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
74 |
STCCompilationDefines passed to stc as command line arguments |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
75 |
STCCompilationIncludes |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
76 |
STCCompilationOptions |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
77 |
<String> |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
78 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
79 |
STCCompilation <Symbol> #always, #primitiveOnly or #never |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
80 |
controls when stc compilation is wanted |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
81 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
82 |
ShareCode <Boolean> reuse byteArrays for common (simple) code sequences |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
83 |
This is normally a 'good' optimization, |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
84 |
expect if you plan to modify the byteCodes. |
263 | 85 |
|
86 |
[author:] |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
87 |
Claus Gittinger |
263 | 88 |
|
3 | 89 |
" |
98 | 90 |
! ! |
91 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
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. |
295 | 96 |
STCKeepCIntermediate := false. |
704 | 97 |
STCKeepOIntermediate := false. |
407 | 98 |
STCKeepSTIntermediate := false. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
99 |
STCModulePath := './modules'. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
600
diff
changeset
|
100 |
ListCompiledMethods := false. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
600
diff
changeset
|
101 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
600
diff
changeset
|
102 |
"Modified: 31.8.1997 / 08:47:49 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
103 |
! ! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
104 |
|
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
105 |
!ByteCodeCompiler class methodsFor:'compiling methods'! |
98 | 106 |
|
0 | 107 |
compile:methodText forClass:classToCompileFor |
108 |
"compile a source-string for a method in classToCompileFor" |
|
109 |
||
110 |
^ self compile:methodText |
|
45 | 111 |
forClass:classToCompileFor |
112 |
inCategory:'others' |
|
113 |
notifying:nil |
|
114 |
install:true |
|
115 |
skipIfSame:false |
|
116 |
silent:false |
|
0 | 117 |
! |
118 |
||
119 |
compile:aString forClass:aClass inCategory:cat |
|
120 |
"compile a source-string for a method in classToCompileFor. |
|
121 |
The method will get cat as category" |
|
122 |
||
123 |
^ self compile:aString |
|
45 | 124 |
forClass:aClass |
125 |
inCategory:cat |
|
126 |
notifying:nil |
|
127 |
install:true |
|
128 |
skipIfSame:false |
|
129 |
silent:false |
|
0 | 130 |
! |
131 |
||
84 | 132 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
0 | 133 |
"compile a source-string for a method in classToCompileFor. |
84 | 134 |
errors are forwarded to requestor. |
0 | 135 |
The method will get cat as category" |
136 |
||
137 |
^ self compile:aString |
|
45 | 138 |
forClass:aClass |
139 |
inCategory:cat |
|
84 | 140 |
notifying:requestor |
45 | 141 |
install:true |
142 |
skipIfSame:false |
|
143 |
silent:false |
|
0 | 144 |
! |
145 |
||
141 | 146 |
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install |
147 |
"compile a source-string for a method in classToCompileFor. |
|
148 |
The install-argument controls if the method is to be installed into the |
|
149 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
150 |
Errors are forwarded to requestor. The method will get cat as category" |
|
151 |
||
152 |
^ self compile:aString |
|
153 |
forClass:aClass |
|
154 |
inCategory:cat |
|
155 |
notifying:requestor |
|
156 |
install:install |
|
157 |
skipIfSame:false |
|
158 |
silent:false |
|
159 |
! |
|
160 |
||
161 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
|
162 |
install:install skipIfSame:skipIfSame |
|
163 |
"compile a source-string for a method in classToCompileFor. |
|
164 |
The install-argument controls if the method is to be installed into the |
|
165 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
166 |
Errors are forwarded to requestor. The method will get cat as category. |
|
167 |
If skipIsSame is true, and the source is the same as an existing |
|
168 |
methods source, this is a noop (for fast fileIn)." |
|
169 |
||
170 |
^ self compile:aString |
|
171 |
forClass:aClass |
|
172 |
inCategory:cat |
|
173 |
notifying:requestor |
|
174 |
install:install |
|
175 |
skipIfSame:skipIfSame |
|
176 |
silent:false |
|
177 |
! |
|
178 |
||
84 | 179 |
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
|
180 |
install:install skipIfSame:skipIfSame silent:silent |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
181 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
182 |
^ self |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
183 |
compile:aString |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
184 |
forClass:aClass |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
185 |
inCategory:cat |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
186 |
notifying:requestor |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
187 |
install:install |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
188 |
skipIfSame:skipIfSame |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
189 |
silent:silent |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
190 |
foldConstants:true |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
191 |
! |
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
192 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
193 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
194 |
install:install skipIfSame:skipIfSame silent:silent foldConstants:fold |
20 | 195 |
|
196 |
"the basic workhorse method for compiling: |
|
0 | 197 |
compile a source-string for a method in classToCompileFor. |
84 | 198 |
errors are forwarded to requestor (report on Transcript and return |
199 |
#Error, if requestor is nil). |
|
0 | 200 |
|
20 | 201 |
The new method will get cat as category. |
202 |
If install is true, the method will go into the classes method-table, |
|
203 |
otherwise the method is simply returned (for anonymous methods). |
|
0 | 204 |
If skipIsSame is true, and the source is the same as an existing |
20 | 205 |
methods source, this is a noop (for fast fileIn). |
206 |
The argument, silent controls if errors are to be reported." |
|
0 | 207 |
|
429 | 208 |
|compiler newMethod tree symbolicCodeArray oldMethod lazy silencio |
459
3a0a95c1a0e8
unchanged methods may have a new package id
Claus Gittinger <cg@exept.de>
parents:
439
diff
changeset
|
209 |
sourceFile sourceStream newSource primNr pos sel keptOldCode msg answer |
3a0a95c1a0e8
unchanged methods may have a new package id
Claus Gittinger <cg@exept.de>
parents:
439
diff
changeset
|
210 |
pkg| |
0 | 211 |
|
212 |
aString isNil ifTrue:[^ nil]. |
|
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
600
diff
changeset
|
213 |
silencio := silent |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
214 |
or:[Smalltalk silentLoading == true |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
215 |
or:[ListCompiledMethods == false]]. |
0 | 216 |
|
19 | 217 |
"lazy compilation is EXPERIMENTAL" |
218 |
lazy := (LazyCompilation == true) and:[install]. |
|
219 |
||
0 | 220 |
"create a compiler, let it parse and create the parsetree" |
221 |
||
54 | 222 |
compiler := self for:(ReadStream on:aString) in:aClass. |
84 | 223 |
compiler parseForCode. |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
224 |
fold ifFalse:[compiler foldConstants:nil]. |
84 | 225 |
compiler notifying:requestor. |
54 | 226 |
silent ifTrue:[ |
227 |
"/ compiler ignoreErrors. |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
228 |
compiler ignoreWarnings. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
229 |
compiler warnUndeclared:false. |
54 | 230 |
]. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
231 |
"/ compiler nextToken. |
350
13e1dcaf87eb
oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
232 |
|
0 | 233 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
234 |
compiler parseError:'syntax error in method specification'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
235 |
tree := #Error |
0 | 236 |
] ifFalse:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
237 |
lazy ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
238 |
"/ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
239 |
"/ that one method IS required |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
240 |
"/ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
241 |
(aClass isMeta and:[compiler selector == #version]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
242 |
lazy := false |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
243 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
244 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
245 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
246 |
lazy ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
247 |
"check if same source" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
248 |
(skipIfSame and:[(sel := compiler selector) notNil]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
249 |
oldMethod := aClass compiledMethodAt:sel. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
250 |
oldMethod notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
251 |
oldMethod source = aString ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
252 |
oldMethod isInvalid ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
253 |
silencio ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
254 |
Transcript showCR:(' unchanged: ',aClass name,' ',compiler selector) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
255 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
256 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
257 |
same. however, category may be different |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
258 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
259 |
(cat notNil and:[cat ~= oldMethod category]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
260 |
oldMethod category:cat. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
261 |
oldMethod changed:#category. |
459
3a0a95c1a0e8
unchanged methods may have a new package id
Claus Gittinger <cg@exept.de>
parents:
439
diff
changeset
|
262 |
"/ aClass updateRevisionString. |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
263 |
aClass addChangeRecordForMethodCategory:oldMethod category:cat. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
264 |
silencio ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
265 |
Transcript showCR:(' (category change only)') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
266 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
267 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
268 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
269 |
and package may be too. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
270 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
271 |
pkg := Class packageQuerySignal raise. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
272 |
(pkg notNil and:[pkg ~~ oldMethod package]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
273 |
oldMethod package:pkg. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
274 |
silencio ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
275 |
Transcript showCR:(' (package-id change only)') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
276 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
277 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
278 |
^ oldMethod |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
279 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
280 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
281 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
282 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
283 |
tree := compiler parseMethodBody. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
284 |
compiler tree:tree. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
285 |
] |
0 | 286 |
]. |
287 |
||
288 |
(compiler errorFlag or:[tree == #Error]) ifTrue:[ |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
289 |
compiler showErrorMessageForClass:aClass. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
290 |
^ #Error |
0 | 291 |
]. |
292 |
||
191 | 293 |
sel := compiler selector. |
19 | 294 |
"if no error and also no selector ..." |
90 | 295 |
sel isNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
296 |
"... it was just a comment or other empty stuff" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
297 |
^ nil |
0 | 298 |
]. |
299 |
||
191 | 300 |
lazy ifFalse:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
301 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
302 |
freak-out support ... |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
303 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
304 |
((compiler hasNonOptionalPrimitiveCode |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
305 |
or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode]) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
306 |
or:[STCCompilation == #always and:[sel ~~ #doIt]]]) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
307 |
and:[STCCompilation ~~ #never]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
308 |
newMethod := compiler |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
309 |
compileToMachineCode:aString |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
310 |
forClass:aClass |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
311 |
inCategory:cat |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
312 |
notifying:requestor |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
313 |
install:install |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
314 |
skipIfSame:skipIfSame |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
315 |
silent:silent. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
316 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
317 |
newMethod == #Error ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
318 |
compiler showErrorMessageForClass:aClass. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
319 |
^ #Error |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
320 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
321 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
322 |
(newMethod == #CannotLoad) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
323 |
newMethod := compiler trappingStubMethodFor:aString inCategory:cat. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
324 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
325 |
keptOldCode := false. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
326 |
install ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
327 |
"/ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
328 |
"/ be very careful with existing methods |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
329 |
"/ (otherwise, you could easily make your system unusable in systems which cannot load) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
330 |
"/ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
331 |
sel notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
332 |
oldMethod := aClass compiledMethodAt:sel |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
333 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
334 |
(oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
335 |
answer := Dialog |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
336 |
confirm: |
649
06675201ca18
name the class/selector in the compilation-failed-dialog.
Claus Gittinger <cg@exept.de>
parents:
632
diff
changeset
|
337 |
'installation of binary code for ''' , aClass name , '>>' , compiler selector , ''' |
06675201ca18
name the class/selector in the compilation-failed-dialog.
Claus Gittinger <cg@exept.de>
parents:
632
diff
changeset
|
338 |
is not possible or disabled. |
97 | 339 |
|
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
|
340 |
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
|
341 |
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
|
342 |
|
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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
|
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
|
347 |
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
|
348 |
' |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
349 |
yesLabel:'trap code' |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
350 |
noLabel:'keep old'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
351 |
answer isNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
352 |
^ #Error |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
353 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
354 |
answer == false ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
355 |
newMethod code:(oldMethod code). |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
356 |
keptOldCode := true. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
357 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
358 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
359 |
aClass addSelector:sel withMethod:newMethod |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
360 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
361 |
Transcript show:'*** '. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
362 |
sel notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
363 |
Transcript show:(sel ,' ') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
364 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
365 |
keptOldCode ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
366 |
msg := 'not really compiled - method still shows previous behavior'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
367 |
] ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
368 |
msg := 'not compiled to machine code - created a stub instead.'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
369 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
370 |
Transcript showCR:msg. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
371 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
372 |
^ newMethod |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
373 |
]. |
19 | 374 |
]. |
375 |
||
726
9f9ca909fc5e
fixed stc-compilation==#never case.
Claus Gittinger <cg@exept.de>
parents:
723
diff
changeset
|
376 |
compiler hasNonOptionalPrimitiveCode ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
377 |
newMethod := compiler trappingStubMethodFor:aString inCategory:cat. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
378 |
aClass addSelector:sel withMethod:newMethod. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
379 |
Transcript show:'*** '. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
380 |
sel notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
381 |
Transcript show:(sel ,' ') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
382 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
383 |
Transcript showCR:'not compiled to machine code - created a stub instead.'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
384 |
^ newMethod |
726
9f9ca909fc5e
fixed stc-compilation==#never case.
Claus Gittinger <cg@exept.de>
parents:
723
diff
changeset
|
385 |
]. |
9f9ca909fc5e
fixed stc-compilation==#never case.
Claus Gittinger <cg@exept.de>
parents:
723
diff
changeset
|
386 |
|
54 | 387 |
" |
388 |
EXPERIMENTAL: quick loading |
|
389 |
only create a lazyMethod, which has no byteCode and will |
|
390 |
compile itself when first called. |
|
391 |
" |
|
19 | 392 |
lazy ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
393 |
newMethod := LazyMethod new. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
394 |
(ClassCategoryReader sourceMode == #sourceReference) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
395 |
sourceFile := ObjectMemory nameForSources. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
396 |
sourceFile notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
397 |
sourceStream := sourceFile asFilename appendingWriteStream. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
398 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
399 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
400 |
sourceStream isNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
401 |
newMethod source:aString string. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
402 |
] ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
403 |
sourceStream setToEnd. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
404 |
pos := sourceStream position. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
405 |
sourceStream nextChunkPut:aString. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
406 |
sourceStream close. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
407 |
newMethod sourceFilename:sourceFile position:pos. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
408 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
409 |
newMethod category:cat. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
410 |
newMethod package:(Class packageQuerySignal raise). |
415 | 411 |
"/ Project notNil ifTrue:[ |
412 |
"/ newMethod package:(Project currentPackageName) |
|
413 |
"/ ]. |
|
19 | 414 |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
415 |
aClass addSelector:sel withLazyMethod:newMethod. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
416 |
^ newMethod |
19 | 417 |
]. |
418 |
||
90 | 419 |
(primNr := compiler primitiveNumber) isNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
420 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
421 |
produce symbolic code first |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
422 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
423 |
symbolicCodeArray := compiler genSymbolicCode. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
424 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
425 |
(symbolicCodeArray == #Error) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
426 |
Transcript show:' '. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
427 |
sel notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
428 |
Transcript show:(sel ,' ') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
429 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
430 |
Transcript showCR:'translation error'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
431 |
^ #Error |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
432 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
433 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
434 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
435 |
take this, producing bytecode |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
436 |
(someone willin' to make machine code :-) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
437 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
438 |
((compiler genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
439 |
Transcript show:' '. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
440 |
sel notNil ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
441 |
Transcript show:(sel ,' ') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
442 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
443 |
Transcript showCR:'relocation error - must be simplified'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
444 |
^ #Error |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
445 |
]. |
0 | 446 |
]. |
447 |
||
54 | 448 |
" |
449 |
finally create the new method-object |
|
450 |
" |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
451 |
newMethod := compiler createMethod. |
90 | 452 |
primNr notNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
453 |
newMethod code:(compiler checkForPrimitiveCode:primNr). |
78 | 454 |
] ifFalse:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
455 |
newMethod byteCode:(compiler code). |
78 | 456 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
457 |
"/ 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
|
458 |
"/ 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
|
459 |
"/ newMethod stackSize:(compiler maxStackDepth). |
19 | 460 |
|
54 | 461 |
" |
462 |
if there where any corrections, install the updated source |
|
463 |
" |
|
90 | 464 |
(newSource := compiler correctedSource) notNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
465 |
newMethod source:newSource string |
19 | 466 |
] ifFalse:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
467 |
newMethod source:aString string. |
19 | 468 |
]. |
0 | 469 |
newMethod category:cat. |
415 | 470 |
newMethod package:(Class packageQuerySignal raise). |
471 |
"/ Project notNil ifTrue:[ |
|
472 |
"/ newMethod package:(Project currentPackageName) |
|
473 |
"/ ]. |
|
0 | 474 |
|
475 |
install ifTrue:[ |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
476 |
aClass addSelector:sel withMethod:newMethod |
0 | 477 |
]. |
478 |
||
54 | 479 |
silencio ifFalse:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
480 |
Transcript showCR:(' compiled: ', aClass name,' ', sel) |
0 | 481 |
]. |
482 |
||
483 |
^ newMethod |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
484 |
|
649
06675201ca18
name the class/selector in the compilation-failed-dialog.
Claus Gittinger <cg@exept.de>
parents:
632
diff
changeset
|
485 |
"Created: / 29.10.1995 / 19:59:36 / cg" |
06675201ca18
name the class/selector in the compilation-failed-dialog.
Claus Gittinger <cg@exept.de>
parents:
632
diff
changeset
|
486 |
"Modified: / 24.6.1996 / 12:41:13 / stefan" |
726
9f9ca909fc5e
fixed stc-compilation==#never case.
Claus Gittinger <cg@exept.de>
parents:
723
diff
changeset
|
487 |
"Modified: / 13.6.1998 / 13:51:31 / cg" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
488 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
489 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
490 |
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
|
491 |
"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
|
492 |
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
|
493 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
494 |
^ self compile:methodText |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
495 |
forClass:classToCompileFor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
496 |
inCategory:'others' |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
497 |
notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
498 |
install:true |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
499 |
skipIfSame:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
500 |
silent:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
501 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
502 |
|
141 | 503 |
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock |
504 |
"name alias for ST-80 compatibility" |
|
505 |
||
506 |
|m| |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
507 |
|
141 | 508 |
m := self |
509 |
compile:textOrStream |
|
510 |
forClass:aClass |
|
511 |
inCategory:'others' |
|
512 |
notifying:requestor |
|
513 |
install:true |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
514 |
skipIfSame:false |
141 | 515 |
silent:false. |
516 |
m == #Error ifTrue:[ |
|
517 |
^ exceptionBlock value |
|
518 |
]. |
|
519 |
^ m |
|
520 |
||
0 | 521 |
! ! |
522 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
523 |
!ByteCodeCompiler class methodsFor:'constants'! |
15 | 524 |
|
525 |
byteCodeFor:aSymbol |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
526 |
"returns the numeric code for some symbolic bytecodes." |
15 | 527 |
|
25 | 528 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
529 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
530 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
531 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
532 |
(aSymbol == #retTop) ifTrue:[^ 0]. |
|
533 |
||
15 | 534 |
(aSymbol == #push0) ifTrue:[^120]. |
535 |
(aSymbol == #push1) ifTrue:[^121]. |
|
536 |
(aSymbol == #push2) ifTrue:[^139]. |
|
537 |
(aSymbol == #pushMinus1) ifTrue:[^122]. |
|
538 |
(aSymbol == #pushNil) ifTrue:[^ 10]. |
|
539 |
(aSymbol == #pushTrue) ifTrue:[^ 11]. |
|
540 |
(aSymbol == #pushFalse) ifTrue:[^ 12]. |
|
541 |
(aSymbol == #pushSelf) ifTrue:[^ 15]. |
|
542 |
self error |
|
543 |
! ! |
|
544 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
545 |
!ByteCodeCompiler class methodsFor:'stc compilation defaults'! |
54 | 546 |
|
141 | 547 |
canCreateMachineCode |
548 |
"return true, if compilation to machine code is supported. |
|
549 |
Currently, all SYSV4 and Linux systems do so; |
|
550 |
REAL/IX, AIX and HPUX do not (due to the need for dynamic loading |
|
551 |
of object files, which is not supported by those). |
|
552 |
MIPS ULTRIX is almost finished, but not yet released. |
|
124 | 553 |
|
141 | 554 |
However, if no compiler is around (i.e. the demo distribution), |
555 |
there is no chance ..." |
|
556 |
||
557 |
ObjectFileLoader isNil ifTrue:[^ false]. |
|
558 |
ObjectFileLoader canLoadObjectFiles ifFalse:[^ false]. |
|
559 |
||
560 |
"/ no chance, if no stc is available |
|
561 |
^ self incrementalStcPath notNil |
|
124 | 562 |
|
563 |
" |
|
141 | 564 |
Compiler canCreateMachineCode |
565 |
" |
|
566 |
||
567 |
"Modified: 13.9.1995 / 15:15:11 / claus" |
|
568 |
! |
|
569 |
||
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
570 |
ccCompilationOptions |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
571 |
"return the options used with cc compilation" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
572 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
573 |
CCCompilationOptions isNil ifTrue:[^ '']. |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
574 |
^ CCCompilationOptions |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
575 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
576 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
577 |
Compiler ccCompilationOptions |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
578 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
579 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
580 |
"Modified: 5.11.1996 / 17:38:56 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
581 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
582 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
583 |
ccCompilationOptions:aString |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
584 |
"define the compilation options |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
585 |
to be used when compiling to machine code. |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
586 |
These are passed to cc. Can be set from your private.rc file." |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
587 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
588 |
CCCompilationOptions := aString |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
589 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
590 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
591 |
Compiler ccCompilationOptions:'-O' |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
592 |
Compiler ccCompilationOptions:'-O -fPIC' |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
593 |
Compiler ccCompilationOptions |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
594 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
595 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
596 |
"Created: 5.11.1996 / 17:37:05 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
597 |
"Modified: 5.11.1996 / 17:38:32 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
598 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
599 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
600 |
ccPath |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
601 |
"return the path to the stc command for incremental method compilation, |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
602 |
or nil if not found." |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
603 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
604 |
CC isNil ifTrue:[ |
512 | 605 |
^ 'cc' |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
606 |
]. |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
607 |
^ CC |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
608 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
609 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
610 |
Compiler ccPath |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
611 |
Compiler ccPath:'gcc' |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
612 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
613 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
614 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
615 |
"Created: 5.11.1996 / 17:35:40 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
616 |
"Modified: 5.11.1996 / 17:37:42 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
617 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
618 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
619 |
ccPath:aPathOrCommandName |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
620 |
"set the path to the cc command for incremental method compilation" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
621 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
622 |
CC := aPathOrCommandName |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
623 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
624 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
625 |
Compiler ccPath |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
626 |
Compiler ccPath:'gcc' |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
627 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
628 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
629 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
630 |
"Created: 5.11.1996 / 17:38:11 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
631 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
632 |
|
141 | 633 |
incrementalStcPath |
634 |
"return the path to the stc command for incremental method compilation, |
|
635 |
or nil if not found." |
|
636 |
||
637 |
|f| |
|
638 |
||
695 | 639 |
STC notNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
640 |
^ STC |
695 | 641 |
]. |
141 | 642 |
(f := self stcPathOf:'stc') notNil ifTrue:[^ f]. |
643 |
^ self stcPathOf:'demostc' |
|
644 |
||
645 |
" |
|
695 | 646 |
Compiler stcPath:'../../stc/stc' |
141 | 647 |
Compiler incrementalStcPath |
648 |
" |
|
649 |
||
650 |
"Created: 13.9.1995 / 14:36:36 / claus" |
|
651 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
|
652 |
! |
|
653 |
||
654 |
stcCompilation |
|
655 |
"return the flag which controls compilation to machine code. |
|
656 |
If #always, methods are always compiled to machine code (which takes |
|
657 |
longer, but provides faster code). If #none, methods are never compiled |
|
658 |
to machine code, instead for non-primitive ones, compilation is to bytecode |
|
659 |
and for primitive ones, a trapping stub is generated. |
|
660 |
Anything else lets the compiler compile to bytecode, |
|
661 |
except for methods containing primitive code. |
|
662 |
This can be set from your private.rc file or from a workspace |
|
663 |
for selective compilation to machine code." |
|
124 | 664 |
|
141 | 665 |
^ STCCompilation |
54 | 666 |
|
667 |
" |
|
141 | 668 |
Compiler stcCompilation |
124 | 669 |
" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
670 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
671 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
672 |
stcCompilation:how |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
673 |
"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
|
674 |
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
|
675 |
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
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
683 |
|ret| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
684 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
685 |
ret := STCCompilation. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
686 |
STCCompilation := how. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
687 |
^ ret |
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 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
690 |
Compiler stcCompilation:#always |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
691 |
Compiler stcCompilation:#never |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
692 |
Compiler stcCompilation:#default |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
693 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
694 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
695 |
|
141 | 696 |
stcCompilationDefines |
697 |
"return the defines used with stc compilation" |
|
698 |
||
699 |
^ STCCompilationDefines |
|
700 |
! |
|
701 |
||
702 |
stcCompilationDefines:aString |
|
703 |
"define the flags (for example, additional -D defines) |
|
704 |
to be used when compiling to machine code. |
|
705 |
These are passed to stc. Can be set from your private.rc file." |
|
706 |
||
707 |
STCCompilationDefines := aString |
|
708 |
||
709 |
" |
|
710 |
Compiler stcCompilationDefines:'-DVGL -DDEBUG' |
|
711 |
" |
|
712 |
! |
|
713 |
||
714 |
stcCompilationIncludes |
|
715 |
"return the includes used with stc compilation" |
|
716 |
||
717 |
^ STCCompilationIncludes |
|
718 |
! |
|
719 |
||
720 |
stcCompilationIncludes:aString |
|
721 |
"define the include directories via additional -I flags. |
|
722 |
These are passed to stc. Can be set in your private.rc file" |
|
723 |
||
586
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
724 |
|libDir incDir| |
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
725 |
|
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
726 |
STCCompilationIncludes := aString. |
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
727 |
|
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
728 |
"/ if STX_LIBDIR is defined, and not in passed argument, |
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
729 |
"/ add it here. |
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
730 |
|
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
731 |
libDir := OperatingSystem getEnvironment:'STX_LIBDIR'. |
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
732 |
(libDir notNil and:[libDir asFilename exists]) ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
733 |
incDir := libDir asFilename construct:'include'. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
734 |
incDir exists ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
735 |
(STCCompilationIncludes asCollectionOfWords includes:('-I' , incDir pathName)) ifFalse:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
736 |
STCCompilationIncludes := aString , ' ' , ('-I' , incDir pathName). |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
737 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
738 |
] |
586
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
739 |
] |
141 | 740 |
|
741 |
" |
|
742 |
Compiler stcCompilationIncludes:'-I/usr/local/include -I../../include' |
|
743 |
Compiler stcCompilationIncludes:(Compiler stcCompilationIncludes , ' -I../../libxt') |
|
744 |
" |
|
586
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
745 |
|
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
746 |
"Modified: 18.7.1997 / 18:04:25 / cg" |
141 | 747 |
! |
748 |
||
124 | 749 |
stcCompilationOptions |
750 |
"return the options used with stc compilation" |
|
751 |
||
752 |
^ STCCompilationOptions |
|
753 |
! |
|
754 |
||
141 | 755 |
stcCompilationOptions:aString |
756 |
"define the compilation options |
|
757 |
to be used when compiling to machine code. |
|
758 |
These are passed to stc. Can be set from your private.rc file." |
|
101 | 759 |
|
141 | 760 |
STCCompilationOptions := aString |
101 | 761 |
|
762 |
" |
|
141 | 763 |
Compiler stcCompilationOptions:'+optinline' |
101 | 764 |
" |
765 |
! |
|
766 |
||
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
767 |
stcModulePath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
768 |
"return the path, where temporary modules are created" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
769 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
770 |
^ STCModulePath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
771 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
772 |
"Created: 12.7.1996 / 12:15:26 / cg" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
773 |
! |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
774 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
775 |
stcModulePath:aPath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
776 |
"set the path to the directory, where temporary modules are created" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
777 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
778 |
STCModulePath := aPath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
779 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
780 |
"Created: 12.7.1996 / 12:15:49 / cg" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
781 |
! |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
782 |
|
141 | 783 |
stcPath |
784 |
"return the path to the stc command, or nil if not found." |
|
785 |
||
695 | 786 |
^ STC ? (self stcPathOf:'stc') |
141 | 787 |
|
788 |
" |
|
789 |
Compiler stcPath |
|
790 |
" |
|
791 |
||
792 |
"Modified: 13.9.1995 / 14:37:26 / claus" |
|
793 |
! |
|
794 |
||
695 | 795 |
stcPath:aPath |
796 |
"set the path to the stc command - useful if private stc is wanted" |
|
797 |
||
798 |
STC := aPath |
|
799 |
||
800 |
" |
|
801 |
Compiler stcPath:'../../stc/stc' |
|
802 |
" |
|
803 |
||
804 |
"Modified: 13.9.1995 / 14:37:26 / claus" |
|
805 |
! |
|
806 |
||
120 | 807 |
stcPathOf:command |
808 |
"return the path to an stc command, or nil if not found." |
|
101 | 809 |
|
623 | 810 |
|f d reqdSuffix cmd| |
811 |
||
812 |
"/ |
|
813 |
"/ care for executable suffix |
|
814 |
"/ |
|
815 |
cmd := command. |
|
816 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
817 |
reqdSuffix := 'exe' |
|
818 |
] ifFalse:[ |
|
819 |
OperatingSystem isVMSlike ifTrue:[ |
|
820 |
reqdSuffix := 'EXE' |
|
821 |
]. |
|
822 |
]. |
|
823 |
reqdSuffix notNil ifTrue:[ |
|
658 | 824 |
(f := cmd asFilename) suffix isEmpty ifTrue:[ |
825 |
cmd := (f withSuffix:reqdSuffix) name |
|
623 | 826 |
] |
827 |
]. |
|
828 |
"/ |
|
829 |
"/ for our convenience, also check in current |
|
830 |
"/ and parent directories; even if PATH does not |
|
831 |
"/ include them ... |
|
832 |
"/ |
|
658 | 833 |
"/ look in current ... |
623 | 834 |
d := Filename currentDirectory. |
835 |
(f := d construct:cmd) isExecutable ifTrue:[ |
|
101 | 836 |
^ f pathName |
837 |
]. |
|
658 | 838 |
"/ look in ../stc ... |
623 | 839 |
d := d construct:'..'. |
840 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
841 |
^ f pathName |
|
842 |
]. |
|
658 | 843 |
"/ look in ../../stc ... |
623 | 844 |
d := d construct:'..'. |
845 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
846 |
^ f pathName |
|
847 |
]. |
|
848 |
||
849 |
"/ |
|
850 |
"/ ok, stc must be installed in some directory along the PATH |
|
851 |
"/ |
|
126 | 852 |
^ OperatingSystem pathOfCommand:command |
97 | 853 |
|
854 |
" |
|
120 | 855 |
Compiler stcPathOf:'stc' |
856 |
" |
|
857 |
||
858 |
"Created: 13.9.1995 / 14:37:16 / claus" |
|
54 | 859 |
! ! |
860 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
861 |
!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
|
862 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
863 |
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
|
864 |
"name alias for ST-80 compatibility" |
0 | 865 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
866 |
^ self class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
867 |
compile:textOrStream |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
868 |
in:aClass |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
869 |
notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
870 |
ifFail:exceptionBlock |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
871 |
"/ |m| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
872 |
"/ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
873 |
"/ m := self class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
874 |
"/ compile:textOrStream |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
875 |
"/ forClass:aClass |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
876 |
"/ inCategory:'no category' |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
877 |
"/ notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
878 |
"/ install:true |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
879 |
"/ skipIfSame:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
880 |
"/ silent:false. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
881 |
"/ m == #Error ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
882 |
"/ ^ exceptionBlock value |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
883 |
"/ ]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
884 |
"/ ^ m |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
885 |
! ! |
0 | 886 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
887 |
!ByteCodeCompiler methodsFor:'accessing'! |
0 | 888 |
|
889 |
code |
|
3 | 890 |
"return the bytecode array - only valid after code-generation" |
0 | 891 |
|
49 | 892 |
^ codeBytes |
0 | 893 |
! |
894 |
||
141 | 895 |
literalArray |
896 |
"return the literal array - only valid after parsing" |
|
897 |
||
898 |
^ litArray |
|
899 |
! |
|
900 |
||
0 | 901 |
maxStackDepth |
902 |
"return the stack-need of the method - only valid after code-generation" |
|
903 |
||
904 |
^ maxStackDepth |
|
905 |
! ! |
|
906 |
||
907 |
!ByteCodeCompiler methodsFor:'code generation'! |
|
908 |
||
141 | 909 |
absJumpFromJump:code |
910 |
"given a jump-symbolic code, return corresponding absolute jump" |
|
0 | 911 |
|
141 | 912 |
JumpToAbsJump isNil ifTrue:[ |
913 |
JumpToAbsJump := IdentityDictionary new. |
|
914 |
JumpToAbsJump at:#jump put:#jumpabs. |
|
915 |
JumpToAbsJump at:#trueJump put:#trueJumpabs. |
|
916 |
JumpToAbsJump at:#falseJump put:#falseJumpabs. |
|
917 |
JumpToAbsJump at:#nilJump put:#nilJumpabs. |
|
918 |
JumpToAbsJump at:#notNilJump put:#notNilJumpabs. |
|
919 |
JumpToAbsJump at:#eqJump put:#eqJumpabs. |
|
920 |
JumpToAbsJump at:#notEqJump put:#notEqJumpabs. |
|
921 |
JumpToAbsJump at:#zeroJump put:#zeroJumpabs. |
|
922 |
JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs. |
|
923 |
JumpToAbsJump at:#makeBlock put:#makeBlockabs. |
|
0 | 924 |
]. |
141 | 925 |
^ JumpToAbsJump at:code |
0 | 926 |
! |
927 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
928 |
addLiteral:anObject |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
929 |
"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
|
930 |
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
|
931 |
|
429 | 932 |
|index "{ Class: SmallInteger }" class| |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
933 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
934 |
litArray isNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
935 |
litArray := Array with:anObject. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
936 |
^ 1 |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
937 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
938 |
index := litArray identityIndexOf:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
939 |
(index == 0) ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
940 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
941 |
reuse constants if same value and same class |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
942 |
" |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
943 |
class := anObject class. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
944 |
((class == Float) |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
945 |
or:[class == Fraction |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
946 |
or:[class == LargeInteger |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
947 |
"or:[class == String] --only if literalString option has been added---" ]]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
948 |
index := litArray indexOf:anObject. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
949 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
950 |
((index == 0) or:[(litArray at:index) class ~~ class]) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
951 |
litArray := litArray copyWith:anObject. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
952 |
^ litArray size |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
953 |
]. |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
954 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
955 |
^ index |
632 | 956 |
|
957 |
"Modified: / 12.11.1997 / 18:49:43 / cg" |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
958 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
959 |
|
141 | 960 |
addReloc:symIndex |
961 |
"remember to relocate offset at symIndex later ..." |
|
3 | 962 |
|
141 | 963 |
relocList isNil ifTrue:[ |
964 |
relocList := OrderedCollection new. |
|
1 | 965 |
]. |
141 | 966 |
relocList add:symIndex |
1 | 967 |
! |
968 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
969 |
appendByte:aByte |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
970 |
"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
|
971 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
972 |
|idx "{Class: SmallInteger }"| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
973 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
974 |
idx := codeIndex. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
975 |
(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
|
976 |
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
|
977 |
codeIndex := idx + 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
978 |
] ifFalse:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
979 |
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
|
980 |
errorFlag := #Error |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
981 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
982 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
983 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
984 |
appendByteCodeFor:codeSymbol |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
985 |
"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
|
986 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
987 |
|idx "{Class: SmallInteger }"| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
988 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
989 |
idx := codeIndex. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
990 |
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
|
991 |
codeIndex := idx + 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
992 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
993 |
|
141 | 994 |
appendEmptyByte |
995 |
"append an empty byte to the code-Array" |
|
3 | 996 |
|
141 | 997 |
|idx "{Class: SmallInteger }"| |
3 | 998 |
|
141 | 999 |
idx := codeIndex. |
1000 |
codeBytes at:idx put:0. |
|
1001 |
codeIndex := idx + 1 |
|
45 | 1002 |
! |
1003 |
||
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1004 |
appendEmptyLong |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1005 |
"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
|
1006 |
|
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1007 |
|idx "{Class: SmallInteger }"| |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1008 |
|
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1009 |
idx := codeIndex. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1010 |
codeBytes at:idx put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1011 |
codeBytes at:idx+1 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1012 |
codeBytes at:idx+2 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1013 |
codeBytes at:idx+3 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1014 |
codeIndex := idx + 4 |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1015 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1016 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1017 |
appendEmptyShort |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1018 |
"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
|
1019 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1020 |
|idx "{Class: SmallInteger }"| |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1021 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1022 |
idx := codeIndex. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1023 |
codeBytes at:idx put:0. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1024 |
codeBytes at:idx+1 put:0. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1025 |
codeIndex := idx + 2 |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1026 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1027 |
|
0 | 1028 |
appendSignedByte:aByte |
1029 |
"append a signedbyte (as in jump-offsets) to the code-Array, |
|
1030 |
check range and report an error if invalid" |
|
1031 |
||
49 | 1032 |
|b "{Class: SmallInteger }" |
1033 |
idx "{Class: SmallInteger }"| |
|
0 | 1034 |
|
49 | 1035 |
idx := codeIndex. |
0 | 1036 |
b := aByte. |
1037 |
(b >= 0) ifTrue:[ |
|
45 | 1038 |
(b > 127) ifTrue:[ |
1039 |
self error:'jump-range error'. |
|
1040 |
errorFlag := #Error |
|
1041 |
]. |
|
49 | 1042 |
codeBytes at:idx put:b |
0 | 1043 |
] ifFalse:[ |
45 | 1044 |
(b < -128) ifTrue:[ |
1045 |
self error:'jump-range error'. |
|
1046 |
errorFlag := #Error |
|
1047 |
]. |
|
49 | 1048 |
b := 256 + b |
0 | 1049 |
]. |
49 | 1050 |
codeBytes at:idx put:b. |
1051 |
codeIndex := idx + 1 |
|
0 | 1052 |
! |
1053 |
||
46 | 1054 |
appendSignedWord:aWord |
1055 |
"append a signed word to the code-Array, |
|
1056 |
check range and report an error if invalid" |
|
1057 |
||
49 | 1058 |
|w "{Class: SmallInteger }"| |
46 | 1059 |
|
1060 |
w := aWord. |
|
1061 |
(w >= 0) ifTrue:[ |
|
1062 |
(w > 16r7FFFF) ifTrue:[ |
|
1063 |
self error:'word-range error'. |
|
1064 |
errorFlag := #Error |
|
1065 |
]. |
|
1066 |
] ifFalse:[ |
|
1067 |
(w < 16r-8000) ifTrue:[ |
|
1068 |
self error:'word-range error'. |
|
1069 |
errorFlag := #Error |
|
1070 |
]. |
|
1071 |
w := (16r10000 + w). |
|
1072 |
]. |
|
1073 |
self appendWord:w |
|
1074 |
! |
|
1075 |
||
141 | 1076 |
appendWord:aWord |
1077 |
"append an unsigned word (low-high) to the code-Array, |
|
1078 |
checking for word-range (debug-only)" |
|
1079 |
||
1080 |
|idx "{Class: SmallInteger }"| |
|
1081 |
||
1082 |
idx := codeIndex. |
|
1083 |
(aWord between:0 and:16rFFFF) ifTrue:[ |
|
1084 |
codeBytes at:idx put:(aWord bitAnd:16rFF). |
|
1085 |
idx := idx + 1. |
|
1086 |
codeBytes at:idx put:(aWord bitShift:-8). |
|
1087 |
codeIndex := idx + 1 |
|
1088 |
] ifFalse:[ |
|
1089 |
self error:'word range error'. |
|
1090 |
errorFlag := #Error |
|
1091 |
] |
|
1092 |
! |
|
1093 |
||
0 | 1094 |
byteCodeFor:aSymbol |
1095 |
"given a symbolic instruction, return the corresponding bytecode. |
|
1096 |
as a side-effect, leave number of bytes pushed/popped by this instr. |
|
1097 |
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
|
1098 |
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
|
1099 |
information and extraLiteral is set if any hidden send is performed by it." |
0 | 1100 |
|
1101 |
"standard bytecodes" |
|
1102 |
||
1103 |
(aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10]. |
|
1104 |
(aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11]. |
|
1105 |
(aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12]. |
|
1106 |
(aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14]. |
|
105 | 1107 |
(aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14]. |
0 | 1108 |
(aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15]. |
1109 |
(aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16]. |
|
1110 |
||
1111 |
(aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30]. |
|
1112 |
(aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31]. |
|
1113 |
(aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32]. |
|
1114 |
(aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33]. |
|
1115 |
(aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34]. |
|
1 | 1116 |
(aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42]. |
1117 |
(aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128]. |
|
0 | 1118 |
|
1119 |
(aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0]. |
|
1120 |
(aSymbol == #retSelf) ifTrue:[^5]. |
|
1121 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1122 |
(aSymbol == #==) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 45]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1123 |
(aSymbol == #~~) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 46]. |
0 | 1124 |
|
1125 |
(aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50]. |
|
1126 |
(aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51]. |
|
1127 |
(aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52]. |
|
1128 |
(aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53]. |
|
1129 |
(aSymbol == #jump) ifTrue:[extra := #offset. ^ 54]. |
|
1 | 1130 |
(aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55]. |
0 | 1131 |
(aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56]. |
1132 |
(aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57]. |
|
1133 |
(aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58]. |
|
1134 |
(aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59]. |
|
1135 |
||
54 | 1136 |
(aSymbol == #lineno) ifTrue:[lineno := true. ^ 8]. |
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
1137 |
(aSymbol == #lineno16) ifTrue:[lineno := true. ^ 9]. |
54 | 1138 |
|
106 | 1139 |
(aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19]. |
1140 |
(aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
1141 |
(aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
117 | 1142 |
(aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13]. |
0 | 1143 |
|
1144 |
(aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18]. |
|
1145 |
(aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47]. |
|
1146 |
||
117 | 1147 |
(aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37]. |
1148 |
(aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38]. |
|
1149 |
(aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39]. |
|
0 | 1150 |
|
117 | 1151 |
(aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35]. |
356
bb3beb18de1f
6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
1152 |
(aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 36]. |
117 | 1153 |
|
1154 |
(aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40]. |
|
356
bb3beb18de1f
6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
1155 |
(aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 41]. |
247 | 1156 |
(aSymbol == #pushSpecialGlobal) ifTrue:[stackDelta := 1. extra := #index. ^ 200]. |
117 | 1157 |
|
1 | 1158 |
(aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129]. |
0 | 1159 |
|
117 | 1160 |
(aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176]. |
1161 |
(aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177]. |
|
105 | 1162 |
|
0 | 1163 |
"optimized bytecodes" |
1164 |
||
1165 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
|
1166 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
1167 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
1168 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
1169 |
(aSymbol == #retNum) ifTrue:[extra := #number. ^ 127]. |
|
25 | 1170 |
(aSymbol == #homeRetTop) ifTrue:[^ 7]. |
0 | 1171 |
|
46 | 1172 |
(aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17]. |
0 | 1173 |
(aSymbol == #push0) ifTrue:[stackDelta := 1. ^120]. |
1174 |
(aSymbol == #push1) ifTrue:[stackDelta := 1. ^121]. |
|
3 | 1175 |
(aSymbol == #push2) ifTrue:[stackDelta := 1. ^139]. |
0 | 1176 |
(aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122]. |
1177 |
||
106 | 1178 |
(aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21]. |
1179 |
(aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22]. |
|
1180 |
(aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23]. |
|
1181 |
(aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24]. |
|
0 | 1182 |
|
106 | 1183 |
(aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180]. |
1184 |
(aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181]. |
|
1185 |
(aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182]. |
|
1186 |
(aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183]. |
|
1187 |
(aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184]. |
|
1188 |
(aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185]. |
|
1189 |
(aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186]. |
|
1190 |
(aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187]. |
|
0 | 1191 |
|
106 | 1192 |
(aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25]. |
1193 |
(aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26]. |
|
1194 |
(aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27]. |
|
1195 |
(aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28]. |
|
1196 |
(aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29]. |
|
0 | 1197 |
|
1198 |
(aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80]. |
|
1199 |
(aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81]. |
|
1200 |
(aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82]. |
|
1201 |
(aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83]. |
|
1202 |
(aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84]. |
|
1203 |
(aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85]. |
|
1204 |
||
1205 |
(aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86]. |
|
1206 |
(aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87]. |
|
1207 |
(aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88]. |
|
1208 |
(aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89]. |
|
1209 |
||
1210 |
(aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90]. |
|
1211 |
(aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91]. |
|
1212 |
(aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92]. |
|
1213 |
(aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93]. |
|
1214 |
(aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94]. |
|
1215 |
(aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95]. |
|
1216 |
(aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96]. |
|
1217 |
(aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97]. |
|
1218 |
(aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98]. |
|
1219 |
(aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99]. |
|
1220 |
||
1221 |
(aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100]. |
|
1222 |
(aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101]. |
|
1223 |
(aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102]. |
|
1224 |
(aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103]. |
|
1225 |
(aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104]. |
|
1226 |
(aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105]. |
|
1227 |
||
1228 |
(aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110]. |
|
1229 |
(aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111]. |
|
1230 |
(aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112]. |
|
1231 |
(aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113]. |
|
1232 |
(aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114]. |
|
1233 |
(aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115]. |
|
1234 |
(aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116]. |
|
1235 |
(aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117]. |
|
1236 |
(aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118]. |
|
1237 |
(aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119]. |
|
1238 |
||
103 | 1239 |
(aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222]. |
1240 |
(aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223]. |
|
1241 |
(aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224]. |
|
1242 |
(aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225]. |
|
1243 |
(aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226]. |
|
1244 |
(aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227]. |
|
1245 |
(aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228]. |
|
1246 |
(aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229]. |
|
1247 |
||
0 | 1248 |
(aSymbol == #retMethodVar1) ifTrue:[^160]. |
1249 |
(aSymbol == #retMethodVar2) ifTrue:[^161]. |
|
1250 |
(aSymbol == #retMethodVar3) ifTrue:[^162]. |
|
1251 |
(aSymbol == #retMethodVar4) ifTrue:[^163]. |
|
1252 |
(aSymbol == #retMethodVar5) ifTrue:[^164]. |
|
1253 |
(aSymbol == #retMethodVar6) ifTrue:[^165]. |
|
1254 |
||
1255 |
(aSymbol == #retInstVar1) ifTrue:[^166]. |
|
1256 |
(aSymbol == #retInstVar2) ifTrue:[^167]. |
|
1257 |
(aSymbol == #retInstVar3) ifTrue:[^168]. |
|
1258 |
(aSymbol == #retInstVar4) ifTrue:[^169]. |
|
1259 |
(aSymbol == #retInstVar5) ifTrue:[^170]. |
|
1260 |
(aSymbol == #retInstVar6) ifTrue:[^171]. |
|
1261 |
(aSymbol == #retInstVar7) ifTrue:[^172]. |
|
1262 |
(aSymbol == #retInstVar8) ifTrue:[^173]. |
|
1263 |
||
1264 |
(aSymbol == #retMethodArg1) ifTrue:[^174]. |
|
1265 |
(aSymbol == #retMethodArg2) ifTrue:[^175]. |
|
1266 |
||
1267 |
(aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140]. |
|
1268 |
(aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141]. |
|
1269 |
(aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142]. |
|
1270 |
(aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143]. |
|
1271 |
||
1 | 1272 |
(aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43]. |
1273 |
(aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44]. |
|
0 | 1274 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1275 |
(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
|
1276 |
(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
|
1277 |
(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
|
1278 |
(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
|
1279 |
(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
|
1280 |
(aSymbol == #class) ifTrue:[extraLiteral := aSymbol. ^134]. |
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1281 |
"/ (aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. ^106]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1282 |
"/ (aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. ^107]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1283 |
"/ (aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. ^108]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1284 |
"/ (aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. ^109]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1285 |
"/ (aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. ^154]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1286 |
"/ (aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. ^155]. |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1287 |
(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
|
1288 |
(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
|
1289 |
(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
|
1290 |
(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
|
1291 |
(aSymbol == #plus1) ifTrue:[lineno := true. extraLiteral := #+. ^123]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1292 |
(aSymbol == #minus1) ifTrue:[lineno := true. extraLiteral := #-. ^124]. |
0 | 1293 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1294 |
(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
|
1295 |
(aSymbol == #decMethodVar) ifTrue:[lineno := true. extraLiteral := #-. extra := #index. ^126]. |
0 | 1296 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1297 |
(aSymbol == #eq0) ifTrue:[extraLiteral := #==. ^48]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1298 |
(aSymbol == #ne0) ifTrue:[extraLiteral := #~~. ^49]. |
0 | 1299 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1300 |
(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
|
1301 |
(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
|
1302 |
(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
|
1303 |
(aSymbol == #<=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 148]. |
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1304 |
"/ (aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 149]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1305 |
"/ (aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 150]. |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1306 |
(aSymbol == #value) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 151]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1307 |
(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
|
1308 |
(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
|
1309 |
(aSymbol == #size) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 153]. |
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1310 |
"/ (aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 158]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1311 |
"/ (aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 159]. |
0 | 1312 |
(aSymbol == #mk0Block) ifTrue:[^ 156]. |
1313 |
(aSymbol == #mkNilBlock) ifTrue:[^ 157]. |
|
1314 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1315 |
(aSymbol == #gt0) ifTrue:[lineno := true. extraLiteral := #>. ^ 212]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1316 |
(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
|
1317 |
(aSymbol == #basicNew) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 211]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1318 |
(aSymbol == #new) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 213]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1319 |
(aSymbol == #basicNew:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 214]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1320 |
(aSymbol == #new:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 215]. |
103 | 1321 |
|
217 | 1322 |
(aSymbol == #pushBlockVar1) ifTrue:[stackDelta := 1. ^ 232]. |
1323 |
(aSymbol == #pushBlockVar2) ifTrue:[stackDelta := 1. ^ 233]. |
|
1324 |
(aSymbol == #pushBlockVar3) ifTrue:[stackDelta := 1. ^ 234]. |
|
1325 |
(aSymbol == #storeBlockVar1) ifTrue:[stackDelta := -1. ^ 235]. |
|
1326 |
(aSymbol == #storeBlockVar2) ifTrue:[stackDelta := -1. ^ 236]. |
|
1327 |
(aSymbol == #storeBlockVar3) ifTrue:[stackDelta := -1. ^ 237]. |
|
1328 |
||
0 | 1329 |
(aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190]. |
1330 |
(aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191]. |
|
1331 |
(aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192]. |
|
1332 |
(aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193]. |
|
1333 |
(aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194]. |
|
1 | 1334 |
(aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195]. |
0 | 1335 |
(aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196]. |
1336 |
(aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197]. |
|
1 | 1337 |
(aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198]. |
1338 |
(aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199]. |
|
0 | 1339 |
|
1340 |
(aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144]. |
|
1341 |
||
425
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1342 |
(aSymbol == #isNil) ifTrue:[extraLiteral := aSymbol. ^ 188]. |
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1343 |
(aSymbol == #notNil) ifTrue:[extraLiteral := aSymbol. ^ 189]. |
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1344 |
(aSymbol == #not) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 179]. |
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1345 |
(aSymbol == #&) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 216]. |
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1346 |
(aSymbol == #|) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 217]. |
76 | 1347 |
|
117 | 1348 |
(aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
1349 |
(aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
|
1350 |
(aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219]. |
|
1351 |
(aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219]. |
|
1352 |
(aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201]. |
|
1353 |
||
1354 |
(aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205]. |
|
1355 |
(aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207]. |
|
1356 |
(aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204]. |
|
1357 |
(aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
1358 |
(aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
106 | 1359 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1360 |
(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
|
1361 |
(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
|
1362 |
(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
|
1363 |
(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
|
1364 |
|
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1365 |
(aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1366 |
(aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1367 |
(aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1368 |
(aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1369 |
(aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1370 |
(aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1371 |
(aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1372 |
(aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1373 |
(aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1374 |
(aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1375 |
|
217 | 1376 |
(aSymbol == #blockRef) ifTrue:[stackDelta := 0. ^ 238]. |
549 | 1377 |
(aSymbol == #over) ifTrue:[stackDelta := 1. ^ 6]. |
217 | 1378 |
|
0 | 1379 |
self error:'invalid code symbol'. |
1380 |
errorFlag := #Error |
|
117 | 1381 |
|
1382 |
"Modified: 3.9.1995 / 12:58:47 / claus" |
|
549 | 1383 |
"Modified: 25.6.1997 / 11:47:26 / cg" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1384 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1385 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1386 |
checkForCommonCode:symbolicCodeArray |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1387 |
"hook to return the code for common code sequences. |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1388 |
This reduces the in-memory number of byteArrays somewhat. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1389 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1390 |
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
|
1391 |
(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
|
1392 |
automatically in the background - or upon request ?)" |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1393 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1394 |
|sz insn1| |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1395 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1396 |
(sz := symbolicCodeArray size) == 2 ifTrue:[ |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1397 |
"/ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1398 |
"/ a very common sequence: return the first literal |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1399 |
"/ |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1400 |
(insn1 := symbolicCodeArray at:1) == #pushLit1 ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1401 |
(symbolicCodeArray at:2) == #retTop ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1402 |
^ #[222 0] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1403 |
] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1404 |
] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1405 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1406 |
sz == 1 ifTrue:[ |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1407 |
"/ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1408 |
"/ another common sequence: return the receiver |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1409 |
"/ |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1410 |
(insn1 := symbolicCodeArray at:1) == #retSelf ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1411 |
^ #[5] |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1412 |
]. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1413 |
insn1 == #retTrue ifTrue:[ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1414 |
^ #[2] |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1415 |
]. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1416 |
insn1 == #retFalse ifTrue:[ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1417 |
^ #[3] |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1418 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1419 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1420 |
^ nil |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1421 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1422 |
|
141 | 1423 |
checkForPrimitiveCode:nr |
1424 |
"return the code for an ST-80 primitive method. |
|
1425 |
Since many primitives available on ST-80 should also be available |
|
1426 |
somewhere in ST/X, this may work for many primitive numbers. |
|
1427 |
However, more information is needed and more things to be added below. |
|
1428 |
||
1429 |
This was added to allow emulation of (some) ST-80 |
|
1430 |
primitives (to fileIn RemoteInvocation & Monitor41 packages)" |
|
1431 |
||
1432 |
|cls sel| |
|
1433 |
||
1434 |
(nr == 75) ifTrue:[ cls := Object. sel := #identityHash ]. |
|
1435 |
(nr == 110) ifTrue:[ cls := Object. sel := #== ]. |
|
1436 |
(nr == 111) ifTrue:[ cls := Object. sel := #class ]. |
|
1437 |
" |
|
1438 |
should add more here, to be able to fileIn ST-80 methods |
|
1439 |
containing primitive calls (who gives me the numbers ... ?) |
|
512 | 1440 |
mhmh - got some ..." |
1441 |
||
1442 |
"/ 18 Number @ |
|
1443 |
"/ 21 LargePositiveInteger + |
|
1444 |
"/ 22 LargePositiveInteger - |
|
1445 |
"/ 29 LargePositiveInteger * |
|
1446 |
"/ 30 LargePositiveInteger / |
|
1447 |
"/ 31 LargePositiveInteger \\ |
|
1448 |
"/ 32 LargePositiveInteger // |
|
1449 |
"/ 34 LargePositiveInteger bitAnd: |
|
1450 |
"/ 35 LargePositiveInteger bitOr: |
|
1451 |
"/ 36 LargePositiveInteger bitXor: |
|
1452 |
"/ 37 LargePositiveInteger bitShift: |
|
1453 |
"/ 40 SmallInteger asFloat |
|
1454 |
"/ 41 Float + |
|
1455 |
"/ 42 Float - |
|
1456 |
"/ 49 Float * |
|
1457 |
"/ 50 Float / |
|
1458 |
"/ 52 Float fractionPart |
|
1459 |
"/ 54 Float timesTwoPower: |
|
1460 |
"/ 70 Behavior basicNew |
|
1461 |
"/ 71 Behavior basicNew: |
|
1462 |
"/ 89 Behavior flushVMmethodCache |
|
1463 |
"/ 91 InputState primCursorLocPut: |
|
1464 |
"/ 105 ByteArray replaceElementsFrom:to:withByteArray:startingAt: |
|
1465 |
"/ 223 ByteString = |
|
1466 |
"/ 306 ObjectMemory class sizesAtStartup |
|
1467 |
"/ 307 ObjectMemory class defaultSizesAtStartup |
|
1468 |
"/ 309 ObjectMemory class defaultThresholds |
|
1469 |
"/ 326 ObjectMemory class getMemoryUsageAndZeroFragmentationStatisticsIf: |
|
1470 |
"/ 395 ExternalInterface ??? |
|
1471 |
"/ 400 FormBitmap class newWidth:height: |
|
1472 |
"/ 414 TwoByteString replaceElementsFrom:to:withTwoByteString:startingAt: |
|
1473 |
"/ 415 TwoByteString = |
|
1474 |
"/ 417 String trueCompare: |
|
1475 |
"/ 418 ByteString nextIndexOf:from:to: |
|
1476 |
"/ 419 ByteString prevIndexOf:from:to: |
|
1477 |
"/ 422 WeakArray indexOf:replaceWith:startingAt:stoppingAt: |
|
1478 |
"/ 522 Behavior flushVMmethodCacheEntriesFor: |
|
1479 |
"/ 524 Context nFromVPC: |
|
1480 |
"/ 525 Context vFromNPC: |
|
1481 |
"/ 532 Object shallowCopy |
|
1482 |
"/ 536 Behavior atomicAllInstances |
|
1483 |
"/ 537 Object allOwners |
|
1484 |
"/ 538 ObjectMemory class allObjects |
|
1485 |
"/ 546 UninterpretedBytes longAt: |
|
1486 |
"/ 548 UninterpretedBytes floatAt: |
|
1487 |
"/ 550 UninterpretedBytes longFloatAt: |
|
1488 |
"/ 544 UninterpretedBytes unsignedLongAt: |
|
1489 |
"/ 559 ByteArray replaceBytesFrom:to:with:startingAt: |
|
1490 |
"/ 560 Double class fromNumber: |
|
1491 |
"/ 561 Double + |
|
1492 |
"/ 562 Double - |
|
1493 |
"/ 569 Double * |
|
1494 |
"/ 570 Double / |
|
1495 |
"/ 572 Double fractionPart |
|
1496 |
"/ 574 Double timesTwoPower: |
|
1497 |
"/ 576 Double sin |
|
1498 |
"/ 577 Double cos |
|
1499 |
"/ 578 Double tan |
|
1500 |
"/ 579 Double arcSin |
|
1501 |
"/ 580 Double arcCos |
|
1502 |
"/ 581 Double arcTan |
|
1503 |
"/ 582 Double sqrt |
|
1504 |
"/ 583 Double ln |
|
1505 |
"/ 584 Double exp |
|
1506 |
"/ 585 Double raisedTo: |
|
1507 |
"/ 587 Double floorLog10 |
|
1508 |
"/ 588 Double asFloat |
|
1509 |
"/ 591 Float cos |
|
1510 |
"/ 592 Float arcSin |
|
1511 |
"/ 593 Float arcCos |
|
1512 |
"/ 600 Float sin |
|
1513 |
"/ 601 Float tan |
|
1514 |
"/ 602 Float arcTan |
|
1515 |
"/ 603 Float sqrt |
|
1516 |
"/ 604 Float ln |
|
1517 |
"/ 605 Float exp |
|
1518 |
"/ 606 Float raisedTo: |
|
1519 |
"/ 609 Float floorLog10 |
|
1520 |
"/ 610 Filename getDatesErrInto: |
|
1521 |
"/ 614 DosFilename class getVolumes |
|
1522 |
"/ 615 UnixFilename primSetProtection:errInto: |
|
1523 |
"/ 616 UnixFilename class primSetCreationMask:errInto: |
|
1524 |
"/ 617 UnixFilename primGetProtectionErrInto: |
|
1525 |
"/ 620 Filename listDirectoryErrInto: |
|
1526 |
"/ 621 Filename deleteErrInto: |
|
1527 |
"/ 622 Filename isDirectoryErrInto: |
|
1528 |
"/ 623 Filename renameTo:errInto: |
|
1529 |
"/ 624 Filename makeDirectoryErrInto: |
|
1530 |
"/ 625 Filename class defaultDirectoryErrInto: |
|
1531 |
"/ 626 Filename fileSizeErrInto: |
|
1532 |
"/ 627 Filename isWritableErrInto: |
|
1533 |
"/ 628 Filename setWritable:errInto: |
|
1534 |
"/ 629 Filename existsErrInto: |
|
1535 |
"/ 630 SocketAccessor setOptionsLevel:name:value: |
|
1536 |
"/ 631 SocketAccessor getOptionsLevel:name: |
|
1537 |
"/ 632 SocketAccessor primGetName |
|
1538 |
"/ 633 SocketAccessor primGetPeer |
|
1539 |
"/ 634 SocketAccessor atMark |
|
1540 |
"/ 637 UnixTtyAccessor primGetOptions |
|
1541 |
"/ 638 UnixTtyAccessor setOptions: |
|
1542 |
"/ 639 UnixRealTtyAccessor modemBits:mask:sendBreak: |
|
1543 |
"/ 640 IPSocketAddress class primHostAddressByName: |
|
1544 |
"/ 641 IPSocketAddress class netAddressByName: |
|
1545 |
"/ 642 IPSocketAddress class protocolNumberByName: |
|
1546 |
"/ 643 IPSocketAddress class servicePortByName: |
|
1547 |
"/ 645 IPSocketAddress class primHostNameByAddress: |
|
1548 |
"/ 646 IPSocketAddress class netNameByAddress: |
|
1549 |
"/ 647 IPSocketAddress class protocolNameByNumber: |
|
1550 |
"/ 648 IPSocketAddress class serviceNameByPort: |
|
1551 |
"/ 649 SocketAccessor class getHostname |
|
1552 |
"/ 650 Filename primOpenFileNamed:direction:creation:errorInto: |
|
1553 |
"/ 651 IOAccessor primClose |
|
1554 |
"/ 652 UnixPipeAccessor class primPipeErrorInto: |
|
1555 |
"/ 653 UnixPseudoTtyAccessor class primPtyErrorInto: |
|
1556 |
"/ 654 SocketAccessor class primPairErrorInto: |
|
1557 |
"/ 655 UnixRealTtyAccessor class primOpen:errInto: |
|
1558 |
"/ 660 IOAccessor primReadInto:startingAt:for: |
|
1559 |
"/ 661 IOAccessor primWriteFrom:startingAt:for: |
|
1560 |
"/ 662 IOAccessor primSeekTo: |
|
1561 |
"/ 664 IOAccessor truncateTo: |
|
1562 |
"/ 665 DosDiskFileAccessor commit |
|
1563 |
"/ 666 IOAccessor primGetSize |
|
1564 |
"/ 667 MacDiskFileAccessor lock:for: |
|
1565 |
"/ 669 UnixIOAccessor bytesForRead |
|
1566 |
"/ 670 SocketAccessor class primFamily:type:protocol:errInto: |
|
1567 |
"/ 671 SocketAccessor primAccept |
|
1568 |
"/ 672 SocketAccessor bindTo: |
|
1569 |
"/ 673 SocketAccessor listenFor: |
|
1570 |
"/ 674 SocketAccessor primConnectTo: |
|
1571 |
"/ 675 SocketAccessor primReceiveFrom:buffer:start:for:flags: |
|
1572 |
"/ 676 SocketAccessor sendTo:buffer:start:for:flags: |
|
1573 |
"/ 677 SocketAccessor shutdown: |
|
1574 |
"/ 681 UnixProcess class primFork:arguments:environment:descriptors:errorTo: |
|
1575 |
"/ 682 UnixProcess class reapOne |
|
1576 |
"/ 683 UnixProcess kill: |
|
1577 |
"/ 690 CEnvironment class primEnvironment |
|
1578 |
"/ 697 OSErrorHolder class errorDescriptionFor: |
|
1579 |
"/ 697 ErrorHolder class errorDescriptionFor: |
|
1580 |
"/ 698 SocketAccessor class primInit: |
|
1581 |
"/ 700 ParagraphEditor class getExternalSelectionOrNil: |
|
1582 |
"/ 701 ParagraphEditor class putExternalSelection:with: |
|
1583 |
"/ 705 Screen ringBell |
|
1584 |
"/ 706 Cursor class primOpenImage:mask:hotSpotX:hotSpotY:background:foreground: |
|
1585 |
"/ 707 Cursor primBeCursor |
|
1586 |
"/ 708 Cursor primFreeCursor |
|
1587 |
"/ 772 SoundManager enumerateSoundsFrom: |
|
1588 |
"/ 773 SoundManager playSoundFrom:sound: |
|
1589 |
"/ 774 SoundManager simpleBeep: |
|
1590 |
"/ 775 Pixmap primFromClipboard |
|
1591 |
"/ 776 Pixmap toClipboard |
|
1592 |
"/ 808 Context findNextMarkedUpTo: |
|
1593 |
"/ 809 Context terminateTo: |
|
1594 |
"/ 710 DosTtyAccessor class primOpen:errInto: |
|
1595 |
"/ 711 DosTtyAccessor primClose |
|
1596 |
"/ 712 DosTtyAccessor primReadInto:startingAt:for: |
|
1597 |
"/ 713 DosTtyAccessor primWriteFrom:startingAt:for: |
|
1598 |
"/ 714 DosTtyAccessor primGetOptions |
|
1599 |
"/ 715 DosTtyAccessor primSetOptions: |
|
1600 |
"/ 716 DosTtyAccessor setSem:forWrite: |
|
1601 |
"/ 717 DosTtyAccessor modemBits:mask:sendBreak: |
|
1602 |
"/ 750 MacFilename class getVolumes |
|
1603 |
"/ 752 MacFilename primSetCreator:type:errInto: |
|
1604 |
"/ 754 MacIOAccessor class getAccessories |
|
1605 |
"/ 755 MacIOAccessor class runAccessory: |
|
1606 |
"/ 756 MacOSFilename class getFileTypes:errInto: |
|
1607 |
"/ 757 MacOSFilename putFileWithPrompt:errInto: |
|
1608 |
"/ 758 MacOSFilename getFileInfoErrInto: |
|
1609 |
"/ 759 MacOSFilename stringFromVRefErrInto: |
|
1610 |
"/ 761 MacOSFilename class getStartupFilesErrInto: |
|
1611 |
"/ 770 DosFilename printPSFileErrInto: |
|
1612 |
"/ 771 DosFilename printTextFileErrInto: |
|
1613 |
"/ 780 MacTtyAccessor class primOpen:errInto: |
|
1614 |
"/ 781 MacTtyAccessor primClose |
|
1615 |
"/ 782 MacTtyAccessor primReadInto:startingAt:for: |
|
1616 |
"/ 783 MacTtyAccessor primWriteFrom:startingAt:for: |
|
1617 |
"/ 786 MacTtyAccessor primGetOptions |
|
1618 |
"/ 787 MacTtyAccessor setOptions: |
|
1619 |
"/ 788 MacTtyAccessor primBreak: |
|
1620 |
"/ 790 MacTtyAccessor primGetStatus |
|
1621 |
"/ 792 MacTtyAccessor setSem:forWrite: |
|
1622 |
"/ 793 MacTtyAccessor primAssertDTR: |
|
1623 |
"/ 794 MacTtyAccessor primGetSize |
|
1624 |
"/ 933 ByteArray copyBitsClippedStride:... |
|
1625 |
"/ 934 ByteArray tileBits32By32Stride:... |
|
1626 |
"/ 935 Screen dragShape:... |
|
1627 |
"/ 936 Screen resizeRectangle... |
|
1628 |
"/ 937 Screen displayShape:... |
|
1629 |
"/ 938 Window resizeFromUserWithMinimum:maximum: |
|
1630 |
"/ 940 Window primClose |
|
1631 |
"/ 942 Window getDimensions |
|
1632 |
"/ 943 Window moveTo:resize: |
|
1633 |
"/ 944 Window primMap |
|
1634 |
"/ 945 Window class primNewAt:extent:min:max:windowType: |
|
1635 |
"/ 946 Screen flush |
|
1636 |
"/ 947 Screen getScreenDimensions |
|
1637 |
"/ 948 Window unmap |
|
1638 |
"/ 950 Screen sync |
|
1639 |
"/ 951 Window setIconMask: |
|
1640 |
"/ 952 Window label:iconLabel: |
|
1641 |
"/ 953 Window raise |
|
1642 |
"/ 954 Window lower |
|
1643 |
"/ 955 Screen queryStackingOrder |
|
1644 |
"/ 956 TextMeasurer primScanCharactersFrom:... |
|
1645 |
"/ 957 GraphicsContext displayMappedString:from:to:at:withMap: |
|
1646 |
"/ 959 Window setBackgroundPixel: |
|
1647 |
"/ 960 Screen class primOpen: |
|
1648 |
"/ 965 UnmappableSurface contentsOfAreaOriginX:y:width:height: |
|
1649 |
"/ 966 Window contentsOfAreaOriginX:y:width:height: |
|
1650 |
"/ 967 Screen contentsOfAreaOriginX:y:width:height: |
|
1651 |
"/ 970 Mask class primExtent:depth: |
|
1652 |
"/ 971 Mask privateClose |
|
1653 |
"/ 976 GraphicsContext displayCharacterOfIndex:at: |
|
1654 |
"/ 978 DeviceFont class listFonts |
|
1655 |
"/ 979 DeviceFont primLoadFont |
|
1656 |
"/ 980 DeviceFont primUnLoadFont |
|
1657 |
"/ 985 GraphicsContext displayLineFrom:to: |
|
1658 |
"/ 986 GraphicsContext displayPolyline:at: |
|
1659 |
"/ 987 GraphicsContext displayPolygon:at: |
|
1660 |
"/ 988 GraphicsContext primDisplayRectangleOrigin:extent: |
|
1661 |
"/ 989 GraphicsContext primDisplayRectangularBorderOrigin:extent: |
|
1662 |
"/ 990 GraphicsContext primDisplayArcBBoxOrigin:extent:startAngle:sweepAngle: |
|
1663 |
"/ 991 GraphicsContext primDisplayWedgeBBoxOrigin:extent:startAngle:sweepAngle: |
|
1664 |
"/ 992 GraphicsContext displayMask:at:" |
|
1665 |
"/ 993 GraphicsContext displayUninterpretedImageBits:at: |
|
1666 |
"/ 994 GraphicsContext primCopyRectangularAreaExtent:from:sourceOffset:destinationOffset: |
|
1667 |
"/ 995 GraphicsContext primCopyMaskedArea:from:sourceOffset:destinationOffset: |
|
1668 |
"/ 996 Screen deviceColormap |
|
1669 |
"/ 998 GraphicsContext displayUninterpretedMonoImageBits:foreground:background:at: |
|
1670 |
||
141 | 1671 |
cls notNil ifTrue:[ |
1672 |
^ (cls compiledMethodAt:sel) code |
|
1673 |
]. |
|
1674 |
^ nil |
|
1675 |
! |
|
1676 |
||
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1677 |
createMethod |
429 | 1678 |
|newMethod| |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1679 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1680 |
newMethod := Method new:(litArray size). |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1681 |
litArray notNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1682 |
"/ fixup CheapBlocks method-field in literal array, |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1683 |
litArray do:[:aLiteral | |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1684 |
(aLiteral isMemberOf:CheapBlock) ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1685 |
aLiteral setMethod:newMethod. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1686 |
] |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1687 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1688 |
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
|
1689 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1690 |
|
594
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1691 |
newMethod numberOfVars:(self numberOfMethodVars + (maxNumTemp ? 0)). |
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1692 |
newMethod numberOfArgs:(self numberOfMethodArgs). |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1693 |
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
|
1694 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1695 |
primitiveResource notNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1696 |
newMethod setResourceFlag |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1697 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1698 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1699 |
^ newMethod |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1700 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1701 |
"Created: 18.5.1996 / 16:33:17 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1702 |
"Modified: 24.6.1996 / 12:32:50 / stefan" |
594
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1703 |
"Modified: 1.8.1997 / 00:27:29 / cg" |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1704 |
! |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1705 |
|
141 | 1706 |
genByteCodeFrom:symbolicCodeArray |
1707 |
"convert symbolicCode into bytecodes" |
|
1708 |
||
1709 |
|symIndex "{Class: SmallInteger }" |
|
1710 |
codeSize "{Class: SmallInteger }" |
|
1711 |
symCodeSize "{Class: SmallInteger }" |
|
429 | 1712 |
index nextSym addr |
141 | 1713 |
codeSymbol nargs needRetry |
429 | 1714 |
stackDepth relocInfo level nvars round| |
141 | 1715 |
|
1716 |
symbolicCodeArray isNil ifTrue:[^ self]. |
|
1717 |
||
1718 |
round := 0. |
|
1719 |
needRetry := true. |
|
1720 |
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
|
1721 |
ShareCode ifTrue:[ |
512 | 1722 |
codeBytes := self checkForCommonCode:symbolicCodeArray. |
1723 |
codeBytes notNil ifTrue:[ |
|
1724 |
^ self |
|
1725 |
]. |
|
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
|
1726 |
]. |
141 | 1727 |
codeSize := symCodeSize. |
1728 |
||
1729 |
[needRetry] whileTrue:[ |
|
512 | 1730 |
stackDepth := 0. |
1731 |
maxStackDepth := 0. |
|
1732 |
||
1733 |
codeBytes := ByteArray uninitializedNew:codeSize. |
|
1734 |
relocInfo := Array basicNew:(codeSize + 1). |
|
1735 |
symIndex := 1. |
|
1736 |
codeIndex := 1. |
|
1737 |
||
1738 |
needRetry := false. |
|
1739 |
round := round + 1. |
|
1740 |
||
1741 |
[symIndex <= symCodeSize] whileTrue:[ |
|
1742 |
relocInfo at:symIndex put:codeIndex. |
|
1743 |
||
1744 |
codeSymbol := symbolicCodeArray at:symIndex. |
|
1745 |
symIndex := symIndex + 1. |
|
1746 |
stackDelta := 0. |
|
1747 |
extra := extraLiteral := nil. |
|
1748 |
lineno := false. |
|
1749 |
||
1750 |
self appendByteCodeFor:codeSymbol. |
|
1751 |
||
1752 |
extraLiteral notNil ifTrue:[ |
|
1753 |
self addLiteral:extraLiteral |
|
1754 |
]. |
|
1755 |
||
1756 |
lineno ifTrue:[ |
|
1757 |
self appendByte:((symbolicCodeArray at:symIndex) min:255). |
|
1758 |
symIndex := symIndex + 1. |
|
1759 |
codeSymbol == #lineno16 ifTrue:[ |
|
1760 |
self appendByte:((symbolicCodeArray at:symIndex) min:255). |
|
1761 |
symIndex := symIndex + 1 |
|
1762 |
] |
|
1763 |
]. |
|
1764 |
||
1765 |
extra notNil ifTrue:[ |
|
1766 |
nextSym := symbolicCodeArray at:symIndex. |
|
1767 |
||
1768 |
(extra == #number) ifTrue:[ |
|
1769 |
index := nextSym. |
|
1770 |
symIndex := symIndex + 1. |
|
1771 |
self appendSignedByte:index |
|
1772 |
||
1773 |
] ifFalse:[ (extra == #number16) ifTrue:[ |
|
1774 |
index := nextSym. |
|
1775 |
symIndex := symIndex + 2. |
|
1776 |
self appendSignedWord:index |
|
1777 |
||
1778 |
] ifFalse:[ (extra == #unsigned16) ifTrue:[ |
|
1779 |
index := nextSym. |
|
1780 |
symIndex := symIndex + 2. |
|
1781 |
self appendWord:index |
|
1782 |
||
1783 |
] ifFalse:[ (extra == #index) ifTrue:[ |
|
1784 |
index := nextSym. |
|
1785 |
symIndex := symIndex + 1. |
|
1786 |
self appendByte:index |
|
1787 |
||
1788 |
] ifFalse:[ (extra == #lit) ifTrue:[ |
|
1789 |
index := self addLiteral:nextSym. |
|
1790 |
symIndex := symIndex + 1. |
|
1791 |
self appendByte:index |
|
1792 |
||
1793 |
] ifFalse:[ (extra == #speciallit) ifTrue:[ |
|
1794 |
index := self addLiteral:nextSym. |
|
1795 |
index > 255 ifTrue:[ |
|
1796 |
self parseError:'too many globals (' , |
|
1797 |
(symbolicCodeArray at:symIndex) , |
|
1798 |
' index=' , index printString , |
|
1799 |
') in method - please simplify'. |
|
1800 |
^ #Error |
|
1801 |
]. |
|
1802 |
symIndex := symIndex + 1. |
|
1803 |
self appendByte:index. |
|
1804 |
||
1805 |
] ifFalse:[ (extra == #speciallitS) ifTrue:[ |
|
1806 |
index := nextSym. |
|
1807 |
symIndex := symIndex + 1. |
|
1808 |
self appendByte:index. |
|
1809 |
||
1810 |
] ifFalse:[ (extra == #speciallitL) ifTrue:[ |
|
1811 |
index := nextSym. |
|
1812 |
symIndex := symIndex + 2. |
|
1813 |
self appendWord:index. |
|
1814 |
||
1815 |
] ifFalse:[ (extra == #offset) ifTrue:[ |
|
1816 |
relocInfo at:symIndex put:codeIndex. |
|
1817 |
self addReloc:symIndex. |
|
1818 |
symIndex := symIndex + 1. |
|
1819 |
self appendByte:0 |
|
1820 |
||
1821 |
] ifFalse:[ (extra == #indexLevel) ifTrue:[ |
|
1822 |
index := nextSym. |
|
1823 |
symIndex := symIndex + 1. |
|
1824 |
self appendByte:index. |
|
1825 |
level := symbolicCodeArray at:symIndex. |
|
1826 |
symIndex := symIndex + 1. |
|
1827 |
self appendByte:level |
|
1828 |
||
1829 |
] ifFalse:[ (extra == #offsetNvarNarg) ifTrue:[ |
|
1830 |
relocInfo at:symIndex put:codeIndex. |
|
1831 |
self addReloc:symIndex. |
|
1832 |
symIndex := symIndex + 1. |
|
1833 |
self appendEmptyByte. |
|
1834 |
nvars := symbolicCodeArray at:symIndex. |
|
1835 |
symIndex := symIndex + 1. |
|
1836 |
self appendByte:nvars. |
|
1837 |
level := symbolicCodeArray at:symIndex. |
|
1838 |
symIndex := symIndex + 1. |
|
1839 |
self appendByte:level |
|
1840 |
||
1841 |
] ifFalse:[ (extra == #absoffset) ifTrue:[ |
|
1842 |
relocInfo at:symIndex put:codeIndex. |
|
1843 |
self addReloc:symIndex. |
|
1844 |
addr := symbolicCodeArray at:symIndex. |
|
1845 |
symIndex := symIndex + 1. |
|
1846 |
self appendByte:(addr bitAnd:16rFF). |
|
1847 |
self appendByte:((addr bitShift:-8) bitAnd:16rFF). |
|
1848 |
||
1849 |
] ifFalse:[ (extra == #absoffsetNvarNarg) ifTrue:[ |
|
1850 |
relocInfo at:symIndex put:codeIndex. |
|
1851 |
self addReloc:symIndex. |
|
1852 |
addr := symbolicCodeArray at:symIndex. |
|
1853 |
symIndex := symIndex + 1. |
|
1854 |
self appendByte:(addr bitAnd:16rFF). |
|
1855 |
self appendByte:((addr bitShift:-8) bitAnd:16rFF). |
|
1856 |
nvars := symbolicCodeArray at:symIndex. |
|
1857 |
symIndex := symIndex + 1. |
|
1858 |
self appendByte:nvars. |
|
1859 |
level := symbolicCodeArray at:symIndex. |
|
1860 |
symIndex := symIndex + 1. |
|
1861 |
self appendByte:level |
|
1862 |
||
1863 |
] ifFalse:[ (extra == #special) ifTrue:[ |
|
1864 |
((codeSymbol == #send) |
|
1865 |
or:[codeSymbol == #sendSelf |
|
1866 |
or:[codeSymbol == #superSend |
|
1867 |
or:[codeSymbol == #hereSend]]]) ifTrue:[ |
|
1868 |
index := nextSym. |
|
1869 |
symIndex := symIndex + 1. |
|
1870 |
nargs := symbolicCodeArray at:symIndex. |
|
1871 |
symIndex := symIndex + 1. |
|
1872 |
self appendByte:nargs. |
|
1873 |
self appendByte:index. |
|
1874 |
||
1875 |
(codeSymbol == #superSend |
|
1876 |
or:[codeSymbol == #hereSend]) ifTrue:[ |
|
1877 |
index := symbolicCodeArray at:symIndex. |
|
1878 |
symIndex := symIndex + 1. |
|
1879 |
self appendByte:index |
|
1880 |
]. |
|
1881 |
stackDelta := nargs negated. |
|
1882 |
codeSymbol == #sendSelf ifTrue:[ |
|
1883 |
stackDelta := stackDelta + 1 |
|
1884 |
] |
|
1885 |
] ifFalse:[ (codeSymbol == #sendDrop) ifTrue:[ |
|
1886 |
index := nextSym. |
|
1887 |
symIndex := symIndex + 1. |
|
1888 |
nargs := symbolicCodeArray at:symIndex. |
|
1889 |
symIndex := symIndex + 1. |
|
1890 |
self appendByte:nargs. |
|
1891 |
self appendByte:index. |
|
1892 |
stackDelta := (nargs + 1) negated |
|
1893 |
]] |
|
1894 |
||
1895 |
] ifFalse:[ (extra == #specialL) ifTrue:[ |
|
1896 |
((codeSymbol == #sendL) |
|
1897 |
or:[codeSymbol == #sendSelfL |
|
1898 |
or:[codeSymbol == #superSendL |
|
1899 |
or:[codeSymbol == #hereSendL]]]) ifTrue:[ |
|
1900 |
index := nextSym. |
|
1901 |
symIndex := symIndex + 2. |
|
1902 |
nargs := symbolicCodeArray at:symIndex. |
|
1903 |
symIndex := symIndex + 1. |
|
1904 |
self appendByte:nargs. |
|
1905 |
self appendWord:index. |
|
1906 |
(codeSymbol == #superSendL |
|
1907 |
or:[codeSymbol == #hereSendL]) ifTrue:[ |
|
1908 |
index := symbolicCodeArray at:symIndex. |
|
1909 |
symIndex := symIndex + 2. |
|
1910 |
self appendWord:index. |
|
1911 |
]. |
|
1912 |
stackDelta := nargs negated. |
|
1913 |
codeSymbol == #sendSelfL ifTrue:[ |
|
1914 |
stackDelta := stackDelta + 1 |
|
1915 |
] |
|
1916 |
] |
|
1917 |
] ifFalse:[ (extra == #specialSend) ifTrue:[ |
|
1918 |
index := nextSym. |
|
1919 |
symIndex := symIndex + 1. |
|
1920 |
self appendByte:index. |
|
1921 |
||
1922 |
] ifFalse:[ |
|
1923 |
"/ self halt:'internal error' |
|
475 | 1924 |
|
512 | 1925 |
]]]]]]]]]]]]]]]] |
1926 |
]. |
|
1927 |
||
1928 |
stackDepth := stackDepth + stackDelta. |
|
1929 |
(stackDepth > maxStackDepth) ifTrue:[ |
|
1930 |
maxStackDepth := stackDepth |
|
1931 |
] |
|
1932 |
]. |
|
1933 |
relocInfo at:symIndex put:codeIndex. |
|
1934 |
||
1935 |
needRetry ifFalse:[ |
|
1936 |
" |
|
1937 |
now relocate - returns true if ok, false if we have to do it again |
|
1938 |
(when short jumps have been changed to long jumps) |
|
1939 |
" |
|
1940 |
relocList notNil ifTrue:[ |
|
1941 |
needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not. |
|
1942 |
" |
|
1943 |
if returned with false, a relative jump was made into |
|
1944 |
an absolute jump - need to start over with one more byte space |
|
1945 |
" |
|
1946 |
needRetry ifTrue:[ |
|
1947 |
relocList := nil. |
|
1948 |
codeSize := codeSize + 1. |
|
1949 |
] |
|
1950 |
] |
|
1951 |
] ifTrue:[ |
|
1952 |
'Compiler [info]: compiling again ...' infoPrintCR. |
|
1953 |
] |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1954 |
]. |
141 | 1955 |
"code printNL." |
1956 |
^ errorFlag |
|
1957 |
||
1958 |
"Modified: 3.9.1995 / 12:59:43 / claus" |
|
475 | 1959 |
"Modified: 10.1.1997 / 15:17:51 / cg" |
141 | 1960 |
! |
1961 |
||
1962 |
genSymbolicCode |
|
1963 |
"traverse the parse-tree producing symbolicCode - return the codeArray" |
|
1964 |
||
1965 |
|codeStream code thisStatement lastStatement| |
|
1966 |
||
1967 |
litArray := nil. |
|
1968 |
codeStream := WriteStream on:(OrderedCollection new:100). |
|
1969 |
||
1970 |
thisStatement := tree. |
|
1971 |
[thisStatement notNil] whileTrue:[ |
|
512 | 1972 |
lastStatement := thisStatement. |
1973 |
thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
1974 |
thisStatement := thisStatement nextStatement |
|
141 | 1975 |
]. |
1976 |
(lastStatement isNil or:[lastStatement isReturnNode not]) |
|
1977 |
ifTrue:[ |
|
512 | 1978 |
"not a return - add retSelf" |
1979 |
" |
|
1980 |
if the last statement was a send for side-effect, |
|
1981 |
replace the previous drop by a retSelf. |
|
1982 |
In this case we have to keep an extra retSelf bacause |
|
1983 |
it could be a jump target. |
|
1984 |
" |
|
1985 |
(lastStatement notNil |
|
1986 |
and:[(code := codeStream contents) notNil |
|
1987 |
and:[code size > 0 |
|
1988 |
and:[code last == #drop]]]) ifTrue:[ |
|
1989 |
codeStream backStep. |
|
1990 |
codeStream nextPut:#retSelf |
|
1991 |
]. |
|
1992 |
codeStream nextPut:#retSelf |
|
141 | 1993 |
]. |
1994 |
^ codeStream contents |
|
328 | 1995 |
|
330
9b9a1ff67ba3
Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents:
328
diff
changeset
|
1996 |
"Modified: 15.8.1996 / 17:35:02 / stefan" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1997 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1998 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1999 |
hasLineNumber:sel |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2000 |
"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
|
2001 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2002 |
(sel == #==) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2003 |
(sel == #~~) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2004 |
(sel == #class) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2005 |
(sel == #isNil) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2006 |
(sel == #notNil) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2007 |
^ true |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2008 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2009 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2010 |
isBuiltIn1ArgSelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2011 |
"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
|
2012 |
(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
|
2013 |
|
530 | 2014 |
(sel == #at:) ifTrue:[^ true]. |
2015 |
(sel == #value:) ifTrue:[^ true]. |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2016 |
(sel == #bitAnd:) ifTrue:[^ true]. |
530 | 2017 |
(sel == #bitOr:) ifTrue:[^ true]. |
2018 |
(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
|
2019 |
(sel == #basicNew:) ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2020 |
"/ this one is critical - some redefine it |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2021 |
receiver isGlobal ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2022 |
(#('String' 'ByteArray' 'Array' |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2023 |
'Point' 'Rectangle' 'Object') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2024 |
includes:receiver name) ifTrue:[^ true]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2025 |
]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2026 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2027 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2028 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2029 |
"Created: 17.4.1996 / 22:33:13 / cg" |
530 | 2030 |
"Modified: 4.6.1997 / 12:24:18 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2031 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2032 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2033 |
isBuiltIn2ArgSelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2034 |
"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
|
2035 |
(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
|
2036 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2037 |
(sel == #at:put:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2038 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2039 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2040 |
"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
|
2041 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2042 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2043 |
isBuiltInBinarySelector:sel forReceiver:receiver |
530 | 2044 |
"return true, if binary selector sel is built-in. |
2045 |
(i.e. there is a single bytecode for it)" |
|
2046 |
||
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2047 |
sel == #== ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2048 |
sel == #~~ ifTrue:[^ true]. |
530 | 2049 |
sel == #= ifTrue:[^ true]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2050 |
sel == #~= ifTrue:[^ true]. |
530 | 2051 |
sel == #+ ifTrue:[^ true]. |
2052 |
sel == #- ifTrue:[^ true]. |
|
2053 |
sel == #< ifTrue:[^ true]. |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2054 |
sel == #<= ifTrue:[^ true]. |
530 | 2055 |
sel == #> ifTrue:[^ true]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2056 |
sel == #>= ifTrue:[^ true]. |
530 | 2057 |
sel == #* ifTrue:[^ true]. |
2058 |
sel == #& ifTrue:[^ true]. |
|
2059 |
sel == #| ifTrue:[^ true]. |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2060 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2061 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2062 |
"Created: 17.4.1996 / 22:34:27 / cg" |
530 | 2063 |
"Modified: 4.6.1997 / 12:24:00 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2064 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2065 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2066 |
isBuiltInUnarySelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2067 |
"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
|
2068 |
(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
|
2069 |
|
530 | 2070 |
(sel == #value) ifTrue:[^ true]. |
2071 |
(sel == #class) ifTrue:[^ true]. |
|
2072 |
(sel == #size) ifTrue:[^ true]. |
|
2073 |
(sel == #isNil) ifTrue:[^ true]. |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2074 |
(sel == #notNil) ifTrue:[^ true]. |
530 | 2075 |
(sel == #not) ifTrue:[^ true]. |
2076 |
||
2077 |
(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
|
2078 |
(sel == #basicNew) ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2079 |
"/ this one is critical - some redefine it |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2080 |
receiver isGlobal ifTrue:[ |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2081 |
(#('String' 'ByteArray' 'Array' |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2082 |
'Point' 'Rectangle' 'Object') |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2083 |
includes:receiver name) ifTrue:[^ true]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2084 |
]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2085 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2086 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2087 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
2088 |
"Created: 17.4.1996 / 22:32:16 / cg" |
530 | 2089 |
"Modified: 4.6.1997 / 12:23:30 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2090 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2091 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2092 |
moveGlobalsToFront |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2093 |
"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
|
2094 |
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
|
2095 |
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
|
2096 |
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
|
2097 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2098 |
litArray isNil ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2099 |
^ 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
|
2100 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2101 |
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
|
2102 |
(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
|
2103 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2104 |
(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
|
2105 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2106 |
(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
|
2107 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2108 |
(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
|
2109 |
ifTrue:[a < b]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2110 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2111 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2112 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2113 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2114 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2115 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2116 |
#(#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
|
2117 |
sort:[:a :b | |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2118 |
(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
|
2119 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2120 |
(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
|
2121 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2122 |
(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
|
2123 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2124 |
(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
|
2125 |
ifTrue:[(a < b)]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2126 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2127 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2128 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2129 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2130 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2131 |
" |
141 | 2132 |
! |
2133 |
||
2134 |
relocateWith:symbolicCodeArray relocInfo:relocInfo |
|
2135 |
"helper for genByteCodeFrom - relocate code using relocInfo. |
|
2136 |
if relocation fails badly (due to long relative jumps) patch |
|
2137 |
symbolicCode to use absolute jumps instead and return false |
|
2138 |
(genByteCodeFrom will then try again). Otherwise return true. |
|
2139 |
Also, on the fly, jumps to jumps and jumps to return are handled." |
|
2140 |
||
2141 |
|delta "{Class: SmallInteger }" |
|
2142 |
codePos "{Class: SmallInteger }" |
|
2143 |
opCodePos "{Class: SmallInteger }" |
|
2144 |
codeOffset "{Class: SmallInteger }" |
|
2145 |
symOffset |
|
2146 |
opcode "{Class: SmallInteger }" |
|
2147 |
dstOpcode jumpTarget |
|
2148 |
jumpCode deleteSet| |
|
2149 |
||
2150 |
deleteSet := OrderedCollection new. |
|
2151 |
relocList do:[:sIndex | |
|
2152 |
"have to relocate symCode at sIndex ..." |
|
2153 |
symOffset := symbolicCodeArray at:sIndex. "the target in the symbolic code" |
|
2154 |
codePos := relocInfo at:sIndex. "position of the offet in byte code" |
|
2155 |
codeOffset := relocInfo at:symOffset. "position of the target in byte code" |
|
2156 |
delta := codeOffset - codePos - 1. |
|
2157 |
opCodePos := codePos - 1. |
|
2158 |
opcode := codeBytes at:opCodePos. |
|
2159 |
||
2160 |
(opcode between:190 and:199) ifTrue:[ |
|
2161 |
"an absolute jump/makeBlock" |
|
2162 |
||
2163 |
codeBytes at:codePos put:(codeOffset bitAnd:16rFF). |
|
2164 |
codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8) |
|
2165 |
] ifFalse:[ |
|
2166 |
"get jump-code from long and vlong codes" |
|
2167 |
(opcode between:50 and:59) ifFalse:[ |
|
2168 |
(opcode between:60 and:69) ifTrue:[ |
|
2169 |
opcode := opcode - 10 |
|
2170 |
] ifFalse:[ |
|
2171 |
(opcode between:70 and:79) ifTrue:[ |
|
2172 |
opcode := opcode - 20 |
|
2173 |
] ifFalse:[ |
|
2174 |
self error:'invalid code to relocate' |
|
2175 |
] |
|
2176 |
]. |
|
2177 |
]. |
|
2178 |
||
2179 |
"optimize jump to return and jump to jump" |
|
2180 |
||
2181 |
(opcode == 54) ifTrue:[ |
|
2182 |
"a jump" |
|
2183 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
2184 |
||
2185 |
(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[ |
|
2186 |
"a jump to a return - put in the return instead jump" |
|
2187 |
||
2188 |
symbolicCodeArray at:(sIndex - 1) put:dstOpcode. |
|
2189 |
symbolicCodeArray at:sIndex put:dstOpcode. |
|
2190 |
codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode). |
|
2191 |
delta := 0. |
|
2192 |
deleteSet add:sIndex. |
|
2193 |
||
2194 |
" |
|
2195 |
'jump to return at: ' print. (sIndex - 1) printNL. |
|
2196 |
" |
|
2197 |
] ifFalse:[ |
|
2198 |
(dstOpcode == #jump) ifTrue:[ |
|
2199 |
"jump to jump to be done soon" |
|
2200 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
2201 |
" |
|
2202 |
'jump to jump at: ' print. (sIndex - 1) print. |
|
2203 |
' newTarget:' print. jumpTarget printNL. |
|
2204 |
" |
|
2205 |
||
2206 |
symbolicCodeArray at:sIndex put:jumpTarget. |
|
2207 |
symOffset := jumpTarget. |
|
2208 |
codeOffset := relocInfo at:symOffset. |
|
2209 |
delta := codeOffset - codePos - 1. |
|
2210 |
||
2211 |
"continue with new delta" |
|
2212 |
] |
|
2213 |
] |
|
2214 |
]. |
|
2215 |
(#(50 51 52 53 56 57 58 59) includes:opcode) ifTrue:[ |
|
2216 |
"a conditional jump" |
|
2217 |
||
2218 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
2219 |
(dstOpcode == #jump) ifTrue:[ |
|
2220 |
"conditional jump to unconditional jump" |
|
2221 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
2222 |
" |
|
2223 |
'cond jump to jump at: ' print. (sIndex - 1) print. |
|
2224 |
' newTarget:' print. jumpTarget printNL. |
|
2225 |
" |
|
2226 |
||
2227 |
symbolicCodeArray at:sIndex put:jumpTarget. |
|
2228 |
symOffset := jumpTarget. |
|
2229 |
codeOffset := relocInfo at:symOffset. |
|
2230 |
delta := codeOffset - codePos - 1. |
|
2231 |
||
2232 |
"continue with new delta" |
|
2233 |
]. |
|
2234 |
]. |
|
2235 |
||
2236 |
(delta >= 0) ifTrue:[ |
|
2237 |
(delta > 127) ifTrue:[ |
|
2238 |
(opcode between:50 and:59) ifFalse:[ |
|
2239 |
self error:'invalid code to relocate' |
|
2240 |
] ifTrue:[ |
|
2241 |
(delta > 255) ifTrue:[ |
|
2242 |
"change jmp into vljmp ..." |
|
2243 |
codeBytes at:opCodePos put:(opcode + 20). |
|
2244 |
delta := delta - 256 |
|
2245 |
] ifFalse:[ |
|
2246 |
"change jmp into ljmp ..." |
|
2247 |
codeBytes at:opCodePos put:(opcode + 10). |
|
2248 |
delta := delta - 128 |
|
2249 |
]. |
|
2250 |
(delta > 127) ifTrue:[ |
|
2251 |
"change symbolic into a jump absolute and fail" |
|
2252 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
2253 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
2254 |
symbolicCodeArray at:sIndex put:symOffset. |
|
2255 |
" |
|
2256 |
'change short into abs jump' printNL. |
|
2257 |
" |
|
2258 |
deleteSet do:[:d | relocList remove:d]. |
|
2259 |
^ false |
|
2260 |
] |
|
2261 |
]. |
|
2262 |
]. |
|
2263 |
codeBytes at:codePos put:delta |
|
2264 |
] ifFalse:[ |
|
2265 |
(delta < -128) ifTrue:[ |
|
2266 |
(opcode between:50 and:59) ifFalse:[ |
|
2267 |
self error:'invalid code to relocate' |
|
2268 |
] ifTrue:[ |
|
2269 |
(delta < -256) ifTrue:[ |
|
2270 |
"change jmp into vljmp ..." |
|
2271 |
codeBytes at:opCodePos put:(opcode + 20). |
|
2272 |
delta := delta + 256 |
|
2273 |
] ifFalse:[ |
|
2274 |
"change jmp into ljmp ..." |
|
2275 |
codeBytes at:opCodePos put:(opcode + 10). |
|
2276 |
delta := delta + 128 |
|
2277 |
]. |
|
2278 |
(delta < -128) ifTrue:[ |
|
2279 |
"change symbolic into a jump absolute and fail" |
|
2280 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
2281 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
2282 |
symbolicCodeArray at:sIndex put:symOffset. |
|
2283 |
" |
|
2284 |
'change short into abs jump' printNL. |
|
2285 |
" |
|
2286 |
deleteSet do:[:d | relocList remove:d]. |
|
2287 |
^ false |
|
2288 |
] |
|
2289 |
] |
|
2290 |
]. |
|
2291 |
codeBytes at:codePos put:(256 + delta) |
|
2292 |
] |
|
2293 |
] |
|
2294 |
]. |
|
2295 |
(errorFlag == #Error) ifTrue:[ |
|
2296 |
self error:'relocation range error' |
|
2297 |
]. |
|
2298 |
^ true |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2299 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2300 |
|
247 | 2301 |
specialGlobalCodeFor:aSymbol |
530 | 2302 |
"codeExtension for globals, |
2303 |
which can be accessed by specialGlobal opCode" |
|
2304 |
||
2305 |
|idx| |
|
2306 |
||
2307 |
idx := self specialGlobals identityIndexOf:aSymbol ifAbsent:nil. |
|
2308 |
idx isNil ifTrue:[^ idx]. |
|
2309 |
^ idx - 1. |
|
2310 |
||
2311 |
"Modified: 4.6.1997 / 12:31:22 / cg" |
|
2312 |
! |
|
2313 |
||
2314 |
specialGlobals |
|
2315 |
"list of globals which can be accessed by specialGlobal opCode; |
|
2316 |
adding any here requires a new VM (i.e. you cannot change it)" |
|
2317 |
||
2318 |
^ #( |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2319 |
#Array "/ 0 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2320 |
#String "/ 1 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2321 |
#FloatArray "/ 2 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2322 |
#DoubleArray "/ 3 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2323 |
#Point "/ 4 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2324 |
#Symbol "/ 5 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2325 |
#Smalltalk "/ 6 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2326 |
#Processor "/ 7 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2327 |
#SmallInteger "/ 8 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2328 |
#Character "/ 9 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2329 |
#Float "/ 10 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2330 |
#Process "/ 11 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2331 |
#Set "/ 12 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2332 |
#IdentitySet "/ 13 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2333 |
#Dictionary "/ 14 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2334 |
#IdentityDictionary "/ 15 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2335 |
#Sempahore "/ 16 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2336 |
#OrderedCollection "/ 17 |
530 | 2337 |
) |
2338 |
||
2339 |
"Created: 4.6.1997 / 12:17:47 / cg" |
|
2340 |
"Modified: 4.6.1997 / 12:31:35 / cg" |
|
247 | 2341 |
! |
2342 |
||
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
2343 |
specialSendCodeFor:sel |
530 | 2344 |
"return the codeExtension for sends, |
2345 |
which can be performed by specialSend opCode" |
|
2346 |
||
2347 |
|idx| |
|
2348 |
||
2349 |
idx := self specialSends identityIndexOf:sel ifAbsent:nil. |
|
2350 |
idx isNil ifTrue:[^ idx]. |
|
2351 |
^ idx - 1. |
|
2352 |
||
2353 |
"Modified: 4.6.1997 / 12:31:08 / cg" |
|
2354 |
! |
|
2355 |
||
2356 |
specialSends |
|
2357 |
"list of selectors which can be sent by specialSend opCode; |
|
2358 |
adding any here requires a new VM (i.e. you cannot change it)" |
|
2359 |
||
2360 |
^ #( |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2361 |
#top "/ 0 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2362 |
#bottom "/ 1 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2363 |
#left "/ 2 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2364 |
#right "/ 3 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2365 |
#x "/ 4 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2366 |
#y "/ 5 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2367 |
#width "/ 6 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2368 |
#height "/ 7 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2369 |
#origin "/ 8 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2370 |
#extent "/ 9 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2371 |
#asInteger "/ 10 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2372 |
#rounded "/ 11 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2373 |
#next "/ 12 |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2374 |
#peek "/ 13 |
530 | 2375 |
) |
2376 |
||
2377 |
"Created: 4.6.1997 / 12:20:28 / cg" |
|
2378 |
"Modified: 4.6.1997 / 12:31:56 / cg" |
|
0 | 2379 |
! ! |
49 | 2380 |
|
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2381 |
!ByteCodeCompiler methodsFor:'code generation helpers'! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2382 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2383 |
addTempVar |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2384 |
"add a temporary variable; return its position (1-based). |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2385 |
Used when a block with args/locals is inlined." |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2386 |
|
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2387 |
numTemp isNil ifTrue:[numTemp := maxNumTemp := 0]. |
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2388 |
numTemp := numTemp + 1. |
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2389 |
maxNumTemp := maxNumTemp max:numTemp. |
560
9311c79529d4
inline blocks withs args/vars
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
2390 |
^ numTemp + methodVars size |
9311c79529d4
inline blocks withs args/vars
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
2391 |
|
9311c79529d4
inline blocks withs args/vars
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
2392 |
"Modified: 26.6.1997 / 10:22:23 / cg" |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2393 |
! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2394 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2395 |
removeTempVar |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2396 |
"remove a temporary variable" |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2397 |
|
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2398 |
numTemp := numTemp - 1 |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2399 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2400 |
"Created: 25.6.1997 / 14:03:00 / cg" |
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2401 |
"Modified: 25.6.1997 / 15:06:10 / cg" |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2402 |
! ! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2403 |
|
49 | 2404 |
!ByteCodeCompiler methodsFor:'machine code generation'! |
2405 |
||
2406 |
compileToMachineCode:aString forClass:aClass inCategory:cat |
|
758 | 2407 |
notifying:requestor install:install skipIfSame:skipIfSame silent:silent |
49 | 2408 |
"this is called to compile primitive code. |
2409 |
This is EXPERIMENTAL and going to be changed to raise an error, |
|
2410 |
an redefined in subclasses which can do it (either by direct compilation, or by calling |
|
2411 |
the external stc do do it. |
|
2412 |
For a description of the arguments, see compile:forClass....." |
|
2413 |
||
721
b98c67a8f4e8
must add cpuDefine to cflags.
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
2414 |
|stFileName stream handle address stcFlags cFlags def |
429 | 2415 |
command oFileName cFileName |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
2416 |
initName newMethod ok status className sep class stcPath ccPath |
510
9f19de0f8f0b
also consult searchedLibs when loading individual methods.
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
2417 |
errorStream errorMessages eMsg m supers mP moduleFileName dummyHandle| |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2418 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2419 |
(mP := STCModulePath asFilename) exists ifFalse:[ |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2420 |
mP makeDirectory |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2421 |
]. |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2422 |
(mP isDirectory |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2423 |
and:[mP isReadable |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2424 |
and:[mP isWritable]]) ifFalse:[ |
758 | 2425 |
self parseError:('no access to tempDir: ' , mP pathName) position:1. |
2426 |
^ #CannotLoad |
|
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2427 |
]. |
96 | 2428 |
|
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
|
2429 |
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
|
2430 |
STCCompilation == #never ifTrue:[^ #CannotLoad]. |
120 | 2431 |
(stcPath := self class incrementalStcPath) isNil ifTrue:[ |
758 | 2432 |
self parseError:'no stc compiler available - cannot create machine code' position:1. |
2433 |
^ #CannotLoad |
|
120 | 2434 |
]. |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
2435 |
(ccPath := self class ccPath) isNil ifTrue:[ |
758 | 2436 |
self parseError:'no cc compiler available - cannot create machine code' position:1. |
2437 |
^ #CannotLoad |
|
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2438 |
]. |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2439 |
|
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2440 |
(ObjectFileLoader notNil |
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2441 |
and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[ |
758 | 2442 |
self parseError:'no dynamic loader configured - cannot create machine code' position:1. |
2443 |
^ #CannotLoad |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
2444 |
]. |
54 | 2445 |
|
298
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
2446 |
"/ generate a unique name, consisting of my processID and a sequence number |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
2447 |
"/ the processId is added to allow filein of modules from different |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
2448 |
"/ lifes |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
2449 |
|
54 | 2450 |
SequenceNumber isNil ifTrue:[ |
758 | 2451 |
SequenceNumber := 0. |
54 | 2452 |
]. |
2453 |
SequenceNumber := SequenceNumber + 1. |
|
49 | 2454 |
|
298
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
2455 |
initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString. |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
2456 |
|
751 | 2457 |
stFileName := (Filename currentDirectory construct:(initName , '.st')) name. |
54 | 2458 |
stream := stFileName asFilename writeStream. |
187 | 2459 |
stream isNil ifTrue:[ |
758 | 2460 |
self parseError:'cannot create temporary sourcefile for compilation'. |
2461 |
^ #CannotLoad |
|
187 | 2462 |
]. |
49 | 2463 |
|
407 | 2464 |
[ |
758 | 2465 |
|definedClasses| |
2466 |
||
2467 |
definedClasses := IdentitySet new. |
|
2468 |
||
2469 |
sep := stream class chunkSeparator. |
|
2470 |
||
2471 |
class := aClass. |
|
2472 |
class isMeta ifTrue:[ |
|
2473 |
class := aClass soleInstance |
|
2474 |
]. |
|
2475 |
supers := class allSuperclasses. |
|
2476 |
supers notNil ifTrue:[ |
|
2477 |
supers reverseDo:[:cls| |
|
2478 |
true "cls ~~ Object" ifTrue:[ |
|
2479 |
cls isLoaded ifFalse:[ |
|
2480 |
stream close. |
|
2481 |
^ #CannotLoad |
|
2482 |
]. |
|
2483 |
cls fileOutDefinitionOn:stream. |
|
2484 |
stream nextPut:sep; cr. |
|
2485 |
definedClasses add:cls. |
|
2486 |
] |
|
2487 |
] |
|
2488 |
]. |
|
2489 |
class fileOutDefinitionOn:stream. |
|
2490 |
stream nextPut:sep; cr. |
|
2491 |
definedClasses add:class. |
|
2492 |
||
2493 |
class privateClassesSorted do:[:aPrivateClass | |
|
2494 |
supers := aPrivateClass allSuperclasses. |
|
2495 |
supers notNil ifTrue:[ |
|
2496 |
supers reverseDo:[:cls| |
|
2497 |
(definedClasses includes:cls) ifFalse:[ |
|
2498 |
true "cls ~~ Object" ifTrue:[ |
|
2499 |
cls isLoaded ifFalse:[ |
|
2500 |
stream close. |
|
2501 |
^ #CannotLoad |
|
2502 |
]. |
|
2503 |
cls fileOutDefinitionOn:stream. |
|
2504 |
stream nextPut:sep; cr. |
|
2505 |
definedClasses add:cls. |
|
2506 |
] |
|
2507 |
] |
|
2508 |
] |
|
2509 |
]. |
|
2510 |
(definedClasses includes:aPrivateClass) ifFalse:[ |
|
2511 |
aPrivateClass fileOutDefinitionOn:stream. |
|
2512 |
stream nextPut:sep; cr. |
|
2513 |
definedClasses add:aPrivateClass. |
|
2514 |
] |
|
2515 |
]. |
|
2516 |
||
2517 |
class fileOutPrimitiveDefinitionsOn:stream. |
|
2518 |
||
2519 |
stream nextPut:sep. |
|
2520 |
className := class name. |
|
2521 |
||
2522 |
stream nextPutAll:className. |
|
2523 |
aClass isMeta ifTrue:[ |
|
2524 |
stream nextPutAll:' class'. |
|
2525 |
]. |
|
2526 |
stream nextPutAll:' methodsFor:'''; nextPutAll:cat; nextPutAll:''''. |
|
2527 |
stream nextPut:sep; cr. |
|
2528 |
||
2529 |
stream nextPutLine:'"{ Line: 0 }"'; |
|
2530 |
nextChunkPut:aString; |
|
2531 |
space; nextPut:sep. |
|
2532 |
||
2533 |
stream close. |
|
2534 |
||
2535 |
" |
|
2536 |
call stc to compile it |
|
2537 |
" |
|
2538 |
oFileName := stFileName asFilename withoutSuffix name , (ObjectFileLoader objectFileExtension). |
|
2539 |
cFileName := (stFileName asFilename withSuffix:'c') name. |
|
2540 |
oFileName asFilename delete. |
|
2541 |
cFileName asFilename delete. |
|
2542 |
||
2543 |
stcFlags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName . |
|
2544 |
cFlags := OperatingSystem getOSDefine. |
|
2545 |
cFlags isNil ifTrue:[ |
|
2546 |
cFlags := '' |
|
2547 |
]. |
|
2548 |
(def := OperatingSystem getCPUDefine) notNil ifTrue:[ |
|
2549 |
cFlags := cFlags , ' ' , def |
|
2550 |
]. |
|
2551 |
||
2552 |
STCCompilationDefines notNil ifTrue:[ |
|
2553 |
cFlags := cFlags , ' ' , STCCompilationDefines |
|
2554 |
]. |
|
2555 |
STCCompilationIncludes notNil ifTrue:[ |
|
2556 |
stcFlags := STCCompilationIncludes , ' ' , stcFlags. |
|
2557 |
cFlags := cFlags , ' ' , STCCompilationIncludes. |
|
2558 |
]. |
|
2559 |
STCCompilationOptions notNil ifTrue:[ |
|
2560 |
stcFlags := STCCompilationOptions , ' ' , stcFlags |
|
2561 |
]. |
|
2562 |
CCCompilationOptions notNil ifTrue:[ |
|
2563 |
cFlags := cFlags , ' ' , CCCompilationOptions |
|
2564 |
]. |
|
2565 |
||
2566 |
command := stcPath , ' ' , stcFlags , ' -C ' , stFileName. |
|
2567 |
||
2568 |
Verbose == true ifTrue:[ |
|
2569 |
'executing: ' infoPrint. command infoPrintCR. |
|
2570 |
]. |
|
2571 |
errorStream := 'errorOutput' asFilename writeStream. |
|
2572 |
||
2573 |
self activityNotification:'compiling (stc)'. |
|
2574 |
ok := OperatingSystem |
|
2575 |
executeCommand:command |
|
2576 |
inputFrom:nil |
|
2577 |
outputTo:errorStream |
|
2578 |
errorTo:errorStream |
|
2579 |
onError:[:stat| |
|
2580 |
status := stat. |
|
2581 |
false |
|
2582 |
]. |
|
2583 |
||
2584 |
cFileName asFilename exists ifTrue:[ |
|
2585 |
ok ifFalse:[ |
|
2586 |
'Compiler [info]: oops - system says it failed - but c-file is there ...' infoPrintCR. |
|
2587 |
ok := true |
|
2588 |
] |
|
2589 |
] ifFalse:[ |
|
2590 |
ok := false |
|
2591 |
]. |
|
2592 |
||
2593 |
ok ifTrue:[ |
|
2594 |
"/ now compile to machine code |
|
2595 |
||
2596 |
command := ccPath , ' ' , cFlags , ' -c ' , cFileName. |
|
2597 |
Verbose == true ifTrue:[ |
|
2598 |
'executing: ' infoPrint. command infoPrintCR. |
|
2599 |
]. |
|
2600 |
self activityNotification:'compiling (' , ccPath , ')'. |
|
2601 |
ok := OperatingSystem |
|
2602 |
executeCommand:command |
|
2603 |
inputFrom:nil |
|
2604 |
outputTo:errorStream |
|
2605 |
errorTo:errorStream |
|
2606 |
onError:[:stat| |
|
2607 |
status := stat. |
|
2608 |
false |
|
2609 |
]. |
|
2610 |
||
2611 |
oFileName asFilename exists ifTrue:[ |
|
2612 |
ok ifFalse:[ |
|
2613 |
'Compiler [info]: system says it failed - but o-file is there ...' infoPrintCR. |
|
2614 |
ok := true |
|
2615 |
] |
|
2616 |
] ifFalse:[ |
|
2617 |
ok := false |
|
2618 |
]. |
|
2619 |
||
2620 |
"for debugging - leave c intermediate" |
|
2621 |
STCKeepCIntermediate == true ifFalse:[ |
|
2622 |
OperatingSystem removeFile:cFileName. |
|
2623 |
]. |
|
2624 |
]. |
|
2625 |
||
2626 |
ok ifFalse:[ |
|
2627 |
(status notNil and:[status couldNotExecute]) ifTrue:[ |
|
2628 |
eMsg := 'oops, no STC - cannot create machine code' |
|
2629 |
] ifFalse:[ |
|
2630 |
errorStream := 'errorOutput' asFilename readStream. |
|
2631 |
errorStream notNil ifTrue:[ |
|
2632 |
errorMessages := errorStream contents. |
|
2633 |
errorStream close. |
|
2634 |
errorMessages notNil ifTrue:[ |
|
2635 |
errorMessages := errorMessages asStringCollection. |
|
2636 |
errorMessages size > 20 ifTrue:[ |
|
2637 |
errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped' |
|
2638 |
]. |
|
407 | 2639 |
"/ errorMessages := errorMessages collect:[:line | |
2640 |
"/ (line startsWith:(stFileName , ':')) ifTrue:[ |
|
2641 |
"/ 'Line: ' , (line copyFrom:(stFileName size + 2)) |
|
2642 |
"/ ] ifFalse:[ |
|
2643 |
"/ line |
|
2644 |
"/ ] |
|
2645 |
"/ ]. |
|
758 | 2646 |
errorMessages := errorMessages asString |
2647 |
]. |
|
2648 |
]. |
|
2649 |
errorMessages isNil ifTrue:[ |
|
2650 |
errorMessages := '' |
|
2651 |
]. |
|
2652 |
errorMessages isEmpty ifTrue:[ |
|
2653 |
eMsg := 'STC / CC error during compilation:\\unspecified error' |
|
2654 |
] ifFalse:[ |
|
2655 |
eMsg := 'STC / CC error during compilation:\\',errorMessages |
|
2656 |
]. |
|
2657 |
eMsg := eMsg withCRs |
|
2658 |
]. |
|
2659 |
OperatingSystem removeFile:'errorOutput'. |
|
2660 |
self activityNotification:'compilation failed'. |
|
2661 |
self parseError:eMsg position:1. |
|
2662 |
||
2663 |
STCKeepOIntermediate == true ifFalse:[ |
|
2664 |
OperatingSystem removeFile:oFileName. |
|
2665 |
]. |
|
2666 |
self activityNotification:''. |
|
2667 |
^ #Error |
|
2668 |
]. |
|
2669 |
||
2670 |
self activityNotification:''. |
|
2671 |
OperatingSystem removeFile:'errorOutput'. |
|
2672 |
||
2673 |
" |
|
2674 |
if required, make a shared or otherwise loadable object file for it |
|
2675 |
" |
|
2676 |
self activityNotification:'linking'. |
|
2677 |
oFileName := ObjectFileLoader createLoadableObjectFor:initName. |
|
2678 |
oFileName isNil ifTrue:[ |
|
2679 |
"/ something went wrong |
|
2680 |
self parseError:(ObjectFileLoader lastError) position:1. |
|
2681 |
^ #CannotLoad |
|
2682 |
]. |
|
2683 |
||
2684 |
oFileName asFilename exists ifFalse:[ |
|
2685 |
OperatingSystem removeFile:oFileName. |
|
2686 |
self parseError:'link failed - cannot create machine code' position:1. |
|
2687 |
^ #CannotLoad |
|
2688 |
]. |
|
2689 |
||
2690 |
" |
|
2691 |
move it into the modules directory |
|
2692 |
" |
|
2693 |
||
2694 |
moduleFileName := (STCModulePath asFilename construct:(initName , '.' , (oFileName asFilename suffix))) name. |
|
2695 |
oFileName asFilename moveTo:moduleFileName. |
|
2696 |
(moduleFileName asFilename exists |
|
2697 |
and:[moduleFileName asFilename isReadable]) ifFalse:[ |
|
2698 |
OperatingSystem removeFile:oFileName. |
|
2699 |
self parseError:'link failed - cannot move shared library module to ''modules'' directory' position:1. |
|
2700 |
^ #CannotLoad |
|
2701 |
]. |
|
2702 |
oFileName := moduleFileName. |
|
2703 |
||
2704 |
" |
|
2705 |
load the objectfile |
|
2706 |
" |
|
2707 |
self activityNotification:'loading'. |
|
2708 |
handle := ObjectFileLoader loadDynamicObject:moduleFileName. |
|
2709 |
handle isNil ifTrue:[ |
|
2710 |
OperatingSystem removeFile:moduleFileName. |
|
2711 |
self parseError:'dynamic load failed - cannot create machine code' position:1. |
|
2712 |
^ #CannotLoad |
|
2713 |
]. |
|
407 | 2714 |
"/ ('handle is ' , handle printString) infoPrintCR. |
2715 |
||
758 | 2716 |
"/ try libs to resolve symbols. |
2717 |
address := ObjectFileLoader getFunction:'__' , initName , '_Init' from:handle. |
|
2718 |
address isNil ifTrue:[ |
|
2719 |
address := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
|
2720 |
address isNil ifTrue:[ |
|
2721 |
(ObjectFileLoader hasUndefinedSymbolsIn:handle) ifTrue:[ |
|
2722 |
ObjectFileLoader searchedLibraries do:[:libName | |
|
2723 |
(ObjectFileLoader hasUndefinedSymbolsIn:handle) ifTrue:[ |
|
2724 |
Transcript showCR:' ... trying ' , libName , ' to resolve undefined symbols ...'. |
|
2725 |
dummyHandle := Array new:4. |
|
2726 |
dummyHandle := ObjectFileLoader primLoadDynamicObject:libName into:dummyHandle. |
|
2727 |
dummyHandle isNil ifTrue:[ |
|
2728 |
Transcript showCR:' ... load of library ' , libName , ' failed.'. |
|
2729 |
] |
|
2730 |
] |
|
2731 |
]. |
|
2732 |
(ObjectFileLoader hasUndefinedSymbolsIn:handle) isNil ifTrue:[ |
|
2733 |
Transcript showCR:('LOADER: still undefined symbols in ',initName,'.'). |
|
2734 |
]. |
|
2735 |
]. |
|
2736 |
||
2737 |
] |
|
2738 |
]. |
|
2739 |
||
2740 |
address := ObjectFileLoader getFunction:'__' , initName , '_Init' from:handle. |
|
2741 |
address isNil ifTrue:[ |
|
2742 |
address := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
|
2743 |
address isNil ifTrue:[ |
|
2744 |
(ObjectFileLoader getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[ |
|
2745 |
ObjectFileLoader listUndefinedSymbolsIn:handle. |
|
2746 |
eMsg := 'undefined symbols in primitive code'. |
|
2747 |
] ifFalse:[ |
|
2748 |
eMsg := initName , '_Init() lookup failed' |
|
2749 |
]. |
|
2750 |
||
2751 |
ObjectFileLoader unloadDynamicObject:handle. |
|
599
9eaffb06df33
#createLoadableObjectFor: has been moved into ObjectFileLoader.
Stefan Vogel <sv@exept.de>
parents:
594
diff
changeset
|
2752 |
|
704 | 2753 |
"/ OperatingSystem getSystemType = 'osf' ifTrue:[ |
2754 |
"/ OperatingSystem executeCommand:('nm -u ' , moduleFileName) |
|
2755 |
"/ ]. |
|
2756 |
||
758 | 2757 |
OperatingSystem removeFile:moduleFileName. |
2758 |
self parseError:(eMsg , ' - cannot create machine code') position:1. |
|
2759 |
^ #CannotLoad |
|
2760 |
] |
|
2761 |
]. |
|
407 | 2762 |
|
2763 |
"/ ('init at ' , address printString) infoPrintCR. |
|
2764 |
||
758 | 2765 |
m := ObjectFileLoader |
2766 |
callInitFunctionAt:address |
|
2767 |
specialInit:true |
|
2768 |
forceOld:true |
|
2769 |
interruptable:false |
|
2770 |
argument:2 |
|
2771 |
identifyAs:handle |
|
2772 |
returnsObject:true. |
|
2773 |
||
2774 |
" |
|
2775 |
did it work ? |
|
2776 |
" |
|
2777 |
newMethod := aClass compiledMethodAt:selector. |
|
2778 |
newMethod notNil ifTrue:[ |
|
2779 |
m ~~ newMethod ifTrue:[ |
|
2780 |
'Compiler [warning]: loaded method installed itself in another class' errorPrintCR. |
|
2781 |
]. |
|
2782 |
||
2783 |
newMethod source:aString string. |
|
2784 |
newMethod package:(Class packageQuerySignal raise). |
|
415 | 2785 |
"/ Project notNil ifTrue:[ |
2786 |
"/ newMethod package:(Project currentPackageName) |
|
2787 |
"/ ]. |
|
407 | 2788 |
|
2789 |
"/ aClass updateRevisionString. |
|
758 | 2790 |
aClass addChangeRecordForMethod:newMethod. |
2791 |
(silent or:[Smalltalk silentLoading == true]) ifFalse:[ |
|
2792 |
Transcript showCR:(' compiled: ', className,' ',selector,' - machine code') |
|
2793 |
]. |
|
2794 |
ObjectMemory flushCaches. |
|
2795 |
||
2796 |
handle method:newMethod. |
|
2797 |
||
2798 |
"/ check for obsolete loaded objects and unload them |
|
2799 |
||
2800 |
ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle | |
|
2801 |
anotherHandle isMethodHandle ifTrue:[ |
|
2802 |
anotherHandle method isNil ifTrue:[ |
|
2803 |
ObjectFileLoader unloadObjectFile:anotherHandle pathName. |
|
2804 |
OperatingSystem removeFile:anotherHandle pathName. |
|
2805 |
] |
|
2806 |
] |
|
2807 |
]. |
|
2808 |
^ newMethod. |
|
2809 |
]. |
|
2810 |
||
2811 |
OperatingSystem removeFile:moduleFileName. |
|
2812 |
self parseError:'dynamic load failed' position:1. |
|
2813 |
^ #CannotLoad |
|
407 | 2814 |
] valueNowOrOnUnwindDo:[ |
758 | 2815 |
STCKeepSTIntermediate ifFalse:[ |
2816 |
OperatingSystem removeFile:stFileName. |
|
2817 |
]. |
|
407 | 2818 |
]. |
49 | 2819 |
|
2820 |
" |
|
2821 |
|m| |
|
2822 |
||
2823 |
Object subclass:#Test |
|
758 | 2824 |
instanceVariableNames:'' |
2825 |
classVariableNames:'' |
|
2826 |
poolDictionaries:'' |
|
2827 |
category:'tests'. |
|
49 | 2828 |
m := ByteCodeCompiler |
758 | 2829 |
compile:'foo ^ ''hello''' |
2830 |
forClass:Test |
|
2831 |
inCategory:'tests' |
|
2832 |
notifying:nil |
|
2833 |
install:false |
|
2834 |
skipIfSame:false. |
|
49 | 2835 |
m inspect |
2836 |
" |
|
2837 |
" |
|
2838 |
|m| |
|
2839 |
||
2840 |
Object subclass:#Test |
|
758 | 2841 |
instanceVariableNames:'' |
2842 |
classVariableNames:'' |
|
2843 |
poolDictionaries:'' |
|
2844 |
category:'tests'. |
|
49 | 2845 |
m := ByteCodeCompiler |
758 | 2846 |
compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}' |
2847 |
forClass:Test |
|
2848 |
inCategory:'tests' |
|
2849 |
notifying:nil |
|
2850 |
install:false |
|
2851 |
skipIfSame:false |
|
2852 |
silent:false. |
|
49 | 2853 |
m inspect |
2854 |
" |
|
120 | 2855 |
|
723
188be048b0b2
when generating machine code,
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
2856 |
"Modified: / 14.9.1995 / 22:33:04 / claus" |
188be048b0b2
when generating machine code,
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
2857 |
"Modified: / 11.8.1997 / 12:25:49 / stefan" |
751 | 2858 |
"Modified: / 3.8.1998 / 16:52:42 / cg" |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2859 |
! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2860 |
|
97 | 2861 |
trappingStubMethodFor:aString inCategory:cat |
2862 |
"return a stub method which traps and reports an error whenever |
|
2863 |
called." |
|
2864 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2865 |
|newMethod| |
97 | 2866 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2867 |
newMethod := Method new:(litArray size). |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2868 |
litArray notNil ifTrue:[ |
742
73b6a9c187f3
ask ObjectFileLoader for objectFile extension
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2869 |
newMethod literals:litArray |
97 | 2870 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2871 |
|
124 | 2872 |
newMethod makeUncompiled. |
594
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2873 |
newMethod numberOfVars:(self numberOfMethodVars). |
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2874 |
newMethod numberOfArgs:(self numberOfMethodArgs). |
682 | 2875 |
newMethod source:aString string. |
97 | 2876 |
newMethod category:cat. |
415 | 2877 |
newMethod package:(Class packageQuerySignal raise). |
2878 |
"/ Project notNil ifTrue:[ |
|
2879 |
"/ newMethod package:(Project currentPackageName) |
|
2880 |
"/ ]. |
|
97 | 2881 |
^ newMethod |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2882 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2883 |
"Modified: 24.6.1996 / 12:28:24 / stefan" |
594
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2884 |
"Modified: 1.8.1997 / 00:27:32 / cg" |
49 | 2885 |
! ! |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2886 |
|
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2887 |
!ByteCodeCompiler methodsFor:'queries'! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2888 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2889 |
numberOfTempVars |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2890 |
"return the number of additional temporary variables which |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2891 |
were created from inlined blocks (valid after parsing)" |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2892 |
|
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2893 |
^ maxNumTemp ? 0 |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2894 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2895 |
"Created: 25.6.1997 / 13:54:29 / cg" |
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2896 |
"Modified: 25.6.1997 / 15:21:34 / cg" |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2897 |
! ! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2898 |
|
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
2899 |
!ByteCodeCompiler class methodsFor:'documentation'! |
148 | 2900 |
|
2901 |
version |
|
758 | 2902 |
^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.140 1998-08-13 11:51:05 cg Exp $' |
148 | 2903 |
! ! |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2904 |
ByteCodeCompiler initialize! |