Smalltalk.st
changeset 18349 b5180d38c630
parent 18329 c7764438ff70
child 18362 a03b2d578e74
--- a/Smalltalk.st	Sat May 16 11:47:43 2015 +0200
+++ b/Smalltalk.st	Sat May 16 11:48:06 2015 +0200
@@ -547,19 +547,19 @@
     "sent from VM via #initializeModules"
 
     Error handle:[:ex |
-        ObjectMemory printStackBacktrace.
-        ClassesFailedToInitialize isNil ifTrue:[
-            ClassesFailedToInitialize := IdentitySet new.
-        ].
-        ClassesFailedToInitialize add:aClass.
-        ('Smalltalk [warning]: error during initialize of ' , aClass name,': ', ex description printString) errorPrintCR.
-        ex suspendedContext fullPrintAll.
-        '------------------------------------------------' errorPrintCR.
-        ((DebuggingStandAlone == true) or:[ Smalltalk commandLineArguments includes:'--debug']) ifTrue:[
-            ex reject
-        ].
+	ObjectMemory printStackBacktrace.
+	ClassesFailedToInitialize isNil ifTrue:[
+	    ClassesFailedToInitialize := IdentitySet new.
+	].
+	ClassesFailedToInitialize add:aClass.
+	('Smalltalk [warning]: error during initialize of ' , aClass name,': ', ex description printString) errorPrintCR.
+	ex suspendedContext fullPrintAll.
+	'------------------------------------------------' errorPrintCR.
+	((DebuggingStandAlone == true) or:[ Smalltalk commandLineArguments includes:'--debug']) ifTrue:[
+	    ex reject
+	].
     ] do:[
-        aClass initialize
+	aClass initialize
     ].
 
     "Modified: / 11-09-2011 / 17:01:32 / cg"
@@ -591,10 +591,15 @@
      Notice: this is not called when an image is restarted"
 
 %{
+#ifdef __SCHTEAM__
+    STClass.initializeAllClasses(__c__);
+    return __c__._RETURN_self();
+#else
     __init_registered_modules__(3);
 
     @global(DemoMode) = __getDemoMode() ? true : false;
     RETURN (self);
+#endif /* not SCHTEAM */
 %}.
     ^ self primitiveFailed
 !
@@ -606,8 +611,8 @@
      Here, a few specific initializations are done, then the actual initialization is
      done inside an error handler in basicInitializeSystem.
      Notice:
-        this is NOT called when an image is restarted;
-        in this case the show starts in Smalltalk>>restart."
+	this is NOT called when an image is restarted;
+	in this case the show starts in Smalltalk>>restart."
 
     |idx|
 
@@ -617,79 +622,79 @@
     AbstractOperatingSystem initializeConcreteClass.
 
     CommandLineArguments isEmptyOrNil ifTrue:[
-        CommandLineArguments := #('stx') asOrderedCollection.
+	CommandLineArguments := #('stx') asOrderedCollection.
     ].
     CommandLine := CommandLineArguments copy.
     CommandLineArguments := CommandLineArguments asOrderedCollection.
     CommandName := CommandLineArguments removeFirst. "/ the command
 
     (idx := CommandLineArguments indexOf:'--silentStartup') ~~ 0 ifTrue:[
-        SilentLoading := true.
-        CommandLineArguments removeIndex:idx
+	SilentLoading := true.
+	CommandLineArguments removeIndex:idx
     ] ifFalse:[
-        SilentLoading := false.
-    ].        
+	SilentLoading := false.
+    ].
     (idx := CommandLineArguments indexOf:'--verboseLoading') ~~ 0 ifTrue:[
-        VerboseLoading := true.
-        CommandLineArguments removeIndex:idx
+	VerboseLoading := true.
+	CommandLineArguments removeIndex:idx
     ] ifFalse:[
-        VerboseLoading := false.
-    ].        
+	VerboseLoading := false.
+    ].
     (idx := CommandLineArguments indexOf:'--verboseStartup') ~~ 0 ifTrue:[
-        VerboseLoading := true.
-        VerboseStartup := true.
-        CommandLineArguments removeIndex:idx
+	VerboseLoading := true.
+	VerboseStartup := true.
+	CommandLineArguments removeIndex:idx
     ] ifFalse:[
-        VerboseStartup := false.
-    ].        
+	VerboseStartup := false.
+    ].
     (idx := CommandLineArguments indexOf:'--verbose') ~~ 0 ifTrue:[
-        Verbose := true.
-        VerboseLoading := true.
-        VerboseStartup := true.
-        CommandLineArguments removeIndex:idx
+	Verbose := true.
+	VerboseLoading := true.
+	VerboseStartup := true.
+	CommandLineArguments removeIndex:idx
     ] ifFalse:[
-        Verbose := false.
-    ].        
+	Verbose := false.
+    ].
 
     DebuggingStandAlone := false.
 
     StandAlone ifTrue:[
-        InfoPrinting := false.
-        ObjectMemory infoPrinting:false.
-        IgnoreAssertions := true.
-
-        idx := CommandLineArguments indexOf:'--debug'.
-        idx ~~ 0 ifTrue:[
-            DebuggingStandAlone := true.
-        ].
-        DebuggingStandAlone ifTrue:[
-            Inspector := MiniInspector.
-            Debugger := MiniDebugger.
-            IgnoreAssertions := false.
-        ].
+	InfoPrinting := false.
+	ObjectMemory infoPrinting:false.
+	IgnoreAssertions := true.
+
+	idx := CommandLineArguments indexOf:'--debug'.
+	idx ~~ 0 ifTrue:[
+	    DebuggingStandAlone := true.
+	].
+	DebuggingStandAlone ifTrue:[
+	    Inspector := MiniInspector.
+	    Debugger := MiniDebugger.
+	    IgnoreAssertions := false.
+	].
     ] ifFalse:[
-        "/
-        "/ define low-level debugging tools - graphical classes are not prepared yet
-        "/ to handle things.
-        "/ This will bring us into the MiniDebugger when an error occurs during startup.
-        "/
-        Inspector := MiniInspector.
-        Debugger := MiniDebugger.
-        IgnoreAssertions := false.
+	"/
+	"/ define low-level debugging tools - graphical classes are not prepared yet
+	"/ to handle things.
+	"/ This will bring us into the MiniDebugger when an error occurs during startup.
+	"/
+	Inspector := MiniInspector.
+	Debugger := MiniDebugger.
+	IgnoreAssertions := false.
     ].
 
     Error handle:[:ex |
-        StandAlone ifTrue:[
-            DebuggingStandAlone ifFalse:[
-                'Startup Error - use "--debug" command line argument for more info' errorPrintCR.
-                Smalltalk exit:1.
-            ].
-            'Smalltalk [error]: Error during early initialization:' errorPrintCR.
-            thisContext fullPrintAll.
-        ].
-        ex reject.
+	StandAlone ifTrue:[
+	    DebuggingStandAlone ifFalse:[
+		'Startup Error - use "--debug" command line argument for more info' errorPrintCR.
+		Smalltalk exit:1.
+	    ].
+	    'Smalltalk [error]: Error during early initialization:' errorPrintCR.
+	    thisContext fullPrintAll.
+	].
+	ex reject.
     ] do:[
-        self basicInitializeSystem
+	self basicInitializeSystem
     ].
 
     "Modified: / 12-10-2010 / 11:27:47 / cg"
