Z3
Public Member Functions | Data Fields
AstMap Class Reference

Public Member Functions

def __init__
 
def __del__ (self)
 
def __len__ (self)
 
def __contains__ (self, key)
 
def __getitem__ (self, key)
 
def __setitem__ (self, k, v)
 
def __repr__ (self)
 
def erase (self, k)
 
def reset (self)
 
def keys (self)
 

Data Fields

 map
 
 ctx
 

Detailed Description

A mapping from ASTs to ASTs.

Definition at line 4959 of file z3py.py.

Constructor & Destructor Documentation

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

Definition at line 4962 of file z3py.py.

4962  def __init__(self, m=None, ctx=None):
4963  self.map = None
4964  if m == None:
4965  self.ctx = _get_ctx(ctx)
4966  self.map = Z3_mk_ast_map(self.ctx.ref())
4967  else:
4968  self.map = m
4969  assert ctx != None
4970  self.ctx = ctx
4971  Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
4972 
Z3_ast_map Z3_API Z3_mk_ast_map(__in Z3_context c)
Return an empty mapping from AST to AST.
def __init__
Definition: z3py.py:4962
void Z3_API Z3_ast_map_inc_ref(__in Z3_context c, __in Z3_ast_map m)
Increment the reference counter of the given AST map.
def __del__ (   self)

Definition at line 4973 of file z3py.py.

4973  def __del__(self):
4974  if self.map != None:
4975  Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
4976 
def __del__(self)
Definition: z3py.py:4973
void Z3_API Z3_ast_map_dec_ref(__in Z3_context c, __in Z3_ast_map m)
Decrement the reference counter of the given AST map.

Member Function Documentation

def __contains__ (   self,
  key 
)
Return `True` if the map contains key `key`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> x in M
True
>>> x+1 in M
False

Definition at line 4990 of file z3py.py.

4990  def __contains__(self, key):
4991  """Return `True` if the map contains key `key`.
4992 
4993  >>> M = AstMap()
4994  >>> x = Int('x')
4995  >>> M[x] = x + 1
4996  >>> x in M
4997  True
4998  >>> x+1 in M
4999  False
5000  """
5001  return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
5002 
Z3_bool Z3_API Z3_ast_map_contains(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k)
Return true if the map m contains the AST key k.
def __contains__(self, key)
Definition: z3py.py:4990
def __getitem__ (   self,
  key 
)
Retrieve the value associated with key `key`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> M[x]
x + 1

Definition at line 5003 of file z3py.py.

5003  def __getitem__(self, key):
5004  """Retrieve the value associated with key `key`.
5005 
5006  >>> M = AstMap()
5007  >>> x = Int('x')
5008  >>> M[x] = x + 1
5009  >>> M[x]
5010  x + 1
5011  """
5012  return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
5013 
def __getitem__(self, key)
Definition: z3py.py:5003
Z3_ast Z3_API Z3_ast_map_find(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k)
Return the value associated with the key k.
def __len__ (   self)
Return the size of the map. 

>>> M = AstMap()
>>> len(M)
0
>>> x = Int('x')
>>> M[x] = IntVal(1)
>>> len(M)
1

Definition at line 4977 of file z3py.py.

4977  def __len__(self):
4978  """Return the size of the map.
4979 
4980  >>> M = AstMap()
4981  >>> len(M)
4982  0
4983  >>> x = Int('x')
4984  >>> M[x] = IntVal(1)
4985  >>> len(M)
4986  1
4987  """
4988  return int(Z3_ast_map_size(self.ctx.ref(), self.map))
4989 
def __len__(self)
Definition: z3py.py:4977
unsigned Z3_API Z3_ast_map_size(__in Z3_context c, __in Z3_ast_map m)
Return the size of the given map.
def __repr__ (   self)

Definition at line 5030 of file z3py.py.

5030  def __repr__(self):
5031  return Z3_ast_map_to_string(self.ctx.ref(), self.map)
5032 
Z3_string Z3_API Z3_ast_map_to_string(__in Z3_context c, __in Z3_ast_map m)
Convert the given map into a string.
def __repr__(self)
Definition: z3py.py:5030
def __setitem__ (   self,
  k,
  v 
)
Add/Update key `k` with value `v`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> len(M)
1
>>> M[x]
x + 1
>>> M[x] = IntVal(1)
>>> M[x]
1

Definition at line 5014 of file z3py.py.

5014  def __setitem__(self, k, v):
5015  """Add/Update key `k` with value `v`.
5016 
5017  >>> M = AstMap()
5018  >>> x = Int('x')
5019  >>> M[x] = x + 1
5020  >>> len(M)
5021  1
5022  >>> M[x]
5023  x + 1
5024  >>> M[x] = IntVal(1)
5025  >>> M[x]
5026  1
5027  """
5028  Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
5029 
def __setitem__(self, k, v)
Definition: z3py.py:5014
void Z3_API Z3_ast_map_insert(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k, __in Z3_ast v)
Store/Replace a new key, value pair in the given map.
def erase (   self,
  k 
)
Remove the entry associated with key `k`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> len(M)
1
>>> M.erase(x)
>>> len(M)
0

Definition at line 5033 of file z3py.py.

5033  def erase(self, k):
5034  """Remove the entry associated with key `k`.
5035 
5036  >>> M = AstMap()
5037  >>> x = Int('x')
5038  >>> M[x] = x + 1
5039  >>> len(M)
5040  1
5041  >>> M.erase(x)
5042  >>> len(M)
5043  0
5044  """
5045  Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
5046 
void Z3_API Z3_ast_map_erase(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k)
Erase a key from the map.
def erase(self, k)
Definition: z3py.py:5033
def keys (   self)
Return an AstVector containing all keys in the map.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x]   = x + 1
>>> M[x+x] = IntVal(1)
>>> M.keys()
[x, x + x]

Definition at line 5062 of file z3py.py.

5062  def keys(self):
5063  """Return an AstVector containing all keys in the map.
5064 
5065  >>> M = AstMap()
5066  >>> x = Int('x')
5067  >>> M[x] = x + 1
5068  >>> M[x+x] = IntVal(1)
5069  >>> M.keys()
5070  [x, x + x]
5071  """
5072  return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
5073 
Z3_ast_vector Z3_API Z3_ast_map_keys(__in Z3_context c, __in Z3_ast_map m)
Return the keys stored in the given map.
def keys(self)
Definition: z3py.py:5062
def reset (   self)
Remove all entries from the map.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x]   = x + 1
>>> M[x+x] = IntVal(1)
>>> len(M)
2
>>> M.reset()
>>> len(M)
0

Definition at line 5047 of file z3py.py.

5047  def reset(self):
5048  """Remove all entries from the map.
5049 
5050  >>> M = AstMap()
5051  >>> x = Int('x')
5052  >>> M[x] = x + 1
5053  >>> M[x+x] = IntVal(1)
5054  >>> len(M)
5055  2
5056  >>> M.reset()
5057  >>> len(M)
5058  0
5059  """
5060  Z3_ast_map_reset(self.ctx.ref(), self.map)
5061 
def reset(self)
Definition: z3py.py:5047
void Z3_API Z3_ast_map_reset(__in Z3_context c, __in Z3_ast_map m)
Remove all keys from the given map.

Field Documentation

ctx
map