SLVMNativeBinding.sleela
lib/vm/SLVMNativeBinding.sleela · 92 line(s) · sleela
<< lib/vm/SLVMNativeBinding.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVMNativeBinding — the controlled seam where a method of
the secondary Sleela VM crosses to the native engine. A binding names a
native service (by symbol and by a canonical OS/service opcode from the
156-opcode ISA) and records its arity. When the VM dispatches a native
method it invokes the binding, which parks a VM-exit the host services —
exactly the mechanism lib/cpu/SLSleelaVM uses in hosted mode.
This keeps "native work crosses an explicit bridge" (the vm-family rule)
concrete: nothing in the secondary VM calls C directly; it goes through a
named, arity-checked binding that the hypervisor/OS can audit.
Family: vm. Composed by SLVM; mirrors lib/cpu VM-exit routing. >>
#sleela 2.5
material;
class SLVMNativeBinding {
< ---- 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 = 933;
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; }
< e.g. "sleela_vm_print_int" >
String symbol;
< canonical OP_* this binding fronts (-1 if pure native) >
int serviceOpcode;
< operands consumed >
int arity;
< 1 once resolved against the native table >
int bound;
int lastResult;
void configure(String nativeSymbol, int opcode, int args) {
symbol = nativeSymbol; serviceOpcode = opcode; arity = args; bound = 0; lastResult = 0;
}
void resolve() { bound = 1; }
String nativeSymbol() { return symbol; }
int opcode() { return serviceOpcode; }
int argCount() { return arity; }
boolean resolved() { return bound == 1; }
< Front the native call by parking a VM-exit on the substrate. The host reads >
< exitReasonOpcode()/exitReasonPayload(), performs the real work, and resumes >
< with pushResult(). payload is the primary argument (e.g. char to print). >
int invoke(SLSleelaVM substrate, int payload) {
if (bound == 0) { return -1; }
substrate.setHosted();
substrate.parkExit(serviceOpcode, 0, payload);
return serviceOpcode;
}
void recordResult(int value) { lastResult = value; }
int result() { return lastResult; }
}