<< lib/opcodes/SLOpcodeBase.sleela SLeeLa Standard Library Definition. Definition: Defines SLOpcodeBase, the shared base of every single-opcode class in the /lib/opcodes family. Contract — "call the VM to the next instruction, then execute one opcode": Each concrete opcode class carries exactly ONE opcode (its canonical code and mnemonic). Its step() does two things, in order: 1. advance() — carefully ask the VM to move the instruction pointer to the next instruction (the fetch), crossing the explicit VM/OS bridge; then 2. fire() — execute precisely this one opcode against the live VM frame. The return of step() is the VM's next-instruction pointer, so a driver can chain opcode objects in verbatim program order, each handing control to the next. This mirrors the canonical native dispatch loop in impl/core/sleela_core.c (`SLInstr in = vm->code[ip++]; switch (in.op) { ... }`): the ip is advanced as part of the fetch, then the single decoded op executes. The /lib/opcodes classes are the SLeeLa-source face of that one-op-at-a-time discipline. Family: opcodes. Native VM/OS work crosses an explicit bridge. >> #sleela 2.5 material; < Unified SLeeLa standard-library front-end object. > class SLOpcodeBase { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10183; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-05"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } < codes 0..155; 0..97 are the base 98, 98..102 the array extension, > < 103..155 the OS/GC/idea-canvas/tail/OSLS groups (the full canonical ISA) > static final int CANONICAL_COUNT = 156; < canonical opcode number, 0..155 > int code; < canonical mnemonic, e.g. "OP_ADD" > String mnemonic; < 0 = idle, 1 = armed > int state; < number of times this single opcode has executed > int fired; void configure(int opcodeCode, String opcodeMnemonic) { code = opcodeCode; mnemonic = opcodeMnemonic; state = 1; fired = 0; } void arm() { state = 1; } void disarm() { state = 0; } boolean armed() { return state == 1; } int opcode() { return code; } String name() { return mnemonic; } int fireCount() { return fired; } < Step 1 of the contract: carefully move the VM to the next instruction. > < Returns the VM's resulting instruction-pointer. The VM owns the pointer; > < this only requests the advance across the bridge. > int advance(int frame) { if (!armed()) { return -1; } return native sleela_opcode_vm_next(frame); } < Step 2 of the contract: execute THIS single opcode against the VM frame at > < the pointer produced by advance(). Concrete classes rely on this base entry; > < the native side dispatches exactly `code` and nothing else. > int fire(int frame, int ip) { if (!armed()) { return -1; } fired = fired + 1; return native sleela_opcode_execute_one(frame, code, ip); } < The full ordered contract: next-instruction fetch, then single execute. > < Returns the next instruction pointer for the following opcode object. > int step(int frame) { int ip = advance(frame); if (ip < 0) { return -1; } return fire(frame, ip); } }