[uim-commit] r2308 - branches/r5rs/sigscheme

kzk at freedesktop.org kzk at freedesktop.org
Thu Dec 1 09:55:05 PST 2005


Author: kzk
Date: 2005-12-01 09:54:57 -0800 (Thu, 01 Dec 2005)
New Revision: 2308

Modified:
   branches/r5rs/sigscheme/eval.c
Log:
* sigscheme/eval.c
  - (ScmExp_do): use POP_ARG macro, initialize local variable with
    SCM_FALSE, add nullp check, fix invalid return value.


Modified: branches/r5rs/sigscheme/eval.c
===================================================================
--- branches/r5rs/sigscheme/eval.c	2005-12-01 17:51:57 UTC (rev 2307)
+++ branches/r5rs/sigscheme/eval.c	2005-12-01 17:54:57 UTC (rev 2308)
@@ -1183,36 +1183,46 @@
      *   <command> ...)
      */
     ScmObj env        = eval_state->env;
-    ScmObj vars       = SCM_NULL;
-    ScmObj vals       = SCM_NULL;
+    ScmObj binding    = SCM_FALSE;
+    ScmObj var        = SCM_FALSE;
+    ScmObj val        = SCM_FALSE;
+    ScmObj vars       = SCM_FALSE;
+    ScmObj vals       = SCM_FALSE;
     ScmObj steps      = SCM_NULL;
-    ScmObj binding    = SCM_NULL;
-    ScmObj step       = SCM_NULL;
-    ScmObj test       = SCM_NULL;
-    ScmObj expression = SCM_NULL;
-    ScmObj tmp_vars   = SCM_NULL;
-    ScmObj tmp_steps  = SCM_NULL;
-    ScmObj obj        = SCM_NULL;
+    ScmObj test       = SCM_FALSE;
+    ScmObj expression = SCM_FALSE;
+    ScmObj tmp_steps  = SCM_FALSE;
+    ScmObj tmp_vars   = SCM_FALSE;
+    ScmObj obj        = SCM_FALSE;
     DECLARE_FUNCTION("do", SyntaxVariadicTailRec2);
 
     /* construct Environment and steps */
     for (; !NULLP(bindings); bindings = CDR(bindings)) {
         binding = CAR(bindings);
-        vars = CONS(CAR(binding), vars);
-        vals = CONS(EVAL(CADR(binding), env), vals);
+        if (NULLP(binding))
+            ERR("invalid bindings");
 
+        var = MUST_POP_ARG(binding);
+        val = MUST_POP_ARG(binding);
+
+        vars = CONS(var, vars);
+        vals = CONS(EVAL(val, env), vals);
+
         /* append <step> to steps */
-        step = CDDR(binding);
-        if (NULLP(step))
-            steps = CONS(CAR(binding), steps);
+        if (NO_MORE_ARG(binding))
+            steps = CONS(var, steps);
         else
-            steps = CONS(CAR(step), steps);
+            steps = CONS(POP_ARG(binding), steps);
+
+        ASSERT_NO_MORE_ARG(binding);
     }
 
     /* now extend environment */
     env = Scm_ExtendEnvironment(vars, vals, env);
 
     /* construct test */
+    if (NULLP(testframe))
+        ERR("invalid testframe");
     test       = CAR(testframe);
     expression = CDR(testframe);
 
@@ -1253,7 +1263,7 @@
 
     eval_state->env = env;
 
-    return ScmExp_begin(expression, eval_state);
+    return NULLP(expression) ? EVAL(test, env) : ScmExp_begin(expression, eval_state);
 }
 
 /*===========================================================================



More information about the uim-commit mailing list