Skip to content

Source: MoonLiveCompiler.h

MoonLiveCompiler

Source text to tokens to AST to IR, and then to native code through the per-ISA assembler.

Enumerations

Name Description
RetType What a function hands back, where void is the default an acting entry point declares.

RetType

enum RetType

What a function hands back, where void is the default an acting entry point declares.

Value Description
Void
Int
Str

Typedefs

Return Name Description
size_t(*)(IrProgram &, uint8_t *, size_t, const RegBudget *) LowerFn Compile source to machine code in out, resolving calls against table.

LowerFn

using LowerFn = size_t(*)(IrProgram &, uint8_t *, size_t, const RegBudget *)

Compile source to machine code in out, resolving calls against table.

Functions

Return Name Description
CompileResult compileSource
uint32_t countTokens Tokens in source, which is what both right-sized buffers derive from.

compileSource

CompileResult compileSource(const char * source, const BuiltinTable & table, const SysVarTable & sysvars, uint8_t * out, size_t cap, const RegBudget * squeeze = nullptr, LowerFn lower = nullptr, char * strings = nullptr, uint16_t stringCap = 0)

countTokens

uint32_t countTokens(const char * source)

Tokens in source, which is what both right-sized buffers derive from.

Variables

Return Name Description
constexpr const char * kCodegenFailed constexpr
constexpr const char * kSpillRefused constexpr
constexpr uint8_t kMaxEntryPoints constexpr How many named functions one script may define.
constexpr uint8_t kMaxEntryName constexpr Longest function name the engine keeps.
constexpr size_t kMaxClassName constexpr Longest class name kept, which a diagnostic quotes.

kCodegenFailed

constexpr

constexpr const char * kCodegenFailed = "codegen failed (unsupported on this target, or too large)"

kSpillRefused

constexpr

constexpr const char * kSpillRefused = "codegen failed: too many live values for this chip's registers"

kMaxEntryPoints

constexpr

constexpr uint8_t kMaxEntryPoints = 8

How many named functions one script may define.


kMaxEntryName

constexpr

constexpr uint8_t kMaxEntryName = 23

Longest function name the engine keeps.


kMaxClassName

constexpr

constexpr size_t kMaxClassName = 31

Longest class name kept, which a diagnostic quotes.

CompileResult

struct CompileResult
src/core/moonlive/MoonLiveCompiler.h:50

Public Attributes

bool ok = false : Whether the compile succeeded.

const char * error = "" : A static diagnostic when the compile failed.

uint16_t errorCol = 0 : The 1-based column the diagnostic points at, or 0.

size_t len = 0 : How many bytes of machine code were emitted.

DeclaredControl members

uint8_t memberCount = 0 : How many members the class declared.

uint16_t stringLen = 0 : How much of the string pool is used.

char className = ""

EntryPoint entries

uint8_t entryCount = 0 : How many named functions the script defined.

Public Static Attributes

constexpr uint16_t kStringPool = 128 : Bytes of string-literal storage the engine holds.

EntryPoint

struct EntryPoint
src/core/moonlive/MoonLiveCompiler.h:30

Public Attributes

const char * name = nullptr : into the source, or the engine's own copy after compile

uint8_t nameLen = 0 : How many characters of name are used.

uint16_t offset = 0 : byte offset of its first instruction within the block

RetType ret = RetType::Void : What this function returns, as the script declared it.

More info

The grammar is a statement calling a host-registered function with expression arguments, so any argument may be a literal or a nested call.

The compiler is neutral by construction: it knows the language and resolves call names against the injected table. Owning no function names and no domain semantics, it leaves the backend lowering a generic call or a generic inline op.