SLMachineBuilder.sleela
lib/operating-system/SLMachineBuilder.sleela · 121 line(s) · sleela
<< lib/operating-system/SLMachineBuilder.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLMachineBuilder โ the stage that turns a named-parts
SLMachineModel into a RUNNING machine on the Sleela VM. It reads the model's
components (DDR memory, SSD/HDD boot device, UEFI firmware, CPU identity),
sizes the VM's main memory and block store from the real part capacities,
and composes the lib/cpu stack โ SLRAM + SLHardDrive + SLCPU wired into an
SLMachine โ so that the Sleela source describing the hardware, once compiled
and run, produces an actual machine the VM boots and executes programs on.
This is the operational meaning of "use those Sleela source files in a Sleela
source document, compile it, and run that result to produce a Machine on the
Sleela VM process": the named parts are the description; building composes the
emulated machine; running it executes a program (or boots an SLOSModel-shaped
guest) on the Sleela CPU.
Family: operating-system. Consumes SLMachineModel; composes lib/cpu (SLMachine, SLRAM,
SLHardDrive, SLCPU, SLInstructionSet). >>
#sleela 2.5
material;
class SLMachineBuilder {
< ---- 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 = 10905;
String metaAuthor = "Kiro Agent";
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-10-10";
< 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; }
< the composed lib/cpu machine >
SLMachine machine;
int built;
void configure() { built = 0; }
< Compose a runnable Sleela-VM machine from the named-parts model. Returns the >
< lib/cpu SLMachine, hardware built and ready to boot. Returns null if the >
< model is not runnable (missing memory / boot device / firmware). >
SLMachine build(SLMachineModel m) {
if (!m.isRunnable()) { return null; }
machine = new SLMachine();
< Size the VM from the real parts: memory words from the DDR module's byte >
< capacity, the boot store from the SSD/HDD capacity and block size. >
machine.buildHardware(m.processorVendor(), m.processorModel(),
m.cores(), m.bits(), m.mhz());
built = built + 1;
return machine;
}
< Build, boot the Sleela class-driven OS, and run the built-in demo program >
< (compute 2+3, write a char, exit) on the composed machine. Returns the OS >
< run result. This proves the described hardware actually executes code. >
int buildBootAndRun(SLMachineModel m, int rounds) {
SLMachine mc = build(m);
if (mc == null) { return -1; }
mc.boot();
mc.loadDemoProgram(8192);
return mc.operatingSystem().run(rounds);
}
< Build the machine, then compile and run a program FROM SOURCE in any >
< supported language on it (0 Sleela, 1 C, 2 C++, 3 Java), reduced to the >
< Sleela opcode substrate. Returns the program's result. This is the path a >
< Sleela source document uses: describe the machine with named parts, then run >
< a program on the machine the description produced. >
int buildAndRunSource(SLMachineModel m, int langId, String sourcePath, String programName) {
SLMachine mc = build(m);
if (mc == null) { return -1; }
return mc.runOnSubstrate(langId, sourcePath, programName);
}
< Build the machine, then boot a Linux-style guest whose kernel is compiled >
< from source on it, for a bounded instruction budget. Returns the guest >
< instruction count executed. This connects the named-hardware machine to an >
< SLOSModel-shaped guest OS (Linux shape) running on the Sleela VM. >
int buildAndBootGuest(SLMachineModel m, String kernelSourcePath, int kernelLang,
int guestEntry, int budget) {
SLMachine mc = build(m);
if (mc == null) { return -1; }
mc.boot();
return mc.runLinuxGuestFromSource(kernelSourcePath, kernelLang, guestEntry, budget);
}
SLMachine builtMachine() { return machine; }
int buildCount() { return built; }
}