Autoload.st
changeset 739 63566c9b691a
parent 729 67a60a088d56
child 789 155eca125ef0
equal deleted inserted replaced
738:576a41a6ab28 739:63566c9b691a
   120 
   120 
   121     (self == Autoload) ifTrue:[^ super fileOutDefinitionOn:aStream].
   121     (self == Autoload) ifTrue:[^ super fileOutDefinitionOn:aStream].
   122 
   122 
   123     myName := self name.
   123     myName := self name.
   124     aStream nextPutAll:'"' ; nextPutAll:'Notice from Autoload:'; cr; cr;
   124     aStream nextPutAll:'"' ; nextPutAll:'Notice from Autoload:'; cr; cr;
   125             spaces:4; nextPutAll:myName , ' is not yet loaded.'; cr; cr.
   125 	    spaces:4; nextPutAll:myName , ' is not yet loaded.'; cr; cr.
   126     aStream nextPutAll:'to load, execute: '.
   126     aStream nextPutAll:'to load, execute: '.
   127     aStream cr; cr; spaces:4; nextPutAll:myName  , ' autoload'; cr.
   127     aStream cr; cr; spaces:4; nextPutAll:myName  , ' autoload'; cr.
   128 
   128 
   129     "
   129     "
   130      the following is simply informative ...
   130      the following is simply informative ...
   132      in Smalltalk 
   132      in Smalltalk 
   133      (knowing the details of loading here is no good coding style)
   133      (knowing the details of loading here is no good coding style)
   134     "
   134     "
   135     fileName := Smalltalk fileNameForClass:myName.
   135     fileName := Smalltalk fileNameForClass:myName.
   136     (ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[
   136     (ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[
   137         (nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[
   137 	(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[
   138             nm := nm , ' (a classLibrary, possibly including more classes)'
   138 	    nm := nm , ' (a classLibrary, possibly including more classes)'
   139         ] ifFalse:[
   139 	] ifFalse:[
   140             nm := Smalltalk getBinaryFileName:(fileName , '.so').
   140 	    nm := Smalltalk getBinaryFileName:(fileName , '.so').
   141             nm isNil ifTrue:[
   141 	    nm isNil ifTrue:[
   142                 nm := Smalltalk getBinaryFileName:(fileName , '.o')
   142 		nm := Smalltalk getBinaryFileName:(fileName , '.o')
   143             ].
   143 	    ].
   144             nm notNil ifTrue:[
   144 	    nm notNil ifTrue:[
   145                 nm := nm , ' (a classBinary)'
   145 		nm := nm , ' (a classBinary)'
   146             ]
   146 	    ]
   147         ].
   147 	].
   148     ].
   148     ].
   149     nm isNil ifTrue:[
   149     nm isNil ifTrue:[
   150         nm := Smalltalk getFileInFileName:(fileName , '.st').
   150 	nm := Smalltalk getFileInFileName:(fileName , '.st').
   151         nm isNil ifTrue:[
   151 	nm isNil ifTrue:[
   152             nm := Smalltalk getSourceFileName:(fileName , '.st').
   152 	    nm := Smalltalk getSourceFileName:(fileName , '.st').
   153         ].
   153 	].
   154     ].
   154     ].
   155     nm notNil ifTrue:[
   155     nm notNil ifTrue:[
   156         aStream cr; nextPutAll:'When accessed, ' , myName , ' will automatically be loaded'; cr.
   156 	aStream cr; nextPutAll:'When accessed, ' , myName , ' will automatically be loaded'; cr.
   157         aStream nextPutAll:'from: '; cr; spaces:4; nextPutAll:nm.
   157 	aStream nextPutAll:'from: '; cr; spaces:4; nextPutAll:nm.
   158         nm asFilename isSymbolicLink ifTrue:[
   158 	nm asFilename isSymbolicLink ifTrue:[
   159             aStream cr; cr.
   159 	    aStream cr; cr.
   160             aStream nextPutAll:'which is a link to: '; cr; spaces:4; 
   160 	    aStream nextPutAll:'which is a link to: '; cr; spaces:4; 
   161                     nextPutAll:(nm asFilename linkInfo at:#path).
   161 		    nextPutAll:(nm asFilename linkInfo at:#path).
   162         ]
   162 	]
   163     ] ifFalse:[
   163     ] ifFalse:[
   164         aStream cr; nextPutAll:'There is currently no file to load ' , myName , ' from.'; cr; cr.
   164 	aStream cr; nextPutAll:'There is currently no file to load ' , myName , ' from.'; cr; cr.
   165 
   165 
   166         (mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[
   166 	(mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[
   167             classFileName := Smalltalk fileNameForClass:myName.
   167 	    classFileName := Smalltalk fileNameForClass:myName.
   168             packageDir := Smalltalk sourceDirectoryNameOfClass:myName.
   168 	    packageDir := Smalltalk sourceDirectoryNameOfClass:myName.
   169         ].
   169 	].
   170         (classFileName notNil and:[packageDir notNil]) ifTrue:[
   170 	(classFileName notNil and:[packageDir notNil]) ifTrue:[
   171             aStream nextPutAll:'When accessed, I''ll ask the sourceCodeManager to load the code 
   171 	    aStream nextPutAll:'When accessed, I''ll ask the sourceCodeManager to load the code 
   172 from "' , classFileName , '.st" in the "' , packageDir , '" package.'.
   172 from "' , classFileName , '.st" in the "' , packageDir , '" package.'.
   173         ] ifFalse:[
   173 	] ifFalse:[
   174             aStream nextPutAll:'When accessed, an error will be reported.'.
   174 	    aStream nextPutAll:'When accessed, an error will be reported.'.
   175         ]
   175 	]
   176     ].
   176     ].
   177     aStream cr; nextPutAll:'"'.
   177     aStream cr; nextPutAll:'"'.
   178 
   178 
   179     "Created: 8.12.1995 / 00:31:53 / cg"
   179     "Created: 8.12.1995 / 00:31:53 / cg"
   180     "Modified: 9.12.1995 / 22:31:02 / cg"
   180     "Modified: 9.12.1995 / 22:31:02 / cg"
   250     ].
   250     ].
   251     LoadedClasses add:self.
   251     LoadedClasses add:self.
   252 
   252 
   253     "wow - it worked. now the big trick ..."
   253     "wow - it worked. now the big trick ..."
   254 
   254 
       
   255     newClass class setSoleInstance:self.   "/ will be undone by become ...
   255     self become:newClass.
   256     self become:newClass.
   256     LoadedClasses rehash.
   257     LoadedClasses rehash.
   257     self initialize.            "/ thats the new class now
   258     self initialize.            "/ thats the new class now
   258     self postAutoload.
   259     self postAutoload.
   259     ^ self  "this is now the new class - see what doesNotUnderstand: does with it"
   260     ^ self  "this is now the new class - see what doesNotUnderstand: does with it"
   359 ! !
   360 ! !
   360 
   361 
   361 !Autoload class methodsFor:'documentation'!
   362 !Autoload class methodsFor:'documentation'!
   362 
   363 
   363 version
   364 version
   364     ^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.35 1995-12-09 23:28:48 cg Exp $'
   365     ^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.36 1995-12-12 12:55:20 cg Exp $'
   365 ! !
   366 ! !
   366 Autoload initialize!
   367 Autoload initialize!