SLVmRuntime.sleela
lib/vm/src/sleela/SLVmRuntime.sleela · 143 line(s) · sleela
<< lib/vm/src/sleela/SLVmRuntime.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVmRuntime โ the OOD equivalent of the native
consolidated facade (virtual-machine/vm-version/010/vm_runtime.{h,c}, v010).
It composes the whole hardened VM โ config, report, status, memory, result,
telemetry, gc, profile, capability, platform, audit โ and wires them in
dependency order behind a four-call surface: init / poll / permit / report
/ shutdown. This is the Sleela object a VM selection resolves to: the native
VM holds this record in memory after loading the chosen version's .sleela
and uses it to configure and observe the loaded C/C++ VM.
Mirrors: VM_RUNTIME_VERSION, vm_runtime_init/register_table/poll/permit/
note/report/shutdown.
Family: vm. Composes SLVmConfig, SLVmReport, SLVmStatus, SLVmMemory,
SLVmResult, SLVmTelemetry, SLVmGc, SLVmProfile, SLVmCapability,
SLVmPlatform, SLVmAudit. Native effects route via SLVMNativeBinding. >>
#sleela 2.5
material;
class SLVmRuntime {
< ---- 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 = 11290;
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; }
< e.g. "idea-vm v010 (consolidated)" >
String versionString;
SLVmConfig config;
SLVmReport report;
SLVmStatus status;
SLVmMemory memory;
< a reusable scratch result >
SLVmResult result;
SLVmTelemetry telemetry;
SLVmGc gc;
SLVmProfile profile;
SLVmCapability capability;
SLVmPlatform platform;
SLVmAudit audit;
< 0 down, 1 running >
int up;
< init in dependency order (mirror vm_runtime_init). >
void init(SLVmConfig cfg, String version) {
versionString = version;
config = cfg;
report = new SLVmReport(); report.bind(cfg);
status = new SLVmStatus(); status.bind(version, cfg);
memory = new SLVmMemory(); memory.defaults();
result = new SLVmResult(); result.ok();
telemetry = new SLVmTelemetry();telemetry.init();
gc = new SLVmGc(); gc.init();
profile = new SLVmProfile(); profile.init();
capability = new SLVmCapability(); capability.bind(cfg);
platform = new SLVmPlatform(); platform.init(0, "", "");
audit = new SLVmAudit(); audit.init();
audit.log(1, "runtime",
"init: " + cfg.memoryLimitMiB + " MiB, " + cfg.threadCap
+ " threads, verbosity=" + cfg.verbosityName(), report);
up = 1;
}
< register a bounded-table capacity for saturation watching. >
void registerTable(int table, int capacity) {
if (telemetry != null) { telemetry.setCapacity(table, capacity); }
}
< periodic health sample: memory pressure (+ gc if fresh stats supplied). >
void poll(int gcAllocated, int gcReclaimed, int gcCollections, boolean haveGc) {
if (up == 0) { return; }
int m = memory.poll(report);
if (m == 2 || m == 3) {
audit.log(1, "memory", "condition=" + memory.conditionName(m), report);
}
if (haveGc) {
int g = gc.observe(gcAllocated, gcReclaimed, gcCollections, result, report);
if (g == 1 || g == 3) {
audit.log(1, "gc", gc.conditionName(g), report);
}
}
}
< guard a native operation by capability; records a denial to the trail. >
boolean permit(int cap, String subsystem, String operation) {
if (capability.check(cap, subsystem, operation, result, report, telemetry)) { return true; }
audit.logResult(result, report);
return false;
}
< the status banner + totals (mirror the consolidated report). >
void reportStatus() {
status.banner();
print("telemetry: steps=" + telemetry.steps + " allocs=" + telemetry.allocs
+ " bridge=" + telemetry.bridge + " errors=" + telemetry.errors);
print("audit: " + audit.totalEvents() + " events (chain " + audit.chain() + ")");
}
void shutdown() {
if (up == 0) { return; }
audit.log(0, "runtime",
"shutdown: " + telemetry.steps + " steps, " + telemetry.errors + " errors", report);
up = 0;
}
}