10021
|
1 |
"
|
10068
|
2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
3 |
All Rights Reserved
|
10021
|
4 |
|
10068
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
10021
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
15314
|
28 |
"{ NameSpace: Smalltalk }"
|
|
29 |
|
10021
|
30 |
Magnitude subclass:#SyntaxElement
|
15467
|
31 |
instanceVariableNames:'start stop type value next prev node'
|
10021
|
32 |
classVariableNames:''
|
|
33 |
poolDictionaries:''
|
|
34 |
category:'Interface-CodeView-Syntax'
|
|
35 |
!
|
|
36 |
|
|
37 |
!SyntaxElement class methodsFor:'documentation'!
|
|
38 |
|
|
39 |
copyright
|
|
40 |
"
|
10068
|
41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
42 |
All Rights Reserved
|
|
43 |
|
|
44 |
Permission is hereby granted, free of charge, to any person
|
|
45 |
obtaining a copy of this software and associated documentation
|
|
46 |
files (the 'Software'), to deal in the Software without
|
|
47 |
restriction, including without limitation the rights to use,
|
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49 |
copies of the Software, and to permit persons to whom the
|
|
50 |
Software is furnished to do so, subject to the following
|
|
51 |
conditions:
|
10021
|
52 |
|
10068
|
53 |
The above copyright notice and this permission notice shall be
|
|
54 |
included in all copies or substantial portions of the Software.
|
|
55 |
|
|
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
63 |
OTHER DEALINGS IN THE SOFTWARE.
|
10021
|
64 |
"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!SyntaxElement class methodsFor:'instance creation'!
|
|
68 |
|
|
69 |
from: start to: stop
|
|
70 |
|
|
71 |
^self new
|
|
72 |
start: start;
|
|
73 |
stop: stop.
|
|
74 |
|
|
75 |
"Created: / 14-02-2010 / 13:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
76 |
!
|
|
77 |
|
|
78 |
from: start to: stop type: type
|
|
79 |
|
|
80 |
^self new
|
|
81 |
start: start;
|
|
82 |
stop: stop;
|
|
83 |
type: type
|
|
84 |
|
|
85 |
"Created: / 14-02-2010 / 14:09:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
86 |
!
|
|
87 |
|
|
88 |
from: start to: stop type: type value: value
|
|
89 |
|
|
90 |
^self new
|
|
91 |
start: start;
|
|
92 |
stop: stop;
|
|
93 |
type: type;
|
|
94 |
value: value
|
|
95 |
|
|
96 |
"Created: / 14-02-2010 / 17:41:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
12909
|
97 |
!
|
|
98 |
|
|
99 |
from: start to: stop type: type value: value assigned:assigned
|
|
100 |
|
|
101 |
^self new
|
|
102 |
start: start;
|
|
103 |
stop: stop;
|
|
104 |
type: type;
|
|
105 |
value: value;
|
|
106 |
assigned: assigned
|
|
107 |
|
|
108 |
"Created: / 14-02-2010 / 17:41:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10021
|
109 |
! !
|
|
110 |
|
|
111 |
!SyntaxElement methodsFor:'accessing'!
|
|
112 |
|
10632
|
113 |
firstElementInChain
|
|
114 |
|first prev|
|
|
115 |
|
|
116 |
first := self.
|
|
117 |
[ (prev := first previousElement) notNil ] whileTrue:[
|
|
118 |
first := prev.
|
|
119 |
].
|
|
120 |
^ first
|
|
121 |
|
|
122 |
"Created: / 21-08-2011 / 09:51:35 / cg"
|
|
123 |
!
|
|
124 |
|
12098
|
125 |
lastElementInChain
|
|
126 |
|last next|
|
|
127 |
|
|
128 |
last := self.
|
|
129 |
[ (next := last nextElement) notNil ] whileTrue:[
|
|
130 |
last := next.
|
|
131 |
].
|
|
132 |
^ last
|
|
133 |
!
|
|
134 |
|
10021
|
135 |
next
|
15457
|
136 |
<resource: #obsolete>
|
|
137 |
"/ please use nextElement: - this is easier to find in the browser
|
|
138 |
|
10021
|
139 |
^ next
|
|
140 |
!
|
|
141 |
|
|
142 |
next:aSyntaxElement
|
15457
|
143 |
<resource: #obsolete>
|
|
144 |
"/ please use nextElement: - this is easier to find in the browser
|
|
145 |
|
10021
|
146 |
next := aSyntaxElement.
|
15457
|
147 |
next previousElement: self.
|
10021
|
148 |
|
|
149 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
150 |
!
|
|
151 |
|
10632
|
152 |
nextElement
|
|
153 |
^ next
|
|
154 |
|
|
155 |
"Created: / 21-08-2011 / 09:47:11 / cg"
|
|
156 |
!
|
|
157 |
|
|
158 |
nextElement:aSyntaxElement
|
|
159 |
next := aSyntaxElement.
|
15457
|
160 |
next previousElement: self.
|
10632
|
161 |
|
|
162 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
163 |
"Created: / 21-08-2011 / 09:47:15 / cg"
|
|
164 |
!
|
|
165 |
|
15468
|
166 |
node
|
|
167 |
^ node
|
|
168 |
!
|
|
169 |
|
|
170 |
node:something
|
|
171 |
node := something.
|
|
172 |
!
|
|
173 |
|
10021
|
174 |
prev
|
15457
|
175 |
<resource: #obsolete>
|
|
176 |
"/ please use nextElement: - this is easier to find in the browser
|
|
177 |
|
10021
|
178 |
^ prev
|
|
179 |
!
|
|
180 |
|
|
181 |
prev:aSyntaxElement
|
15457
|
182 |
<resource: #obsolete>
|
|
183 |
"/ please use nextElement: - this is easier to find in the browser
|
|
184 |
|
10021
|
185 |
prev := aSyntaxElement.
|
|
186 |
!
|
|
187 |
|
10632
|
188 |
previousElement
|
|
189 |
^ prev
|
|
190 |
|
|
191 |
"Created: / 21-08-2011 / 09:47:23 / cg"
|
|
192 |
!
|
|
193 |
|
|
194 |
previousElement:aSyntaxElement
|
|
195 |
prev := aSyntaxElement.
|
|
196 |
|
|
197 |
"Created: / 21-08-2011 / 09:47:28 / cg"
|
|
198 |
!
|
|
199 |
|
10021
|
200 |
start
|
|
201 |
^ start
|
|
202 |
!
|
|
203 |
|
|
204 |
start:anInteger
|
|
205 |
start := anInteger.
|
|
206 |
!
|
|
207 |
|
|
208 |
stop
|
|
209 |
^ stop
|
|
210 |
!
|
|
211 |
|
|
212 |
stop:anInteger
|
|
213 |
stop := anInteger.
|
|
214 |
!
|
|
215 |
|
|
216 |
type
|
|
217 |
^ type
|
|
218 |
!
|
|
219 |
|
|
220 |
type:aSymbol
|
|
221 |
type := aSymbol.
|
|
222 |
!
|
|
223 |
|
|
224 |
value
|
|
225 |
^ value
|
|
226 |
!
|
|
227 |
|
|
228 |
value:anObject
|
|
229 |
value := anObject.
|
|
230 |
! !
|
|
231 |
|
|
232 |
!SyntaxElement methodsFor:'comparing'!
|
|
233 |
|
|
234 |
< anObject
|
|
235 |
anObject isNumber ifTrue:[^stop < anObject].
|
12909
|
236 |
"/ anObject class == self class ifFalse:[^false].
|
10021
|
237 |
|
12909
|
238 |
^stop < anObject stop
|
10021
|
239 |
|
|
240 |
"Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
241 |
"Modified (format): / 27-07-2012 / 21:53:22 / cg"
|
10021
|
242 |
!
|
|
243 |
|
|
244 |
= anObject
|
|
245 |
anObject class == self class ifFalse:[^false].
|
|
246 |
|
|
247 |
^start == (anObject start) and:
|
|
248 |
[stop == (anObject stop) and:
|
|
249 |
[type == (anObject type)]].
|
|
250 |
|
|
251 |
"Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
252 |
"Modified (format): / 27-07-2012 / 21:53:24 / cg"
|
10021
|
253 |
!
|
|
254 |
|
|
255 |
hash
|
|
256 |
^start hash bitXor:[stop hash bitXor:[type hash]].
|
|
257 |
|
|
258 |
"Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
259 |
"Modified (format): / 27-07-2012 / 21:53:28 / cg"
|
10021
|
260 |
! !
|
|
261 |
|
|
262 |
!SyntaxElement methodsFor:'double dispatching'!
|
|
263 |
|
|
264 |
lessFromInteger:anInteger
|
15314
|
265 |
^ self stop < anInteger
|
10021
|
266 |
|
|
267 |
"Created: / 14-02-2010 / 13:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
268 |
"Modified (format): / 27-07-2012 / 21:53:33 / cg"
|
10021
|
269 |
! !
|
|
270 |
|
|
271 |
!SyntaxElement methodsFor:'printing & storing'!
|
|
272 |
|
|
273 |
printOn:aStream
|
16784
|
274 |
"append a printed representation of the receiver to the argument, aStream"
|
10021
|
275 |
|
|
276 |
super printOn:aStream.
|
10632
|
277 |
aStream nextPutAll:'('.
|
10021
|
278 |
type printOn: aStream.
|
16784
|
279 |
aStream nextPutAll:' -> '.
|
10021
|
280 |
value printOn:aStream.
|
12909
|
281 |
aStream nextPut:$[.
|
|
282 |
start printOn:aStream.
|
16784
|
283 |
aStream nextPutAll:' .. '.
|
12909
|
284 |
stop printOn:aStream.
|
|
285 |
aStream nextPut:$].
|
10021
|
286 |
aStream nextPut:$).
|
|
287 |
|
|
288 |
"Modified: / 25-06-2010 / 13:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10632
|
289 |
"Modified: / 21-08-2011 / 09:33:51 / cg"
|
|
290 |
! !
|
|
291 |
|
|
292 |
!SyntaxElement methodsFor:'queries'!
|
|
293 |
|
12985
|
294 |
assigned
|
|
295 |
^ false.
|
|
296 |
!
|
|
297 |
|
15467
|
298 |
isInBlockScope:aBlockScopeOrNil
|
|
299 |
^ node notNil and:[ node block == aBlockScopeOrNil ]
|
|
300 |
!
|
|
301 |
|
|
302 |
isInSameBlockScopeAs:anotherElement
|
|
303 |
^ node notNil and:[ anotherElement isInBlockScope:node block ]
|
|
304 |
!
|
|
305 |
|
10632
|
306 |
isSelector
|
|
307 |
^ type == #selector
|
|
308 |
|
|
309 |
"Created: / 21-08-2011 / 09:09:19 / cg"
|
|
310 |
!
|
|
311 |
|
|
312 |
isSelf
|
|
313 |
^ type == #self
|
|
314 |
|
|
315 |
"Created: / 21-08-2011 / 09:31:20 / cg"
|
|
316 |
!
|
|
317 |
|
|
318 |
isVariableOrSelf
|
|
319 |
^ self isVariable or:[self isSelf]
|
|
320 |
|
|
321 |
"Created: / 21-08-2011 / 09:31:33 / cg"
|
10021
|
322 |
! !
|
|
323 |
|
15468
|
324 |
!SyntaxElement methodsFor:'testing'!
|
|
325 |
|
|
326 |
isClassVariable
|
|
327 |
^ node notNil and:[node isVariable and:[node isClassVariable]]
|
|
328 |
!
|
|
329 |
|
|
330 |
isGlobal
|
|
331 |
^ node notNil and:[ node isGlobal ]
|
|
332 |
!
|
|
333 |
|
|
334 |
isInstanceVariable
|
|
335 |
^ node notNil and:[node isVariable and:[node isInstanceVariable]]
|
|
336 |
|
|
337 |
"Created: / 01-07-2013 / 21:54:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
338 |
!
|
|
339 |
|
|
340 |
isVariable
|
|
341 |
^ node notNil and:[ node isVariable ]
|
|
342 |
|
|
343 |
"Created: / 21-08-2011 / 09:09:00 / cg"
|
|
344 |
"Modified: / 16-02-2012 / 19:24:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
345 |
! !
|
|
346 |
|
10021
|
347 |
!SyntaxElement class methodsFor:'documentation'!
|
|
348 |
|
15468
|
349 |
version
|
16784
|
350 |
^ '$Header$'
|
15468
|
351 |
!
|
|
352 |
|
10021
|
353 |
version_CVS
|
16784
|
354 |
^ '$Header$'
|
10021
|
355 |
!
|
|
356 |
|
|
357 |
version_SVN
|
16784
|
358 |
^ '$Id$'
|
10021
|
359 |
! !
|
12098
|
360 |
|