Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::vm::VirtualMachine Class Reference

Compiles query terms into matching bytecode and evaluates that bytecode against archetypes. The VM owns query matching and cache construction only. Row, chunk, entity-seed, sorted, traversal, and mapped typed callback dispatch are selected later by QueryImpl::QueryPlan. More...

#include <vm.h>

Public Member Functions

GAIA_NODISCARD util::str bytecode (const World &world) const
 Formats the compiled query bytecode for diagnostics.
 
void compile (const EntityToArchetypeMap &entityToArchetypeMap, std::span< const Archetype * > allArchetypes, QueryCtx &queryCtx)
 Transforms inputs into virtual machine opcodes.
 
GAIA_NODISCARD bool is_compiled () const
 Returns whether this VM contains compiled executable opcodes.
 
GAIA_NODISCARD uint32_t op_count () const
 Returns the total number of compiled opcodes.
 
GAIA_NODISCARD uint64_t op_signature () const
 Computes a stable signature of the compiled opcode stream.
 
void exec (MatchingCtx &ctx)
 Executes compiled query-matching opcodes.
 

Detailed Description

Compiles query terms into matching bytecode and evaluates that bytecode against archetypes. The VM owns query matching and cache construction only. Row, chunk, entity-seed, sorted, traversal, and mapped typed callback dispatch are selected later by QueryImpl::QueryPlan.

Member Function Documentation

◆ bytecode()

GAIA_NODISCARD util::str gaia::ecs::vm::VirtualMachine::bytecode ( const World world) const
inline

Formats the compiled query bytecode for diagnostics.

Parameters
worldWorld used to resolve entity names in the output.
Returns
Human-readable bytecode and operand metadata.

◆ compile()

void gaia::ecs::vm::VirtualMachine::compile ( const EntityToArchetypeMap entityToArchetypeMap,
std::span< const Archetype * >  allArchetypes,
QueryCtx queryCtx 
)
inline

Transforms inputs into virtual machine opcodes.

Parameters
entityToArchetypeMapComponent-to-archetype lookup available during compilation.
allArchetypesArchetypes available during compilation.
queryCtxQuery definition and dependency metadata to compile.

◆ exec()

void gaia::ecs::vm::VirtualMachine::exec ( MatchingCtx ctx)
inline

Executes compiled query-matching opcodes.

Parameters
ctxMatching state updated with the resulting archetypes.

◆ is_compiled()

GAIA_NODISCARD bool gaia::ecs::vm::VirtualMachine::is_compiled ( ) const
inline

Returns whether this VM contains compiled executable opcodes.

Returns
True when compilation produced at least one opcode.

◆ op_count()

GAIA_NODISCARD uint32_t gaia::ecs::vm::VirtualMachine::op_count ( ) const
inline

Returns the total number of compiled opcodes.

Returns
Number of compiled opcodes, including variable-search programs.

◆ op_signature()

GAIA_NODISCARD uint64_t gaia::ecs::vm::VirtualMachine::op_signature ( ) const
inline

Computes a stable signature of the compiled opcode stream.

Returns
Hash of opcode kinds, control-flow targets, operands, and costs.

The documentation for this class was generated from the following file: