1
2
3 """BAP BIL Python representation"""
4
5 from .adt import *
6
7
8 -class Exp(ADT) : pass
10 "Load(mem,idx,endian,size)"
11 @property
12 - def mem(self) : return self.arg[0]
13 @property
14 - def idx(self) : return self.arg[1]
15 @property
16 - def endian(self): return self.arg[2]
17 @property
18 - def size(self): return self.arg[3]
19
22 "Store(mem,idx,val,endian,size)"
23 @property
24 - def mem(self) : return self.arg[0]
25 @property
26 - def idx(self) : return self.arg[1]
27 @property
28 - def value(self): return self.arg[2]
29 @property
30 - def endian(self): return self.arg[3]
31 @property
32 - def size(self): return self.arg[4]
33
35 "Abstract base for all binary operators"
36 @property
37 - def lhs(self): return self.arg[0]
38 @property
39 - def rhs(self): return self.arg[1]
40
41 -class UnOp(Exp) : pass
42
44 "Var(name,type)"
45 @property
46 - def name(self): return self.arg[0]
47 @property
48 - def type(self): return self.arg[1]
49
51 "Int(int,size)"
52 @property
53 - def value(self): return self.arg[0]
54 @property
56 "word size in bits"
57 return self.arg[1]
58
60 "Abstract base for all cast operations"
61 @property
62 - def size(self): return self.arg[0]
63 @property
64 - def expr(self): return self.arg[1]
65
67 "Let(var,val,expr)"
68 @property
69 - def var(self): return self.arg[0]
70 @property
71 - def value(self): return self.arg[1]
72 @property
73 - def expr(self): return self.arg[2]
74
76 "Unknown(string,type)"
77 @property
78 - def desc(self): return self.arg[0]
79 @property
80 - def type(self): return self.arg[1]
81
83 "Ite (cond,if_true,if_false)"
84 @property
85 - def cond(self): return self.arg[0]
86 @property
87 - def true(self): return self.arg[1]
88 @property
89 - def false(self): return self.arg[2]
90
92 "Extract(hb,lb, exp)"
93 @property
95 @property
97 @property
99
101 @property
102 - def lhs(self): return self.arg[0]
103 @property
104 - def rhs(self): return self.arg[1]
105
106 -class Stmt(ADT) : pass
107
109 "Move(var,exp)"
110 @property
111 - def var(self): return self.arg[0]
112 @property
113 - def expr(self): return self.arg[1]
114
115 -class Jmp(Stmt) : pass
118 "While (cond, stmts)"
119 @property
120 - def cond(self): return self.arg[0]
121
122 @property
123 - def stmts(self): return self.arg[1]
124
126 "If(cond, yes-exprs, no-exprs)"
127 @property
128 - def cond(self): return self.arg[0]
129 @property
130 - def true(self): return self.arg[1]
131 @property
132 - def false(self): return self.arg[2]
133
135
136
137 -class PLUS (BinOp) : pass
138 -class MINUS (BinOp) : pass
139 -class TIMES (BinOp) : pass
142 -class MOD (BinOp) : pass
143 -class SMOD (BinOp) : pass
147 -class AND (BinOp) : pass
148 -class OR (BinOp) : pass
149 -class XOR (BinOp) : pass
150 -class EQ (BinOp) : pass
151 -class NEQ (BinOp) : pass
152 -class LT (BinOp) : pass
153 -class LE (BinOp) : pass
154 -class SLT (BinOp) : pass
155 -class SLE (BinOp) : pass
156
157
158 -class NEG (UnOp) : pass
159 -class NOT (UnOp) : pass
160
164 -class HIGH(Cast) : pass
165 -class LOW(Cast) : pass
166
171
172 -class Type(ADT) : pass
174 "Imm(size) - immediate value"
175 @property
176 - def size(self): return self.arg
177
179 "Mem(addr_size, value_size)"
180 @property
182
183 @property
185
188