Metaclass.st
author Claus Gittinger <cg@exept.de>
Mon, 15 Apr 1996 17:41:28 +0200
changeset 1179 3e0f32177af4
parent 1087 6cb00ecfbc6d
child 1266 cef9b3cd49df
permissions -rw-r--r--
allow subclasses of Class to be changed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Class subclass:#Metaclass
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
    14
	instanceVariableNames:'myClass'
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
    15
	classVariableNames:''
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
    16
	poolDictionaries:''
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
    17
	category:'Kernel-Classes'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    20
!Metaclass class methodsFor:'documentation'!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    24
 COPYRIGHT (c) 1988 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    25
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    33
"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    34
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    35
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    36
documentation
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    37
"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    38
    every classes class is a subclass of Metaclass.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    39
    (i.e. every class is the sole instance of its Metaclass)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    40
    Metaclass provides support for creating new (sub)classes and/or 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    41
    changing the definition of an already existing class.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    42
"
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    43
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    44
356
claus
parents: 328
diff changeset
    45
!Metaclass class methodsFor:'creating metaclasses'!
claus
parents: 328
diff changeset
    46
claus
parents: 328
diff changeset
    47
new
claus
parents: 328
diff changeset
    48
    "creating a new metaclass - have to set the new classes
claus
parents: 328
diff changeset
    49
     flags correctly to have it behave like a metaclass ...
claus
parents: 328
diff changeset
    50
     Not for normal applications - creating new metaclasses is a very
claus
parents: 328
diff changeset
    51
     tricky thing; should be left to the gurus ;-)"
claus
parents: 328
diff changeset
    52
claus
parents: 328
diff changeset
    53
    |newMetaclass|
claus
parents: 328
diff changeset
    54
claus
parents: 328
diff changeset
    55
    newMetaclass := super new.
claus
parents: 328
diff changeset
    56
    newMetaclass instSize:(Class instSize).
claus
parents: 328
diff changeset
    57
    newMetaclass setSuperclass:Class.
claus
parents: 328
diff changeset
    58
claus
parents: 328
diff changeset
    59
    ^ newMetaclass
claus
parents: 328
diff changeset
    60
claus
parents: 328
diff changeset
    61
    "
claus
parents: 328
diff changeset
    62
     Metaclass new           <- new metaclass
claus
parents: 328
diff changeset
    63
     Metaclass new new       <- new class
claus
parents: 328
diff changeset
    64
     Metaclass new new new   <- new instance
claus
parents: 328
diff changeset
    65
    "
claus
parents: 328
diff changeset
    66
! !
claus
parents: 328
diff changeset
    67
1179
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    68
!Metaclass class methodsFor:'queries'!
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    69
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    70
isBuiltInClass
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    71
    ^ self == Metaclass class or:[self == Metaclass]
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    72
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    73
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    74
! !
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
    75
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    76
!Metaclass methodsFor:'accessing'!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    77
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    78
name
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    79
    "return my name - that is the name of my sole class, with 'class'
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    80
     appended. Currently, this is incompatible to ST-80 (which appends ' class')
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    81
     and will be changed (have to check for side effects first ...)"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    82
682
a10f434805a7 be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
    83
    |nm|
a10f434805a7 be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
    84
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    85
    myClass isNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    86
        ^ 'someMetaclass'
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    87
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    88
"/    ^ myClass name , ' class'
682
a10f434805a7 be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
    89
a10f434805a7 be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
    90
    (nm := myClass name) isNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    91
        'METACLASS: oops - no name in my class' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    92
        name notNil ifTrue:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    93
            ^ name
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    94
        ].
682
a10f434805a7 be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
    95
    ].
a10f434805a7 be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
    96
    ^ nm , 'class'
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    97
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
    98
    "Modified: 7.3.1996 / 19:18:53 / cg"
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
    99
! !
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   100
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   101
!Metaclass methodsFor:'class instance variables'!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   102
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   103
instanceVariableNames:aString
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   104
    "changing / adding class-inst vars -
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   105
     this actually creates a new metaclass and class, leaving the original
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   106
     classes around as obsolete classes. This may also be true for all subclasses,
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   107
     if class instance variables are added/removed.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   108
     Existing instances continue to be defined by their original classes.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   109
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   110
     Time will show, if this is an acceptable behavior or if we should migrate
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   111
     instances to become insts. of the new classes."
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   112
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   113
    |newClass newMetaclass nClassInstVars oldClass 
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   114
     allSubclasses oldVars
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   115
     oldNames newNames addedNames
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   116
     oldOffsets newOffsets offset changeSet delta
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   117
     oldToNew newSubMeta newSub oldSubMeta oldSuper
986
c3a9f590146d removed unused locals
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
   118
     commonClassInstVars t|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   119
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   120
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   121
     cleanup needed here: extract common things with name:inEnvironment:...
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   122
     and restructure things ... currently way too complex.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   123
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   124
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   125
    oldVars := self instanceVariableString.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   126
    aString = oldVars ifTrue:[
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   127
"
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   128
	Transcript showCr:'no change (', oldVars , ') -> (', aString , ')'.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   129
"
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   130
	^ self
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   131
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   132
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   133
    oldNames := oldVars asCollectionOfWords.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   134
    newNames := aString asCollectionOfWords.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   135
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   136
    oldNames = newNames ifTrue:[
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   137
"
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   138
	Transcript showCr:'no real change'.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   139
"
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   140
	"no real change (just formatting)"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   141
	self setInstanceVariableString:aString.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   142
	^ self
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   143
    ]. 
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   144
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   145
"/    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   146
"/     let user confirm, if any name is no good (and was good before)
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   147
"/    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   148
"/    (oldNames inject:true
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   149
"/                into:[:okSoFar :word |
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   150
"/                         okSoFar and:[word first isUppercase]
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   151
"/                     ])
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   152
"/    ifTrue:[
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   153
"/        "was ok before"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   154
"/        (newNames inject:true
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   155
"/                    into:[:okSoFar :word |
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   156
"/                             okSoFar and:[word first isUppercase]
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   157
"/                         ])
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   158
"/        ifFalse:[
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   159
"/            (self confirm:'class instance variable names should start with an uppercase letter
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   160
"/(by convention only)
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   161
"/
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   162
"/install anyway ?' withCRs)
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   163
"/            ifFalse:[
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   164
"/                ^ nil
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   165
"/            ]
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   166
"/        ]
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   167
"/    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   168
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   169
    nClassInstVars := newNames size.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   170
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   171
"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   172
    Transcript showCr:'create new class/metaclass'.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   173
"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   174
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   175
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   176
     create the new metaclass
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   177
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   178
    newMetaclass := Metaclass new.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   179
    newMetaclass setSuperclass:superclass.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   180
    newMetaclass instSize:(superclass instSize + nClassInstVars).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   181
    (nClassInstVars ~~ 0) ifTrue:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   182
	newMetaclass setInstanceVariableString:aString
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   183
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   184
"/    newMetaclass flags:(Behavior flagBehavior "flagNotIndexed").
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   185
    newMetaclass setName:name.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   186
    newMetaclass classVariableString:classvars.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   187
    newMetaclass category:category.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   188
    newMetaclass setComment:(self comment).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   189
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   190
    "find the class which is my sole instance"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   191
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   192
    t := Smalltalk allClasses select:[:element | element class == self].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   193
    (t size ~~ 1) ifTrue:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   194
	self error:'oops - I should have exactly one instance'.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   195
	^ nil
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   196
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   197
    oldClass := t anElement.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   198
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   199
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   200
     create the new class
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   201
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   202
    newClass := newMetaclass new.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   203
    newClass setSuperclass:(oldClass superclass).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   204
    newClass instSize:(oldClass instSize).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   205
    newClass flags:(oldClass flags).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   206
    newClass setName:(oldClass name).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   207
    newClass setInstanceVariableString:(oldClass instanceVariableString).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   208
    newClass classVariableString:(oldClass classVariableString).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   209
    newClass setComment:(oldClass comment).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   210
    newClass category:(oldClass category).
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   211
    (t := oldClass primitiveSpec) notNil ifTrue:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   212
	newClass primitiveSpec:t.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   213
	newClass setClassFilename:(oldClass classFilename).
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   214
    ].        
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   215
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   216
    "/ set the new classes package
