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