SLVmConfig.sleela
lib/vm/src/sleela/SLVmConfig.sleela · 143 line(s) · sleela
<< lib/vm/src/sleela/SLVmConfig.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVmConfig — the OOD equivalent of the native user-level
VM configuration surface (virtual-machine/vm-version/001/vm_config.{h,c},
VM v001). It is the single place a user tunes a selected VM before start:
the memory limit (256 MiB..2 GiB, 0 = manager off), the thread cap (1..128),
the report verbosity, and the capability mask. The native side binds these
fields to the sleela_memmgr limit and the bridge capability gate; on the
Sleela side this class is the loadable record a user edits in setup or a
conference and that the native VM reads when it boots the chosen VM.
Mirrors: struct VmConfig { memory_limit_bytes; thread_cap; verbosity;
capabilities; memory_manager_on }, enums VmVerbosity and VmCapability.
Family: vm. A data+policy record; composed by SLVmVersion* manifests and
applied through SLVmRuntime. Native application crosses the SLVMNativeBinding
VM-exit seam (never a direct C call). >>
#sleela 2.5
material;
class SLVmConfig {
< ---- 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 = 11284;
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; }
< Verbosity ordinals (mirror VmVerbosity). >
static final int VERBOSITY_QUIET = 0;
static final int VERBOSITY_NORMAL = 1;
static final int VERBOSITY_VERBOSE = 2;
static final int VERBOSITY_DEBUG = 3;
< Capability bits (mirror VmCapability; OR together). >
static final int CAP_MEMORY = 1;
static final int CAP_FILE_IO = 2;
static final int CAP_NETWORK = 4;
static final int CAP_THREADS = 8;
static final int CAP_DYNLIB = 16;
static final int CAP_TERMINAL = 32;
static final int CAP_PATHS = 64;
static final int CAP_PROCESS = 128;
static final int CAP_IPC = 256;
static final int CAP_TIME = 512;
< 0x3FF >
static final int CAP_ALL = 1023;
< Bounds (mirror the native #defines). >
static final int MIN_MEMORY_MIB = 256;
static final int MAX_MEMORY_MIB = 2048;
static final int MAX_THREADS = 128;
< ---- the configuration (mirror struct VmConfig) ---- >
< 256..2048; 0 = manager off >
int memoryLimitMiB;
< 1..128 >
int threadCap;
< VERBOSITY_* >
int verbosity;
< CAP_* bitset >
int capabilities;
< 1/0 >
int memoryManagerOn;
< Sensible default: 2 GiB, 128 threads, NORMAL, all caps, manager on. >
void defaults() {
memoryLimitMiB = MAX_MEMORY_MIB;
threadCap = MAX_THREADS;
verbosity = VERBOSITY_NORMAL;
capabilities = CAP_ALL;
memoryManagerOn = 1;
}
< Clamping setters (mirror vm_config_set_*). >
void setMemoryMiB(int mib) {
if (mib == 0) { memoryManagerOn = 0; memoryLimitMiB = 0; return; }
if (mib < MIN_MEMORY_MIB) { mib = MIN_MEMORY_MIB; }
if (mib > MAX_MEMORY_MIB) { mib = MAX_MEMORY_MIB; }
memoryLimitMiB = mib;
memoryManagerOn = 1;
}
void setThreads(int n) {
if (n < 1) { n = 1; }
if (n > MAX_THREADS) { n = MAX_THREADS; }
threadCap = n;
}
void setVerbosity(int v) {
if (v < VERBOSITY_QUIET) { v = VERBOSITY_QUIET; }
if (v > VERBOSITY_DEBUG) { v = VERBOSITY_DEBUG; }
verbosity = v;
}
void enable(int cap) {
< set the bit without bitwise-or (surface has no '|'): add if not already set. >
if ((capabilities / cap) % 2 == 0) { capabilities = capabilities + cap; }
}
void disable(int cap) {
< clear the bit without a bitwise-not (surface has no ~): subtract if set. >
if ((capabilities / cap) % 2 == 1) { capabilities = capabilities - cap; }
}
boolean has(int cap) { return (capabilities / cap) % 2 == 1; }
String verbosityName() {
if (verbosity == VERBOSITY_QUIET) { return "quiet"; }
if (verbosity == VERBOSITY_VERBOSE) { return "verbose"; }
if (verbosity == VERBOSITY_DEBUG) { return "debug"; }
return "normal";
}
}