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