@@ -1047,8 +1052,7 @@
 #ifdef __SCHTEAM__
     {
 	STSymbol keySymbol = aKey.asSTSymbol();
-	STObject oldValue = SmalltalkEnvironment.setBinding(keySymbol, aValue);
-	__c__.setLocal0( oldValue );
+	oldValue = SmalltalkEnvironment.setBinding(keySymbol, aValue);
     }
 #else
     oldValue = __GLOBAL_SET(aKey, aValue, (OBJ *)0);
@@ -2111,13 +2115,13 @@
 basicKeys
     "for rel > 5 only"
 
+%{
+#ifdef __SCHTEAM__
+    STObject[] keys = SmalltalkEnvironment.getKeyVector();
+    return __c__._RETURN( new STVector(keys) );
+#endif
+%}.
     self primitiveFailed
-
-
-
-
-
-
 !
 
 do:aBlock
@@ -2243,12 +2247,12 @@
      loadOK "exePath" errorInInitialize|
 
     packageDirOrStringOrNil notNil ifTrue:[
-        packageDirOrNil := packageDirOrStringOrNil asFilename.
+	packageDirOrNil := packageDirOrStringOrNil asFilename.
     ].
     VerboseLoading ifTrue:[
-        silent := false
+	silent := false
     ] ifFalse:[
-        silent := (SilentLoading or:[ StandAlone ]) or:[ InfoPrinting not ].
+	silent := (SilentLoading or:[ StandAlone ]) or:[ InfoPrinting not ].
     ].
 
     "For now: have to read the project definition first!!
@@ -2259,112 +2263,112 @@
     "maybe, it is already in the image"
     projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString.
     (projectDefinitionClass notNil and:[projectDefinitionClass supportedOnPlatform not]) ifTrue:[
-        ^ PackageNotCompatibleError raiseRequestWith:aPackageString errorString:' - package is not compatible with this platform'.
+	^ PackageNotCompatibleError raiseRequestWith:aPackageString errorString:' - package is not compatible with this platform'.
     ].
 
     "Is there a shared library (.dll or .so) ?"
     binaryClassLibraryFilename := ObjectFileLoader
