Metaclass.st
author Claus Gittinger <cg@exept.de>
Sat, 26 Oct 1996 17:22:06 +0200
changeset 1819 e53f745ed80b
parent 1809 d5f8d427904b
child 1821 0ef23966c67b
permissions -rw-r--r--
when changing a class, do not forget to move the privateClasses with it.
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.
1671
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   404
    ].
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   405
    ObjectMemory flushCachesFor:oldClass.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   406
1671
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   407
    allSubclasses do:[:oldSubClass |
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   408
        |newSubClass|
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   409
1671
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   410
        newSubClass := oldToNew at:oldSubClass.
1733
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   411
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   412
"/        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
   413
"/                          ' as ' , newSubClass name.
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   414
1671
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   415
        (Smalltalk at:(oldSubClass name asSymbol) ifAbsent:nil) == oldSubClass ifTrue:[
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   416
            Smalltalk at:oldSubClass name asSymbol put:newSubClass.
1798
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
   417
            self checkForAliasesOf:oldSubClass with:newSubClass.
1671
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   418
        ].
cceee8a44757 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   419
        ObjectMemory flushCachesFor:oldSubClass.
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   420
    ].
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   421
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   422
    "tell dependents ..."
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   423
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   424
    oldClass changed:#definition.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   425
    self changed:#definition.
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   426
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   427
    ^ newMetaclass
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
    "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
   430
    "Modified: 7.6.1996 / 08:43:19 / stefan"
1798
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
   431
    "Modified: 22.10.1996 / 15:20:47 / cg"
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   432
! !
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   433
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   434
!Metaclass methodsFor:'copying'!
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
postCopy
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   437
    "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
   438
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
   439
    myClass := nil
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
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   442
!Metaclass methodsFor:'creating classes'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   443
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   444
name:newName in:aSystemDictionaryOrClass
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   445
             subclassOf:aClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   446
             instanceVariableNames:stringOfInstVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   447
             variable:variableBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   448
             words:wordsBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   449
             pointers:pointersBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   450
             classVariableNames:stringOfClassVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   451
             poolDictionaries:stringOfPoolNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   452
             category:categoryString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   453
             comment:commentString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   454
             changed:changed
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   455
             classInstanceVariableNames:stringOfClassInstVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   456
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   457
    "this is the main workhorse for installing new classes - special care
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   458
     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
   459
     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
   460
     recompiled.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   461
     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
   462
     to allow existing instances some life. 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   463
     This might change in the future.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   464
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   465
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   466
    |newClass newMetaclass nInstVars nameString classSymbol oldClass 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   467
     classVarChange instVarChange superClassChange newComment
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   468
     changeSet1 changeSet2 addedNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   469
     anyChange oldInstVars newInstVars oldClassVars newClassVars superFlags newFlags
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   470
     project currentProject t nClassInstVars superInstVars
1809
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   471
     realNewName thisIsPrivate oldCIVNames newCIVNames msg|
