Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Functions
miasm2.expression.stp Namespace Reference

Functions

def ExprInt_strcst
 
def ExprId_strcst
 
def genop
 
def genop_nosize
 
def ExprOp_strcst
 
def ExprSlice_strcst
 
def ExprCond_strcst
 

Function Documentation

def miasm2.expression.stp.ExprCond_strcst (   self)

Definition at line 57 of file stp.py.

57 
58 def ExprCond_strcst(self):
59  cond = self.cond.strcst()
60  src1 = self.src1.strcst()
61  src2 = self.src2.strcst()
62  return "(IF %s=(%s) THEN %s ELSE %s ENDIF)" % (
63  "0bin%s" % ('0' * self.cond.size), cond, src2, src1)
64 
65 ExprInt.strcst = ExprInt_strcst
66 ExprId.strcst = ExprId_strcst
67 ExprOp.strcst = ExprOp_strcst
68 ExprCond.strcst = ExprCond_strcst
69 ExprSlice.strcst = ExprSlice_strcst
def ExprCond_strcst
Definition: stp.py:57
def miasm2.expression.stp.ExprId_strcst (   self)

Definition at line 17 of file stp.py.

17 
18 def ExprId_strcst(self):
19  return self.name
20 
def miasm2.expression.stp.ExprInt_strcst (   self)

Definition at line 10 of file stp.py.

10 
11 def ExprInt_strcst(self):
12  b = bin(int(self.arg))[2::][::-1]
13  b += "0" * self.size
14  b = b[:self.size][::-1]
15  return "0bin" + b
16 
def ExprInt_strcst
Definition: stp.py:10
def miasm2.expression.stp.ExprOp_strcst (   self)

Definition at line 29 of file stp.py.

29 
30 def ExprOp_strcst(self):
31  op = self.op
32  op_dct = {"|": " | ",
33  "&": " & "}
34  if op in op_dct:
35  return '(' + op_dct[op].join([x.strcst() for x in self.args]) + ')'
36  op_dct = {"-": "BVUMINUS"}
37  if op in op_dct:
38  return op_dct[op] + '(' + self.args[0].strcst() + ')'
39  op_dct = {"^": ("BVXOR", genop_nosize),
40  "+": ("BVPLUS", genop)}
41  if not op in op_dct:
42  raise ValueError('implement op', op)
43  op, f = op_dct[op]
44  args = [x.strcst() for x in self.args][::-1]
45  a = args.pop()
46  b = args.pop()
47  size = self.args[0].size
48  out = f(op, size, a, b)
49  while args:
50  out = f(op, size, out, args.pop())
51  return out
52 
def miasm2.expression.stp.ExprSlice_strcst (   self)

Definition at line 53 of file stp.py.

53 
54 def ExprSlice_strcst(self):
55  return '(' + self.arg.strcst() + ')[%d:%d]' % (self.stop - 1, self.start)
56 
def ExprSlice_strcst
Definition: stp.py:53
def miasm2.expression.stp.genop (   op,
  size,
  a,
  b 
)

Definition at line 21 of file stp.py.

21 
22 def genop(op, size, a, b):
23  return op + '(' + str(size) + ',' + a + ', ' + b + ')'
24 
def miasm2.expression.stp.genop_nosize (   op,
  size,
  a,
  b 
)

Definition at line 25 of file stp.py.

25 
26 def genop_nosize(op, size, a, b):
27  return op + '(' + a + ', ' + b + ')'
28