🐐 LITTERA
This commit is contained in:
@@ -1441,6 +1441,10 @@ class BuiltIn(Node):
|
||||
if isinstance(params[0], (ValList, ValStr, ValDict)):
|
||||
return vtable, ValInt(len(params[0].value()))
|
||||
raise CentvrionError("LONGITVDO requires an array, string, or dict")
|
||||
case "LITTERA":
|
||||
if len(params) != 1:
|
||||
raise CentvrionError("LITTERA takes exactly I argument")
|
||||
return vtable, ValStr(make_string(params[0], magnvm, svbnvlla))
|
||||
case "CLAVES":
|
||||
if not isinstance(params[0], ValDict):
|
||||
raise CentvrionError("CLAVES requires a dict")
|
||||
|
||||
@@ -237,6 +237,9 @@ def _emit_builtin(node, ctx):
|
||||
case "LONGITVDO":
|
||||
lines.append(f"CentValue {tmp} = cent_longitudo({param_vars[0]});")
|
||||
|
||||
case "LITTERA":
|
||||
lines.append(f"CentValue {tmp} = cent_littera({param_vars[0]});")
|
||||
|
||||
case "FORTVITVS_NVMERVS":
|
||||
if not ctx.has_module("FORS"):
|
||||
lines.append('cent_runtime_error("FORS module required for FORTVITVS_NVMERVS");')
|
||||
|
||||
@@ -644,6 +644,10 @@ CentValue cent_longitudo(CentValue v) {
|
||||
return cent_null(); /* unreachable; silences warning */
|
||||
}
|
||||
|
||||
CentValue cent_littera(CentValue v) {
|
||||
return cent_str(cent_make_string(v));
|
||||
}
|
||||
|
||||
CentValue cent_typvs(CentValue v) {
|
||||
switch (v.type) {
|
||||
case CENT_INT: return cent_str("NVMERVS");
|
||||
|
||||
@@ -223,6 +223,7 @@ void cent_dic(CentValue v); /* DIC */
|
||||
CentValue cent_avdi(void); /* AVDI */
|
||||
CentValue cent_avdi_numerus(void); /* AVDI_NVMERVS */
|
||||
CentValue cent_longitudo(CentValue v); /* LONGITVDO */
|
||||
CentValue cent_littera(CentValue v); /* LITTERA */
|
||||
CentValue cent_fortuitus_numerus(CentValue lo, CentValue hi); /* FORTVITVS_NVMERVS */
|
||||
CentValue cent_fortuita_electionis(CentValue lst); /* FORTVITA_ELECTIO */
|
||||
CentValue cent_decimatio(CentValue lst); /* DECIMATIO */
|
||||
|
||||
@@ -54,6 +54,7 @@ builtin_tokens = [("BUILTIN", i) for i in [
|
||||
"EVERRE",
|
||||
"FORTVITVS_NVMERVS",
|
||||
"FORTVITA_ELECTIO",
|
||||
"LITTERA",
|
||||
"LONGITVDO",
|
||||
"NVMERVS",
|
||||
"ORDINA",
|
||||
|
||||
Reference in New Issue
Block a user