lmcode-csharp-sample reference

Reference tables for the lmcode-csharp-sample (C# (.NET 8)) type conversions, 45 Shop/Ledger domain signatures, CLI protocol flags, and exit codes.

Host language type conversions

lmcode typeHost representationBoundary rule
intlong (Value.AsInt)Checked/unchecked signed 64-bit wrapping arithmetic
floatdouble (Value.AsFloat)Invariant G15 trace formatting and shortest round-trip JSON result formatting
boolbool (Value.AsBool)Strict boolean without numeric coercion
stringVmString (Value.AsStr)Immutable ReadOnlySpan<byte> preserving raw note bytes and invalid UTF-8
Money / Items / Shop / LedgerObjRef + Context.Get<T>Typed handles stored in the per-invocation Context arena
voidValue.NoneDistinct from a null JSON result payload

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 sample_tmp() -> stringHost functionReturn the isolated SAMPLE_TMP scratch directory path (opted into dry-mode preview)
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 runtime error such as division or remainder by zero
RUN_HOSTrun3Host callback failure, invalid encoding, or expired collection handle
APP_FAILapp4Post-run application domain validation failure or output stream write failure