author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 10 Aug 2010 09:55:15 +0100 | |
branch | jv |
changeset 17795 | 569eec7576f1 |
parent 17780 | b6e42c92eba0 |
child 17807 | 06cc6c49e291 |
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 |
||
8538 | 60 |
!SharedPool class methodsFor:'name lookup'! |
61 |
||
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
62 |
at:name |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
63 |
"retrieve a pool variable by name" |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
64 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
65 |
^ self at:name ifAbsent:[self errorKeyNotFound:name] |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
66 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
67 |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
68 |
at:name ifAbsent:aBlock |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
69 |
"retrieve a pool variable by name" |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
70 |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
71 |
(self includesKey:name) ifFalse:[^ aBlock value]. |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
72 |
^ self classVarAt:name |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
73 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
74 |
|
8538 | 75 |
bindingOf: varName |
76 |
"Answer the binding of some variable resolved in the scope of the receiver" |
|
77 |
||
78 |
| aSymbol binding | |
|
79 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
80 |
self shouldImplement. "not yet finished" |
8538 | 81 |
aSymbol := varName asSymbol. |
82 |
||
83 |
"First look in classVar dictionary." |
|
84 |
binding := self classPool bindingOf: aSymbol. |
|
17795 | 85 |
binding notNil ifTrue:[^binding]. |
8538 | 86 |
|
87 |
"Next look in shared pools." |
|
88 |
self sharedPools do:[:pool | |
|
17795 | 89 |
binding := pool bindingOf: aSymbol. |
90 |
binding notNil ifTrue:[^binding]. |
|
8538 | 91 |
]. |
92 |
||
93 |
"subclassing and environment are not preserved" |
|
94 |
^nil |
|
17795 | 95 |
|
96 |
"Modified: / 08-08-2010 / 14:46:09 / cg" |
|
8538 | 97 |
! |
98 |
||
99 |
bindingsDo: aBlock |
|
100 |
self halt:'unfinished implementation'. |
|
101 |
^ self classPool bindingsDo: aBlock |
|
102 |
! |
|
103 |
||
104 |
classBindingOf: varName |
|
105 |
"For initialization messages grant the regular scope" |
|
106 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
107 |
self shouldImplement. "not yet finished" |
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
108 |
^ super bindingOf: varName |
8551 | 109 |
! |
110 |
||
111 |
includesKey:aSymbol |
|
112 |
^ self keys includes:aSymbol |
|
113 |
||
114 |
" |
|
115 |
OpenGLConstants includesKey:#GL3Bytes |
|
116 |
" |
|
117 |
! |
|
118 |
||
119 |
keys |
|
120 |
^ self classVarNames |
|
121 |
||
122 |
" |
|
123 |
OpenGLConstants keys |
|
124 |
" |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
125 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
126 |
|
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
127 |
keysDo:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
128 |
^ self keys do:aBlock |
8551 | 129 |
! ! |
130 |
||
131 |
!SharedPool class methodsFor:'printing & storing'! |
|
132 |
||
133 |
displayString |
|
134 |
"return a printed represenation - here, a reminder is appended, |
|
135 |
that this is not a regular class" |
|
136 |
||
137 |
self == SharedPool ifTrue:[ |
|
138 |
^ super displayString |
|
139 |
]. |
|
140 |
^ self name , ' (* SharedPool *)' |
|
8538 | 141 |
! ! |
142 |
||
143 |
!SharedPool class methodsFor:'queries'! |
|
144 |
||
145 |
isSharedPool |
|
146 |
^ self ~~ SharedPool |
|
147 |
! ! |
|
148 |
||
149 |
!SharedPool class methodsFor:'documentation'! |
|
150 |
||
151 |
version |
|
17795 | 152 |
^ '$Id: SharedPool.st 10564 2010-08-10 08:55:15Z vranyj1 $' |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
153 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
154 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
155 |
version_CVS |
17795 | 156 |
^ 'Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.9 2010/08/08 12:46:20 cg Exp ' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
157 |
! |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
158 |
|
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
159 |
version_SVN |
17795 | 160 |
^ '$Id: SharedPool.st 10564 2010-08-10 08:55:15Z vranyj1 $' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
161 |
! ! |
17767 | 162 |
|
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
163 |
|
17780 | 164 |
|
17795 | 165 |