mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-06 20:56:36 +02:00
WIP
This commit is contained in:
parent
8f0b9dbc4d
commit
56a37d3900
1 changed files with 31 additions and 0 deletions
31
runtime.h
31
runtime.h
|
@ -572,6 +572,7 @@ static object Cyc_write(x) object x;
|
||||||
{case string_tag:
|
{case string_tag:
|
||||||
printf("\"%s\"", ((string_type *) x)->str);
|
printf("\"%s\"", ((string_type *) x)->str);
|
||||||
break;
|
break;
|
||||||
|
// TODO: what about a list? contents should be displayed per (write)
|
||||||
default:
|
default:
|
||||||
Cyc_display(x);}
|
Cyc_display(x);}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -993,6 +994,35 @@ typedef union {
|
||||||
string_type string_t;
|
string_type string_t;
|
||||||
} common_type;
|
} common_type;
|
||||||
|
|
||||||
|
static void dispatch(int argc, closure func, object cont, object args) {
|
||||||
|
// object buf, tmp;
|
||||||
|
// int i;
|
||||||
|
//printf("%d %d ", sizeof(buf), sizeof(buf[0]));
|
||||||
|
// for (i = 0; i < argc; i++){
|
||||||
|
// //tmp = car(args);
|
||||||
|
// //if (nullp(tmp) || is_value_type(tmp)) {
|
||||||
|
// // buf[i] = tmp;
|
||||||
|
// //} else {
|
||||||
|
// // buf[i] = &tmp;
|
||||||
|
// //}
|
||||||
|
// buf[i] = car(args);
|
||||||
|
// args = cdr(args);
|
||||||
|
// }
|
||||||
|
//Cyc_display(buf[0]);
|
||||||
|
|
||||||
|
object tmp;
|
||||||
|
object buf[20];
|
||||||
|
tmp = car(args);
|
||||||
|
buf[0] = tmp;
|
||||||
|
object carbuf = buf[0]; //car(args);
|
||||||
|
return_funcall2(func, cont, buf[0]);
|
||||||
|
|
||||||
|
// switch(argc) {
|
||||||
|
// case 5: return_funcall6(func, cont, buf[0], buf[1], buf[2], buf[3], buf[4]);
|
||||||
|
// default: break;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* @param cont - Continuation for the function to call into
|
* @param cont - Continuation for the function to call into
|
||||||
|
@ -1089,6 +1119,7 @@ static object apply(object cont, object func, object args){
|
||||||
case 3: return_funcall4((closure)func, cont, car(args), cadr(args), caddr(args));
|
case 3: return_funcall4((closure)func, cont, car(args), cadr(args), caddr(args));
|
||||||
case 4: return_funcall5((closure)func, cont, car(args), cadr(args), caddr(args), cadddr(args));
|
case 4: return_funcall5((closure)func, cont, car(args), cadr(args), caddr(args), cadddr(args));
|
||||||
// TODO: can see the pattern but this is not efficient. is there a better way?
|
// TODO: can see the pattern but this is not efficient. is there a better way?
|
||||||
|
case 5: dispatch(buf.integer_t.value, (closure)func, cont, args);
|
||||||
default:
|
default:
|
||||||
printf("Unhandled number of function arguments: %d\n", buf.integer_t.value);
|
printf("Unhandled number of function arguments: %d\n", buf.integer_t.value);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue