author | Claus Gittinger <cg@exept.de> |
Fri, 27 Feb 2015 21:23:08 +0100 | |
changeset 15459 | 3b21c401a9b2 |
parent 15315 | caa632247421 |
child 15469 | a9f1c22fc39c |
permissions | -rw-r--r-- |
15459 | 1 |
"{ Encoding: utf8 }" |
2 |
||
13864 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
14 |
"{ Package: 'stx:libtool' }" |
|
15 |
||
15171 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
13864 | 18 |
SortedCollection subclass:#ParseTreeIndex |
14192 | 19 |
instanceVariableNames:'tree source' |
13864 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-CodeView-Syntax' |
|
23 |
! |
|
24 |
||
15315
caa632247421
class: ParseTreeIndex::Element
Stefan Vogel <sv@exept.de>
parents:
15171
diff
changeset
|
25 |
SyntaxElement subclass:#Element |
caa632247421
class: ParseTreeIndex::Element
Stefan Vogel <sv@exept.de>
parents:
15171
diff
changeset
|
26 |
instanceVariableNames:'node' |
13864 | 27 |
classVariableNames:'' |
28 |
poolDictionaries:'' |
|
29 |
privateIn:ParseTreeIndex |
|
30 |
! |
|
31 |
||
32 |
!ParseTreeIndex class methodsFor:'documentation'! |
|
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
48 |
documentation |
|
49 |
" |
|
50 |
For given parse tree, a ParseTreeIndex provides an |
|
51 |
fast access to individual (leave) nodes by keeping |
|
52 |
an index. Used by CodeView2 for various queries |
|
53 |
||
54 |
Experimental |
|
55 |
||
56 |
[author:] |
|
57 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
58 |
||
59 |
[instance variables:] |
|
60 |
||
61 |
[class variables:] |
|
62 |
||
63 |
[see also:] |
|
64 |
||
65 |
" |
|
66 |
! ! |
|
67 |
||
68 |
!ParseTreeIndex methodsFor:'accessing'! |
|
69 |
||
14192 | 70 |
source |
71 |
^ source |
|
72 |
! |
|
73 |
||
74 |
source:something |
|
75 |
source := something. |
|
76 |
! |
|
77 |
||
13864 | 78 |
tree |
79 |
^ tree |
|
80 |
! |
|
81 |
||
82 |
tree:aParseNode |
|
83 |
tree := aParseNode. |
|
84 |
! ! |
|
85 |
||
86 |
!ParseTreeIndex methodsFor:'utilities'! |
|
87 |
||
88 |
newElementFor: aParseNode |
|
89 |
||
90 |
^(Element new node: aParseNode) |
|
91 |
||
92 |
"Created: / 16-02-2012 / 21:00:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
93 |
! ! |
|
94 |
||
95 |
!ParseTreeIndex::Element class methodsFor:'documentation'! |
|
96 |
||
97 |
copyright |
|
98 |
" |
|
99 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
|
100 |
All Rights Reserved |
|
101 |
||
102 |
Permission is hereby granted, free of charge, to any person |
|
103 |
obtaining a copy of this software and associated documentation |
|
104 |
files (the 'Software'), to deal in the Software without |
|
105 |
restriction, including without limitation the rights to use, |
|
106 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
107 |
copies of the Software, and to permit persons to whom the |
|
108 |
Software is furnished to do so, subject to the following |
|
109 |
conditions: |
|
110 |
||
111 |
The above copyright notice and this permission notice shall be |
|
112 |
included in all copies or substantial portions of the Software. |
|
113 |
||
114 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
115 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
116 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
117 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
118 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
119 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
120 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
121 |
OTHER DEALINGS IN THE SOFTWARE. |
|
122 |
" |
|
123 |
! ! |
|
124 |
||
125 |
!ParseTreeIndex::Element methodsFor:'accessing'! |
|
126 |
||
127 |
assigned |
|
14055
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
128 |
| p | |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
129 |
|
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
130 |
^ node isVariableNode |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
131 |
and:[(p := node parent) notNil |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
132 |
and:[p isAssignment |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
133 |
and:[p variable == node]]]. |
13864 | 134 |
|
135 |
"Created: / 01-07-2013 / 21:53:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14055
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
136 |
"Modified: / 25-02-2014 / 20:52:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13864 | 137 |
! |
138 |
||
139 |
name |
|
140 |
^node isVariable ifTrue:[node name] ifFalse:[nil] |
|
141 |
||
142 |
"Created: / 01-07-2013 / 21:56:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
143 |
! |
|
144 |
||
145 |
node |
|
146 |
^ node |
|
147 |
! |
|
148 |
||
149 |
node:something |
|
150 |
node := something. |
|
151 |
! |
|
152 |
||
153 |
start |
|
154 |
^ node startPosition |
|
155 |
||
156 |
"Modified: / 16-02-2012 / 20:56:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
157 |
! |
|
158 |
||
159 |
stop |
|
160 |
^ node endPosition |
|
161 |
||
162 |
"Modified: / 16-02-2012 / 20:56:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14507 | 163 |
! |
164 |
||
165 |
value |
|
166 |
^node name |
|
13864 | 167 |
! ! |
168 |
||
169 |
!ParseTreeIndex::Element methodsFor:'comparing'! |
|
170 |
||
171 |
< anObject |
|
172 |
||
173 |
anObject isNumber ifTrue:[^self stop < anObject]. |
|
174 |
anObject class == self class ifFalse:[^false]. |
|
175 |
||
176 |
^self stop < anObject start |
|
177 |
||
178 |
"Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
179 |
! |
|
180 |
||
181 |
= anObject |
|
182 |
||
183 |
anObject class == self class ifFalse:[^false]. |
|
184 |
||
185 |
^self start == (anObject start) and: |
|
186 |
[self stop == (anObject stop) and: |
|
187 |
[self node class == (anObject node class)]]. |
|
188 |
||
189 |
"Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
190 |
! |
|
191 |
||
192 |
hash |
|
193 |
||
194 |
^self start hash bitXor:[self stop hash bitXor:[node class hash]]. |
|
195 |
||
196 |
"Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
197 |
! ! |
|
198 |
||
199 |
!ParseTreeIndex::Element methodsFor:'printing & storing'! |
|
200 |
||
201 |
printOn:aStream |
|
202 |
"append a printed representation if the receiver to the argument, aStream" |
|
203 |
||
204 |
super printOn:aStream. |
|
205 |
aStream nextPutAll:'('. |
|
206 |
node class name printOn: aStream. |
|
207 |
aStream nextPut:$). |
|
208 |
||
209 |
"Modified: / 21-08-2011 / 09:33:51 / cg" |
|
210 |
"Modified: / 16-02-2012 / 19:23:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
211 |
! ! |
|
212 |
||
15459 | 213 |
!ParseTreeIndex::Element methodsFor:'queries'! |
214 |
||
215 |
isInBlockScope:aBlockScopeOrNil |
|
216 |
^ node block == aBlockScopeOrNil |
|
217 |
! |
|
218 |
||
219 |
isInSameBlockScopeAs:anotherElement |
|
220 |
^ anotherElement isInBlockScope:node block |
|
221 |
! ! |
|
222 |
||
13864 | 223 |
!ParseTreeIndex::Element methodsFor:'testing'! |
224 |
||
15171 | 225 |
isClassVariable |
226 |
^node isVariable and:[node isClassVariable] |
|
227 |
! |
|
228 |
||
13940 | 229 |
isGlobal |
230 |
^ node isGlobal |
|
231 |
! |
|
232 |
||
13864 | 233 |
isInstanceVariable |
15171 | 234 |
^node isVariable and:[node isInstanceVariable] |
13864 | 235 |
|
236 |
"Created: / 01-07-2013 / 21:54:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
237 |
! |
|
238 |
||
239 |
isSelector |
|
240 |
^ node class == SelectorNode |
|
241 |
||
242 |
"Created: / 21-08-2011 / 09:09:19 / cg" |
|
243 |
"Modified: / 16-02-2012 / 21:04:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
244 |
! |
|
245 |
||
246 |
isSelf |
|
247 |
^ node isSelf |
|
248 |
||
249 |
"Created: / 21-08-2011 / 09:31:20 / cg" |
|
250 |
"Modified: / 16-02-2012 / 19:25:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
251 |
! |
|
252 |
||
253 |
isVariable |
|
254 |
^ node isVariable |
|
255 |
||
256 |
"Created: / 21-08-2011 / 09:09:00 / cg" |
|
257 |
"Modified: / 16-02-2012 / 19:24:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
258 |
! ! |
|
259 |
||
260 |
!ParseTreeIndex class methodsFor:'documentation'! |
|
261 |
||
262 |
version |
|
15459 | 263 |
^ '$Header: /cvs/stx/stx/libtool/ParseTreeIndex.st,v 1.8 2015-02-27 20:23:08 cg Exp $' |
13864 | 264 |
! |
265 |
||
266 |
version_CVS |
|
15459 | 267 |
^ '$Header: /cvs/stx/stx/libtool/ParseTreeIndex.st,v 1.8 2015-02-27 20:23:08 cg Exp $' |
13864 | 268 |
! ! |
269 |