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