author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 26 Apr 2010 19:26:38 +0100 | |
branch | jv |
changeset 17761 | b0e5971141bc |
parent 17735 | 6a5bc05f696a |
child 17767 | a4a32df3aa5e |
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. |
|
85 |
binding ifNotNil:[^binding]. |
|
86 |
||
87 |
"Next look in shared pools." |
|
88 |
self sharedPools do:[:pool | |
|
89 |
binding := pool bindingOf: aSymbol. |
|
90 |
binding ifNotNil:[^binding]. |
|
91 |
]. |
|
92 |
||
93 |
"subclassing and environment are not preserved" |
|
94 |
^nil |
|
95 |
! |
|
96 |
||
97 |
bindingsDo: aBlock |
|
98 |
self halt:'unfinished implementation'. |
|
99 |
^ self classPool bindingsDo: aBlock |
|
100 |
! |
|
101 |
||
102 |
classBindingOf: varName |
|
103 |
"For initialization messages grant the regular scope" |
|
104 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
105 |
self shouldImplement. "not yet finished" |
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
106 |
^ super bindingOf: varName |
8551 | 107 |
! |
108 |
||
109 |
includesKey:aSymbol |
|
110 |
^ self keys includes:aSymbol |
|
111 |
||
112 |
" |
|
113 |
OpenGLConstants includesKey:#GL3Bytes |
|
114 |
" |
|
115 |
! |
|
116 |
||
117 |
keys |
|
118 |
^ self classVarNames |
|
119 |
||
120 |
" |
|
121 |
OpenGLConstants keys |
|
122 |
" |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
123 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
124 |
|
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
125 |
keysDo:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
126 |
^ self keys do:aBlock |
8551 | 127 |
! ! |
128 |
||
129 |
!SharedPool class methodsFor:'printing & storing'! |
|
130 |
||
131 |
displayString |
|
132 |
"return a printed represenation - here, a reminder is appended, |
|
133 |
that this is not a regular class" |
|
134 |
||
135 |
self == SharedPool ifTrue:[ |
|
136 |
^ super displayString |
|
137 |
]. |
|
138 |
^ self name , ' (* SharedPool *)' |
|
8538 | 139 |
! ! |
140 |
||
141 |
!SharedPool class methodsFor:'queries'! |
|
142 |
||
143 |
isSharedPool |
|
144 |
^ self ~~ SharedPool |
|
145 |
! ! |
|
146 |
||
147 |
!SharedPool class methodsFor:'documentation'! |
|
148 |
||
149 |
version |
|
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
150 |
^ '$Id: SharedPool.st 10517 2010-04-26 18:26:38Z vranyj1 $' |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
151 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
152 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
153 |
version_CVS |
17735 | 154 |
^ '§Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.8 2009/10/12 19:09:14 cg Exp §' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
155 |
! |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
156 |
|
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
157 |
version_SVN |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
158 |
^ '$Id: SharedPool.st 10517 2010-04-26 18:26:38Z vranyj1 $' |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
159 |
! ! |