Added notes, working example

This commit is contained in:
Justin Ethier 2015-05-18 13:42:45 -04:00
parent da54b226e4
commit f5d0ff3717
5 changed files with 33 additions and 26 deletions

26
TODO
View file

@ -5,17 +5,27 @@ Working TODO list:
1) Need to manually assign Cyc_global_variables in lib2.c
2) Need to add this manually, need to compute it:
static void c_entry_pt(argc, env,cont) int argc; closure env,cont; {
c_schemebase_entry_pt(argc, env,cont);
c_libslib1_entry_pt(argc, env, cont);
c_libslib2_entry_pt(argc, env, cont);
return_check0(__lambda_3);
extern void c_libslib2_entry_pt(int argc, closure cont);
extern void c_libslib1_entry_pt(int argc, closure cont);
extern void c_schemebase_entry_pt(int argc, closure cont);
static void c_entry_pt(argc, env,cont) int argc; closure env,cont; {
// TODO: should do these explicitly instead of using macros, in case they are not generated
mclosure1(c_done, __lambda_3, &c_done);
mclosure1(c_lib2, c_libslib2_entry_pt, &c_done);
mclosure1(c_lib1, c_libslib1_entry_pt, &c_lib2);
mclosure1(c_base, c_schemebase_entry_pt, &c_lib1);
// TODO: need to change each entry point to accept above closures
// will need to check in each one for closure1 or closure0, I think???
(c_base.fn)(0, &c_base);
}
3) Above is no good, the functions cannot return, or any vars allocated on the stack will be corrupted!
3) Need to change signature of library entry_pt functions, and append this at the end:
cont = ((closure1_type *)cont)->elt1;
((cont)->fn)(0, cont);
Alternatively, we can leave the existing signature and pass cont twice...
- Reduction in size of generated code

View file

@ -139,14 +139,14 @@ extern void c_libslib1_entry_pt(int argc, closure cont);
extern void c_schemebase_entry_pt(int argc, closure cont);
static void c_entry_pt(argc, env,cont) int argc; closure env,cont; {
// TODO: should do these explicitly instead of using macros, in case they are not generated
mclosure0(c_done, __lambda_3);
mclosure1(c_done, __lambda_3, &c_done);
mclosure1(c_lib2, c_libslib2_entry_pt, &c_done);
mclosure1(c_lib1, c_libslib1_entry_pt, &c_lib2);
mclosure1(c_base, c_schemebase_entry_pt, &c_lib1);
// TODO: need to change each entry point to accept above closures
// will need to check in each one for closure1 or closure0, I think???
funcall0(&c_base);
(c_base.fn)(0, &c_base);
// TODO: these can't return, they need to call into each other as a continuation chain
//c_schemebase_entry_pt(argc, env,cont);

View file

@ -139,8 +139,6 @@ make_cons(c_7332, &pair_7328, &c_7333);
make_cons(c_7331, &pair_7330, &c_7332);
Cyc_global_variables = &c_7331;
if (((closure)cont)->tag == closure1_tag) {
((cont)->fn)(1, ((closure1_type *)cont)->elt1);
} else {
((cont)->fn)(0, cont);
}}
cont = ((closure1_type *)cont)->elt1;
((cont)->fn)(0, cont);
}

View file

@ -57,8 +57,11 @@ void c_libslib2_entry_pt(argc, cont) int argc; closure cont; {
make_cons(c_739, &pair_738,Cyc_global_variables);
Cyc_global_variables = &c_739;
if (((closure)cont)->tag == closure1_tag) {
((cont)->fn)(1, ((closure1_type *)cont)->elt1);
} else {
((cont)->fn)(0, cont);
}}
cont = ((closure1_type *)cont)->elt1;
((cont)->fn)(0, cont);
//if (((closure)cont)->tag == closure1_tag) {
// ((cont)->fn)(1, ((closure1_type *)cont)->elt1);
//} else {
// ((cont)->fn)(0, cont);
//}
}

View file

@ -2894,11 +2894,7 @@ make_cons(c_731471, &pair_731467, &c_731472);
make_cons(c_731470, &pair_731469, &c_731471);
Cyc_global_variables = &c_731470;
if (((closure)cont)->tag == closure1_tag) {
((cont)->fn)(1, ((closure1_type *)cont)->elt1);
} else {
((cont)->fn)(0, cont);
}
cont = ((closure1_type *)cont)->elt1;
((cont)->fn)(0, cont);
}