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