Class ConstraintContextObj#

Inheritance Relationships#

Base Type#

  • public ffi::Object

Class Documentation#

class ConstraintContextObj : public ffi::Object#

Tracks the constraints relevant to each point in a traversal.

Holds variable bindings, value ranges, and predicates collected during traversal. Callbacks can inspect these constraints when processing the current expression or statement. Captured constraint and expression nodes must not be changed through aliases: appending preserves earlier prefixes, but snapshots do not deep-copy their contents.

Public Functions

ConstraintContextObj() = default#

Construct an empty root context.

inline ConstraintContextObj(ffi::ObjectPtr<ConstraintContextObj> parent, int64_t parent_local_prefix)#

Capture an inherited prefix and start an empty local sequence.

Parameters:
  • parent – Non-null parent context.

  • parent_local_prefix – Number of parent-local entries to capture.

Throws:

ffi::Error – If parent is null or the prefix is outside [0, parent->LocalSize()].

ConstraintContextObj(const ConstraintContextObj&) = delete#
ConstraintContextObj &operator=(const ConstraintContextObj&) = delete#
inline void Append(const Constraint &constraint)#

Append a premise locally, preserving every previously captured prefix.

Parameters:

constraint – Premise to retain as supplied, without validation or inference. Its node and referenced expressions must not later be mutated through aliases.

inline int64_t LocalSize() const#

Count the local entries.

Returns:

Local sequence length, excluding captured ancestors.

inline ConstraintContext Snapshot() const#

Captures the constraints currently visible in this context. Later additions to this context do not affect the returned context, which can be extended independently. Constraint objects and referenced expressions remain shared. For an existing integer expression x:

sym::ConstraintContext context;
context->Append(sym::PredicateConstraint(x >= 0));
auto saved = context->Snapshot();
context->Append(sym::PredicateConstraint(x < 16));
// saved contains x >= 0; context contains both predicates.

Returns:

An independently extensible context capturing the current prefix.

template<typename F>
inline void ForEach(F &&f) const#

Read constraints in inherited/local order. Later appends do not enter this iteration. The reference passed to the callback is valid only during that invocation; copy the handle to retain the premise.

Template Parameters:

F – Callable accepting a const Constraint&.

Parameters:

f – Callback invoked once per captured premise, in inherited/local order.

inline ffi::Array<Constraint> ToArray() const#

Returns an independent array of the constraints in this context. Includes inherited constraints in order. Later additions to the context do not change the returned array. Edits to the array do not change this context. Constraint objects remain shared and must not be mutated through aliases.

Returns:

A copy-on-write array containing the captured premises.

Public Static Functions

static void RegisterReflection()#

Register the context methods exposed through FFI reflection.

static inline int32_t _GetOrAllocRuntimeTypeIndex()#
static inline int32_t RuntimeTypeIndex() noexcept#