Home /Modules/sldocument/SLDocumentStep.sleela

SLDocumentStep.sleela

lib/sldocument/SLDocumentStep.sleela · 107 line(s) · sleela

<< lib/sldocument/SLDocumentStep.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLDocumentStep, one ordered step of an .sldocument — an
     annotated method that runs in top-down order and usually returns a single
     binary veritable-and-kind value.
   
   A step pairs an annotation (how it is named/ordered) with the method it
   invokes on the VM. When the document runs, each step is executed in order and
   its SLVeritable result is captured. The method body is ordinary compiled
   SLeeLa; the step is the document-level wrapper that records order and result.
   
   Family: sldocument. Native VM/OS work crosses an explicit bridge. >>
#sleela 2.5
material;
< Unified SLeeLa standard-library front-end object. >
class SLDocumentStep {
  < ---- 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 = 10074;
  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; }
  < how the step is named/ordered >
  SLDocumentAnnotation annotation;
  < resolved 1-based position in the run >
  int effectiveOrder;
  < VM frame the method is invoked against >
  int frame;
  < the single binary value the step returned >
  SLVeritable result;
  boolean ran;
  int state;

  void configure(SLDocumentAnnotation ann, int textualPosition, int vmFrame) {
    annotation = ann;
    < Explicit @order wins; otherwise the textual (top-down) position governs. >
    if (ann != null && ann.hasExplicitOrder()) { effectiveOrder = ann.orderValue(); }
    else { effectiveOrder = textualPosition; }
    frame = vmFrame;
    ran = false;
    state = 1;
  }

  void enable() { state = 1; }
  void disable() { state = 0; }
  boolean active() { return state == 1; }
  int order() { return effectiveOrder; }
  String name() { return annotation == null ? "" : annotation.method(); }

  < Invoke the step's method on the VM and capture its single binary result. >
  < The native side evaluates the compiled method and reports a 1 (veritable) >
  < or 0 (not), together with a kindness flag for well-formedness. >
  SLVeritable invoke() {
    SLVeritable v = new SLVeritable();
    if (!active() || annotation == null) {
      v.configure(false, false, name());
      result = v;
      ran = true;
      return v;
    }
    int bit = native sleela_sldocument_invoke(frame, annotation.method(), effectiveOrder);
    boolean kindFlag = native sleela_sldocument_kind(frame, annotation.method());
    v.configure(bit == 1, kindFlag, name());
    result = v;
    ran = true;
    return v;
  }

  boolean hasRun() { return ran; }
  SLVeritable value() { return result; }
}