Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions manticore/core/smtlib/visitors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import functools

from ...utils.helpers import CacheDict
from ...exceptions import SmtlibError
from .expression import *
Expand Down Expand Up @@ -53,14 +55,21 @@ def result(self):
return self._stack[-1]

def _method(self, expression, *args):
for cls in expression.__class__.__mro__[:-1]:
for method in self._methods(expression.__class__):
value = method(expression, *args)
if value is not None:
return value
return self._rebuild(expression, args)

@functools.lru_cache(maxsize=256)
def _methods(self, ecls):
methods = []
for cls in ecls.__mro__[:-1]:
sort = cls.__name__
methodname = "visit_%s" % sort
if hasattr(self, methodname):
value = getattr(self, methodname)(expression, *args)
if value is not None:
return value
return self._rebuild(expression, args)
methods.append(getattr(self, methodname))
return tuple(methods)

def visit(self, node, use_fixed_point=False):
"""
Expand Down