566
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   217
    "/ from the old package
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   218
566
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   219
    t := oldClass package.
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   220
    newMetaclass package:t.
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   221
    newClass package:t.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   222
723
ebc969b4678d preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents: 682
diff changeset
   223
    "/ and keep the binary revision
ebc969b4678d preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents: 682
diff changeset
   224
    newClass setBinaryRevision:(oldClass revision).
ebc969b4678d preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents: 682
diff changeset
   225
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   226
    changeSet := Set new.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   227
    ((oldNames size == 0) 
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   228
    or:[newNames startsWith:oldNames]) ifTrue:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   229
	"new variable(s) has/have been added - old methods still work"
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   230
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   231
" "
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   232
	Transcript showCr:'copying methods ...'.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   233
	Transcript endEntry.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   234
" "
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   235
	self copyMethodsFrom:self for:newMetaclass.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   236
	self copyMethodsFrom:oldClass for:newClass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   237
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   238
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   239
	 but have to recompile methods accessing stuff now defined
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   240
	 (it might have been a global before ...)
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   241
	"
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   242
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   243
	addedNames := newNames select:[:nm | (oldNames includes:nm) not].
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   244
" "
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   245
	Transcript showCr:'recompiling methods accessing ' , addedNames printString ,  '...'.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   246
	Transcript endEntry.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   247
" "
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   248
	"recompile class-methods"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   249
	newMetaclass recompileMethodsAccessingAny:addedNames.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   250
    ] ifFalse:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   251
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   252
	 create the changeSet; thats the set of class instvar names
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   253
	 which have changed their position or are new
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   254
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   255
	offset := 0. oldOffsets := Dictionary new.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   256
	oldNames do:[:nm | offset := offset + 1. oldOffsets at:nm put:offset].
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   257
	offset := 0. newOffsets := Dictionary new.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   258
	newNames do:[:nm | offset := offset + 1. newOffsets at:nm put:offset].
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   259
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   260
	oldOffsets associationsDo:[:a |
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   261
	    |k|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   262
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   263
	    k := a key.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   264
	    (newOffsets includesKey:k) ifFalse:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   265
		changeSet add:k
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   266
	    ] ifTrue:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   267
		(a value ~~ (newOffsets at:k)) ifTrue:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   268
		    changeSet add:k
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   269
		]
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   270
	    ]
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   271
	].
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   272
	newOffsets associationsDo:[:a |
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   273
	    |k|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   274
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   275
	    k := a key.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   276
	    (oldOffsets includesKey:k) ifFalse:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   277
		changeSet add:k
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   278
	    ] ifTrue:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   279
		(a value ~~ (oldOffsets at:k)) ifTrue:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   280
		    changeSet add:k
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   281
		]
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   282
	    ]
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   283
	].
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   284
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   285
" "
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   286
	Transcript showCr:'recompiling methods accessing ' , changeSet printString , ' ...'.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   287
	Transcript endEntry.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   288
" "
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   289
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   290
	 recompile class-methods
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   291
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   292
	self copyInvalidatedMethodsFrom:self for:newMetaclass accessingAny:changeSet.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   293
	newMetaclass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   294
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   295
	self copyMethodsFrom:oldClass for:newClass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   296
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   297
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   298
    delta := newNames size - oldNames size.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   299
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   300
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   301
     get list of all subclasses - do before superclass is changed
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   302
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   303
    allSubclasses := oldClass allSubclasses.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   304
    allSubclasses := allSubclasses asSortedCollection:[:a :b |
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   305
				b isSubclassOf:a
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   306
		     ].
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   307
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   308
    oldToNew := IdentityDictionary new.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   309
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   310
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   311
     create a new class tree, based on new version
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   312
    "
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   313
    allSubclasses do:[:aSubclass |
943
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   314
	|sels methods|
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   315
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   316
	oldSuper := aSubclass superclass.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   317
	oldSubMeta := aSubclass class.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   318
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   319
	newSubMeta := Metaclass new.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   320
	oldSuper == oldClass ifTrue:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   321
	    newSubMeta setSuperclass:newMetaclass.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   322
	] ifFalse:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   323
	    newSubMeta setSuperclass:(oldToNew at:oldSuper) class.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   324
	].
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   325
	newSubMeta instSize:(oldSubMeta instSize + delta).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   326
	newSubMeta flags:(oldSubMeta flags).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   327
	newSubMeta setName:(oldSubMeta name).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   328
	newSubMeta setInstanceVariableString:(oldSubMeta instanceVariableString).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   329
	newSubMeta classVariableString:(oldSubMeta classVariableString).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   330
	newSubMeta setComment:(oldSubMeta comment).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   331
	newSubMeta category:(oldSubMeta category).
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   332
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   333
	newSub := newSubMeta new.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   334
	oldSuper == oldClass ifTrue:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   335
	    newSub setSuperclass:newClass.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   336
	] ifFalse:[
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   337
	    newSub setSuperclass:(oldToNew at:oldSuper).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   338
	].
