made a copy
[strongtalk-kjk.git] / StrongtalkSource / DeltaSideUpdate.dlt
blobee7323dfa8a41e793c7082c21b8e740daaabea93
1 Delta define: #DeltaSideUpdate as: (\r
2 (Class subclassOf: 'DeltaSideUpdateBehavior' instanceVariables: 'superclassType supportedProtocol classDecl klass mirror messages methods selfTV selfPublicTV typeOfInstances relevantTVs scope invocationCache loopMarker ')) !\r
3 \r
4 (Delta mirrorFor: #DeltaSideUpdate) revision: '$Revision: 1.3 $'!\r
5 \r
6 (Delta mirrorFor: #DeltaSideUpdate) group: 'ast'!\r
7 \r
8 (Delta mirrorFor: #DeltaSideUpdate)\r
9 comment: \r
10 'Concrete class representing a side.\r
11  (c) 1995-1997 Sun Microsystems, Inc. ALL RIGHTS RESERVED. \r
12 Use and distribution of this software is subject to the terms of the attached source license.'!\r
14 ! (Delta mirrorFor: #DeltaSideUpdate) methodsFor: 'Unclassified' !\r
17 addRelevantTypeVar: tv <TypeVar>\r
19 self relevantTypeVars add: tv.\r
20 self supportedProtocol isNil\r
21   ifFalse:[self supportedProtocol addRelevantTypeVar: tv].!\r
23 asMixinSide ^ <MixinSide>\r
25 ^self!\r
27 basicLocator\r
28         self isMetaSide\r
29                 ifTrue: [^self classDecl instanceSide basicLocator isMetaSide: true]\r
30                 ifFalse: [^DeltaBasicMixinLocator new id: self name; isMetaSide: false]!\r
32 classDecl ^ <DeltaClassUpdate>\r
33     ^classDecl!\r
35 classDecl: cd <DeltaClassUpdate > ^ <Self>\r
36     classDecl := cd!\r
38 clearCaches\r
40 self relevantTVs:  nil.!\r
42 hasMethodsLoaded ^ <Boolean>\r
44 ^methods isNil not\r
45 !\r
47 heirScope ^ <Scope>\r
48     ^self scope delta!\r
50 initialize\r
52 loopMarker := false.\r
53 super initialize.\r
54 self invocationCache: (IdentityDictionary[ObjectType, ObjectType] new).!\r
56 initializeWithin: lexicalScope <Scope>\r
58 loopMarker := false.\r
59 super initializeWith: lexicalScope.\r
60 self invocationCache: (IdentityDictionary[ObjectType, ObjectType] new).!\r
62 invocationCache ^ <Dict[ObjectType, ObjectType]>\r
64 ^invocationCache!\r
66 invocationCache: c <VarDict[ObjectType, ObjectType]>\r
68 invocationCache := c!\r
70 klass\r
72 ^klass!\r
74 klass: k\r
75 "Transcript show: 'SideUpdate>>klass'; cr."\r
76 klass := k.\r
77 self isMetaSide ifFalse:[self scope at: #Instance put: self selfTV]\r
78                          ifTrue:[\r
79                                    self selfTV isMeta: true.\r
80                                    self selfPublicTV isMeta: true.\r
81                                    self scope at: #Instance put: self selfClassTV.\r
82                                    self scope at: #PublicInstance put: self selfPublicClassTV.\r
83                                    self selfTV dual: self selfClassTV.\r
84                                    self selfClassTV dual: self selfTV.\r
85                                    self selfPublicTV dual: self selfPublicClassTV.\r
86                                    self selfPublicClassTV dual: self selfPublicTV.\r
87                                    ].\r
88 "Whatever class is linked to me, must have my type var in its scope"!\r
90 localScope ^ <Scope>\r
91     ^self heirScope delta!\r
93 lookupTypeOfInstances ^ <ObjectType>\r
95 | key <ObjectType> result   <ObjectType> |\r
97 ^loopMarker \r
98    ifFalse:[\r
99                  loopMarker := true.\r
100                  key := self superclassType asProtocol canonicalRep.\r
101                  result := self invocationCache at: key \r
102                         ifAbsent:[self invocationCache at: key\r
103                                                                   put: self typeOfInstances].\r
104                  loopMarker := false.\r
105                  result.\r
106                  ]\r
107   ifTrue:[typeOfInstances := super typeOfInstances].!\r
109 messages ^ <Dict[Symbol,Message]>\r
111 messages isNil ifTrue:[self mirror createMethodTypeStructure].\r
112     ^messages!\r
114 messages: ms<Dict[Symbol,Message]>\r
115     messages := ms!\r
117 methods ^ <Dict[Symbol,Method]>\r
119 methods isNil ifTrue:[self mirror createMethodTypeStructure].\r
120     ^methods!\r
122 methods: ms<Dict[Symbol,Method]>\r
123     methods := ms!\r
125 mirror ^ <Mirror>\r
127 mirror isNil ifTrue:[mirror :=super mirror].\r
128 ^mirror!\r
130 relevantTVs ^ <Set[TypeVar]>\r
132 ^relevantTVs!\r
134 relevantTVs: rtvs <Set[TypeVar]>\r
136 relevantTVs := rtvs!\r
138 relevantTypeVars ^ <Set[TypeVar]>\r
140 self relevantTVs isNil\r
141    ifTrue:[self relevantTVs: super relevantTypeVars].\r
142 ^self relevantTVs.!\r
144 scope ^<Scope>\r
145     ^scope!\r
147 scope: s <Scope>\r
148     scope := s!\r
150 selfPublicTV ^ <TypeVar>\r
151     ^selfPublicTV!\r
153 selfPublicTV: stv <TypeVar>\r
154     selfPublicTV := stv.\r
155     self localScope at: #PublicSelf put:  stv.!\r
157 selfTV ^ <TypeVar>\r
158     ^selfTV!\r
160 selfTV: stv <TypeVar>\r
161     selfTV := stv.\r
162     self localScope at: #Self put:  stv.!\r
164 superclassType ^ <ClassNode>\r
165     ^superclassType!\r
167 superclassType: st <ClassNode > ^ <Self>\r
168     \r
169 superclassType := st.\r
170 self heirScope  base: st heirScope.\r
171 "  (DeltaScopeReference for: st accessBlk: [:x | x heirScope])."\r
172 "self scope at: #super put: (DeltaSuperVar new name: #super type: nil)."!\r
174 supportedProtocol ^ <Protocol>\r
175     ^supportedProtocol!\r
177 supportedProtocol: p <Protocol > ^ <Self>\r
178     supportedProtocol := p.!\r
180 typeOfInstances ^ <ObjectType>\r
181 "This method returns and caches the public protocol of the side. The actual \r
182 construction of the value is handled by super's version of the\r
183 method. "\r
185     ^typeOfInstances isNil\r
186    ifTrue:[\r
187               typeOfInstances := self lookupTypeOfInstances.\r
188               ]\r
189    ifFalse:[typeOfInstances].! !\r