commit c0be33b518d21934447b6afbd81b1a6351974675
parent 046abd03047ddd31203727bd71244770f0928f49
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sat,  5 Mar 2011 14:33:40 -0300
Slightly modified the underlying functions of operatives and continuations.
Diffstat:
7 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/src/kcontinuation.c b/src/kcontinuation.c
@@ -12,7 +12,7 @@
 #include "kmem.h"
 
 TValue kmake_continuation(klisp_State *K, TValue parent, TValue name, 
-			  TValue si, klisp_Ifunc fn, int32_t xcount, ...)
+			  TValue si, klisp_Cfunc fn, int32_t xcount, ...)
 {
     va_list argp;
     Continuation *new_cont = (Continuation *)
diff --git a/src/kcontinuation.h b/src/kcontinuation.h
@@ -12,6 +12,6 @@
 
 /* TODO: make some specialized constructors for 0, 1 and 2 parameters */
 TValue kmake_continuation(klisp_State *K, TValue parent, TValue name, 
-			  TValue si, klisp_Ifunc fn, int xcount, ...);
+			  TValue si, klisp_Cfunc fn, int xcount, ...);
 
 #endif
diff --git a/src/kobject.h b/src/kobject.h
@@ -236,21 +236,13 @@ typedef struct __attribute__ ((__packed__)) {
     TValue bindings; /* TEMP: for now alist of (binding . value) */
 } Environment;
 
-/*
-** prototype for callable c functions from the interpreter main loop:
-**
-** TEMP: Has to be here because it uses TValue type
-** ideally it should be in klisp.h
-*/
-typedef void (*klisp_Ifunc) (TValue *ud, TValue val, TValue env);
-
 typedef struct __attribute__ ((__packed__)) {
     CommonHeader;
     TValue mark; /* for guarding continuation */
     TValue name; /* cont name/type */
     TValue si; /* source code info (either () or (filename line col) */
     TValue parent; /* may be () for root continuation */
-    klisp_Ifunc fn; /* the function that does the work */
+    void *fn; /* the function that does the work */
     int32_t extra_size;
     TValue extra[];
 } Continuation;
@@ -259,7 +251,7 @@ typedef struct __attribute__ ((__packed__)) {
     CommonHeader;
     TValue name;
     TValue si; /* source code info (either () or (filename line col) */
-    klisp_Ifunc fn; /* the function that does the work */
+    void *fn; /* the function that does the work */
     int32_t extra_size;
     TValue extra[];
 } Operative;
diff --git a/src/koperative.c b/src/koperative.c
@@ -12,7 +12,7 @@
 #include "kmem.h"
 
 TValue kmake_operative(klisp_State *K, TValue name, TValue si, 
-		       klisp_Ifunc fn, int32_t xcount, ...)
+		       klisp_Ofunc fn, int32_t xcount, ...)
 {
     va_list argp;
     Operative *new_op = (Operative *) 
diff --git a/src/koperative.h b/src/koperative.h
@@ -12,6 +12,6 @@
 
 /* TODO: make some specialized constructors for 0, 1 and 2 parameters */
 TValue kmake_operative(klisp_State *K, TValue name, TValue si, 
-		       klisp_Ifunc fn, int xcount, ...);
+		       klisp_Ofunc fn, int xcount, ...);
 
 #endif
diff --git a/src/kstate.c b/src/kstate.c
@@ -40,7 +40,9 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) {
   K->symbol_table = KNIL;
   /* TODO: create a continuation */
   K->curr_cont = NULL;
-  K->ret_value = KINERT;
+
+  K->next_value = KINERT;
+  K->next_value = KINERT;
 
   K->frealloc = f;
   K->ud = ud;
diff --git a/src/kstate.h b/src/kstate.h
@@ -40,7 +40,14 @@ struct klisp_State {
     TValue symbol_table;
     Continuation *curr_cont;
 
-    TValue ret_value;     /* the value to be passed to the next function */
+    /*
+    ** If next_env is NIL, then the next_func is of type klisp_Cfunc
+    ** (from a continuation) and otherwise next_func is of type
+    ** klisp_Ofunc (from an operative)
+    */
+    void *next_func; /* the next function to call (operative or cont) */
+    TValue next_value;     /* the value to be passed to the next function */
+    TValue next_env; /* either NIL or an environment for next operative */
 
     klisp_Alloc frealloc;  /* function to reallocate memory */
     void *ud;         /* auxiliary data to `frealloc' */
@@ -204,4 +211,14 @@ inline bool ks_tbisempty(klisp_State *K)
     return ks_tbidx(K) == 0;
 }
 
+
+/*
+** prototypes for underlying c functions of continuations &
+** operatives
+*/
+typedef void (*klisp_Cfunc) (klisp_State*K, TValue *ud, TValue val);
+typedef void (*klisp_Ofunc) (klisp_State *K, TValue *ud, TValue ptree, 
+			     TValue env);
+
 #endif
+