943
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   339
	sels := aSubclass selectorArray copy.
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   340
	methods := aSubclass methodArray copy.
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   341
	newSub setSelectorArray:sels.
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   342
	newSub setMethodArray:methods.
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   343
	newSub setName:(aSubclass name).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   344
	newSub classVariableString:(aSubclass classVariableString).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   345
	newSub setComment:(aSubclass comment).
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   346
	newSub category:(aSubclass category).
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   347
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   348
	oldToNew at:aSubclass put:newSub.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   349
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   350
	aSubclass category:'obsolete'.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   351
	aSubclass class category:'obsolete'.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   352
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   353
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   354
    "recompile what needs to be"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   355
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   356
    delta == 0 ifTrue:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   357
	"only have to recompile class methods accessing 
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   358
	 class instvars from changeset
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   359
	"
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   360
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   361
	allSubclasses do:[:oldSubclass |
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   362
	    |newSubclass|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   363
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   364
	    newSubclass := oldToNew at:oldSubclass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   365
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   366
Transcript showCr:'recompiling class methods of ' , newSubclass class name ,
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   367
		  ' accessing any of ' , changeSet printString.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   368
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   369
	    newSubclass class recompileMethodsAccessingAny:changeSet.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   370
	]
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   371
    ] ifFalse:[
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   372
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   373
	 have to recompile all class methods accessing class instvars
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   374
	"
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   375
	commonClassInstVars := oldClass class allInstVarNames.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   376
	changeSet do:[:v |
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   377
	    commonClassInstVars remove:v ifAbsent:[]
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   378
	].
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   379
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   380
	allSubclasses do:[:oldSubclass |
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   381
	    |newSubclass classInstVars|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   382
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   383
	    newSubclass := oldToNew at:oldSubclass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   384
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   385
	    classInstVars := newSubclass class allInstVarNames asSet.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   386
	    classInstVars removeAll:commonClassInstVars.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   387
	    classInstVars addAll:changeSet.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   388
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   389
Transcript showCr:'recompiling class methods of ' , newSubclass class name ,
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   390
		  ' accessing any of ' , classInstVars printString.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   391
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   392
	    newSubclass class recompileMethodsAccessingAny:classInstVars.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   393
	]
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   394
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   395
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   396
    self addChangeRecordForClassInstvars:newClass.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   397
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   398
    "install all new classes"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   399
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   400
    Smalltalk at:(oldClass name asSymbol) put:newClass.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   401
    ObjectMemory flushCachesFor:oldClass.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   402
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   403
    allSubclasses do:[:oldClass |
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   404
	|newClass|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   405
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   406
	newClass := oldToNew at:oldClass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   407
"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   408
Transcript showCr:'install ' , newClass name , '(' , newClass category , ')' ,
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   409
		  ' as ' , newClass name.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   410
"
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   411
	Smalltalk at:newClass name asSymbol put:newClass.
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   412
	ObjectMemory flushCachesFor:oldClass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   413
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   414
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   415
    "tell dependents ..."
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   416
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   417
    oldClass changed:#definition.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   418
    self changed:#definition.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   419
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   420
    ^ newMetaclass
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   421
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   422
    "Created: 29.10.1995 / 19:57:08 / cg"
723
ebc969b4678d preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents: 682
diff changeset
   423
    "Modified: 9.12.1995 / 17:05:44 / cg"
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   424
! !
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   425
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   426
!Metaclass methodsFor:'copying'!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   427
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   428
postCopy
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   429
    "redefined - a copy may have a new instance"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   430
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   431
    myClass := nil
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   432
! !
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   433
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   434
!Metaclass methodsFor:'creating classes'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   435
a27a279701f8 Initial revision
claus
parents:
diff changeset
   436
name:newName inEnvironment:aSystemDictionary
739
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   437
	     subclassOf:aClass
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   438
	     instanceVariableNames:stringOfInstVarNames
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   439
	     variable:variableBoolean
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   440
	     words:wordsBoolean
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   441
	     pointers:pointersBoolean
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   442
	     classVariableNames:stringOfClassVarNames
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   443
	     poolDictionaries:stringOfPoolNames
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   444
	     category:categoryString
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   445
	     comment:commentString
63566c9b691a oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
   446
	     changed:changed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   447
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   448
    ^ self
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   449
	name:newName 
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   450
	inEnvironment:aSystemDictionary
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   451
	subclassOf:aClass
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   452
	instanceVariableNames:stringOfInstVarNames
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   453
	variable:variableBoolean
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   454
	words:wordsBoolean
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   455
	pointers:pointersBoolean
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   456
	classVariableNames:stringOfClassVarNames
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   457
	poolDictionaries:stringOfPoolNames
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   458
	category:categoryString
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   459
	comment:commentString
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   460
	changed:changed
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   461
	classInstanceVariableNames:''
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   462
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   463
    "Modified: 22.1.1996 / 13:18:08 / cg"
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   464
!
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   465
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   466
name:newName inEnvironment:aSystemDictionary
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   467
             subclassOf:aClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   468
             instanceVariableNames:stringOfInstVarNames
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   469
             variable:variableBoolean
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   470
             words:wordsBoolean
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   471
             pointers:pointersBoolean
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   472
             classVariableNames:stringOfClassVarNames
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   473
             poolDictionaries:stringOfPoolNames
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   474
             category:categoryString
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   475
             comment:commentString
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   476
             changed:changed
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   477
             classInstanceVariableNames:stringOfClassInstVarNames
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   478
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   479
    "this is the main workhorse for installing new classes - special care
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   480
     has to be taken, when changing an existing classes definition. In this
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   481
     case, some or all of the methods and subclasses methods have to be
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   482
     recompiled.
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   483
     Also, the old class(es) are still kept (but not accessable as a global),
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   484
     to allow existing instances some life. 
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   485
     This might change in the future.
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   486
    "
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   487
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   488
    |newClass newMetaclass nInstVars nameString classSymbol oldClass 
175
82ba8d2e3569 *** empty log message ***
claus
parents: 159
diff changeset
   489
     classVarChange instVarChange superClassChange newComment
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
   490
     changeSet1 changeSet2 addedNames
326
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   491
     anyChange oldInstVars newInstVars oldClassVars newClassVars superFlags newFlags
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   492
     project currentProject t nClassInstVars|
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   493
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   494
    "NOTICE:
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   495
     this method is too complex and should be splitted into managable pieces ...
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
   496
     I dont like it anymore :-) 
356
claus
parents: 328
diff changeset
   497
     (well, at least, its a good test for the compilers ability 
claus
parents: 328
diff changeset
   498
      to handle big, complex methods ;-)
claus
parents: 328
diff changeset
   499
     take it as an example of bad coding style ...
claus
parents: 328
diff changeset
   500
claus
parents: 328
diff changeset
   501
     ST-80 uses a ClassBuilder object to collect the work and perform all updates;
claus
parents: 328
diff changeset
   502
     this method may be changed to do something similar in the future ...
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   503
    "
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   504
328
claus
parents: 326
diff changeset
   505
    project := Project. "/ have to fetch this before, in case its autoloaded
claus
parents: 326
diff changeset
   506
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   507
    newName = aClass name ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   508
        self error:'trying to create circular class definition'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   509
        ^ nil
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   510
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   511
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   512
    "check for invalid subclassing of UndefinedObject and SmallInteger"
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   513
    aClass canBeSubclassed ifFalse:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   514
        self error:('it is not possible to subclass ' , aClass name).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   515
        ^ nil
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   516
    ].
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   517
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   518
    nInstVars := stringOfInstVarNames countWords.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   519
    nameString := newName asString.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   520
    classSymbol := newName asSymbol.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   521
    newComment := commentString.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   522
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   523
    "look, if it already exists as a class"
870
0d60b4b7962a handle nil environment
Claus Gittinger <cg@exept.de>
parents: 866
diff changeset
   524
    aSystemDictionary notNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   525
        oldClass := aSystemDictionary at:classSymbol ifAbsent:[nil].
870
0d60b4b7962a handle nil environment
Claus Gittinger <cg@exept.de>
parents: 866
diff changeset
   526
    ].
866
615ea25db48b dont copy comment from autoloaded classes
Claus Gittinger <cg@exept.de>
parents: 739
diff changeset
   527
    (oldClass isBehavior and:[oldClass isLoaded]) ifFalse:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   528
        oldClass := nil.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   529
    ] ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   530
        oldClass name ~= classSymbol ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   531
            (self confirm:(classSymbol , ' is an alias for ' , oldClass name , '\\continue ?') withCRs)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   532
            ifFalse:[^ self].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   533
            oldClass := nil
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   534
        ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   535
            "/
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   536
            "/ some consisteny checks
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   537
            "/
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   538
            oldClass superclass notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   539
                oldClass allSuperclasses do:[:cls |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   540
                    cls name = nameString ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   541
                        self error:'trying to create circular class definition'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   542
                        ^ nil
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   543
                    ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   544
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   545
            ].
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   546
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   547
            aClass superclass notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   548
                aClass allSuperclasses do:[:cls |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   549
                    cls name = nameString ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   550
                        self error:'trying to create circular class definition'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   551
                        ^ nil
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   552
                    ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   553
                ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   554
            ].
