mirror of
https://github.com/Z3Prover/z3
synced 2025-06-09 23:53:25 +00:00
Merge pull request #1410 from bannsec/assertion_slices
Allowing slices and negative index in assertions
This commit is contained in:
commit
d80c4307a6
1 changed files with 12 additions and 3 deletions
|
@ -5140,10 +5140,19 @@ class AstVector(Z3PPObject):
|
||||||
>>> A[1]
|
>>> A[1]
|
||||||
y
|
y
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if isinstance(i, int):
|
||||||
|
if i < 0:
|
||||||
|
i += self.__len__()
|
||||||
|
|
||||||
if i >= self.__len__():
|
if i >= self.__len__():
|
||||||
raise IndexError
|
raise IndexError
|
||||||
return _to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, i), self.ctx)
|
return _to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, i), self.ctx)
|
||||||
|
|
||||||
|
elif isinstance(i, slice):
|
||||||
|
return [_to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, ii), self.ctx) for ii in range(*i.indices(self.__len__()))]
|
||||||
|
|
||||||
|
|
||||||
def __setitem__(self, i, v):
|
def __setitem__(self, i, v):
|
||||||
"""Update AST at position `i`.
|
"""Update AST at position `i`.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue