Smalltalk.st
changeset 17279 5e8cf598ce7e
parent 17095 2f236a870c9b
child 17317 f2f4dd9e8b3b
--- a/Smalltalk.st	Tue Jan 06 13:50:08 2015 +0100
+++ b/Smalltalk.st	Fri Jan 09 14:20:03 2015 +0100
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#Smalltalk
 	instanceVariableNames:''
 	classVariableNames:'StartBlocks ImageStartBlocks ExitBlocks CachedClasses
@@ -4212,196 +4214,210 @@
      while reading patches- and rc-file, do not add things into change-file
     "
     Class withoutUpdatingChangesDo:[
-	|commandFile defaultRC prevCatchSetting
-	 isEval isPrint isFilter isRepl idxFileArg process|
-
-	didReadRCFile := false.
-
-	StandAlone ifFalse:[
-	    "/
-	    "/ look for any '-q', '-e' or '-f' command line arguments
-	    "/ and handle them;
-	    "/ read startup and patches file
-	    "/
-	    idx := CommandLineArguments indexOfAny:#('-q' '--silent').
-	    idx ~~ 0 ifTrue:[
-		Object infoPrinting:false.
-		ObjectMemory infoPrinting:false.
-		CommandLineArguments removeAtIndex:idx.
-	    ].
-
-	    "/ 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 := [
-		    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.
-	    ].
-
-	    isEval := isPrint := isFilter := isRepl := false.
-
-	    "/ 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:[
-		    (self secureFileIn:commandFile) ifFalse:[
-			('Smalltalk [error]: "', commandFile, '" not found.') errorPrintCR.
-			OperatingSystem exit:1.
-		    ]
-		].
-
-		isRepl ifTrue:[
-		    self readEvalPrint.
-		    self exit.
-		].
-		process := [
-		    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.
-		    ] ifFalse:[
-			self exit.
-		    ].
-		] newProcess.
-		process priority:(Processor userSchedulingPriority).
-		process name:'main'.
-		process beGroupLeader.
-		process resume.
-
-		Processor dispatchLoop.
-		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|
+
+        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:#('-q' '--silent').
+            idx ~~ 0 ifTrue:[
+                Object infoPrinting:false.
+                ObjectMemory infoPrinting:false.
+                CommandLineArguments removeAtIndex:idx.
+            ].
+
+            [
+                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 := [
+                    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.
+            ].
+
+            isEval := isPrint := isFilter := isRepl := false.
+
+            "/ 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:[
+                    (self secureFileIn:commandFile) ifFalse:[
+                        ('Smalltalk [error]: "', commandFile, '" not found.') errorPrintCR.
+                        OperatingSystem exit:1.
+                    ]
+                ].
+
+                isRepl ifTrue:[
+                    self readEvalPrint.
+                    self exit.
+                ].
+                process := [
+                    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.
+                    ] ifFalse:[
+                        self exit.
+                    ].
+                ] newProcess.
+                process priority:(Processor userSchedulingPriority).
+                process name:'main'.
+                process beGroupLeader.
+                process resume.
+
+                Processor dispatchLoop.
+                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 ].
@@ -4411,67 +4427,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 ].
@@ -8271,11 +8287,11 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1093 2014-11-20 00:59:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1094 2015-01-09 13:20:03 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1093 2014-11-20 00:59:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1094 2015-01-09 13:20:03 cg Exp $'
 !
 
 version_SVN