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