SLDocument.sleela
lib/sldocument/SLDocument.sleela · 154 line(s) · sleela
<< lib/sldocument/SLDocument.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLDocument, an ordered .sldocument whose annotated method
steps run top-down and are compiled against and with standard SLeeLa source.
An .sldocument is a document, not a free script: its order is already
established, so running it is a matter of flow and architecture rather than
control plumbing. These documents suit tasks more sophisticated than bash
scripting, and clear "national program" work where the sequence A..Z is
settled in advance.
Running the document:
1. steps are arranged by effective order (explicit @order, else top-down);
2. each step is invoked in that order and its single binary veritable value
is recorded;
3. by default the document stops at the first unsound step (fail-closed),
because an ordered program should not proceed past a broken step; this
may be relaxed with permitContinue() to record every step.
Family: sldocument. Native VM/OS work crosses an explicit bridge. >>
#sleela 2.5
material;
< Unified SLeeLa standard-library front-end object. >
class SLDocument {
< ---- 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 = 10068;
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-05";
< 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 MAX_STEPS = 65536;
String title;
< the declared #sldocument version, e.g. "1.0" >
String version;
SLDocumentStep[] steps;
int count;
< VM frame the steps execute against >
int frame;
< false = stop at first unsound step >
boolean continueOnUnsound;
SLDocumentResult result;
int state;
String lastError;
void init(String docTitle, String docVersion, int vmFrame) {
title = docTitle;
version = docVersion;
steps = new SLDocumentStep[MAX_STEPS];
count = 0;
frame = vmFrame;
continueOnUnsound = false;
result = new SLDocumentResult();
result.init();
state = 0;
lastError = "";
}
void permitContinue() { continueOnUnsound = true; }
< Add a step in textual (top-down) order. The textual position becomes the >
< step's order unless the annotation carries an explicit @order. >
boolean addStep(SLDocumentAnnotation annotation) {
if (count >= MAX_STEPS) { lastError = "document full"; return false; }
SLDocumentStep s = new SLDocumentStep();
s.configure(annotation, count + 1, frame);
steps[count] = s;
count = count + 1;
return true;
}
boolean valid() {
if (count < 1) { lastError = "empty document"; return false; }
return true;
}
void enable() { if (valid()) { state = 1; } }
void disable() { state = 0; }
boolean active() { return state == 1 && valid(); }
int size() { return count; }
< Arrange steps by effective order so the run is strictly top-down/ascending. >
void arrange() {
for (int i = 0; i < count; i = i + 1) {
for (int j = i + 1; j < count; j = j + 1) {
if (steps[j].order() < steps[i].order()) {
SLDocumentStep tmp = steps[i];
steps[i] = steps[j];
steps[j] = tmp;
}
}
}
}
< Run the document top-down. Returns the result collection. >
SLDocumentResult run() {
if (!active()) { return result; }
arrange();
for (int i = 0; i < count; i = i + 1) {
SLVeritable v = steps[i].invoke();
result.record(steps[i].name(), v);
if (!continueOnUnsound) {
< stop at first unsound >
if (v == null || !v.sound()) { return result; }
}
}
return result;
}
< The whole document's single binary item: sound and final-bit together. >
SLVeritable outcome() {
SLVeritable v = new SLVeritable();
v.configure(result.sound(), result.sound(), title);
return v;
}
SLDocumentResult results() { return result; }
}