Home /Modules/sldocument/SLDocumentResult.sleela

SLDocumentResult.sleela

lib/sldocument/SLDocumentResult.sleela · 104 line(s) · sleela

<< lib/sldocument/SLDocumentResult.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLDocumentResult, the ordered collection of per-step
     veritable-and-kind values produced by running an .sldocument top-down.
   
   The document's overall outcome is the composition of its steps: it is sound
   only when every step that ran was itself sound (veritable AND kind). The
   result also records where the first unsound step occurred so a national
   program with established order can see exactly where flow broke.
   
   Family: sldocument. Native VM/OS work crosses an explicit bridge. >>
#sleela 2.5
material;
< Unified SLeeLa standard-library front-end object. >
class SLDocumentResult {
  < ---- 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 = 10073;
  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;

  < one per step, in run order >
  SLVeritable[] values;
  < the step name for each value >
  String[] names;
  int count;
  < index of the first unsound step, or -1 >
  int firstUnsound;
  int state;

  void init() {
    values = new SLVeritable[MAX_STEPS];
    names = new String[MAX_STEPS];
    count = 0;
    firstUnsound = -1;
    state = 1;
  }

  void record(String stepName, SLVeritable v) {
    if (count >= MAX_STEPS) { return; }
    values[count] = v;
    names[count] = stepName;
    if (firstUnsound < 0 && (v == null || !v.sound())) { firstUnsound = count; }
    count = count + 1;
  }

  int size() { return count; }
  boolean active() { return state == 1; }

  < The document is sound when every recorded step was sound. >
  boolean sound() { return state == 1 && count > 0 && firstUnsound < 0; }
  int firstFault() { return firstUnsound; }

  SLVeritable at(int index) {
    if (index < 0 || index >= count) { return null; }
    return values[index];
  }

  < The final binary item of the whole document: the last step's bit, which in >
  < an ordered program is the established "final result" of the flow. >
  int finalBit() {
    if (count < 1) { return 0; }
    SLVeritable last = values[count - 1];
    return last == null ? 0 : last.bit();
  }
}