Home /Modules/vm/SLVmStatus.sleela

SLVmStatus.sleela

lib/vm/src/sleela/SLVmStatus.sleela · 91 line(s) · sleela

<< lib/vm/src/sleela/SLVmStatus.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLVmStatus — the OOD equivalent of the native status
     readout (virtual-machine/vm-version/001/vm_status.{h,c}, v001): the
     "what am I running" banner that renders the VM version plus the applied
     configuration (memory, threads, verbosity, capabilities). It reads an
     SLVmConfig and prints a compact banner at NORMAL+ verbosity.
   
   Mirrors: VM_VERSION_STRING, vm_status_render/banner.
   
   Family: vm. Composes SLVmConfig. >>
#sleela 2.5
material;
class SLVmStatus {
  < ---- 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 = 11292;
  String metaAuthor = "unknown";
  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 = "unknown";
  < 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; }
  < e.g. "idea-vm v001 (ground floor)" >
  String versionString;
  SLVmConfig config;

  void bind(String version, SLVmConfig cfg) { versionString = version; config = cfg; }

  void banner() {
    if (config != null && config.verbosity == 0) { return; }
    print(versionString);
    if (config == null) { print("  (no configuration applied yet)"); return; }
    if (config.memoryManagerOn == 1 && config.memoryLimitMiB > 0) {
      print("  memory : " + config.memoryLimitMiB + " MiB (manager on)");
    } else {
      print("  memory : manager off");
    }
    print("  threads: " + config.threadCap + " (max " + 128 + ")");
    print("  verbose: " + config.verbosityName());
    print("  caps   : " + capsLine());
  }

  String capsLine() {
    String s = "";
    if (config.has(1))   { s = s + "mem "; }
    if (config.has(2))  { s = s + "io "; }
    if (config.has(4))  { s = s + "net "; }
    if (config.has(8))  { s = s + "thr "; }
    if (config.has(16))   { s = s + "dynlib "; }
    if (config.has(32)) { s = s + "term "; }
    if (config.has(64))    { s = s + "paths "; }
    if (config.has(128))  { s = s + "proc "; }
    if (config.has(256))      { s = s + "ipc "; }
    if (config.has(512))     { s = s + "time"; }
    return s;
  }
}