SLFrontend.sleela
lib/cpu/SLFrontend.sleela · 94 line(s) · sleela
<< lib/cpu/SLFrontend.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLFrontend — the base class for every language frontend.
A frontend turns program source in one language into the common SLIR, which
the shared backend (SLLowering) then compiles to machine code for the
SLInstructionSet. Concrete frontends exist for C, C++, Java, and Sleela.
The contract is deliberately the same one real toolchains use: a frontend is
responsible for its language's lexing, parsing, and semantic lowering to a
common IR; everything after the IR (optimization, register allocation, code
emission) is language-neutral and shared.
Family: cpu. Base of the frontend hierarchy; composes SLIR. >>
#sleela 2.5
material;
class SLFrontend {
< ---- 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 = 10218;
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 LANG_SLEELA = 0;
static final int LANG_C = 1;
static final int LANG_CPP = 2;
static final int LANG_JAVA = 3;
String language;
int langId;
String sourcePath;
< count of errors/warnings produced >
int diagnostics;
SLIR ir;
void configure(String lang, int id, String path) {
language = lang; langId = id; sourcePath = path; diagnostics = 0;
ir = new SLIR(); ir.configure(lang, 4096);
}
< Lex + parse + semantic check. Concrete frontends override; the base reports >
< readiness only. >
boolean parse() { return sourcePath != null; }
< Lower parsed source to the common IR. Concrete frontends override to emit >
< real IR; the base emits an empty, well-formed module (HALT only). >
SLIR lower() {
ir.emit(SLIRInstructionConst(), -1, -1, -1, 0);
return ir;
}
< Helper so subclasses can reference the IR_HALT constant without an instance. >
int SLIRInstructionConst() { SLIRInstruction t = new SLIRInstruction(); return t.IR_HALT; }
SLIR intermediate() { return ir; }
String languageName() { return language; }
int languageId() { return langId; }
int diagnosticCount() { return diagnostics; }
}