328
claus
parents: 326
diff changeset
   555
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   556
            newComment isNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   557
                newComment := oldClass comment
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   558
            ].
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   559
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   560
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   561
             warn, if it exists with different category and different instvars,
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   562
             and the existing is not an autoload class.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   563
             Usually, this indicates that someone wants to create a new class with
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   564
             a name, which already exists (it happened a few times to myself, while 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   565
             I wanted to create a new class called ReturnNode ...).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   566
             This will be much less of a problem, once multiple name spaces are
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   567
             implemented and classes can be put into separate packages.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   568
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   569
            oldClass isLoaded ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   570
                oldClass category ~= categoryString ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   571
                    oldClass instanceVariableString asCollectionOfWords 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   572
                    ~= stringOfInstVarNames asCollectionOfWords ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   573
                        (self confirm:'a class named ' , oldClass name , 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   574
                                      ' already exists -\\create (i.e. change) anyway ?' withCRs)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   575
                        ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   576
                            ^ nil
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   577
                        ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   578
                    ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   579
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   580
            ].
362
claus
parents: 357
diff changeset
   581
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   582
            "/
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   583
            "/ hints - warn, if creating a variableSubclass of a Set
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   584
            "/ (common error - containers in ST/X do not use variable-slots)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   585
            "/
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   586
            ((variableBoolean == true) and:[pointersBoolean]) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   587
                (oldClass isKindOf:Set class) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   588
                    (self confirm:'ST/X Set & Dictionary are not variable-classes\create anyway ?' withCRs)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   589
                    ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   590
                        ^ nil
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   591
                    ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   592
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   593
            ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   594
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   595
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   596
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   597
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   598
     Check for some 'considered bad-style' things, like lower case names.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   599
     But only do these checks for new classes - 
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   600
     - thus, once confirmed, the warnings will not come again and again.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   601
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   602
     NOTICE:
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
   603
     I dont like the confirmers there - we need a notifying: argument, to give
44
b262907c93ea *** empty log message ***
claus
parents: 33
diff changeset
   604
     the outer codeview a chance to highlight the error.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   605
     (but thats how its defined in the book - maybe I will change anyway).
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   606
    "
44
b262907c93ea *** empty log message ***
claus
parents: 33
diff changeset
   607
    oldClass isNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   608
        (self checkConventionsFor:newName 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   609
                    instVarNames:stringOfInstVarNames 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   610
                    classVarNames:stringOfClassVarNames) ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   611
            ^ nil
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   612
        ]
44
b262907c93ea *** empty log message ***
claus
parents: 33
diff changeset
   613
    ].
b262907c93ea *** empty log message ***
claus
parents: 33
diff changeset
   614
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   615
    nClassInstVars := stringOfClassInstVarNames countWords.
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   616
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   617
    "create the metaclass first"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   618
    newMetaclass := Metaclass new.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   619
    newMetaclass setSuperclass:(aClass class).
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   620
    newMetaclass instSize:(aClass class instSize + nClassInstVars).
175
82ba8d2e3569 *** empty log message ***
claus
parents: 159
diff changeset
   621
    newMetaclass setName:(nameString , 'class') asSymbol.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   622
    newMetaclass classVariableString:'' "stringOfClassVarNames".
226
9287f8ace7ae set package
claus
parents: 202
diff changeset
   623
"/    newMetaclass setComment:newComment category:categoryString.
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
   624
    newMetaclass setInstanceVariableString:stringOfClassInstVarNames.
326
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   625
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
   626
    "then let the new meta create the class"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   627
    newClass := newMetaclass new.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   628
    newClass setSuperclass:aClass.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   629
    newClass instSize:(aClass instSize + nInstVars).
175
82ba8d2e3569 *** empty log message ***
claus
parents: 159
diff changeset
   630
    newClass setName:classSymbol.
82ba8d2e3569 *** empty log message ***
claus
parents: 159
diff changeset
   631
    newClass setComment:newComment category:categoryString.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   632
362
claus
parents: 357
diff changeset
   633
    "/ set the new classes package
566
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   634
    "/ but prefer the old package
362
claus
parents: 357
diff changeset
   635
566
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   636
    oldClass notNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   637
        t := oldClass package.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   638
        newClass setBinaryRevision:(oldClass binaryRevision).
566
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   639
    ] ifFalse:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   640
        project notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   641
            currentProject := project current.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   642
            currentProject notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   643
                t := currentProject packageName.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   644
            ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   645
        ].
566
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   646
    ].
3d2527a9e96d preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   647
    t notNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   648
        newMetaclass package:t.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   649
        newClass package:t.
362
claus
parents: 357
diff changeset
   650
    ].
claus
parents: 357
diff changeset
   651
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   652
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   653
     Allowing non-booleans as variableBoolean
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   654
     is a hack for backward (ST-80) compatibility:
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   655
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   656
     ST-80 code will pass true or false as variableBoolean,
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   657
     while ST/X also calls it with symbols such as #float, #double etc.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   658
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   659
    (variableBoolean == true) ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   660
        pointersBoolean ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   661
            newFlags := Behavior flagPointers
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   662
        ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   663
            wordsBoolean ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   664
                newFlags := Behavior flagWords
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   665
            ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   666
                newFlags := Behavior flagBytes
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   667
            ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   668
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   669
    ] ifFalse:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   670
        (variableBoolean == #float) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   671
            newFlags := Behavior flagFloats
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   672
        ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   673
            (variableBoolean == #double) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   674
                newFlags := Behavior flagDoubles
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   675
            ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   676
                (variableBoolean == #long) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   677
                    newFlags := Behavior flagLongs
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   678
                ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   679
                    newFlags := Behavior flagNotIndexed   
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   680
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   681
            ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   682
        ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   683
    ].
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   684
    superFlags := aClass flags bitAnd:(Behavior maskIndexType bitInvert). "preserve other bits"
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   685
    oldClass notNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   686
        oldClass isBuiltInClass ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   687
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   688
             special care when redefining Method, Block and other built-in classes,
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   689
             which might have other flag bits ...
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   690
            "
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   691
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   692
            newFlags := newFlags bitOr:(oldClass flags bitAnd:(Behavior maskIndexType bitInvert))
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   693
        ]
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   694
    ].
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   695
    newClass flags:(newFlags bitOr:superFlags). "preserve  inherited special bits"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   696
a27a279701f8 Initial revision
claus
parents:
diff changeset
   697
    (nInstVars ~~ 0) ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   698
        newClass setInstanceVariableString:stringOfInstVarNames
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   699
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   700
    oldClass notNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   701
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   702
         setting first will make new class clear obsolete classvars
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   703
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   704
        newClass setClassVariableString:(oldClass classVariableString).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   705
        (t := oldClass primitiveSpec) notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   706
            newClass primitiveSpec:t.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   707
            newClass setClassFilename:(oldClass classFilename).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   708
        ]        
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   709
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   710
    newClass classVariableString:stringOfClassVarNames.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   711
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   712
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   713
     for new classes, we are almost done here
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   714
     (also for autoloaded classes)
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   715
    "
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   716
    (oldClass isNil or:[oldClass isLoaded not]) ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   717
        (oldClass isNil and:[changed]) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   718
            self addChangeRecordForClass:newClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   719
        ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   720
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   721
        commentString notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   722
            newClass comment:commentString
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   723
        ].
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   724
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   725
        aSystemDictionary notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   726
            aSystemDictionary at:classSymbol put:newClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   727
        ].
