Support operators + and += for Constraints()

pull/534/head
Nikhil Parasaram 6 years ago
parent 98288da43c
commit d0c00eef9c
  1. 2
      mythril/analysis/solver.py
  2. 16
      mythril/laser/ethereum/state.py

@ -5,7 +5,7 @@ import logging
def get_model(constraints):
constraints.solver.set("timeout", 10000)
constraints.solver.set("timeout", 100000)
result = constraints.solver.check()
if result == sat:
return constraints.solver.model()

@ -1,4 +1,4 @@
from z3 import BitVec, BitVecVal, Solver, ExprRef, sat, unsat
from z3 import BitVec, BitVecVal, Solver, unsat, unknown
from mythril.disassembler.disassembly import Disassembly
from copy import copy, deepcopy
from enum import Enum
@ -140,9 +140,9 @@ class Constraints(list):
self.solver.add(constraint)
def check_possibility(self):
if self.__possibility is None:
self.__possibility = (self.solver.check() != unsat)
return self.__possibility
if self.__possibility in (None, unknown):
self.__possibility = self.solver.check()
return self.__possibility != unsat
def append(self, constraint):
self.__possibility = None
@ -158,8 +158,7 @@ class Constraints(list):
return Constraints(constraint_list, self.solver, self.__possibility)
def __deepcopy__(self, memodict={}):
constraint_list = super(Constraints, self).copy()
return Constraints(constraint_list, self.solver, self.__possibility)
return self.__copy__()
def __add__(self, constraints):
constraints_list = super(Constraints, self).__add__(constraints)
@ -169,10 +168,7 @@ class Constraints(list):
return Constraints(constraint_list=constraints_list, solver=new_solver)
def __iadd__(self, other):
"""
Implement constraint concatenation if needed
"""
raise NotImplementedError
return self.__add__(other)
class MachineStack(list):

Loading…
Cancel
Save