Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'ULE': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpULE',
tuple(map(self._convert_claripy_bool_ast, cond_.args)),
),
'__gt__': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpGT',
tuple(map(self._convert_claripy_bool_ast, cond_.args)),
),
try:
typevar = None
if r0.typevar is not None and isinstance(r1.data, int):
typevar = typevars.DerivedTypeVariable(r0.typevar, typevars.AddN(r1.data))
sum_ = None
if r0.data is not None and r1.data is not None:
sum_ = r0.data + r1.data
return RichR(sum_,
typevar=typevar,
type_constraints={ typevars.Subtype(r0.typevar, r1.typevar) }
)
except TypeError:
return RichR(ailment.Expr.BinaryOp(expr.idx, 'Add', [r0, r1], **expr.tags))
def _ail_handle_CmpEQ(self, expr):
op0 = self._expr(expr.operands[0])
op1 = self._expr(expr.operands[1])
if op0 is None: op0 = expr.operands[0]
if op1 is None: op1 = expr.operands[1]
return ailment.Expr.BinaryOp(expr.idx, expr.op, [op0, op1], **expr.tags)
def _ail_handle_Div(self, expr):
operand_0 = self._expr(expr.operands[0])
operand_1 = self._expr(expr.operands[1])
if isinstance(operand_1, Expr.Const) \
and isinstance(operand_0, Expr.BinaryOp) \
and operand_0.op in {'Div', 'DivMod'} \
and isinstance(operand_0.operands[1], Expr.Const):
new_const_value = operand_1.value * operand_0.operands[1].value
new_const = Expr.Const(operand_1.idx, None, new_const_value, operand_1.bits)
return Expr.BinaryOp(expr.idx, 'Div', [operand_0.operands[0], new_const], **expr.tags)
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
return Expr.BinaryOp(expr.idx, 'Div', [operand_0, operand_1], **expr.tags)
return expr
def _ail_handle_CmpLE(self, expr):
op0 = self._expr(expr.operands[0])
op1 = self._expr(expr.operands[1])
return ailment.Expr.BinaryOp(expr.idx, expr.op, [op0, op1], **expr.tags)
return Expr.Convert(expr.idx, operand_expr.from_bits, expr.to_bits, expr.is_signed,
operand_expr.operand, **expr.tags)
elif type(operand_expr) is Expr.Const:
# do the conversion right away
value = operand_expr.value
mask = (2 ** expr.to_bits) - 1
value &= mask
return Expr.Const(expr.idx, operand_expr.variable, value, expr.to_bits, **expr.tags)
elif type(operand_expr) is Expr.BinaryOp \
and operand_expr.op in {'Mul', 'Shl', 'Div', 'DivMod', 'Add', 'Sub'}:
if isinstance(operand_expr.operands[1], Expr.Const):
if isinstance(operand_expr.operands[0], Expr.Register) and \
expr.from_bits == operand_expr.operands[0].bits:
converted = Expr.Convert(expr.idx, expr.from_bits, expr.to_bits, expr.is_signed,
operand_expr.operands[0])
return Expr.BinaryOp(operand_expr.idx, operand_expr.op,
[converted, operand_expr.operands[1]], **expr.tags)
elif isinstance(operand_expr.operands[0], Expr.Convert) and \
expr.from_bits == operand_expr.operands[0].to_bits and \
expr.to_bits == operand_expr.operands[0].from_bits:
return Expr.BinaryOp(operand_expr.idx, operand_expr.op,
[operand_expr.operands[0].operand, operand_expr.operands[1]], **operand_expr.tags)
elif isinstance(operand_expr.operands[0], Expr.Convert) \
and isinstance(operand_expr.operands[1], Expr.Convert) \
and operand_expr.operands[0].from_bits == operand_expr.operands[1].from_bits:
if operand_expr.operands[0].to_bits == operand_expr.operands[1].to_bits \
and expr.from_bits == operand_expr.operands[0].to_bits \
and expr.to_bits == operand_expr.operands[1].from_bits:
return Expr.BinaryOp(operand_expr.idx, operand_expr.op,
[operand_expr.operands[0].operand, operand_expr.operands[1].operand],
**operand_expr.tags)
return Expr.BinaryOp(expr.idx, 'DivMod', [X, new_const], **expr.tags)
if isinstance(operand_1, Expr.Const):
if isinstance(operand_0, Expr.Register):
new_operand = Expr.Const(operand_1.idx, None, 2**operand_1.value, operand_1.bits)
return Expr.BinaryOp(expr.idx, 'DivMod', [operand_0, new_operand])
elif isinstance(operand_0, Expr.BinaryOp) \
and operand_0.op == 'Shr' \
and isinstance(operand_0.operands[1], Expr.Const):
new_const = Expr.Const(operand_1.idx, None,
operand_0.operands[1].value+operand_1.value, operand_1.bits)
return Expr.BinaryOp(expr.idx, 'Shr', [operand_0.operands[0], new_const], **expr.tags)
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
return Expr.BinaryOp(expr.idx, 'Shr', [operand_0, operand_1])
return expr
'__ne__': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpNE',
tuple(map(self._convert_claripy_bool_ast, cond_.args)),
),
def _ail_handle_Mul(self, expr):
operand_0 = self._expr(expr.operands[0])
operand_1 = self._expr(expr.operands[1])
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
return Expr.BinaryOp(expr.idx, 'Mul', [operand_0, operand_1], **expr.tags)
return expr