Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::aot Namespace Reference

Classes

class  Dispatcher
struct  WorldStamp
struct  QuerySpec
class  CallArena
struct  RowSpan
struct  BoundSystem
class  Module

Typedefs

using SystemFn = void (*)(es_addr_t)
using ComponentAt = std::function<void*(std::uint32_t)>
using Candidates = std::optional<std::span<const std::uint32_t>>
using CandidatesOf = std::function<Candidates()>
using ResourceLookup = std::function<void*(const char*)>
using ComponentLookup = std::function<ComponentAt(const char*)>
using CandidateLookup = std::function<CandidatesOf(const char*)>

Functions

std::uint32_t applyCommands (ecs::Registry &registry, std::span< const EsCmd > cmds)
ComponentAt engineComponentAt (ecs::Registry &registry, const char *name)
CandidatesOf engineComponentCandidates (ecs::Registry &registry, const char *name)
bool isEngineComponent (const char *name)
Candidates narrowest (const QuerySpec &spec)
bool narrows (std::span< const QuerySpec > queries)
std::span< const EsCmd > run (SystemFn fn, std::span< const std::uint32_t > fallback, std::span< const QuerySpec > queries, std::span< void *const > resources, CallArena &arena, WorldStamp world={})
void * rowAt (const RowSpan &span, std::uint32_t entity)
ComponentAt fromRows (const RowSpan &span)
ComponentAt fromMovingRows (const RowSpan *slot)
CandidatesOf fromMovingOwners (const RowSpan *slot)
BoundSystem bind (const EsSystemDecl &decl, const ComponentLookup &components, const ResourceLookup &resources, const CandidateLookup &candidates={})
std::span< const EsCmd > runBound (const BoundSystem &bound, std::span< const std::uint32_t > fallback, const ResourceLookup &resources, CallArena &arena, WorldStamp world={}, bool *runnable=nullptr)
std::uint64_t abiHash (std::uint64_t contract)

Variables

constexpr std::uint32_t NO_OWNER = 0xFFFFFFFFu

Typedef Documentation

◆ CandidateLookup

using esengine::aot::CandidateLookup = std::function<CandidatesOf(const char*)>

The third question, and the only optional one: who holds that component. Separate from ComponentLookup because a host with no answer must still bind and run — narrowing is an optimisation and cannot be allowed to change which rows a system sees.

Definition at line 358 of file AotHost.hpp.

◆ Candidates

using esengine::aot::Candidates = std::optional<std::span<const std::uint32_t>>

Which entities a component's storage says it holds, as raw ids.

Empty means nobody has it and the query matches nothing; nullopt means this host cannot enumerate that column and the caller must WIDEN, not narrow. Reading the second as the first drops every row.

Definition at line 58 of file AotHost.hpp.

◆ CandidatesOf

using esengine::aot::CandidatesOf = std::function<Candidates()>

A column's members, asked per call because a pool grows between them.

Definition at line 61 of file AotHost.hpp.

◆ ComponentAt

using esengine::aot::ComponentAt = std::function<void*(std::uint32_t)>

Where one component's bytes are for an entity, or nullptr if it has none. Supplied per component by the layer that knows its type — a generated binding, or a test.

Definition at line 49 of file AotHost.hpp.

◆ ComponentLookup

using esengine::aot::ComponentLookup = std::function<ComponentAt(const char*)>

How a host answers the two questions a declaration asks: where one component is for an entity, and where one resource is. Both by NAME, because names are what the artifact carries — it cannot know this host's type ids.

Definition at line 350 of file AotHost.hpp.

◆ ResourceLookup

using esengine::aot::ResourceLookup = std::function<void*(const char*)>

Definition at line 120 of file AotHost.hpp.

◆ SystemFn

What a compiled system is: one exported symbol, taking the ctx.

Definition at line 42 of file AotHost.hpp.

Function Documentation

◆ abiHash()

std::uint64_t esengine::aot::abiHash ( std::uint64_t contract)
inline

The constant a compiled artifact exports, as this host computes it. The contract half comes from the artifact; the width is ours, and mixing it here is what stops a 32-bit artifact loading into a 64-bit host.

Definition at line 428 of file AotHost.hpp.

◆ applyCommands()

std::uint32_t esengine::aot::applyCommands ( ecs::Registry & registry,
std::span< const EsCmd > cmds )
inline

Apply a call's records to this registry; returns how many it did not know.

Despawn is the whole v1 set, and the interpreted side applies exactly that — so a nonzero result is this host being older than the module it loaded, not a malformed record.

Definition at line 38 of file AotCommands.hpp.

References esengine::ecs::Registry::destroy(), ES_CMD_DESPAWN, and esengine::Entity::fromRaw().

◆ bind()

BoundSystem esengine::aot::bind ( const EsSystemDecl & decl,
const ComponentLookup & components,
const ResourceLookup & resources,
const CandidateLookup & candidates = {} )
inline

Resolve decl against this host. A component or resource the host cannot name leaves fn null: the system is simply not run, which is the interpreter fallback arriving one layer down rather than a crash at the first row.

Definition at line 376 of file AotHost.hpp.

◆ engineComponentAt()

ComponentAt esengine::aot::engineComponentAt ( ecs::Registry & registry,
const char * name )

