Autoload.st
changeset 3267 870789c08fad
parent 3151 018115a34d6f
child 3287 f3761386e4ba
equal deleted inserted replaced
3266:839e8f33d509 3267:870789c08fad
   256     "remove myself - to avoid recompilation"
   256     "remove myself - to avoid recompilation"
   257     Smalltalk at:myName put:nil.
   257     Smalltalk at:myName put:nil.
   258 
   258 
   259     "load it"
   259     "load it"
   260     (Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[
   260     (Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[
   261 	Transcript showCR:('autoloading ', myName , ' ...'); endEntry.
   261         Transcript showCR:('autoloading ', myName , ' ...'); endEntry.
   262     ].
   262     ].
   263 
   263 
   264     [
   264     [
   265 	prevMode := ClassCategoryReader sourceMode.
   265         prevMode := ClassCategoryReader sourceMode.
   266 "/
   266 "/
   267 "/ no- do not do this; it may lead to trouble ...
   267 "/ no- do not do this; it may lead to trouble ...
   268 "/        ClassCategoryReader sourceMode:#reference.
   268 "/        ClassCategoryReader sourceMode:#reference.
   269 
   269 
   270 	"/
   270         "/
   271 	"/ in order to not get a package of private (or whatever),
   271         "/ in order to not get a package of private (or whatever),
   272 	"/ temporarily set the currentProject to nil.
   272         "/ temporarily set the currentProject to nil.
   273 	"/ we will later set the classes package to something useful
   273         "/ we will later set the classes package to something useful
   274 	"/
   274         "/
   275 	Project notNil ifTrue:[
   275         Project notNil ifTrue:[
   276 	    project := Project current.
   276             project := Project current.
   277 	    Project setProject:nil.
   277             Project setProject:nil.
   278 	].
   278         ].
   279 
   279 
   280 	Class nameSpaceQuerySignal answer:myNameSpace "Smalltalk" 
   280         Class nameSpaceQuerySignal answer:myNameSpace "Smalltalk" 
   281 	do:[
   281         do:[
   282 	    package := self package.
   282             package := self package.
   283 	    package notNil ifTrue:[
   283             package notNil ifTrue:[
   284 		(package includes:$:) ifTrue:[
   284                 (package includes:$:) ifTrue:[
   285 		    package := package asString copy replaceAll:$: with:$/
   285                     package := package asString copy replaceAll:$: with:$/
   286 		] ifFalse:[
   286                 ] ifFalse:[
   287 		    package := 'stx/' , package
   287                     package := 'stx/' , package
   288 		]
   288                 ]
   289 	    ].
   289             ].
   290 	    Smalltalk 
   290             Smalltalk 
   291 		fileInClass:myName
   291                 fileInClass:myName
   292 		package:package
   292                 package:package
   293 		initialize:false 
   293                 initialize:false 
   294 		lazy:LazyLoading
   294                 lazy:LazyLoading
   295 		silent:nil.
   295                 silent:nil.
   296 	].
   296         ].
   297 	ClassCategoryReader sourceMode:prevMode.
   297         ClassCategoryReader sourceMode:prevMode.
   298 	project notNil ifTrue:[
   298         project notNil ifTrue:[
   299 	    Project setProject:project.
   299             Project setProject:project.
   300 	].
   300         ].
   301     ] valueOnUnwindDo:[
   301     ] valueOnUnwindDo:[
   302 	ClassCategoryReader sourceMode:prevMode.
   302         ClassCategoryReader sourceMode:prevMode.
   303 	project notNil ifTrue:[
   303         project notNil ifTrue:[
   304 	    Project setProject:project.
   304             Project setProject:project.
   305 	].
   305         ].
   306 	Smalltalk at:myName put:mySelf.
   306         Smalltalk at:myName put:mySelf.
   307     ].
   307     ].
   308 
   308 
   309     "did it work ?"
   309     "did it work ?"
   310     newClass := Smalltalk at:myName.
   310     newClass := Smalltalk at:myName.
   311     Smalltalk at:myName put:mySelf.   "will be undone by become:"
   311     Smalltalk at:myName put:mySelf.   "will be undone by become:"
   312 
   312 
   313     "no - report the error"
   313     "no - report the error"
   314     newClass isNil ifTrue:[
   314     newClass isNil ifTrue:[
   315 	"
   315         "
   316 	 this signal is raised, if an autoloaded class
   316          this signal is raised, if an autoloaded class
   317 	 cannot be loaded. Usually, this happends when
   317          cannot be loaded. Usually, this happends when
   318 	 some sourcefile is missing, not readable or if 
   318          some sourcefile is missing, not readable or if 
   319 	 an entry is missing in the abbreviation file.
   319          an entry is missing in the abbreviation file.
   320 	 Check for a readable file named <myName>.st 
   320          Check for a readable file named <myName>.st 
   321 	 in the 'source' directory and (if its a long fileName) 
   321          in the 'source' directory and (if its a long fileName) 
   322 	 for a corresponding entry in the abbreviation file
   322          for a corresponding entry in the abbreviation file
   323 	 'include/abbrev.stc'.
   323          'include/abbrev.stc'.
   324 	 Finally, your searchpath could be set wrong -
   324          Finally, your searchpath could be set wrong -
   325 	 both 'source' and 'include' directories must be found in
   325          both 'source' and 'include' directories must be found in
   326 	 one of the directories named in systemPath.
   326          one of the directories named in systemPath.
   327 
   327 
   328 	 In the debugger, press 'abort' to continue execution.
   328          In the debugger, press 'abort' to continue execution.
   329 	" 
   329         " 
   330 	AutoloadFailedSignal
   330         AutoloadFailedSignal
   331 	    raiseRequestWith:self
   331             raiseRequestWith:self
   332 	    errorString:('autoload of ' , myName , ' failed').
   332             errorString:('autoload of ' , myName , ' failed').
   333 	^ nil
   333         ^ nil
   334     ].
   334     ].
   335 
   335 
   336     "/
   336     "/
   337     "/ autoloaded classes get their package from the revision (if present)
   337     "/ autoloaded classes get their package from the revision (if present)
   338     "/ this only happens with autoloaded sourceFiles which have no package
   338     "/ this only happens with autoloaded sourceFiles which have no package
   340     "/ If there is no such information, give it my package (if I have one)
   340     "/ If there is no such information, give it my package (if I have one)
   341     "/
   341     "/
   342     newClass setPackageFromRevision.
   342     newClass setPackageFromRevision.
   343     (newClass package isNil 
   343     (newClass package isNil 
   344     or:[newClass package = 'no package']) ifTrue:[
   344     or:[newClass package = 'no package']) ifTrue:[
   345 	package := self package.
   345         package := self package.
   346 	(package notNil and:[package ~= 'no package'])
   346         (package notNil and:[package ~= 'no package'])
   347 	ifTrue:[
   347         ifTrue:[
   348 	    newClass setPackage:package.
   348             newClass setPackage:package.
   349 	].
   349         ].
   350     ].
   350     ].
   351 
   351 
   352     LoadedClasses isNil ifTrue:[
   352     LoadedClasses isNil ifTrue:[
   353 	LoadedClasses := IdentitySet new.
   353         LoadedClasses := IdentitySet new.
   354     ].
   354     ].
   355     LoadedClasses add:newClass.
   355     LoadedClasses add:newClass.
   356 
   356 
   357     "wow - it worked. now the big trick ..."
   357     "wow - it worked. now the big trick ..."
   358 
   358 
   359 "/    newClass class setSoleInstance:self.   "/ will be undone by become ...
   359 "/    newClass class setSoleInstance:self.   "/ will be undone by become ...
   360     oldMeta := self class.
   360     oldMeta := self class.
   361 
   361 
   362 self setName:(self name , ' (auto)').
   362 "/ self setName:(self name , ' (auto)').
   363 
   363 
   364     self becomeSameAs:newClass.
   364     self becomeSameAs:newClass.
   365     oldMeta becomeSameAs:newClass class.
   365     oldMeta becomeSameAs:newClass class.
   366 
   366 
   367     ObjectMemory flushCaches.
   367     ObjectMemory flushCaches.
   368     LoadedClasses rehash.
   368     LoadedClasses rehash.
   369 
   369 
   370     (newClass class implements:#initialize) ifTrue:[
   370     (newClass class implements:#initialize) ifTrue:[
   371 	newClass initialize.
   371         newClass initialize.
   372     ].
   372     ].
   373     newClass privateClassesDo:[:aPrivateClass |
   373     newClass privateClassesDo:[:aPrivateClass |
   374 	(aPrivateClass class implements:#initialize) ifTrue:[
   374         (aPrivateClass class implements:#initialize) ifTrue:[
   375 	    aPrivateClass initialize.
   375             aPrivateClass initialize.
   376 	]
   376         ]
   377     ].
   377     ].
   378     newClass postAutoload.
   378     newClass postAutoload.
   379     ^ newClass
   379     ^ newClass
   380 
   380 
   381     "Modified: / 9.1.1998 / 15:03:00 / cg"
   381     "Modified: / 3.2.1998 / 18:30:13 / cg"
   382 ! !
   382 ! !
   383 
   383 
   384 !Autoload class methodsFor:'message catching'!
   384 !Autoload class methodsFor:'message catching'!
   385 
   385 
   386 basicNew
   386 basicNew
   592 ! !
   592 ! !
   593 
   593 
   594 !Autoload class methodsFor:'documentation'!
   594 !Autoload class methodsFor:'documentation'!
   595 
   595 
   596 version
   596 version
   597     ^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.77 1998-01-12 13:09:39 cg Exp $'
   597     ^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.78 1998-02-03 17:30:42 cg Exp $'
   598 ! !
   598 ! !
   599 Autoload initialize!
   599 Autoload initialize!