314
7581a5c57224 *** empty log message ***
claus
parents: 308
diff changeset
   728
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   729
        oldClass isNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   730
            project notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   731
                currentProject := project current.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   732
                currentProject notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   733
                    "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   734
                     new classes get the package assigned
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   735
                    "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   736
                    newClass package:(currentProject packageName asSymbol)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   737
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   738
            ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   739
        ].
314
7581a5c57224 *** empty log message ***
claus
parents: 308
diff changeset
   740
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   741
        aSystemDictionary notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   742
            aSystemDictionary changed:#newClass with:newClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   743
        ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   744
        ^ newClass
2
claus
parents: 1
diff changeset
   745
    ].
claus
parents: 1
diff changeset
   746
10
claus
parents: 5
diff changeset
   747
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   748
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   749
     here comes the hard part - we are actually changing the
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   750
     definition of an existing class ....
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   751
     Try hard to get away WITHOUT recompiling, since it makes all
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   752
     compiled code into interpreted ...
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   753
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   754
10
claus
parents: 5
diff changeset
   755
    oldInstVars := oldClass instanceVariableString asCollectionOfWords.
claus
parents: 5
diff changeset
   756
    newInstVars := newClass instanceVariableString asCollectionOfWords.
claus
parents: 5
diff changeset
   757
    oldClassVars := oldClass classVariableString asCollectionOfWords.
claus
parents: 5
diff changeset
   758
    newClassVars := newClass classVariableString asCollectionOfWords.
claus
parents: 5
diff changeset
   759
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   760
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   761
     we are on the bright side of life, if the instance layout and
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   762
     inheritance do not change.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   763
     In this case, we can go ahead and patch the class object.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   764
    "
2
claus
parents: 1
diff changeset
   765
    (oldClass superclass == newClass superclass) ifTrue:[
claus
parents: 1
diff changeset
   766
      (oldClass instSize == newClass instSize) ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   767
        (oldClass flags == newClass flags) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   768
          (oldClass name = newClass name) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   769
            (oldInstVars = newInstVars) ifTrue:[
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   770
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   771
              (newComment ~= oldClass comment) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   772
                  oldClass setComment:newComment.        "writes a change-chunk"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   773
                  oldClass changed:#comment with:oldClass comment.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   774
                  changed ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   775
                      self addChangeRecordForClassComment:oldClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   776
                  ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   777
              ]. 
10
claus
parents: 5
diff changeset
   778
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   779
              (oldClassVars = newClassVars) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   780
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   781
                 really no change (just comment and/or category)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   782
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   783
                anyChange := false.
10
claus
parents: 5
diff changeset
   784
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   785
                oldClass setInstanceVariableString:(newClass instanceVariableString).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   786
                oldClass setClassVariableString:(newClass classVariableString).
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   787
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   788
                oldClass category ~= categoryString ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   789
                    oldClass category:categoryString. 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   790
                    changed ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   791
                        self addChangeRecordForClass:newClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   792
                    ].    
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   793
                    aSystemDictionary notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   794
                        "notify change of category"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   795
                        aSystemDictionary changed:#organization
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   796
                    ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   797
                ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   798
                "notify change of class"
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
   799
"/                oldClass changed.
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   800
                ^ oldClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   801
              ].
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   802
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   803
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   804
               when we arrive here, class variables have changed
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   805
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   806
              oldClass category ~= categoryString ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   807
                  "notify change of organization"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   808
                  oldClass category:categoryString. 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   809
                  aSystemDictionary notNil ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   810
                      "notify change of organization"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   811
                      aSystemDictionary changed:#organization
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   812
                  ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   813
              ].
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   814
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   815
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   816
               set class variable string; 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   817
               this also updates the set of class variables
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   818
               by creating new / deleting obsolete ones.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   819
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   820
              oldClass classVariableString:stringOfClassVarNames.
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   821
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   822
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   823
               get the set of changed class variables
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   824
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   825
              changeSet1 := Set new.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   826
              oldClassVars do:[:nm |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   827
                  (newClassVars includes:nm) ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   828
                      changeSet1 add:nm
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   829
                  ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   830
              ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   831
              newClassVars do:[:nm |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   832
                  (oldClassVars includes:nm) ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   833
                      changeSet1 add:nm
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   834
                  ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   835
              ].
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   836
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   837
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   838
               recompile all methods accessing set of changed classvars
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   839
               here and also in all subclasses ...
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   840
              "
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
   841
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   842
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   843
               dont update change file for the recompilation
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   844
              "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   845
              Class withoutUpdatingChangesDo:[
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   846
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   847
                  Transcript showCr:'recompiling class & inst methods accessing ' , changeSet1 printString.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   848
                  Transcript endEntry.
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   849
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   850
                  oldClass withAllSubclasses do:[:aClass |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   851
                      aClass class recompileMethodsAccessingAny:changeSet1.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   852
                      aClass recompileMethodsAccessingAny:changeSet1.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   853
                  ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   854
              ].
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   855
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   856
              "notify change of class"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   857
              changed ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   858
                  self addChangeRecordForClass:oldClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   859
              ].  
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   860
              oldClass changed:#definition.
33
50cf0f6bc0ad *** empty log message ***
claus
parents: 13
diff changeset
   861
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   862
              ^ oldClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   863
            ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   864
          ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   865
        ]
2
claus
parents: 1
diff changeset
   866
      ]
claus
parents: 1
diff changeset
   867
    ].
claus
parents: 1
diff changeset
   868
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   869
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   870
     here we enter the darkness of mordor ...
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
   871
     since instance variable layout and/or inheritance has changed.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   872
    "
2
claus
parents: 1
diff changeset
   873
    (newComment ~= oldClass comment) ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   874
        newClass comment:newComment
2
claus
parents: 1
diff changeset
   875
    ].
claus
parents: 1
diff changeset
   876
claus
parents: 1
diff changeset
   877
    superClassChange := oldClass superclass ~~ newClass superclass.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   878
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   879
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   880
     dont allow built-in classes to be modified this way
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   881
    "
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   882
    (oldClass notNil and:[oldClass isBuiltInClass and:[superClassChange]]) ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   883
        self error:'the inheritance of this class is fixed - you cannot change it'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   884
        ^ oldClass
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   885
    ].
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   886
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   887
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   888
     catch special case, where superclass changed its layout and thus
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   889
     forced redefinition of this class; 
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   890
     only log if this is not the case.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   891
    "
904
be65513cde2a dont write change records if the changed: arg is false
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   892
    changed ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   893
        (superClassChange 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   894
         and:[(oldClass superclass isNil or:[oldClass superclass name = newClass superclass name])
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   895
         and:[(oldClassVars = newClassVars) 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   896
         and:[(oldInstVars = newInstVars)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   897
         and:[newComment = oldClass comment]]]]) ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   898
            self addChangeRecordForClass:newClass.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   899
        ]
2
claus
parents: 1
diff changeset
   900
    ].
claus
parents: 1
diff changeset
   901
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   902
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   903
     care for class methods ...
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   904
    "
