Source:
MoonLiveBuiltins.h
MoonLiveBuiltins¶
The neutral seam a host fills with its own vocabulary.
Enumerations¶
| Name | Description |
|---|---|
CtrlType |
|
InlineOp |
|
BuiltinKind |
|
SysVarKind |
A name the host defines and the script only reads. |
CtrlType¶
| Value | Description |
|---|---|
Int |
|
Byte |
|
Bool |
|
Fixed |
|
Str |
InlineOp¶
| Value | Description |
|---|---|
StoreElem |
|
StoreFirst |
|
FillElems |
BuiltinKind¶
| Value | Description |
|---|---|
Call |
|
Inline |
SysVarKind¶
A name the host defines and the script only reads.
| Value | Description |
|---|---|
Arena |
|
Arg |
Typedefs¶
| Return | Name | Description |
|---|---|---|
uint32_t(*)(const uintptr_t *args, uint32_t argc, const uint8_t *arena) |
HostCallFn |
HostCallFn¶
Functions¶
| Return | Name | Description |
|---|---|---|
constexpr uint8_t |
ctrlWidth constexpr |
Bytes one array element occupies. |
constexpr uint8_t |
ctrlSlotBytes constexpr |
Bytes a scalar occupies, which is always four whatever its type. |
constexpr size_t |
codeCapFor constexpr |
Bytes to reserve for a script of tokens tokens. |
constexpr uint8_t |
scriptArgOffset constexpr |
The arena byte offset of argument i. |
ctrlWidth¶
constexpr
Bytes one array element occupies.
ctrlSlotBytes¶
constexpr
Bytes a scalar occupies, which is always four whatever its type.
codeCapFor¶
constexpr
Bytes to reserve for a script of tokens tokens.
scriptArgOffset¶
constexpr
The arena byte offset of argument i.
Variables¶
| Return | Name | Description |
|---|---|---|
constexpr uint8_t |
kCtrlBytes static constexpr |
Bytes the script's own members may occupy. |
constexpr uint8_t |
kMaxCtrls static constexpr |
|
constexpr size_t |
kCodeCap static constexpr |
|
constexpr uint8_t |
kMaxSysVars static constexpr |
|
constexpr uint8_t |
kSysVarBytes static constexpr |
Bytes per system variable. |
constexpr uint8_t |
kDepthSlot static constexpr |
Where the emitted code keeps its recursion depth. |
constexpr uint8_t |
kMaxCallDepth static constexpr |
The depth at which a call is refused, so 31 activations execute and the 32nd returns. |
constexpr uint8_t |
kMaxScriptArgs static constexpr |
Where a script call's arguments are passed. |
constexpr uint8_t |
kScriptArgBytes static constexpr |
|
constexpr uint8_t |
kScriptArgBase static constexpr |
Where the argument block starts, aligned to four bytes because these are 32-bit slots. |
constexpr uint8_t |
kArenaBytes static constexpr |
How many bytes the whole arena holds. |
kCtrlBytes¶
static constexpr
Bytes the script's own members may occupy.
kMaxCtrls¶
static constexpr
kCodeCap¶
static constexpr
kMaxSysVars¶
static constexpr
kSysVarBytes¶
static constexpr
Bytes per system variable.
kDepthSlot¶
static constexpr
Where the emitted code keeps its recursion depth.
kMaxCallDepth¶
static constexpr
The depth at which a call is refused, so 31 activations execute and the 32nd returns.
kMaxScriptArgs¶
static constexpr
Where a script call's arguments are passed.
kScriptArgBytes¶
static constexpr
kScriptArgBase¶
static constexpr
Where the argument block starts, aligned to four bytes because these are 32-bit slots.
kArenaBytes¶
static constexpr
How many bytes the whole arena holds.
Builtin¶
src/core/moonlive/MoonLiveBuiltins.h:48Public Attributes¶
const char * name = nullptr
: The script-visible name, owned by the host.
uint8_t argc = 0
: How many arguments the builtin takes.
bool returns = false
: Whether the call produces a value rather than acting as a statement.
BuiltinKind kind = BuiltinKind::Call
: Whether this lowers to a host call or an inline op.
HostCallFn fn = nullptr
: The host function a Call targets.
InlineOp inlineOp {}
: The neutral opcode tag an Inline op carries.
uint8_t byRef = 0
: Which arguments are passed by reference, a bit per position.
uint8_t byStr = 0
: Which arguments must be a string literal, a bit per position.
uint8_t fixedArgs = 0
: Which arguments are fixed-point rather than whole numbers, a bit per position.
bool fixedReturn = false
: Whether the result is fixed-point.
BuiltinTable¶
src/core/moonlive/MoonLiveBuiltins.h:86Public Attributes¶
Builtin items
: The registered builtins.
uint8_t count = 0
: How many builtins are registered.
bool overflowed = false
: Set when an add was dropped for lack of room.
Public Methods¶
inline bool add(const Builtin & b)
: Register one builtin, returning false when the table is full.
inline bool full() const
: True when a registration was dropped for lack of room.
inline uint8_t registered() const
: Every registered name, for the overflow diagnostic. Not used on any hot path.
inline const Builtin * find(const char * name, size_t len) const
: The builtin registered under name, or null when there is none.
Public Static Attributes¶
constexpr uint8_t kMax = 96
: How many builtins one table holds.
SysVar¶
src/core/moonlive/MoonLiveBuiltins.h:174Public Attributes¶
const char * name = nullptr
: The script-visible name, owned by the host.
SysVarKind kind = SysVarKind::Arena
: Whether the value lives in the arena or in an argument register.
uint8_t where = 0
: The arena byte offset, or the argument register, by kind.
SysVarTable¶
src/core/moonlive/MoonLiveBuiltins.h:184The system variables one host domain defines, which the compiler resolves names against.
Public Attributes¶
SysVar items
: The registered system variables.
uint8_t count = 0
: How many system variables are registered.
Public Methods¶
inline bool add(const SysVar & v)
: Register one system variable, returning false when it cannot be held.
inline const SysVar * find(const char * name, size_t len) const
: The system variable registered under name, or null when there is none.
Public Static Attributes¶
constexpr uint8_t kMax = kMaxSysVars
: How many system variables one table holds.
More info¶
The core compiler knows only that a name maps to a descriptor, owning no function names and no domain semantics.
What a descriptor decides¶
A descriptor says how a call lowers. A Call is a pure host helper, lowered to a generic call. An Inline is a routine the backend emits without per-call overhead, carrying a neutral opcode tag the per-ISA lowering knows, which the core threads through without interpreting.
Macros¶
| Name | Description |
|---|---|
MM_ASSERT_NO_BUILTIN_OVERFLOW |
Assert a host's builtin table did not silently drop a registration. |
MM_ASSERT_NO_BUILTIN_OVERFLOW¶
Assert a host's builtin table did not silently drop a registration.