コミットメタ情報

リビジョンc93529056aeb3dbc6339a257b57cce9099103d09 (tree)
日時2018-12-08 02:50:59
作者Agustina Arzille <avarzille@rise...>
コミッターAgustina Arzille

ログメッセージ

Fix use of circular packages

変更サマリ

差分

diff -r bc6d843f3fbf -r c93529056aeb compiler.cpp
--- a/compiler.cpp Thu Dec 06 17:05:28 2018 -0300
+++ b/compiler.cpp Fri Dec 07 14:50:59 2018 -0300
@@ -2371,7 +2371,7 @@
23712371 call_n (interp, 0);
23722372
23732373 // Add a 'POP' instruction to mantain the stack size consistent.
2374- bvector *bvp = as_bvector(retp->bcode);
2374+ bvector *bvp = as_bvector (retp->bcode);
23752375 bvp->data[bvp->nbytes - 1] = OP_POP;
23762376 bytecode.add_data (bvp->data, bvp->nbytes);
23772377
diff -r bc6d843f3fbf -r c93529056aeb symbol.cpp
--- a/symbol.cpp Thu Dec 06 17:05:28 2018 -0300
+++ b/symbol.cpp Fri Dec 07 14:50:59 2018 -0300
@@ -599,6 +599,16 @@
599599 }
600600 }
601601
602+static inline void
603+register_pkg (package *p, dlist *node)
604+{
605+ dlist *lp = &p->pkg_link;
606+ lp->next = node;
607+ lp->prev = node->prev;
608+ node->prev->next = lp;
609+ node->prev = lp;
610+}
611+
602612 struct import_data
603613 {
604614 static const uint32_t only_qpfiles = 1;
@@ -614,6 +624,7 @@
614624 uint32_t flags = 0;
615625 char *canonical_path = nullptr;
616626 int path_len;
627+ package *rpkg = nullptr;
617628
618629 import_data (interpreter *ip) : interp (ip),
619630 dir (ip, UNBOUND), strm (ip, UNBOUND),
@@ -630,13 +641,24 @@
630641 if (*this->prev != UNBOUND)
631642 this->interp->xpkg = *this->prev;
632643 this->release_path ();
644+
645+ if (this->rpkg != nullptr)
646+ this->rpkg->pkg_link.del ();
633647 }
634648
635- void set_pkg (object pkg)
649+ object set_pkg (package *p, dlist *node)
636650 {
651+ if (!node)
652+ {
653+ this->rpkg = nullptr;
654+ return (p->as_obj ());
655+ }
656+
637657 *this->prev = this->interp->xpkg;
638- as_package(pkg)->path = *this->dir;
639- this->interp->xpkg = pkg;
658+ p->path = *this->dir;
659+ this->interp->xpkg = p->as_obj ();
660+ register_pkg (this->rpkg = p, node);
661+ return (UNBOUND);
640662 }
641663
642664 void release_path ()
@@ -746,7 +768,8 @@
746768 (len > 3 && sp[1] == '.' && sp[2] == '/')))
747769 { // Path is relative to current directory.
748770 relative:
749- bool ret = data.open (sp, len, as_package(interp->xpkg)->path);
771+ bool ret = data.open (sp, len,
772+ *data.dir = as_package(interp->xpkg)->path);
750773
751774 if (ret)
752775 {
@@ -813,17 +836,6 @@
813836 return (nullptr);
814837 }
815838
816-static inline object
817-register_pkg (object pkg, const char *path, int len, dlist *node)
818-{
819- dlist *lp = &as_package(pkg)->pkg_link;
820- lp->next = node;
821- lp->prev = node->prev;
822- node->prev->next = lp;
823- node->prev = lp;
824- return (pkg);
825-}
826-
827839 static object
828840 import_pkg_lk (interpreter *interp, object path, object name, import_data& dt)
829841 {
@@ -852,19 +864,18 @@
852864 { // Found a compiled package.
853865 fstream_stat st1, st2;
854866
855- if ((*dt.strm == UNBOUND ||
867+ if (*dt.strm == UNBOUND ||
856868 (fstream_fstat (as_stream (*dt.strm), st1) &&
857869 fstream_fstat (as_stream (*dt.qpc), st2) &&
858- st1.mtime <= st2.mtime)))
870+ st1.mtime <= st2.mtime && st2.mtime != st2.ctime))
859871 { // The compiled package is up to date.
860872 object expr = xdeserialize (interp, as_stream (*dt.qpc), sin);
861873 if (fct_p (expr))
862874 {
863- dt.set_pkg (*ret);
875+ dt.set_pkg (p, node);
864876 interp->push (expr);
865877 call_n (interp, 0);
866- qp_return (register_pkg (*ret, p->canonical_path,
867- p->path_len, node));
878+ qp_return (dt.set_pkg (p, nullptr));
868879 }
869880 }
870881 }
@@ -874,7 +885,7 @@
874885
875886 reader rd (interp, *dt.strm, as_package (*ret));
876887 // Switch packages before executing any code.
877- dt.set_pkg (*ret);
888+ dt.set_pkg (p, node);
878889
879890 // Compile the package and (optionally) serialize it.
880891 object expr = compile_pkg (interp, rd);
@@ -883,7 +894,7 @@
883894 fstream_truncate (interp, as_stream (*dt.qpc), 0))
884895 xserialize (interp, as_stream (*dt.qpc), expr, sin);
885896
886- qp_return (register_pkg (*ret, p->canonical_path, p->path_len, node));
897+ qp_return (dt.set_pkg (p, nullptr));
887898 }
888899
889900 object import_pkg (interpreter *interp, object path, object name)
diff -r bc6d843f3fbf -r c93529056aeb sysdeps/thread-unix.h
--- a/sysdeps/thread-unix.h Thu Dec 06 17:05:28 2018 -0300
+++ b/sysdeps/thread-unix.h Fri Dec 07 14:50:59 2018 -0300
@@ -16,8 +16,8 @@
1616 return (ret);
1717 }
1818
19-static inline
20-timespec tstamp2tspec (double dbl)
19+static inline timespec
20+tstamp2tspec (double dbl)
2121 {
2222 timespec ret;
2323
旧リポジトリブラウザで表示