[Quipu-dev] quipu/quipu: General bugfixes

Back to archive index

scmno****@osdn***** scmno****@osdn*****
Sat Jun 9 14:36:34 JST 2018


changeset 9d4c985e1b60 in quipu/quipu
details: http://hg.osdn.jp/view/quipu/quipu?cmd=changeset;node=9d4c985e1b60
user: Agustina Arzille <avarz****@riseu*****>
date: Sat Jun 09 05:36:20 2018 +0000
description: General bugfixes

diffstat:

 arith.cpp    |   4 +--
 bytecode.cpp |   4 +-
 compiler.cpp |  70 ++++++++++++++++++++++++++---------------------------------
 defs.h       |   2 +-
 event.cpp    |   2 +-
 memory.cpp   |   2 +-
 6 files changed, 37 insertions(+), 47 deletions(-)

diffs (250 lines):

diff -r 1a2b2182deb3 -r 9d4c985e1b60 arith.cpp
--- a/arith.cpp	Wed Jun 06 19:40:41 2018 -0300
+++ b/arith.cpp	Sat Jun 09 05:36:20 2018 +0000
@@ -889,6 +889,7 @@
 
   memset (&info, 0, sizeof (info));
   info.type = typecode::INT;
+  info.base = 10;
 
   if (src[ix] == '-')
     info.sign = 1, ++ix;
@@ -918,9 +919,6 @@
         info.base = 8, ++ix;
     }
 
-  if (info.base == 0)
-    info.base = 10;
-
   for (; src[ix] == '0' && ix < len; ++ix) ;
   if (ix == len)
     return (0);   // Nothing but 0's.
diff -r 1a2b2182deb3 -r 9d4c985e1b60 bytecode.cpp
--- a/bytecode.cpp	Wed Jun 06 19:40:41 2018 -0300
+++ b/bytecode.cpp	Sat Jun 09 05:36:20 2018 +0000
@@ -5,9 +5,9 @@
 #include "stream.h"
 #include "function.h"
 #include "io.h"
-#include "utils/ivector.h"
 #include <cstring>
 #include <cstdio>
+#include <vector>
 
 QP_DECLS_BEGIN
 
@@ -233,7 +233,7 @@
   const array *vals = as_array (fct_vals (fn));
   int sx, width = bc->nbytes < 0xff ? 2 :
     bc->nbytes < 0xffff ? 4 : 8;