-                                    binaryClassFilenameForPackage:aPackageString
-                                    inDirectory:packageDirOrNil.
+				    binaryClassFilenameForPackage:aPackageString
+				    inDirectory:packageDirOrNil.
 
     (binaryClassLibraryFilename notNil and:[binaryClassLibraryFilename exists]) ifTrue:[
-        |loadErrorOccurred|
-
-        loadErrorOccurred := false.
-        ObjectFileLoader objectFileLoadErrorNotification handle:[:ex |
-            loadErrorOccurred := true.
-            ex proceedWith:true.
-        ] do:[
-            loadOK := (ObjectFileLoader loadObjectFile:binaryClassLibraryFilename) notNil.
-            "/ loadOK := self loadPackage:aPackageString fromClassLibrary:binaryClassLibraryFilename.
-        ].
-        (loadOK and:[loadErrorOccurred not]) ifTrue:[
-            silent ifFalse:[
-                Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageString , ' from binary classLib file: ' , binaryClassLibraryFilename pathName).
-            ].
-            "now, all compiled classes have been loaded.
-             keep classes in the package which are autoloaded as autoloaded."
-            ^ true
-        ].
-
-        loadErrorOccurred ifTrue:[
-            self breakPoint:#cg.
-            projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString.
-            projectDefinitionClass notNil ifTrue:[
-                projectDefinitionClass supportedOnPlatform ifTrue:[
-                    "/ load prerequisites...
-                    projectDefinitionClass loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded.
-                    self breakPoint:#cg.
-                ].
-            ].
-        ].
+	|loadErrorOccurred|
+
+	loadErrorOccurred := false.
+	ObjectFileLoader objectFileLoadErrorNotification handle:[:ex |
+	    loadErrorOccurred := true.
+	    ex proceedWith:true.
+	] do:[
+	    loadOK := (ObjectFileLoader loadObjectFile:binaryClassLibraryFilename) notNil.
+	    "/ loadOK := self loadPackage:aPackageString fromClassLibrary:binaryClassLibraryFilename.
+	].
+	(loadOK and:[loadErrorOccurred not]) ifTrue:[
+	    silent ifFalse:[
+		Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageString , ' from binary classLib file: ' , binaryClassLibraryFilename pathName).
+	    ].
+	    "now, all compiled classes have been loaded.
+	     keep classes in the package which are autoloaded as autoloaded."
+	    ^ true
+	].
+
+	loadErrorOccurred ifTrue:[
+	    self breakPoint:#cg.
+	    projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString.
+	    projectDefinitionClass notNil ifTrue:[
+		projectDefinitionClass supportedOnPlatform ifTrue:[
+		    "/ load prerequisites...
+		    projectDefinitionClass loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded.
+		    self breakPoint:#cg.
+		].
+	    ].
+	].
     ].
     packageDirOrNil isNil ifTrue:[
-        ^ PackageNotFoundError raiseRequestWith:aPackageString.
+	^ PackageNotFoundError raiseRequestWith:aPackageString.
     ].
 
     "fallback - go through the project definition"
     projectDefinitionClass isNil ifTrue:[
-        projectDefinitionClassName := ProjectDefinition projectDefinitionClassNameForDefinitionOf:aPackageString.
-        "/ try to load the project definition class
-        projectDefinitionFilename := (packageDirOrNil / projectDefinitionClassName) withSuffix:'st'.
-        projectDefinitionFilename exists ifFalse:[
-            projectDefinitionFilename := (packageDirOrNil / 'source' / projectDefinitionClassName) withSuffix:'st'.
-        ].
-        projectDefinitionFilename exists ifTrue:[
-            Class withoutUpdatingChangesDo:[
-                Smalltalk silentlyLoadingDo:[
-                    Error handle:[:ex |
-                        "/ catch error during initialization;
-                        ex suspendedContext withAllSendersDo:[:sender |
-                            sender selector == #initialize ifTrue:[
-                                sender receiver isBehavior ifTrue:[
-                                    sender receiver name = projectDefinitionClassName ifTrue:[
-                                        errorInInitialize := true
-                                    ]
-                                ]
-                            ]
-                        ].
-                        errorInInitialize ifFalse:[ ex reject ].
-                    ] do:[
-                        projectDefinitionFilename fileIn.
-                    ].
-                ].
-            ].
-            errorInInitialize ifTrue:[
-                Transcript showCR:'Smalltalk [warning]: an error happened in #initialize - retry after loading package.'.
-            ].
-            projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString.
-        ].
+	projectDefinitionClassName := ProjectDefinition projectDefinitionClassNameForDefinitionOf:aPackageString.
+	"/ try to load the project definition class
+	projectDefinitionFilename := (packageDirOrNil / projectDefinitionClassName) withSuffix:'st'.
+	projectDefinitionFilename exists ifFalse:[
+	    projectDefinitionFilename := (packageDirOrNil / 'source' / projectDefinitionClassName) withSuffix:'st'.
+	].
+	projectDefinitionFilename exists ifTrue:[
+	    Class withoutUpdatingChangesDo:[
+		Smalltalk silentlyLoadingDo:[
+		    Error handle:[:ex |
+			"/ catch error during initialization;
+			ex suspendedContext withAllSendersDo:[:sender |
+			    sender selector == #initialize ifTrue:[
+				sender receiver isBehavior ifTrue:[
+				    sender receiver name = projectDefinitionClassName ifTrue:[
+					errorInInitialize := true
+				    ]
+				]
+			    ]
+			].
+			errorInInitialize ifFalse:[ ex reject ].
+		    ] do:[
+			projectDefinitionFilename fileIn.
+		    ].
+		].
+	    ].
+	    errorInInitialize ifTrue:[
+		Transcript showCR:'Smalltalk [warning]: an error happened in #initialize - retry after loading package.'.
+	    ].
+	    projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString.
+	].
     ].
     projectDefinitionClass notNil ifTrue:[
-        projectDefinitionClass autoload.
-        projectDefinitionClass supportedOnPlatform ifFalse:[
-            ^ PackageNotCompatibleError raiseRequestWith:aPackageString errorString:' - package is not compatible with this platform'.
-        ].
-        projectDefinitionClass loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded.
-        somethingHasBeenLoaded := projectDefinitionClass loadAsAutoloaded:doLoadAsAutoloaded.
-        errorInInitialize ifTrue:[
-            Transcript showCR:('Smalltalk [info]: retrying #initialize').
-            projectDefinitionClass initialize.
-        ].
-        (silent not and:[somethingHasBeenLoaded]) ifTrue:[
-            Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageString , ' from project definition').
-        ].
-        ^ true.
+	projectDefinitionClass autoload.
+	projectDefinitionClass supportedOnPlatform ifFalse:[
+	    ^ PackageNotCompatibleError raiseRequestWith:aPackageString errorString:' - package is not compatible with this platform'.
+	].
+	projectDefinitionClass loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded.
+	somethingHasBeenLoaded := projectDefinitionClass loadAsAutoloaded:doLoadAsAutoloaded.
+	errorInInitialize ifTrue:[
+	    Transcript showCR:('Smalltalk [info]: retrying #initialize').
+	    projectDefinitionClass initialize.
+	].
+	(silent not and:[somethingHasBeenLoaded]) ifTrue:[
+	    Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageString , ' from project definition').
+	].
+	^ true.
     ].
 
     "/ source files-file loading no longer supported
     "/ however, allow for autoload-stub loaded
     doLoadAsAutoloaded ifTrue:[
-        self
-            recursiveInstallAutoloadedClassesFrom:packageDirOrNil
-            rememberIn:(Set new)
-            maxLevels:2
-            noAutoload:false
-            packageTop:packageDirOrNil
-            showSplashInLevels:0.
-        ^ true
+	self
+	    recursiveInstallAutoloadedClassesFrom:packageDirOrNil
+	    rememberIn:(Set new)
+	    maxLevels:2
+	    noAutoload:false
+	    packageTop:packageDirOrNil
+	    showSplashInLevels:0.
+	^ true
     ].
 
     ^ PackageNotFoundError raiseRequestWith:aPackageString errorString:' - no projectDef, dll or loadAll found'.
