]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.units: fix bug that came up recently with nested compilation units
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 3 Feb 2010 14:20:48 +0000 (03:20 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 3 Feb 2010 14:20:48 +0000 (03:20 +1300)
basis/compiler/tests/redefine21.factor [new file with mode: 0644]
core/compiler/units/units.factor

diff --git a/basis/compiler/tests/redefine21.factor b/basis/compiler/tests/redefine21.factor
new file mode 100644 (file)
index 0000000..30c00bf
--- /dev/null
@@ -0,0 +1,10 @@
+USING: kernel tools.test definitions compiler.units ;
+IN: compiler.tests.redefine21
+
+[ ] [ : a ( -- ) ; << : b ( quot -- ) call a ; inline >> [ ] b ] unit-test
+
+[ ] [ [ { a b } forget-all ] with-compilation-unit ] unit-test
+
+[ ] [ : A ( -- ) ; << : B ( -- ) A ; inline >> B ] unit-test
+
+[ ] [ [ { A B } forget-all ] with-compilation-unit ] unit-test
index 60d27e84879673ba0b8d57ef9cccee064fd7900d..9582ebadb6e3d54bb8318fde5ca3b24d8a03b677 100644 (file)
@@ -168,6 +168,17 @@ M: object always-bump-effect-counter? drop f ;
         notify-observers
     ] if-bootstrapping ;
 
+TUPLE: nesting-observer new-words ;
+
+M: nesting-observer definitions-changed new-words>> swap assoc-diff! drop ;
+
+: add-nesting-observer ( -- )
+    new-words get nesting-observer boa
+    [ nesting-observer set ] [ add-definition-observer ] bi ;
+
+: remove-nesting-observer ( -- )
+    nesting-observer get remove-definition-observer ;
+
 PRIVATE>
 
 : with-nested-compilation-unit ( quot -- )
@@ -178,19 +189,17 @@ PRIVATE>
         H{ } clone outdated-generics set
         H{ } clone outdated-tuples set
         H{ } clone new-words set
-        [ finish-compilation-unit ] [ ] cleanup
+        add-nesting-observer
+        [
+            remove-nesting-observer
+            finish-compilation-unit
+        ] [ ] cleanup
     ] with-scope ; inline
 
 : with-compilation-unit ( quot -- )
     [
-        H{ } clone changed-definitions set
-        H{ } clone maybe-changed set
-        H{ } clone changed-effects set
-        H{ } clone outdated-generics set
-        H{ } clone forgotten-definitions set
-        H{ } clone outdated-tuples set
-        H{ } clone new-words set
         <definitions> new-definitions set
         <definitions> old-definitions set
-        [ finish-compilation-unit ] [ ] cleanup
+        H{ } clone forgotten-definitions set
+        with-nested-compilation-unit
     ] with-scope ; inline