Smalltalk.st
changeset 19589 3f183fdea754
parent 19516 69d40825637a
child 19597 435f19b58541
--- a/Smalltalk.st	Thu Apr 14 19:06:16 2016 +0200
+++ b/Smalltalk.st	Fri Apr 15 10:45:51 2016 +0200
@@ -2333,133 +2333,126 @@
      The package is either located in packageDirOrStringOrNil, or in the current directory (if nil).
      Answer true, if the load succeeded, false if it failed"
 
-    |packageDirOrNil "shLibName"
-     binaryClassLibraryFilename projectDefinitionFilename projectDefinitionClass projectDefinitionClassName silent somethingHasBeenLoaded
-     loadOK "exePath" errorInInitialize|
+    |packageDirOrNil binaryClassLibraryFilename projectDefinitionFilename 
+     projectDefinitionClass projectDefinitionClassName silent somethingHasBeenLoaded
+     loadOK errorInInitialize|
 
     packageDirOrStringOrNil notNil ifTrue:[
-	packageDirOrNil := packageDirOrStringOrNil asFilename.
-    ].
-    VerboseLoading ifTrue:[
-	silent := false
-    ] ifFalse:[
-	silent := (SilentLoading or:[ StandAlone ]) or:[ InfoPrinting not ].
-    ].
+        packageDirOrNil := packageDirOrStringOrNil asFilename.
+    ].
+    silent := VerboseLoading not 
+                and:[SilentLoading or:[StandAlone or:[InfoPrinting not]]].
 
     "For now: have to read the project definition first!!
      The class library may contain subclasses of classes in prerequisite packages -
-     so the prerequisite packages have to be loaded first"
-    "normally there is a project definiton, use that one to pull in the rest"
+     so the prerequisite packages have to be loaded first.
+     Normally there is a project definiton, use that one to pull in the rest"
 
     "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:[
+            "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 
+                                and:[sender receiver isBehavior 
+                                and:[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'.