Z3
Loading...
Searching...
No Matches
DatatypeRef Class Reference
Inheritance diagram for DatatypeRef:

Public Member Functions

 sort (self)
 update_field (self, field_accessor, new_value)
Public Member Functions inherited from ExprRef
 as_ast (self)
 get_id (self)
 sort_kind (self)
 __eq__ (self, other)
 __hash__ (self)
 __ne__ (self, other)
 params (self)
 decl (self)
 kind (self)
 num_args (self)
 arg (self, idx)
 children (self)
 update (self, *args)
 from_string (self, s)
 serialize (self)
Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 __del__ (self)
 __deepcopy__ (self, memo={})
 __str__ (self)
 __repr__ (self)
 __eq__ (self, other)
 __hash__ (self)
 __nonzero__ (self)
 __bool__ (self)
 sexpr (self)
 ctx_ref (self)
 eq (self, other)
 translate (self, target)
 __copy__ (self)
 hash (self)
 py_value (self)
Public Member Functions inherited from Z3PPObject
 use_pp (self)

Additional Inherited Members

Data Fields inherited from AstRef
 ast = ast
 ctx = _get_ctx(ctx)
Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)

Detailed Description

Datatype expressions.

Definition at line 5917 of file z3py.py.

Member Function Documentation

◆ sort()

sort ( self)
Return the datatype sort of the datatype expression `self`.

Reimplemented from ExprRef.

Definition at line 5920 of file z3py.py.

5920 def sort(self):
5921 """Return the datatype sort of the datatype expression `self`."""
5922 return DatatypeSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
5923
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

◆ update_field()

update_field ( self,
field_accessor,
new_value )
Return a new datatype expression with the specified field updated.

Args:
    field_accessor: The accessor function declaration for the field to update
    new_value: The new value for the field
    
Returns:
    A new datatype expression with the field updated, other fields unchanged
    
Example:
    >>> Person = Datatype('Person')
    >>> Person.declare('person', ('name', StringSort()), ('age', IntSort()))
    >>> Person = Person.create()
    >>> person_age = Person.accessor(0, 1)  # age accessor
    >>> p = Const('p', Person)
    >>> p2 = p.update_field(person_age, IntVal(30))

Definition at line 5924 of file z3py.py.

5924 def update_field(self, field_accessor, new_value):
5925 """Return a new datatype expression with the specified field updated.
5926
5927 Args:
5928 field_accessor: The accessor function declaration for the field to update
5929 new_value: The new value for the field
5930
5931 Returns:
5932 A new datatype expression with the field updated, other fields unchanged
5933
5934 Example:
5935 >>> Person = Datatype('Person')
5936 >>> Person.declare('person', ('name', StringSort()), ('age', IntSort()))
5937 >>> Person = Person.create()
5938 >>> person_age = Person.accessor(0, 1) # age accessor
5939 >>> p = Const('p', Person)
5940 >>> p2 = p.update_field(person_age, IntVal(30))
5941 """
5942 if z3_debug():
5943 _z3_assert(is_func_decl(field_accessor), "Z3 function declaration expected")
5944 _z3_assert(is_expr(new_value), "Z3 expression expected")
5945 return _to_expr_ref(
5946 Z3_datatype_update_field(self.ctx_ref(), field_accessor.ast, self.as_ast(), new_value.as_ast()),
5947 self.ctx
5948 )
5949
Z3_ast Z3_API Z3_datatype_update_field(Z3_context c, Z3_func_decl field_access, Z3_ast t, Z3_ast value)
Update record field with a value.