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