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

5537 def sort(self):
5538 """Return the datatype sort of the datatype expression `self`."""
5539 return DatatypeSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
5540
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 5541 of file z3py.py.

5541 def update_field(self, field_accessor, new_value):
5542 """Return a new datatype expression with the specified field updated.
5543
5544 Args:
5545 field_accessor: The accessor function declaration for the field to update
5546 new_value: The new value for the field
5547
5548 Returns:
5549 A new datatype expression with the field updated, other fields unchanged
5550
5551 Example:
5552 >>> Person = Datatype('Person')
5553 >>> Person.declare('person', ('name', StringSort()), ('age', IntSort()))
5554 >>> Person = Person.create()
5555 >>> person_age = Person.accessor(0, 1) # age accessor
5556 >>> p = Const('p', Person)
5557 >>> p2 = p.update_field(person_age, IntVal(30))
5558 """
5559 if z3_debug():
5560 _z3_assert(is_func_decl(field_accessor), "Z3 function declaration expected")
5561 _z3_assert(is_expr(new_value), "Z3 expression expected")
5562 return _to_expr_ref(
5563 Z3_datatype_update_field(self.ctx_ref(), field_accessor.ast, self.as_ast(), new_value.as_ast()),
5564 self.ctx
5565 )
5566
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.