Skip to content

Latest commit

 

History

History
123 lines (88 loc) · 4.69 KB

File metadata and controls

123 lines (88 loc) · 4.69 KB

Moonquakes v0.1.0 — First Crescent

Moonquakes enters its first stable phase.

This release defines the scope of the runtime core. It establishes the execution model, memory structure, and compilation pipeline that form the foundation of the system.

Scope of v0.1.0

v0.1.0 defines the core of Moonquakes:

  • A register-based virtual machine compatible with Lua 5.4 bytecode semantics
  • A non-moving mark-and-sweep garbage collector
  • Explicit separation of stack, heap, and host memory
  • Prototype-based compilation pipeline (lexer → parser → materialization)
  • _ENV modeled as a first-class upvalue
  • Protected calls with structured error unwinding

This version focuses on structural correctness. The VM executes Lua 5.4 source code through a clean-room implementation.

Opcodes

All 83 Lua 5.4 opcodes are implemented (MOVE through EXTRAARG, 0-82).

One extension opcode is added:

  • PCALL (100) — Protected call with structured error handling

Standard Library

Implemented

Library Functions
global _G, _VERSION, assert, collectgarbage, dofile, error, getmetatable, ipairs, load, loadfile, next, pairs, pcall, print, rawequal, rawget, rawlen, rawset, select, setmetatable, tonumber, tostring, type, warn, xpcall
string byte, char, dump, find, format, gmatch, gsub, len, lower, match, rep, reverse, sub, upper, pack, unpack, packsize
table concat, insert, move, pack, remove, sort, unpack
math abs, acos, asin, atan, ceil, cos, deg, exp, floor, fmod, huge, log, max, maxinteger, min, mininteger, modf, pi, rad, random, randomseed, sin, sqrt, tan, tointeger, type, ult
io close, flush, input, lines, open, output, popen, read, stdin, stdout, stderr, tmpfile, type, write
os clock, date, difftime, execute, exit, getenv, remove, rename, setlocale, time, tmpname
utf8 char, charpattern, codepoint, codes, len, offset
debug debug, gethook, getinfo, getlocal, getmetatable, getregistry, getupvalue, getuservalue, newuserdata, sethook, setlocal, setmetatable, setupvalue, setuservalue, traceback, upvalueid, upvaluejoin

Not Implemented

Library Status
coroutine Deferred to future release
package Not implemented

Metamethods

Implemented

Metamethod Description
__add, __sub, __mul, __div, __mod, __pow, __idiv Arithmetic
__unm Unary minus
__band, __bor, __bxor, __bnot, __shl, __shr Bitwise
__concat Concatenation
__len Length
__eq, __lt, __le Comparison
__index, __newindex Table access
__call Function call
__tostring String conversion
__close To-be-closed variables
__gc Garbage collection finalizer
__name Type name hint
__metatable Metatable protection
__pairs Custom pairs iteration

Not Implemented

Metamethod Status
__mode Weak tables deferred

Differences from Lua 5.4

Known Differences

Behavior Lua 5.4 Moonquakes v0.1.0
String coercion Supports 0x hex prefix, whitespace trimming Whitespace trimming only
Integer overflow Wrapping arithmetic Wrapping arithmetic (compatible)
NaN table keys Error Error (compatible)
Nil indexing Error Error (compatible)
debug.getinfo fields Full set Partial (source="?", currentline=-1, no name inference)

Structural Differences

  • No coroutine support (yield/resume not available)
  • Debug hooks do not fire (sethook/gethook API exists but hooks are not dispatched)
  • No weak table semantics (__mode ignored)
  • No package library (require/module system)
  • string.dump produces Moonquakes-specific format (not Lua bytecode)

What v0.1.0 Is Not

The following are intentionally outside the scope of this release:

  • Coroutine library
  • Public C API
  • Full debug metadata (line mapping, variable names, hook dispatch)
  • Incremental or generational garbage collection

These are reserved for future phases.

Design Position

v0.1.0 marks the point at which:

  • The execution model is internally consistent
  • The memory model is explicit and stable
  • The compiler and runtime are fully integrated
  • The system no longer depends on placeholder behavior

This release does not aim for completeness. It aims for structural integrity.

First Crescent

Memory has shape. Execution has meaning. The runtime exists.