ReadEvalPrintLoop.st
changeset 22771 a5b520826aad
parent 22770 b83f3a481878
child 22772 d08c521eba2c
equal deleted inserted replaced
22770:b83f3a481878 22771:a5b520826aad
   298 ! !
   298 ! !
   299 
   299 
   300 !ReadEvalPrintLoop methodsFor:'directives'!
   300 !ReadEvalPrintLoop methodsFor:'directives'!
   301 
   301 
   302 askYesNo:message
   302 askYesNo:message
   303     self errorStream show:message.
   303     stderr show:message.
   304     ^ (self inputStream nextLine withoutSeparators startsWith:'y').
   304     ^ (self inputStream nextLine withoutSeparators startsWith:'y').
   305 !
   305 !
   306 
   306 
   307 cmd_apropos:lineStream
   307 cmd_apropos:lineStream
   308     "apropos directive; i.e.
   308     "apropos directive; i.e.
   315     words := lineStream upToEnd asCollectionOfSubstringsSeparatedBy:$;.
   315     words := lineStream upToEnd asCollectionOfSubstringsSeparatedBy:$;.
   316     words := words select:[:each | each notEmpty].
   316     words := words select:[:each | each notEmpty].
   317     words := words select:[:each | each isBlank not].
   317     words := words select:[:each | each isBlank not].
   318 
   318 
   319     (words isEmpty) ifTrue:[
   319     (words isEmpty) ifTrue:[
   320         self errorStream showCR:'? usage: #apropos <word> [; morewords]'.
   320         stderr showCR:'? usage: #apropos <word> [; morewords]'.
   321         ^ self.
   321         ^ self.
   322     ].
   322     ].
   323 
   323 
   324     "/ search in classes:
   324     "/ search in classes:
   325     classNamesMatching := Smalltalk allClasses 
   325     classNamesMatching := Smalltalk allClasses 
   350                     showIt := self askYesNo:( 
   350                     showIt := self askYesNo:( 
   351                         'apropos: there are %1 matching %2; list them all (y/n)? '
   351                         'apropos: there are %1 matching %2; list them all (y/n)? '
   352                             bindWith:list size
   352                             bindWith:list size
   353                             with:listName)
   353                             with:listName)
   354                 ] ifFalse:[
   354                 ] ifFalse:[
   355                     self errorStream showCR:'matching %1:' with:listName.  
   355                     stderr showCR:'matching %1:' with:listName.  
   356                 ].
   356                 ].
   357                 showIt ifTrue:[
   357                 showIt ifTrue:[
   358                     sortedList := list asOrderedCollection sort.
   358                     sortedList := list asOrderedCollection sort.
   359                     longest := (list collect:[:nm | nm size]) max.
   359                     longest := (list collect:[:nm | nm size]) max.
   360                     limit := 78.
   360                     limit := 78.
   361                     numCols := (80 // (longest min:limit)) max:1.
   361                     numCols := (80 // (longest min:limit)) max:1.
   362                     colWidth := (longest min:limit).
   362                     colWidth := (longest min:limit).
   363                     sortedList slicesOf:numCols do:[:eachGroupOfN |
   363                     sortedList slicesOf:numCols do:[:eachGroupOfN |
   364                         self errorStream
   364                         stderr
   365                             spaces:2;
   365                             spaces:2;
   366                             nextPutLine:(
   366                             nextPutLine:(
   367                                 (eachGroupOfN 
   367                                 (eachGroupOfN 
   368                                     collect:[:nm | 
   368                                     collect:[:nm | 
   369                                         (nm contractTo:colWidth) paddedTo:colWidth
   369                                         (nm contractTo:colWidth) paddedTo:colWidth
   525 !
   525 !
   526 
   526 
   527 cmd_edit:lineStream
   527 cmd_edit:lineStream
   528     "edit a class or selector in an external editor"
   528     "edit a class or selector in an external editor"
   529 
   529 
   530     |errStream classOrMethodName cls methodName selector 
   530     |classOrMethodName cls methodName selector 
   531      code isNewClass editFullClass tmpFile modifiedTime|
   531      code isNewClass editFullClass tmpFile modifiedTime|
   532 
       
   533     errStream := self errorStream.
       
   534 
   532 
   535     isNewClass := editFullClass := false.
   533     isNewClass := editFullClass := false.
   536 
   534 
   537     lineStream skipSeparators.
   535     lineStream skipSeparators.
   538     lineStream atEnd ifTrue:[
   536     lineStream atEnd ifTrue:[
   544                                     ch isLetterOrDigit not and:[ch ~~ $_]
   542                                     ch isLetterOrDigit not and:[ch ~~ $_]
   545                                 ].
   543                                 ].
   546         "/ 
   544         "/ 
   547         (classOrMethodName isUppercaseFirst) ifTrue:[ 
   545         (classOrMethodName isUppercaseFirst) ifTrue:[ 
   548             (cls := Smalltalk classNamed:classOrMethodName) isNil ifTrue:[
   546             (cls := Smalltalk classNamed:classOrMethodName) isNil ifTrue:[
   549                 errStream show:'edit: no such class: ',classOrMethodName,' ; create (y/n)? '.
   547                 stderr show:'edit: no such class: ',classOrMethodName,' ; create (y/n)? '.
   550                 (self inputStream nextLine withoutSeparators startsWith:'y') ifFalse:[^ self].
   548                 (self inputStream nextLine withoutSeparators startsWith:'y') ifFalse:[^ self].
   551                 isNewClass := true.
   549                 isNewClass := true.
   552                 code := 
   550                 code := 
   553 '"/ change the code as required, then save and exit the editor.
   551 '"/ change the code as required, then save and exit the editor.
   554 "/ To cancel this edit, leave the editor WITHOUT saving.
   552 "/ To cancel this edit, leave the editor WITHOUT saving.
   578     ].
   576     ].
   579     
   577     
   580     isNewClass ifFalse:[
   578     isNewClass ifFalse:[
   581         cls := cls ? lastEditedClass.
   579         cls := cls ? lastEditedClass.
   582         cls isNil ifTrue:[
   580         cls isNil ifTrue:[
   583             errStream showCR:'edit usage:'.
   581             stderr showCR:'edit usage:'.
   584             errStream showCR:'   #edit className selector'.
   582             stderr showCR:'   #edit className selector'.
   585             errStream showCR:'   #edit className '.
   583             stderr showCR:'   #edit className '.
   586             errStream showCR:'   #edit selector (class as in previous edit)'.
   584             stderr showCR:'   #edit selector (class as in previous edit)'.
   587             errStream showCR:'   #edit          (class/method as in previous edit)'.
   585             stderr showCR:'   #edit          (class/method as in previous edit)'.
   588             ^ self.
   586             ^ self.
   589         ].
   587         ].
   590         lastEditedClass := cls.
   588         lastEditedClass := cls.
   591         lastEditedSelector := methodName.
   589         lastEditedSelector := methodName.
   592 
   590 
   638                 onError:[:status | false].
   636                 onError:[:status | false].
   639                 
   637                 
   640         (ok and:[tmpFile modificationTime ~= modifiedTime]) ifTrue:[
   638         (ok and:[tmpFile modificationTime ~= modifiedTime]) ifTrue:[
   641             isNewClass ifTrue:[
   639             isNewClass ifTrue:[
   642                 Compiler evaluate:tmpFile contentsOfEntireFile.    
   640                 Compiler evaluate:tmpFile contentsOfEntireFile.    
   643                 errStream showCR:'Class (re)defined.'
   641                 stderr showCR:'Class (re)defined.'
   644             ] ifFalse:[
   642             ] ifFalse:[
   645                 editFullClass ifTrue:[
   643                 editFullClass ifTrue:[
   646                     tmpFile fileIn.
   644                     tmpFile fileIn.
   647                     errStream showCR:'Class (re)compiled.'
   645                     stderr showCR:'Class (re)compiled.'
   648                 ] ifFalse:[    
   646                 ] ifFalse:[    
   649                     cls compile:tmpFile contentsOfEntireFile classified:'*as yet uncategorized'.    
   647                     cls compile:tmpFile contentsOfEntireFile classified:'*as yet uncategorized'.    
   650                     errStream showCR:'Method (re)compiled.'
   648                     stderr showCR:'Method (re)compiled.'
   651                 ].    
   649                 ].    
   652             ].    
   650             ].    
   653         ] ifFalse:[
   651         ] ifFalse:[
   654             errStream showCR:'No change.'
   652             stderr showCR:'No change.'
   655         ].    
   653         ].    
   656     ] ensure:[
   654     ] ensure:[
   657         tmpFile notNil ifTrue:[
   655         tmpFile notNil ifTrue:[
   658             tmpFile remove
   656             tmpFile remove
   659         ]
   657         ]
   681 
   679 
   682     "Created: / 07-12-2006 / 18:55:46 / cg"
   680     "Created: / 07-12-2006 / 18:55:46 / cg"
   683 !
   681 !
   684 
   682 
   685 cmd_help:lineStream
   683 cmd_help:lineStream
   686     self errorStream
   684     stderr
   687         nextPutAll:
   685         nextPutAll:
   688 'Everything entered up to an empty line or a line ending in "." is called a "chunk" and evaluated.
   686 'Everything entered up to an empty line or a line ending in "." is called a "chunk" and evaluated.
   689 Lines starting with "#" (in the first column) are commands to the read-eval-print interpreter.
   687 Lines starting with "#" (in the first column) are commands to the read-eval-print interpreter.
   690 
   688 
   691 Valid commands are:
   689 Valid commands are:
   758     lang = 'javascript' ifTrue:[
   756     lang = 'javascript' ifTrue:[
   759         compiler := JavaScriptCompiler.
   757         compiler := JavaScriptCompiler.
   760         ^ self.
   758         ^ self.
   761     ].
   759     ].
   762 
   760 
   763     self errorStream 
   761     stderr
   764         showCR:'? usage: #language smalltalk';
   762         showCR:'? usage: #language smalltalk';
   765         showCR:'?    or: #language javascript'.
   763         showCR:'?    or: #language javascript'.
   766 !
   764 !
   767 
   765 
   768 cmd_list:lineStream
   766 cmd_list:lineStream
   769     "list directive; i.e.
   767     "list directive; i.e.
   770         #list <classname> ['class'] <selector>
   768         #list <classname> ['class'] <selector>
   771     "
   769     "
   772 
   770 
   773     |class selector source errStream|
   771     |class selector source|
   774 
       
   775     errStream := self errorStream.
       
   776 
   772 
   777     (self 
   773     (self 
   778         getClassNameAndSelectorFrom:lineStream
   774         getClassNameAndSelectorFrom:lineStream
   779         specialWords:nil
   775         specialWords:nil
   780         into:[:classArg :selectorArg |
   776         into:[:classArg :selectorArg |
   781             class := classArg.
   777             class := classArg.
   782             selector := selectorArg.
   778             selector := selectorArg.
   783         ]) ifFalse:[^ self].
   779         ]) ifFalse:[^ self].
   784 
   780 
   785     selector isNil ifTrue:[
   781     selector isNil ifTrue:[
   786         errStream nextPutAll:(class definition); cr.
   782         stderr nextPutAll:(class definition); cr.
   787         errStream nextPutAll:(class commentOrDocumentationString); cr.
   783         stderr nextPutAll:(class commentOrDocumentationString); cr.
   788     ] ifFalse:[
   784     ] ifFalse:[
   789         source := class sourceCodeAt:selector asSymbol.
   785         source := class sourceCodeAt:selector asSymbol.
   790         source isEmptyOrNil ifTrue:[
   786         source isEmptyOrNil ifTrue:[
   791             errStream nextPutLine:'Sorry, no sourcecode found'
   787             stderr nextPutLine:'Sorry, no sourcecode found'
   792         ] ifFalse:[
   788         ] ifFalse:[
   793             errStream nextPutAll:source; cr
   789             stderr nextPutAll:source; cr
   794         ].
   790         ].
   795     ].
   791     ].
   796 
   792 
   797     "
   793     "
   798      self basicNew 
   794      self basicNew 
   819      savedTraceFlag savedProfileFlag savedNoDebugger|
   815      savedTraceFlag savedProfileFlag savedNoDebugger|
   820 
   816 
   821     lineStream skipSeparators.
   817     lineStream skipSeparators.
   822     filename := lineStream upToEnd withoutSeparators.
   818     filename := lineStream upToEnd withoutSeparators.
   823     filename isEmptyOrNil ifTrue:[
   819     filename isEmptyOrNil ifTrue:[
   824         self errorStream showCR:'? usage: #read <filename>'.
   820         stderr showCR:'? usage: #read <filename>'.
   825         ^ self.
   821         ^ self.
   826     ].
   822     ].
   827 
   823 
   828     currentDirectory := currentDirectory ? (Filename currentDirectory).
   824     currentDirectory := currentDirectory ? (Filename currentDirectory).
   829 
   825 
   834 
   830 
   835     StreamError ignoreIn:[
   831     StreamError ignoreIn:[
   836         newInput := filename readStream.
   832         newInput := filename readStream.
   837     ].
   833     ].
   838     newInput isNil ifTrue:[
   834     newInput isNil ifTrue:[
   839         self errorStream showCR:('Could not find file: "',filename pathName,'"').
   835         stderr showCR:('Could not find file: "',filename pathName,'"').
   840         ^ self.
   836         ^ self.
   841     ].
   837     ].
   842 
   838 
   843     [
   839     [
   844         savedCurrentDirectory := currentDirectory.
   840         savedCurrentDirectory := currentDirectory.
   957                 self answerPrompt:''.
   953                 self answerPrompt:''.
   958             ].
   954             ].
   959             ^ self.
   955             ^ self.
   960         ].
   956         ].
   961     ].
   957     ].
   962     self errorStream 
   958     stderr
   963         showCR:'? usage: set/clear <flag>';
   959         showCR:'? usage: set/clear <flag>';
   964         showCR:'? (<flag> must be one of: print, nodebug, confirmdebug, trace, times, profile, chunk, prompt, answerprompt, editor)'.
   960         showCR:'? (<flag> must be one of: print, nodebug, confirmdebug, trace, times, profile, chunk, prompt, answerprompt, editor)'.
   965     self cmd_show:('flags' readStream).
   961     self cmd_show:('flags' readStream).
   966 
   962 
   967     "Modified: / 08-11-2016 / 22:49:17 / cg"
   963     "Modified: / 08-11-2016 / 22:49:17 / cg"
   973         show modules (= loaded packages)
   969         show modules (= loaded packages)
   974         show variables 
   970         show variables 
   975         etc.
   971         etc.
   976     "
   972     "
   977 
   973 
   978     |errStream what showAll ok|
   974     |what showAll ok|
   979 
       
   980     errStream := self errorStream.
       
   981 
   975 
   982     lineStream skipSeparators.
   976     lineStream skipSeparators.
   983     what := lineStream nextAlphaNumericWord.
   977     what := lineStream nextAlphaNumericWord.
   984     ok := false.
   978     ok := false.
   985     
   979     
   986     what notNil ifTrue:[
   980     what notNil ifTrue:[
   987         showAll := (what startsWith:'all').
   981         showAll := (what startsWith:'all').
   988         
   982         
   989         (showAll or:[ what startsWith:'var' ]) ifTrue:[                      
   983         (showAll or:[ what startsWith:'var' ]) ifTrue:[                      
   990             errStream showCR:'Variables:'; showCR:'----------'.
   984             stderr showCR:'Variables:'; showCR:'----------'.
   991             self showVariables.
   985             self showVariables.
   992             ok := true.
   986             ok := true.
   993         ].
   987         ].
   994         
   988         
   995         (showAll or:[ what startsWith:'proc' ]) ifTrue:[                    
   989         (showAll or:[ what startsWith:'proc' ]) ifTrue:[                    
   996             errStream cr; showCR:'Threads:'; showCR:'--------'.
   990             stderr cr; showCR:'Threads:'; showCR:'--------'.
   997             MiniDebugger basicNew showProcesses.
   991             MiniDebugger basicNew showProcesses.
   998             ok := true.
   992             ok := true.
   999         ].
   993         ].
  1000         
   994         
  1001         ("showAll or:[" what startsWith:'pack' "]") ifTrue:[                    
   995         ("showAll or:[" what startsWith:'pack' "]") ifTrue:[                    
  1002             errStream cr; showCR:'Available Packages:'; showCR:'--------'.
   996             stderr cr; showCR:'Available Packages:'; showCR:'--------'.
  1003             self showPackages.
   997             self showPackages.
  1004             ok := true.
   998             ok := true.
  1005         ].
   999         ].
  1006 
  1000 
  1007         (showAll or:[ what startsWith:'mod' ]) ifTrue:[
  1001         (showAll or:[ what startsWith:'mod' ]) ifTrue:[
  1008             errStream cr; showCR:'Modules:'; showCR:'--------'.
  1002             stderr cr; showCR:'Modules:'; showCR:'--------'.
  1009             self showModules.
  1003             self showModules.
  1010 
  1004 
  1011             ok := true.
  1005             ok := true.
  1012         ].
  1006         ].
  1013         
  1007         
  1014         (showAll or:[ what startsWith:'mem' ]) ifTrue:[
  1008         (showAll or:[ what startsWith:'mem' ]) ifTrue:[
  1015             |allMem|
  1009             |allMem|
  1016             
  1010             
  1017             errStream cr; showCR:'Memory:'; showCR:'-------'.
  1011             stderr cr; showCR:'Memory:'; showCR:'-------'.
  1018             "/ allMem := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed
  1012             "/ allMem := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed
  1019             "/                                     + ObjectMemory newSpaceUsed.
  1013             "/                                     + ObjectMemory newSpaceUsed.
  1020             errStream
  1014             stderr
  1021                 "/ showCR:('overall: ',(allMem // 1024) printString,' Kb');
  1015                 "/ showCR:('overall: ',(allMem // 1024) printString,' Kb');
  1022                 showCR:('used   : ',(ObjectMemory bytesUsed // 1024) printString,' Kb');
  1016                 showCR:('used   : ',(ObjectMemory bytesUsed // 1024) printString,' Kb');
  1023                 showCR:('free   : ',(ObjectMemory freeSpace // 1024) printString,' Kb');
  1017                 showCR:('free   : ',(ObjectMemory freeSpace // 1024) printString,' Kb');
  1024                 show:('minorGC: ',(ObjectMemory scavengeCount) printString);
  1018                 show:('minorGC: ',(ObjectMemory scavengeCount) printString);
  1025                 showCR:(' majorGC: ',(ObjectMemory garbageCollectCount) printString).
  1019                 showCR:(' majorGC: ',(ObjectMemory garbageCollectCount) printString).
  1026             ok := true.
  1020             ok := true.
  1027         ].
  1021         ].
  1028         
  1022         
  1029         (showAll or:[ what startsWith:'flag' ]) ifTrue:[
  1023         (showAll or:[ what startsWith:'flag' ]) ifTrue:[
  1030             errStream cr; showCR:'Flags:'; showCR:'------'.
  1024             stderr cr; showCR:'Flags:'; showCR:'------'.
  1031             errStream
  1025             stderr
  1032                 showCR:('print:       ',self printFlag printString);
  1026                 showCR:('print:       ',self printFlag printString);
  1033                 showCR:('nodebug:     ',self noDebugger printString);
  1027                 showCR:('nodebug:     ',self noDebugger printString);
  1034                 showCR:('confirmdebug:',self confirmDebugger printString);
  1028                 showCR:('confirmdebug:',self confirmDebugger printString);
  1035                 showCR:('trace :      ',(traceFlag ? false) printString);
  1029                 showCR:('trace :      ',(traceFlag ? false) printString);
  1036                 showCR:('timing:      ',(timingFlag ? false) printString);
  1030                 showCR:('timing:      ',(timingFlag ? false) printString);
  1044             ok := true.
  1038             ok := true.
  1045         ].
  1039         ].
  1046     ].
  1040     ].
  1047 
  1041 
  1048     ok ifFalse:[
  1042     ok ifFalse:[
  1049         errStream showCR:'? usage: show <what>'.
  1043         stderr showCR:'? usage: show <what>'.
  1050         errStream showCR:'? (<what> must be one of: packages, modules, variables, flags, memory, processes)'.
  1044         stderr showCR:'? (<what> must be one of: packages, modules, variables, flags, memory, processes)'.
  1051     ].
  1045     ].
  1052     
  1046     
  1053     "
  1047     "
  1054      self basicNew cmd_show:'packages' readStream
  1048      self basicNew cmd_show:'packages' readStream
  1055     "
  1049     "
  1067     |pkg s defaultPrefix|
  1061     |pkg s defaultPrefix|
  1068 
  1062 
  1069     lineStream skipSeparators.
  1063     lineStream skipSeparators.
  1070     pkg := lineStream upToEnd withoutSeparators.
  1064     pkg := lineStream upToEnd withoutSeparators.
  1071     pkg isEmpty ifTrue:[
  1065     pkg isEmpty ifTrue:[
  1072         self errorStream 
  1066         stderr
  1073             showCR:'? usage: #use <package>';
  1067             showCR:'? usage: #use <package>';
  1074             showCR:'?    or: #use default <packagePrefix>'.
  1068             showCR:'?    or: #use default <packagePrefix>'.
  1075         ^ self.
  1069         ^ self.
  1076     ].
  1070     ].
  1077 
  1071 
  1085     [
  1079     [
  1086         Smalltalk loadPackage:pkg.
  1080         Smalltalk loadPackage:pkg.
  1087     ] on:PackageLoadError do:[:ex|
  1081     ] on:PackageLoadError do:[:ex|
  1088         "/ allow for some shortcuts...
  1082         "/ allow for some shortcuts...
  1089         (pkg includes:$:) ifTrue:[
  1083         (pkg includes:$:) ifTrue:[
  1090             self errorStream showCR:('Failed to load package: "',pkg,'"').
  1084             stderr showCR:('Failed to load package: "',pkg,'"').
  1091         ] ifFalse:[
  1085         ] ifFalse:[
  1092             "/ try stx standard package
  1086             "/ try stx standard package
  1093             pkg := (self defaultPackagePrefix), pkg.
  1087             pkg := (self defaultPackagePrefix), pkg.
  1094             ex restart.
  1088             ex restart.
  1095         ].
  1089         ].
  1110     s skipSeparators.
  1104     s skipSeparators.
  1111 
  1105 
  1112     cmd := s nextAlphaNumericWord.
  1106     cmd := s nextAlphaNumericWord.
  1113     cmd notNil ifTrue:[
  1107     cmd notNil ifTrue:[
  1114         AbortAllOperationRequest handle:[:ex |
  1108         AbortAllOperationRequest handle:[:ex |
  1115             self errorStream showCR:('Directive aborted: ', ex description)
  1109             stderr showCR:('Directive aborted: ', ex description)
  1116         ] do:[
  1110         ] do:[
  1117             Error handle:[:ex |
  1111             Error handle:[:ex |
  1118                 self errorStream showCR:('Caught in directive: ', ex description).
  1112                 stderr showCR:('Caught in directive: ', ex description).
  1119                 ex suspendedContext fullPrintAll.
  1113                 ex suspendedContext fullPrintAll.
  1120             ] do:[    
  1114             ] do:[    
  1121                 ControlInterrupt handle:[:ex |
  1115                 ControlInterrupt handle:[:ex |
  1122                     MiniDebugger enter.
  1116                     MiniDebugger enter.
  1123                     "/ self errorStream showCR:('Ignored in directive: ', ex description).
  1117                     "/ stderr showCR:('Ignored in directive: ', ex description).
  1124                     "/ ex reject. 
  1118                     "/ ex reject. 
  1125                     "/ ex proceed. 
  1119                     "/ ex proceed. 
  1126                 ] do:[    
  1120                 ] do:[    
  1127                     self
  1121                     self
  1128                         perform:('cmd_',cmd) asMutator with:s
  1122                         perform:('cmd_',cmd) asMutator with:s
  1129                         ifNotUnderstood:[
  1123                         ifNotUnderstood:[
  1130                             self errorStream
  1124                             stderr
  1131                                 showCR:'?? invalid command: %1. Type "#help" for help.' with:cmd.
  1125                                 showCR:'?? invalid command: %1. Type "#help" for help.' with:cmd.
  1132                         ].
  1126                         ].
  1133                 ].
  1127                 ].
  1134             ].
  1128             ].
  1135         ].
  1129         ].
  1162         ^ className
  1156         ^ className
  1163     ].
  1157     ].
  1164 
  1158 
  1165     class := Smalltalk classNamed:className.
  1159     class := Smalltalk classNamed:className.
  1166     class isNil ifTrue:[
  1160     class isNil ifTrue:[
  1167         self errorStream showCR:'no such class: ',className.
  1161         stderr showCR:'no such class: ',className.
  1168         ^ false.
  1162         ^ false.
  1169     ].
  1163     ].
  1170 
  1164 
  1171     (wordStream atEnd not and:[wordStream peek = 'class']) ifTrue:[
  1165     (wordStream atEnd not and:[wordStream peek = 'class']) ifTrue:[
  1172         wordStream next.
  1166         wordStream next.
  1178     aBlock value:class value:selector.
  1172     aBlock value:class value:selector.
  1179     ^ true
  1173     ^ true
  1180 !
  1174 !
  1181 
  1175 
  1182 showModules
  1176 showModules
  1183     |errStream printModule|
  1177     |printModule|
  1184 
  1178 
  1185     errStream := self errorStream.
       
  1186     
       
  1187     printModule :=
  1179     printModule :=
  1188         [:mod |
  1180         [:mod |
  1189             errStream
  1181             stderr
  1190                 show:'  ';
  1182                 show:'  ';
  1191                 show:(mod package "libraryName");
  1183                 show:(mod package "libraryName");
  1192                 showCR:' (',(mod type),')'.
  1184                 showCR:' (',(mod type),')'.
  1193         ].
  1185         ].
  1194 
  1186 
  1195     errStream nextPutLine:'builtIn:'.
  1187     stderr nextPutLine:'builtIn:'.
  1196     ((ObjectMemory binaryModuleInfo
  1188     ((ObjectMemory binaryModuleInfo
  1197         reject:[:m | m dynamic])
  1189         reject:[:m | m dynamic])
  1198             asSortedCollection:[:a :b | a name < b name]) do:printModule.
  1190             asSortedCollection:[:a :b | a name < b name]) do:printModule.
  1199 
  1191 
  1200     errStream nextPutLine:'dynamic:'.
  1192     stderr nextPutLine:'dynamic:'.
  1201     ((ObjectMemory binaryModuleInfo
  1193     ((ObjectMemory binaryModuleInfo
  1202         select:[:m | m dynamic])
  1194         select:[:m | m dynamic])
  1203             asSortedCollection:[:a :b | a name < b name]) do:printModule.
  1195             asSortedCollection:[:a :b | a name < b name]) do:printModule.
  1204 
  1196 
  1205     "
  1197     "
  1214     Smalltalk knownLoadablePackagesDo:[:packageID :type :path |
  1206     Smalltalk knownLoadablePackagesDo:[:packageID :type :path |
  1215         all add:packageID
  1207         all add:packageID
  1216     ].
  1208     ].
  1217     all := all asOrderedCollection sort.
  1209     all := all asOrderedCollection sort.
  1218     all do:[:eachPackage |
  1210     all do:[:eachPackage |
  1219         self errorStream show:eachPackage.
  1211         stderr show:eachPackage.
  1220         (Smalltalk isPackageLoaded:eachPackage) ifTrue:[
  1212         (Smalltalk isPackageLoaded:eachPackage) ifTrue:[
  1221             self errorStream show:' (loaded)'.
  1213             stderr show:' (loaded)'.
  1222         ].    
  1214         ].    
  1223         self errorStream cr.
  1215         stderr cr.
  1224     ].    
  1216     ].    
  1225 
  1217 
  1226     "
  1218     "
  1227      ReadEvalPrintLoop basicNew showPackages
  1219      ReadEvalPrintLoop basicNew showPackages
  1228      ReadEvalPrintLoop basicNew showModules
  1220      ReadEvalPrintLoop basicNew showModules
  1231 
  1223 
  1232 showVariables
  1224 showVariables
  1233     Workspace notNil ifTrue:[
  1225     Workspace notNil ifTrue:[
  1234         Workspace workspaceVariables keys asOrderedCollection sort do:[:nm |
  1226         Workspace workspaceVariables keys asOrderedCollection sort do:[:nm |
  1235             |holder|
  1227             |holder|
       
  1228 
  1236             holder := Workspace workspaceVariables at:nm.
  1229             holder := Workspace workspaceVariables at:nm.
  1237             self errorStream 
  1230             stderr
  1238                 show:nm;  
  1231                 show:nm;  
  1239                 show:' -> '; 
  1232                 show:' -> '; 
  1240                 showCR:holder value printString.
  1233                 showCR:holder value printString.
  1241         ].
  1234         ].
  1242     ].
  1235     ].