author | Claus Gittinger <cg@exept.de> |
Mon, 17 Jul 2006 13:34:14 +0200 | |
changeset 1777 | 242e89fa2170 |
parent 1680 | 6ba154c6ae8f |
child 1899 | 434971573b92 |
permissions | -rw-r--r-- |
1669 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
4 |
All Rights Reserved |
|
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
13 |
||
14 |
"{ Package: 'stx:libcomp' }" |
|
15 |
||
16 |
Object subclass:#STCCompilerInterface |
|
17 |
instanceVariableNames:'originator parserFlags' |
|
18 |
classVariableNames:'SequenceNumber Verbose' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler' |
|
21 |
! |
|
22 |
||
23 |
!STCCompilerInterface class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
28 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
a refactored complex method - originally found in ByteCodeCompiler. |
|
43 |
" |
|
44 |
! ! |
|
45 |
||
46 |
!STCCompilerInterface class methodsFor:'accessing'! |
|
47 |
||
48 |
stcPathOf:command |
|
49 |
"return the path to an stc command, or nil if not found." |
|
50 |
||
51 |
|f d reqdSuffix cmd| |
|
52 |
||
53 |
"/ |
|
54 |
"/ care for executable suffix |
|
55 |
"/ |
|
56 |
cmd := command. |
|
57 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
58 |
reqdSuffix := 'exe' |
|
59 |
] ifFalse:[ |
|
60 |
OperatingSystem isVMSlike ifTrue:[ |
|
61 |
reqdSuffix := 'EXE' |
|
62 |
]. |
|
63 |
]. |
|
64 |
reqdSuffix notNil ifTrue:[ |
|
65 |
(f := cmd asFilename) suffix isEmpty ifTrue:[ |
|
66 |
cmd := (f withSuffix:reqdSuffix) name |
|
67 |
] |
|
68 |
]. |
|
69 |
"/ |
|
70 |
"/ for our convenience, also check in current |
|
71 |
"/ and parent directories; even if PATH does not |
|
72 |
"/ include them ... |
|
73 |
"/ |
|
74 |
"/ look in current ... |
|
75 |
d := Filename currentDirectory. |
|
76 |
(f := d construct:cmd) isExecutable ifTrue:[ |
|
77 |
^ f pathName |
|
78 |
]. |
|
79 |
"/ look in ../stc ... |
|
80 |
d := d construct:'..'. |
|
81 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
82 |
^ f pathName |
|
83 |
]. |
|
84 |
"/ look in ../../stc ... |
|
85 |
d := d construct:'..'. |
|
86 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
87 |
^ f pathName |
|
88 |
]. |
|
89 |
||
90 |
"/ |
|
91 |
"/ ok, stc must be installed in some directory along the PATH |
|
92 |
"/ |
|
93 |
^ OperatingSystem pathOfCommand:command |
|
94 |
||
95 |
" |
|
96 |
STCCompilerInterface stcPathOf:'stc' |
|
97 |
" |
|
98 |
||
99 |
"Created: 13.9.1995 / 14:37:16 / claus" |
|
100 |
! ! |
|
101 |
||
102 |
!STCCompilerInterface class methodsFor:'class initialization'! |
|
103 |
||
104 |
initialize |
|
105 |
Verbose := false. |
|
106 |
! ! |
|
107 |
||
108 |
!STCCompilerInterface methodsFor:'accessing'! |
|
109 |
||
110 |
incrementalStcPath |
|
111 |
"return the path to the stc command for incremental method compilation, |
|
112 |
or nil if not found." |
|
113 |
||
114 |
|f cmd| |
|
115 |
||
116 |
(cmd := parserFlags stcPath) isEmptyOrNil ifTrue:[ |
|
117 |
(f := self class stcPathOf:'stc') notNil ifTrue:[ |
|
118 |
cmd := f |
|
119 |
] ifFalse:[ |
|
120 |
cmd := self class stcPathOf:'demostc' |
|
121 |
] |
|
122 |
]. |
|
123 |
(cmd notNil and:[cmd includes:Character space]) ifTrue:[ |
|
124 |
cmd := '"' , cmd , '"'. |
|
125 |
]. |
|
126 |
^ cmd |
|
127 |
||
128 |
"Created: 13.9.1995 / 14:36:36 / claus" |
|
129 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
|
130 |
! |
|
131 |
||
132 |
originator:something |
|
133 |
originator := something. |
|
134 |
! |
|
135 |
||
136 |
parserFlags:something |
|
137 |
parserFlags := something. |
|
138 |
! ! |
|
139 |
||
140 |
!STCCompilerInterface methodsFor:'machine code generation'! |
|
141 |
||
142 |
compileToMachineCode:aString forClass:aClass selector:selector inCategory:cat |
|
143 |
notifying:requestor install:install skipIfSame:skipIfSame silent:silent |
|
144 |
"this is called to compile primitive code. |
|
145 |
This is EXPERIMENTAL and going to be changed to raise an error, |
|
146 |
an redefined in subclasses which can do it (either by direct compilation, or by calling |
|
147 |
the external stc do do it. |
|
148 |
For a description of the arguments, see compile:forClass....." |
|
149 |
||
150 |
|stFileName stream handle stcFlags cFlags def |
|
151 |
command oFileName cFileName |
|
152 |
initName oldMethod newMethod ok status className sep class stcPath ccPath |
|
1670 | 153 |
errorStream errorMessages eMsg moduleFileName |
154 |
mapFileName libFileName pkg libDir incDir incDirArg| |
|
1669 | 155 |
|
156 |
install ifFalse:[ |
|
157 |
"/ cannot do it uninstalled. reason: |
|
158 |
"/ if it is loaded twice, the first version could be unloaded by |
|
159 |
"/ finalization, which would also unload the second version |
|
160 |
"/ (because the first unload would unload the second version too) |
|
161 |
^ #CannotLoad |
|
162 |
]. |
|
163 |
||
1670 | 164 |
self ensureModuleDirectoryExists. |
1669 | 165 |
|
166 |
ObjectFileLoader isNil ifTrue:[^ #CannotLoad]. |
|
167 |
parserFlags stcCompilation == #never ifTrue:[^ #CannotLoad]. |
|
1670 | 168 |
|
1669 | 169 |
(stcPath := self incrementalStcPath) isNil ifTrue:[ |
170 |
originator parseError:'no stc compiler available - cannot create machine code' position:1. |
|
171 |
^ #CannotLoad |
|
172 |
]. |
|
173 |
(ccPath := parserFlags ccPath) isNil ifTrue:[ |
|
174 |
originator parseError:'no cc compiler available - cannot create machine code' position:1. |
|
175 |
^ #CannotLoad |
|
176 |
]. |
|
177 |
||
178 |
(ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[ |
|
179 |
originator parseError:'no dynamic loader configured - cannot create machine code' position:1. |
|
180 |
^ #CannotLoad |
|
181 |
]. |
|
182 |
||
1670 | 183 |
class := aClass theNonMetaclass. |
184 |
self ensureSuperClassesAreLoadedOf:class. |
|
185 |
class privateClassesSorted do:[:aPrivateClass | |
|
186 |
self ensureSuperClassesAreLoadedOf:aPrivateClass. |
|
187 |
]. |
|
188 |
||
1669 | 189 |
"/ generate a unique name, consisting of my processID and a sequence number |
190 |
"/ the processId is added to allow filein of modules from different |
|
191 |
"/ lifes |
|
192 |
||
193 |
SequenceNumber := (SequenceNumber ? 0) + 1. |
|
194 |
||
195 |
initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString. |
|
196 |
||
197 |
stFileName := (Filename currentDirectory construct:(initName , '.st')) name. |
|
198 |
[ |
|
199 |
stream := stFileName asFilename writeStream. |
|
200 |
] on:FileStream openErrorSignal do:[:ex| |
|
201 |
originator parseError:'cannot create temporary sourcefile for compilation'. |
|
202 |
^ #CannotLoad |
|
203 |
]. |
|
204 |
||
205 |
[ |
|
206 |
|definedClasses| |
|
207 |
||
208 |
definedClasses := IdentitySet new. |
|
209 |
||
210 |
sep := stream class chunkSeparator. |
|
211 |
||
212 |
Class fileOutNameSpaceQuerySignal answer:true |
|
213 |
do:[ |
|
1670 | 214 |
self |
215 |
fileOutAllDefinitionsOf:class |
|
216 |
to:stream |
|
217 |
rememberIn:definedClasses. |
|
1669 | 218 |
|
219 |
class privateClassesSorted do:[:aPrivateClass | |
|
1670 | 220 |
self |
221 |
fileOutAllDefinitionsOf:aPrivateClass |
|
222 |
to:stream |
|
223 |
rememberIn:definedClasses. |
|
1669 | 224 |
]. |
225 |
class fileOutPrimitiveDefinitionsOn:stream. |
|
226 |
]. |
|
227 |
||
228 |
(aClass isNil or:[parserFlags allowExtensionsToPrivateClasses or:[aClass owningClass isNil]]) ifTrue:[ |
|
229 |
(requestor respondsTo:#packageToInstall) ifFalse:[ |
|
230 |
pkg := Class packageQuerySignal query. |
|
231 |
] ifTrue:[ |
|
232 |
pkg := requestor packageToInstall |
|
233 |
]. |
|
234 |
] ifFalse:[ |
|
235 |
pkg := aClass owningClass package |
|
236 |
]. |
|
237 |
false ifTrue:[ |
|
238 |
stream cr. |
|
239 |
stream nextPutLine:'"{ Package: ''' , pkg , ''' }"'. |
|
240 |
stream cr. |
|
241 |
]. |
|
242 |
||
243 |
stream nextPut:sep. |
|
244 |
className := class name. |
|
245 |
||
246 |
stream nextPutAll:className. |
|
247 |
aClass isMeta ifTrue:[ |
|
248 |
stream nextPutAll:' class'. |
|
249 |
]. |
|
250 |
stream nextPutAll:' methodsFor:'''; nextPutAll:cat; nextPutAll:''''. |
|
251 |
stream nextPut:sep; cr. |
|
252 |
||
253 |
stream nextPutLine:'"{ Line: 0 }"'; |
|
254 |
nextChunkPut:aString; |
|
255 |
space; nextPut:sep. |
|
256 |
||
257 |
stream close. |
|
258 |
||
259 |
" |
|
260 |
call stc to compile it |
|
261 |
" |
|
262 |
oFileName := stFileName asFilename withoutSuffix name , (ObjectFileLoader objectFileExtension). |
|
263 |
cFileName := (stFileName asFilename withSuffix:'c') name. |
|
264 |
mapFileName := (stFileName asFilename withSuffix:'map') name. |
|
265 |
libFileName := (stFileName asFilename withSuffix:'lib') name. |
|
266 |
oFileName asFilename delete. |
|
267 |
cFileName asFilename delete. |
|
268 |
||
269 |
"/ stcFlags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName . |
|
270 |
stcFlags := '+newIncremental -E:errorOutput -N' , initName . |
|
271 |
cFlags := OperatingSystem getOSDefine. |
|
272 |
cFlags isNil ifTrue:[ |
|
273 |
cFlags := '' |
|
274 |
]. |
|
275 |
(def := OperatingSystem getCPUDefine) notNil ifTrue:[ |
|
276 |
cFlags := cFlags , ' ' , def |
|
277 |
]. |
|
278 |
||
279 |
parserFlags stcCompilationDefines notNil ifTrue:[ |
|
280 |
cFlags := cFlags , ' ' , parserFlags stcCompilationDefines |
|
281 |
]. |
|
282 |
parserFlags stcCompilationIncludes notNil ifTrue:[ |
|
283 |
stcFlags := parserFlags stcCompilationIncludes , ' ' , stcFlags. |
|
284 |
cFlags := cFlags , ' ' , parserFlags stcCompilationIncludes. |
|
285 |
||
286 |
"/ if STX_LIBDIR is defined, and not in passed argument, |
|
287 |
"/ add it here. |
|
288 |
||
289 |
libDir := OperatingSystem getEnvironment:'STX_LIBDIR'. |
|
290 |
(libDir notNil and:[libDir asFilename exists]) ifTrue:[ |
|
291 |
incDir := libDir asFilename construct:'include'. |
|
292 |
incDir exists ifTrue:[ |
|
293 |
incDirArg := '-I' , incDir pathName. |
|
294 |
(parserFlags stcCompilationIncludes asCollectionOfWords includes:incDirArg) ifFalse:[ |
|
295 |
stcFlags := stcFlags , ' ' , incDirArg. |
|
296 |
cFlags := cFlags , ' ' , incDirArg. |
|
297 |
] |
|
298 |
] |
|
299 |
]. |
|
300 |
]. |
|
301 |
parserFlags stcCompilationOptions notNil ifTrue:[ |
|
302 |
stcFlags := parserFlags stcCompilationOptions , ' ' , stcFlags |
|
303 |
]. |
|
304 |
parserFlags ccCompilationOptions notNil ifTrue:[ |
|
305 |
cFlags := cFlags , ' ' , parserFlags ccCompilationOptions |
|
306 |
]. |
|
307 |
||
308 |
command := stcPath , ' ' , stcFlags , ' -C ' , stFileName. |
|
309 |
||
310 |
Verbose == true ifTrue:[ |
|
311 |
'executing: ' infoPrint. command infoPrintCR. |
|
312 |
]. |
|
313 |
errorStream := 'errorOutput' asFilename writeStream. |
|
314 |
||
315 |
originator activityNotification:'compiling (stc)'. |
|
316 |
ok := OperatingSystem |
|
317 |
executeCommand:command |
|
318 |
inputFrom:nil |
|
319 |
outputTo:errorStream |
|
320 |
errorTo:errorStream |
|
321 |
onError:[:stat| |
|
322 |
status := stat. |
|
323 |
false |
|
324 |
]. |
|
325 |
||
326 |
cFileName asFilename exists ifTrue:[ |
|
327 |
ok ifFalse:[ |
|
328 |
'Compiler [info]: oops - system says stc failed - but c-file is there ...' infoPrintCR. |
|
329 |
ok := true |
|
330 |
] |
|
331 |
] ifFalse:[ |
|
332 |
ok ifTrue:[ |
|
333 |
'Compiler [info]: oops - system says stc ok - but no c-file is there ...' infoPrintCR. |
|
334 |
]. |
|
335 |
ok := false |
|
336 |
]. |
|
337 |
||
338 |
ok ifTrue:[ |
|
339 |
"/ now compile to machine code |
|
340 |
||
341 |
command := ccPath , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -c ' , cFileName. |
|
342 |
Verbose == true ifTrue:[ |
|
343 |
'executing: ' infoPrint. command infoPrintCR. |
|
344 |
]. |
|
345 |
originator activityNotification:'compiling (' , ccPath , ')'. |
|
346 |
ok := OperatingSystem |
|
347 |
executeCommand:command |
|
348 |
inputFrom:nil |
|
349 |
outputTo:errorStream |
|
350 |
errorTo:errorStream |
|
351 |
onError:[:stat| |
|
352 |
status := stat. |
|
353 |
false |
|
354 |
]. |
|
355 |
||
356 |
oFileName asFilename exists ifTrue:[ |
|
357 |
ok ifFalse:[ |
|
358 |
'Compiler [info]: system says compile failed - but o-file is there ...' infoPrintCR. |
|
359 |
ok := true |
|
360 |
] |
|
361 |
] ifFalse:[ |
|
362 |
ok ifTrue:[ |
|
363 |
'Compiler [info]: system says compile ok - but no o-file is there ...' infoPrintCR. |
|
364 |
]. |
|
365 |
ok := false |
|
366 |
]. |
|
367 |
]. |
|
368 |
||
369 |
ok ifFalse:[ |
|
370 |
(status notNil and:[status couldNotExecute]) ifTrue:[ |
|
371 |
eMsg := 'oops, no STC - cannot create machine code' |
|
372 |
] ifFalse:[ |
|
373 |
errorMessages := 'errorOutput' asFilename contents. |
|
374 |
errorMessages notNil ifTrue:[ |
|
375 |
errorMessages size > 20 ifTrue:[ |
|
1680
6ba154c6ae8f
filter warnings in shown error dialog
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
376 |
errorMessages := errorMessages select:[:line | line asLowercase startsWith:'error']. |
6ba154c6ae8f
filter warnings in shown error dialog
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
377 |
errorMessages size > 20 ifTrue:[ |
1669 | 378 |
errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped' |
1680
6ba154c6ae8f
filter warnings in shown error dialog
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
379 |
]. |
1669 | 380 |
]. |
381 |
"/ errorMessages := errorMessages collect:[:line | |
|
382 |
"/ (line startsWith:(stFileName , ':')) ifTrue:[ |
|
383 |
"/ 'Line: ' , (line copyFrom:(stFileName size + 2)) |
|
384 |
"/ ] ifFalse:[ |
|
385 |
"/ line |
|
386 |
"/ ] |
|
387 |
"/ ]. |
|
388 |
errorMessages := errorMessages asString |
|
389 |
]. |
|
390 |
errorMessages isNil ifTrue:[ |
|
391 |
errorMessages := '' |
|
392 |
]. |
|
393 |
errorMessages isEmpty ifTrue:[ |
|
394 |
eMsg := 'STC / CC error during compilation:\\unspecified error' withCRs |
|
395 |
] ifFalse:[ |
|
396 |
eMsg := 'STC / CC error during compilation:\\'withCRs,errorMessages |
|
397 |
]. |
|
398 |
"/ eMsg := eMsg withCRs |
|
399 |
]. |
|
400 |
originator activityNotification:'compilation failed'. |
|
401 |
originator parseError:eMsg position:1. |
|
402 |
||
403 |
originator activityNotification:''. |
|
404 |
^ #Error |
|
405 |
]. |
|
406 |
||
407 |
originator activityNotification:''. |
|
408 |
OperatingSystem removeFile:'errorOutput'. |
|
409 |
||
410 |
" |
|
411 |
if required, make a shared or otherwise loadable object file for it |
|
412 |
" |
|
413 |
originator activityNotification:'linking'. |
|
414 |
||
415 |
oFileName := ObjectFileLoader createLoadableObjectFor:initName. |
|
416 |
oFileName isNil ifTrue:[ |
|
417 |
"/ something went wrong |
|
418 |
originator parseError:('link error: ' , ObjectFileLoader lastError) position:1. |
|
419 |
^ #CannotLoad |
|
420 |
]. |
|
421 |
oFileName asFilename exists ifFalse:[ |
|
422 |
originator parseError:'link failed - cannot create machine code' position:1. |
|
423 |
^ #CannotLoad |
|
424 |
]. |
|
425 |
||
426 |
" |
|
427 |
move it into the modules directory |
|
428 |
" |
|
429 |
moduleFileName := (parserFlags stcModulePath asFilename construct:(initName , '.' , (oFileName asFilename suffix))) name. |
|
430 |
oFileName asFilename moveTo:moduleFileName. |
|
431 |
(moduleFileName asFilename exists |
|
432 |
and:[moduleFileName asFilename isReadable]) ifFalse:[ |
|
433 |
originator parseError:'link failed - cannot move shared library module to ''modules'' directory' position:1. |
|
434 |
^ #CannotLoad |
|
435 |
]. |
|
436 |
||
437 |
oldMethod := aClass compiledMethodAt:selector. |
|
438 |
oldMethod notNil ifTrue:[pkg := oldMethod package]. |
|
439 |
||
440 |
" |
|
441 |
load the method objectfile |
|
442 |
" |
|
443 |
originator activityNotification:'loading'. |
|
444 |
||
445 |
handle := ObjectFileLoader loadMethodObjectFile:moduleFileName. |
|
446 |
handle isNil ifTrue:[ |
|
447 |
OperatingSystem removeFile:moduleFileName. |
|
448 |
originator parseError:'dynamic load of machine code failed' position:1. |
|
449 |
^ #CannotLoad |
|
450 |
]. |
|
451 |
||
452 |
" |
|
453 |
did it work ? |
|
454 |
" |
|
455 |
newMethod := aClass compiledMethodAt:selector. |
|
456 |
||
457 |
"/ if install is false, we have to undo the install (which is always done, when loading machine code) |
|
458 |
install ifFalse:[ |
|
459 |
oldMethod isNil ifTrue:[ |
|
460 |
aClass removeSelector:selector |
|
461 |
] ifFalse:[ |
|
462 |
newMethod setPackage:oldMethod package. |
|
463 |
aClass addSelector:selector withMethod:oldMethod. |
|
464 |
oldMethod setPackage:pkg. |
|
465 |
] |
|
466 |
]. |
|
467 |
||
468 |
newMethod notNil ifTrue:[ |
|
469 |
handle method ~~ newMethod ifTrue:[ |
|
470 |
'Compiler [warning]: loaded method installed itself in another class' errorPrintCR. |
|
471 |
]. |
|
472 |
||
473 |
newMethod source:aString string. |
|
474 |
newMethod setPackage:pkg. |
|
475 |
"/ Project notNil ifTrue:[ |
|
476 |
"/ newMethod package:(Project currentPackageName) |
|
477 |
"/ ]. |
|
478 |
||
479 |
"/ aClass updateRevisionString. |
|
480 |
install ifTrue:[ |
|
481 |
aClass addChangeRecordForMethod:newMethod fromOld:oldMethod. |
|
482 |
||
483 |
"/ kludge-sigh: must send change messages manually here (stc-loaded code does not do it) |
|
484 |
"/ see addMethod:... in ClassDescription |
|
485 |
aClass changed:#methodDictionary with:(Array with:selector with:oldMethod). |
|
486 |
Smalltalk changed:#methodInClass with:(Array with:aClass with:selector with:oldMethod). |
|
487 |
]. |
|
488 |
||
489 |
(silent or:[Smalltalk silentLoading == true]) ifFalse:[ |
|
490 |
Transcript showCR:(' compiled: ', className,' ',selector,' - machine code') |
|
491 |
]. |
|
492 |
ObjectMemory flushCaches. |
|
493 |
||
494 |
handle method:newMethod. |
|
495 |
||
496 |
"/ check for obsolete loaded objects and unload them |
|
497 |
||
498 |
ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle | |
|
499 |
anotherHandle isMethodHandle ifTrue:[ |
|
500 |
anotherHandle method isNil ifTrue:[ |
|
501 |
ObjectFileLoader unloadObjectFile:anotherHandle pathName. |
|
502 |
OperatingSystem removeFile:anotherHandle pathName. |
|
503 |
] |
|
504 |
] |
|
505 |
]. |
|
506 |
^ newMethod. |
|
507 |
]. |
|
508 |
||
509 |
OperatingSystem removeFile:moduleFileName. |
|
510 |
originator parseError:'dynamic load failed' position:1. |
|
511 |
^ #CannotLoad |
|
512 |
] ensure:[ |
|
513 |
parserFlags stcKeepSTIntermediate ifFalse:[ |
|
514 |
OperatingSystem removeFile:stFileName. |
|
515 |
OperatingSystem removeFile:'errorOutput'. |
|
516 |
]. |
|
517 |
parserFlags stcKeepOIntermediate == true ifFalse:[ |
|
518 |
(oFileName notNil and:[oFileName asFilename exists]) ifTrue:[oFileName asFilename delete]. |
|
519 |
]. |
|
520 |
parserFlags stcKeepCIntermediate == true ifFalse:[ |
|
521 |
(cFileName notNil and:[cFileName asFilename exists]) ifTrue:[cFileName asFilename delete]. |
|
522 |
]. |
|
523 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
524 |
"/ (mapFileName notNil and:[mapFileName asFilename exists]) ifTrue:[mapFileName asFilename delete]. |
|
525 |
"/ (libFileName notNil and:[libFileName asFilename exists]) ifTrue:[libFileName asFilename delete]. |
|
526 |
]. |
|
527 |
]. |
|
528 |
||
529 |
" |
|
530 |
|m| |
|
531 |
||
532 |
Object subclass:#Test |
|
533 |
instanceVariableNames:'' |
|
534 |
classVariableNames:'' |
|
535 |
poolDictionaries:'' |
|
536 |
category:'tests'. |
|
537 |
m := ByteCodeCompiler |
|
538 |
compile:'foo ^ ''hello''' |
|
539 |
forClass:Test |
|
540 |
inCategory:'tests' |
|
541 |
notifying:nil |
|
542 |
install:false |
|
543 |
skipIfSame:false. |
|
544 |
m inspect |
|
545 |
" |
|
546 |
" |
|
547 |
|m| |
|
548 |
||
549 |
Object subclass:#Test |
|
550 |
instanceVariableNames:'' |
|
551 |
classVariableNames:'' |
|
552 |
poolDictionaries:'' |
|
553 |
category:'tests'. |
|
554 |
m := ByteCodeCompiler |
|
555 |
compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}' |
|
556 |
forClass:Test |
|
557 |
inCategory:'tests' |
|
558 |
notifying:nil |
|
559 |
install:false |
|
560 |
skipIfSame:false |
|
561 |
silent:false. |
|
562 |
m inspect |
|
563 |
" |
|
564 |
||
565 |
"Modified: / 14.9.1995 / 22:33:04 / claus" |
|
566 |
"Modified: / 19.3.1999 / 08:31:42 / stefan" |
|
567 |
"Modified: / 10.11.2001 / 01:46:00 / cg" |
|
1670 | 568 |
! |
569 |
||
570 |
ensureModuleDirectoryExists |
|
571 |
|mP t s| |
|
572 |
||
573 |
(mP := parserFlags stcModulePath asFilename) exists ifFalse:[ |
|
574 |
mP makeDirectory |
|
575 |
]. |
|
576 |
(mP isDirectory and:[ mP isReadable and:[ mP isWritable ] ]) ifFalse:[ |
|
577 |
Parser::ParseError raiseErrorString:('No access to temporary module directory: ' , mP pathName). |
|
578 |
]. |
|
579 |
"/ create a small README there ... |
|
580 |
||
581 |
(t := mP construct:'README') exists ifFalse:[ |
|
582 |
s := t writeStream. |
|
583 |
s |
|
584 |
nextPutAll:'This temporary ST/X directory contains machine code for |
|
585 |
accepted methods with embedded C-code |
|
586 |
(i.e. dynamic compiled code for inline-C methods). |
|
587 |
||
588 |
Files here are not automatically removed, since ST/X |
|
589 |
cannot determine if any (other) snapshot image still |
|
590 |
requires a file here. |
|
591 |
||
592 |
Please be careful when removing files here - a snapshot |
|
593 |
image which was saved with accepted embedded C-code |
|
594 |
may not be able to restart correctly if you remove a |
|
595 |
required file. |
|
596 |
Also, when you export a snapshot image for execution |
|
597 |
on another machine, make certain that the required |
|
598 |
module-files are also present there. |
|
599 |
||
600 |
You should periodically clean dead entries here. |
|
601 |
i.e. remove files, when you are certain that none |
|
602 |
of your snapshot images refers to any module here. |
|
603 |
||
604 |
See the launchers File-Modules dialog for a list of |
|
605 |
modules which are still required by your running image. |
|
606 |
||
607 |
With kind regards - your ST/X. |
|
608 |
'. |
|
609 |
s close. |
|
610 |
]. |
|
611 |
! |
|
612 |
||
613 |
ensureSuperClassesAreLoadedOf:aClass |
|
614 |
|supers| |
|
615 |
||
616 |
supers := aClass allSuperclasses. |
|
617 |
supers reverseDo:[:cls| |
|
618 |
cls isLoaded ifFalse:[ |
|
619 |
Parser::ParseError raiseErrorString:'Cannot stc-compile (Some superclass is unloaded)'. |
|
620 |
] |
|
621 |
]. |
|
622 |
! |
|
623 |
||
624 |
fileOutAllDefinitionsOf:aClass to:aStream rememberIn:definedClasses |
|
625 |
|defineAction| |
|
626 |
||
627 |
defineAction := |
|
628 |
[:cls| |
|
629 |
(definedClasses includes:cls) ifFalse:[ |
|
630 |
cls |
|
631 |
basicFileOutDefinitionOn:aStream |
|
632 |
withNameSpace:false withPackage:false |
|
633 |
syntaxHilighting:false. |
|
634 |
||
635 |
aStream nextPut:(aStream class chunkSeparator); cr. |
|
636 |
definedClasses add:cls. |
|
637 |
]. |
|
638 |
]. |
|
639 |
||
640 |
aClass allSuperclasses reverseDo:defineAction. |
|
641 |
defineAction value:aClass. |
|
1669 | 642 |
! ! |
643 |
||
644 |
!STCCompilerInterface class methodsFor:'documentation'! |
|
645 |
||
646 |
version |
|
1680
6ba154c6ae8f
filter warnings in shown error dialog
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
647 |
^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.3 2006-02-20 09:10:05 cg Exp $' |
1669 | 648 |
! ! |
649 |
||
650 |
STCCompilerInterface initialize! |