-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointers_visitor.py
128 lines (83 loc) · 3.25 KB
/
pointers_visitor.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from visitors import Visitor
class Keys:
POINTER = "p"
class PointersVisitor(Visitor):
def __init__(self, ast):
super(PointersVisitor, self).__init__(ast)
self.super = super(PointersVisitor, self)
self._pointers = dict()
@property
def pointers(self):
return self._pointers
def visit_Assign(self, node):
value = self.super.visit_Assign(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_While(self, node):
value = self.super.visit_While(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Break(self, node):
value = self.super.visit_Break(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Compare(self, node):
value = self.super.visit_Compare(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Load(self, node):
value = self.super.visit_Load(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Name(self, node):
value = self.super.visit_Name(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Add(self, node):
value = self.super.visit_Add(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Store(self, node):
value = self.super.visit_Store(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Module(self, node):
value = self.super.visit_Module(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Expr(self, node):
value = self.super.visit_Expr(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_If(self, node):
value = self.super.visit_If(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Lt(self, node):
value = self.super.visit_Lt(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Constant(self, node):
value = self.super.visit_Constant(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_NotEq(self, node):
value = self.super.visit_NotEq(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_BinOp(self, node):
value = self.super.visit_BinOp(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Call(self, node):
value = self.super.visit_Call(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Eq(self, node):
value = self.super.visit_Eq(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node
def visit_Gt(self, node):
value = self.super.visit_Gt(node)
node[Keys.POINTER] = id(node)
self._pointers[node[Keys.POINTER]] = node