From 35acd71551ba9b70b7f6f16bdfb8a312317fd26b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 4 Feb 2010 03:20:48 +1300 Subject: [PATCH] compiler.units: fix bug that came up recently with nested compilation units --- basis/compiler/tests/redefine21.factor | 10 ++++++++++ core/compiler/units/units.factor | 27 +++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 basis/compiler/tests/redefine21.factor diff --git a/basis/compiler/tests/redefine21.factor b/basis/compiler/tests/redefine21.factor new file mode 100644 index 0000000000..30c00bf732 --- /dev/null +++ b/basis/compiler/tests/redefine21.factor @@ -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 diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 60d27e8487..9582ebadb6 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -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 new-definitions set old-definitions set - [ finish-compilation-unit ] [ ] cleanup + H{ } clone forgotten-definitions set + with-nested-compilation-unit ] with-scope ; inline