Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specialized iterative serialization for Array #1756

Merged
merged 2 commits into from
Jun 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 22 additions & 2 deletions manticore/core/smtlib/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,27 @@ def index(self):
def value(self):
return self.operands[2]

def __getstate__(self):
state = {}
array = self
items = []
while isinstance(array, ArrayStore):
items.append((array.index, array.value))
array = array.array
state["_array"] = array
state["_items"] = items
return state

def __setstate__(self, state):
array = state["_array"]
for index, value in reversed(state["_items"][0:]):
array = array.store(index, value)
self._index_bits = array.index_bits
self._index_max = array.index_max
self._value_bits = array.value_bits
index, value = state["_items"][0]
self._operands = (array, index, value)


class ArraySlice(ArrayOperation):
def __init__(
Expand Down Expand Up @@ -1126,15 +1147,14 @@ def __getstate__(self):
state["_array"] = self._array
state["name"] = self.name
state["_concrete_cache"] = self._concrete_cache
state["_written"] = self._written
return state

def __setstate__(self, state):
self._default = state["_default"]
self._array = state["_array"]
self._name = state["name"]
self._concrete_cache = state["_concrete_cache"]
self._written = state["_written"]
self._written = None

def __copy__(self):
return ArrayProxy(self)
Expand Down