SLVmSource.sleela
lib/vm/src/sleela/SLVmSource.sleela · 109 line(s) · sleela
<< lib/vm/src/sleela/SLVmSource.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVmSource โ the OOD equivalent of the native VM
source-requirement validator (lib/vm/src/sleela_vm_source.c). It records
the requirements a selected VM target must satisfy โ target kind (SLVM or
SLJVM), pointer width, memory/cpu/stack limits, ABI code, module count, and
a 128-bit feature mask โ and validates them before the native loader is
allowed to build and boot the chosen VM. This is the Sleela gate the VM
selector consults when a user chooses a non-native VM.
Mirrors: struct sleela_vm_requirements_t + sleela_vm_requirements_validate/
_plan_modules/_feature_enabled/_option_compatible (ABI: SLJVM=32, SLVM=30/31).
Family: vm. Consulted by SLVmVersion* manifests and SLVmRegistry. >>
#sleela 2.5
material;
class SLVmSource {
< ---- 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 = 11291;
String metaAuthor = "unknown";
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 = "unknown";
< 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; }
static final int KIND_SLVM = 0;
static final int KIND_SLJVM = 1;
int kind;
< 32 or 64 >
int pointerBits;
int memoryLimitMiB;
int cpuLimit;
int stackLimit;
< SLJVM=32; SLVM=30 or 31 >
int abiCode;
int moduleCount;
< bits 0..30 (surface int) >
int featureMaskLow;
< bits 31..61 >
int featureMaskHigh;
void configure(int k, int pbits, int memMiB, int cpu, int stack, int abi) {
kind = k; pointerBits = pbits; memoryLimitMiB = memMiB;
cpuLimit = cpu; stackLimit = stack; abiCode = abi;
moduleCount = 0; featureMaskLow = 0; featureMaskHigh = 0;
}
< validate (mirror sleela_vm_requirements_validate): kind + widths + ABI code. >
boolean validate() {
if (kind != KIND_SLVM && kind != KIND_SLJVM) { return false; }
if (pointerBits != 32 && pointerBits != 64) { return false; }
if (memoryLimitMiB <= 0 || cpuLimit <= 0 || stackLimit <= 0) { return false; }
if (kind == KIND_SLJVM) { return abiCode == 32; }
< SLVM >
return abiCode == 30 || abiCode == 31;
}
boolean planModules(int n) { if (n < 0) { return false; } moduleCount = n; return true; }
< feature bit 0..61 via the two halves. >
boolean featureEnabled(int bit) {
if (bit < 0 || bit > 61) { return false; }
if (bit <= 30) { return (featureMaskLow / pow2(bit)) % 2 == 1; }
return (featureMaskHigh / pow2(bit - 31)) % 2 == 1;
}
void setFeature(int bit) {
if (bit < 0 || bit > 61) { return; }
if (bit <= 30) { if (!featureEnabled(bit)) { featureMaskLow = featureMaskLow + pow2(bit); } }
else { if (!featureEnabled(bit)) { featureMaskHigh = featureMaskHigh + pow2(bit - 31); } }
}
int pow2(int n) { int v = 1; int i = 0; while (i < n) { v = v * 2; i = i + 1; } return v; }
String target() { return (kind == KIND_SLJVM) ? "SLJVM" : "SLVM"; }
}