SLProgram.sleela
lib/cpu/SLProgram.sleela · 139 line(s) · sleela
<< lib/cpu/SLProgram.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLProgram — an executable image: a sequence of encoded
instructions plus an entry point and a name. A program is produced by the
assembler (SLAssembler), stored by the filesystem, loaded into memory by
SLProgramLoader, and run as a process on the Sleela CPU under the Sleela OS.
Instructions are staged into a backing SLRAM region at build time so the
loader can copy them to their final load address.
A program may also carry an SLTimingManifest — the stated timing/voltage/
expertise operating point the image was compiled for. When present, a
compiler or VM operates those DECLARED timings instead of assuming the
quality of the hardware ("rather than inherently to expect the quality of
these operating as confidences of how CPUs operate").
A program may likewise carry an SLAccessManifest — the stated meaning of its
public / private / protected members as system roles (exposed hop / local /
integrity-guarded), so the VM stands up a clean System backdrop from the
declared semantics instead of inferring a file-network topology.
Family: cpu. Composes SLInstruction, SLRAM, SLTimingManifest, SLAccessManifest. >>
#sleela 2.5
material;
class SLProgram {
< ---- 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 = 10272;
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-06";
< 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;
int entryPoint;
< instruction count >
int length;
< staging buffer holding the encoded words >
SLRAM image;
< stated operating point (null until attached) >
SLTimingManifest timing;
< stated access semantics (null until attached) >
SLAccessManifest access;
< Document-level memory tier: flags the WHOLE program with a default tier >
< (SLMemoryTierRouter.TIER_*): 0 none (accurate/DDR5 default), 1 usual (DDR2), >
< 2 accurate (DDR5). A method's own usualmem/accuratemem tier overrides this; >
< any method that declares no tier inherits this document default. This is >
< the "flag the entire document" lever; per-method flags handle any subset. >
int docMemTier;
void configure(String programName, int capacityWords) {
name = programName; entryPoint = 0; length = 0;
image = new SLRAM(); image.configure(capacityWords, 32); image.allocate();
timing = null; access = null; docMemTier = 0;
}
< Flag the entire document's default tier. `usualmem` on the program means >
< "everything is usual unless a method says otherwise"; likewise accurate. >
void setDocumentTier(int tier) { docMemTier = tier; }
int documentTier() { return docMemTier; }
< The EFFECTIVE tier for a method: the method's own tier when it declares one >
< (usualmem/accuratemem), else the document default, else accurate (2). >
int effectiveTier(int methodTier) {
if (methodTier == 1 || methodTier == 2) { return methodTier; }
if (docMemTier == 1 || docMemTier == 2) { return docMemTier; }
< accurate / DDR5 default >
return 2;
}
void setEntryPoint(int addr) { entryPoint = addr; }
< Attach the stated timing/voltage/expertise manifest this image was compiled >
< for. The loader and VM read it instead of inferring an operating point. >
void attachTiming(SLTimingManifest manifest) { timing = manifest; }
SLTimingManifest timingManifest() { return timing; }
boolean hasTiming() { return timing != null; }
< True only when the image declares an operating point AND that point was >
< sealed honored at compile time — the consumer may trust it as stated. >
boolean timingHonored() { return timing != null && timing.honored(); }
< Attach the stated access-semantics manifest (public/private/protected as >
< system roles). The VM reads it to stand up the System backdrop instead of >
< guessing a file-network topology. >
void attachAccess(SLAccessManifest manifest) { access = manifest; }
SLAccessManifest accessManifest() { return access; }
boolean hasAccess() { return access != null; }
< True only when the image declares access semantics AND they were sealed as >
< a competent backdrop the consumer may realize as stated. >
boolean accessCompetent() { return access != null && access.competent(); }
< Append one encoded instruction word to the image. >
int append(int encodedWord) {
image.writeWord(length, encodedWord);
int at = length;
length = length + 1;
return at;
}
int wordAt(int index) { return image.readWord(index); }
int size() { return length; }
int entry() { return entryPoint; }
String programName() { return name; }
}