-  ivector troff;
+  std::vector<int> troff;
 
   for (int i = 0; i < bc->nbytes; )
     {
diff -r 1a2b2182deb3 -r 9d4c985e1b60 compiler.cpp
--- a/compiler.cpp	Wed Jun 06 19:40:41 2018 -0300
+++ b/compiler.cpp	Sat Jun 09 05:36:20 2018 +0000
@@ -3,12 +3,12 @@
 #include <cstdio>
 #include <climits>
 #include <cstdarg>
+#include <vector>
 #include "quipu.h"
 #include "builtins.h"
 #include "bytecode.h"
 #include "utils/lstack.h"
 #include "utils/sorted_list.h"
-#include "utils/ivector.h"
 
 QP_DECLS_BEGIN
 
@@ -70,7 +70,7 @@
 {
 public:
   typedef sorted_list<xcmp_call> ctable_t;
-  typedef ivector codevec_t;
+  typedef std::vector<object> codevec_t;
 
   interpreter *interp;
   ctable_t ctable;
@@ -387,7 +387,7 @@
     {
       if (lasti == OPX_(NOT))
         {
-          if (cv.size () > 2 && cv[cv.size () - 2] == (intptr_t)lasti)
+          if (cv.size () > 2 && cv[cv.size () - 2] == lasti)
             {
               cv.pop_back ();
               cv.back() = OPX_(BRN);
@@ -1710,11 +1710,14 @@
         {
           int d;
           bc_emitter tmp (self.interp);
-          object prev = ctvs[nctvs - 1].cdr;
+          object prev = NIL;
 
           tmp.ct_env = self.ct_env;
           if (nctvs > 0)
-            ctvs[nctvs - 1].cdr = NIL;
+            {
+              prev = ctvs[nctvs - 1].cdr;
+              ctvs[nctvs - 1].cdr = NIL;
+            }
 
           tmp.compile_fct (NIL, xcdr (ev), d);
           if (nctvs > 0)
@@ -1743,7 +1746,7 @@
 
   cons sbody[2];
   int nargs = 0;
-  bool seq_mode = false;
+  bool dbind = false;
 
   if (!xcons_p (bindings))
     {
@@ -1756,7 +1759,7 @@
       else if (xcdr (expr) == NIL)
         this->interp->raise2 ("arg-error", "missing body in let");
 
-      seq_mode = special_symbol_p (bindings);
+      dbind = special_symbol_p (bindings);
 
       sbody[0].car = bindings;
       sbody[0].cdr = sbody[1].as_obj ();
@@ -1775,7 +1778,7 @@
           raise_e (this->interp, "let bindings must be "
             "symbols, not", 0, xcar (tmp));
 
-        seq_mode = seq_mode || special_symbol_p (xcar (tmp));
+        dbind = dbind || special_symbol_p (xcar (tmp));
 
         if (xcdr (tmp) == NIL)
           raise_e (this->interp, "let bindings must come in pairs, "
@@ -1786,8 +1789,9 @@
       }
 
   QP_TMARK (this->interp);
-  cons *syms = (cons *)QP_TALLOC (this->interp, nargs * 4 * sizeof (*syms));
-  cons *ctvs = syms + nargs + 1;
+  cons *syms = (cons *)QP_TALLOC (this->interp,
+    (nargs + 2) * 4 * sizeof (*syms));
+  cons *ctvs = syms + nargs + 2;
 
   cons t1, t2;
   object *sep = &syms[0].cdr, *cep = &ctvs[0].cdr;
@@ -1805,9 +1809,6 @@
   t2.cdr = this->ct_env;
   this->ct_env = t2.as_obj ();
 
-  if (!seq_mode)
-    ++this->inlet;
-
   for (; bindings != NIL; bindings = xcddr (bindings))
     {
       object ev = xcadr (bindings);
@@ -1833,27 +1834,29 @@
            * eventually patch or remove. */
           this->emit (OPX_(NOP));
           cls.attach (*this);
-
-          if (seq_mode)
-            {
-              this->emit (OPX_(MKFRAME), intobj (0));
-              aarg = (int)this->code.size () - 1;
-              ++this->let_cnt;
-            }
-          else
-            this->emit (OPX_(LOADNIL));
-
+          this->emit (OPX_(MKFRAME), intobj (0));
+          aarg = (int)this->code.size () - 1;
+          ++this->let_cnt;
           first = false;
         }
 
+      object prev = NIL;
+      if (nlex > 0)
+        {
+          prev = syms[nlex - 1].cdr;
+          syms[nlex - 1].cdr = NIL;
+        }
+
       this->compile_in (t1.as_obj (), false, ev);
+      if (nlex > 0)
+        syms[nlex - 1].cdr = prev;
 
       if (special_symbol_p (xcar (bindings)))
         {
           this->emit (OPX_(BIND), xcar (bindings));
           continue;
         }
-      else if (seq_mode)
+      else
         this->emit (OPX_(SETAPOP), intobj (nlex));
 
       syms[nlex].car = xcar (bindings);
@@ -1866,23 +1869,12 @@
   if (!first)
     {
       syms[nlex - 1].cdr = NIL;
-      if (!seq_mode)
-        this->emit (OPX_(MKFRAME), intobj (-nlex));
-      else
-        {
-          this->code[aarg] = intobj (nlex);
-          if (nlex > 0xff)
-            this->code[aarg - 1] = OPX_(MKFRAMEL);
-        }
+      this->code[aarg] = intobj (nlex);
+      if (nlex > 0xff)
+        this->code[aarg - 1] = OPX_(MKFRAMEL);
     }
 
-  if (!seq_mode)
-    {
-      --this->inlet;
-      ++this->let_cnt;
-    }
-
-  int r = this->compile_do (t1.as_obj (), tail && !seq_mode, xcdr (expr));
+  int r = this->compile_do (t1.as_obj (), tail && !dbind, xcdr (expr));
   this->ct_env = t2.cdr;
 
   if (!first)
diff -r 1a2b2182deb3 -r 9d4c985e1b60 defs.h
--- a/defs.h	Wed Jun 06 19:40:41 2018 -0300
+++ b/defs.h	Sat Jun 09 05:36:20 2018 +0000
@@ -255,7 +255,7 @@
 template <class T>
 inline constexpr bool pow2_p (T __val)
 {
-  return ((__val & (__val - 1)) == 0);
+  return (__val != 0 && ((__val & (__val - 1)) == 0));
 }
 
 // Stack allocations.
diff -r 1a2b2182deb3 -r 9d4c985e1b60 event.cpp
--- a/event.cpp	Wed Jun 06 19:40:41 2018 -0300
+++ b/event.cpp	Sat Jun 09 05:36:20 2018 +0000
@@ -5,7 +5,7 @@
 
 QP_DECLS_BEGIN
 
-static object ev_handlers[QP_NSIG];
+static object ev_handlers[NPENDEV + 1];
 static atomic_t evh_lock;
 
 #ifdef QP_PLATFORM_UNIX
diff -r 1a2b2182deb3 -r 9d4c985e1b60 memory.cpp
--- a/memory.cpp	Wed Jun 06 19:40:41 2018 -0300
+++ b/memory.cpp	Sat Jun 09 05:36:20 2018 +0000
@@ -7,7 +7,7 @@
 
 QP_DECLS_BEGIN
 
-static void
+[[noreturn]] static void
 oom_fatal (void)
 {
   fputs ("memory exhausted\n", stderr);




More information about the Quipu-dev mailing list
Back to archive index