11 " |
11 " |
12 |
12 |
13 Object subclass:#Smalltalk |
13 Object subclass:#Smalltalk |
14 instanceVariableNames:'' |
14 instanceVariableNames:'' |
15 classVariableNames:'ExitBlocks CachedClasses SystemPath |
15 classVariableNames:'ExitBlocks CachedClasses SystemPath |
16 StartupClass StartupSelector StartupArguments |
16 StartupClass StartupSelector StartupArguments |
17 CachedAbbreviations |
17 CachedAbbreviations |
18 SilentLoading Initializing |
18 SilentLoading Initializing |
19 StandAlone |
19 StandAlone |
20 LogDoits' |
20 LogDoits' |
21 poolDictionaries:'' |
21 poolDictionaries:'' |
22 category:'System-Support' |
22 category:'System-Support' |
23 ! |
23 ! |
24 |
24 |
25 Smalltalk comment:' |
25 Smalltalk comment:' |
26 COPYRIGHT (c) 1988 by Claus Gittinger |
26 COPYRIGHT (c) 1988 by Claus Gittinger |
27 All Rights Reserved |
27 All Rights Reserved |
28 |
28 |
29 $Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.21 1994-08-23 23:11:28 claus Exp $ |
29 $Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.22 1994-10-10 00:28:32 claus Exp $ |
30 '! |
30 '! |
31 |
31 |
32 " |
32 " |
33 dont depend on these being global - they will become |
33 dont depend on these being global - they will become |
34 class variables of some class ... |
34 class variables of some class ... |
70 (due to the need to be able to access globals from c-code as well). |
70 (due to the need to be able to access globals from c-code as well). |
71 However, it provides the known enumeration protocol. |
71 However, it provides the known enumeration protocol. |
72 It may change to become a subclass of collection at some time ... |
72 It may change to become a subclass of collection at some time ... |
73 |
73 |
74 Instance variables: |
74 Instance variables: |
75 none - all handling is done in the VM |
75 none - all handling is done in the VM |
76 |
76 |
77 Class variables: |
77 Class variables: |
78 ExitBlocks <Collection> blocks to evaluate before system is |
78 ExitBlocks <Collection> blocks to evaluate before system is |
79 left. Not currently used. |
79 left. Not currently used. |
80 |
80 |
81 CachedClasses <Collection> known classes (cached for faster enumeration) |
81 CachedClasses <Collection> known classes (cached for faster enumeration) |
82 |
82 |
83 SystemPath <Collection> path to search for system files (sources, bitmaps etc) |
83 SystemPath <Collection> path to search for system files (sources, bitmaps etc) |
84 |
84 |
85 StartupClass <Class> class, which gets initial message |
85 StartupClass <Class> class, which gets initial message |
86 (right after VM initialization) |
86 (right after VM initialization) |
87 StartupSelector <Symbol> message sent to StartupClass |
87 StartupSelector <Symbol> message sent to StartupClass |
88 |
88 |
89 CachedAbbreviations |
89 CachedAbbreviations |
90 <Dictionary> className to filename mappings |
90 <Dictionary> className to filename mappings |
91 |
91 |
92 SilentLoading <Boolean> suppresses messages during fileIn and in compiler |
92 SilentLoading <Boolean> suppresses messages during fileIn and in compiler |
93 (can be set to true from a customized main) |
93 (can be set to true from a customized main) |
94 |
94 |
95 LogDoits <Boolean> if true, doits are also logged in the changes |
95 LogDoits <Boolean> if true, doits are also logged in the changes |
96 file. Default is false, since the changes file |
96 file. Default is false, since the changes file |
97 may become huge ... |
97 may become huge ... |
98 " |
98 " |
99 ! ! |
99 ! ! |
100 |
100 |
101 !Smalltalk class methodsFor:'time-versions'! |
101 !Smalltalk class methodsFor:'time-versions'! |
102 |
102 |
203 "stupid: this should come from a resource file ... |
203 "stupid: this should come from a resource file ... |
204 but I dont use it here, to allow mini-systems without |
204 but I dont use it here, to allow mini-systems without |
205 Resource-stuff." |
205 Resource-stuff." |
206 |
206 |
207 (Language == #german) ifTrue:[ |
207 (Language == #german) ifTrue:[ |
208 ^ 'Willkommen bei SmallTalk/X version ' |
208 ^ 'Willkommen bei SmallTalk/X version ' |
209 , self versionString , ' vom ' , self versionDate |
209 , self versionString , ' vom ' , self versionDate |
210 ]. |
210 ]. |
211 (Language == #french) ifTrue:[ |
211 (Language == #french) ifTrue:[ |
212 ^ 'Bienvenue a SmallTalk/X version ' |
212 ^ 'Bienvenue a SmallTalk/X version ' |
213 , self versionString , ' de ' , self versionDate |
213 , self versionString , ' de ' , self versionDate |
214 ]. |
214 ]. |
215 ^ 'Hello World - here is SmallTalk/X version ' |
215 ^ 'Hello World - here is SmallTalk/X version ' |
216 , self versionString , ' of ' , self versionDate |
216 , self versionString , ' of ' , self versionDate |
217 |
217 |
218 " |
218 " |
265 " |
265 " |
266 Inspector := MiniInspector. |
266 Inspector := MiniInspector. |
267 Debugger := MiniDebugger. |
267 Debugger := MiniDebugger. |
268 Compiler := ByteCodeCompiler. |
268 Compiler := ByteCodeCompiler. |
269 Compiler isNil ifTrue:[ |
269 Compiler isNil ifTrue:[ |
270 " |
270 " |
271 ByteCodeCompiler is not in the system (i.e. has not been linked in) |
271 ByteCodeCompiler is not in the system (i.e. has not been linked in) |
272 this allows at least immediate evaluations for runtime systems without compiler |
272 this allows at least immediate evaluations for runtime systems without compiler |
273 NOTICE: a parser is always needed, otherwise we cannot read resource files etc. |
273 NOTICE: a parser is always needed, otherwise we cannot read resource files etc. |
274 " |
274 " |
275 Compiler := Parser |
275 Compiler := Parser |
276 ]. |
276 ]. |
277 |
277 |
278 " |
278 " |
279 now finally initialize all classes |
279 now, finally, initialize all leftover classes |
280 " |
280 " |
|
281 "/ Object allSubclassesInOrderDo:[:aClass | |
281 self allBehaviorsDo:[:aClass | |
282 self allBehaviorsDo:[:aClass | |
282 " |
283 " |
283 avoid never-ending story ... |
284 avoid never-ending story ... |
284 " |
285 " |
285 (aClass ~~ Smalltalk) ifTrue:[ |
286 (aClass ~~ Smalltalk) ifTrue:[ |
286 aClass initialize |
287 "/ 'init ' print. aClass name printNL. |
287 ] |
288 aClass initialize |
288 ]. |
289 ] |
|
290 ]. |
|
291 |
289 " |
292 " |
290 now we can enable the graphical debugger/inspector |
293 now we can enable the graphical debugger/inspector |
291 " |
294 " |
292 self initStandardTools. |
295 self initStandardTools. |
293 self initInterrupts. |
296 self initInterrupts. |
308 |
311 |
309 " |
312 " |
310 extract Language and LanguageTerritory from LANG variable. |
313 extract Language and LanguageTerritory from LANG variable. |
311 the language and territory must not be abbreviated, |
314 the language and territory must not be abbreviated, |
312 valid is for example: english_usa |
315 valid is for example: english_usa |
313 english |
316 english |
314 german |
317 german |
315 german_austria |
318 german_austria |
316 " |
319 " |
317 |
320 |
318 envString := OperatingSystem getEnvironment:'LANG'. |
321 envString := OperatingSystem getEnvironment:'LANG'. |
319 envString notNil ifTrue:[ |
322 envString notNil ifTrue:[ |
320 i := envString indexOf:$_. |
323 i := envString indexOf:$_. |
321 (i == 0) ifTrue:[ |
324 (i == 0) ifTrue:[ |
322 langString := envString. |
325 langString := envString. |
323 terrString := envString |
326 terrString := envString |
324 ] ifFalse:[ |
327 ] ifFalse:[ |
325 langString := envString copyTo:(i - 1). |
328 langString := envString copyTo:(i - 1). |
326 terrString := envString copyFrom:(i + 1) |
329 terrString := envString copyFrom:(i + 1) |
327 ]. |
330 ]. |
328 Language := langString asSymbol. |
331 Language := langString asSymbol. |
329 LanguageTerritory := terrString asSymbol |
332 LanguageTerritory := terrString asSymbol |
330 ]. |
333 ]. |
331 |
334 |
332 " |
335 " |
333 this too is a leftover - once all refs to View3D |
336 this too is a leftover - once all refs to View3D |
334 are removed, this will vanish ... |
337 are removed, this will vanish ... |
335 (please use: View>>defaultStyle:) |
338 (please use: View>>defaultStyle:) |
336 " |
339 " |
337 envString := OperatingSystem getEnvironment:'VIEW3D'. |
340 envString := OperatingSystem getEnvironment:'VIEW3D'. |
338 envString notNil ifTrue:[ |
341 envString notNil ifTrue:[ |
339 firstChar := (envString at:1) asLowercase. |
342 firstChar := (envString at:1) asLowercase. |
340 (firstChar == $t) ifTrue:[ |
343 (firstChar == $t) ifTrue:[ |
341 Smalltalk at:#View3D put:true |
344 Smalltalk at:#View3D put:true |
342 ] ifFalse: [ |
345 ] ifFalse: [ |
343 Smalltalk at:#View3D put:false |
346 Smalltalk at:#View3D put:false |
344 ] |
347 ] |
345 ] |
348 ] |
346 "Smalltalk initGlobalsFromEnvironment" |
349 "Smalltalk initGlobalsFromEnvironment" |
347 ! |
350 ! |
348 |
351 |
349 initStandardTools |
352 initStandardTools |
392 ! |
395 ! |
393 |
396 |
394 initSystemPath |
397 initSystemPath |
395 "setup path where system files are searched for. |
398 "setup path where system files are searched for. |
396 the default path is set to: |
399 the default path is set to: |
397 . |
400 . |
398 .. |
401 .. |
399 $HOME (if defined) |
402 $HOME (if defined) |
400 $HOME/.smalltalk (if defined & existing) |
403 $HOME/.smalltalk (if defined & existing) |
401 $SMALLTALK_LIBDIR (if defined & existing) |
404 $SMALLTALK_LIBDIR (if defined & existing) |
402 /usr/local/lib/smalltalk (if existing) |
405 /usr/local/lib/smalltalk (if existing) |
403 /usr/lib/smalltalk (if existing) |
406 /usr/lib/smalltalk (if existing) |
404 |
407 |
405 of course, it is possible to add entries from the 'smalltalk.rc' |
408 of course, it is possible to add entries from the 'smalltalk.rc' |
406 startup file; add expressions such as: |
409 startup file; add expressions such as: |
407 Smalltalk systemPath addFirst:'/foo/bar/baz'. |
410 Smalltalk systemPath addFirst:'/foo/bar/baz'. |
408 or: |
411 or: |
409 Smalltalk systemPath addLast:'/fee/foe/foo'. |
412 Smalltalk systemPath addLast:'/fee/foe/foo'. |
410 " |
413 " |
411 |
414 |
412 |p homePath| |
415 |p homePath| |
413 |
416 |
414 homePath := OperatingSystem getHomeDirectory. |
417 homePath := OperatingSystem getHomeDirectory. |
461 look for a '-e filename' argument - this will force evaluation of |
464 look for a '-e filename' argument - this will force evaluation of |
462 filename only, no standard startup |
465 filename only, no standard startup |
463 " |
466 " |
464 idx := Arguments indexOf:'-e'. |
467 idx := Arguments indexOf:'-e'. |
465 idx ~~ 0 ifTrue:[ |
468 idx ~~ 0 ifTrue:[ |
466 self fileIn:(Arguments at:idx + 1). |
469 self fileIn:(Arguments at:idx + 1). |
467 self exit |
470 self exit |
468 ]. |
471 ]. |
469 |
472 |
470 (self fileIn:((Arguments at:1) , '.rc')) ifFalse:[ |
473 (self fileIn:((Arguments at:1) , '.rc')) ifFalse:[ |
471 "no .rc file where executable is; try default smalltalk.rc" |
474 "no .rc file where executable is; try default smalltalk.rc" |
472 self fileIn:'smalltalk.rc' |
475 (self fileIn:'smalltalk.rc') ifFalse:[ |
|
476 Transcript showCr:'no startup rc-file found' |
|
477 ] |
473 ]. |
478 ]. |
474 |
479 |
475 Class updateChanges:true. |
480 Class updateChanges:true. |
476 |
481 |
477 (SilentLoading == true) ifFalse:[ "i.e. undefined counts as false" |
482 (SilentLoading == true) ifFalse:[ "i.e. undefined counts as false" |
478 Transcript showCr:(self hello). |
483 Transcript showCr:(self hello). |
479 Transcript showCr:(self copyrightString). |
484 Transcript showCr:(self copyrightString). |
480 Transcript cr. |
485 Transcript cr. |
481 |
486 |
482 DemoMode ifTrue:[ |
487 DemoMode ifTrue:[ |
483 Transcript showCr:'*** Restricted use: ***'. |
488 Transcript showCr:'*** Restricted use: ***'. |
484 Transcript showCr:'*** This program may be used for education only. ***'. |
489 Transcript showCr:'*** This program may be used for education only. ***'. |
485 Transcript showCr:'*** Please read the files COPYRIGHT and LICENSE ***'. |
490 Transcript showCr:'*** Please read the files COPYRIGHT and LICENSE ***'. |
486 Transcript showCr:'*** for more details. ***'. |
491 Transcript showCr:'*** for more details. ***'. |
487 Transcript cr. |
492 Transcript cr. |
488 ]. |
493 ]. |
489 ]. |
494 ]. |
490 |
495 |
491 Initializing := false. |
496 Initializing := false. |
492 |
497 |
493 " |
498 " |
498 |
503 |
499 " |
504 " |
500 if there is a display, start its event dispatcher |
505 if there is a display, start its event dispatcher |
501 " |
506 " |
502 Display notNil ifTrue:[ |
507 Display notNil ifTrue:[ |
503 Display startDispatch. |
508 Display startDispatch. |
504 |
509 |
505 "this is a leftover - will vanish" |
510 "this is a leftover - will vanish" |
506 " " |
511 " " |
507 ModalDisplay notNil ifTrue:[ |
512 ModalDisplay notNil ifTrue:[ |
508 ModalDisplay startDispatch |
513 ModalDisplay startDispatch |
509 ] |
514 ] |
510 " " |
515 " " |
511 ]. |
516 ]. |
512 |
517 |
513 (StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
518 (StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
514 StartupClass perform:StartupSelector withArguments:StartupArguments. |
519 StartupClass perform:StartupSelector withArguments:StartupArguments. |
515 ]. |
520 ]. |
516 |
521 |
517 " |
522 " |
518 if view-classes exist, start dispatching; |
523 if view-classes exist, start dispatching; |
519 otherwise go into a read-eval-print loop |
524 otherwise go into a read-eval-print loop |
520 " |
525 " |
521 Display notNil ifTrue:[ |
526 Display notNil ifTrue:[ |
522 Processor dispatchLoop |
527 Processor dispatchLoop |
523 ] ifFalse:[ |
528 ] ifFalse:[ |
524 self readEvalPrint |
529 self readEvalPrint |
525 ]. |
530 ]. |
526 |
531 |
527 "done" |
532 "done" |
528 |
533 |
529 self exit |
534 self exit |
532 restart |
537 restart |
533 "startup after an image has been loaded; |
538 "startup after an image has been loaded; |
534 there are three change-notifications made to dependents of ObjectMemory, |
539 there are three change-notifications made to dependents of ObjectMemory, |
535 which allow a stepwise re-init: #earlyRestart, #restarted and #returnFromSnapshot. |
540 which allow a stepwise re-init: #earlyRestart, #restarted and #returnFromSnapshot. |
536 #earlyRestart is send first, nothing has been setup yet. |
541 #earlyRestart is send first, nothing has been setup yet. |
537 (should be used to flush all device dependent entries) |
542 (should be used to flush all device dependent entries) |
538 #restarted is send right after. |
543 #restarted is send right after. |
539 (should be used to recreate external resources (fds, bitmaps etc) |
544 (should be used to recreate external resources (fds, bitmaps etc) |
540 #returnFromSnapshot is sent last |
545 #returnFromSnapshot is sent last |
541 (should be used to restart processes, reOpen Streams which cannot |
546 (should be used to restart processes, reOpen Streams which cannot |
542 be automatically be reopened (i.e. Sockets, Pipes) and so on. |
547 be automatically be reopened (i.e. Sockets, Pipes) and so on. |
543 " |
548 " |
544 |
549 |
545 |deb insp imageName| |
550 |deb insp imageName| |
546 |
551 |
547 Initializing := true. |
552 Initializing := true. |
548 Processor reInitialize. |
553 Processor reinitialize. |
549 |
554 |
550 "temporary switch back to dumb interface - |
555 "temporary switch back to dumb interface - |
551 to handle errors while view-stuff is not yet reinitialized" |
556 to handle errors while view-stuff is not yet reinitialized" |
552 |
557 |
553 insp := Inspector. |
558 insp := Inspector. |
580 |
585 |
581 " |
586 " |
582 if there is no Transcript, go to stderr |
587 if there is no Transcript, go to stderr |
583 " |
588 " |
584 Transcript isNil ifTrue:[ |
589 Transcript isNil ifTrue:[ |
585 self initStandardStreams. |
590 self initStandardStreams. |
586 Transcript := Stderr |
591 Transcript := Stderr |
587 ]. |
592 ]. |
588 |
593 |
589 (SilentLoading == true) ifFalse:[ |
594 (SilentLoading == true) ifFalse:[ |
590 Transcript cr. |
595 Transcript cr. |
591 Transcript showCr:('Smalltalk restarted from:' , ObjectMemory imageName). |
596 Transcript showCr:('Smalltalk restarted from:' , ObjectMemory imageName). |
592 Transcript cr. |
597 Transcript cr. |
593 |
598 |
594 DemoMode ifTrue:[ |
599 DemoMode ifTrue:[ |
595 Transcript showCr:'*** Restricted use: ***'. |
600 Transcript showCr:'*** Restricted use: ***'. |
596 Transcript showCr:'*** This program may be used for education only. ***'. |
601 Transcript showCr:'*** This program may be used for education only. ***'. |
597 Transcript showCr:'*** Please read the files COPYRIGHT and LICENSE ***'. |
602 Transcript showCr:'*** Please read the files COPYRIGHT and LICENSE ***'. |
598 Transcript showCr:'*** for more details. ***'. |
603 Transcript showCr:'*** for more details. ***'. |
599 Transcript cr. |
604 Transcript cr. |
600 ]. |
605 ]. |
601 ]. |
606 ]. |
602 |
607 |
603 " |
608 " |
604 give user a chance to re-customize things |
609 give user a chance to re-customize things |
605 " |
610 " |
606 (Arguments includes:'-faststart') ifFalse:[ |
611 (Arguments includes:'-faststart') ifFalse:[ |
607 Class updateChanges:false. |
612 Class updateChanges:false. |
608 (self fileIn:((Arguments at:1) , '_r.rc')) ifFalse:[ |
613 (self fileIn:((Arguments at:1) , '_r.rc')) ifFalse:[ |
609 "no _r.rc file where executable is; try default smalltalk_r.rc" |
614 "no _r.rc file where executable is; try default smalltalk_r.rc" |
610 self fileIn:'smalltalk_r.rc' |
615 self fileIn:'smalltalk_r.rc' |
611 ]. |
616 ]. |
612 Class updateChanges:true. |
617 Class updateChanges:true. |
613 ]. |
618 ]. |
614 |
619 |
615 " |
620 " |
616 if there is a display, start its event dispatcher |
621 if there is a display, start its event dispatcher |
617 " |
622 " |
618 Display notNil ifTrue:[ |
623 Display notNil ifTrue:[ |
619 Display startDispatch. |
624 Display startDispatch. |
620 " " |
625 " " |
621 ModalDisplay notNil ifTrue:[ |
626 ModalDisplay notNil ifTrue:[ |
622 ModalDisplay startDispatch |
627 ModalDisplay startDispatch |
623 ] |
628 ] |
624 " " |
629 " " |
625 ]. |
630 ]. |
626 |
631 |
627 " |
632 " |
628 this allows firing an application by defining |
633 this allows firing an application by defining |
629 these two globals during snapshot ... or in main |
634 these two globals during snapshot ... or in main |
630 " |
635 " |
631 (StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
636 (StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
632 "allow customization by reading an image specific rc-file" |
637 "allow customization by reading an image specific rc-file" |
633 imageName := ObjectMemory imageName. |
638 imageName := ObjectMemory imageName. |
634 imageName notNil ifTrue:[ |
639 imageName notNil ifTrue:[ |
635 (imageName endsWith:'.img') ifTrue:[ |
640 (imageName endsWith:'.img') ifTrue:[ |
636 self fileIn:((imageName copyTo:(imageName size - 4)), '.rc') |
641 self fileIn:((imageName copyTo:(imageName size - 4)), '.rc') |
637 ] ifFalse:[ |
642 ] ifFalse:[ |
638 self fileIn:(imageName , '.rc') |
643 self fileIn:(imageName , '.rc') |
639 ] |
644 ] |
640 ]. |
645 ]. |
641 StartupClass perform:StartupSelector withArguments:StartupArguments. |
646 StartupClass perform:StartupSelector withArguments:StartupArguments. |
642 ]. |
647 ]. |
643 |
648 |
644 " |
649 " |
645 if view-classes exist, start dispatching; |
650 if view-classes exist, start dispatching; |
646 otherwise go into a read-eval-print loop |
651 otherwise go into a read-eval-print loop |
647 " |
652 " |
648 Display notNil ifTrue:[ |
653 Display notNil ifTrue:[ |
649 Processor dispatchLoop |
654 Processor dispatchLoop |
650 ] ifFalse:[ |
655 ] ifFalse:[ |
651 self readEvalPrint |
656 self readEvalPrint |
652 ]. |
657 ]. |
653 |
658 |
654 self exit |
659 self exit |
655 ! |
660 ! |
656 |
661 |
935 ! |
940 ! |
936 |
941 |
937 statistic |
942 statistic |
938 "print some statistic data. |
943 "print some statistic data. |
939 WARNING: this method is for debugging only |
944 WARNING: this method is for debugging only |
940 it may be removed without notice" |
945 it may be removed without notice" |
941 |
946 |
942 %{ /* NOCONTEXT */ |
947 %{ /* NOCONTEXT */ |
943 statistic(); |
948 __STATISTIC__(); |
944 %} |
949 %} |
945 ! |
950 ! |
946 |
951 |
947 debugOn |
952 debugOn |
948 "turns some tracing on. |
953 "turns some tracing on. |
949 WARNING: this method is for debugging only |
954 WARNING: this method is for debugging only |
950 it may be removed without notice" |
955 it may be removed without notice" |
951 |
956 |
952 "LookupTrace := true. " |
957 "LookupTrace := true. " |
953 MessageTrace := true. |
958 MessageTrace := true. |
954 "AllocTrace := true. " |
959 "AllocTrace := true. " |
955 ObjectMemory flushInlineCaches |
960 ObjectMemory flushInlineCaches |
956 ! |
961 ! |
957 |
962 |
958 debugOff |
963 debugOff |
959 "turns tracing off. |
964 "turns tracing off. |
960 WARNING: this method is for debugging only |
965 WARNING: this method is for debugging only |
961 it may be removed without notice" |
966 it may be removed without notice" |
962 |
967 |
963 LookupTrace := nil. |
968 LookupTrace := nil. |
964 MessageTrace := nil |
969 MessageTrace := nil |
965 ". AllocTrace := nil " |
970 ". AllocTrace := nil " |
966 ! |
971 ! |
967 |
972 |
968 executionDebugOn |
973 executionDebugOn |
969 "turns tracing of interpreter on. |
974 "turns tracing of interpreter on. |
970 WARNING: this method is for debugging only |
975 WARNING: this method is for debugging only |
971 it may be removed without notice" |
976 it may be removed without notice" |
972 |
977 |
973 ExecutionTrace := true |
978 ExecutionTrace := true |
974 ! |
979 ! |
975 |
980 |
976 executionDebugOff |
981 executionDebugOff |
977 "turns tracing of interpreter off. |
982 "turns tracing of interpreter off. |
978 WARNING: this method is for debugging only |
983 WARNING: this method is for debugging only |
979 it may be removed without notice" |
984 it may be removed without notice" |
980 |
985 |
981 ExecutionTrace := nil |
986 ExecutionTrace := nil |
982 ! ! |
987 ! ! |
983 |
988 |
984 !Smalltalk class methodsFor:'enumeration'! |
989 !Smalltalk class methodsFor:'enumeration'! |
1000 associationsDo:aBlock |
1005 associationsDo:aBlock |
1001 "evaluate the argument, aBlock for all key/value pairs |
1006 "evaluate the argument, aBlock for all key/value pairs |
1002 in the Smalltalk dictionary" |
1007 in the Smalltalk dictionary" |
1003 |
1008 |
1004 self allKeysDo:[:aKey | |
1009 self allKeysDo:[:aKey | |
1005 aBlock value:(aKey -> (self at:aKey)) |
1010 aBlock value:(aKey -> (self at:aKey)) |
1006 ] |
1011 ] |
1007 |
1012 |
1008 "Smalltalk associationsDo:[:assoc | assoc printNL]" |
1013 "Smalltalk associationsDo:[:assoc | assoc printNL]" |
1009 ! |
1014 ! |
1010 |
1015 |
1011 keysAndValuesDo:aBlock |
1016 keysAndValuesDo:aBlock |
1012 "evaluate the two-arg block, aBlock for all keys and values" |
1017 "evaluate the two-arg block, aBlock for all keys and values" |
1013 |
1018 |
1014 self allKeysDo:[:aKey | |
1019 self allKeysDo:[:aKey | |
1015 aBlock value:aKey value:(self at:aKey) |
1020 aBlock value:aKey value:(self at:aKey) |
1016 ] |
1021 ] |
1017 ! |
1022 ! |
1018 |
1023 |
1019 allBehaviorsDo:aBlock |
1024 allBehaviorsDo:aBlock |
1020 "evaluate the argument, aBlock for all classes in the system" |
1025 "evaluate the argument, aBlock for all classes in the system" |
1057 references:anObject |
1062 references:anObject |
1058 "return true, if I refer to the argument, anObject |
1063 "return true, if I refer to the argument, anObject |
1059 must be reimplemented since Smalltalk is no real collection." |
1064 must be reimplemented since Smalltalk is no real collection." |
1060 |
1065 |
1061 self do:[:o | |
1066 self do:[:o | |
1062 (o == anObject) ifTrue:[^ true] |
1067 (o == anObject) ifTrue:[^ true] |
1063 ]. |
1068 ]. |
1064 ^ false |
1069 ^ false |
1065 ! |
1070 ! |
1066 |
1071 |
1067 allClasses |
1072 allClasses |
1068 "return a collection of all classes in the system" |
1073 "return a collection of all classes in the system" |
1069 |
1074 |
1070 CachedClasses isNil ifTrue:[ |
1075 CachedClasses isNil ifTrue:[ |
1071 CachedClasses := IdentitySet new:500. |
1076 CachedClasses := IdentitySet new:800. |
1072 self do:[:anObject | |
1077 self do:[:anObject | |
1073 anObject notNil ifTrue:[ |
1078 anObject notNil ifTrue:[ |
1074 anObject isBehavior ifTrue:[ |
1079 anObject isBehavior ifTrue:[ |
1075 CachedClasses add:anObject |
1080 CachedClasses add:anObject |
1076 ] |
1081 ] |
1077 ] |
1082 ] |
1078 ] |
1083 ] |
1079 ]. |
1084 ]. |
1080 ^ CachedClasses |
1085 ^ CachedClasses |
1081 |
1086 |
1082 "Smalltalk allClasses" |
1087 "Smalltalk allClasses" |
1083 ! |
1088 ! |
1139 |
1163 |
1140 |sym cSym names oldName| |
1164 |sym cSym names oldName| |
1141 |
1165 |
1142 oldName := aClass name. |
1166 oldName := aClass name. |
1143 sym := oldName asSymbol. |
1167 sym := oldName asSymbol. |
1144 ((self at:sym) == aClass) ifFalse:[ ^ self]. |
1168 ((self at:sym) == aClass) ifFalse:[ |
|
1169 "check other name ..." |
|
1170 (self includes:aClass) ifFalse:[ |
|
1171 'no such class' errorPrintNL. |
|
1172 ^ self |
|
1173 ]. |
|
1174 "the class has changed its name - without telling me ... |
|
1175 what should be done in this case ?" |
|
1176 'class ' errorPrint. oldName errorPrint. |
|
1177 ' has changed its name' errorPrintNL. |
|
1178 ^ self |
|
1179 ]. |
1145 |
1180 |
1146 self at:sym put:nil. "nil it out for compiled accesses" |
1181 self at:sym put:nil. "nil it out for compiled accesses" |
1147 self removeKey:sym. |
1182 self removeKey:sym. |
1148 |
1183 |
|
1184 aClass category:#removed. |
|
1185 |
1149 "remove class variables" |
1186 "remove class variables" |
1150 |
1187 |
1151 names := aClass classVariableString asCollectionOfWords. |
1188 names := aClass classVariableString asCollectionOfWords. |
1152 names do:[:name | |
1189 names do:[:name | |
1153 cSym := (sym , ':' , name) asSymbol. |
1190 cSym := (sym , ':' , name) asSymbol. |
1154 self at:cSym asSymbol put:nil. |
1191 self at:cSym asSymbol put:nil. |
1155 self removeKey:cSym |
1192 self removeKey:cSym |
1156 ]. |
1193 ]. |
1157 " |
1194 " |
1158 actually could get along with less flushing |
1195 actually could get along with less flushing |
1159 (entries for aClass and subclasses only) |
1196 (entries for aClass and subclasses only) |
1160 |
1197 |
1161 aClass allSubclassesDo:[:aSubclass | |
1198 aClass allSubclassesDo:[:aSubclass | |
1162 ObjectMemory flushInlineCachesForClass:aSubclass. |
1199 ObjectMemory flushInlineCachesForClass:aSubclass. |
1163 ObjectMemory flushMethodCacheFor:aSubclass |
1200 ObjectMemory flushMethodCacheFor:aSubclass |
1164 ]. |
1201 ]. |
1165 ObjectMemory flushInlineCachesForClass:aClass. |
1202 ObjectMemory flushInlineCachesForClass:aClass. |
1166 ObjectMemory flushMethodCacheFor:aClass |
1203 ObjectMemory flushMethodCacheFor:aClass |
1167 " |
1204 " |
1168 ObjectMemory flushInlineCaches. |
1205 ObjectMemory flushInlineCaches. |
1169 ObjectMemory flushMethodCache. |
1206 ObjectMemory flushMethodCache. |
1170 |
1207 |
1171 aClass addChangeRecordForClassRemove:oldName |
1208 aClass addChangeRecordForClassRemove:oldName. |
1172 ! ! |
1209 ! ! |
1173 |
1210 |
1174 !Smalltalk class methodsFor:'browsing'! |
1211 !Smalltalk class methodsFor:'browsing'! |
1175 |
1212 |
1176 browseChanges |
1213 browseChanges |
1177 "startup a changes browser" |
1214 "startup a changes browser" |
1178 |
1215 |
1179 ChangesBrowser notNil ifTrue:[ |
1216 ChangesBrowser notNil ifTrue:[ |
1180 ChangesBrowser open |
1217 ChangesBrowser open |
1181 ] ifFalse:[ |
1218 ] ifFalse:[ |
1182 self warn:'no ChangesBrowser built in' |
1219 self warn:'no ChangesBrowser built in' |
1183 ] |
1220 ] |
1184 |
1221 |
1185 " |
1222 " |
1186 Smalltalk browseChanges |
1223 Smalltalk browseChanges |
1187 " |
1224 " |
1311 |aStream line index thisName abbrev| |
1349 |aStream line index thisName abbrev| |
1312 |
1350 |
1313 CachedAbbreviations := Dictionary new. |
1351 CachedAbbreviations := Dictionary new. |
1314 aStream := self systemFileStreamFor:'abbrev.stc'. |
1352 aStream := self systemFileStreamFor:'abbrev.stc'. |
1315 aStream isNil ifTrue:[ |
1353 aStream isNil ifTrue:[ |
1316 aStream := self systemFileStreamFor:'include/abbrev.stc'. |
1354 aStream := self systemFileStreamFor:'include/abbrev.stc'. |
1317 ]. |
1355 ]. |
1318 aStream notNil ifTrue:[ |
1356 aStream notNil ifTrue:[ |
1319 [aStream atEnd] whileFalse:[ |
1357 [aStream atEnd] whileFalse:[ |
1320 line := aStream nextLine. |
1358 line := aStream nextLine. |
1321 line notNil ifTrue:[ |
1359 line notNil ifTrue:[ |
1322 (line startsWith:'#') ifFalse:[ |
1360 (line startsWith:'#') ifFalse:[ |
1323 (line countWords == 2) ifTrue:[ |
1361 (line countWords == 2) ifTrue:[ |
1324 index := line indexOfSeparatorStartingAt:1. |
1362 index := line indexOfSeparatorStartingAt:1. |
1325 (index ~~ 0) ifTrue:[ |
1363 (index ~~ 0) ifTrue:[ |
1326 thisName := line copyTo:(index - 1). |
1364 thisName := line copyTo:(index - 1). |
1327 abbrev := (line copyFrom:index) withoutSeparators. |
1365 abbrev := (line copyFrom:index) withoutSeparators. |
1328 CachedAbbreviations at:thisName put:abbrev. |
1366 CachedAbbreviations at:thisName put:abbrev. |
1329 ] |
1367 ] |
1330 ] |
1368 ] |
1331 ] |
1369 ] |
1332 ] |
1370 ] |
1333 ]. |
1371 ]. |
1334 aStream close |
1372 aStream close |
1335 ] |
1373 ] |
1336 ! |
1374 ! |
1337 |
1375 |
1338 abbreviations |
1376 abbreviations |
1339 "return a dictionary containing the classname-to-filename |
1377 "return a dictionary containing the classname-to-filename |
1340 mappings. (needed for sys5.3 users, where filenames are limited |
1378 mappings. (needed for sys5.3 users, where filenames are limited |
1341 to 14 chars)" |
1379 to 14 chars)" |
1342 |
1380 |
1343 CachedAbbreviations isNil ifTrue:[ |
1381 CachedAbbreviations isNil ifTrue:[ |
1344 self readAbbreviations |
1382 self readAbbreviations |
1345 ]. |
1383 ]. |
1346 ^ CachedAbbreviations |
1384 ^ CachedAbbreviations |
1347 |
1385 |
1348 "flush with: |
1386 "flush with: |
1349 |
1387 |
1476 |
1514 |
1477 |shortName newClass upd ok nm| |
1515 |shortName newClass upd ok nm| |
1478 |
1516 |
1479 upd := Class updateChanges:false. |
1517 upd := Class updateChanges:false. |
1480 [ |
1518 [ |
1481 " |
1519 " |
1482 first, look for a loader-driver file (in fileIn/xxx.ld) |
1520 first, look for a loader-driver file (in fileIn/xxx.ld) |
1483 " |
1521 " |
1484 (self fileIn:('fileIn/' , aClassName , '.ld')) |
1522 (self fileIn:('fileIn/' , aClassName , '.ld')) |
1485 ifFalse:[ |
1523 ifFalse:[ |
1486 shortName := self fileNameForClass:aClassName. |
1524 shortName := self fileNameForClass:aClassName. |
1487 " |
1525 " |
1488 try abbreviated driver-file (in fileIn/xxx.ld) |
1526 try abbreviated driver-file (in fileIn/xxx.ld) |
1489 " |
1527 " |
1490 (self fileIn:('fileIn/' , shortName , '.ld')) |
1528 (self fileIn:('fileIn/' , shortName , '.ld')) |
1491 ifFalse:[ |
1529 ifFalse:[ |
1492 " |
1530 " |
1493 then, if dynamic linking is available, look for a shared binary in binary/xxx.o |
1531 then, if dynamic linking is available, look for a shared binary in binary/xxx.o |
1494 " |
1532 " |
1495 ObjectFileLoader notNil ifTrue:[ |
1533 ObjectFileLoader notNil ifTrue:[ |
1496 nm := 'binary/' , aClassName. |
1534 nm := 'binary/' , aClassName. |
1497 (self fileInClassObject:aClassName from:(nm , '.so')) |
1535 (self fileInClassObject:aClassName from:(nm , '.so')) |
1498 ifFalse:[ |
1536 ifFalse:[ |
1499 (self fileInClassObject:aClassName from:(nm , '.o')) |
1537 (self fileInClassObject:aClassName from:(nm , '.o')) |
1500 ifFalse:[ |
1538 ifFalse:[ |
1501 nm := 'binary/' , shortName. |
1539 nm := 'binary/' , shortName. |
1502 (self fileInClassObject:aClassName from:(nm , '.so')) |
1540 (self fileInClassObject:aClassName from:(nm , '.so')) |
1503 ifFalse:[ |
1541 ifFalse:[ |
1504 ok := self fileInClassObject:aClassName from:(nm , '.o') |
1542 ok := self fileInClassObject:aClassName from:(nm , '.o') |
1505 ]. |
1543 ]. |
1506 ]. |
1544 ]. |
1507 ]. |
1545 ]. |
1508 ]. |
1546 ]. |
1509 |
1547 |
1510 " |
1548 " |
1511 if that did not work, look for an st-source file ... |
1549 if that did not work, look for an st-source file ... |
1512 " |
1550 " |
1513 ok ifFalse:[ |
1551 ok ifFalse:[ |
1514 (self fileIn:(aClassName , '.st')) |
1552 (self fileIn:(aClassName , '.st')) |
1515 ifFalse:[ |
1553 ifFalse:[ |
1516 (self fileIn:(shortName , '.st')) |
1554 (self fileIn:(shortName , '.st')) |
1517 ifFalse:[ |
1555 ifFalse:[ |
1518 " |
1556 " |
1519 ... and in the standard source-directory |
1557 ... and in the standard source-directory |
1520 " |
1558 " |
1521 (self fileIn:('source/' , aClassName , '.st')) |
1559 (self fileIn:('source/' , aClassName , '.st')) |
1522 ifFalse:[ |
1560 ifFalse:[ |
1523 ok := self fileIn:('source/' , shortName , '.st') |
1561 ok := self fileIn:('source/' , shortName , '.st') |
1524 ] |
1562 ] |
1525 ] |
1563 ] |
1526 ] |
1564 ] |
1527 ] |
1565 ] |
1528 ]. |
1566 ]. |
1529 ] |
1567 ] |
1530 ] valueNowOrOnUnwindDo:[Class updateChanges:upd]. |
1568 ] valueNowOrOnUnwindDo:[Class updateChanges:upd]. |
1531 newClass := self at:(aClassName asSymbol). |
1569 newClass := self at:(aClassName asSymbol). |
1532 newClass notNil ifTrue:[newClass initialize] |
1570 newClass notNil ifTrue:[newClass initialize] |
|
1571 ! |
|
1572 |
|
1573 silentFileIn:aFilename |
|
1574 "same as fileIn:, but do not output 'compiled...'-messages on Transcript. |
|
1575 Main use is during startup." |
|
1576 |
|
1577 |wasSilent| |
|
1578 |
|
1579 wasSilent := self silentLoading:true. |
|
1580 [ |
|
1581 self fileIn:aFilename |
|
1582 ] valueNowOrOnUnwindDo:[ |
|
1583 self silentLoading:wasSilent |
|
1584 ] |
1533 ! ! |
1585 ! ! |
1534 |
1586 |
1535 !Smalltalk class methodsFor: 'binary storage'! |
1587 !Smalltalk class methodsFor: 'binary storage'! |
1536 |
1588 |
1537 addGlobalsTo: globalDictionary manager: manager |
1589 addGlobalsTo: globalDictionary manager: manager |
1538 |pools| |
1590 |pools| |
1539 |
1591 |
1540 pools := Set new. |
1592 pools := Set new. |
1541 self associationsDo:[:assoc | |
1593 self associationsDo:[:assoc | |
1542 assoc value == self ifFalse:[ |
1594 assoc value == self ifFalse:[ |
1543 assoc value isClass ifTrue:[ |
1595 assoc value isClass ifTrue:[ |
1544 assoc value addGlobalsTo:globalDictionary manager:manager. |
1596 assoc value addGlobalsTo:globalDictionary manager:manager. |
1545 pools addAll:assoc value sharedPools |
1597 pools addAll:assoc value sharedPools |
1546 ] ifFalse:[ |
1598 ] ifFalse:[ |
1547 globalDictionary at:assoc put:self |
1599 globalDictionary at:assoc put:self |
1548 ]. |
1600 ]. |
1549 assoc value isNil ifFalse:[ |
1601 assoc value isNil ifFalse:[ |
1550 globalDictionary at:assoc value put:self |
1602 globalDictionary at:assoc value put:self |
1551 ] |
1603 ] |
1552 ] |
1604 ] |
1553 ]. |
1605 ]. |
1554 |
1606 |
1555 pools do:[:poolDictionary| |
1607 pools do:[:poolDictionary| |
1556 poolDictionary addGlobalsTo:globalDictionary manager:manager |
1608 poolDictionary addGlobalsTo:globalDictionary manager:manager |
1557 ] |
1609 ] |
1558 ! |
1610 ! |
1559 |
1611 |
1560 storeBinaryDefinitionOf: anObject on: stream manager: manager |
1612 storeBinaryDefinitionOf: anObject on: stream manager: manager |
1561 |string| |
1613 |string| |
1562 |
1614 |
1563 anObject class == Association ifTrue:[ |
1615 anObject class == Association ifTrue:[ |
1564 string := 'Smalltalk associationAt: ', anObject key storeString |
1616 string := 'Smalltalk associationAt: ', anObject key storeString |
1565 ] ifFalse: [ |
1617 ] ifFalse: [ |
1566 string := 'Smalltalk at: ', (self keyAtValue: anObject) storeString |
1618 string := 'Smalltalk at: ', (self keyAtValue: anObject) storeString |
1567 ]. |
1619 ]. |
1568 stream nextNumber:2 put:string size. |
1620 stream nextNumber:2 put:string size. |
1569 string do:[:char | stream nextPut:char asciiValue] |
1621 string do:[:char | stream nextPut:char asciiValue] |
1570 ! ! |
1622 ! ! |