Where a named ENGINE component lives, for this registry.

tryGet, never getOrEmplace: a resolver that created the component would give one to every entity the query walked, and a row is kept only when every component resolves — the absence IS the filter.

No lazily-derived field is refreshed, because the interpreted side does not refresh one either and it is the oracle. A component whose fields are stale until a method runs cannot be read by a compiled system at all, and that is a subset question rather than a resolver one.

An unknown name yields an EMPTY resolver: a project component lives in the script pool and is not this table's to answer for. Call it and it throws, so a caller must ask isEngineComponent first.

Definition at line 73 of file AotComponents.generated.cpp.

References esengine::Entity::fromRaw(), and esengine::ecs::Registry::tryGet().

◆ engineComponentCandidates()

CandidatesOf esengine::aot::engineComponentCandidates ( ecs::Registry & registry,
const char * name )

WHO has that component, for a caller narrowing a query to its shortest column.

The resolver above answers per entity and can only be asked about one that is already a candidate; this is where candidates come FROM. A host without it must offer every entity, and then what a compiled system costs is the size of the world instead of the size of what it matches.

An empty span means nobody has it — a query that matches nothing. The empty FUNCTION means this table does not answer for the name, which is a different answer and the caller must not narrow on it.

Definition at line 357 of file AotComponents.generated.cpp.

References esengine::ecs::Registry::entitiesWith().

◆ fromMovingOwners()

CandidatesOf esengine::aot::fromMovingOwners ( const RowSpan * slot)
inline

Who is in that column, read through the same slot for the same reason. nullopt rather than empty when no owner array was reported: "did not say" is not "is empty", and confusing them runs every system over nothing.

Definition at line 338 of file AotHost.hpp.

References esengine::aot::RowSpan::ownerCount, and esengine::aot::RowSpan::owners.

◆ fromMovingRows()

ComponentAt esengine::aot::fromMovingRows ( const RowSpan * slot)
inline

The same, for rows that MOVE.

A pool reallocates as it grows, and a resolver holding the span by value then reads memory nobody owns; this reads it through a slot the owner overwrites. The slot must outlive the resolver; a null one is simply absent.

Definition at line 327 of file AotHost.hpp.

References rowAt().

◆ fromRows()

ComponentAt esengine::aot::fromRows ( const RowSpan & span)
inline

span as a resolver, for rows that will not move while it is held.

Definition at line 316 of file AotHost.hpp.

References rowAt().

◆ isEngineComponent()

bool esengine::aot::isEngineComponent ( const char * name)

Whether this table answers for that name, without building a resolver.

Definition at line 641 of file AotComponents.generated.cpp.

◆ narrowest()

Candidates esengine::aot::narrowest ( const QuerySpec & spec)
inline

The shortest column this query names, or nullopt when none of them could say.

An entity missing any one component cannot match, so any column bounds the answer and the shortest bounds it best — ecs::View's strategy, reached through names. run still filters; this only decides what it is paid over.

Definition at line 96 of file AotHost.hpp.

References esengine::aot::QuerySpec::sources.

Referenced by narrows().

◆ narrows()

bool esengine::aot::narrows ( std::span< const QuerySpec > queries)
inline

Whether every one of these queries can narrow itself — that is, whether the caller can skip enumerating the world. Asked before it does. No queries at all answers true: nothing would walk the list.

Definition at line 112 of file AotHost.hpp.

References narrowest().

◆ rowAt()

void * esengine::aot::rowAt ( const RowSpan & span,
std::uint32_t entity )
inline

One row out of a span. Absent is zero in the table, as it is in a sparse set.

Definition at line 307 of file AotHost.hpp.

References esengine::aot::RowSpan::indexMask, esengine::aot::RowSpan::rows, esengine::aot::RowSpan::sparse, esengine::aot::RowSpan::sparseCount, and esengine::aot::RowSpan::stride.

Referenced by fromMovingRows(), and fromRows().

◆ run()

std::span< const EsCmd > esengine::aot::run ( SystemFn fn,
std::span< const std::uint32_t > fallback,
std::span< const QuerySpec > queries,
std::span< void *const > resources,
CallArena & arena,
WorldStamp world = {} )
inline

Materialise, call, and return the commands the system produced. A row is kept only when every component resolves — an absent one is the filter.

fallback is walked only by a query that cannot narrow itself; ask narrows first, since building it is O(world). Applying the commands is the CALLER's job: a despawn here invalidates the rows just handed over.

Definition at line 181 of file AotHost.hpp.

◆ runBound()

std::span< const EsCmd > esengine::aot::runBound ( const BoundSystem & bound,
std::span< const std::uint32_t > fallback,
const ResourceLookup & resources,
CallArena & arena,
WorldStamp world = {},
bool * runnable = nullptr )
inline

Run a bound system, resolving its resources for this call. fallback is for the queries that cannot narrow themselves; see run.

Definition at line 404 of file AotHost.hpp.

Variable Documentation

◆ NO_OWNER

std::uint32_t esengine::aot::NO_OWNER = 0xFFFFFFFFu
inlineconstexpr

A slot nobody holds. Entity::INVALID_RAW: the one raw value the engine never hands out, so a hole resolves to no row and the filter drops it.

Definition at line 304 of file AotHost.hpp.