🐐 TYPVS

This commit is contained in:
2026-04-21 21:09:59 +02:00
parent 693054491f
commit 78b1dd7667
7 changed files with 50 additions and 1 deletions

View File

@@ -1121,6 +1121,13 @@ class BuiltIn(Node):
case "EVERRO":
print("\033[2J\033[H", end="", flush=True)
return vtable, ValNul()
case "TYPVS":
type_map = {
ValInt: "NVMERVS", ValStr: "LITTERA", ValBool: "VERAX",
ValList: "CATALOGVS", ValFrac: "FRACTIO", ValDict: "TABVLA",
ValFunc: "FVNCTIO", ValNul: "NVLLVS",
}
return vtable, ValStr(type_map[type(params[0])])
case _:
raise NotImplementedError(self.builtin)

View File

@@ -255,6 +255,9 @@ def _emit_builtin(node, ctx):
lines.append("cent_everro();")
lines.append(f"CentValue {tmp} = cent_null();")
case "TYPVS":
lines.append(f"CentValue {tmp} = cent_typvs({param_vars[0]});")
case _:
raise NotImplementedError(node.builtin)

View File

@@ -545,6 +545,20 @@ CentValue cent_longitudo(CentValue v) {
return cent_null(); /* unreachable; silences warning */
}
CentValue cent_typvs(CentValue v) {
switch (v.type) {
case CENT_INT: return cent_str("NVMERVS");
case CENT_STR: return cent_str("LITTERA");
case CENT_BOOL: return cent_str("VERAX");
case CENT_LIST: return cent_str("CATALOGVS");
case CENT_FRAC: return cent_str("FRACTIO");
case CENT_DICT: return cent_str("TABVLA");
case CENT_FUNC: return cent_str("FVNCTIO");
case CENT_NULL: return cent_str("NVLLVS");
}
return cent_str("IGNOTA"); /* unreachable */
}
CentValue cent_fortis_numerus(CentValue lo, CentValue hi) {
if (lo.type != CENT_INT || hi.type != CENT_INT)
cent_type_error("'FORTIS_NVMERVS' requires two integers");

View File

@@ -220,6 +220,7 @@ CentValue cent_decimatio(CentValue lst); /* DECIMATIO */
void cent_semen(CentValue seed); /* SEMEN */
void cent_everro(void); /* EVERRO */
CentValue cent_senatus(CentValue *args, int n); /* SENATVS */
CentValue cent_typvs(CentValue v); /* TYPVS */
/* ------------------------------------------------------------------ */
/* Array helpers */

View File

@@ -49,7 +49,8 @@ builtin_tokens = [("BUILTIN", i) for i in [
"FORTIS_ELECTIONIS",
"LONGITVDO",
"SEMEN",
"SENATVS"
"SENATVS",
"TYPVS"
]]
data_tokens = [