forked from bonzini/gst-visualgst
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWorkspaceVariableTracker.st
57 lines (40 loc) · 1.26 KB
/
WorkspaceVariableTracker.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
STInST.STInST.RBProgramNodeVisitor subclass: WorkspaceVariableTracker [
| keyword class |
initialize [
<category: 'initialization'>
keyword := #('self' 'super' 'true' 'false' 'nil' 'thisContext') asSet.
class := (Behavior new)
superclass: Object;
yourself
]
objectClass [
<category: 'accessing'>
^ class
]
includesVariable: aString [
<category: 'operation'>
^ aString first isUppercase or: [ (keyword includes: aString) or: [ class allInstVarNames includes: aString asSymbol ] ]
]
defineVariable: aString [
<category: 'operation'>
class addInstVarName: aString
]
removeVariable: aString [
<category: 'operation'>
class removeInstVarName: aString
]
checkAndAdd: aString [
<category: 'operation'>
(self includesVariable: aString)
ifFalse: [ self defineVariable: aString ].
]
acceptAssignmentNode: anRBAssignmentNode [
<category: 'operation'>
self checkAndAdd: anRBAssignmentNode variable name.
self visitNode: anRBAssignmentNode value
]
acceptVariableNode: anRBVariableNode [
<category: 'operation'>
self checkAndAdd: anRBVariableNode name
]
]