-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAST.py
42 lines (41 loc) · 1.13 KB
/
AST.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
class Variable(object):
def __init__(self, f, r):
self.type = ''
self.name = ''
self.init = ''
self.full = f
self.initialized = False
self.used = False
self.used_without_init = False
self.raw = r
def setInit(self,i):
self.init = i
self.initialized = True
def setUsed(self):
self.used = True
if not self.initialized:
self.used_without_init = True
def print(self):
print("t:%s n:%s i:%s f:%s" % (self.type, self.name, self.init, self.full))
def print_raw(self):
print(self.raw)
class Function(object):
def __init__(self, f, r, rh):
self.vars = []
self.full = f
self.type = ''
self.name = ''
self.used = False
self.raw = r
self.raw_head = rh
def setUsed(self):
self.used = True
def print(self):
print("t:%s n:%s" % (self.type, self.name))
for v in self.vars:
print(" ", end="")
v.print()
def print_header(self):
print(self.raw_head)
def print_raw(self):
print(self.raw)