From 20facdea8fb7394e30be1cc1ceae1f258edccf2f Mon Sep 17 00:00:00 2001 From: slava Date: Thu, 25 May 2006 05:29:45 +0000 Subject: [PATCH] Fix problem with word redefinition messing up crossref --- TODO.FACTOR.txt | 1 - library/collections/graphs.factor | 6 ++---- library/test/words.factor | 21 +++++++++++++++------ library/words.factor | 9 +++++++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 00f75b811c..7be7386a16 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -23,7 +23,6 @@ - code walker & exceptions -- test and debug problems - code walker and callbacks is broken? -- look at xref issue + io: diff --git a/library/collections/graphs.factor b/library/collections/graphs.factor index fe909eb504..4e68c0b006 100644 --- a/library/collections/graphs.factor +++ b/library/collections/graphs.factor @@ -20,10 +20,8 @@ USING: hashtables kernel namespaces sequences ; : (remove-vertex) ( vertex graph -- ) nest remove-hash ; : remove-vertex ( vertex edges graph -- ) - [ - >r dup dup r> call [ nest remove-hash ] each-with - namespace remove-hash - ] if-graph ; inline + [ dupd call [ nest remove-hash ] each-with ] if-graph ; + inline : in-edges ( vertex graph -- seq ) ?hash dup [ hash-keys ] when ; diff --git a/library/test/words.factor b/library/test/words.factor index 066326b47b..c3aef4ee80 100644 --- a/library/test/words.factor +++ b/library/test/words.factor @@ -85,12 +85,21 @@ FORGET: another-forgotten FORGET: foe -! This has to be the last test in the file. -: test-last ( -- ) ; -word word-name "last-word-test" set - -[ "test-last" ] [ "last-word-test" get ] unit-test - ! xref should not retain references to gensyms gensym [ * ] define-compound [ t ] [ \ * usage [ interned? not ] subset empty? ] unit-test + +DEFER: calls-a-gensym +\ calls-a-gensym gensym dup "x" set unit define-compound +[ f ] [ "x" get crossref get hash ] unit-test + +! regression +GENERIC: freakish +: bar freakish ; +M: array freakish ; +[ t ] [ \ bar \ freakish usage member? ] unit-test + +! This has to be the last test in the file. +: test-last ( -- ) ; + +[ "test-last" ] [ word word-name ] unit-test diff --git a/library/words.factor b/library/words.factor index 5c7acd9cd4..6df3f32e3d 100644 --- a/library/words.factor +++ b/library/words.factor @@ -49,8 +49,12 @@ M: word set-word-xt ( xt w -- ) 7 set-integer-slot ; SYMBOL: crossref : xref-word ( word -- ) - dup word-vocabulary - [ [ uses ] crossref get add-vertex ] [ drop ] if ; + dup word-vocabulary [ + [ uses [ word-vocabulary ] subset ] + crossref get add-vertex + ] [ + drop + ] if ; : usage ( word -- seq ) crossref get in-edges ; @@ -141,6 +145,7 @@ SYMBOL: vocabularies : forget ( word -- ) dup unxref-word + crossref get [ dupd remove-hash ] when* dup word-name swap word-vocabulary vocab remove-hash ; : forget-vocab ( vocab -- )