SLVMModule.sleela
lib/vm/SLVMModule.sleela · 198 line(s) · sleela
<< lib/vm/SLVMModule.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVMModule โ a loaded unit of code and types in the
secondary Sleela VM: the id->SLVMClass table for the types it declares, an
entry class/method to begin execution, and the shared SLSleelaVM substrate
that actually holds and runs the 156 canonical opcodes those methods compile
to. A module is the granularity the loader (SLVMModuleLoader) resolves and
the linker (SleelaVMLinkingManager*) binds.
The module owns the substrate so every method in it executes against one code
store โ the same opcode stream the native engine (lib/cpu/SLSleelaVM)
interprets, which is what keeps the two VM layers behaviourally identical.
Family: vm. Composes SLVMClass, SLSleelaVM; composed by SLVM. >>
#sleela 2.5
material;
class SLVMModule {
< ---- 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 = 931;
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; }
String name;
< 0 unloaded, 1 loaded, 2 linked >
int state;
< the canonical-opcode engine shared by all methods >
SLSleelaVM substrate;
int classCount;
SLVMClass k0; SLVMClass k1; SLVMClass k2; SLVMClass k3;
SLVMClass k4; SLVMClass k5; SLVMClass k6; SLVMClass k7;
int entryClassId;
String entryMethod;
< Stated access semantics this module was compiled with (null until adopted >
< from the program image). When present, the VM realizes the System backdrop >
< and enforces role-gated resolution from it instead of guessing. >
SLAccessManifest access;
void configure(String moduleName, int codeCap, int stackCap, int globalCap) {
name = moduleName; state = 0;
substrate = new SLSleelaVM();
substrate.configure(codeCap, stackCap, globalCap);
classCount = 0; entryClassId = -1; entryMethod = "main";
access = null;
}
< Adopt the access manifest the compiled image carries, so the module honors >
< the stated public/private/protected semantics (exposed hop / local system / >
< integrity-guarded) rather than inferring them. >
void adoptAccess(SLAccessManifest manifest) { access = manifest; }
SLAccessManifest accessManifest() { return access; }
boolean hasAccess() { return access != null; }
boolean accessCompetent() { return access != null && access.competent(); }
< Append one canonical opcode to the shared code store; returns its index so >
< methods can be configured with (entry,length) windows. >
int emit(int opcode, int arg) { return substrate.emit(opcode, arg); }
int codeLength() { return substrate.programLength(); }
void addClass(SLVMClass k) {
if (classCount == 0) { k0 = k; }
else if (classCount == 1) { k1 = k; }
else if (classCount == 2) { k2 = k; }
else if (classCount == 3) { k3 = k; }
else if (classCount == 4) { k4 = k; }
else if (classCount == 5) { k5 = k; }
else if (classCount == 6) { k6 = k; }
else if (classCount == 7) { k7 = k; }
if (classCount < 8) { classCount = classCount + 1; }
}
SLVMClass classIndex(int index) {
if (index == 0) { return k0; }
if (index == 1) { return k1; }
if (index == 2) { return k2; }
if (index == 3) { return k3; }
if (index == 4) { return k4; }
if (index == 5) { return k5; }
if (index == 6) { return k6; }
if (index == 7) { return k7; }
return null;
}
< Look a class up by the id stored in object headers. >
SLVMClass classById(int id) {
int i = 0;
while (i < classCount) {
SLVMClass k = classIndex(i);
if (k != null && k.id() == id) { return k; }
i = i + 1;
}
return null;
}
SLVMClass classByName(String className) {
int i = 0;
while (i < classCount) {
SLVMClass k = classIndex(i);
if (k != null && k.className() == className) { return k; }
i = i + 1;
}
return null;
}
< Resolve a method with a superclass walk using the module's class table. >
SLVMMethod resolveMethod(int classId, String methodName) {
int cid = classId;
while (cid >= 0) {
SLVMClass k = classById(cid);
if (k == null) { return null; }
SLVMMethod mm = k.resolveMethod(methodName);
if (mm != null) { return mm; }
cid = k.superclass();
}
return null;
}
< Resolve a method the way the network sees it: only an exposed (public) hop >
< binds. This is the module-level enforcement point for "a network of files >
< may assume a public function is reachable" โ private/protected do not bind. >
SLVMMethod resolveExposedMethod(int classId, String methodName) {
int cid = classId;
while (cid >= 0) {
SLVMClass k = classById(cid);
if (k == null) { return null; }
SLVMMethod mm = k.resolveExposedMethod(methodName);
if (mm != null) { return mm; }
cid = k.superclass();
}
return null;
}
< Resolve on behalf of a caller with a known role (local/in-system callers can >
< reach private/protected; a network/exposed caller cannot). >
SLVMMethod resolveMethodForCaller(int classId, String methodName, int callerRole) {
int cid = classId;
while (cid >= 0) {
SLVMClass k = classById(cid);
if (k == null) { return null; }
SLVMMethod mm = k.resolveMethodForCaller(methodName, callerRole);
if (mm != null) { return mm; }
cid = k.superclass();
}
return null;
}
void setEntry(int classId, String methodName) { entryClassId = classId; entryMethod = methodName; }
void load() { state = 1; }
void link() { if (state >= 1) { state = 2; } }
String moduleName() { return name; }
SLSleelaVM engine() { return substrate; }
int classes() { return classCount; }
int entryClass() { return entryClassId; }
String entryName() { return entryMethod; }
boolean loaded() { return state >= 1; }
boolean linked() { return state == 2; }
boolean active() { return state >= 1; }
}