2
claus
parents: 1
diff changeset
   905
    changeSet1 := Set new.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   906
2
claus
parents: 1
diff changeset
   907
    classVarChange := false.
claus
parents: 1
diff changeset
   908
claus
parents: 1
diff changeset
   909
    superClassChange ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   910
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   911
         superclass changed:
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   912
         must recompile all class methods accessing ANY classvar
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   913
         (
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   914
          actually, we could be less strict and handle the case where
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   915
          both the old and the new superclass have a common ancestor,
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   916
          and both have no new classvariables in between.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   917
          This would speedup the case when a class is inserted into
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   918
          the inheritance chain.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   919
         )
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   920
        "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   921
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   922
        oldClass allClassVarNames do:[:nm | changeSet1 add:nm].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   923
        newClass allClassVarNames do:[:nm | changeSet1 add:nm].
2
claus
parents: 1
diff changeset
   924
claus
parents: 1
diff changeset
   925
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   926
        Transcript showCr:'recompiling class methods accessing any classvar'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   927
        Transcript endEntry.
2
claus
parents: 1
diff changeset
   928
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   929
        self copyInvalidatedMethodsFrom:(oldClass class) 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   930
                                    for:newMetaclass 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   931
                           accessingAny:changeSet1
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   932
                                orSuper:true.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   933
        newMetaclass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
2
claus
parents: 1
diff changeset
   934
    ] ifFalse:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   935
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   936
         same superclass, find out which classvars have changed
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   937
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   938
        classVarChange := oldClassVars ~= newClassVars.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   939
        classVarChange ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   940
            oldClassVars do:[:nm |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   941
                (newClassVars includes:nm) ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   942
                    changeSet1 add:nm
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   943
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   944
            ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   945
            newClassVars do:[:nm |
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   946
                (oldClassVars includes:nm) ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   947
                    changeSet1 add:nm
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   948
                ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   949
            ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   950
        ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   951
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   952
        classVarChange ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   953
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   954
             must recompile some class-methods
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   955
            "
2
claus
parents: 1
diff changeset
   956
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   957
            Transcript showCr:'recompiling class methods accessing ' , changeSet1 printString.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   958
            Transcript endEntry.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   959
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   960
            self copyInvalidatedMethodsFrom:(oldClass class) for:newMetaclass accessingAny:changeSet1.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   961
            newMetaclass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   962
        ] ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   963
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   964
             class methods still work
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   965
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   966
            self copyMethodsFrom:(oldClass class) for:newMetaclass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   967
        ].
2
claus
parents: 1
diff changeset
   968
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   969
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   970
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   971
     care for instance methods ...
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   972
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   973
2
claus
parents: 1
diff changeset
   974
    superClassChange ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   975
        "superclass changed,
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   976
         must recompile all methods accessing any class or instvar.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   977
         If number of instvars (i.e. the instances instSize) is the same,
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   978
         we can limit the set of recompiled instance methods to those methods,
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   979
         which refer to an instvar with a different inst-index
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   980
        "
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   981
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   982
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   983
         the changeset consists of instance variables, 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   984
         with a different position
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   985
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   986
        changeSet2 := self differentInstanceVariableOffsetsIn:oldClass and:newClass.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   987
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   988
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   989
         merge in the changed class variables
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   990
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   991
        changeSet1 do:[:nm | changeSet2 add:nm].
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
   992
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   993
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   994
        Transcript showCr:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   995
        Transcript endEntry.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   996
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   997
        self copyInvalidatedMethodsFrom:oldClass 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   998
                                    for:newClass 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
   999
                           accessingAny:changeSet2
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1000
                                orSuper:true.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1001
        newClass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  1002
2
claus
parents: 1
diff changeset
  1003
    ] ifFalse:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1004
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1005
         same inheritance ...
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1006
        "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1007
        instVarChange := oldInstVars ~= newInstVars.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1008
        instVarChange ifFalse:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1009
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1010
             same instance variables ...
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1011
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1012
            classVarChange ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1013
                "recompile all inst methods accessing changed classvars"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1014
2
claus
parents: 1
diff changeset
  1015
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1016
                Transcript showCr:'recompiling instance methods accessing ' , changeSet1 printString , ' ...'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1017
                Transcript endEntry.
2
claus
parents: 1
diff changeset
  1018
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1019
                self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet1.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1020
                newClass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1021
            ]
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1022
        ] ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1023
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1024
             dont allow built-in classes to be modified
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1025
            "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1026
            (oldClass notNil and:[oldClass isBuiltInClass and:[instVarChange]]) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1027
                self error:'the layout of this class is fixed - you cannot change it'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1028
                ^ oldClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1029
            ].
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  1030
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1031
            ((oldInstVars size == 0) 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1032
            or:[newInstVars startsWith:oldInstVars]) ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1033
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1034
                 only new inst variable(s) has/have been added - 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1035
                 old methods still work (the existing inst-indices are still valid)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1036
                "
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1037
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1038
                Transcript showCr:'copying methods ...'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1039
                Transcript endEntry.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1040
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1041
                self copyMethodsFrom:oldClass for:newClass.
2
claus
parents: 1
diff changeset
  1042
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1043
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1044
                 but: we have to recompile all methods accessing new instars
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1045
                 (it might have been a classVar/global before ...)
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1046
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1047
                addedNames := newInstVars select:[:nm | (oldInstVars includes:nm) not].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1048
                "merge in class variables"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1049
                changeSet1 do:[:nm | addedNames add:nm].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1050
2
claus
parents: 1
diff changeset
  1051
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1052
                Transcript showCr:'recompiling instance methods accessing ' , addedNames printString ,  '...'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1053
                Transcript endEntry.
2
claus
parents: 1
diff changeset
  1054
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1055
                newClass recompileMethodsAccessingAny:addedNames.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1056
            ] ifFalse:[
2
claus
parents: 1
diff changeset
  1057
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1058
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1059
                 the changeset consists of instance variables, 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1060
                 with a different position
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1061
                "
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1062
                changeSet2 := self differentInstanceVariableOffsetsIn:oldClass and:newClass.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1063
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1064
                "merge in the class variables"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1065
                changeSet1 do:[:nm | changeSet2 add:nm].
2
claus
parents: 1
diff changeset
  1066
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1067
                Transcript showCr:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1068
                Transcript endEntry.
2
claus
parents: 1
diff changeset
  1069
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1070
                self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet2.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1071
                newClass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1072
            ].
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1073
        ].
2
claus
parents: 1
diff changeset
  1074
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1075
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1076
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1077
     WOW, everything done for this class
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1078
     what about subclasses ?
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1079
    "
2
claus
parents: 1
diff changeset
  1080
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1081
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1082
     update superclass of immediate subclasses - 
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1083
     this forces recompilation (recursively) if needed
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1084
     (dont update change file for the subclass changes)
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1085
    "
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1086
    Class withoutUpdatingChangesDo:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1087
        oldClass subclassesDo:[:aClass |
2
claus
parents: 1
diff changeset
  1088
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1089
            Transcript showCr:'changing superclass of:' , aClass name.
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1090
            Transcript endEntry.
2
claus
parents: 1
diff changeset
  1091
" "
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1092
            aClass superclass:newClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1093
        ]
2
claus
parents: 1
diff changeset
  1094
    ].
