Make compileTimeResolveString available in SpecialForms
This commit is contained in:
@@ -829,4 +829,17 @@ class Helpers {
|
||||
throw KissError.fromExp(exp, '$forThis bindings should be a list or list expression with an even number of sub expressions (at least 2)');
|
||||
};
|
||||
}
|
||||
|
||||
public static function compileTimeResolveToString(description:String, description2:String, exp:ReaderExp, k:KissState):String {
|
||||
switch (exp.def) {
|
||||
case StrExp(str):
|
||||
return str;
|
||||
case CallExp({pos: _, def: Symbol(mac)}, innerArgs) if (k.macros.exists(mac)):
|
||||
var docs = k.formDocs[mac];
|
||||
exp.checkNumArgs(docs.minArgs, docs.maxArgs, docs.expectedForm);
|
||||
return compileTimeResolveToString(description, description2, k.macros[mac](exp, innerArgs, k), k);
|
||||
default:
|
||||
throw KissError.fromExp(exp, '${description} should resolve at compile-time to a string literal of ${description2}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,18 +37,7 @@ class Macros {
|
||||
k.formDocs[newName] = k.formDocs[oldName];
|
||||
}
|
||||
|
||||
function compileTimeResolveToString(description:String, description2:String, exp:ReaderExp, k:KissState):String {
|
||||
switch (exp.def) {
|
||||
case StrExp(str):
|
||||
return str;
|
||||
case CallExp({pos: _, def: Symbol(mac)}, innerArgs) if (macros.exists(mac)):
|
||||
var docs = k.formDocs[mac];
|
||||
exp.checkNumArgs(docs.minArgs, docs.maxArgs, docs.expectedForm);
|
||||
return compileTimeResolveToString(description, description2, macros[mac](exp, innerArgs, k), k);
|
||||
default:
|
||||
throw KissError.fromExp(exp, '${description} should resolve at compile-time to a string literal of ${description2}');
|
||||
}
|
||||
}
|
||||
var compileTimeResolveToString = Helpers.compileTimeResolveToString;
|
||||
|
||||
k.doc("load", 1, 1, '(load "<file.kiss>")');
|
||||
macros["load"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||
|
@@ -23,6 +23,8 @@ class SpecialForms {
|
||||
public static function builtins(k:KissState, ?context:FrontendContext) {
|
||||
var map:Map<String, SpecialFormFunction> = [];
|
||||
|
||||
var compileTimeResolveToString = Helpers.compileTimeResolveToString;
|
||||
|
||||
function renameAndDeprecate(oldName:String, newName:String) {
|
||||
var form = map[oldName];
|
||||
map[oldName] = (wholeExp, args, k) -> {
|
||||
|
Reference in New Issue
Block a user