Skip to content

Commit

Permalink
Specialized iterative serialization for Array (#1756)
Browse files Browse the repository at this point in the history
* Specialized itereative serialization for Array

* lint
  • Loading branch information
feliam committed Jun 30, 2020
1 parent a2f072f commit e265bce
Showing 1 changed file with 22 additions and 2 deletions.
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

0 comments on commit e265bce

Please sign in to comment.