author | Claus Gittinger <cg@exept.de> |
Wed, 01 Nov 1995 15:44:26 +0100 | |
changeset 468 | 72dfba4603b4 |
parent 457 | 41c73cbee305 |
child 477 | 8710aba7876b |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 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 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
13 |
'From Smalltalk/X, Version:2.10.8 on 29-oct-1995 at 20:01:13' ! |
453 | 14 |
|
1 | 15 |
Object subclass:#Smalltalk |
453 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'ExitBlocks CachedClasses SystemPath StartupClass StartupSelector |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
18 |
StartupArguments CachedAbbreviations SilentLoading Initializing |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
19 |
StandAlone LogDoits LoadBinaries RealSystemPath ResourcePath |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
20 |
SourcePath BitmapPath BinaryPath FileInPath' |
453 | 21 |
poolDictionaries:'' |
22 |
category:'System-Support' |
|
1 | 23 |
! |
24 |
||
70 | 25 |
!Smalltalk class methodsFor:'documentation'! |
26 |
||
95 | 27 |
version |
28 |
" |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
29 |
$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.71 1995-10-29 19:27:04 cg Exp $ |
95 | 30 |
" |
31 |
! |
|
32 |
||
70 | 33 |
documentation |
34 |
" |
|
35 |
This is one of the central classes in the system; |
|
36 |
it provides all system-startup, shutdown and maintenance support. |
|
37 |
Also global variables are kept here. |
|
38 |
||
39 |
As you will notice, this is NOT a Dictionary |
|
40 |
- my implementation of globals is totally different |
|
41 |
(due to the need to be able to access globals from c-code as well). |
|
42 |
However, it provides the known enumeration protocol. |
|
43 |
It may change to become a subclass of collection at some time ... |
|
44 |
||
45 |
Instance variables: |
|
159 | 46 |
none - all handling is done in the VM |
70 | 47 |
|
48 |
Class variables: |
|
159 | 49 |
ExitBlocks <Collection> blocks to evaluate before system is |
50 |
left. Not currently used. |
|
70 | 51 |
|
159 | 52 |
CachedClasses <Collection> known classes (cached for faster enumeration) |
70 | 53 |
|
159 | 54 |
SystemPath <Collection> path to search for system files (sources, bitmaps etc) |
70 | 55 |
|
159 | 56 |
StartupClass <Class> class, which gets initial message |
57 |
(right after VM initialization) |
|
58 |
StartupSelector <Symbol> message sent to StartupClass |
|
70 | 59 |
|
159 | 60 |
CachedAbbreviations |
61 |
<Dictionary> className to filename mappings |
|
70 | 62 |
|
159 | 63 |
SilentLoading <Boolean> suppresses messages during fileIn and in compiler |
64 |
(can be set to true from a customized main) |
|
122 | 65 |
|
159 | 66 |
LogDoits <Boolean> if true, doits are also logged in the changes |
67 |
file. Default is false, since the changes file |
|
68 |
may become huge ... |
|
329 | 69 |
|
400 | 70 |
LoadBinaries <Boolean> if true, we attempt to load classes rom a binary |
390 | 71 |
file, if present. If false, this is always suppressed. |
72 |
||
329 | 73 |
SourcePath <Collection> cached names of really existing directories |
74 |
BitmapPath These are remembered, since in NFS systems, |
|
75 |
ResourcePath the time to lookup files may become long |
|
76 |
BinaryPath (especially, if some directories are on machines |
|
77 |
FileInPath which are not up ...). Therefore, the set of really |
|
78 |
existing directories is cached when the SystemPath |
|
79 |
is walked the first time. |
|
70 | 80 |
" |
1 | 81 |
! |
82 |
||
453 | 83 |
copyright |
84 |
" |
|
85 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
86 |
All Rights Reserved |
|
87 |
||
88 |
This software is furnished under a license and may be used |
|
89 |
only in accordance with the terms of that license and with the |
|
90 |
inclusion of the above copyright notice. This software may not |
|
91 |
be provided or otherwise made available to, or used by, any |
|
92 |
other person. No title to or ownership of the software is |
|
93 |
hereby transferred. |
|
94 |
" |
|
1 | 95 |
! ! |
96 |
||
97 |
!Smalltalk class methodsFor:'initialization'! |
|
98 |
||
325 | 99 |
initializeSystem |
24 | 100 |
"initialize all other classes; setup dispatcher processes etc. |
211 | 101 |
This one is the first entry into the smalltalk world right after startup, |
102 |
ususally followed by Smalltalk>>start. |
|
103 |
Notice: this is not called when an image is restarted; in this |
|
104 |
case the show starts in Smalltalk>>restart." |
|
105 |
||
348 | 106 |
SilentLoading := false. |
107 |
Initializing := true. |
|
108 |
||
211 | 109 |
" |
110 |
define low-level debugging tools - graphical classes are not prepared yet |
|
111 |
to handle things. |
|
112 |
This will bring us into the MiniDebugger when an error occurs |
|
113 |
during startup |
|
114 |
" |
|
115 |
Inspector := MiniInspector. |
|
116 |
Debugger := MiniDebugger. |
|
1 | 117 |
|
118 |
self initGlobalsFromEnvironment. |
|
119 |
||
70 | 120 |
" |
121 |
sorry - there are some, which MUST be initialized before .. |
|
122 |
reason: if any error happens during init, we need Signals, Stdout etc. to be there |
|
123 |
" |
|
1 | 124 |
Object initialize. |
423 | 125 |
Signal initialize. |
326 | 126 |
ObjectMemory initialize. |
1 | 127 |
ExternalStream initialize. |
211 | 128 |
|
129 |
self initStandardStreams. "/ setup Stdin, Stdout etc. |
|
1 | 130 |
|
70 | 131 |
" |
132 |
sorry, path must be set before ... |
|
133 |
reason: some classes need it during initialize (they might need resources, bitmaps etc) |
|
134 |
" |
|
1 | 135 |
self initSystemPath. |
136 |
||
70 | 137 |
" |
138 |
must init display here - some classes (Color, Form) need it during initialize |
|
139 |
" |
|
1 | 140 |
Workstation notNil ifTrue:[ |
159 | 141 |
Workstation initialize |
1 | 142 |
]. |
143 |
||
144 |
Compiler := ByteCodeCompiler. |
|
145 |
Compiler isNil ifTrue:[ |
|
159 | 146 |
" |
147 |
ByteCodeCompiler is not in the system (i.e. has not been linked in) |
|
148 |
this allows at least immediate evaluations for runtime systems without compiler |
|
149 |
NOTICE: a parser is always needed, otherwise we cannot read resource files etc. |
|
150 |
" |
|
151 |
Compiler := Parser |
|
1 | 152 |
]. |
153 |
||
70 | 154 |
" |
325 | 155 |
now, finally, initialize all other classes |
70 | 156 |
" |
325 | 157 |
self initializeModules. |
158 |
||
159 |
"/ self allBehaviorsDo:[:aClass | |
|
159 | 160 |
"/ 'init ' print. aClass name printNL. |
329 | 161 |
"/ aClass initialize |
325 | 162 |
"/ ]. |
159 | 163 |
|
321 | 164 |
Display notNil ifTrue:[ |
329 | 165 |
Display initialize. |
321 | 166 |
]. |
70 | 167 |
self initInterrupts. |
325 | 168 |
self initUserPreferences. |
169 |
! |
|
1 | 170 |
|
325 | 171 |
initializeModules |
172 |
"perform module specific initialization and |
|
173 |
send #initialize to all classes. |
|
174 |
Notice: this is not called when an image is restarted" |
|
175 |
%{ |
|
176 |
init_registered_modules(3 COMMA_CON); |
|
177 |
%} |
|
1 | 178 |
! |
179 |
||
122 | 180 |
initUserPreferences |
181 |
"setup other stuff" |
|
182 |
||
390 | 183 |
LogDoits := false. |
184 |
LoadBinaries := false. |
|
122 | 185 |
! |
186 |
||
1 | 187 |
initGlobalsFromEnvironment |
188 |
"setup globals from the shell-environment" |
|
189 |
||
211 | 190 |
|envString i langString terrString| |
1 | 191 |
|
70 | 192 |
" |
193 |
extract Language and LanguageTerritory from LANG variable. |
|
1 | 194 |
the language and territory must not be abbreviated, |
211 | 195 |
valid are for example: english_usa |
196 |
english |
|
197 |
german |
|
198 |
german_austria |
|
70 | 199 |
" |
1 | 200 |
|
211 | 201 |
Language := #english. |
202 |
LanguageTerritory := #usa. |
|
203 |
||
1 | 204 |
envString := OperatingSystem getEnvironment:'LANG'. |
205 |
envString notNil ifTrue:[ |
|
159 | 206 |
i := envString indexOf:$_. |
207 |
(i == 0) ifTrue:[ |
|
208 |
langString := envString. |
|
209 |
terrString := envString |
|
210 |
] ifFalse:[ |
|
211 |
langString := envString copyTo:(i - 1). |
|
212 |
terrString := envString copyFrom:(i + 1) |
|
213 |
]. |
|
214 |
Language := langString asSymbol. |
|
215 |
LanguageTerritory := terrString asSymbol |
|
1 | 216 |
]. |
217 |
||
70 | 218 |
" |
211 | 219 |
Smalltalk initGlobalsFromEnvironment |
70 | 220 |
" |
1 | 221 |
! |
222 |
||
223 |
initStandardTools |
|
95 | 224 |
"predefine some tools which we will need later |
1 | 225 |
- if the view-classes exist, |
226 |
they will redefine Inspector and Debugger for graphical interfaces" |
|
227 |
||
228 |
"redefine debug-tools, if view-classes exist" |
|
229 |
||
95 | 230 |
Display notNil ifTrue:[ |
159 | 231 |
InspectorView notNil ifTrue:[ |
232 |
Inspector := InspectorView |
|
233 |
]. |
|
234 |
DebugView notNil ifTrue:[ |
|
235 |
Debugger := DebugView |
|
236 |
]. |
|
237 |
Display initialize |
|
1 | 238 |
] |
239 |
"Smalltalk initStandardTools" |
|
240 |
! |
|
241 |
||
242 |
initStandardStreams |
|
243 |
"initialize some well-known streams" |
|
244 |
||
245 |
Stdout := NonPositionableExternalStream forStdout. |
|
246 |
Stderr := NonPositionableExternalStream forStderr. |
|
247 |
Stdin := NonPositionableExternalStream forStdin. |
|
248 |
Printer := PrinterStream. |
|
249 |
Transcript := Stderr |
|
250 |
||
251 |
"Smalltalk initStandardStreams" |
|
252 |
! |
|
253 |
||
254 |
initInterrupts |
|
255 |
"initialize interrupts" |
|
256 |
||
257 |
OperatingSystem enableUserInterrupts. |
|
77 | 258 |
OperatingSystem enableHardSignalInterrupts. |
2 | 259 |
OperatingSystem enableFpExceptionInterrupts. |
260 |
||
261 |
ObjectMemory userInterruptHandler:self. |
|
13 | 262 |
ObjectMemory signalInterruptHandler:self. |
263 |
ObjectMemory recursionInterruptHandler:self. |
|
1 | 264 |
|
265 |
"Smalltalk initInterrupts" |
|
266 |
! |
|
267 |
||
268 |
initSystemPath |
|
70 | 269 |
"setup path where system files are searched for. |
7 | 270 |
the default path is set to: |
159 | 271 |
. |
272 |
.. |
|
273 |
$HOME (if defined) |
|
274 |
$HOME/.smalltalk (if defined & existing) |
|
275 |
$SMALLTALK_LIBDIR (if defined & existing) |
|
276 |
/usr/local/lib/smalltalk (if existing) |
|
277 |
/usr/lib/smalltalk (if existing) |
|
70 | 278 |
|
279 |
of course, it is possible to add entries from the 'smalltalk.rc' |
|
280 |
startup file; add expressions such as: |
|
159 | 281 |
Smalltalk systemPath addFirst:'/foo/bar/baz'. |
282 |
or: |
|
283 |
Smalltalk systemPath addLast:'/fee/foe/foo'. |
|
7 | 284 |
" |
1 | 285 |
|
70 | 286 |
|p homePath| |
287 |
||
288 |
homePath := OperatingSystem getHomeDirectory. |
|
443 | 289 |
homePath isNil ifTrue:[ |
290 |
homePath := '.' |
|
291 |
]. |
|
1 | 292 |
|
70 | 293 |
" |
294 |
the path is set to search files first locally |
|
295 |
- this allows private stuff to override global stuff |
|
296 |
" |
|
1 | 297 |
SystemPath := OrderedCollection new. |
298 |
SystemPath add:'.'. |
|
299 |
SystemPath add:'..'. |
|
70 | 300 |
SystemPath add:homePath. |
301 |
(OperatingSystem isDirectory:(p := homePath , '/.smalltalk')) ifTrue:[ |
|
159 | 302 |
SystemPath add:p |
1 | 303 |
]. |
304 |
p := OperatingSystem getEnvironment:'SMALLTALK_LIBDIR'. |
|
305 |
p notNil ifTrue:[ |
|
159 | 306 |
SystemPath add:p |
1 | 307 |
]. |
308 |
(OperatingSystem isDirectory:'/usr/local/lib/smalltalk') ifTrue:[ |
|
159 | 309 |
SystemPath add:'/usr/local/lib/smalltalk' |
1 | 310 |
]. |
311 |
(OperatingSystem isDirectory:'/usr/lib/smalltalk') ifTrue:[ |
|
159 | 312 |
SystemPath add:'/usr/lib/smalltalk' |
1 | 313 |
]. |
329 | 314 |
self flushPathCaches |
1 | 315 |
|
95 | 316 |
" |
317 |
Smalltalk initSystemPath |
|
318 |
Smalltalk systemPath |
|
319 |
" |
|
162 | 320 |
! |
321 |
||
322 |
isInitialized |
|
323 |
"this returns true, if the system is properly initialized; |
|
324 |
i.e. false during startup. Especially, the whole viewing stuff is |
|
325 |
not working correctly until initialized." |
|
326 |
||
327 |
^ Initializing not |
|
161 | 328 |
! ! |
329 |
||
453 | 330 |
!Smalltalk class methodsFor:'accessing'! |
331 |
||
332 |
at:aKey |
|
333 |
"retrieve the value stored under aKey, a symbol. |
|
334 |
Return nil if not present (this will be changed to trigger an error)" |
|
335 |
||
336 |
%{ /* NOCONTEXT */ |
|
337 |
extern OBJ __GLOBAL_GET(); |
|
338 |
||
339 |
RETURN ( __GLOBAL_GET(aKey) ); |
|
340 |
%} |
|
341 |
! |
|
342 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
343 |
includesKey:aKey |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
344 |
"return true, if the key is known" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
345 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
346 |
%{ /* NOCONTEXT */ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
347 |
extern OBJ __GLOBAL_KEYKNOWN(); |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
348 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
349 |
RETURN ( __GLOBAL_KEYKNOWN(aKey) ); |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
350 |
%} |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
351 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
352 |
|
453 | 353 |
at:aKey ifAbsent:aBlock |
354 |
"retrieve the value stored at aKey. |
|
355 |
If there is nothing stored under this key, return the value of |
|
356 |
the evaluation of aBlock." |
|
357 |
||
358 |
(self includesKey:aKey) ifTrue:[ |
|
359 |
^ self at:aKey |
|
360 |
]. |
|
361 |
^ aBlock value |
|
362 |
||
363 |
" |
|
364 |
Smalltalk at:#fooBar <- returns nil |
|
365 |
Smalltalk at:#fooBar ifAbsent:['sorry'] <- no error |
|
366 |
" |
|
367 |
! |
|
368 |
||
369 |
at:aKey put:aValue |
|
370 |
"store the argument aValue under aKey, a symbol" |
|
371 |
||
372 |
" |
|
373 |
|oldValue| |
|
374 |
||
375 |
%{ |
|
376 |
extern OBJ __GLOBAL_SET(); |
|
377 |
||
378 |
oldValue = __GLOBAL_SET(aKey, aValue, (OBJ *)0); |
|
379 |
%}. |
|
380 |
CachedClasses notNil ifTrue:[ |
|
381 |
oldValue isBehavior ifTrue:[ |
|
382 |
CachedClasses remove:oldValue |
|
383 |
]. |
|
384 |
aValue isBehavior ifTrue:[ |
|
385 |
CachedClasses add:aValue |
|
386 |
]. |
|
387 |
]. |
|
388 |
^ aValue |
|
389 |
" |
|
390 |
%{ /* NOCONTEXT */ |
|
391 |
extern OBJ __GLOBAL_SET(); |
|
392 |
||
393 |
(void) __GLOBAL_SET(aKey, aValue, (OBJ *)0); |
|
394 |
%}. |
|
395 |
CachedClasses := nil. |
|
396 |
^ aValue |
|
397 |
! |
|
398 |
||
399 |
removeKey:aKey |
|
400 |
"remove the argument from the globals dictionary" |
|
401 |
||
402 |
CachedClasses := nil. |
|
403 |
||
404 |
%{ /* NOCONTEXT */ |
|
405 |
extern OBJ __GLOBAL_REMOVE(); |
|
406 |
||
407 |
RETURN ( __GLOBAL_REMOVE(aKey) ); |
|
408 |
%} |
|
409 |
! |
|
410 |
||
411 |
keyAtValue:anObject |
|
412 |
"return the symbol under which anObject is stored - or nil" |
|
413 |
||
414 |
self keysDo:[:aKey | |
|
415 |
(self at:aKey) == anObject ifTrue:[^ aKey] |
|
416 |
]. |
|
417 |
^ nil |
|
418 |
||
419 |
"Smalltalk keyAtValue:Object" |
|
420 |
! |
|
421 |
||
422 |
keys |
|
423 |
"return a collection with all keys in the Smalltalk dictionary" |
|
424 |
||
425 |
|keys| |
|
426 |
||
427 |
keys := IdentitySet new. |
|
428 |
self keysDo:[:k | keys add:k]. |
|
429 |
^ keys |
|
430 |
! ! |
|
431 |
||
432 |
!Smalltalk class methodsFor:'binary storage'! |
|
433 |
||
434 |
addGlobalsTo: globalDictionary manager: manager |
|
435 |
|pools| |
|
436 |
||
437 |
pools := Set new. |
|
438 |
self associationsDo:[:assoc | |
|
439 |
assoc value == self ifFalse:[ |
|
440 |
assoc value isClass ifTrue:[ |
|
441 |
assoc value addGlobalsTo:globalDictionary manager:manager. |
|
442 |
pools addAll:assoc value sharedPools |
|
443 |
] ifFalse:[ |
|
444 |
globalDictionary at:assoc put:self |
|
445 |
]. |
|
446 |
assoc value isNil ifFalse:[ |
|
447 |
globalDictionary at:assoc value put:self |
|
448 |
] |
|
449 |
] |
|
450 |
]. |
|
451 |
||
452 |
pools do:[:poolDictionary| |
|
453 |
poolDictionary addGlobalsTo:globalDictionary manager:manager |
|
454 |
] |
|
455 |
! |
|
456 |
||
457 |
storeBinaryDefinitionOf: anObject on: stream manager: manager |
|
458 |
|string| |
|
459 |
||
460 |
anObject class == Association ifTrue:[ |
|
461 |
string := 'Smalltalk associationAt: ', anObject key storeString |
|
462 |
] ifFalse: [ |
|
463 |
string := 'Smalltalk at: ', (self keyAtValue: anObject) storeString |
|
464 |
]. |
|
465 |
stream nextNumber:2 put:string size. |
|
466 |
string do:[:char | stream nextPut:char asciiValue] |
|
467 |
! ! |
|
468 |
||
469 |
!Smalltalk class methodsFor:'browsing'! |
|
470 |
||
471 |
browseChanges |
|
472 |
"startup a changes browser" |
|
473 |
||
474 |
ChangesBrowser notNil ifTrue:[ |
|
475 |
ChangesBrowser open |
|
476 |
] ifFalse:[ |
|
477 |
self warn:'no ChangesBrowser built in' |
|
478 |
] |
|
479 |
||
480 |
" |
|
481 |
Smalltalk browseChanges |
|
482 |
" |
|
483 |
! |
|
484 |
||
485 |
browseAllSelect:aBlock |
|
486 |
"startup a browser for all methods for which aBlock returns true" |
|
487 |
||
488 |
SystemBrowser browseAllSelect:aBlock |
|
489 |
||
490 |
" |
|
491 |
Smalltalk browseAllSelect:[:m | m literals isNil] |
|
492 |
" |
|
493 |
! |
|
494 |
||
495 |
browseImplementorsOf:aSelectorSymbol |
|
496 |
"startup a browser for all methods implementing a particular message" |
|
497 |
||
498 |
SystemBrowser browseImplementorsOf:aSelectorSymbol |
|
499 |
||
500 |
" |
|
501 |
Smalltalk browseImplementorsOf:#at:put: |
|
502 |
" |
|
503 |
! |
|
504 |
||
505 |
browseAllCallsOn:aSelectorSymbol |
|
506 |
"startup a browser for all methods sending a particular message" |
|
507 |
||
508 |
SystemBrowser browseAllCallsOn:aSelectorSymbol |
|
509 |
||
510 |
" |
|
511 |
Smalltalk browseAllCallsOn:#at:put: |
|
512 |
" |
|
513 |
! ! |
|
514 |
||
515 |
!Smalltalk class methodsFor:'class management'! |
|
516 |
||
517 |
flushCachedClasses |
|
518 |
CachedClasses := nil |
|
519 |
! |
|
520 |
||
521 |
renameClass:aClass to:newName |
|
522 |
"rename aClass to newName" |
|
523 |
||
524 |
|oldName oldSym newSym names cSym value| |
|
525 |
||
526 |
oldName := aClass name. |
|
527 |
oldSym := oldName asSymbol. |
|
528 |
||
529 |
((self at:oldSym) == aClass) ifFalse:[^ self]. |
|
530 |
||
531 |
"rename the class" |
|
532 |
||
533 |
aClass setName:newName. |
|
534 |
||
535 |
"and its meta" |
|
536 |
||
537 |
aClass class setName:(newName , 'class'). |
|
538 |
||
539 |
"store it in Smalltalk" |
|
540 |
||
541 |
newSym := newName asSymbol. |
|
542 |
self at:oldSym put:nil. |
|
543 |
self removeKey:oldSym. |
|
544 |
self at:newSym put:aClass. |
|
545 |
||
546 |
"rename class variables" |
|
547 |
||
548 |
names := aClass classVariableString asCollectionOfWords. |
|
549 |
names do:[:name | |
|
550 |
cSym := (oldSym , ':' , name) asSymbol. |
|
551 |
value := self at:cSym. |
|
552 |
self at:cSym put:nil. |
|
553 |
self removeKey:cSym. |
|
554 |
cSym := (newSym , ':' , name) asSymbol. |
|
555 |
self at:cSym put:value. |
|
556 |
]. |
|
557 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
558 |
aClass updateVersionString. |
453 | 559 |
aClass addChangeRecordForClassRename:oldName to:newName |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
560 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
561 |
"Created: 29.10.1995 / 19:58:32 / cg" |
453 | 562 |
! |
563 |
||
564 |
removeClass:aClass |
|
565 |
"remove the argument, aClass from the smalltalk dictionary; |
|
566 |
we have to flush the caches since these methods are now void. |
|
567 |
Also, class variables of aClass are removed." |
|
568 |
||
569 |
|sym cSym names oldName| |
|
570 |
||
571 |
oldName := aClass name. |
|
572 |
sym := oldName asSymbol. |
|
573 |
((self at:sym) == aClass) ifFalse:[ |
|
574 |
"check other name ..." |
|
575 |
(self includes:aClass) ifFalse:[ |
|
576 |
'SMALLTALK: no such class: ' errorPrint. oldName errorPrintNL. |
|
577 |
^ self |
|
578 |
]. |
|
579 |
" |
|
580 |
the class has changed its name - without telling me ... |
|
581 |
what should be done in this case ? |
|
582 |
" |
|
583 |
'SMALLTALK: class ' errorPrint. oldName errorPrint. |
|
584 |
' has changed its name' errorPrintNL. |
|
585 |
^ self |
|
586 |
]. |
|
587 |
||
588 |
self at:sym put:nil. "nil it out for compiled accesses" |
|
589 |
self removeKey:sym. "remove key - this actually fails, if there are |
|
590 |
still compiled code references." |
|
591 |
||
592 |
"remove class variables" |
|
593 |
||
594 |
names := aClass classVariableString asCollectionOfWords. |
|
595 |
names do:[:name | |
|
596 |
cSym := (sym , ':' , name) asSymbol. |
|
597 |
self at:cSym asSymbol put:nil. |
|
598 |
self removeKey:cSym |
|
599 |
]. |
|
600 |
" |
|
601 |
actually could get along with less flushing |
|
602 |
(entries for aClass and subclasses only) |
|
603 |
but we have to delay this, until we have the set of subclasses |
|
604 |
at hand - for now, searching for all subclasses is way more |
|
605 |
expensive then cache flushing. |
|
606 |
||
607 |
aClass allSubclassesDo:[:aSubclass | |
|
608 |
ObjectMemory flushInlineCachesForClass:aSubclass. |
|
609 |
ObjectMemory flushMethodCacheFor:aSubclass |
|
610 |
]. |
|
611 |
ObjectMemory flushInlineCachesForClass:aClass. |
|
612 |
ObjectMemory flushMethodCacheFor:aClass |
|
613 |
" |
|
614 |
ObjectMemory flushInlineCaches. |
|
615 |
ObjectMemory flushMethodCache. |
|
616 |
||
617 |
aClass addChangeRecordForClassRemove:oldName. |
|
618 |
self changed:#classRemove with:aClass. |
|
619 |
||
620 |
aClass category:#removed. |
|
621 |
! ! |
|
622 |
||
623 |
!Smalltalk class methodsFor:'copying'! |
|
624 |
||
625 |
shallowCopy |
|
626 |
"redefine copy - there is only one Smalltalk dictionary" |
|
627 |
||
628 |
^ self |
|
629 |
! |
|
630 |
||
631 |
simpleDeepCopy |
|
632 |
"redefine copy - there is only one Smalltalk dictionary" |
|
633 |
||
634 |
^ self |
|
635 |
! |
|
636 |
||
637 |
deepCopyUsing:aDictionary |
|
638 |
"redefine copy - there is only one Smalltalk dictionary" |
|
639 |
||
640 |
^ self |
|
641 |
! |
|
642 |
||
643 |
deepCopy |
|
644 |
"redefine copy - there is only one Smalltalk dictionary" |
|
645 |
||
646 |
^ self |
|
647 |
! ! |
|
648 |
||
649 |
!Smalltalk class methodsFor:'debugging ST/X'! |
|
650 |
||
651 |
debugBreakPoint |
|
652 |
"call the dummy debug function, on which a breakpoint |
|
653 |
can be put in adb, sdb, dbx or gdb. |
|
654 |
WARNING: this method is for debugging only |
|
655 |
it will be removed without notice." |
|
656 |
%{ |
|
657 |
_PATCHUPCONTEXTS(__context); |
|
658 |
debugBreakPoint(); |
|
659 |
%} |
|
660 |
! |
|
661 |
||
662 |
printPolyCaches |
|
663 |
"dump poly caches. |
|
664 |
WARNING: this method is for debugging only |
|
665 |
it will be removed without notice" |
|
666 |
%{ |
|
667 |
__dumpILCCaches(); |
|
668 |
%} |
|
669 |
! |
|
670 |
||
671 |
printStackBacktrace |
|
672 |
"print a stack backtrace - then continue. |
|
673 |
(You may turn off the stack print with debugPrinting:false) |
|
674 |
WARNING: this method is for debugging only |
|
675 |
it will be removed without notice" |
|
676 |
||
677 |
%{ |
|
678 |
__printStack(__context); |
|
679 |
%} |
|
680 |
"Smalltalk printStackBacktrace" |
|
681 |
! |
|
682 |
||
683 |
printSymbols |
|
684 |
"dump the internal symbol table. |
|
685 |
WARNING: this method is for debugging only |
|
686 |
it will be removed without notice" |
|
687 |
%{ |
|
688 |
__dumpSymbols(); |
|
689 |
%} |
|
690 |
! |
|
691 |
||
692 |
fatalAbort:aMessage |
|
693 |
"report a fatal-error; print a stack backtrace and exit with core dump |
|
694 |
(You may turn off the stack print with debugPrinting:false)" |
|
695 |
||
696 |
%{ |
|
697 |
char *msg; |
|
698 |
||
699 |
if (__isString(aMessage)) |
|
700 |
msg = (char *) _stringVal(aMessage); |
|
701 |
else |
|
702 |
msg = "fatalAbort"; |
|
703 |
||
704 |
__fatal0(__context, msg); |
|
705 |
/* NEVER RETURNS */ |
|
706 |
%} |
|
707 |
! |
|
708 |
||
709 |
fatalAbort |
|
710 |
"report a fatal-error, print a stack backtrace and exit with core dump. |
|
711 |
(You may turn off the stack print with debugPrinting:false)" |
|
712 |
%{ |
|
713 |
__fatal0(__context, "fatalAbort"); |
|
714 |
/* NEVER RETURNS */ |
|
715 |
%} |
|
716 |
! |
|
717 |
||
718 |
exitWithCoreDump |
|
719 |
"abort program and dump core" |
|
720 |
||
721 |
%{ /* NOCONTEXT */ |
|
722 |
abort(); |
|
723 |
/* NEVER RETURNS */ |
|
724 |
%} |
|
725 |
! |
|
726 |
||
727 |
statistic |
|
728 |
"print some statistic data. |
|
729 |
WARNING: this method is for debugging only |
|
730 |
it may be removed without notice" |
|
731 |
||
732 |
%{ /* NOCONTEXT */ |
|
733 |
__STATISTIC__(); |
|
734 |
%} |
|
735 |
! |
|
736 |
||
737 |
debugOn |
|
738 |
"turns some tracing on. |
|
739 |
WARNING: this method is for debugging only |
|
740 |
it may be removed without notice" |
|
741 |
||
742 |
"LookupTrace := true. " |
|
743 |
"AllocTrace := true. " |
|
744 |
ObjectMemory flushCaches |
|
745 |
! |
|
746 |
||
747 |
debugOff |
|
748 |
"turns tracing off. |
|
749 |
WARNING: this method is for debugging only |
|
750 |
it may be removed without notice" |
|
751 |
||
752 |
LookupTrace := nil. |
|
753 |
". AllocTrace := nil " |
|
754 |
! |
|
755 |
||
756 |
executionDebugOn |
|
757 |
"turns tracing of interpreter on. |
|
758 |
WARNING: this method is for debugging only |
|
759 |
it may be removed without notice" |
|
760 |
||
761 |
ExecutionTrace := true |
|
762 |
! |
|
763 |
||
764 |
executionDebugOff |
|
765 |
"turns tracing of interpreter off. |
|
766 |
WARNING: this method is for debugging only |
|
767 |
it may be removed without notice" |
|
768 |
||
769 |
ExecutionTrace := nil |
|
770 |
! ! |
|
771 |
||
772 |
!Smalltalk class methodsFor:'enumerating'! |
|
773 |
||
774 |
do:aBlock |
|
775 |
"evaluate the argument, aBlock for all values in the Smalltalk dictionary" |
|
776 |
||
777 |
|work| |
|
778 |
||
779 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
780 |
__GLOBALS_DO(&aBlock, &work COMMA_CON); |
|
781 |
%} |
|
782 |
! |
|
783 |
||
784 |
allBehaviorsDo:aBlock |
|
785 |
"evaluate the argument, aBlock for all classes in the system" |
|
786 |
||
787 |
CachedClasses isNil ifTrue:[ |
|
788 |
self allClasses |
|
789 |
]. |
|
790 |
CachedClasses do:aBlock |
|
791 |
||
792 |
" |
|
793 |
Smalltalk allBehaviorsDo:[:aClass | aClass name printNL] |
|
794 |
" |
|
795 |
! |
|
796 |
||
797 |
keysDo:aBlock |
|
798 |
"evaluate the argument, aBlock for all keys in the Smalltalk dictionary" |
|
799 |
|work| |
|
800 |
||
801 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
802 |
__GLOBALKEYS_DO(&aBlock, &work COMMA_CON); |
|
803 |
%} |
|
804 |
! |
|
805 |
||
806 |
allKeysDo:aBlock |
|
807 |
"evaluate the argument, aBlock for all keys in the Smalltalk dictionary" |
|
808 |
||
809 |
^ self keysDo:aBlock |
|
810 |
! |
|
811 |
||
812 |
associationsDo:aBlock |
|
813 |
"evaluate the argument, aBlock for all key/value pairs |
|
814 |
in the Smalltalk dictionary" |
|
815 |
||
816 |
self keysDo:[:aKey | |
|
817 |
aBlock value:(aKey -> (self at:aKey)) |
|
818 |
] |
|
819 |
||
820 |
"Smalltalk associationsDo:[:assoc | assoc printNL]" |
|
821 |
! |
|
822 |
||
823 |
keysAndValuesDo:aBlock |
|
824 |
"evaluate the two-arg block, aBlock for all keys and values" |
|
825 |
||
826 |
self keysDo:[:aKey | |
|
827 |
aBlock value:aKey value:(self at:aKey) |
|
828 |
] |
|
829 |
! |
|
830 |
||
831 |
allClassesDo:aBlock |
|
832 |
"evaluate the argument, aBlock for all classes in the system. |
|
833 |
Backward compatibility - use #allBehaviorsDo: for ST-80 compatibility." |
|
834 |
||
835 |
^ self allBehaviorsDo:aBlock |
|
836 |
||
837 |
" |
|
838 |
Smalltalk allClassesDo:[:aClass | aClass name printNL] |
|
839 |
" |
|
840 |
! |
|
841 |
||
842 |
allClassesInCategory:aCategory do:aBlock |
|
843 |
"evaluate the argument, aBlock for all classes in the aCategory; |
|
844 |
The order of the classes is not defined." |
|
845 |
||
846 |
aCategory notNil ifTrue:[ |
|
847 |
self allBehaviorsDo:[:aClass | |
|
848 |
aClass isMeta ifFalse:[ |
|
849 |
(aClass category = aCategory) ifTrue:[ |
|
850 |
aBlock value:aClass |
|
851 |
] |
|
852 |
] |
|
853 |
] |
|
854 |
] |
|
855 |
||
856 |
" |
|
857 |
Smalltalk allClassesInCategory:'Views-Basic' do:[:aClass | aClass name printNL] |
|
858 |
" |
|
859 |
! |
|
860 |
||
861 |
allClassesInCategory:aCategory inOrderDo:aBlock |
|
862 |
"evaluate the argument, aBlock for all classes in aCategory; |
|
863 |
superclasses come first - then subclasses" |
|
864 |
||
865 |
|classes| |
|
866 |
||
867 |
aCategory notNil ifTrue:[ |
|
868 |
classes := OrderedCollection new. |
|
869 |
self allBehaviorsDo:[:aClass | |
|
870 |
aClass isMeta ifFalse:[ |
|
871 |
(aClass category = aCategory) ifTrue:[ |
|
872 |
classes add:aClass |
|
873 |
] |
|
874 |
] |
|
875 |
]. |
|
876 |
classes topologicalSort:[:a :b | b isSubclassOf:a]. |
|
877 |
classes do:aBlock |
|
878 |
] |
|
879 |
||
880 |
" |
|
881 |
Smalltalk allClassesInCategory:'Views-Basic' inOrderDo:[:aClass | aClass name printNL] |
|
882 |
" |
|
883 |
! ! |
|
884 |
||
885 |
!Smalltalk class methodsFor:'inspecting'! |
|
886 |
||
887 |
inspectorClass |
|
888 |
"redefined to launch a DictionaryInspector |
|
889 |
(instead of the default Inspector)." |
|
890 |
||
891 |
^ DictionaryInspectorView |
|
892 |
! ! |
|
893 |
||
894 |
!Smalltalk class methodsFor:'message control'! |
|
895 |
||
896 |
silentLoading |
|
897 |
"returns the Silentloading class variable." |
|
898 |
||
899 |
^ SilentLoading |
|
900 |
! |
|
901 |
||
902 |
silentLoading:aBoolean |
|
903 |
"allows access to the Silentloading class variable, which controls |
|
904 |
messages from all kinds of system onto the transcript. |
|
905 |
You can save a snapshot with this flag set to true, which makes |
|
906 |
the image come up silent. Can also be set, to read in files unlogged." |
|
907 |
||
908 |
|prev| |
|
909 |
||
910 |
prev := SilentLoading. |
|
911 |
SilentLoading := aBoolean. |
|
912 |
^ prev |
|
913 |
! ! |
|
914 |
||
915 |
!Smalltalk class methodsFor:'misc stuff'! |
|
916 |
||
917 |
exit |
|
918 |
"finish Smalltalk system" |
|
919 |
||
920 |
ObjectMemory changed:#aboutToQuit. "/ for ST-80 compatibility |
|
921 |
ExitBlocks notNil ifTrue:[ |
|
922 |
ExitBlocks do:[:aBlock | |
|
923 |
aBlock value |
|
924 |
] |
|
925 |
]. |
|
926 |
OperatingSystem exit |
|
927 |
||
928 |
" |
|
929 |
Smalltalk exit |
|
930 |
" |
|
931 |
! |
|
932 |
||
933 |
addExitBlock:aBlock |
|
934 |
"add a block to be executed when Smalltalk finishes. |
|
935 |
This feature is currently not used anywhere - but could be useful for |
|
936 |
cleanup in stand alone applications." |
|
937 |
||
938 |
ExitBlocks isNil ifTrue:[ |
|
939 |
ExitBlocks := OrderedCollection with:aBlock |
|
940 |
] ifFalse:[ |
|
941 |
ExitBlocks add:aBlock |
|
942 |
] |
|
943 |
! |
|
944 |
||
945 |
sleep:aDelay |
|
946 |
"wait for aDelay seconds. |
|
947 |
OBSOLETE: this is historical leftover and will be removed" |
|
948 |
||
949 |
OperatingSystem sleep:aDelay |
|
950 |
! ! |
|
951 |
||
952 |
!Smalltalk class methodsFor:'queries'! |
|
953 |
||
954 |
allClasses |
|
955 |
"return an unordered collection of all classes in the system. |
|
956 |
Only globally anchored classes are returned |
|
957 |
(i.e. anonymous ones have to be aquired by Behavior allSubInstances)" |
|
958 |
||
959 |
|classes| |
|
960 |
||
961 |
"/ you may wander, what this while is for, here ... |
|
962 |
"/ the reason is that if we modify the class hierarchy in |
|
963 |
"/ anothe view (background fileIn), while building up the |
|
964 |
"/ cachedClasses set, this may be flushed (invalidated) by the |
|
965 |
"/ other process in the meanwhile. |
|
966 |
"/ If that happens, we restart the set-building here |
|
967 |
"/ |
|
968 |
[(classes := CachedClasses) isNil] whileTrue:[ |
|
969 |
CachedClasses := classes := IdentitySet new:800. |
|
970 |
self do:[:anObject | |
|
971 |
anObject notNil ifTrue:[ |
|
972 |
anObject isBehavior ifTrue:[ |
|
973 |
classes add:anObject |
|
974 |
] |
|
975 |
] |
|
976 |
] |
|
977 |
]. |
|
978 |
^ classes |
|
979 |
||
980 |
" |
|
981 |
Smalltalk allClasses |
|
982 |
" |
|
983 |
! |
|
984 |
||
985 |
classNamed:aString |
|
986 |
"return the class with name aString, or nil if absent. |
|
987 |
To get to the metaClass, append 'class' to the string." |
|
988 |
||
989 |
|cls str sym| |
|
990 |
||
991 |
"be careful, to not invent new symbols ..." |
|
992 |
sym := aString asSymbolIfInterned. |
|
993 |
sym notNil ifTrue:[ |
|
994 |
cls := self at:sym ifAbsent:[]. |
|
995 |
cls isNil ifTrue:[^ nil]. |
|
996 |
cls isBehavior ifTrue:[^ cls] |
|
997 |
]. |
|
998 |
(aString endsWith:'class') ifTrue:[ |
|
999 |
str := aString copyTo:(aString size - 5). |
|
1000 |
sym := str asSymbolIfInterned. |
|
1001 |
sym notNil ifTrue:[ |
|
1002 |
cls := self at:sym ifAbsent:[]. |
|
1003 |
cls isNil ifTrue:[^ nil]. |
|
1004 |
cls isBehavior ifTrue:[^ cls] |
|
1005 |
] |
|
1006 |
]. |
|
1007 |
^ nil |
|
1008 |
||
1009 |
" |
|
1010 |
Smalltalk classNamed:'Object' |
|
1011 |
Smalltalk classNamed:'fooBar' |
|
1012 |
Smalltalk classNamed:'true' |
|
1013 |
Smalltalk classNamed:'Objectclass' |
|
1014 |
Smalltalk classNamed:'Metaclass' |
|
1015 |
" |
|
1016 |
! |
|
1017 |
||
1018 |
numberOfGlobals |
|
1019 |
"return the number of global variables in the system" |
|
1020 |
||
1021 |
|tally "{ Class: SmallInteger }" | |
|
1022 |
||
1023 |
tally := 0. |
|
1024 |
self do:[:obj | tally := tally + 1]. |
|
1025 |
^ tally |
|
1026 |
||
1027 |
"Smalltalk numberOfGlobals" |
|
1028 |
! |
|
1029 |
||
1030 |
cellAt:aName |
|
1031 |
"return the address of a global cell |
|
1032 |
- used internally for compiler only" |
|
1033 |
||
1034 |
%{ /* NOCONTEXT */ |
|
1035 |
extern OBJ __GLOBAL_GETCELL(); |
|
1036 |
||
1037 |
RETURN ( __GLOBAL_GETCELL(aName) ); |
|
1038 |
%} |
|
1039 |
! |
|
1040 |
||
1041 |
classNames |
|
1042 |
"return a collection of all classNames in the system" |
|
1043 |
||
1044 |
^ self allClasses collect:[:aClass | aClass name] |
|
1045 |
||
1046 |
"Smalltalk classNames" |
|
1047 |
! |
|
1048 |
||
1049 |
classnameCompletion:aPartialClassName |
|
1050 |
"given a partial classname, return an array consisting of |
|
1051 |
2 entries: 1st: collection consisting of matching names |
|
1052 |
2nd: the longest match" |
|
1053 |
||
1054 |
|matches best| |
|
1055 |
||
1056 |
matches := SortedCollection new. |
|
1057 |
self allClassesDo:[:aClass | |
|
1058 |
aClass isMeta ifFalse:[ |
|
1059 |
(aClass name startsWith:aPartialClassName) ifTrue:[ |
|
1060 |
matches add:aClass name |
|
1061 |
] |
|
1062 |
] |
|
1063 |
]. |
|
1064 |
matches isEmpty ifTrue:[ |
|
1065 |
^ Array with:aPartialClassName with:(Array with:aPartialClassName) |
|
1066 |
]. |
|
1067 |
matches size == 1 ifTrue:[ |
|
1068 |
^ Array with:matches first with:(matches asArray) |
|
1069 |
]. |
|
1070 |
best := matches longestCommonPrefix. |
|
1071 |
^ Array with:best with:matches asArray |
|
1072 |
||
1073 |
" |
|
1074 |
Smalltalk classnameCompletion:'Arr' |
|
1075 |
Smalltalk classnameCompletion:'Arra' |
|
1076 |
" |
|
1077 |
! |
|
1078 |
||
1079 |
selectorCompletion:aPartialSymbolName |
|
1080 |
"given a partial selector, return an array consisting of |
|
1081 |
2 entries: 1st: collection consisting of matching implemented selectors |
|
1082 |
2nd: the longest match" |
|
1083 |
||
1084 |
|matches best| |
|
1085 |
||
1086 |
matches := IdentitySet new. |
|
1087 |
self allClassesDo:[:aClass | |
|
1088 |
aClass selectorArray do:[:aSelector | |
|
1089 |
(aSelector startsWith:aPartialSymbolName) ifTrue:[ |
|
1090 |
matches add:aSelector |
|
1091 |
] |
|
1092 |
]. |
|
1093 |
aClass class selectorArray do:[:aSelector | |
|
1094 |
(aSelector startsWith:aPartialSymbolName) ifTrue:[ |
|
1095 |
matches add:aSelector |
|
1096 |
] |
|
1097 |
] |
|
1098 |
]. |
|
1099 |
matches := matches asSortedCollection. |
|
1100 |
matches isEmpty ifTrue:[ |
|
1101 |
^ Array with:aPartialSymbolName with:(Array with:aPartialSymbolName) |
|
1102 |
]. |
|
1103 |
matches size == 1 ifTrue:[ |
|
1104 |
^ Array with:matches first with:(matches asArray) |
|
1105 |
]. |
|
1106 |
best := matches longestCommonPrefix. |
|
1107 |
^ Array with:best with:matches asArray |
|
1108 |
||
1109 |
" |
|
1110 |
Smalltalk selectorCompletion:'at:p' |
|
1111 |
Smalltalk selectorCompletion:'nextP' |
|
1112 |
" |
|
1113 |
! |
|
1114 |
||
1115 |
includes:something |
|
1116 |
"this should come from Collection. |
|
1117 |
will change the inheritance - Smalltalk is actually a collection" |
|
1118 |
||
1119 |
self do:[:element | element = something ifTrue:[^ true]]. |
|
1120 |
^ false |
|
1121 |
! |
|
1122 |
||
1123 |
references:anObject |
|
1124 |
"redefined, since the references are only kept in the VM's symbol table" |
|
1125 |
||
1126 |
self keysAndValuesDo:[:key :val | |
|
1127 |
(key == anObject) ifTrue:[^ true]. |
|
1128 |
(val == anObject ) ifTrue:[^ true]. |
|
1129 |
]. |
|
1130 |
^ super references:anObject |
|
1131 |
! |
|
1132 |
||
1133 |
referencesDerivedInstanceOf:aClass |
|
1134 |
"redefined, since the references are only kept in the VM's symbol table" |
|
1135 |
||
1136 |
self keysAndValuesDo:[:key :val | |
|
1137 |
(key isKindOf:aClass) ifTrue:[^ true]. |
|
1138 |
(val isKindOf:aClass) ifTrue:[^ true]. |
|
1139 |
]. |
|
1140 |
^ super referencesDerivedInstanceOf:aClass |
|
1141 |
! |
|
1142 |
||
1143 |
referencesInstanceOf:aClass |
|
1144 |
"redefined, since the references are only kept in the VM's symbol table" |
|
1145 |
||
1146 |
self keysAndValuesDo:[:key :val | |
|
1147 |
(key isMemberOf:aClass) ifTrue:[^ true]. |
|
1148 |
(val isMemberOf:aClass) ifTrue:[^ true]. |
|
1149 |
]. |
|
1150 |
^ super referencesInstanceOf:aClass |
|
1151 |
! ! |
|
1152 |
||
161 | 1153 |
!Smalltalk class methodsFor:'startup'! |
1 | 1154 |
|
1155 |
start |
|
1156 |
"main startup, if there is a Display, initialize it |
|
443 | 1157 |
and start dispatching; otherwise go into a read-eval-print loop." |
1158 |
||
1159 |
|idx haveStartupFile| |
|
1160 |
||
1161 |
haveStartupFile := true. |
|
1 | 1162 |
Initializing := true. |
1163 |
||
70 | 1164 |
" |
1165 |
while reading patches- and rc-file, do not add things into change-file |
|
1166 |
" |
|
421 | 1167 |
Class withoutUpdatingChangesDo:[ |
423 | 1168 |
" |
1169 |
look for a '-e filename' argument - this will force evaluation of |
|
1170 |
filename only, no standard startup |
|
1171 |
" |
|
1172 |
idx := Arguments indexOf:'-e'. |
|
1173 |
idx ~~ 0 ifTrue:[ |
|
421 | 1174 |
self fileIn:(Arguments at:idx + 1). |
1175 |
self exit |
|
423 | 1176 |
]. |
1177 |
||
1178 |
self secureFileIn:'patches'. |
|
1179 |
||
1180 |
(self secureFileIn:((Arguments at:1) , '.rc')) ifFalse:[ |
|
421 | 1181 |
"no .rc file where executable is; try default smalltalk.rc" |
1182 |
(self secureFileIn:'smalltalk.rc') ifFalse:[ |
|
443 | 1183 |
Transcript showCr:'SMALLTALK: no startup rc-file found. Going into line-by-line interpreter.'. |
1184 |
haveStartupFile := false. |
|
421 | 1185 |
] |
423 | 1186 |
]. |
7 | 1187 |
]. |
1188 |
||
70 | 1189 |
(SilentLoading == true) ifFalse:[ "i.e. undefined counts as false" |
159 | 1190 |
Transcript showCr:(self hello). |
1191 |
Transcript showCr:(self copyrightString). |
|
1192 |
Transcript cr. |
|
70 | 1193 |
|
159 | 1194 |
DemoMode ifTrue:[ |
1195 |
Transcript showCr:'*** Restricted use: ***'. |
|
1196 |
Transcript showCr:'*** This program may be used for education only. ***'. |
|
1197 |
Transcript showCr:'*** Please read the files COPYRIGHT and LICENSE ***'. |
|
1198 |
Transcript showCr:'*** for more details. ***'. |
|
1199 |
Transcript cr. |
|
1200 |
]. |
|
1 | 1201 |
]. |
1202 |
||
85 | 1203 |
" |
357 | 1204 |
enable the graphical debugger/inspector |
1205 |
(they could have been (re)defined as autoloaded in the patches file) |
|
85 | 1206 |
" |
1207 |
self initStandardTools. |
|
1208 |
||
1209 |
" |
|
95 | 1210 |
if there is a display, start its event dispatcher |
85 | 1211 |
" |
8 | 1212 |
Display notNil ifTrue:[ |
159 | 1213 |
Display startDispatch. |
8 | 1214 |
]. |
24 | 1215 |
|
162 | 1216 |
Initializing := false. |
1217 |
||
24 | 1218 |
(StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
159 | 1219 |
StartupClass perform:StartupSelector withArguments:StartupArguments. |
24 | 1220 |
]. |
1221 |
||
95 | 1222 |
" |
1223 |
if view-classes exist, start dispatching; |
|
1224 |
otherwise go into a read-eval-print loop |
|
1225 |
" |
|
443 | 1226 |
(Display notNil and:[haveStartupFile]) ifTrue:[ |
159 | 1227 |
Processor dispatchLoop |
95 | 1228 |
] ifFalse:[ |
159 | 1229 |
self readEvalPrint |
95 | 1230 |
]. |
1 | 1231 |
|
1232 |
"done" |
|
1233 |
||
1234 |
self exit |
|
1235 |
! |
|
1236 |
||
453 | 1237 |
readEvalPrint |
1238 |
"simple read-eval-print loop for non-graphical Minitalk" |
|
1239 |
||
1240 |
|text| |
|
1241 |
||
1242 |
'ST- ' print. |
|
1243 |
Stdin skipSeparators. |
|
1244 |
Stdin atEnd ifFalse:[ |
|
1245 |
text := Stdin nextChunk. |
|
1246 |
[text notNil] whileTrue:[ |
|
1247 |
(Compiler evaluate:text) printNL. |
|
1248 |
'ST- ' print. |
|
1249 |
text := Stdin nextChunk |
|
1250 |
]. |
|
1251 |
]. |
|
1252 |
'' printNL |
|
1253 |
! |
|
1254 |
||
1 | 1255 |
restart |
24 | 1256 |
"startup after an image has been loaded; |
10 | 1257 |
there are three change-notifications made to dependents of ObjectMemory, |
1258 |
which allow a stepwise re-init: #earlyRestart, #restarted and #returnFromSnapshot. |
|
335 | 1259 |
|
10 | 1260 |
#earlyRestart is send first, nothing has been setup yet. |
159 | 1261 |
(should be used to flush all device dependent entries) |
335 | 1262 |
|
10 | 1263 |
#restarted is send right after. |
159 | 1264 |
(should be used to recreate external resources (fds, bitmaps etc) |
335 | 1265 |
|
10 | 1266 |
#returnFromSnapshot is sent last |
159 | 1267 |
(should be used to restart processes, reOpen Streams which cannot |
1268 |
be automatically be reopened (i.e. Sockets, Pipes) and so on. |
|
335 | 1269 |
(Notice that positionable fileStreams are already reopened and repositioned) |
1 | 1270 |
" |
10 | 1271 |
|
77 | 1272 |
|deb insp imageName| |
1 | 1273 |
|
1274 |
Initializing := true. |
|
335 | 1275 |
|
1276 |
" |
|
1277 |
flush cached path directories (may have changed in the meanwhile) |
|
1278 |
" |
|
329 | 1279 |
self flushPathCaches. |
1 | 1280 |
|
95 | 1281 |
"temporary switch back to dumb interface - |
1282 |
to handle errors while view-stuff is not yet reinitialized" |
|
1 | 1283 |
|
1284 |
insp := Inspector. |
|
1285 |
deb := Debugger. |
|
1286 |
Inspector := MiniInspector. |
|
1287 |
Debugger := MiniDebugger. |
|
1288 |
||
335 | 1289 |
" |
1290 |
reinitialize the Processor |
|
1291 |
" |
|
1292 |
Processor reinitialize. |
|
1293 |
||
7 | 1294 |
ObjectMemory changed:#earlyRestart. |
1 | 1295 |
ObjectMemory changed:#restarted. |
1296 |
||
1297 |
" |
|
1298 |
some must be reinitialized before ... |
|
1299 |
- sorry, but order is important |
|
1300 |
" |
|
62 | 1301 |
Workstation notNil ifTrue:[ |
159 | 1302 |
Workstation reinitialize. |
62 | 1303 |
]. |
1 | 1304 |
|
1305 |
ObjectMemory changed:#returnFromSnapshot. |
|
1306 |
||
1307 |
OperatingSystem enableUserInterrupts. |
|
77 | 1308 |
OperatingSystem enableHardSignalInterrupts. |
1 | 1309 |
|
335 | 1310 |
"now, display and view-stuff works; |
1311 |
back to the previous debugging interface |
|
1312 |
" |
|
1 | 1313 |
Inspector := insp. |
1314 |
Debugger := deb. |
|
1315 |
||
1316 |
Initializing := false. |
|
1317 |
||
1318 |
" |
|
1319 |
if there is no Transcript, go to stderr |
|
1320 |
" |
|
1321 |
Transcript isNil ifTrue:[ |
|
159 | 1322 |
self initStandardStreams. |
1323 |
Transcript := Stderr |
|
1 | 1324 |
]. |
1325 |
||
70 | 1326 |
(SilentLoading == true) ifFalse:[ |
159 | 1327 |
Transcript cr. |
1328 |
Transcript showCr:('Smalltalk restarted from:' , ObjectMemory imageName). |
|
1329 |
Transcript cr. |
|
70 | 1330 |
|
159 | 1331 |
DemoMode ifTrue:[ |
1332 |
Transcript showCr:'*** Restricted use: ***'. |
|
1333 |
Transcript showCr:'*** This program may be used for education only. ***'. |
|
1334 |
Transcript showCr:'*** Please read the files COPYRIGHT and LICENSE ***'. |
|
1335 |
Transcript showCr:'*** for more details. ***'. |
|
1336 |
Transcript cr. |
|
1337 |
]. |
|
1 | 1338 |
]. |
1339 |
||
7 | 1340 |
" |
1341 |
give user a chance to re-customize things |
|
335 | 1342 |
reading if smalltalk_r.rc may be suppressed by the |
1343 |
-fastStart argument. |
|
7 | 1344 |
" |
95 | 1345 |
(Arguments includes:'-faststart') ifFalse:[ |
423 | 1346 |
Class withoutUpdatingChangesDo:[ |
421 | 1347 |
(self fileIn:((Arguments at:1) , '_r.rc')) ifFalse:[ |
423 | 1348 |
"no _r.rc file where executable is; try default smalltalk_r.rc" |
1349 |
self fileIn:'smalltalk_r.rc' |
|
421 | 1350 |
]. |
1351 |
] |
|
7 | 1352 |
]. |
1353 |
||
95 | 1354 |
" |
1355 |
if there is a display, start its event dispatcher |
|
1356 |
" |
|
10 | 1357 |
Display notNil ifTrue:[ |
159 | 1358 |
Display startDispatch. |
10 | 1359 |
]. |
1360 |
||
95 | 1361 |
" |
1362 |
this allows firing an application by defining |
|
1363 |
these two globals during snapshot ... or in main |
|
1364 |
" |
|
7 | 1365 |
(StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
335 | 1366 |
" |
1367 |
allow more customization by reading an image specific rc-file |
|
1368 |
" |
|
159 | 1369 |
imageName := ObjectMemory imageName. |
1370 |
imageName notNil ifTrue:[ |
|
1371 |
(imageName endsWith:'.img') ifTrue:[ |
|
359 | 1372 |
imageName := imageName copyWithoutLast:4 |
1373 |
]. |
|
1374 |
self fileIn:(imageName , '.rc') |
|
159 | 1375 |
]. |
1376 |
StartupClass perform:StartupSelector withArguments:StartupArguments. |
|
1 | 1377 |
]. |
1378 |
||
95 | 1379 |
" |
1380 |
if view-classes exist, start dispatching; |
|
1381 |
otherwise go into a read-eval-print loop |
|
1382 |
" |
|
1 | 1383 |
Display notNil ifTrue:[ |
159 | 1384 |
Processor dispatchLoop |
1 | 1385 |
] ifFalse:[ |
159 | 1386 |
self readEvalPrint |
1 | 1387 |
]. |
95 | 1388 |
|
1389 |
self exit |
|
1 | 1390 |
! |
1391 |
||
70 | 1392 |
startupClass:aClass selector:aSymbol arguments:anArrayOrNil |
1393 |
"set the class, selector and arguments to be performed when smalltalk |
|
1394 |
starts. Setting those before saving a snapshot, will make the saved |
|
1395 |
image come up executing your application (instead of the normal mainloop)" |
|
1396 |
||
1397 |
StartupClass := aClass. |
|
1398 |
StartupSelector := aSymbol. |
|
1399 |
StartupArguments := anArrayOrNil |
|
1400 |
! |
|
1401 |
||
1402 |
startupClass |
|
1403 |
"return the class, that will get the start message when smalltalk |
|
1404 |
starts and its non-nil. Usually this is nil, but saving an image |
|
1405 |
with a non-nil StartupClass allows stand-alone applications" |
|
1406 |
||
1407 |
^ StartupClass |
|
1408 |
! |
|
1409 |
||
1410 |
startupSelector |
|
1411 |
"return the selector, that will be sent to StartupClass" |
|
1412 |
||
1413 |
^ StartupSelector |
|
1414 |
! |
|
1415 |
||
1416 |
startupArguments |
|
1417 |
"return the arguments passed to StartupClass" |
|
1418 |
||
1419 |
^ StartupArguments |
|
1420 |
! ! |
|
1421 |
||
1422 |
!Smalltalk class methodsFor:'system management'! |
|
1423 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1424 |
searchPath:aPath for:aFileName in:aDirName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1425 |
"search aPath for a subdirectory named aDirectory with a file |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1426 |
named aFileName" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1427 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1428 |
aPath do:[:dirName | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1429 |
|realName| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1430 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1431 |
(OperatingSystem isReadable:(realName := dirName , '/' , aDirName , '/' , aFileName)) ifTrue: [ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1432 |
^ realName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1433 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1434 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1435 |
^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1436 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1437 |
|
88 | 1438 |
language |
1439 |
"return the language setting" |
|
1440 |
||
1441 |
^ Language |
|
1442 |
! |
|
1443 |
||
1444 |
languageTerritory |
|
1445 |
"return the language territory setting" |
|
1446 |
||
1447 |
^ LanguageTerritory |
|
1448 |
! |
|
1449 |
||
122 | 1450 |
logDoits |
1451 |
"return true if doits should go into the changes file |
|
1452 |
as well as changes - by default, this is off, since |
|
1453 |
it can blow up the changes file enormously ... |
|
1454 |
" |
|
1455 |
||
1456 |
^ LogDoits |
|
1457 |
||
1458 |
" |
|
1459 |
LogDoits := false |
|
1460 |
LogDoits := true |
|
1461 |
" |
|
1462 |
! |
|
1463 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1464 |
loadBinaries:aBoolean |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1465 |
"turn on/off loading of binary objects" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1466 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1467 |
LoadBinaries := aBoolean |
453 | 1468 |
! |
1469 |
||
122 | 1470 |
logDoits:aBoolean |
1471 |
"turn on/off logging of doits in the changes file. |
|
1472 |
By default, this is off, since it can blow up the |
|
1473 |
changes file enormously ... |
|
1474 |
" |
|
1475 |
||
1476 |
LogDoits := aBoolean |
|
1477 |
||
1478 |
! |
|
1479 |
||
329 | 1480 |
getSourceFileName:aFileName |
1481 |
"search aFileName in some standard places |
|
1482 |
(subdirectories named 'source' in SystemPath); |
|
1483 |
return the absolute filename or nil if none is found." |
|
1484 |
||
1485 |
(aFileName startsWith:'/') ifTrue:[ |
|
1486 |
"dont use path for absolute file names" |
|
1487 |
||
1488 |
^ aFileName |
|
1489 |
]. |
|
1490 |
||
1491 |
SourcePath isNil ifTrue:[ |
|
1492 |
SourcePath := self constructPathFor:'source' |
|
1493 |
]. |
|
1494 |
||
1495 |
^ self searchPath:SourcePath for:aFileName in:'source' |
|
1496 |
||
1497 |
" |
|
1498 |
Smalltalk getSourceFileName:'Smalltalk.st' |
|
1499 |
" |
|
1500 |
! |
|
1501 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1502 |
systemPath |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1503 |
"return a collection of directorynames, where smalltalk |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1504 |
looks for system files |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1505 |
(usually in subdirs such as resources, bitmaps, source etc.) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1506 |
see comment in Smalltalk>>initSystemPath." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1507 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1508 |
^ SystemPath |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1509 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1510 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1511 |
Smalltalk systemPath |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1512 |
Smalltalk systemPath addLast:'someOtherDirectoryPath' |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1513 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1514 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1515 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1516 |
realSystemPath |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1517 |
"return the realSystemPath - thats the directorynames from |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1518 |
SystemPath which exist and are readable" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1519 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1520 |
RealSystemPath isNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1521 |
RealSystemPath := SystemPath select:[:dirName | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1522 |
(OperatingSystem isDirectory:dirName) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1523 |
and:[OperatingSystem isReadable:dirName] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1524 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1525 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1526 |
^ RealSystemPath |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1527 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1528 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1529 |
constructPathFor:aDirectoryName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1530 |
"search for aDirectory in SystemPath" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1531 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1532 |
^ self realSystemPath select:[:dirName | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1533 |
OperatingSystem isDirectory:(dirName , '/' , aDirectoryName) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1534 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1535 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1536 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1537 |
loadBinaries |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1538 |
"return true, if binaries should be loaded into the system, |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1539 |
false if this should be suppressed. The default is false (for now)." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1540 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1541 |
^ LoadBinaries |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1542 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1543 |
|
329 | 1544 |
getResourceFileName:aFileName |
1545 |
"search aFileName in some standard places |
|
1546 |
(subdirectories named 'resource' in SystemPath); |
|
1547 |
return the absolute filename or nil if none is found." |
|
70 | 1548 |
|
1549 |
(aFileName startsWith:'/') ifTrue:[ |
|
159 | 1550 |
"dont use path for absolute file names" |
70 | 1551 |
|
159 | 1552 |
^ aFileName |
70 | 1553 |
]. |
1554 |
||
329 | 1555 |
ResourcePath isNil ifTrue:[ |
1556 |
ResourcePath := self constructPathFor:'resources' |
|
1557 |
]. |
|
1558 |
||
1559 |
^ self searchPath:ResourcePath for:aFileName in:'resources' |
|
1560 |
||
1561 |
" |
|
1562 |
Smalltalk getResourceFileName:'SBrowser.rs' |
|
1563 |
" |
|
1564 |
! |
|
1565 |
||
1566 |
getBitmapFileName:aFileName |
|
1567 |
"search aFileName in some standard places |
|
1568 |
(subdirectories named 'bitmaps' in SystemPath); |
|
1569 |
return the absolute filename or nil if none is found." |
|
1570 |
||
1571 |
(aFileName startsWith:'/') ifTrue:[ |
|
1572 |
"dont use path for absolute file names" |
|
1573 |
||
1574 |
^ aFileName |
|
1575 |
]. |
|
1576 |
||
1577 |
BitmapPath isNil ifTrue:[ |
|
1578 |
BitmapPath := self constructPathFor:'bitmaps' |
|
1579 |
]. |
|
1580 |
||
1581 |
^ self searchPath:BitmapPath for:aFileName in:'bitmaps' |
|
1582 |
||
1583 |
" |
|
1584 |
Smalltalk getBitmapFileName:'SBrowser.xbm' |
|
1585 |
" |
|
1586 |
! |
|
1587 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1588 |
flushPathCaches |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1589 |
RealSystemPath := ResourcePath := SourcePath := BitmapPath := BinaryPath := FileInPath := nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1590 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1591 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1592 |
bitmapFileStreamFor:aFileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1593 |
"search aFileName in some standard places; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1594 |
return a readonly fileStream or nil if not found. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1595 |
Searches in subdirectories named 'bitmaps' in SystemPath" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1596 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1597 |
|aString| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1598 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1599 |
aString := self getBitmapFileName:aFileName. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1600 |
aString notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1601 |
^ FileStream readonlyFileNamed:aString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1602 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1603 |
^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1604 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1605 |
|
453 | 1606 |
getSystemFileName:aFileName |
1607 |
"search aFileName in some standard places; |
|
1608 |
return the absolute filename or nil if none is found. |
|
1609 |
see comment in Smalltalk>>initSystemPath." |
|
1610 |
||
1611 |
"credits for this method go to Markus ...." |
|
1612 |
||
1613 |
(aFileName startsWith:'/') ifTrue:[ |
|
1614 |
"dont use path for absolute file names" |
|
1615 |
||
1616 |
^ aFileName |
|
1617 |
]. |
|
1618 |
||
1619 |
self realSystemPath do:[:dirName | |
|
1620 |
|realName| |
|
1621 |
||
1622 |
realName := dirName , '/' , aFileName. |
|
1623 |
(OperatingSystem isReadable:realName) ifTrue: [ |
|
1624 |
^ realName |
|
1625 |
] |
|
1626 |
]. |
|
1627 |
^ nil |
|
1628 |
! |
|
1629 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1630 |
systemFileStreamFor:aFileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1631 |
"search aFileName in some standard places; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1632 |
return a readonly fileStream or nil if not found. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1633 |
see comment in Smalltalk>>initSystemPath" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1634 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1635 |
|aString| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1636 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1637 |
aString := self getSystemFileName:aFileName. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1638 |
aString notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1639 |
^ FileStream readonlyFileNamed:aString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1640 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1641 |
^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1642 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1643 |
|
453 | 1644 |
systemPath:aPath |
1645 |
"set the collection of directorynames, where smalltalk |
|
1646 |
looks for system files |
|
1647 |
(usually in subdirs such as resources, bitmaps, source etc.) |
|
1648 |
see comment in Smalltalk>>initSystemPath." |
|
1649 |
||
1650 |
SystemPath := aPath. |
|
1651 |
self flushPathCaches |
|
1652 |
||
1653 |
" |
|
1654 |
Smalltalk systemPath |
|
1655 |
Smalltalk systemPath:(Smalltalk systemPath copy addLast:'someOtherDirectoryPath') |
|
1656 |
" |
|
1657 |
! |
|
1658 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1659 |
resourceFileStreamFor:aFileName |
453 | 1660 |
"search aFileName in some standard places; |
1661 |
return a readonly fileStream or nil if not found. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1662 |
Searches in subdirectories named 'resource' in SystemPath" |
453 | 1663 |
|
1664 |
|aString| |
|
1665 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1666 |
aString := self getResourceFileName:aFileName. |
453 | 1667 |
aString notNil ifTrue:[ |
1668 |
^ FileStream readonlyFileNamed:aString |
|
1669 |
]. |
|
1670 |
^ nil |
|
1671 |
! |
|
1672 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1673 |
sourceFileStreamFor:aFileName |
453 | 1674 |
"search aFileName in some standard places; |
1675 |
return a readonly fileStream or nil if not found. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1676 |
Searches in subdirectories named 'source' in SystemPath" |
453 | 1677 |
|
1678 |
|aString| |
|
1679 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1680 |
aString := self getSourceFileName:aFileName. |
453 | 1681 |
aString notNil ifTrue:[ |
1682 |
^ FileStream readonlyFileNamed:aString |
|
1683 |
]. |
|
1684 |
^ nil |
|
1685 |
! |
|
1686 |
||
329 | 1687 |
getFileInFileName:aFileName |
1688 |
"search aFileName in some standard places |
|
1689 |
(subdirectories named 'fileIn' in SystemPath); |
|
1690 |
return the absolute filename or nil if none is found." |
|
1691 |
||
1692 |
(aFileName startsWith:'/') ifTrue:[ |
|
1693 |
"dont use path for absolute file names" |
|
1694 |
||
1695 |
^ aFileName |
|
1696 |
]. |
|
1697 |
||
1698 |
FileInPath isNil ifTrue:[ |
|
1699 |
FileInPath := self constructPathFor:'fileIn' |
|
1700 |
]. |
|
1701 |
||
1702 |
^ self searchPath:FileInPath for:aFileName in:'fileIn' |
|
1703 |
||
1704 |
! |
|
1705 |
||
1706 |
getBinaryFileName:aFileName |
|
1707 |
"search aFileName in some standard places |
|
1708 |
(subdirectories named 'binary' in SystemPath); |
|
1709 |
return the absolute filename or nil if none is found." |
|
1710 |
||
1711 |
(aFileName startsWith:'/') ifTrue:[ |
|
1712 |
"dont use path for absolute file names" |
|
1713 |
||
1714 |
^ aFileName |
|
1715 |
]. |
|
1716 |
||
1717 |
BinaryPath isNil ifTrue:[ |
|
1718 |
BinaryPath := self constructPathFor:'binary' |
|
1719 |
]. |
|
1720 |
||
1721 |
^ self searchPath:BinaryPath for:aFileName in:'binary' |
|
70 | 1722 |
! |
1723 |
||
10 | 1724 |
readAbbreviations |
202 | 1725 |
"read classname to filename mappings from include/abbrev.stc. |
329 | 1726 |
sigh - all for those poor sys5.3 or MSDOS people with short filenames ..." |
10 | 1727 |
|
345 | 1728 |
|aStream line words| |
10 | 1729 |
|
202 | 1730 |
CachedAbbreviations := IdentityDictionary new. |
329 | 1731 |
aStream := self systemFileStreamFor:'include/abbrev.stc'. |
10 | 1732 |
aStream notNil ifTrue:[ |
159 | 1733 |
[aStream atEnd] whileFalse:[ |
1734 |
line := aStream nextLine. |
|
1735 |
line notNil ifTrue:[ |
|
1736 |
(line startsWith:'#') ifFalse:[ |
|
345 | 1737 |
words := line asCollectionOfWords. |
1738 |
words size >= 2 ifTrue:[ |
|
1739 |
CachedAbbreviations |
|
1740 |
at:(words at:1) withoutSeparators asSymbol |
|
1741 |
put:(words at:2) withoutSeparators. |
|
1742 |
] |
|
1743 |
] |
|
1744 |
] |
|
1745 |
]. |
|
1746 |
aStream close |
|
1747 |
] |
|
1748 |
||
1749 |
" |
|
1750 |
Smalltalk readAbbreviations |
|
1751 |
" |
|
1752 |
! |
|
1753 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1754 |
fileInFileStreamFor:aFileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1755 |
"search aFileName in some standard places; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1756 |
return a readonly fileStream or nil if not found. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1757 |
Searches in subdirectories named 'fileIn' in SystemPath" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1758 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1759 |
|aString| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1760 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1761 |
aString := self getFileInFileName:aFileName. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1762 |
aString notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1763 |
^ FileStream readonlyFileNamed:aString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1764 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1765 |
^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1766 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1767 |
|
345 | 1768 |
libraryFileNameOfClass:aClassName |
354 | 1769 |
"read the libinfo file 'liblist.stc' and the abbreviation file |
1770 |
'abbrev.stc' for an entry for aClassName. |
|
1771 |
Search for aClassName in the first col, and return the value found in |
|
1772 |
the 2nd (for the libinfo file) or the 3rd (for the abbrev file) col. |
|
1773 |
Return nil if no entry is found. |
|
1774 |
||
345 | 1775 |
A nil returns means that this class is either built-in or not present |
1776 |
in a package-class library (i.e. either as separate .o or separate .st file). |
|
354 | 1777 |
Otherwise, the returned name is the classLibrary object of that class." |
345 | 1778 |
|
1779 |
|aStream line words n| |
|
1780 |
||
354 | 1781 |
#('include/liblist.stc' 'include/abbrev.stc') |
1782 |
with:#(2 3) do:[:fileName :col | |
|
1783 |
||
1784 |
aStream := self systemFileStreamFor:fileName. |
|
1785 |
aStream notNil ifTrue:[ |
|
1786 |
[aStream atEnd] whileFalse:[ |
|
1787 |
line := aStream nextLine. |
|
1788 |
line notNil ifTrue:[ |
|
1789 |
(line startsWith:'#') ifFalse:[ |
|
1790 |
words := line asCollectionOfWords. |
|
1791 |
(n := words size) > 1 ifTrue:[ |
|
1792 |
(words at:1) = aClassName ifTrue:[ |
|
1793 |
n >= col ifTrue:[ |
|
1794 |
^ (words at:col) withoutSeparators |
|
1795 |
] |
|
345 | 1796 |
] |
159 | 1797 |
] |
1798 |
] |
|
1799 |
] |
|
357 | 1800 |
]. |
1801 |
aStream close |
|
159 | 1802 |
]. |
345 | 1803 |
]. |
354 | 1804 |
|
345 | 1805 |
^ nil |
1806 |
||
1807 |
" |
|
1808 |
Smalltalk libraryFileNameOfClass:'ClockView' |
|
1809 |
Smalltalk libraryFileNameOfClass:'Bag' |
|
1810 |
" |
|
10 | 1811 |
! |
1812 |
||
202 | 1813 |
filenameAbbreviations |
70 | 1814 |
"return a dictionary containing the classname-to-filename |
1815 |
mappings. (needed for sys5.3 users, where filenames are limited |
|
1816 |
to 14 chars)" |
|
7 | 1817 |
|
70 | 1818 |
CachedAbbreviations isNil ifTrue:[ |
159 | 1819 |
self readAbbreviations |
7 | 1820 |
]. |
70 | 1821 |
^ CachedAbbreviations |
77 | 1822 |
|
122 | 1823 |
"flush with: |
1824 |
||
77 | 1825 |
CachedAbbreviations := nil |
1826 |
" |
|
202 | 1827 |
" |
1828 |
Smalltalk filenameAbbreviations |
|
1829 |
" |
|
1 | 1830 |
! |
1831 |
||
1832 |
fileNameForClass:aClassName |
|
1833 |
"return a good filename for aClassName - |
|
1834 |
using abbreviation file if there is one" |
|
1835 |
||
10 | 1836 |
|fileName abbrev| |
1 | 1837 |
|
1838 |
fileName := aClassName. |
|
1839 |
||
10 | 1840 |
"first look, if the class exists and has a fileName" |
1841 |
||
24 | 1842 |
" later ... - compiler should put the source file name into the class |
10 | 1843 |
Symbol hasInterned:aClassName ifTrue:[:sym | |
159 | 1844 |
|class| |
10 | 1845 |
|
159 | 1846 |
(Smalltalk includesKey:sym) ifTrue:[ |
1847 |
class := Smalltalk at:sym. |
|
1848 |
class isClass ifTrue:[ |
|
1849 |
abbrev := class classFileName. |
|
1850 |
] |
|
1851 |
] |
|
10 | 1852 |
]. |
1853 |
" |
|
1854 |
||
7 | 1855 |
"look for abbreviation" |
1 | 1856 |
|
202 | 1857 |
abbrev := self filenameAbbreviations at:fileName ifAbsent:[nil]. |
10 | 1858 |
abbrev notNil ifTrue:[^ abbrev]. |
7 | 1859 |
|
10 | 1860 |
"no abbreviation found - if its a short name, take it" |
1861 |
||
1862 |
OperatingSystem maxFileNameLength < (fileName size + 3) ifTrue:[ |
|
159 | 1863 |
"this will only be triggered on sys5.3 type systems" |
216 | 1864 |
self warn:'cant find short for ' , fileName , ' in abbreviation file' |
1 | 1865 |
]. |
1866 |
^ fileName |
|
1867 |
! |
|
1868 |
||
2 | 1869 |
classNameForFile:aFileName |
10 | 1870 |
"return the className which corresponds to an abbreviated fileName, |
1871 |
or nil if no special translation applies. The given filename arg should |
|
1872 |
NOT include any suffix such as '.st'." |
|
2 | 1873 |
|
357 | 1874 |
^ self filenameAbbreviations keyAtEqualValue:aFileName ifAbsent:[aFileName]. |
2 | 1875 |
|
329 | 1876 |
" |
1877 |
Smalltalk classNameForFile:'DrawObj' |
|
1878 |
" |
|
2 | 1879 |
! |
1880 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1881 |
secureFileIn:aFileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1882 |
"read in the named file, looking for it at standard places. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1883 |
Catch any error during fileIn. Return true if ok, false if failed" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1884 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1885 |
(SignalSet |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1886 |
with:AbortSignal |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1887 |
with:Process terminateSignal) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1888 |
handle:[:ex | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1889 |
ex return |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1890 |
] do:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1891 |
^ self fileIn:aFileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1892 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1893 |
^ false |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1894 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1895 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1896 |
fileIn:aFileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1897 |
"read in the named file - look for it in some standard places; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1898 |
return true if ok, false if failed" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1899 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1900 |
^ self fileIn:aFileName lazy:nil silent:nil logged:false |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1901 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1902 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1903 |
Smalltalk fileIn:'source/TicTacToe.st' |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1904 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1905 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1906 |
"Created: 28.10.1995 / 17:06:28 / cg" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1907 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1908 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1909 |
silentFileIn:aFilename |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1910 |
"same as fileIn:, but do not output 'compiled...'-messages on Transcript. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1911 |
Main use is during startup." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1912 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1913 |
|wasSilent| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1914 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1915 |
wasSilent := self silentLoading:true. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1916 |
[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1917 |
self fileIn:aFilename |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1918 |
] valueNowOrOnUnwindDo:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1919 |
self silentLoading:wasSilent |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1920 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1921 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1922 |
|
345 | 1923 |
fileInClass:aClassName fromObject:aFileName |
70 | 1924 |
"read in the named object file and dynamic-link it into the system |
1925 |
- look for it in some standard places; |
|
1926 |
return true if ok, false if failed." |
|
1 | 1927 |
|
356 | 1928 |
|path ok| |
329 | 1929 |
|
70 | 1930 |
" |
1931 |
check if the dynamic loader class is in |
|
1932 |
" |
|
390 | 1933 |
(LoadBinaries not or:[ObjectFileLoader isNil]) ifTrue:[^ false]. |
1 | 1934 |
|
329 | 1935 |
(path := self getBinaryFileName:aFileName) isNil ifTrue:[^ false]. |
356 | 1936 |
ok := (ObjectFileLoader loadClass:aClassName fromObjectFile:path) notNil. |
1937 |
ok ifTrue:[ |
|
1938 |
Transcript show:' loaded ' , aClassName , ' from ' ; showCr:aFileName. |
|
1939 |
]. |
|
1940 |
^ ok |
|
1 | 1941 |
|
70 | 1942 |
" |
345 | 1943 |
Smalltalk fileInClass:'AbstractPath' fromObject:'../../goodies/Paths/AbstrPath.so' |
1944 |
Smalltalk fileInClass:'ClockView' fromObject:'../../libwidg3/libwidg3.so' |
|
70 | 1945 |
" |
1 | 1946 |
! |
1947 |
||
400 | 1948 |
fileIn:aFileName logged:logged |
1949 |
"read in the named file - look for it in some standard places; |
|
1950 |
return true if ok, false if failed. |
|
1951 |
The argument logged controls, if the changefile is to be updated." |
|
1952 |
||
1953 |
^ self fileIn:aFileName lazy:nil silent:nil logged:logged |
|
1954 |
||
1955 |
" |
|
1956 |
Smalltalk fileIn:'source/TicTacToe.st' logged:false |
|
1957 |
" |
|
1958 |
! |
|
1959 |
||
1960 |
fileIn:aFileName lazy:lazy silent:silent logged:logged |
|
1961 |
"read in the named file - look for it in some standard places; |
|
1962 |
return true if ok, false if failed. |
|
1963 |
If lazy is true, no code is generated for methods, instead stups |
|
1964 |
are created which compile themself when first executed. This allows |
|
1965 |
for much faster fileIn (but slows down the first execution later). |
|
1966 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
|
1967 |
code which is known to be syntactically correct. |
|
1968 |
If silent is true, no compiler messages are output to the transcript. |
|
1969 |
Giving nil for silent/lazy will use the current settings." |
|
1970 |
||
421 | 1971 |
|aStream path wasLazy wasSilent morePath oldSystemPath oldRealPath| |
122 | 1972 |
|
1973 |
" |
|
1974 |
an object or shared object ? |
|
1975 |
" |
|
1976 |
((aFileName endsWith:'.o') |
|
1977 |
or:[(aFileName endsWith:'.obj') |
|
1978 |
or:[aFileName endsWith:'.so']]) ifTrue:[ |
|
390 | 1979 |
(LoadBinaries not or:[ObjectFileLoader isNil]) ifTrue:[^ false]. |
329 | 1980 |
path := self getBinaryFileName:aFileName. |
122 | 1981 |
path isNil ifTrue:[^ false]. |
1982 |
^ ObjectFileLoader loadObjectFile:aFileName |
|
1983 |
]. |
|
1 | 1984 |
|
329 | 1985 |
(aFileName startsWith:'source/') ifTrue:[ |
1986 |
aStream := self sourceFileStreamFor:(aFileName copyFrom:8) |
|
1987 |
] ifFalse:[ |
|
1988 |
(aFileName startsWith:'fileIn/') ifTrue:[ |
|
1989 |
aStream := self fileInFileStreamFor:(aFileName copyFrom:8) |
|
1990 |
] ifFalse:[ |
|
1991 |
aStream := self systemFileStreamFor:aFileName. |
|
375 | 1992 |
(aStream notNil and:[aFileName includes:$/]) ifTrue:[ |
362 | 1993 |
"/ temporarily prepend the files directory |
1994 |
"/ to the searchPath. |
|
1995 |
"/ This allows fileIn-driver files to refer to local |
|
1996 |
"/ files via a relative path, and drivers to fileIn other |
|
1997 |
"/ drivers ... |
|
1998 |
morePath := aStream pathName asFilename directoryName. |
|
1999 |
] |
|
329 | 2000 |
] |
2001 |
]. |
|
1 | 2002 |
aStream isNil ifTrue:[^ false]. |
2003 |
||
329 | 2004 |
lazy notNil ifTrue:[wasLazy := Compiler compileLazy:lazy]. |
2005 |
silent notNil ifTrue:[wasSilent := self silentLoading:silent]. |
|
2006 |
[ |
|
423 | 2007 |
Class updateChangeFileQuerySignal handle:[:ex | |
421 | 2008 |
ex proceedWith:logged |
423 | 2009 |
] do:[ |
421 | 2010 |
oldSystemPath := SystemPath copy. |
2011 |
morePath notNil ifTrue:[ |
|
423 | 2012 |
SystemPath addFirst:morePath. |
2013 |
oldRealPath := RealSystemPath. |
|
2014 |
RealSystemPath := nil. |
|
421 | 2015 |
]. |
2016 |
aStream fileIn |
|
2017 |
] |
|
329 | 2018 |
] valueNowOrOnUnwindDo:[ |
362 | 2019 |
morePath notNil ifTrue:[ |
2020 |
SystemPath := oldSystemPath. |
|
2021 |
RealSystemPath := oldRealPath. |
|
2022 |
]. |
|
329 | 2023 |
lazy notNil ifTrue:[Compiler compileLazy:wasLazy]. |
2024 |
silent notNil ifTrue:[self silentLoading:wasSilent]. |
|
2025 |
aStream close |
|
2026 |
]. |
|
1 | 2027 |
^ true |
2028 |
||
77 | 2029 |
" |
329 | 2030 |
Smalltalk fileIn:'source/TicTacToe.st' lazy:true silent:true |
77 | 2031 |
" |
1 | 2032 |
! |
2033 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2034 |
fileIn:aFileName lazy:lazy |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2035 |
"read in the named file - look for it in some standard places; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2036 |
return true if ok, false if failed. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2037 |
If lazy is true, no code is generated for methods, instead stups |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2038 |
are created which compile themself when first executed. This allows |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2039 |
for much faster fileIn (but slows down the first execution later). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2040 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2041 |
code which is known to be syntactically correct." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2042 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2043 |
^ self fileIn:aFileName lazy:lazy silent:nil logged:false |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2044 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2045 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2046 |
Smalltalk fileIn:'source/TicTacToe.st' lazy:true |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2047 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2048 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2049 |
"Created: 28.10.1995 / 17:06:36 / cg" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2050 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2051 |
|
453 | 2052 |
fileIn:aFileName lazy:lazy silent:silent |
2053 |
"read in the named file - look for it in some standard places; |
|
2054 |
return true if ok, false if failed. |
|
2055 |
If lazy is true, no code is generated for methods, instead stups |
|
2056 |
are created which compile themself when first executed. This allows |
|
2057 |
for much faster fileIn (but slows down the first execution later). |
|
2058 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
|
2059 |
code which is known to be syntactically correct. |
|
2060 |
If silent is true, no compiler messages are output to the transcript. |
|
2061 |
Giving nil for silent/lazy will use the current settings." |
|
2062 |
||
2063 |
^ self fileIn:aFileName lazy:lazy silent:silent logged:false |
|
2064 |
||
2065 |
"Created: 28.10.1995 / 17:06:41 / cg" |
|
2066 |
! |
|
2067 |
||
1 | 2068 |
fileInChanges |
2069 |
"read in the last changes file - bringing the system to the state it |
|
70 | 2070 |
had when left the last time. |
2071 |
WARNING: this method is rubbish: it should only read things after the |
|
400 | 2072 |
last '**snapshot**' - entry |
2073 |
(instead of the complete changes file)." |
|
1 | 2074 |
|
70 | 2075 |
" |
400 | 2076 |
do NOT update the changes file now ... |
70 | 2077 |
" |
400 | 2078 |
self fileIn:'changes' logged:false |
1 | 2079 |
|
77 | 2080 |
" |
2081 |
Smalltalk fileInChanges |
|
2082 |
" |
|
1 | 2083 |
! |
2084 |
||
2085 |
fileInClass:aClassName |
|
10 | 2086 |
"find a source/object file for aClassName and -if found - load it. |
95 | 2087 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
2088 |
finally source file (.st) in that order. |
|
70 | 2089 |
The file is first searched for using the class name, then the abbreviated name." |
1 | 2090 |
|
216 | 2091 |
^ self fileInClass:aClassName initialize:true lazy:false silent:false |
2092 |
! |
|
2093 |
||
2094 |
fileInClass:aClassName initialize:doInit lazy:loadLazy silent:beSilent |
|
2095 |
"find a source/object file for aClassName and -if found - load it. |
|
345 | 2096 |
search is in some standard places, trying driver-file (.ld), object-file (.o) and |
2097 |
finally source file (.st), in that order. |
|
2098 |
The file is first searched for using the class name, then the abbreviated name. |
|
2099 |
The argument doInit controlls if the class should be sent a #initialize after the |
|
2100 |
load; loadLazy tells if it should be loaded lazyly. beSilent tells if the compiler |
|
2101 |
should not send notes to the transcript." |
|
2102 |
||
2103 |
|shortName libName newClass ok wasLazy wasSilent| |
|
216 | 2104 |
|
2105 |
wasLazy := Compiler compileLazy:loadLazy. |
|
2106 |
wasSilent := self silentLoading:beSilent. |
|
2107 |
||
7 | 2108 |
[ |
216 | 2109 |
Class withoutUpdatingChangesDo: |
2110 |
[ |
|
329 | 2111 |
ok := false. |
2112 |
||
159 | 2113 |
" |
216 | 2114 |
first, look for a loader-driver file (in fileIn/xxx.ld) |
2115 |
" |
|
329 | 2116 |
(ok := self fileIn:('fileIn/' , aClassName , '.ld') lazy:loadLazy silent:beSilent) |
159 | 2117 |
ifFalse:[ |
216 | 2118 |
shortName := self fileNameForClass:aClassName. |
159 | 2119 |
" |
216 | 2120 |
try abbreviated driver-file (in fileIn/xxx.ld) |
159 | 2121 |
" |
329 | 2122 |
shortName ~= aClassName ifTrue:[ |
2123 |
ok := self fileIn:('fileIn/' , shortName , '.ld') lazy:loadLazy silent:beSilent |
|
2124 |
]. |
|
2125 |
ok ifFalse:[ |
|
216 | 2126 |
" |
345 | 2127 |
then, if dynamic linking is available, |
216 | 2128 |
" |
390 | 2129 |
(LoadBinaries and:[ObjectFileLoader notNil]) ifTrue:[ |
345 | 2130 |
" |
2131 |
first look for a class packages shared binary in binary/xxx.o |
|
2132 |
" |
|
2133 |
libName := self libraryFileNameOfClass:aClassName. |
|
2134 |
libName notNil ifTrue:[ |
|
2135 |
(ok := self fileInClass:aClassName fromObject:(libName, '.so')) |
|
159 | 2136 |
ifFalse:[ |
345 | 2137 |
ok := self fileInClass:aClassName fromObject:(libName, '.o') |
2138 |
]. |
|
2139 |
]. |
|
2140 |
||
2141 |
" |
|
2142 |
then, look for a shared binary in binary/xxx.o |
|
2143 |
" |
|
2144 |
ok ifFalse:[ |
|
2145 |
(ok := self fileInClass:aClassName fromObject:(aClassName, '.so')) |
|
2146 |
ifFalse:[ |
|
2147 |
(ok := self fileInClass:aClassName fromObject:(aClassName, '.o')) |
|
2148 |
ifFalse:[ |
|
2149 |
shortName ~= aClassName ifTrue:[ |
|
2150 |
(ok := self fileInClass:aClassName fromObject:(shortName, '.so')) |
|
2151 |
ifFalse:[ |
|
2152 |
ok := self fileInClass:aClassName fromObject:(shortName, '.o') |
|
2153 |
] |
|
2154 |
]. |
|
216 | 2155 |
]. |
159 | 2156 |
]. |
2157 |
]. |
|
2158 |
]. |
|
77 | 2159 |
|
216 | 2160 |
" |
2161 |
if that did not work, look for an st-source file ... |
|
2162 |
" |
|
2163 |
ok ifFalse:[ |
|
329 | 2164 |
(ok := self fileIn:(aClassName , '.st') lazy:loadLazy silent:beSilent) |
159 | 2165 |
ifFalse:[ |
329 | 2166 |
shortName ~= aClassName ifTrue:[ |
2167 |
ok := self fileIn:(shortName , '.st') lazy:loadLazy silent:beSilent |
|
2168 |
]. |
|
2169 |
ok ifFalse:[ |
|
216 | 2170 |
" |
2171 |
... and in the standard source-directory |
|
2172 |
" |
|
329 | 2173 |
(ok := self fileIn:('source/' , aClassName , '.st') lazy:loadLazy silent:beSilent) |
216 | 2174 |
ifFalse:[ |
329 | 2175 |
shortName ~= aClassName ifTrue:[ |
2176 |
ok := self fileIn:('source/' , shortName , '.st') lazy:loadLazy silent:beSilent |
|
2177 |
] |
|
216 | 2178 |
] |
159 | 2179 |
] |
2180 |
] |
|
2181 |
] |
|
216 | 2182 |
]. |
2183 |
] |
|
2184 |
]. |
|
329 | 2185 |
ok ifTrue:[ |
2186 |
newClass := self at:(aClassName asSymbol). |
|
2187 |
newClass notNil ifTrue:[ |
|
2188 |
doInit ifTrue:[ |
|
2189 |
newClass initialize |
|
2190 |
] |
|
216 | 2191 |
] |
2192 |
]. |
|
2193 |
] valueNowOrOnUnwindDo:[ |
|
2194 |
Compiler compileLazy:wasLazy. |
|
2195 |
self silentLoading:wasSilent |
|
202 | 2196 |
]. |
159 | 2197 |
|
216 | 2198 |
^ newClass |
191 | 2199 |
! |
2200 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2201 |
fileInClass:aClassName initialize:doInit |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2202 |
"find a source/object file for aClassName and -if found - load it. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2203 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2204 |
finally source file (.st) in that order. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2205 |
The file is first searched for using the class name, then the abbreviated name." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2206 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2207 |
^ self fileInClass:aClassName initialize:doInit lazy:false silent:false |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2208 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2209 |
|
453 | 2210 |
fileInClass:aClassName initialize:doInit lazy:loadLazy |
2211 |
"find a source/object file for aClassName and -if found - load it. |
|
2212 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
|
2213 |
finally source file (.st) in that order. |
|
2214 |
The file is first searched for using the class name, then the abbreviated name." |
|
2215 |
||
2216 |
^ self fileInClass:aClassName initialize:doInit lazy:loadLazy silent:false |
|
2217 |
! |
|
2218 |
||
191 | 2219 |
compressSources |
2220 |
"compress the sources file, and remove all method source strings |
|
2221 |
from the system and replace them by refs to a string in the source file. |
|
2222 |
This is a bit different in ST/X than in other smalltalks, |
|
2223 |
since we use per-class sourcefiles for the compiled classes, |
|
2224 |
and a mix of in-memory strings and one-for-all sourceFile for |
|
2225 |
incremental compiled methods. |
|
2226 |
Therefore, only those sources which are not coming from compiled |
|
2227 |
methods are put into the 'st.src' file - all others are untouched. |
|
2228 |
This is being automated - so dont care for now." |
|
2229 |
||
2230 |
" |
|
2231 |
first, find all methods which contain either a string-ref |
|
2232 |
or an external string in the 'st.src' file |
|
2233 |
" |
|
202 | 2234 |
|newStream table source pos fileName| |
191 | 2235 |
|
2236 |
newStream := 'src.tmp' asFilename writeStream. |
|
2237 |
newStream isNil ifTrue:[ |
|
2238 |
self error:'cannot create new temporary source file'. |
|
2239 |
^ self |
|
2240 |
]. |
|
2241 |
||
2242 |
table := IdentityDictionary new:100. |
|
2243 |
||
329 | 2244 |
Method allSubInstancesDo:[:aMethod | |
191 | 2245 |
source := nil. |
2246 |
aMethod sourcePosition notNil ifTrue:[ |
|
2247 |
aMethod sourceFilename = 'st.src' ifTrue:[ |
|
2248 |
source := aMethod source. |
|
2249 |
] |
|
2250 |
] ifFalse:[ |
|
2251 |
source := aMethod source |
|
2252 |
]. |
|
2253 |
||
2254 |
source notNil ifTrue:[ |
|
2255 |
pos := newStream position. |
|
2256 |
newStream nextChunkPut:source. |
|
2257 |
||
2258 |
" |
|
2259 |
dont change the methods info - maybe some write error |
|
202 | 2260 |
occurs later, in that case we abort and leave everything |
191 | 2261 |
untouched. |
2262 |
" |
|
2263 |
table at:aMethod put:pos |
|
2264 |
] |
|
2265 |
]. |
|
2266 |
||
2267 |
newStream close. |
|
2268 |
||
2269 |
" |
|
2270 |
now, rename the new source file, |
|
2271 |
" |
|
202 | 2272 |
fileName := (ObjectMemory nameForSources). |
2273 |
('src.tmp' asFilename renameTo:fileName) ifFalse:[ |
|
191 | 2274 |
self error:'cannot rename temporary file to new source file'. |
2275 |
^ self |
|
2276 |
]. |
|
2277 |
||
2278 |
"good - now go over all changed methods, and change their |
|
2279 |
source reference" |
|
2280 |
||
2281 |
table keysAndValuesDo:[:aMethod :pos | |
|
202 | 2282 |
aMethod sourceFilename:fileName position:pos. |
271 | 2283 |
"/ aMethod printNL. |
191 | 2284 |
]. |
2285 |
||
2286 |
" |
|
2287 |
Smalltalk compressSources |
|
2288 |
" |
|
1 | 2289 |
! ! |
2 | 2290 |
|
453 | 2291 |
!Smalltalk class methodsFor:'time-versions'! |
2292 |
||
2293 |
majorVersionNr |
|
2294 |
"return the major version number. |
|
2295 |
This is only incremented for very fundamental changes, |
|
2296 |
which make old object files totally incompatible |
|
2297 |
(for example, if the layout/representation of fundamental |
|
2298 |
classes changes)." |
|
2299 |
||
2300 |
^ 2 |
|
2301 |
||
2302 |
" |
|
2303 |
Smalltalk majorVersionNr |
|
2304 |
" |
|
2305 |
! |
|
2306 |
||
2307 |
minorVersionNr |
|
2308 |
"return the minor version number. |
|
2309 |
This is incremented for changes which make some old object |
|
2310 |
files incompatible, or the protocol changes such that some |
|
2311 |
classes need rework." |
|
2312 |
||
2313 |
^ 10 |
|
2314 |
||
2315 |
" |
|
2316 |
Smalltalk minorVersionNr |
|
2317 |
" |
|
2318 |
! |
|
2319 |
||
2320 |
revisionNr |
|
2321 |
"return the revision number. |
|
2322 |
Incremented for releases which fix bugs/add features |
|
2323 |
and represent a stable workable version which got published |
|
2324 |
to the outside world." |
|
2325 |
||
456 | 2326 |
^ 8 |
453 | 2327 |
|
2328 |
" |
|
2329 |
Smalltalk revisionNr |
|
2330 |
" |
|
2331 |
! |
|
2332 |
||
2333 |
versionString |
|
2334 |
"return the version string" |
|
2335 |
||
2336 |
^ (self majorVersionNr printString , |
|
2337 |
'.', |
|
2338 |
self minorVersionNr printString , |
|
2339 |
'.', |
|
2340 |
self revisionNr printString) |
|
2341 |
||
2342 |
" |
|
2343 |
Smalltalk versionString |
|
2344 |
" |
|
2345 |
! |
|
2346 |
||
2347 |
versionDate |
|
456 | 2348 |
"return the executables build date - thats the date when the smalltalk |
2349 |
executable was built" |
|
453 | 2350 |
%{ |
456 | 2351 |
extern char *__getBuildDateString(); |
2352 |
||
2353 |
RETURN (__MKSTRING(__getBuildDateString() COMMA_SND) ); |
|
2354 |
%} |
|
453 | 2355 |
" |
2356 |
Smalltalk versionDate |
|
2357 |
" |
|
2358 |
! |
|
2359 |
||
2360 |
releaseNr |
|
2361 |
"return the revision number. |
|
2362 |
Incremented for releases which fix bugs/add features." |
|
2363 |
||
2364 |
^ 2 |
|
2365 |
||
2366 |
" |
|
2367 |
Smalltalk releaseNr |
|
2368 |
" |
|
2369 |
! |
|
2370 |
||
2371 |
configuration |
|
2372 |
"for developers only: return the configuration, with which |
|
2373 |
this smalltalk was compiled." |
|
2374 |
||
2375 |
%{ |
|
2376 |
extern char *__getConfigurationString(); |
|
2377 |
||
2378 |
RETURN (__MKSTRING(__getConfigurationString() COMMA_SND)); |
|
2379 |
%} |
|
2380 |
||
2381 |
" |
|
2382 |
Smalltalk configuration |
|
2383 |
" |
|
2384 |
! |
|
2385 |
||
2386 |
copyrightString |
|
2387 |
"return a copyright string" |
|
2388 |
||
2389 |
^ 'Copyright (c) 1988-95 by Claus Gittinger' |
|
2390 |
||
2391 |
" |
|
2392 |
Smalltalk copyrightString |
|
2393 |
" |
|
2394 |
! |
|
2395 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2396 |
timeStamp |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2397 |
"return a string useful for timestamping a file. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2398 |
The returned string is padded with spaces for a constant |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2399 |
length (to avoid changing a files size in fileOut with unchanged |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2400 |
class)." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2401 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2402 |
^ ('''From Smalltalk/X, Version:' , (Smalltalk versionString) , ' on ' |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2403 |
, Date today printString , ' at ' , Time now printString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2404 |
, '''') paddedTo:80 with:(Character space) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2405 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
2406 |
|
453 | 2407 |
hello |
2408 |
"return a greeting string" |
|
2409 |
||
2410 |
"stupid: this should come from a resource file ... |
|
2411 |
but I dont use it here, to allow mini-systems without |
|
2412 |
Resource-stuff." |
|
2413 |
||
2414 |
(Language == #german) ifTrue:[ |
|
2415 |
^ 'Willkommen bei SmallTalk/X - Version ' |
|
2416 |
, self versionString , ' vom ' , self versionDate |
|
2 | 2417 |
]. |
453 | 2418 |
(Language == #french) ifTrue:[ |
2419 |
^ 'Bienvenue ` SmallTalk/X - version ' |
|
2420 |
, self versionString , ' de ' , self versionDate |
|
2421 |
]. |
|
2422 |
^ 'Hello World - here is SmallTalk/X version ' |
|
2423 |
, self versionString , ' of ' , self versionDate |
|
2424 |
||
2425 |
" |
|
2426 |
Smalltalk hello |
|
2427 |
" |
|
2 | 2428 |
! ! |
453 | 2429 |