Class.st
changeset 10 4f1f9a91e406
parent 5 67342904af11
child 22 847106305963
--- a/Class.st	Mon Nov 08 03:29:58 1993 +0100
+++ b/Class.st	Mon Nov 08 03:32:43 1993 +0100
@@ -45,7 +45,7 @@
 
 WARNING: layout known by compiler and runtime system
 
-$Header: /cvs/stx/stx/libbasic/Class.st,v 1.4 1993-10-13 02:11:26 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Class.st,v 1.5 1993-11-08 02:29:39 claus Exp $
 written Spring 89 by claus
 '!
 
@@ -73,22 +73,6 @@
     ^ newClass
 ! !
 
-!Class methodsFor:'autoload check'!
-
-isLoaded
-    "return true, if the class has been loaded; redefined in Autoload;
-     see comment there"
-
-    ^ true
-!
-
-autoload
-    "force autoloading - do nothing here; redefined in Autoload;
-     see comment there"
-
-    ^ self
-! !
-
 !Class methodsFor:'subclass creation'!
 
 subclass:t instanceVariableNames:f
@@ -406,7 +390,10 @@
 classVarNames
     "return a collection of the class variable name-strings"
 
-    ^ self addClassVarNamesTo:(OrderedCollection new)
+    classvars isNil ifTrue:[
+        ^ OrderedCollection new
+    ].
+    ^ classvars asCollectionOfWords
 !
 
 allClassVarNames
@@ -416,19 +403,6 @@
     ^ self addAllClassVarNamesTo:(OrderedCollection new)
 !
 
-instVarNames
-    "return a collection of the instance variable name-strings"
-
-    ^ self addInstVarNamesTo:(OrderedCollection new)
-!
-
-allInstVarNames
-    "return a collection of all the instance variable name-strings
-     this includes all superclass-instance variables"
-
-    ^ self addAllInstVarNamesTo:(OrderedCollection new)
-!
-
 comment
     "return the comment (aString) of the class"
 
@@ -446,8 +420,16 @@
     "set the comment of the class to be the argument, aString;
      create a change record"
 
-    comment := aString.
-    self addChangeRecordForClassComment:self
+    comment ~= aString ifTrue:[
+        comment := aString.
+        self addChangeRecordForClassComment:self
+    ]
+!
+
+classFileName
+    "return the name of the file from which the class was compiled"
+
+    ^ classFileName
 !
 
 definition
@@ -471,27 +453,23 @@
     category := categoryStringOrSymbol asSymbol
 !
 
-setName:aString
-    "set the classes name"
-
-    name := aString
-!
-
 setClassVariableString:aString
-    "set the classes classvarnames string"
+    "set the classes classvarnames string. This is a dangerous
+     (low level) operation, since the classvariables are not really
+     created."
 
     classvars := aString
 !
 
 classVariableString:aString
     "set the classes classvarnames string;
-     initialize new class variables with nil, clear and remove
-     old ones"
+     initialize new class variables with nil, 
+     clear and remove old ones. No change record is written."
 
     |prevVarNames varNames|
 
     "ignore for metaclasses except the one"
