Skip to content

Commit

Permalink
make symbol and value macros error when undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
NQNStudios committed Jul 26, 2024
1 parent a2aaca9 commit a265854
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/kiss/Macros.hx
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,23 @@ class Macros {
k.doc("#value", 1, 1, '(#value "<name>")');
macros["#value"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
var b = wholeExp.expBuilder();
b.str(Context.definedValue(compileTimeResolveToString("The only argument to (#value...)", "a compiler flag's name", args[0], k)));
var key = compileTimeResolveToString("The only argument to (#value...)", "a compiler flag's name", args[0], k);
var value = Context.definedValue(key);
if (value == null) {
throw KissError.fromExp(wholeExp, 'Compiler value "$key" is not defined');
}
b.str(value);
};

k.doc("#symbol", 1, 1, '(#symbol "<name>")');
macros["#symbol"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
var b = wholeExp.expBuilder();
b.symbol(Context.definedValue(compileTimeResolveToString("The only argument to (#symbol...)", "a compiler flag's name", args[0], k)));
var key = compileTimeResolveToString("The only argument to (#value...)", "a compiler flag's name", args[0], k);
var value = Context.definedValue(key);
if (value == null) {
throw KissError.fromExp(wholeExp, 'Compiler value $key is not defined');
}
b.symbol(value);
};

k.doc("or", 1, null, "(or <v1> <values...>)");
Expand Down

0 comments on commit a265854

Please sign in to comment.