mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
Remove dispatch.c, port Cyc_apply
This commit is contained in:
parent
807eb98843
commit
d06dbcb64a
3 changed files with 21 additions and 34 deletions
10
Makefile
10
Makefile
|
@ -167,10 +167,6 @@ cyclone : cyclone.scm $(CYC_RT_LIB) $(CYC_BN_LIB)
|
|||
icyc : icyc.scm $(CYC_RT_LIB) $(CYC_BN_LIB)
|
||||
$(CYCLONE) $<
|
||||
|
||||
dispatch.c : generate-c.scm
|
||||
$(CYCLONE) $<
|
||||
./generate-c
|
||||
|
||||
$(CYC_RT_LIB) : $(CFILES) $(HEADERS) $(CYC_BN_LIB)
|
||||
|
||||
$(CYC_BN_LIB) : $(CYC_BN_LIB_SUBDIR)/*.c
|
||||
|
@ -179,9 +175,6 @@ $(CYC_BN_LIB) : $(CYC_BN_LIB_SUBDIR)/*.c
|
|||
hashset.o : hashset.c $(HEADERS)
|
||||
$(CCOMP) -c $< -o $@
|
||||
|
||||
dispatch.o : dispatch.c $(HEADERS)
|
||||
$(CCOMP) -c $< -o $@
|
||||
|
||||
gc.o : gc.c $(HEADERS)
|
||||
$(CCOMP) -std=gnu99 -c $< -o $@
|
||||
|
||||
|
@ -208,7 +201,7 @@ runtime.o : runtime.c $(HEADERS)
|
|||
-DCYC_PLATFORM=\"$(PLATFORM)\" \
|
||||
$< -o $@
|
||||
|
||||
libcyclone.a : runtime.o gc.o dispatch.o ffi.o mstreams.o hashset.o
|
||||
libcyclone.a : runtime.o gc.o ffi.o mstreams.o hashset.o
|
||||
$(CREATE_LIBRARY_COMMAND) $(CREATE_LIBRARY_FLAGS) $@ $&
|
||||
$(RANLIB_COMMAND)
|
||||
# Instructions from: http://www.adp-gmbh.ch/cpp/gcc/create_lib.html
|
||||
|
@ -245,7 +238,6 @@ bootstrap : icyc libs
|
|||
cp mstreams.c $(BOOTSTRAP_DIR)
|
||||
cp hashset.c $(BOOTSTRAP_DIR)
|
||||
cp gc.c $(BOOTSTRAP_DIR)
|
||||
cp dispatch.c $(BOOTSTRAP_DIR)
|
||||
cp scheme/base.c $(BOOTSTRAP_DIR)/scheme
|
||||
cp scheme/case-lambda.c $(BOOTSTRAP_DIR)/scheme
|
||||
cp scheme/cxr.c $(BOOTSTRAP_DIR)/scheme
|
||||
|
|
|
@ -180,8 +180,6 @@ void dispatch_apply_va(void *data, int argc, object clo, object cont, object fun
|
|||
object apply_va(void *data, object cont, int argc, object func, ...);
|
||||
void dispatch(void *data, int argc, function_type func, object clo, object cont,
|
||||
object args);
|
||||
void do_dispatch(void *data, int argc, function_type func, object clo,
|
||||
object * buffer);
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
|
43
runtime.c
43
runtime.c
|
@ -5596,34 +5596,31 @@ object apply(void *data, object cont, object func, object args)
|
|||
}
|
||||
|
||||
// Version of apply meant to be called from within compiled code
|
||||
// TODO: in cargs branch we are swapping cont and prim below
|
||||
// old call convention, EG: Cyc_apply(td, 0, (closure)(a1), clo);
|
||||
//
|
||||
void Cyc_apply(void *data, int argc, closure cont, object prim, ...)
|
||||
void Cyc_apply(void *data, object cont, int argc, object *args)
|
||||
{
|
||||
va_list ap;
|
||||
object tmp;
|
||||
int i;
|
||||
list args = alloca(sizeof(pair_type) * argc);
|
||||
list arglis = alloca(sizeof(pair_type) * argc);
|
||||
// TODO: check size of argc/args??
|
||||
// TODO: seems inefficient to put these in a list now, with
|
||||
// cargs do we still need to do this??
|
||||
object prim = args[0];
|
||||
|
||||
va_start(ap, prim);
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
tmp = va_arg(ap, object);
|
||||
args[i].hdr.mark = gc_color_red;
|
||||
args[i].hdr.grayed = 0;
|
||||
args[i].hdr.immutable = 0;
|
||||
args[i].tag = pair_tag;
|
||||
args[i].pair_car = tmp;
|
||||
args[i].pair_cdr = (i == (argc - 1)) ? NULL : &args[i + 1];
|
||||
for (i = 1; i < argc; i++) {
|
||||
tmp = args[i];
|
||||
arglis[i].hdr.mark = gc_color_red;
|
||||
arglis[i].hdr.grayed = 0;
|
||||
arglis[i].hdr.immutable = 0;
|
||||
arglis[i].tag = pair_tag;
|
||||
arglis[i].pair_car = tmp;
|
||||
arglis[i].pair_cdr = (i == (argc - 1)) ? NULL : &arglis[i + 1];
|
||||
}
|
||||
//printf("DEBUG applying primitive to ");
|
||||
//Cyc_display(data, (object)&args[0]);
|
||||
//Cyc_display(data, (object)&arglis[0]);
|
||||
//printf("\n");
|
||||
|
||||
va_end(ap);
|
||||
apply(data, cont, prim, (argc > 0)
|
||||
? (object) & args[0]
|
||||
apply(data, cont, prim, (argc > 1)
|
||||
? (object) & arglis[0]
|
||||
: NULL);
|
||||
}
|
||||
|
||||
|
@ -5671,8 +5668,8 @@ void Cyc_start_trampoline(gc_thread_data * thd)
|
|||
if (obj_is_not_closure(thd->gc_cont)) {
|
||||
Cyc_apply_from_buf(thd, thd->gc_num_args, thd->gc_cont, thd->gc_args);
|
||||
} else {
|
||||
do_dispatch(thd, thd->gc_num_args, ((closure) (thd->gc_cont))->fn,
|
||||
thd->gc_cont, thd->gc_args);
|
||||
closure clo = thd->gc_cont;
|
||||
(clo->fn)(thd, clo, thd->gc_num_args, thd->gc_args);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Internal error: should never have reached this line\n");
|
||||
|
@ -6099,7 +6096,7 @@ void dispatch(void *data, int argc, function_type func, object clo, object cont,
|
|||
args = cdr(args);
|
||||
}
|
||||
|
||||
do_dispatch(data, argc, func, clo, b);
|
||||
func(data, clo, argc, b);
|
||||
}
|
||||
|
||||
static primitive_type Cyc_91global_91vars_primitive =
|
||||
|
|
Loading…
Add table
Reference in a new issue