-    (self isMeta "isKindOf:Metaclass") ifTrue:[
+    (self isMeta) ifTrue:[
         (self == Metaclass) ifFalse:[
             ^ self
         ]
@@ -695,6 +673,34 @@
     ]
 !
 
+addChangeRecordForClassRename:oldName to:newName
+    "add a class-rename-record to the changes file"
+
+    |aStream|
+
+    aStream := self changesStream.
+    aStream notNil ifTrue:[
+        aStream nextPutAll:('Smalltalk renameClass:' , oldName , ' to:''' , newName , '''').
+        aStream nextPut:$!!.
+        aStream cr.
+        aStream close
+    ]
+!
+
+addChangeRecordForClassRemove:oldName
+    "add a class-remove-record to the changes file"
+
+    |aStream|
+
+    aStream := self changesStream.
+    aStream notNil ifTrue:[
+        aStream nextPutAll:('Smalltalk removeClass:' , oldName).
+        aStream nextPut:$!!.
+        aStream cr.
+        aStream close
+    ]
+!
+
 addChangeRecordForSnapshot
     "add a snapshot-record to the changes file"
 
@@ -713,18 +719,25 @@
 
 !Class methodsFor:'compiling'!
 
+compiler
+    "return the compiler to use for this class - this can be used to define
+     things like Lisp, Prolog or Basic :-) classes."
+
+    ^ Compiler
+!
+
 compile:code
     "compile code, aString for this class; if sucessful update method
      dictionary."
 
-    (Smalltalk at:#Compiler) compile:code forClass:self
+    self compiler compile:code forClass:self
 !
 
 compile:code notifying:requestor
     "compile code, aString for this class; on any error, notify
      requestor, anObject with the error reason"
 
-    (Smalltalk at:#Compiler) compile:code forClass:self notifying:requestor
+    self compiler compile:code forClass:self notifying:requestor
 !
 
 recompileMethodsAccessingAny:setOfNames
@@ -754,7 +767,7 @@
     [
         cat := (self compiledMethodAt:aSelector) category.
         code := self sourceCodeAt:aSelector.
-        (Smalltalk at:#Compiler) compile:code forClass:self inCategory:cat
+        self compiler compile:code forClass:self inCategory:cat
     ] valueNowOrOnUnwindDo:[
         Class updateChanges:upd
     ]
@@ -804,8 +817,8 @@
 !Class methodsFor:'queries'!
 
 isClass
-    "return true, if the receiver is some kind of class (real class, not
-     just behavior);
+    "return true, if the receiver is some kind of class 
+     (a real class, not just behavior);
      true is returned here - the method is redefined from Object"
 
     ^ true
@@ -833,64 +846,17 @@
 
 !Class methodsFor:'private'!
 
-addFromString:aString to:aCollection
-    "helper - take individual words from the first argument, aString
-     and add them as strings to the 2nd argument, aCollection.
-     return aCollection"
-
-    |start stop strLen|
-
-    aString isNil ifFalse:[
-        start := 1.
-        strLen := aString size.
-        [start <= strLen] whileTrue:[
-            (aString at:start) isSeparator ifTrue:[
-                start := start + 1
-            ] ifFalse:[
-                stop := aString indexOfSeparatorStartingAt:start.
-                stop == 0 ifTrue:[
-                    stop := strLen + 1
-                ].
-                aCollection add:(aString copyFrom:start to:(stop - 1)).
-                start := stop
-            ]
-        ]
-    ].
-    ^ aCollection
-!
-
-addInstVarNamesTo:aCollection
-    "add the name-strings of the instance variables
-     to the argument, aCollection. Return aCollection"
-
-    ^ self addFromString:instvars to:aCollection
-!
-
-addClassVarNamesTo:aCollection
-    "add the name-strings of the class varvariables
-     to the argument, aCollection. Return aCollection"
-
-    ^ self addFromString:classvars to:aCollection
-!
-
-addAllInstVarNamesTo:aCollection
-    "add the name-strings of the instance variables and of the inst-vars
-     of all superclasses to the argument, aCollection. Return aCollection"
-
-    (superclass notNil) ifTrue:[
-        superclass addAllInstVarNamesTo:aCollection
-    ].
-    ^ self addInstVarNamesTo:aCollection
-!
-
 addAllClassVarNamesTo:aCollection
-    "add the name-strings of the class variables and of the class-vars
+    "helper - add the name-strings of the class variables and of the class-vars
      of all superclasses to the argument, aCollection. Return aCollection"
 
     (superclass notNil) ifTrue:[
         superclass addAllClassVarNamesTo:aCollection
     ].
-    ^ self addClassVarNamesTo:aCollection
+    classvars notNil ifTrue:[
+        aCollection addAll:(classvars asCollectionOfWords).
+    ].
+    ^ aCollection
 !
 
 addCategoriesTo:aCollection
@@ -922,7 +888,8 @@
 !Class methodsFor:'fileIn interface'!
 
 methodsFor:aCategory
-    "return a ClassCategoryReader to read in and compile methods for me"
+    "return a ClassCategoryReader to read in and compile methods for me.
+     This one actually creates the ClassReader when code is filed-in."
 
     ^ ClassCategoryReader class:self category:aCategory
 !
@@ -1231,7 +1198,7 @@
     |collectionOfCategories|
 
     aStream nextPutAll:(Smalltalk timeStamp).
-    aStream nextPut:$!. 
+    aStream nextPut:$!!. 
     aStream cr.
     aStream cr.
     self fileOutDefinitionOn:aStream.
@@ -1346,11 +1313,11 @@
             aStream nextPut:$!!.
 
             aMethod byteCode isNil ifTrue:[
-                temporaryMethod := Compiler compile:(aMethod source)
-                                           forClass:self
-                                         inCategory:(aMethod category)
-                                          notifying:nil
-                                            install:false.
+                temporaryMethod := self compiler compile:(aMethod source)
+                                                forClass:self
+                                              inCategory:(aMethod category)
+                                               notifying:nil
+                                                 install:false.
                 temporaryMethod binaryFileOutOn:aStream
             ] ifFalse:[
                 aMethod binaryFileOutOn:aStream