Home /Modules/vm/SLVMMethod.sleela

SLVMMethod.sleela

lib/vm/SLVMMethod.sleela · 141 line(s) · sleela

<< lib/vm/SLVMMethod.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLVMMethod — one executable method in the secondary Sleela
     VM. A method is a window into its module's canonical-opcode code store
     (SLVMModule holds the SLSleelaVM substrate): an entry instruction index, a
     length, an argument count, and a local-slot count. Calling a method pushes
     an SLVMFrame sized to maxLocals and points the substrate's ip at entry.
   
   The method does not own code bytes itself — code lives once in the module's
   SLSleelaVM so every layer executes the same 156 canonical opcodes the native
   engine (lib/cpu/SLSleelaVM) interprets.
   
   A method also carries an access role (exposed-hop / local-system /
   integrity-guarded) under the extensible-network interpretation, so the VM can
   gate resolution by role and realize the per-role backdrop.
   
   Family: vm. Composed by SLVMClass; drives SLVMFrame + SLVMModule. >>
#sleela 2.5
material;
class SLVMMethod {
  < ---- 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 = 930;
  String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins";
  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-09-28";
  < 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; }
  String name;
  < e.g. "(II)I" style signature summary >
  String descriptor;
  < first opcode index in the module code store >
  int entry;
  < number of opcodes >
  int length;
  < operands popped from caller / consumed as params >
  int argCount;
  < local slots the frame must reserve >
  int maxLocals;
  boolean isStatic;
  < body is an SLVMNativeBinding instead of opcodes >
  boolean isNative;

  < Access role under the extensible-network interpretation (mirrors >
  < SLAccessSemantics.ROLE_*): 0 none, 1 exposed-hop (public), 2 local-system >
  < (private), 3 integrity-guarded (protected). This is the first VM-level >
  < access metadata on a method; resolveMethod gates on it (see SLVMClass). >
  int accessRole;

  < Memory tier this method runs against (SLMemoryTierRouter.TIER_*): >
  < 0 inherit (use the program/document default), 1 usual (DDR2), 2 accurate >
  < (DDR5). Set from the usualmem/accuratemem modifiers; the dispatcher uses it >
  < to pick the physical memory module the method binds to. >
  int memTier;

  void configure(String methodName, String sig, int entryIndex, int codeLength,
                 int args, int locals, boolean staticMethod, boolean nativeMethod) {
    configureAccess(methodName, sig, entryIndex, codeLength, args, locals,
                    staticMethod, nativeMethod, 0);
  }

  < Full form: also record the method's access role. The old configure() >
  < delegates here with role 0 (none), so existing callers are unchanged. >
  void configureAccess(String methodName, String sig, int entryIndex, int codeLength,
                       int args, int locals, boolean staticMethod, boolean nativeMethod,
                       int role) {
    name = methodName;
    descriptor = sig;
    entry = entryIndex;
    length = codeLength;
    argCount = args;
    maxLocals = locals;
    isStatic = staticMethod;
    isNative = nativeMethod;
    accessRole = role;
    memTier = 0;
  }

  void setAccessRole(int role) { accessRole = role; }
  void setMemTier(int tier)    { memTier = tier; }

  String methodName() { return name; }
  String signature()  { return descriptor; }
  int entryPoint()    { return entry; }
  int lastIndex()     { return entry + length; }
  int arity()         { return argCount; }
  int locals()        { return maxLocals; }
  boolean staticMethod(){ return isStatic; }
  boolean nativeMethod(){ return isNative; }

  < Role predicates for the resolve-time access gate. >
  int role()            { return accessRole; }
  < public  : REST-exposed >
  boolean exposedHop()  { return accessRole == 1; }
  < private : local/admin/safety >
  boolean localOnly()   { return accessRole == 2; }
  < protected: integrity-checked >
  boolean guarded()     { return accessRole == 3; }

  < Memory-tier accessors (SLMemoryTierRouter.TIER_*). >
  int tier()            { return memTier; }
  boolean usualTier()   { return memTier == 1; }
  boolean accurateTier(){ return memTier == 2; }

  < Does the given instruction index fall inside this method's code window? >
  boolean contains(int ip) { return ip >= entry && ip < entry + length; }
}