claus
parents: 1
diff changeset
  1095
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1096
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1097
     change category in oldClass - so we see immediately what it is ...
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1098
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1099
    oldClass category:'obsolete'.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1100
    oldClass class category:'obsolete'.
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1101
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1102
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1103
     and make the new class globally known
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1104
    "
870
0d60b4b7962a handle nil environment
Claus Gittinger <cg@exept.de>
parents: 866
diff changeset
  1105
    aSystemDictionary notNil ifTrue:[
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1106
        aSystemDictionary at:classSymbol put:newClass.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1107
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1108
        oldClass category ~= categoryString ifTrue:[
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1109
            "notify change of organization"
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1110
            aSystemDictionary changed:#organization
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1111
        ].
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1112
    ].
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1113
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1114
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1115
     Not becoming the old class creates some update problems;
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1116
     the browsers must check carefully - a simple identity compare is
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1117
     not enough ...
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1118
     QUESTION: is this a good idea ?
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1119
    "
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1120
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1121
    newClass dependents:(oldClass dependents).
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1122
    newClass changed:#definition.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1123
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1124
    "just to make certain ... - tell dependents of oldClass, that something changed
85
claus
parents: 77
diff changeset
  1125
     (systemBrowsers will react on this, and update their views)"
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1126
    oldClass changed:#definition with:newClass.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1127
2
claus
parents: 1
diff changeset
  1128
    ObjectMemory flushCaches.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1129
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1130
    ^ newClass
723
ebc969b4678d preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents: 682
diff changeset
  1131
