WIP for fixing eval'd call/cc

This commit is contained in:
Justin Ethier 2016-03-31 02:55:04 -04:00
parent faac688f20
commit 258c823ef3
2 changed files with 18 additions and 1 deletions

View file

@ -401,7 +401,15 @@ extern const object primitive_Cyc_91display;
extern const object primitive_call_95cc;
/* -------------------------------------------- */
/* Globals that are needed by the runtime */
/** Globals that are needed by the runtime
* What's going on here is the globals are defined by a module, but
* are also used by the runtime. At least for now, these macros are
* used to point everybody to the objects, which are used by both
* those libraries and this module.
*
* The assumption for now is that a program that does not include
* the necessary libray would never use the corresponding function.
*/
extern object Cyc_glo_eval;
extern object Cyc_glo_eval_from_c;
extern object Cyc_glo_call_cc;

View file

@ -2397,6 +2397,15 @@ object apply(void *data, object cont, object func, object args){
case closure0_tag:
case closure1_tag:
case closureN_tag:
if (func == Cyc_glo_call_cc) {
make_cons(c, cont, args);
//Cyc_display(args, stderr);
// args = &c;
//Cyc_display(&c, stderr);
count = Cyc_length(data, args);
// Cyc_check_num_args(data, "<procedure>", ((closure)func)->num_args, args);
dispatch(data, obj_obj2int(count), ((closure)func)->fn, func, cont, args);
}
count = Cyc_length(data, args);
// TODO: validate number of args provided:
Cyc_check_num_args(data, "<procedure>", ((closure)func)->num_args, args); // TODO: could be more efficient, eg: cyc_length(args) is called twice.