author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 08 Jun 2011 22:53:07 +0100 | |
branch | jv |
changeset 17841 | 7abcc4aef871 |
parent 17834 | 04ff72c5039a |
child 17845 | 7e0cfaac936d |
permissions | -rw-r--r-- |
8728 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
8538 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
14 |
Object subclass:#SharedPool |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Kernel-Classes' |
|
19 |
! |
|
20 |
||
21 |
!SharedPool class methodsFor:'documentation'! |
|
22 |
||
8728 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
8538 | 37 |
documentation |
38 |
" |
|
39 |
A shared pool represents a set of bindings which are accessible to all classes |
|
40 |
which import the pool in its 'pool dictionaries'. |
|
41 |
SharedPool is NOT a dictionary but rather a name space. |
|
42 |
Bindings are represented by 'class variables' - as long as we have no better way to represent |
|
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
43 |
them at least. This is done to make stc happy (or at least, to not be forced to adapt it |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
44 |
to any new semantics). |
8538 | 45 |
" |
46 |
! ! |
|
47 |
||
9091 | 48 |
!SharedPool class methodsFor:'Compatibility-V''Age'! |
49 |
||
50 |
declareConstant:constantName value:value |
|
51 |
self == SharedPool ifTrue:[ self error ]. |
|
52 |
||
53 |
(self classVarNames includes:constantName) ifFalse:[ |
|
54 |
self addClassVarName:constantName |
|
55 |
]. |
|
56 |
||
57 |
self classVarAt:constantName put:value. |
|
58 |
! ! |
|
59 |
||
17815 | 60 |
!SharedPool class methodsFor:'code generation'! |
61 |
||
62 |
initializeFrom:aDictionary |
|
63 |
"given a dictionary, generate my classvars and the init code" |
|
64 |
||
65 |
|sortedNames code| |
|
66 |
||
67 |
sortedNames := aDictionary keys asSortedCollection. |
|
68 |
self addClassVarNames:sortedNames. |
|
69 |
||
70 |
code := String streamContents:[:s | |
|
71 |
s nextPutLine:'initialize'. |
|
72 |
sortedNames do:[:k | |
|
73 |
|v| |
|
74 |
||
75 |
v := aDictionary at:k. |
|
76 |
s nextPutLine:(' %1 := %2.' bindWith:k with:v storeString). |
|
77 |
]. |
|
78 |
]. |
|
79 |
self class compile:code classified:'initialization' |
|
80 |
||
81 |
" |
|
82 |
OLEStatusCodeConstants initializeFrom:aDictionary |
|
83 |
" |
|
84 |
||
85 |
"Created: / 21-12-2010 / 17:58:25 / cg" |
|
86 |
"Modified: / 15-01-2011 / 14:20:58 / cg" |
|
87 |
! ! |
|
88 |
||
89 |
||
17807 | 90 |
!SharedPool class methodsFor:'misc ui support'! |
91 |
||
92 |
iconInBrowserSymbol |
|
93 |
<resource: #programImage> |
|
94 |
||
95 |
self == SharedPool ifTrue:[^ super iconInBrowserSymbol]. |
|
96 |
^ #sharedPoolBrowserIcon |
|
97 |
||
98 |
"Created: / 14-10-2010 / 12:04:32 / cg" |
|
99 |
! ! |
|
100 |
||
8538 | 101 |
!SharedPool class methodsFor:'name lookup'! |
102 |
||
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
103 |
at:name |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
104 |
"retrieve a pool variable by name" |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
105 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
106 |
^ self at:name ifAbsent:[self errorKeyNotFound:name] |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
107 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
108 |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
109 |
at:name ifAbsent:aBlock |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
110 |
"retrieve a pool variable by name" |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
111 |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
112 |
(self includesKey:name) ifFalse:[^ aBlock value]. |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
113 |
^ self classVarAt:name |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
114 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
115 |
|
8538 | 116 |
bindingOf: varName |
117 |
"Answer the binding of some variable resolved in the scope of the receiver" |
|
118 |
||
119 |
| aSymbol binding | |
|
120 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
121 |
self shouldImplement. "not yet finished" |
8538 | 122 |
aSymbol := varName asSymbol. |
123 |
||
124 |
"First look in classVar dictionary." |
|
125 |
binding := self classPool bindingOf: aSymbol. |
|
17795 | 126 |
binding notNil ifTrue:[^binding]. |
8538 | 127 |
|
128 |
"Next look in shared pools." |
|
129 |
self sharedPools do:[:pool | |
|
17795 | 130 |
binding := pool bindingOf: aSymbol. |
131 |
binding notNil ifTrue:[^binding]. |
|
8538 | 132 |
]. |
133 |
||
134 |
"subclassing and environment are not preserved" |
|
135 |
^nil |
|
17795 | 136 |
|
137 |
"Modified: / 08-08-2010 / 14:46:09 / cg" |
|
8538 | 138 |
! |
139 |
||
140 |
bindingsDo: aBlock |
|
141 |
self halt:'unfinished implementation'. |
|
142 |
^ self classPool bindingsDo: aBlock |
|
143 |
! |
|
144 |
||
145 |
classBindingOf: varName |
|
146 |
"For initialization messages grant the regular scope" |
|
147 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
148 |
self shouldImplement. "not yet finished" |
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
149 |
^ super bindingOf: varName |
8551 | 150 |
! |
151 |
||
152 |
includesKey:aSymbol |
|
153 |
^ self keys includes:aSymbol |
|
154 |
||
155 |
" |
|
156 |
OpenGLConstants includesKey:#GL3Bytes |
|
157 |
" |
|
158 |
! |
|
159 |
||
160 |
keys |
|
161 |
^ self classVarNames |
|
162 |
||
163 |
" |
|
164 |
OpenGLConstants keys |
|
165 |
" |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
166 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
167 |
|
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
168 |
keysDo:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
169 |
^ self keys do:aBlock |
8551 | 170 |
! ! |
171 |
||
172 |
!SharedPool class methodsFor:'printing & storing'! |
|
173 |
||
174 |
displayString |
|
175 |
"return a printed represenation - here, a reminder is appended, |
|
176 |
that this is not a regular class" |
|
177 |
||
178 |
self == SharedPool ifTrue:[ |
|
179 |
^ super displayString |
|
180 |
]. |
|
181 |
^ self name , ' (* SharedPool *)' |
|
8538 | 182 |
! ! |
183 |
||
184 |
!SharedPool class methodsFor:'queries'! |
|
185 |
||
186 |
isSharedPool |
|
187 |
^ self ~~ SharedPool |
|
188 |
! ! |
|
189 |
||
190 |
!SharedPool class methodsFor:'documentation'! |
|
191 |
||
192 |
version |
|
17841 | 193 |
^ '$Id: SharedPool.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
194 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
195 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
196 |
version_CVS |
17841 | 197 |
^ 'Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.15 2011/01/15 13:21:03 cg Exp ' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
198 |
! |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
199 |
|
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
200 |
version_SVN |
17841 | 201 |
^ '$Id: SharedPool.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
202 |
! ! |
17767 | 203 |
|
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
204 |
|
17780 | 205 |
|
17795 | 206 |
|
17807 | 207 |
|
17814 | 208 |
|
17815 | 209 |
|
17834 | 210 |
|
17841 | 211 |