Skip to main content

Module vm

Module vm 

Source
Expand description

Lua virtual machine — port of src/lvm.c (1899 lines, 32 functions).

This module implements:

  • Number coercion helpers (tonumber_, flttointeger, tointegerns, tointeger)
  • Numeric for-loop preparation and stepping (forlimit, forprep, floatforloop)
  • Table get/set with metamethod chaining (finishget, finishset)
  • String comparison respecting embedded NULs (l_strcmp)
  • Relational operators: lessthan, lessequal, equalobj (with metamethods)
  • String concatenation (concat)
  • Object length operator (objlen)
  • Integer arithmetic: idiv, mod, modf, shiftl
  • Closure creation (pushclosure)
  • Yield-resume bridge (finishOp)
  • Main interpreter loop (execute) — the Lua bytecode dispatch engine.

§Control flow note

The C source uses goto startfunc / goto returning / goto ret across labelled points in luaV_execute. These are modelled with Rust’s labelled loops ('startfunc, 'returning, 'dispatch) and continue/break on those labels. See inline PORT NOTE comments.

Enums§

OpCode
TODO(phase-b): lua-types does not yet expose OpCode. Stubbed locally with all 5.4 opcodes so call sites in vm.rs/debug.rs resolve; the real numeric values and per-opcode mode flags live in lua-types/src/opcode.rs once translated.

Traits§

InstructionExt
TODO(phase-b): Instruction accessor extension trait. The real per-mode decode helpers live in lua-types::opcode once translated. Stubbed locally so call sites resolve; bodies are inferred from lopcodes.h macro shapes.