Class.st
changeset 328 7b542c0bf1dd
parent 326 d2902942491d
child 333 18e7d5971e16
--- a/Class.st	Thu Apr 20 20:04:43 1995 +0200
+++ b/Class.st	Mon May 01 23:30:32 1995 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/Class.st,v 1.39 1995-04-11 14:48:39 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Class.st,v 1.40 1995-05-01 21:28:45 claus Exp $
 '!
 
 !Class class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/Class.st,v 1.39 1995-04-11 14:48:39 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Class.st,v 1.40 1995-05-01 21:28:45 claus Exp $
 "
 !
 
@@ -507,7 +507,7 @@
     "
     comment isNumber ifTrue:[
 	classFilename notNil ifTrue:[
-	    stream := Smalltalk systemFileStreamFor:('source/' , classFilename).
+	    stream := Smalltalk sourceFileStreamFor:classFilename.
 	    stream notNil ifTrue:[
 		stream position:comment.
 		string := String readFrom:stream onError:''.
@@ -544,10 +544,6 @@
     ]
 !
 
-organization
-    ^ ClassOrganization for:self
-!
-
 package
     "return the package of the class"
 
@@ -828,8 +824,10 @@
 unload
     "if the receiver was autoloaded, unload and reinstall it as
      autoloaded. Can be used to get rid of no longer needed autoloaded
-     classes. (maybe, autoloaded classes should unload themselfes when no
-     longer needed - for example, when tha application view is closed ...)"
+     classes. 
+     (maybe, autoloaded classes should unload themselfes when no
+      longer needed - for example, after some delay when the last instance 
+      is gone ...)"
 
     |nm|
 
@@ -1176,17 +1174,33 @@
 !Class methodsFor:'compiling'!
 
 compile:code
-    "compile code, aString for this class; if sucessful update method
-     dictionary."
-
-    self compilerClass compile:code forClass:self
+    "compile code, aString for this class; 
+     if sucessful update the method dictionary."
+
+    self compilerClass 
+	compile:code 
+	forClass:self
+!
+
+compile:code classified:category
+    "compile code, aString for this class; 
+     if sucessful update the method dictionary. 
+     The method is classified under category."
+
+    self compilerClass 
+	compile:code 
+	forClass:self 
+	inCategory:category
 !
 
 compile:code notifying:requestor
     "compile code, aString for this class; on any error, notify
-     requestor, anObject with the error reason"
-
-    self compilerClass compile:code forClass:self notifying:requestor
+     requestor, anObject with the error reason."
+
+    self compilerClass 
+	compile:code 
+	forClass:self 
+	notifying:requestor
 !
 
 recompileMethodsAccessingAny:setOfNames
@@ -1323,7 +1337,55 @@
 !
 
 wasAutoloaded
+    "return true, if this class came into the system via an
+     autoload; false otherwise.
+     This is not an attribute of the class, but instead remembered in
+     Autoload. The interface here is for covenience."
+
     ^ Autoload wasAutoloaded:self
+!
+
+whichClassDefinesInstVar:aVariableName
+    "return the class which defines the instance variable
+     named aVariableName. This method should not be used for
+     repeated searches (i.e. in the compiler/parser), since it creates
+     many throw away intermediate objects."
+
+    |cls|
+
+    cls := self.
+    [cls notNil] whileTrue:[
+	(cls instVarNames includes:aVariableName) ifTrue:[ ^ cls].
+	cls := cls superclass
+    ].
+    ^ nil
+
+    "
+     StandardSystemView whichClassDefinesInstVar:'label'  
+     StandardSystemView whichClassDefinesInstVar:'paint'  
+     StandardSystemView whichClassDefinesInstVar:'foo'  
+    "
+!
+
+whichClassDefinesClassVar:aVariableName
+    "return the class which defines the class variable
+     named aVariableName. This method should not be used for
+     repeated searches (i.e. in the compiler/parser), since it creates
+     many throw away intermediate objects."
+
+    |cls|
+
+    cls := self.
+    [cls notNil] whileTrue:[
+	(cls classVarNames includes:aVariableName) ifTrue:[ ^ cls].
+	cls := cls superclass
+    ].
+    ^ nil
+
+    "
+     StandardSystemView whichClassDefinesClassVar:'ErrorSignal'
+     StandardSystemView whichClassDefinesClassVar:'Foo'
+    "
 ! !
 
 !Class methodsFor:'private'!
@@ -1378,7 +1440,7 @@
     "
     pos isNumber ifTrue:[
 	classFilename notNil ifTrue:[
-	    stream := Smalltalk systemFileStreamFor:('source/' , classFilename).
+	    stream := Smalltalk sourceFileStreamFor:classFilename.
 	    stream notNil ifTrue:[
 		stream position:pos+1.
 		string := stream nextChunk.
@@ -1753,7 +1815,7 @@
 		raiseRequestWith:self
 		errorString:('no source for method: ' ,
 			     self name , '>>' ,
-			     (self selectorForMethod:aMethod))
+			     (self selectorAtMethod:aMethod))
 	] ifFalse:[
 	    aStream nextChunkPut:(aMethod source).
 	].
@@ -1932,7 +1994,7 @@
 
     |aStream fileName selector|
 
-    selector := self selectorForMethod:aMethod.
+    selector := self selectorAtMethod:aMethod.
     selector notNil ifTrue:[
 	fileName := name , '-' , selector, '.st'.
 	fileName replaceAll:$: by:$_.