lmcode-java-sample reference

Reference tables for the lmcode-java-sample (Java 21 (JVM & GraalVM Native Image)) type conversions, 45 Shop/Ledger domain signatures, CLI protocol flags, and exit codes.

Host language type conversions

lmcode typeHost representationBoundary rule
intlong (Value.asInt / Value.ofInt)Signed 64-bit two's-complement wrapping via Java long operators
floatdouble (Value.asFloat / Value.ofFloat)IEEE-754 binary64 formatted with Formatting.formatG15
boolboolean (Value.asBool / Value.ofBool)Strict boolean value
stringVmString (Value.asString / Value.ofString)Immutable byte[] wrapper serialized via Reports.escapeBytes without UTF-16 corruption
Money / Items / Shop / LedgerObject (Value.object)Arena-retained Java object references compared by identity
voidValue.none()Value.Kind.NONE pushing nothing onto the VM stack

Shop and Ledger host schema signatures

Canonical signatureKindDescription
context shop: ShopContext objectShop domain root owning three initial priced items (125, 250, 375 cents)
context ledger: LedgerContext objectLedger domain root recording Money entries and raw byte notes
enum CurrencyUSD | EURCurrency enumeration passed across the host boundary as member spelling strings
interface Adjuster(Money) -> voidSAM interfaceRule entry interface for in-place item adjustment (case 067)
interface Score(Money) -> intSAM interfaceRule entry interface for @item and @total host-dispatched scoring (cases 068-069)
fn fee(int) -> intHost functionPure host fee computation helper
fn money(int) -> MoneyHost function / conversionConstruct a Money handle in signed int64 cents (also declared int -> Money conversion)
fn money(float) -> MoneyHost function overloadConstruct a Money handle from finite currency units rounded half away from zero to cents
fn host_null() -> MoneyHost functionReturn a typed null Money sentinel handle for boundary verification
fn sample_tmp() -> stringHost functionReturn the isolated SAMPLE_TMP scratch directory path
method Money.amount() -> intHost methodReturn signed int64 cents stored in this Money handle
method Money.currency() -> CurrencyHost methodReturn the Currency enum member (such as USD) for this Money handle
method Money.set(int) -> MoneyHost method (returns: self)Update cents in place and return the same Money receiver handle
method Money.plus(Money) -> MoneyOperator +Allocate a Money handle with wrapped int64 sum of cents
method Money.minus(Money) -> MoneyOperator -Allocate a Money handle with wrapped int64 difference of cents
method Money.times(int) -> MoneyOperator *Allocate a Money handle with wrapped int64 product of cents
method Money.neg() -> MoneyUnary operator -Allocate a Money handle with wrapped int64 negated cents
method Shop.items() -> ItemsHost methodReturn the shop Items collection handle
method Shop.total() -> MoneyHost methodReturn a Money handle with the sum of all current shop items
method Items.len() -> intCollection protocolReturn item count to enable for (item in shop.items()) loops
method Items.at(int) -> MoneyCollection protocolReturn the existing Money handle at index preserving pointer/handle identity
method Ledger.record(Money) -> LedgerHost method (returns: self)Append a Money amount to the ledger and return the Ledger receiver
method Ledger.note(string) -> voidHost methodAppend a raw byte string note to the ledger
method Ledger.balance() -> MoneyHost methodReturn the current ledger balance as a Money handle
method Ledger.count() -> intHost methodReturn the number of recorded ledger entries

Structured error codes and exit statuses

Error codePhaseExit statusTrigger condition
LOAD_BAD_BYTECODEload3Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation
LOAD_BAD_SCHEMAload3Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract
LOAD_SCHEMA_MISMATCHload332-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes
LOAD_UNBOUNDload3Bytecode imports a context, function, or method signature not registered in the host Registry
RUN_ERRORrun3VM division or remainder by zero
RUN_HOSTrun3Host callback failure, invalid encoding, or expired collection handle
APP_FAILapp4Post-run application domain validation failure