SLVMValue.sleela
lib/vm/SLVMValue.sleela · 100 line(s) · sleela
<< lib/vm/SLVMValue.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVMValue — a single tagged runtime value in the secondary
Sleela VM. Every operand on a frame's stack, every field slot, and every
local is an SLVMValue: a 2-word pair of (tag, payload). The tag says how to
read the payload; the payload is either an inline scalar (int/bool/char) or
a heap handle (object/string/array reference) into SLVMHeap.
This is the atom the whole secondary VM manipulates. Keeping it a flat
(tag,payload) pair means values can live uniformly in SLRAM-backed stacks and
heaps without the SLeeLa surface needing arrays of structs.
Family: vm. Composed by SLVMFrame, SLVMObject, SLVMHeap. >>
#sleela 2.5
material;
class SLVMValue {
< ---- 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 = 936;
String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-09-28";
< 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; }
< Type tags. NULL is the canonical empty reference. >
static final int TAG_NULL = 0;
static final int TAG_INT = 1;
static final int TAG_BOOL = 2;
static final int TAG_CHAR = 3;
< payload is a heap handle (object/array) >
static final int TAG_REF = 4;
< payload is a heap handle to a string blob >
static final int TAG_STR = 5;
int tag;
int payload;
void setNull() { tag = TAG_NULL; payload = 0; }
void setInt(int v) { tag = TAG_INT; payload = v; }
void setBool(boolean b) { tag = TAG_BOOL; payload = b ? 1 : 0; }
void setChar(int c) { tag = TAG_CHAR; payload = c; }
void setRef(int handle) { tag = TAG_REF; payload = handle; }
void setStr(int handle) { tag = TAG_STR; payload = handle; }
int type() { return tag; }
int raw() { return payload; }
int asInt() { return payload; }
boolean asBool() { return payload != 0; }
int asHandle(){ return payload; }
boolean isNull() { return tag == TAG_NULL; }
boolean isScalar() { return tag == TAG_INT || tag == TAG_BOOL || tag == TAG_CHAR; }
boolean isReference() { return tag == TAG_REF || tag == TAG_STR; }
< Truthiness used by control-flow opcodes (JMPF): null and 0 are false. >
boolean truthy() {
if (tag == TAG_NULL) { return false; }
return payload != 0;
}
< Pack/unpack the (tag,payload) pair as a single word so a value can be >
< stored in one SLRAM slot when a frame stack is laid out two words apart. >
int packedTag() { return tag; }
int packedPayload() { return payload; }
void unpack(int t, int p) { tag = t; payload = p; }
}