Module ir

Module ir 

Source
Expand description

Intermediate Representation (IR) for compiled queries.

This module contains the in-memory representation of compiled queries as defined in ADR-0004 through ADR-0008. The IR is designed for:

  • Cache-efficient execution (64-byte aligned transitions)
  • Zero-copy access patterns
  • WASM compatibility

Note: This module contains only type definitions. Query execution lives elsewhere.

Structs§

CompiledQuery
A compiled query ready for execution.
CompiledQueryBuffer
Aligned buffer for compiled query data.
CompiledQueryOffsets
Offset metadata extracted from CompiledQuery.
Entrypoint
Named entrypoint into the query graph.
MapResolver
Map-based resolver for testing.
MatcherView
A view of a matcher with resolved slices.
Nav
Navigation instruction determining cursor movement and skip policy.
NullResolver
A resolver that always fails (for testing without tree-sitter).
QueryEmitter
Emits a compiled query from a BuildGraph.
Slice
Relative range within a compiled query segment.
StringInterner
String interner for query compilation.
StringRef
Reference to a string in the string pool.
Transition
A single transition in the query graph.
TransitionView
A view of a transition with resolved slices.
TypeDef
Type definition in the compiled query.
TypeMember
Member of a Record (field) or Enum (variant).

Enums§

EffectOp
Effect operation in the IR effect stream.
EmitError
Query emitter error.
Matcher
Matcher determines what node satisfies a transition.
MatcherKind
Discriminant for matcher variants.
NavKind
Navigation kind determining movement direction and skip policy.
RefTransition
Marks a transition as entering or exiting a definition reference.
SerializeError
Serialization error.
TypeKind
Discriminant for type definitions.

Constants§

BUFFER_ALIGN
Buffer alignment for cache-line efficiency.
FORMAT_VERSION
Current format version.
HEADER_SIZE
Header size in bytes (64 bytes for cache-line alignment).
MAGIC
Magic bytes identifying a compiled query file.
MAX_INLINE_SUCCESSORS
Maximum number of inline successors before spilling to external segment.
STRING_NONE
Sentinel value for unnamed types (wrapper types have no explicit name).
TYPE_COMPOSITE_START
First composite type ID (after primitives 0-2).
TYPE_INVALID
TYPE_NODE
TYPE_STR
TYPE_VOID

Traits§

NodeKindResolver
Callback for resolving node kind names to IDs.

Functions§

align_up
Aligns an offset up to the given alignment.
deserialize
Deserializes a compiled query from a reader.
from_bytes
Deserializes a compiled query from a byte slice.
serialize
Serializes a compiled query to a writer.
to_bytes
Serializes a compiled query to a byte vector.

Type Aliases§

DataFieldId
Field name in effects (alias for type safety).
EmitResult
Result type for emit operations.
NodeFieldId
Node field ID from tree-sitter. Uses NonZeroU16 so Option<NodeFieldId> is the same size as NodeFieldId (niche optimization with 0 = None).
NodeTypeId
Node type ID from tree-sitter. Do not change the underlying type.
RefId
Index for definition references (Enter/Exit).
SerializeResult
Result type for serialization operations.
StringId
Index into the string_refs segment.
TransitionId
Index into the transitions segment.
TypeId
Index into type_defs segment (with reserved primitives 0-2).
VariantTagId
Variant tag in effects (alias for type safety).