@@ -2725,13 +2729,13 @@
     Smalltalk installAutoloadedClassesFrom:abbrevFile pathName.
 
     doLoadAsAutoloaded ifFalse:[
-        "/ force autoloading...
-        Smalltalk allClassesInPackage:aPackageId do:[:eachClass | eachClass autoload].
+	"/ force autoloading...
+	Smalltalk allClassesInPackage:aPackageId do:[:eachClass | eachClass autoload].
     ].
 
     self loadExtensionsFromDirectory:packageDir.
     VerboseLoading ifTrue:[
-        Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageId , ' from abbrev file: ' , abbrevFile pathName).
+	Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageId , ' from abbrev file: ' , abbrevFile pathName).
     ].
     ^ true
 
@@ -4143,243 +4147,243 @@
      while reading patches- and rc-file, do not add things into change-file
     "
     Class withoutUpdatingChangesDo:[
-        |commandFile defaultRC prevCatchSetting
-         isEval isPrint isFilter isRepl idxFileArg process|
-
-        isEval := isPrint := isFilter := isRepl := false.
-        didReadRCFile := false.
-
-        StandAlone ifFalse:[
-            "/
-            "/ look for any '-q', '-e', '-l' or '-f' command line arguments
-            "/ and handle them;
-            "/ read startup and patches file
-            "/
-            idx := CommandLineArguments indexOfAny:#('-R' '--repl').
-            isRepl := (idx ~~ 0).
-
-            idx := CommandLineArguments indexOfAny:#('-q' '--silent').
-            idx ~~ 0 ifTrue:[
-                Object infoPrinting:false.
-                ObjectMemory infoPrinting:false.
-                CommandLineArguments removeAtIndex:idx.
-                SilentLoading := true.
-            ].
-
-            [
-                idx := CommandLineArguments indexOfAny:#('-pp' '--packagePath').
-                idx ~~ 0
-            ] whileTrue:[
-                arg := CommandLineArguments at:idx + 1.
-                CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
-                self packagePath addLast:arg.
-                VerboseStartup == true ifTrue:[
-                    ('Smalltalk [info]: add to packagePath: "', arg, '".') infoPrintCR.
-                ].
-            ].
-
-            [
-                idx := CommandLineArguments indexOfAny:#('-l' '--load').
-                idx ~~ 0
-            ] whileTrue:[
-                arg := CommandLineArguments at:idx + 1.
-                CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
-                arg asFilename exists ifTrue:[
-                    Smalltalk fileIn:arg
-                ] ifFalse:[
-                    Smalltalk loadPackage:arg
-                ].
-            ].
-
-            "/ look for a '-e filename' or '--execute filename' argument
-            "/ this will force fileIn of filename only, no standard startup.
-
-            idx := CommandLineArguments indexOfAny:#('-e' '--execute' '--script').
-            idx ~~ 0 ifTrue:[
-                SilentLoading := true.
-                CommandName := arg := CommandLineArguments at:idx + 1.
-
-                CommandLineArguments
-                    removeAtIndex:idx+1; removeAtIndex:idx.
-
-                self startSchedulerAndBackgroundCollector.
-                keepSplashWindow ifFalse:[ self hideSplashWindow ].
-                Initializing := false.
-
-                process := [
-                    VerboseStartup == true ifTrue:[
-                        ('Smalltalk [info]: reading script from: "', arg, '".') infoPrintCR.
-                    ].
-                    UserInterrupt handle:[:ex |
-                        self exit:128+(OperatingSystem sigINT).
-                    ] do:[
-                        arg = '-' ifTrue:[
-                            self fileInStream:Stdin
-                                   lazy:nil
-                                   silent:nil
-                                   logged:false
-                                   addPath:nil
-                        ] ifFalse:[
-                            IsSTScript := true.
-                            self fileIn:arg.
-                        ].
-                    ].
-                    "/ after the script, if Screen has been opened and there are any open windows,
-                    "/ then do not exit
-                    Display notNil ifTrue:[
-                        Display exitOnLastClose:true.
-                        Display checkForEndOfDispatch.
-                        Processor exitWhenNoMoreUserProcesses:true.
-                    ] ifFalse:[
-                        self exit.
-                    ].
-                ] newProcess.
-                process priority:(Processor userSchedulingPriority).
-                process name:'main'.
-                process beGroupLeader.
-                process resume.
-
-                Processor dispatchLoop.
-                self exit
-            ].
-
-            "look for a '-f filename' or '--file filename' argument
-             if scripting, thisis loaded before -P, -E or-R action.
-             if not scripting, this will force evaluation of filename instead of smalltalk.rc"
-            idxFileArg := CommandLineArguments indexOfAny:#('-f' '--file').
-            (idxFileArg ~~ 0) ifTrue:[
-                commandFile := CommandLineArguments at:idxFileArg+1.
-                CommandLineArguments removeAtIndex:idxFileArg+1; removeAtIndex:idxFileArg.
-            ].
-
-            "/ look for a '-E expr' or '--eval expr' argument (-P or --print to print the result of evaluation)
-            "/ or -F/--filter or a '--repl' argument
-            "/ E, P and F this will force evaluation of expr only, no standard startup
-            "/ repl go into an interactive loop.
-            idx := CommandLineArguments indexOfAny:#('-E' '--eval').
-            (isEval := (idx ~~ 0)) ifFalse:[
-                idx := CommandLineArguments indexOfAny:#('-P' '--print').
-                (isPrint := (idx ~~ 0)) ifFalse:[
-                    idx := CommandLineArguments indexOfAny:#('-F' '--filter').
-                    (isFilter := (idx ~~ 0)) ifFalse:[
-                        idx := CommandLineArguments indexOfAny:#('-R' '--repl').
-                        isRepl := (idx ~~ 0)
-                    ].
-                ].
-            ].
-
-            (isEval | isPrint | isFilter | isRepl) ifTrue:[
-                isRepl ifFalse:[
-                    CommandLineArguments size <= idx ifTrue:[
-                        'stx: missing argument after -E/-P/-F' errorPrintCR.
-                        self exit:1.
-                    ].
-                    arg := CommandLineArguments at:idx + 1.
-                    CommandLineArguments removeAtIndex:idx+1.
-                ].
-                CommandLineArguments removeAtIndex:idx.
-
-                self startSchedulerAndBackgroundCollector.
-                keepSplashWindow ifFalse:[ self hideSplashWindow ].
-                Initializing := false.
-
-                "/ enable this, so we can provide $1..$n in the script
-                ParserFlags allowDollarInIdentifier:true.
-                ParserFlags warnDollarInIdentifier:false.
-
-                "/ add bindings for arguments
-                CommandLineArguments doWithIndex:[:arg :i |
-                    Workspace workspaceVariableAt:('_$',i printString) put:arg.
-                ].
-
-                "/ all of the above allow for a -f file to be loaded before any other action
-                (commandFile notNil) ifTrue:[
-                    VerboseStartup == true ifTrue:[
-                        ('Smalltalk [info]: reading command file from: "', commandFile, '".') infoPrintCR.
-                    ].
-                    (self secureFileIn:commandFile) ifFalse:[
-                        ('Smalltalk [error]: "', commandFile, '" not found.') errorPrintCR.
-                        OperatingSystem exit:1.
-                    ]
-                ].
-
-                isRepl ifTrue:[
-                    self readEvalPrint.
-                    self exit.
-                ].
-                process := [
-                    VerboseStartup == true ifTrue:[
-                        ('Smalltalk [info]: executing expression: "', arg, '".') infoPrintCR.
-                    ].
-                    UserInterrupt handle:[:ex |
-                        self exit:128+(OperatingSystem sigINT).
-                    ] do:[
-                        isFilter ifTrue:[
-                            "/ --filter - apply code to each input line.
-                            "/ compile code only once
-                            Compiler
-                                compile:'doIt ',arg
-                                forClass:String
-                                notifying:(EvalScriptingErrorHandler new source:arg).
-
-                            [Stdin atEnd] whileFalse:[
-                                |line|
-
-                                line := Stdin nextLine.
-                                line doIt.
-                            ].
-                        ] ifFalse:[
-                            "/ --print or --eval
-                            |rslt|
-
-                            rslt := Parser new
-                                        evaluate:arg
-                                        notifying:(EvalScriptingErrorHandler new source:arg)
-                                        compile:true.
-                            isPrint ifTrue:[
-                                rslt printCR.
-                            ].
-                        ].
-                    ].
-
-                    "/ after the script, if Screen has been opened and there are any open windows,
-                    "/ then do not exit
-                    Display notNil ifTrue:[
-                        Display exitOnLastClose:true.
-                        Display checkForEndOfDispatch.
-                        Processor exitWhenNoMoreUserProcesses:true.
-                        VerboseStartup == true ifTrue:[
-                            ('Smalltalk [info]: display opened.') infoPrintCR.
-                        ].
-                    ] ifFalse:[
-                        VerboseStartup == true ifTrue:[
-                            ('Smalltalk [info]: no display - exit after script.') infoPrintCR.
-                        ].
-                        self exit.
-                    ].
-                ] newProcess.
-                process priority:(Processor userSchedulingPriority).
-                process name:'main'.
-                process beGroupLeader.
-                process resume.
-
-                Processor dispatchLoop.
-                VerboseStartup == true ifTrue:[
-                    ('Smalltalk [info]: exit normally.') infoPrintCR.
-                ].
-                self exit
-            ].
-        ].
-
-        commandFile notNil ifTrue:[
-            SilentLoading := true.  "/ suppress the hello & copyright messages
-            self addStartBlock:
-                [
-                    (self secureFileIn:commandFile) ifFalse:[
-                        ('Smalltalk [error]: startup file "', commandFile, '" not found.') errorPrintCR.
-                        OperatingSystem exit:1.
-                    ].
-                ].
+	|commandFile defaultRC prevCatchSetting
+	 isEval isPrint isFilter isRepl idxFileArg process|
+
+	isEval := isPrint := isFilter := isRepl := false.
+	didReadRCFile := false.
+
+	StandAlone ifFalse:[
+	    "/
+	    "/ look for any '-q', '-e', '-l' or '-f' command line arguments
+	    "/ and handle them;
+	    "/ read startup and patches file
+	    "/
+	    idx := CommandLineArguments indexOfAny:#('-R' '--repl').
+	    isRepl := (idx ~~ 0).
+
+	    idx := CommandLineArguments indexOfAny:#('-q' '--silent').
+	    idx ~~ 0 ifTrue:[
+		Object infoPrinting:false.
+		ObjectMemory infoPrinting:false.
+		CommandLineArguments removeAtIndex:idx.
+		SilentLoading := true.
+	    ].
+
+	    [
+		idx := CommandLineArguments indexOfAny:#('-pp' '--packagePath').
+		idx ~~ 0
+	    ] whileTrue:[
+		arg := CommandLineArguments at:idx + 1.
+		CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
+		self packagePath addLast:arg.
+		VerboseStartup == true ifTrue:[
+		    ('Smalltalk [info]: add to packagePath: "', arg, '".') infoPrintCR.
+		].
+	    ].
+
+	    [
+		idx := CommandLineArguments indexOfAny:#('-l' '--load').
+		idx ~~ 0
+	    ] whileTrue:[
+		arg := CommandLineArguments at:idx + 1.
+		CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
+		arg asFilename exists ifTrue:[
+		    Smalltalk fileIn:arg
+		] ifFalse:[
+		    Smalltalk loadPackage:arg
+		].
+	    ].
+
+	    "/ look for a '-e filename' or '--execute filename' argument
+	    "/ this will force fileIn of filename only, no standard startup.
+
+	    idx := CommandLineArguments indexOfAny:#('-e' '--execute' '--script').
+	    idx ~~ 0 ifTrue:[
+		SilentLoading := true.
+		CommandName := arg := CommandLineArguments at:idx + 1.
+
+		CommandLineArguments
+		    removeAtIndex:idx+1; removeAtIndex:idx.
+
+		self startSchedulerAndBackgroundCollector.
+		keepSplashWindow ifFalse:[ self hideSplashWindow ].
+		Initializing := false.
+
+		process := [
+		    VerboseStartup == true ifTrue:[
+			('Smalltalk [info]: reading script from: "', arg, '".') infoPrintCR.
+		    ].
+		    UserInterrupt handle:[:ex |
+			self exit:128+(OperatingSystem sigINT).
+		    ] do:[
+			arg = '-' ifTrue:[
+			    self fileInStream:Stdin
+				   lazy:nil
+				   silent:nil
+				   logged:false
+				   addPath:nil
+			] ifFalse:[
+			    IsSTScript := true.
+			    self fileIn:arg.
+			].
+		    ].
+		    "/ after the script, if Screen has been opened and there are any open windows,
+		    "/ then do not exit
+		    Display notNil ifTrue:[
+			Display exitOnLastClose:true.
+			Display checkForEndOfDispatch.
+			Processor exitWhenNoMoreUserProcesses:true.
+		    ] ifFalse:[
+			self exit.
+		    ].
+		] newProcess.
+		process priority:(Processor userSchedulingPriority).
+		process name:'main'.
+		process beGroupLeader.
+		process resume.
+
+		Processor dispatchLoop.
+		self exit
+	    ].
+
+	    "look for a '-f filename' or '--file filename' argument
+	     if scripting, thisis loaded before -P, -E or-R action.
+	     if not scripting, this will force evaluation of filename instead of smalltalk.rc"
+	    idxFileArg := CommandLineArguments indexOfAny:#('-f' '--file').
+	    (idxFileArg ~~ 0) ifTrue:[
+		commandFile := CommandLineArguments at:idxFileArg+1.
+		CommandLineArguments removeAtIndex:idxFileArg+1; removeAtIndex:idxFileArg.
+	    ].
+
+	    "/ look for a '-E expr' or '--eval expr' argument (-P or --print to print the result of evaluation)
+	    "/ or -F/--filter or a '--repl' argument
+	    "/ E, P and F this will force evaluation of expr only, no standard startup
+	    "/ repl go into an interactive loop.
+	    idx := CommandLineArguments indexOfAny:#('-E' '--eval').
+	    (isEval := (idx ~~ 0)) ifFalse:[
+		idx := CommandLineArguments indexOfAny:#('-P' '--print').
+		(isPrint := (idx ~~ 0)) ifFalse:[
+		    idx := CommandLineArguments indexOfAny:#('-F' '--filter').
+		    (isFilter := (idx ~~ 0)) ifFalse:[
+			idx := CommandLineArguments indexOfAny:#('-R' '--repl').
+			isRepl := (idx ~~ 0)
+		    ].
+		].
+	    ].
+
+	    (isEval | isPrint | isFilter | isRepl) ifTrue:[
+		isRepl ifFalse:[
+		    CommandLineArguments size <= idx ifTrue:[
+			'stx: missing argument after -E/-P/-F' errorPrintCR.
+			self exit:1.
+		    ].
+		    arg := CommandLineArguments at:idx + 1.
+		    CommandLineArguments removeAtIndex:idx+1.
+		].
+		CommandLineArguments removeAtIndex:idx.
+
+		self startSchedulerAndBackgroundCollector.
+		keepSplashWindow ifFalse:[ self hideSplashWindow ].
+		Initializing := false.
+
+		"/ enable this, so we can provide $1..$n in the script
+		ParserFlags allowDollarInIdentifier:true.
+		ParserFlags warnDollarInIdentifier:false.
+
+		"/ add bindings for arguments
+		CommandLineArguments doWithIndex:[:arg :i |
+		    Workspace workspaceVariableAt:('_$',i printString) put:arg.
+		].
+
+		"/ all of the above allow for a -f file to be loaded before any other action
+		(commandFile notNil) ifTrue:[
+		    VerboseStartup == true ifTrue:[
+			('Smalltalk [info]: reading command file from: "', commandFile, '".') infoPrintCR.
+		    ].
+		    (self secureFileIn:commandFile) ifFalse:[
+			('Smalltalk [error]: "', commandFile, '" not found.') errorPrintCR.
+			OperatingSystem exit:1.
+		    ]
+		].
+
+		isRepl ifTrue:[
+		    self readEvalPrint.
+		    self exit.
+		].
+		process := [
+		    VerboseStartup == true ifTrue:[
+			('Smalltalk [info]: executing expression: "', arg, '".') infoPrintCR.
+		    ].
+		    UserInterrupt handle:[:ex |
+			self exit:128+(OperatingSystem sigINT).
+		    ] do:[
+			isFilter ifTrue:[
+			    "/ --filter - apply code to each input line.
+			    "/ compile code only once
+			    Compiler
+				compile:'doIt ',arg
+				forClass:String
+				notifying:(EvalScriptingErrorHandler new source:arg).
+
+			    [Stdin atEnd] whileFalse:[
+				|line|
+
+				line := Stdin nextLine.
+				line doIt.
+			    ].
+			] ifFalse:[
+			    "/ --print or --eval
+			    |rslt|
+
+			    rslt := Parser new
+					evaluate:arg
+					notifying:(EvalScriptingErrorHandler new source:arg)
+					compile:true.
+			    isPrint ifTrue:[
+				rslt printCR.
+			    ].
+			].
+		    ].
+
+		    "/ after the script, if Screen has been opened and there are any open windows,
+		    "/ then do not exit
+		    Display notNil ifTrue:[
+			Display exitOnLastClose:true.
+			Display checkForEndOfDispatch.
+			Processor exitWhenNoMoreUserProcesses:true.
+			VerboseStartup == true ifTrue:[
+			    ('Smalltalk [info]: display opened.') infoPrintCR.
+			].
+		    ] ifFalse:[
+			VerboseStartup == true ifTrue:[
+			    ('Smalltalk [info]: no display - exit after script.') infoPrintCR.
+			].
+			self exit.
+		    ].
+		] newProcess.
+		process priority:(Processor userSchedulingPriority).
+		process name:'main'.
+		process beGroupLeader.
+		process resume.
+
+		Processor dispatchLoop.
+		VerboseStartup == true ifTrue:[
+		    ('Smalltalk [info]: exit normally.') infoPrintCR.
+		].
+		self exit
+	    ].
+	].
+
+	commandFile notNil ifTrue:[
+	    SilentLoading := true.  "/ suppress the hello & copyright messages
+	    self addStartBlock:
+		[
+		    (self secureFileIn:commandFile) ifFalse:[
+			('Smalltalk [error]: startup file "', commandFile, '" not found.') errorPrintCR.
+			OperatingSystem exit:1.
+		    ].
+		].
 
 "/            self startSchedulerAndBackgroundCollector.
 "/            keepSplashWindow ifFalse:[ self hideSplashWindow ].
@@ -4389,67 +4393,67 @@
 "/                ('Smalltalk [error]: startup file "', commandFile, '" not found.') errorPrintCR.
 "/                OperatingSystem exit:1.
 "/            ].
-        ] ifFalse:[
-            "/ look for <command>.rc
-            "/ if not found, read smalltalk.rc (or stxapp.rc for standAlone operation)
-
-            commandFile := self commandName asFilename withSuffix:'rc'.
-            (didReadRCFile := commandFile exists and:[self secureFileIn:commandFile]) ifFalse:[
-                StandAlone ifFalse:[
-                    defaultRC := 'smalltalk.rc' "/asFilename
-                ] ifTrue:[
-                    defaultRC := 'stxapp.rc' "/asFilename
-                ].
-                "JV@2011-11-01: DO NOT check defaultRC exist - this prevents smalltalk to
-                    to be started with different working directory than stx/projects/smalltalk !!!!!!"
-
-                "/didReadRCFile := defaultRC exists and:[self secureFileIn:defaultRC].
-                didReadRCFile := (self getSystemFileName:defaultRC) notNil
-                                 and:[self secureFileIn:defaultRC].
-                didReadRCFile ifFalse:[
-                    StandAlone ifFalse:[
-                        'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
-                        graphicalMode := false.
-                    ]
-                ]
-            ].
-
-            "/ ('StandAlone is %1' bindWith:StandAlone) printCR.
-            "/ ('Headless is %1' bindWith:HeadlessOperation) printCR.
-            "/ ('Display is %1' bindWith:Display) printCR.
-            "/ ('Screen is %1' bindWith:Screen) printCR.
-
-            keepSplashWindow ifFalse:[ self hideSplashWindow ].
-            didReadRCFile ifFalse:[
-                'private.rc' asFilename exists ifTrue:[ self secureFileIn:'private.rc' ].
-
-                "/
-                "/ No RC file found;
-                "/ Setup more default stuff
-                "/
-                StandAlone ifFalse:[
-                    "/ its a smalltalk - proceed in interpreter.
-                    'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
-                    graphicalMode := false.
-                ].
-
-                "/ setup more defaults...
+	] ifFalse:[
+	    "/ look for <command>.rc
+	    "/ if not found, read smalltalk.rc (or stxapp.rc for standAlone operation)
+
+	    commandFile := self commandName asFilename withSuffix:'rc'.
+	    (didReadRCFile := commandFile exists and:[self secureFileIn:commandFile]) ifFalse:[
+		StandAlone ifFalse:[
+		    defaultRC := 'smalltalk.rc' "/asFilename
+		] ifTrue:[
+		    defaultRC := 'stxapp.rc' "/asFilename
+		].
+		"JV@2011-11-01: DO NOT check defaultRC exist - this prevents smalltalk to
+		    to be started with different working directory than stx/projects/smalltalk !!!!!!"
+
+		"/didReadRCFile := defaultRC exists and:[self secureFileIn:defaultRC].
+		didReadRCFile := (self getSystemFileName:defaultRC) notNil
+				 and:[self secureFileIn:defaultRC].
+		didReadRCFile ifFalse:[
+		    StandAlone ifFalse:[
+			'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
+			graphicalMode := false.
+		    ]
+		]
+	    ].
+
+	    "/ ('StandAlone is %1' bindWith:StandAlone) printCR.
+	    "/ ('Headless is %1' bindWith:HeadlessOperation) printCR.
+	    "/ ('Display is %1' bindWith:Display) printCR.
+	    "/ ('Screen is %1' bindWith:Screen) printCR.
+
+	    keepSplashWindow ifFalse:[ self hideSplashWindow ].
+	    didReadRCFile ifFalse:[
+		'private.rc' asFilename exists ifTrue:[ self secureFileIn:'private.rc' ].
+
+		"/
+		"/ No RC file found;
+		"/ Setup more default stuff
+		"/
+		StandAlone ifFalse:[
+		    "/ its a smalltalk - proceed in interpreter.
+		    'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
+		    graphicalMode := false.
+		].
+
+		"/ setup more defaults...
 "/                ObjectMemory startBackgroundCollectorAt:5.
 "/                ObjectMemory startBackgroundFinalizationAt:5.
-                self addStartBlock:[
-                    self startSchedulerAndBackgroundCollector
-                ].
-            ].
-        ].
-        (CommandLineArguments includes:'--scripting') ifTrue:[
-            self addStartBlock:[
-                StandaloneStartup handleScriptingOptionsFromArguments:CommandLineArguments.
-            ].
-        ].
+		self addStartBlock:[
+		    self startSchedulerAndBackgroundCollector
+		].
+	    ].
+	].
+	(CommandLineArguments includes:'--scripting') ifTrue:[
+	    self addStartBlock:[
+		StandaloneStartup handleScriptingOptionsFromArguments:CommandLineArguments.
+	    ].
+	].
     ].
 
     HeadlessOperation ifTrue:[
-        graphicalMode := false.
+	graphicalMode := false.
     ].
 
     keepSplashWindow ifFalse:[ self hideSplashWindow ].
@@ -8278,11 +8282,11 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1129 2015-05-08 01:20:17 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1130 2015-05-16 09:48:06 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1129 2015-05-08 01:20:17 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1130 2015-05-16 09:48:06 cg Exp $'
 !
 
 version_SVN