|
Class: ClassBuilder
Object
|
+--ClassBuilder
- Package:
- stx:libbasic
- Category:
- Kernel-Support
- Version:
- rev:
1.188
date: 2024/04/26 19:38:33
- user: cg
- file: ClassBuilder.st directory: libbasic
- module: stx stc-classLibrary: libbasic
an old, ugly beast.
instances are temporarily created to figure out,
which methods and which subclasses need to be recompiled whenever a class's definition
changes.
For fast turn around times, it is good to recompile the smallest needed amount.
(However, in the meantime, so many checks and small-lints and others are watching for
such changes, that recompilation gets a little slow at times.
Also, the more browsers you have open, which react and research on changes,
the slower you get)
Code here is ugly and hard to maintain.
Keep your fingers away...
copyrightCOPYRIGHT (c) 2001 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
change & update
-
initialize
-
(comment from inherited method)
called only once - initialize signals
-
update: something with: aParameter from: changedObject
-
keep track of the namespace->classnames cache
checks
-
checkForAliasesOf: oldClass with: newClass
-
oldClass changed its identity (now use newClass).
check if there are any global aliases, which should also be changed
-
differentInstanceVariableOffsetsIn: class1 and: class2
-
return a set of instance variable names which have different
positions in class1 and class2.
Also, variables which are only present in one class are returned.
This is used to find methods which need recompilation after a
change in the instance variable layout.
Usage example(s):
View class
differentInstanceVariableOffsetsIn:View
and:StandardSystemView
View class
differentInstanceVariableOffsetsIn:Object
and:Point
|
class access
-
migrateInstancesQuery
-
recompiling
-
copyInvalidatedMethodsFrom: oldClass for: newClass
-
copy all methods from oldClass to newClass and change their code
to a trap method reporting an error.
This is done when a class has changed its layout or inheritance,
before recompilation is attempted.
This allows us to keep the source while trapping uncompilable (due to
now undefined instvars) methods. Later compilation of these methods will show
an error on the transcript and lead to the debugger once called.
-
copyInvalidatedMethodsFrom: oldClass for: newClass accessingAny: setOfNames
-
copy all methods from oldClass to newClass. Those methods accessing
a variable in setOfNames will be copied as invalid method, leading to
a trap when its executed. This is used when a class has changed its
layout for all methods which are affected by the change.
-
copyInvalidatedMethodsFrom: oldClass for: newClass accessingAny: setOfNames orSuper: superBoolean
-
copy all methods from oldClass to newClass.
Those methods accessing a variable in setOfNames will be copied as invalid method,
leading to a trap when executed. If superBoolean is true, this is also done
for methods accessing super.
When a class has changed its layout,
this is done for all methods which are affected by the change.
-
copyMethodsFrom: oldClass for: newClass
-
copy all methods from oldClass to newClass.
This is used for class-methods when a class has changed, but its metaclass is
unaffected (i.e. classVars/inheritance have not changed) so there is no need
to recompile the class methods.
-
recompileGlobalAccessorsTo: aGlobalKey in: aNamespace except: someClass
-
when a new class enters a namespace, all accessors to the same-named
class in that namespace must be recompiled.
This is required because if some global Foo is used inside a namespace, and that namespace
does not contain a Foo, that Foo refers to Smalltalk::Foo.
However when we finally load a Foo, all those refs should now refer to Namespace::Foo.
Because that is used heavily during package loading (for the same namespace), cache it.
-
recompileMachineCodeMethodsIn: aClass
-
recompile all machine-code methods in aClass.
Compatibility-Squeak
-
name: newName inEnvironment: aSystemDictionaryOrClass subclassOf: aClass type: type instanceVariableNames: stringOfInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryString
-
this returns the created class; it is not a simple accessor
accessing
-
classClass
-
-
classClass: aClass
-
-
metaclass: metaclassOrASubclassOfIt
-
-
name: newName inEnvironment: aSystemDictionaryOrClass subclassOf: aClass instanceVariableNames: stringOfInstVarNames variable: variableBoolean words: wordsBoolean pointers: pointersBoolean classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryString comment: commentString changed: changedBoolean classInstanceVariableNames: stringOfClassInstVarNamesOrNil
-
Allowing non-booleans as variableBoolean
-
oldMetaclass: aMetaclass instanceVariableNames: stringOfInstVarNames
-
building
-
buildClass
-
this is the main workhorse for installing new classes - special care
has to be taken, when changing an existing classes definition. In this
case, some or all of the methods and subclass-methods have to be
recompiled.
Also, the old class(es) are still kept (but not accessible as a global),
to allow existing instances some life.
This might change in the future.
-
newSubclassOf: baseClass type: typeOfClass instanceVariables: instanceVariables from: oldClassArg
-
anonymous classes can be built with this entry
building-helpers
-
changeReferencesFrom: oldClass to: newClass
-
answer := OptionBox
-
copyClassInstanceVariablesFrom: oldClass to: newClass
-
copy over classInstanceVariables
-
determineNewName
-
does the name imply a nameSpace ?
-
environmentChanged: how with: argument
-
-
environmentChangedOrganization
-
-
fixMethodsIn: newClass
-
care for class methods ...
-
flagsForVariable: variable pointers: pointers words: words
-
Allowing non-booleans as variable is a hack for STX / ST80 compatibility:
-
handleEasyNewClass: newClass
-
instance layout remains the same.
We only have to recompile methods which access changed class variables,
changed pool variables.
-
handleHardNewClass: newClass
-
instance layout has changed.
We have to recompile methods where the slot-index of any accessed instvar is different,
(in addition to those which access changed class variables, changed pool variables, etc.)
-
handleNewlyCreatedClass: newClass
-
comment notNil ifTrue:[
-
instantiateMetaclass
-
create the metaclass proper
-
instantiateNewClassFrom: newMetaclass
-
create the class proper
-
migrateInstancesOf: oldClass to: newClass
-
-
namesInPoolNamed: poolName ofClass: aClass
-
ns can be a owning class or a real nameSpace or Smalltalk
-
rebuildForChangedClassInstanceVariables
-
only called for metaclasses.
changing / adding class-inst vars -
this actually creates a new metaclass and class, leaving the original
classes around as obsolete classes. This may also be true for all subclasses,
if class instance variables are added/removed.
Existing instances become an instance of the new class
(which can be done without become, by changing their class only, because
the instance-layout has not changed).
However, if the old class is referenced somewhere (in a collection),
that reference will still point to the old, now obsolete class.
Time will show, if that is a problem and should be fixed.
-
setPackageInNewClass: newClass fromOld: oldClass
-
set the new classes package
-
setupNewClass: newClass fromOld: oldClass
-
self flagsForVariable:variable pointers:pointers words:words.
checks
-
checkClassName
-
check if the given name implies a (sub-) namespace
-
checkConventionsFor: className subClassOf: aClass instVarNames: instVarNameString classVarNames: classVarNameString
-
Check for some 'considered bad-style' things, like lower case names.
NOTICE:
I don't like the confirmers below - we need a notifying: argument, to give
the outer codeview a chance to highlight the error.
(but that's how its defined in the book - maybe I will change it anyway).
-
checkForCircularDefinitionFrom: oldClass
-
-
checkInstvarRedefsWith: stringOfInstVarNames subclassOf: aClass old: oldClass name: newName
-
check for instVar redef of superClass instVars
-
checkValidPools
-
check for invalid subclassing of UndefinedObject and SmallInteger
-
checkValidSubclassing
-
check for invalid subclassing of UndefinedObject and SmallInteger
-
checkValidVarNamesFor: className subClassOf: aClass instVarNames: instVarNameString classVarNames: classVarNameString
-
Check for some 'considered bad-style' things, like lower case names.
NOTICE:
I don't like the confirmers below - we need a notifying: argument, or a
notifierSignal to give the outer codeview a chance to highlight the error.
(but that's how its defined in the book - maybe I will change it anyway).
|