1439
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
    "NOTICE:
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   474
     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
   475
     I dont like it anymore :-) 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   476
     (well, at least, its a good test for the compilers ability 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   477
      to handle big, complex methods ;-)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   478
     take it as an example of bad coding style ...
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
     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
   481
     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
   482
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   483
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   484
    Behavior flushSubclassInfo.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   485
    project := Project. "/ have to fetch this before, in case its autoloaded
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
    newName = aClass name ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   488
        self error:'trying to create circular class definition'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   489
        ^ nil
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
1733
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   492
    (newName isSymbol not
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   493
    or:[newName size == 0]) ifTrue:[
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   494
        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
   495
        ^ nil
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   496
    ].
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   497
    newName first isLetter ifFalse:[
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   498
        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
   499
        ^ nil
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   500
    ].
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   501
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   502
    "check for invalid subclassing of UndefinedObject and SmallInteger"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   503
    aClass canBeSubclassed ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   504
        self error:('it is not possible to subclass ' , aClass name).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   505
        ^ nil
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   506
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   507
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   508
    nInstVars := stringOfInstVarNames countWords.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   509
    nameString := newName asString.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   510
    classSymbol := newName asSymbol.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   511
    newComment := commentString.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   512
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   513
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   514
    (aSystemDictionaryOrClass notNil
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   515
    and:[aSystemDictionaryOrClass isNamespace not]) ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   516
        thisIsPrivate := true.
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   517
        realNewName := (aSystemDictionaryOrClass name , '::' , classSymbol) asSymbol.
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   518
    ] ifFalse:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   519
        thisIsPrivate := false.
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   520
        realNewName := classSymbol.
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   521
    ].
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   522
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   523
    "look, if it already exists as a class"
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   524
    aSystemDictionaryOrClass notNil ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   525
        thisIsPrivate ifFalse:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   526
            oldClass := aSystemDictionaryOrClass at:classSymbol ifAbsent:[nil].
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   527
        ] ifTrue:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   528
            oldClass := aSystemDictionaryOrClass privateClassesAt:classSymbol.
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   529
        ]
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   530
    ].
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   531
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   532
    (oldClass isBehavior and:[oldClass isLoaded]) ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   533
        oldClass := nil.
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   534
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   535
        thisIsPrivate ifTrue:[
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   536
            Compiler warnSTXSpecials ifTrue:[
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   537
                (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
   538
                ifFalse:[^ self].
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   539
            ]
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   540
        ].
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   541
    ] ifTrue:[
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   542
        oldClass name ~= realNewName ifTrue:[
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   543
            (self confirm:(classSymbol , ' is an alias for ' , oldClass name , '\\continue ?') withCRs)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   544
            ifFalse:[^ self].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   545
            oldClass := nil
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   546
        ] ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   547
            "/
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   548
            "/ some consisteny checks
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   549
            "/
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   550
            oldClass superclass notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   551
                oldClass allSuperclasses do:[:cls |
1776
794f35149de7 oops - use full name when checking for circular definition
Claus Gittinger <cg@exept.de>
parents: 1757
diff changeset
   552
                    cls name = realNewName ifTrue:[
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   553
                        self error:'trying to create circular class definition'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   554
                        ^ nil
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   555
                    ]
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
            ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   558
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   559
            aClass superclass notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   560
                aClass allSuperclasses do:[:cls |
1776
794f35149de7 oops - use full name when checking for circular definition
Claus Gittinger <cg@exept.de>
parents: 1757
diff changeset
   561
                    cls name = realNewName ifTrue:[
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   562
                        self error:'trying to create circular class definition'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   563
                        ^ nil
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
            ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   567
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   568
            newComment isNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   569
                newComment := oldClass comment
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   570
            ].
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
             warn, if it exists with different category and different instvars,
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   574
             and the existing is not an autoload class.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   575
             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
   576
             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
   577
             I wanted to create a new class called ReturnNode ...).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   578
             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
   579
             implemented and classes can be put into separate packages.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   580
            "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   581
            oldClass isLoaded ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   582
                oldClass category ~= categoryString ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   583
                    oldClass instanceVariableString asCollectionOfWords 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   584
                    ~= stringOfInstVarNames asCollectionOfWords ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   585
                        (self confirm:'a class named ' , oldClass name , 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   586
                                      ' already exists -\\create (i.e. change) anyway ?' withCRs)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   587
                        ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   588
                            ^ nil
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   589
                        ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   590
                    ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   591
                ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   592
            ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   593
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   594
            "/
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   595
            "/ hints - warn, if creating a variableSubclass of a Set
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   596
            "/ (common error - containers in ST/X do not use variable-slots)
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
            ((variableBoolean == true) and:[pointersBoolean]) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   599
                (oldClass isKindOf:Set class) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   600
                    (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
   601
                    ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   602
                        ^ nil
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   603
                    ]
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
            ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   606
        ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   607
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   608
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   609
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   610
     Check for some 'considered bad-style' things, like lower case names.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   611
     But only do these checks for new classes - 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   612
     - thus, once confirmed, the warnings will not come again and again.
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
     NOTICE:
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   615
     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
   616
     the outer codeview a chance to highlight the error.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   617
     (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
   618
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   619
    oldClass isNil ifTrue:[
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   620
        (self 
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   621
            checkConventionsFor:newName
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   622
            subClassOf:aClass
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   623
            instVarNames:stringOfInstVarNames 
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   624
            classVarNames:stringOfClassVarNames) 
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   625
        ifFalse:[
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   626
            ^ nil
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   627
        ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   628
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   629
1698
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   630
    aClass notNil ifTrue:[
1809
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   631
        "
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   632
         check for instVar redef of superClass instVars
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   633
        "
1698
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   634
        superInstVars := aClass allInstVarNames.
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   635
        stringOfInstVarNames asCollectionOfWords do:[:nm |
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   636
            (superInstVars includes:nm) ifTrue:[
1809
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   637
                (oldClass notNil 
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   638
                and:[stringOfInstVarNames = oldClass instanceVariableString])
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   639
                ifTrue:[
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   640
                    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
   641
                    self warn:msg withCRs.
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   642
                ] ifFalse:[
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   643
                    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
   644
                    (self confirm:msg withCRs) ifFalse:[
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   645
                        ^ nil.
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   646
                    ]
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   647
                ].
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   648
            ]
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   649
        ].
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   650
    ].
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   651
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   652
    oldClass notNil ifTrue:[
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
         check for instVar redefs in subclass instVars
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
        oldClass allSubclassesDo:[:sub |
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   657
            |vars|
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
            vars := sub instVarNames.
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   660
            stringOfInstVarNames asCollectionOfWords do:[:nm |
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   661
                (vars includes:nm) ifTrue:[
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   662
                    (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
   663
                    ifFalse:[
d5f8d427904b more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents: 1798
diff changeset
   664
                        ^ nil.
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
                ]
1698
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   667
            ]
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   668
        ]
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   669
    ].
0aaf983588b8 catch instvar redefinitions
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   670
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   671
    nClassInstVars := stringOfClassInstVarNames countWords.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   672
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   673
    "create the metaclass first"
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   674
    thisIsPrivate ifTrue:[
1733
2cc88c50db99 check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   675
        newMetaclass := PrivateMetaclass new
1725
eaa45019ad44 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
   676
    ] ifFalse:[
eaa45019ad44 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
   677
        newMetaclass := Metaclass new.
eaa45019ad44 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
   678
    ].
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   679
    newMetaclass setSuperclass:(aClass class).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   680
    newMetaclass instSize:(aClass class instSize + nClassInstVars).
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   681
    newMetaclass classVariableString:''.
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   682
    newMetaclass setInstanceVariableString:stringOfClassInstVarNames.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   683
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   684
    "then let the new meta create the class"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   685
    newClass := newMetaclass new.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   686
    newClass setSuperclass:aClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   687
    newClass instSize:(aClass instSize + nInstVars).
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   688
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   689
    thisIsPrivate ifTrue:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   690
        "/ some private class
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   691
        newMetaclass setOwningClass:aSystemDictionaryOrClass.
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   692
        newClass setName:(aSystemDictionaryOrClass name , '::' , classSymbol) asSymbol.
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   693
    ] ifFalse:[
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   694
        newClass setName:classSymbol.
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   695
    ].
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   696
    newClass setComment:newComment category:categoryString.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   697
1778
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   698
    oldClass notNil ifTrue:[
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   699
        "/ copy over classInstanceVariables
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   700
        "/ 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
   701
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   702
        oldCIVNames := oldClass class allInstVarNames asSet.
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   703
        newCIVNames := newClass class allInstVarNames asSet.
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   704
        Class class allInstVarNames do:[:n |
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   705
             oldCIVNames remove:n ifAbsent:nil.
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   706
             newCIVNames remove:n ifAbsent:nil.
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   707
        ].
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
        newCIVNames size > 0 ifTrue:[
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   710
            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
   711
            newCIVNames do:[:n |
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   712
                (oldCIVNames includes:n) ifTrue:[
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   713
                    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
   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
        ].
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   717
    ].
fd558245c662 preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
   718
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   719
    "/ set the new classes package
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   720
    "/ but prefer the old package
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   721
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   722
    oldClass notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   723
        t := oldClass package.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   724
        newClass setBinaryRevision:(oldClass binaryRevision).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   725
    ] ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   726
        project notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   727
            currentProject := project current.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   728
            currentProject notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   729
                t := currentProject packageName.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   730
            ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   731
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   732
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   733
    t notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   734
        newMetaclass package:t.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   735
        newClass package:t.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   736
    ].
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
     Allowing non-booleans as variableBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   740
     is a hack for backward (ST-80) compatibility:
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   741
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   742
     ST-80 code will pass true or false as variableBoolean,
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   743
     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
   744
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   745
    (variableBoolean == true) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   746
        pointersBoolean ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   747
            newFlags := Behavior flagPointers
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   748
        ] ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   749
            wordsBoolean ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   750
                newFlags := Behavior flagWords
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   751
            ] ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   752
                newFlags := Behavior flagBytes
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   753
            ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   754
        ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   755
    ] ifFalse:[
1655
fb6ee1b55ec4 use *-categories
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
   756
        "/ false or symbol.
fb6ee1b55ec4 use *-categories
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
   757
        newFlags := Behavior flagForSymbolic:variableBoolean.
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   758
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   759
    superFlags := aClass flags bitAnd:(Behavior maskIndexType bitInvert). "preserve other bits"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   760
    oldClass notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   761
        oldClass isBuiltInClass ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   762
            "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   763
             special care when redefining Method, Block and other built-in classes,
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   764
             which might have other flag bits ...
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
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   767
            newFlags := newFlags bitOr:(oldClass flags bitAnd:(Behavior maskIndexType bitInvert))
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   768
        ]
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
    newClass flags:(newFlags bitOr:superFlags). "preserve  inherited special bits"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   771
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   772
    (nInstVars ~~ 0) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   773
        newClass setInstanceVariableString:stringOfInstVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   774
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   775
    oldClass notNil ifTrue:[
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
         setting first will make new class clear obsolete classvars
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
        newClass setClassVariableString:(oldClass classVariableString).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   780
        (t := oldClass primitiveSpec) notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   781
            newClass primitiveSpec:t.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   782
            newClass setClassFilename:(oldClass classFilename).
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
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   785
    newClass classVariableString:stringOfClassVarNames.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   786
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   787
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   788
     for new classes, we are almost done here
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   789
     (also for autoloaded classes)
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
    (oldClass isNil or:[oldClass isLoaded not]) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   792
        (oldClass isNil and:[changed]) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   793
            self addChangeRecordForClass:newClass.
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
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   796
        commentString notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   797
            newClass comment:commentString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   798
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   799
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   800
        aSystemDictionaryOrClass notNil ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   801
            thisIsPrivate ifTrue:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   802
                aSystemDictionaryOrClass privateClassesAt:classSymbol put:newClass.
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   803
            ] ifFalse:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   804
                aSystemDictionaryOrClass at:classSymbol put:newClass.
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   805
            ]
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   806
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   807
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   808
        oldClass isNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   809
            project notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   810
                currentProject := project current.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   811
                currentProject notNil ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   812
                    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   813
                     new classes get the package assigned
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
                    newClass package:(currentProject packageName asSymbol)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   816
                ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   817
            ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   818
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   819
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   820
        aSystemDictionaryOrClass notNil ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   821
            thisIsPrivate ifTrue:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   822
                aSystemDictionaryOrClass changed.
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   823
            ] ifFalse:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   824
                aSystemDictionaryOrClass changed:#newClass with:newClass.
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   825
            ]
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   826
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   827
        ^ newClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   828
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   829
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   830
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   831
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   832
     here comes the hard part - we are actually changing the
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   833
     definition of an existing class ....
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   834
     Try hard to get away WITHOUT recompiling, since it makes all
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   835
     compiled code into interpreted ...
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
    oldInstVars := oldClass instanceVariableString asCollectionOfWords.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   839
    newInstVars := newClass instanceVariableString asCollectionOfWords.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   840
    oldClassVars := oldClass classVariableString asCollectionOfWords.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   841
    newClassVars := newClass classVariableString asCollectionOfWords.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   842
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
     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
   845
     inheritance do not change.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   846
     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
   847
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   848
    (oldClass superclass == newClass superclass) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   849
      (oldClass instSize == newClass instSize) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   850
        (oldClass flags == newClass flags) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   851
          (oldClass name = newClass name) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   852
            (oldInstVars = newInstVars) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   853
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   854
              (newComment ~= oldClass comment) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   855
                  oldClass setComment:newComment.        "writes a change-chunk"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   856
                  oldClass changed:#comment with:oldClass comment.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   857
                  changed ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   858
                      self addChangeRecordForClassComment:oldClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   859
                  ]
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
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   862
              (oldClassVars = newClassVars) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   863
                "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   864
                 really no change (just comment and/or category)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   865
                "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   866
                anyChange := false.
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
                oldClass setInstanceVariableString:(newClass instanceVariableString).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   869
                oldClass setClassVariableString:(newClass classVariableString).
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
                oldClass category ~= categoryString ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   872
                    oldClass category:categoryString. 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   873
                    changed ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   874
                        self addChangeRecordForClass:newClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   875
                    ].    
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   876
                    aSystemDictionaryOrClass notNil ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   877
                        thisIsPrivate ifFalse:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   878
                            "notify change of category"
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   879
                            aSystemDictionaryOrClass changed:#organization
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   880
                        ]
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   881
                    ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   882
                ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   883
                "notify change of class"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   884
