diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-04 11:50:41 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-04 11:50:41 +0800 |
commit | 65f17438de5983ca010e10b4b24c5da65756a9b5 (patch) | |
tree | dfa88443d6cd10a14f587377f101e14359e98f56 /eval.cpp | |
parent | d42c4bd97982c1252c5ad638a11aea5319c4be7f (diff) |
added exception facilities
Diffstat (limited to 'eval.cpp')
-rw-r--r-- | eval.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,5 +1,7 @@ #include "eval.h" #include "builtin.h" +#include "exc.h" +#include "consts.h" #include <cstdio> extern Cons *empty_list; @@ -87,7 +89,14 @@ EvalObj *Evaluator::run_expr(Cons *prog) { top_ptr++; } else - pc = dynamic_cast<OptObj*>(args->car)->call(args, envt, cont, top_ptr); + { + EvalObj *opt = args->car; + if (opt->is_opt_obj()) + pc = static_cast<OptObj*>(opt)-> + call(args, envt, cont, top_ptr); + else + throw TokenError(opt->ext_repr(), SYN_ERR_CAN_NOT_APPLY); + } } } // static_cast because the previous while condition |