Home /Modules/cpu/SLSystemCall.sleela

SLSystemCall.sleela

lib/cpu/SLSystemCall.sleela · 86 line(s) · sleela

<< lib/cpu/SLSystemCall.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLSystemCall — the system-call interface: the controlled
     doorway from user programs into the kernel. A user program issues the
     SYSCALL instruction with a call number; the CPU switches to supervisor mode
     and jumps to the kernel's syscall handler, which dispatches on the number.
     This class is the registry of call numbers and the dispatcher contract.
   
   Call numbers model a minimal POSIX-like surface: write, read, open, close,
   exit, spawn, yield.
   
   Family: cpu. Pure Sleela ABI definition. >>
#sleela 2.5
material;
class SLSystemCall {
  < ---- 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 = 10286;
  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; }
  static final int SYS_WRITE = 0;
  static final int SYS_READ  = 1;
  static final int SYS_OPEN  = 2;
  static final int SYS_CLOSE = 3;
  static final int SYS_EXIT  = 4;
  static final int SYS_SPAWN = 5;
  static final int SYS_YIELD = 6;
  static final int SYS_COUNT = 7;

  int calls;

  void configure() { calls = 0; }

  boolean valid(int number) { return number >= 0 && number < SYS_COUNT; }
  void count() { calls = calls + 1; }

  String nameOf(int number) {
    if (number == SYS_WRITE) { return "write"; }
    if (number == SYS_READ) { return "read"; }
    if (number == SYS_OPEN) { return "open"; }
    if (number == SYS_CLOSE) { return "close"; }
    if (number == SYS_EXIT) { return "exit"; }
    if (number == SYS_SPAWN) { return "spawn"; }
    if (number == SYS_YIELD) { return "yield"; }
    return "invalid";
  }

  int callCount() { return calls; }
}