"/                oldClass changed.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   885
                ^ oldClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   886
              ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   887
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
               when we arrive here, class variables have changed
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   890
              "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   891
              oldClass category ~= categoryString ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   892
                  "notify change of organization"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   893
                  oldClass category:categoryString. 
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   894
                  aSystemDictionaryOrClass notNil ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
   895
                       thisIsPrivate ifFalse:[ 
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   896
                          "notify change of organization"
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   897
                          aSystemDictionaryOrClass changed:#organization
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
   898
                        ]
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   899
                  ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   900
              ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   901
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   902
              "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   903
               set class variable string; 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   904
               this also updates the set of class variables
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   905
               by creating new / deleting obsolete ones.
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
              oldClass classVariableString:stringOfClassVarNames.
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
               get the set of changed class variables
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   911
              "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   912
              changeSet1 := Set new.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   913
              oldClassVars do:[:nm |
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   914
                  (newClassVars includes:nm) ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   915
                      changeSet1 add:nm
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
              ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   918
              newClassVars do:[:nm |
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   919
                  (oldClassVars includes:nm) ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   920
                      changeSet1 add:nm
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   921
                  ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   922
              ].
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
               recompile all methods accessing set of changed classvars
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   926
               here and also in all subclasses ...
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   927
              "
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
               dont update change file for the recompilation
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
              Class withoutUpdatingChangesDo:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   933
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   934
                  Transcript showCR:'recompiling class & inst methods accessing ' , changeSet1 printString.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   935
                  Transcript endEntry.
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
                  oldClass withAllSubclasses do:[:aClass |
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   938
                      aClass class recompileMethodsAccessingAny:changeSet1.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   939
                      aClass recompileMethodsAccessingAny:changeSet1.
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
              ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   942
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   943
              "notify change of class"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   944
              changed ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   945
                  self addChangeRecordForClass:oldClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   946
              ].  
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   947
              oldClass changed:#definition.
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
              ^ oldClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   950
            ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   951
          ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   952
        ]
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
    ].
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
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   957
     here we enter the darkness of mordor ...
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   958
     since instance variable layout and/or inheritance has changed.
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
    (newComment ~= oldClass comment) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   961
        newClass comment:newComment
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
    superClassChange := oldClass superclass ~~ newClass superclass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   965
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
     dont allow built-in classes to be modified this way
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   968
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   969
    (oldClass notNil and:[oldClass isBuiltInClass and:[superClassChange]]) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   970
        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
   971
        ^ oldClass
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
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   975
     catch special case, where superclass changed its layout and thus
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   976
     forced redefinition of this class; 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   977
     only log if this is not the case.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   978
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   979
    changed ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   980
        (superClassChange 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   981
         and:[(oldClass superclass isNil or:[oldClass superclass name = newClass superclass name])
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   982
         and:[(oldClassVars = newClassVars) 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   983
         and:[(oldInstVars = newInstVars)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   984
         and:[newComment = oldClass comment]]]]) ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   985
            self addChangeRecordForClass:newClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   986
        ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   987
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   988
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   989
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   990
     care for class methods ...
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   991
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   992
    changeSet1 := Set new.
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
    classVarChange := false.
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
    superClassChange ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   997
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   998
         superclass changed:
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
   999
         must recompile all class methods accessing ANY classvar
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
          actually, we could be less strict and handle the case where
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1002
          both the old and the new superclass have a common ancestor,
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1003
          and both have no new classvariables in between.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1004
          This would speedup the case when a class is inserted into
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1005
          the inheritance chain.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1006
         )
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
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1009
        oldClass allClassVarNames do:[:nm | changeSet1 add:nm].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1010
        newClass allClassVarNames do:[:nm | changeSet1 add:nm].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1011
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1012
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1013
        Transcript showCR:'recompiling class methods accessing any classvar'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1014
        Transcript endEntry.
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
        self copyInvalidatedMethodsFrom:(oldClass class) 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1017
                                    for:newMetaclass 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1018
                           accessingAny:changeSet1
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1019
                                orSuper:true.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1020
        newMetaclass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1021
    ] ifFalse:[
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
         same superclass, find out which classvars have changed
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1024
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1025
        classVarChange := oldClassVars ~= newClassVars.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1026
        classVarChange ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1027
            oldClassVars do:[:nm |
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1028
                (newClassVars includes:nm) ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1029
                    changeSet1 add:nm
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1030
                ]
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
            newClassVars do:[:nm |
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1033
                (oldClassVars includes:nm) ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1034
                    changeSet1 add:nm
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1035
                ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1036
            ].
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
        classVarChange ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1040
            "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1041
             must recompile some class-methods
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
            Transcript showCR:'recompiling class methods accessing ' , changeSet1 printString.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1045
            Transcript endEntry.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1046
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1047
            self copyInvalidatedMethodsFrom:(oldClass class) for:newMetaclass accessingAny:changeSet1.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1048
            newMetaclass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1049
        ] ifFalse:[
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
             class methods still work
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1052
            "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1053
            self copyMethodsFrom:(oldClass class) for:newMetaclass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1054
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1055
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1056
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
     care for instance methods ...
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
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1061
    superClassChange ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1062
        "superclass changed,
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1063
         must recompile all methods accessing any class or instvar.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1064
         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
  1065
         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
  1066
         which refer to an instvar with a different inst-index
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
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1069
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1070
         the changeset consists of instance variables, 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1071
         with a different position
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1072
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1073
        changeSet2 := self differentInstanceVariableOffsetsIn:oldClass and:newClass.
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
         merge in the changed class variables
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1077
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1078
        changeSet1 do:[:nm | changeSet2 add:nm].
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
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1081
        Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1082
        Transcript endEntry.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1083
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1084
        self copyInvalidatedMethodsFrom:oldClass 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1085
                                    for:newClass 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1086
                           accessingAny:changeSet2
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1087
                                orSuper:true.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1088
        newClass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1089
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1090
    ] ifFalse:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1091
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1092
         same inheritance ...
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1093
        "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1094
        instVarChange := oldInstVars ~= newInstVars.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1095
        instVarChange ifFalse:[
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
             same instance variables ...
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
            classVarChange ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1100
                "recompile all inst methods accessing changed classvars"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1101
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1102
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1103
                Transcript showCR:'recompiling instance methods accessing ' , changeSet1 printString , ' ...'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1104
                Transcript endEntry.
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
                self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet1.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1107
                newClass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
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
        ] ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1110
            "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1111
             dont allow built-in classes to be modified
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
            (oldClass notNil and:[oldClass isBuiltInClass and:[instVarChange]]) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1114
                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
  1115
                ^ oldClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1116
            ].
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
            ((oldInstVars size == 0) 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1119
            or:[newInstVars startsWith:oldInstVars]) ifTrue:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1120
                "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1121
                 only new inst variable(s) has/have been added - 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1122
                 old methods still work (the existing inst-indices are still valid)
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
                Transcript showCR:'copying methods ...'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1126
                Transcript endEntry.
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
                self copyMethodsFrom:oldClass for:newClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1129
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
                 but: we have to recompile all methods accessing new instars
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1132
                 (it might have been a classVar/global before ...)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1133
                "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1134
                addedNames := newInstVars select:[:nm | (oldInstVars includes:nm) not].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1135
                "merge in class variables"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1136
                changeSet1 do:[:nm | addedNames add:nm].
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
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1139
                Transcript showCR:'recompiling instance methods accessing ' , addedNames printString ,  '...'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1140
                Transcript endEntry.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1141
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1142
                newClass recompileMethodsAccessingAny:addedNames.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1143
            ] ifFalse:[
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
                 the changeset consists of instance variables, 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1147
                 with a different position
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
                changeSet2 := self differentInstanceVariableOffsetsIn:oldClass and:newClass.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1150
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1151
                "merge in the class variables"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1152
                changeSet1 do:[:nm | changeSet2 add:nm].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1153
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1154
                Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1155
                Transcript endEntry.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1156
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1157
                self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet2.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1158
                newClass recompileInvalidatedMethods:(Metaclass compiledMethodAt:#invalidCodeObject).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1159
            ].
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
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1162
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
     WOW, everything done for this class
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1165
     what about subclasses ?
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
     update superclass of immediate subclasses - 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1170
     this forces recompilation (recursively) if needed
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1171
     (dont update change file for the subclass changes)
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1172
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1173
    Class withoutUpdatingChangesDo:[
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1174
        oldClass subclassesDo:[:aClass |
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
            Transcript showCR:'changing superclass of:' , aClass name.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1177
            Transcript endEntry.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1178
" "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1179
            aClass superclass:newClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1180
        ]
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1181
    ].
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
    "
1819
e53f745ed80b when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
  1184
     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
  1185
    "
e53f745ed80b when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
  1186
    oldClass privateClassesDo:[:aClass |
e53f745ed80b when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
  1187
        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
  1188
    ].
e53f745ed80b when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
  1189
e53f745ed80b when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
  1190
    "
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1191
     change category in oldClass - so we see immediately what it is ...
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1192
    "
1655
fb6ee1b55ec4 use *-categories
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  1193
    oldClass category:#'* obsolete *'.
fb6ee1b55ec4 use *-categories
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  1194
    oldClass class category:#'* obsolete *'.
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1195
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1196
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1197
     and make the new class globally known
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1198
    "
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1199
    aSystemDictionaryOrClass notNil ifTrue:[
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1200
        thisIsPrivate ifTrue:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1201
            aSystemDictionaryOrClass privateClassesAt:classSymbol put:newClass.
1749
c146bb48d03b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1202
        ] ifFalse:[
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1203
            aSystemDictionaryOrClass at:classSymbol put:newClass.
1798
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1204
            aSystemDictionaryOrClass == Smalltalk ifTrue:[
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1205
                self checkForAliasesOf:oldClass with:newClass.
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1206
            ].
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1207
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1208
            oldClass category ~= categoryString ifTrue:[
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1209
                "notify change of organization"
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1210
                aSystemDictionaryOrClass changed:#organization
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1211
            ]
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1212
        ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1213
    ].
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1214
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1215
    "
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1216
     Not becoming the old class creates some update problems;
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1217
     the browsers must check carefully - a simple identity compare is
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1218
     not enough ...
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1219
     QUESTION: is this a good idea ?
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
    newClass dependents:(oldClass dependents).
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1223
    newClass changed:#definition.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1224
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1225
    "just to make certain ... - tell dependents of oldClass, that something changed
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1226
     (systemBrowsers will react on this, and update their views)"
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1227
    oldClass changed:#definition with:newClass.
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
    ObjectMemory flushCaches.
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1230
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1231
    ^ newClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1232
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1233
    "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
  1234
    "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
  1235
    "Modified: 26.10.1996 / 16:20:46 / cg"
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1236
!
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1237
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1238
name:newName inEnvironment:aSystemDictionary
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1239
             subclassOf:aClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1240
             instanceVariableNames:stringOfInstVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1241
             variable:variableBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1242
             words:wordsBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1243
             pointers:pointersBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1244
             classVariableNames:stringOfClassVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1245
             poolDictionaries:stringOfPoolNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1246
             category:categoryString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1247
             comment:commentString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1248
             changed:changed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1249
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
  1250
    ^ self
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1251
        name:newName 
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1252
        in:aSystemDictionary
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1253
        subclassOf:aClass
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1254
        instanceVariableNames:stringOfInstVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1255
        variable:variableBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1256
        words:wordsBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1257
        pointers:pointersBoolean
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1258
        classVariableNames:stringOfClassVarNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1259
        poolDictionaries:stringOfPoolNames
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1260
        category:categoryString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1261
        comment:commentString
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1262
        changed:changed
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1263
        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
  1264
1439
d8a58d20a93c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1416
diff changeset
  1265
    "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
  1266
!
ca805f0f4984 changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  1267
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1268
new
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1269
    "create & return a new metaclass (a classes class).
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1270
     Since metaclasses only have one instance (the class),
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1271
     complain if there is already one.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1272
     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
  1273
     (confusing - isn't it ?)"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1274
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1275
    |newClass|
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1276
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1277
    myClass notNil ifTrue:[
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1278
        ^ self error:'Each metaclass may only have one instance'.
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1279
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1280
    newClass := self basicNew.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1281
    newClass setSuperclass:Object
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1282
          methodDictionary:MethodDictionary new
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1283
                instSize:0 
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1284
                   flags:(Behavior flagBehavior).
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1285
    newClass setName:'someClass'.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1286
    myClass := newClass.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1287
    ^ newClass
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1288
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1289
    "Modified: 7.6.1996 / 15:39:11 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1290
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1291
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1292
!Metaclass methodsFor:'private'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1293
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1294
anyInvalidatedMethodsIn:aClass
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1295
    "return true, if aClass has any invalidated methods in it"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1296
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1297
    |trap trapCode trapByteCode|
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1298
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1299
    trap := Metaclass compiledMethodAt:#invalidCodeObject.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1300
    trapCode := trap code.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1301
    trapByteCode := trap byteCode.
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1302
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1303
    aClass methodDictionary do:[:aMethod |
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1304
        trapCode notNil ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1305
            (aMethod code = trapCode) ifTrue:[^ true]
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1306
        ].
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1307
        trapByteCode notNil ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1308
            (aMethod byteCode == trapByteCode) ifTrue:[^ true]
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1309
        ]
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1310
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1311
    ^ false
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1312
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1313
    "Modified: 7.6.1996 / 09:15:40 / stefan"
68
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1314
!
59faa75185ba *** empty log message ***
claus
parents: 49
diff changeset
  1315
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1316
checkConventionsFor:className subClassOf:aClass instVarNames:instVarNameString classVarNames:classVarNameString
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1317
    "Check for some 'considered bad-style' things, like lower case names.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1318
     NOTICE:
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1319
     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
  1320
     the outer codeview a chance to highlight the error.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1321
     (but thats how its defined in the book - maybe I will change it anyway).
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1322
    "
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1323
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1324
    |superClassInstVarNames|
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1325
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1326
"/    superClassInstVarNames := aClass allInstVarNames asSet.
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1327
"/
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1328
"/    "check for instVar redefs - this is not good"
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1329
"/    instVarNameString asCollectionOfWords do:[:anInstVarName |
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1330
"/        (superClassInstVarNames includes:anInstVarName) ifTrue:[
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1331
"/            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
  1332
"/            ^ false
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1333
"/        ]
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
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1336
    "let user confirm, if the classname is no good"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1337
    className first isUppercase ifFalse:[
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1338
        (self confirm:'classename ''' , className , ''' should start with an uppercase letter
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1339
(by convention only)
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1340
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1341
install anyway ?' withCRs)
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1342
            ifFalse:[
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1343
                ^ false
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1344
            ]
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1345
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1346
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1347
    "let user confirm, if any instvarname is no good"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1348
    (instVarNameString asCollectionOfWords 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1349
    findFirst:[:word | word first isUppercase]) ~~ 0 ifTrue:[
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1350
        (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
  1351
(by convention only)
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
install anyway ?' withCRs)
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1354
        ifFalse:[
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1355
            ^ false
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1356
        ]
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1357
    ].
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1358
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1359
    "let user confirm, if any classvarname is no good"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1360
    (classVarNameString asCollectionOfWords 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1361
    findFirst:[:word | word first isLowercase]) ~~ 0 ifTrue:[
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1362
        (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
  1363
(by convention only)
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
install anyway ?' withCRs)
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1366
        ifFalse:[
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1367
            ^ false
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1368
        ].
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1369
    ].
308
f04744ef7b5d *** empty log message ***
claus
parents: 251
diff changeset
  1370
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1371
    ^ true
1752
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1372
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1373
    "Created: 15.10.1996 / 11:56:38 / cg"
1ef6932982a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
  1374
    "Modified: 15.10.1996 / 12:00:30 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1375
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1376
1798
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1377
checkForAliasesOf:oldClass with:newClass
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1378
    "oldClass changed its identity (now use newClass).
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1379
     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
  1380
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1381
    Smalltalk keysAndValuesDo:[:nm :o |
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1382
        o == oldClass ifTrue:[
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1383
            nm ~~ oldClass name ifTrue:[
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1384
                (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
  1385
                ifTrue:[
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1386
                    Smalltalk at:nm put:newClass
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
            ]
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1389
        ]
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1390
    ].
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1391
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1392
    "Created: 22.10.1996 / 15:20:59 / cg"
543f1601bbeb look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents: 1778
diff changeset
  1393
    "Modified: 22.10.1996 / 15:25:50 / cg"
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
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1396
copyInvalidatedMethodsFrom:oldClass for:newClass
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1397
    "copy all methods from oldClass to newClass and change their code
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1398
     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
  1399
     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
  1400
     before recompilation is attempted.
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1401
     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
  1402
     now undefined instvars) methods. Later compilation of these methods will show
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1403
     an error on the transcript and lead to the debugger once called."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1404
986
c3a9f590146d removed unused locals
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1405
    |trap trapCode trapByteCode oldMethod newMethod
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1406
     oldDict newDict|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1407
328
claus
parents: 326
diff changeset
  1408
    trap := Metaclass compiledMethodAt:#invalidCodeObject.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1409
    trapCode := trap code.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1410
    trapByteCode := trap byteCode.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1411
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1412
    oldDict := oldClass methodDictionary.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1413
    newDict := MethodDictionary new:oldDict size.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1414
    oldDict keysAndValuesDo:[ :sel :mthd |
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1415
        mthd isWrapped ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1416
            oldMethod := mthd originalMethod
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1417
        ] ifFalse:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1418
            oldMethod := mthd.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1419
        ].
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1420
        newMethod := oldMethod copy.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1421
        newMethod code:trapCode.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1422
        newMethod literals:nil.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1423
        newMethod byteCode:trapByteCode.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1424
        newDict at:sel put:newMethod
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1425
    ].
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
    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
  1428
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1429
    "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
  1430
    "Modified: 12.6.1996 / 10:44:27 / stefan"
2
claus
parents: 1
diff changeset
  1431
!
claus
parents: 1
diff changeset
  1432
claus
parents: 1
diff changeset
  1433
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames
claus
parents: 1
diff changeset
  1434
    "copy all methods from oldClass to newClass. Those methods accessing
claus
parents: 1
diff changeset
  1435
     a variable in setOfNames will be copied as invalid method, leading to
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1436
     a trap when its executed. This is used when a class has changed its
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1437
     layout for all methods which are affected by the change."
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1438
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1439
    self copyInvalidatedMethodsFrom:oldClass 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1440
				for:newClass 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1441
		       accessingAny:setOfNames 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1442
			    orSuper:false 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1443
!
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1444
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1445
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames orSuper:superBoolean
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1446
    "copy all methods from oldClass to newClass. 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1447
     Those methods accessing a variable in setOfNames will be copied as invalid method, 
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1448
     leading to a trap when its executed. If superBoolean is true, this is also done
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1449
     for methods accessing super.  This is used when a class has changed its
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
  1450
     layout for all methods which are affected by the change."
2
claus
parents: 1
diff changeset
  1451
251
claus
parents: 226
diff changeset
  1452
    |trap trapCode trapByteCode p source mustInvalidate
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1453
     oldMethod newMethod methodDict newMethodDict nNames usedVars|
2
claus
parents: 1
diff changeset
  1454
328
claus
parents: 326
diff changeset
  1455
    trap := Metaclass compiledMethodAt:#invalidCodeObject.
2
claus
parents: 1
diff changeset
  1456
    trapCode := trap code.
claus
parents: 1
diff changeset
  1457
    trapByteCode := trap byteCode.
claus
parents: 1
diff changeset
  1458
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1459
    methodDict := oldClass methodDictionary.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1460
    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
  1461
    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
  1462
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1463
    methodDict keysAndValuesDo:[:selector :method |
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1464
        method isWrapped ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1465
            oldMethod := method originalMethod
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1466
        ] ifFalse:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1467
            oldMethod := method
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1468
        ].
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1469
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1470
        "before parsing (which may take some time),
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1471
         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
  1472
         we are looking for.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1473
         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
  1474
         parsing it right away may be faster ..."
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1475
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1476
        source := oldMethod source.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1477
        ((nNames == 1) and:[superBoolean not]) ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1478
            mustInvalidate := (source findString:(setOfNames first)) ~~ 0.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1479
        ] ifFalse:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1480
            ((nNames == 0) and:[superBoolean]) ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1481
                mustInvalidate := (source findString:'super') ~~ 0.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1482
            ] ifFalse:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1483
                mustInvalidate := true
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1484
            ].
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1485
        ].
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1486
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1487
        mustInvalidate ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1488
            "we have to parse it ..."
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1489
            p := Parser parseMethod:source in:newClass.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1490
            (p isNil 
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1491
             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
  1492
             or:[superBoolean and:[p usesSuper]]]) ifFalse:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1493
                mustInvalidate := false
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1494
            ]
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1495
        ].
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 195
diff changeset
  1496
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1497
        mustInvalidate ifTrue:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1498
            newMethod := oldMethod copy.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1499
            newMethod code:trapCode.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1500
            newMethod literals:nil.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1501
            newMethod byteCode:trapByteCode
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1502
        ] ifFalse:[
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1503
            newMethod := oldMethod.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1504
        ].
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1505
        newMethodDict at:selector put:newMethod
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1506
    ].
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1507
    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
  1508
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1509
    "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
  1510
    "Modified: 7.6.1996 / 08:33:52 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1511
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1512
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1513
copyMethodsFrom:oldClass for:newClass
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1514
    "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
  1515
     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
  1516
     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
  1517
     to recompile the class methods."
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1518
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1519
    newClass methodDictionary:(oldClass methodDictionary copy).
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1520
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1442
diff changeset
  1521
    "Modified: 7.6.1996 / 08:34:43 / stefan"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1522
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1523
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1524
differentInstanceVariableOffsetsIn:class1 and:class2
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1525
    "return a set of instance variable names which have different
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1526
     positions in class1 and class2.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1527
     Also, variables which are only present in one class are returned.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1528
     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
  1529
     change in the instance variable layout."
621
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
    |offsets1 offsets2 changeSet|
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1532
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1533
    changeSet := Set new.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1534
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1535
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1536
     collect the instvar-indices in the old and new class
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 := class1 instanceVariableOffsets.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1539
    offsets2 := class2 instanceVariableOffsets.
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1540
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1541
    "
912
a009f25a6800 be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1542
     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
  1543
     which have a different position
621
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 keysAndValuesDo:[:varName :varIndex |
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1546
	(offsets2 includesKey:varName) ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1547
	    changeSet add:varName 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1548
	] ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1549
	    (varIndex ~~ (offsets2 at:varName)) ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1550
		changeSet add:varName 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1551
	    ]
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1552
	]
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1553
    ].
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1554
    offsets2 keysAndValuesDo:[:varName :varIndex |
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1555
	(offsets1 includesKey:varName) ifFalse:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1556
	    changeSet add:varName
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1557
	] ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1558
	    (varIndex ~~ (offsets1 at:varName)) ifTrue:[
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1559
		changeSet add:varName
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1560
	    ]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1561
	]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1562
    ].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1563
    ^ changeSet
195
515af3696a5c *** empty log message ***
claus
parents: 175
diff changeset
  1564
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1565
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1566
     View class 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1567
	differentInstanceVariableOffsetsIn:View
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1568
				       and:StandardSystemView
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1569
     View class 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1570
	differentInstanceVariableOffsetsIn:Object 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1571
				       and:Point 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1572
    "
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1573
!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1574
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1575
invalidCodeObject
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1576
    "When recompiling classes after a definition-change, all
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1577
     uncompilable methods will be bound to this method here,
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1578
     so that evaluating such an uncompilable method will trigger an error.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1579
     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
  1580
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1581
    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
  1582
!
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1583
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1584
setSoleInstance:aClass 
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1585
    myClass := aClass
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1586
5d4d1c7411ab dont clobber the binaryRevision from a nonBinary-one
ca
parents: 986
diff changeset
  1587
    "Created: 12.12.1995 / 13:46:22 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1588
! !
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1589
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1590
!Metaclass methodsFor:'queries'!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1591
1179
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1592
isBuiltInClass
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1593
    "return true if this class is known by the run-time-system.
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1594
     Here, true is returned for myself, false for subclasses."
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1595
1179
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1596
    ^ self == Metaclass class or:[self == Metaclass]
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1597
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1598
    "Created: 15.4.1996 / 17:17:34 / cg"
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1599
    "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
  1600
!
3e0f32177af4 allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1601
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1602
isMeta
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1603
    "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
  1604
     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
  1605
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1606
    ^ true
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1607
!
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1608
1724
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1609
owningClass
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1610
    "return nil here - regular metaclasses are never private"
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1611
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1612
    ^ nil
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1613
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1614
    "Created: 12.10.1996 / 20:12:16 / cg"
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1615
!
ef3f680996db support for private classes
Claus Gittinger <cg@exept.de>
parents: 1698
diff changeset
  1616
1757
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1617
package
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1618
    "return my package-id"
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1619
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1620
    ^ myClass package
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1621
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1622
    "Created: 15.10.1996 / 19:44:51 / cg"
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1623
!
c153e56cbcad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
  1624
457
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1625
soleInstance 
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1626
    "return my sole class."
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1627
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1628
    ^ myClass
41c73cbee305 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 423
diff changeset
  1629
! !
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
  1630
1742
e1ee359969f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1631
!Metaclass class methodsFor:'documentation'!
639
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1632
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1633
version
1819
e53f745ed80b when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
  1634
    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.77 1996-10-26 15:22:06 cg Exp $'
639
9ff94fa31be6 version at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1635
! !