pass reflection and expression evaluation to macro evaluator

This commit is contained in:
2021-08-04 16:48:03 -06:00
parent 2359ef21ac
commit 960ab35314
3 changed files with 5 additions and 1 deletions

View File

@@ -334,6 +334,9 @@ class Helpers {
for (name => value in k.macroVars) {
interp.variables.set(name, value);
}
// This is kind of a big deal:
interp.variables.set("eval", Helpers.runAtCompileTimeDynamic.bind(_, k));
interps.push(interp);
} else {
interps.push(new Cloner().clone(interps[-1]));

View File

@@ -58,6 +58,7 @@ class Kiss {
// Helpful built-in aliases
// These ones might conflict with a programmer's variable names, so they only apply in call expressions:
callAliases: [
// TODO some of these probably won't conflict, and could be passed as functions for a number of reasons
"print" => Symbol("Prelude.print"),
"sort" => Symbol("Prelude.sort"),
"groups" => Symbol("Prelude.groups"),
@@ -106,7 +107,6 @@ class Kiss {
macroVars: new Map()
};
// Helpful aliases
return k;
}

View File

@@ -19,6 +19,7 @@ class KissInterp extends Interp {
this.nullForUnknownVar = nullForUnknownVar;
variables.set("Reflect", Reflect);
variables.set("Prelude", Prelude);
variables.set("Lambda", Lambda);
variables.set("Std", Std);