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 4936 of file z3py.py.

Constructor & Destructor Documentation

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

Definition at line 4939 of file z3py.py.

4939  def __init__(self, m=None, ctx=None):
4940  self.map = None
4941  if m == None:
4942  self.ctx = _get_ctx(ctx)
4943  self.map = Z3_mk_ast_map(self.ctx.ref())
4944  else:
4945  self.map = m
4946  assert ctx != None
4947  self.ctx = ctx
4948  Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
4949 
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:4939
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 4950 of file z3py.py.

4950  def __del__(self):
4951  if self.map != None:
4952  Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
4953 
def __del__(self)
Definition: z3py.py:4950
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 4967 of file z3py.py.

4967  def __contains__(self, key):
4968  """Return `True` if the map contains key `key`.
4969 
4970  >>> M = AstMap()
4971  >>> x = Int('x')
4972  >>> M[x] = x + 1
4973  >>> x in M
4974  True
4975  >>> x+1 in M
4976  False
4977  """
4978  return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
4979 
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:4967
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 4980 of file z3py.py.

4980  def __getitem__(self, key):
4981  """Retrieve the value associated with key `key`.
4982 
4983  >>> M = AstMap()
4984  >>> x = Int('x')
4985  >>> M[x] = x + 1
4986  >>> M[x]
4987  x + 1
4988  """
4989  return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
4990 
def __getitem__(self, key)
Definition: z3py.py:4980
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 4954 of file z3py.py.

4954  def __len__(self):
4955  """Return the size of the map.
4956 
4957  >>> M = AstMap()
4958  >>> len(M)
4959  0
4960  >>> x = Int('x')
4961  >>> M[x] = IntVal(1)
4962  >>> len(M)
4963  1
4964  """
4965  return int(Z3_ast_map_size(self.ctx.ref(), self.map))
4966 
def __len__(self)
Definition: z3py.py:4954
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 5007 of file z3py.py.

5007  def __repr__(self):
5008  return Z3_ast_map_to_string(self.ctx.ref(), self.map)
5009 
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:5007
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 4991 of file z3py.py.

4991  def __setitem__(self, k, v):
4992  """Add/Update key `k` with value `v`.
4993 
4994  >>> M = AstMap()
4995  >>> x = Int('x')
4996  >>> M[x] = x + 1
4997  >>> len(M)
4998  1
4999  >>> M[x]
5000  x + 1
5001  >>> M[x] = IntVal(1)
5002  >>> M[x]
5003  1
5004  """
5005  Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
5006 
def __setitem__(self, k, v)
Definition: z3py.py:4991
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 5010 of file z3py.py.

5010  def erase(self, k):
5011  """Remove the entry associated with key `k`.
5012 
5013  >>> M = AstMap()
5014  >>> x = Int('x')
5015  >>> M[x] = x + 1
5016  >>> len(M)
5017  1
5018  >>> M.erase(x)
5019  >>> len(M)
5020  0
5021  """
5022  Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
5023 
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:5010
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 5039 of file z3py.py.

5039  def keys(self):
5040  """Return an AstVector containing all keys in the map.
5041 
5042  >>> M = AstMap()
5043  >>> x = Int('x')
5044  >>> M[x] = x + 1
5045  >>> M[x+x] = IntVal(1)
5046  >>> M.keys()
5047  [x, x + x]
5048  """
5049  return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
5050 
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:5039
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 5024 of file z3py.py.

5024  def reset(self):
5025  """Remove all entries from the map.
5026 
5027  >>> M = AstMap()
5028  >>> x = Int('x')
5029  >>> M[x] = x + 1
5030  >>> M[x+x] = IntVal(1)
5031  >>> len(M)
5032  2
5033  >>> M.reset()
5034  >>> len(M)
5035  0
5036  """
5037  Z3_ast_map_reset(self.ctx.ref(), self.map)
5038 
def reset(self)
Definition: z3py.py:5024
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