885
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  1132
    "Modified: 22.1.1996 / 13:17:13 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1133
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1134
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1135
new
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1136
    "create & return a new metaclass (a classes class).
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1137
     Since metaclasses only have one instance (the class),
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1138
     complain if there is already one.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1139
     You get a new class by sending #new to the returned metaclass
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1140
     (confusing - isn't it ?)"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1141
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1142
    |newClass|
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1143
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1144
    myClass notNil ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1145
	^ self error:'Each metaclass may only have one instance'.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1146
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1147
    newClass := self basicNew.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1148
    newClass setSuperclass:Object
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1149
	       selectors:(Array new:0)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1150
		 methods:(Array new:0)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1151
		instSize:0 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1152
		   flags:(Behavior flagBehavior).
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1153
    newClass setName:'someClass'.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1154
    myClass := newClass.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1155
    ^ newClass
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1156
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1157
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1158
!Metaclass methodsFor:'private'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1159
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1160
anyInvalidatedMethodsIn:aClass
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1161
    "return true, if aClass has any invalidated methods in it"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1162
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1163
    |trap trapCode trapByteCode|
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1164
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1165
    trap := Metaclass compiledMethodAt:#invalidCodeObject.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1166
    trapCode := trap code.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1167
    trapByteCode := trap byteCode.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1168
943
57641242a972 be careful with self modifying selectorArrays
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
  1169
    aClass methodArray copy do:[:aMethod |
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1170
	trapCode notNil ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1171
	    (aMethod code = trapCode) ifTrue:[^ true]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1172
	].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1173
	trapByteCode notNil ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1174
	    (aMethod byteCode == trapByteCode) ifTrue:[^ true]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1175
	]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1176
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1177
    ^ false
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1178
!
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1179
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1180
checkConventionsFor:className instVarNames:instVarNameString classVarNames:classVarNameString
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1181
    "Check for some 'considered bad-style' things, like lower case names.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1182
     NOTICE:
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1183
     I dont like the confirmers below - we need a notifying: argument, to give
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1184
     the outer codeview a chance to highlight the error.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1185
     (but thats how its defined in the book - maybe I will change it anyway).
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1186
    "
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1187
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1188
    "let user confirm, if the classname is no good"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1189
    className first isUppercase ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1190
	(self confirm:'classename ''' , className , ''' should start with an uppercase letter
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1191
(by convention only)
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1192
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1193
install anyway ?' withCRs)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1194
	    ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1195
		^ false
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1196
	    ]
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1197
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1198
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1199
    "let user confirm, if any instvarname is no good"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1200
    (instVarNameString asCollectionOfWords 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1201
    findFirst:[:word | word first isUppercase]) ~~ 0 ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1202
	(self confirm:'instance variable names should start with a lowercase letter
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1203
(by convention only)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1204
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1205
install anyway ?' withCRs)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1206
	ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1207
	    ^ false
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1208
	]
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1209
    ].
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1210
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1211
    "let user confirm, if any classvarname is no good"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1212
    (classVarNameString asCollectionOfWords 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1213
    findFirst:[:word | word first isLowercase]) ~~ 0 ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1214
	(self confirm:'class variable names should start with an uppercase letter
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1215
(by convention only)
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1216
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1217
install anyway ?' withCRs)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1218
	ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1219
	    ^ false
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1220
	].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1221
    ].
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1222
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1223
    ^ true
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1224
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1225
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1226
copyInvalidatedMethodsFrom:oldClass for:newClass
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1227
    "copy all methods from oldClass to newClass and change their code
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1228
     to a trap method reporting an error.
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1229
     This is done when a class has changed its layout or inheritance,
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1230
     before recompilation is attempted.
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1231
     This allows us to keep the source while trapping uncompilable (due to
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1232
     now undefined instvars) methods. Later compilation of these methods will show
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1233
     an error on the transcript and lead to the debugger once called."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1234
986
c3a9f590146d removed unused locals
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1235
    |trap trapCode trapByteCode oldMethod newMethod
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1236
     newSelectorArray newMethodArray
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1237
     nMethods "{ Class: SmallInteger }"|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1238
328
claus
parents: 326
diff changeset
  1239
    trap := Metaclass compiledMethodAt:#invalidCodeObject.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1240
    trapCode := trap code.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1241
    trapByteCode := trap byteCode.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1242
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1243
    newMethodArray := oldClass methodArray copy.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1244
    newSelectorArray := oldClass selectorArray copy.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1245
    newClass selectors:newSelectorArray methods:newMethodArray.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1246
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1247
    nMethods := newMethodArray size.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1248
    1 to:nMethods do:[:i |
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1249
	oldMethod := newMethodArray at:i.
251
claus
parents: 226
diff changeset
  1250
	oldMethod isWrapped ifTrue:[
claus
parents: 226
diff changeset
  1251
	    oldMethod := oldMethod originalMethod
claus
parents: 226
diff changeset
  1252
	].
claus
parents: 226
diff changeset
  1253
	newMethod := oldMethod copy.
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1254
	newMethod code:trapCode.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1255
	newMethod literals:nil.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1256
	newMethod byteCode:trapByteCode.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1257
	newMethodArray at:i put:newMethod
2
claus
parents: 1
diff changeset
  1258
    ]
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1259
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1260
    "Modified: 27.1.1996 / 17:57:48 / cg"
2
claus
parents: 1
diff changeset
  1261
!
claus
parents: 1
diff changeset
  1262
claus
parents: 1
diff changeset
  1263
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames
claus
parents: 1
diff changeset
  1264
    "copy all methods from oldClass to newClass. Those methods accessing
claus
parents: 1
diff changeset
  1265
     a variable in setOfNames will be copied as invalid method, leading to
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1266
     a trap when its executed. This is used when a class has changed its
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1267
     layout for all methods which are affected by the change."
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1268
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1269
    self copyInvalidatedMethodsFrom:oldClass 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1270
				for:newClass 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1271
		       accessingAny:setOfNames 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1272
			    orSuper:false 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1273
!
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1274
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1275
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames orSuper:superBoolean
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1276
    "copy all methods from oldClass to newClass. 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1277
     Those methods accessing a variable in setOfNames will be copied as invalid method, 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1278
     leading to a trap when its executed. If superBoolean is true, this is also done
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1279
     for methods accessing super.  This is used when a class has changed its
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1280
     layout for all methods which are affected by the change."
2
claus
parents: 1
diff changeset
  1281
251
claus
parents: 226
diff changeset
  1282
    |trap trapCode trapByteCode p source mustInvalidate
986
c3a9f590146d removed unused locals
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1283
     oldMethod newMethod newSelectorArray newMethodArray
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1284
     nMethods "{ Class: SmallInteger }"
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1285
     nNames usedVars|
2
claus
parents: 1
diff changeset
  1286
328
claus
parents: 326
diff changeset
  1287
    trap := Metaclass compiledMethodAt:#invalidCodeObject.
2
claus
parents: 1
diff changeset
  1288
    trapCode := trap code.
claus
parents: 1
diff changeset
  1289
    trapByteCode := trap byteCode.
claus
parents: 1
diff changeset
  1290
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1291
    newMethodArray := oldClass methodArray copy.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1292
    newSelectorArray := oldClass selectorArray copy.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1293
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1294
    newClass selectors:newSelectorArray methods:newMethodArray.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1295
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1296
    nNames := setOfNames size.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1297
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1298
    nMethods := newMethodArray size.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1299
    1 to:nMethods do:[:i |
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1300
	oldMethod := newMethodArray at:i.
251
claus
parents: 226
diff changeset
  1301
	oldMethod isWrapped ifTrue:[
claus
parents: 226
diff changeset
  1302
	    oldMethod := oldMethod originalMethod
claus
parents: 226
diff changeset
  1303
	].
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1304
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1305
	"before parsing (which may take some time),
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1306
	 do a string search if its only one variable,
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1307
	 we are looking for.
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1308
	 Could look for more than one variable by string compare, but then
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1309
	 parsing it right away may be faster ..."
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1310
251
claus
parents: 226
diff changeset
  1311
	source := oldMethod source.
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1312
	((nNames == 1) and:[superBoolean not]) ifTrue:[
251
claus
parents: 226
diff changeset
  1313
	    mustInvalidate := (source findString:(setOfNames first)) ~~ 0.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1314
	] ifFalse:[
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1315
	    ((nNames == 0) and:[superBoolean]) ifTrue:[
251
claus
parents: 226
diff changeset
  1316
		mustInvalidate := (source findString:'super') ~~ 0.
claus
parents: 226
diff changeset
  1317
	    ] ifFalse:[
claus
parents: 226
diff changeset
  1318
		mustInvalidate := true
claus
parents: 226
diff changeset
  1319
	    ].
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1320
	].
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1321
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1322
	mustInvalidate ifTrue:[
251
claus
parents: 226
diff changeset
  1323
	    "we have to parse it ..."
claus
parents: 226
diff changeset
  1324
	    p := Parser parseMethod:source in:newClass.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1325
	    (p isNil 
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1326
	     or:[((usedVars := p usedVars) notNil and:[usedVars includesAny:setOfNames])
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1327
	     or:[superBoolean and:[p usesSuper]]]) ifFalse:[
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1328
		mustInvalidate := false
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1329
	    ]
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1330
	].
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1331
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1332
	mustInvalidate ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1333
	    newMethod := oldMethod copy.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1334
	    newMethod code:trapCode.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1335
	    newMethod literals:nil.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1336
	    newMethod byteCode:trapByteCode
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1337
	] ifFalse:[
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1338
	    newMethod := oldMethod.
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1339
	].
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1340
	newMethodArray at:i put:newMethod
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1341
    ]
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1342
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1343
    "Modified: 27.1.1996 / 17:56:44 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1344
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1345
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1346
copyMethodsFrom:oldClass for:newClass
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1347
    "copy all methods from oldClass to newClass.
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1348
     This is used for class-methods when a class has changed, but its metaclass is 
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1349
     unaffected (i.e. classVars/inheritance have not changed) so there is no need
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1350
     to recompile the class methods."
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1351
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1352
    newClass selectors:(oldClass selectorArray copy) 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1353
	       methods:(oldClass methodArray copy)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1354
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1355
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1356
differentInstanceVariableOffsetsIn:class1 and:class2
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1357
    "return a set of instance variable names which have different
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1358
     positions in class1 and class2.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1359
     Also, variables which are only present in one class are returned.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1360
     This is used to find methods which need recompilation after a
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1361
     change in the instance variable layout."
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1362
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1363
    |offsets1 offsets2 changeSet|
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1364
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1365
    changeSet := Set new.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1366
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1367
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1368
     collect the instvar-indices in the old and new class
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1369
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1370
    offsets1 := class1 instanceVariableOffsets.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1371
    offsets2 := class2 instanceVariableOffsets.
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1372
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1373
    "
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1374
     compute the changeset as a set of instance variables, 
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1375
     which have a different position
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1376
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1377
    offsets1 keysAndValuesDo:[:varName :varIndex |
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1378
	(offsets2 includesKey:varName) ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1379
	    changeSet add:varName 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1380
	] ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1381
	    (varIndex ~~ (offsets2 at:varName)) ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1382
		changeSet add:varName 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1383
	    ]
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1384
	]
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1385
    ].
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1386
    offsets2 keysAndValuesDo:[:varName :varIndex |
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1387
	(offsets1 includesKey:varName) ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1388
	    changeSet add:varName
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1389
	] ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1390
	    (varIndex ~~ (offsets1 at:varName)) ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1391
		changeSet add:varName
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1392
	    ]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1393
	]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1394
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1395
    ^ changeSet
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1396
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1397
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1398
     View class 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1399
	differentInstanceVariableOffsetsIn:View
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1400
				       and:StandardSystemView
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1401
     View class 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1402
	differentInstanceVariableOffsetsIn:Object 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1403
				       and:Point 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1404
    "
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1405
!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1406
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1407
invalidCodeObject
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1408
    "When recompiling classes after a definition-change, all
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1409
     uncompilable methods will be bound to this method here,
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1410
     so that evaluating such an uncompilable method will trigger an error.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1411
     Can also happen when Compiler/runtime system is broken."
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1412
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1413
    self error:'invalid method - this method failed to compile when the class was changed'
1047
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1414
!
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1415
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1416
setSoleInstance:aClass 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1417
    myClass := aClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1418
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1419
    "Created: 12.12.1995 / 13:46:22 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1420
! !
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1421
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1422
!Metaclass methodsFor:'queries'!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1423
1179
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1424
isBuiltInClass
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1425
    ^ self == Metaclass class or:[self == Metaclass]
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1426
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1427
    "Created: 15.4.1996 / 17:17:34 / cg"
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1428
!
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1429
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1430
isMeta
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1431
    "return true, if the receiver is some kind of metaclass;
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1432
     true is returned here. Redefines isMeta in Object"
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1433
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1434
    ^ true
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1435
!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1436
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1437
soleInstance 
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1438
    "return my sole class."
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1439
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1440
    ^ myClass
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1441
! !
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1442
639
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1443
!Metaclass class methodsFor:'documentation'!
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1444
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1445
version
1179
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1446
    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.51 1996-04-15 15:41:28 cg Exp $'
639
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1447
! !