Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Data Fields
AstVector Class Reference
+ Inheritance diagram for AstVector:

Public Member Functions

def __init__
 
def __del__
 
def __len__
 
def __getitem__
 
def __setitem__
 
def push
 
def resize
 
def __contains__
 
def translate
 
def __repr__
 
def sexpr
 
- Public Member Functions inherited from Z3PPObject
def use_pp
 

Data Fields

 vector
 
 ctx
 

Detailed Description

A collection (vector) of ASTs.

Definition at line 4717 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  v = None,
  ctx = None 
)

Definition at line 4720 of file z3py.py.

4721  def __init__(self, v=None, ctx=None):
4722  self.vector = None
4723  if v == None:
4724  self.ctx = _get_ctx(ctx)
4725  self.vector = Z3_mk_ast_vector(self.ctx.ref())
4726  else:
4727  self.vector = v
4728  assert ctx != None
4729  self.ctx = ctx
4730  Z3_ast_vector_inc_ref(self.ctx.ref(), self.vector)
def __del__ (   self)

Definition at line 4731 of file z3py.py.

4732  def __del__(self):
4733  if self.vector != None:
4734  Z3_ast_vector_dec_ref(self.ctx.ref(), self.vector)

Member Function Documentation

def __contains__ (   self,
  item 
)
Return `True` if the vector contains `item`.

>>> x = Int('x')
>>> A = AstVector()
>>> x in A
False
>>> A.push(x)
>>> x in A
True
>>> (x+1) in A
False
>>> A.push(x+1)
>>> (x+1) in A
True
>>> A
[x, x + 1]

Definition at line 4804 of file z3py.py.

4805  def __contains__(self, item):
4806  """Return `True` if the vector contains `item`.
4807 
4808  >>> x = Int('x')
4809  >>> A = AstVector()
4810  >>> x in A
4811  False
4812  >>> A.push(x)
4813  >>> x in A
4814  True
4815  >>> (x+1) in A
4816  False
4817  >>> A.push(x+1)
4818  >>> (x+1) in A
4819  True
4820  >>> A
4821  [x, x + 1]
4822  """
4823  for elem in self:
4824  if elem.eq(item):
4825  return True
4826  return False
def __getitem__ (   self,
  i 
)
Return the AST at position `i`.

>>> A = AstVector()
>>> A.push(Int('x') + 1)
>>> A.push(Int('y'))
>>> A[0]
x + 1
>>> A[1]
y

Definition at line 4748 of file z3py.py.

4749  def __getitem__(self, i):
4750  """Return the AST at position `i`.
4751 
4752  >>> A = AstVector()
4753  >>> A.push(Int('x') + 1)
4754  >>> A.push(Int('y'))
4755  >>> A[0]
4756  x + 1
4757  >>> A[1]
4758  y
4759  """
4760  if i >= self.__len__():
4761  raise IndexError
4762  return _to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, i), self.ctx)
def __len__ (   self)
Return the size of the vector `self`.

>>> A = AstVector()
>>> len(A)
0
>>> A.push(Int('x'))
>>> A.push(Int('x'))
>>> len(A)
2

Definition at line 4735 of file z3py.py.

Referenced by AstVector.__getitem__().

4736  def __len__(self):
4737  """Return the size of the vector `self`.
4738 
4739  >>> A = AstVector()
4740  >>> len(A)
4741  0
4742  >>> A.push(Int('x'))
4743  >>> A.push(Int('x'))
4744  >>> len(A)
4745  2
4746  """
4747  return int(Z3_ast_vector_size(self.ctx.ref(), self.vector))
def __repr__ (   self)

Definition at line 4840 of file z3py.py.

4841  def __repr__(self):
4842  return obj_to_string(self)
def __setitem__ (   self,
  i,
  v 
)
Update AST at position `i`.

>>> A = AstVector()
>>> A.push(Int('x') + 1)
>>> A.push(Int('y'))
>>> A[0]
x + 1
>>> A[0] = Int('x')
>>> A[0]
x

Definition at line 4763 of file z3py.py.

4764  def __setitem__(self, i, v):
4765  """Update AST at position `i`.
4766 
4767  >>> A = AstVector()
4768  >>> A.push(Int('x') + 1)
4769  >>> A.push(Int('y'))
4770  >>> A[0]
4771  x + 1
4772  >>> A[0] = Int('x')
4773  >>> A[0]
4774  x
4775  """
4776  if i >= self.__len__():
4777  raise IndexError
4778  Z3_ast_vector_set(self.ctx.ref(), self.vector, i, v.as_ast())
def push (   self,
  v 
)
Add `v` in the end of the vector.

>>> A = AstVector()
>>> len(A)
0
>>> A.push(Int('x'))
>>> len(A)
1

Definition at line 4779 of file z3py.py.

4780  def push(self, v):
4781  """Add `v` in the end of the vector.
4782 
4783  >>> A = AstVector()
4784  >>> len(A)
4785  0
4786  >>> A.push(Int('x'))
4787  >>> len(A)
4788  1
4789  """
4790  Z3_ast_vector_push(self.ctx.ref(), self.vector, v.as_ast())
def resize (   self,
  sz 
)
Resize the vector to `sz` elements.

>>> A = AstVector()
>>> A.resize(10)
>>> len(A)
10
>>> for i in range(10): A[i] = Int('x')
>>> A[5]
x

Definition at line 4791 of file z3py.py.

4792  def resize(self, sz):
4793  """Resize the vector to `sz` elements.
4794 
4795  >>> A = AstVector()
4796  >>> A.resize(10)
4797  >>> len(A)
4798  10
4799  >>> for i in range(10): A[i] = Int('x')
4800  >>> A[5]
4801  x
4802  """
4803  Z3_ast_vector_resize(self.ctx.ref(), self.vector, sz)
def sexpr (   self)
Return a textual representation of the s-expression representing the vector.

Definition at line 4843 of file z3py.py.

4844  def sexpr(self):
4845  """Return a textual representation of the s-expression representing the vector."""
4846  return Z3_ast_vector_to_string(self.ctx.ref(), self.vector)
def translate (   self,
  other_ctx 
)
Copy vector `self` to context `other_ctx`.

>>> x = Int('x')
>>> A = AstVector()
>>> A.push(x)
>>> c2 = Context()
>>> B = A.translate(c2)
>>> B
[x]

Definition at line 4827 of file z3py.py.

4828  def translate(self, other_ctx):
4829  """Copy vector `self` to context `other_ctx`.
4830 
4831  >>> x = Int('x')
4832  >>> A = AstVector()
4833  >>> A.push(x)
4834  >>> c2 = Context()
4835  >>> B = A.translate(c2)
4836  >>> B
4837  [x]
4838  """
4839  return AstVector(Z3_ast_vector_translate(self.ctx.ref(), self.vector, other_ctx.ref()), other_ctx)

Field Documentation

ctx

Definition at line 4723 of file z3py.py.

Referenced by Probe.__eq__(), Probe.__ge__(), AstVector.__getitem__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Tactic.apply(), ApplyResult.as_expr(), ApplyResult.convert_model(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_rules(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Tactic.solver(), and Fixedpoint.statistics().

vector

Definition at line 4721 of file z3py.py.

Referenced by AstVector.__del__(), AstVector.__getitem__(), AstVector.__len__(), AstVector.__setitem__(), AstVector.push(), AstVector.resize(), AstVector.sexpr(), and AstVector.translate().