2010-01-20 10:23:20 -05:00
|
|
|
! Copyright (C) 2009, 2010 Slava Pestov.
|
2009-11-08 07:08:04 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2010-01-29 03:40:09 -05:00
|
|
|
USING: arrays assocs classes.algebra compiler.units definitions
|
|
|
|
graphs grouping kernel namespaces sequences words fry
|
2009-11-08 21:34:46 -05:00
|
|
|
stack-checker.dependencies ;
|
2009-11-08 07:08:04 -05:00
|
|
|
IN: compiler.crossref
|
|
|
|
|
|
|
|
SYMBOL: compiled-crossref
|
|
|
|
|
|
|
|
compiled-crossref [ H{ } clone ] initialize
|
|
|
|
|
|
|
|
SYMBOL: compiled-generic-crossref
|
|
|
|
|
|
|
|
compiled-generic-crossref [ H{ } clone ] initialize
|
|
|
|
|
|
|
|
: compiled-usage ( word -- assoc )
|
|
|
|
compiled-crossref get at ;
|
|
|
|
|
|
|
|
: (compiled-usages) ( word -- assoc )
|
2010-01-29 08:58:39 -05:00
|
|
|
compiled-usage [ nip inlined-dependency dependency>= ] assoc-filter ;
|
2009-11-08 07:08:04 -05:00
|
|
|
|
2010-01-29 03:40:09 -05:00
|
|
|
: compiled-usages ( assoc -- assocs )
|
2009-11-08 07:08:04 -05:00
|
|
|
[ drop word? ] assoc-filter
|
|
|
|
[ [ drop (compiled-usages) ] { } assoc>map ] keep suffix ;
|
|
|
|
|
2010-01-29 03:40:09 -05:00
|
|
|
: dependencies-satisfied? ( word -- ? )
|
2010-01-29 09:12:29 -05:00
|
|
|
"dependency-checks" word-prop [ satisfied? ] all? ;
|
2010-01-29 03:40:09 -05:00
|
|
|
|
2010-01-29 08:58:39 -05:00
|
|
|
: outdated-conditional-usages ( assoc -- assocs )
|
2010-01-29 03:40:09 -05:00
|
|
|
[
|
|
|
|
drop
|
|
|
|
compiled-usage
|
2010-01-29 03:53:14 -05:00
|
|
|
[ nip conditional-dependency dependency>= ] assoc-filter
|
2010-01-29 03:40:09 -05:00
|
|
|
[ drop dependencies-satisfied? not ] assoc-filter
|
|
|
|
] { } assoc>map ;
|
|
|
|
|
2009-11-08 07:08:04 -05:00
|
|
|
: compiled-generic-usage ( word -- assoc )
|
|
|
|
compiled-generic-crossref get at ;
|
|
|
|
|
|
|
|
: (compiled-xref) ( word dependencies word-prop variable -- )
|
2009-11-08 07:22:39 -05:00
|
|
|
[ [ concat ] dip set-word-prop ] [ get add-vertex* ] bi-curry* 2bi ;
|
2009-11-08 07:08:04 -05:00
|
|
|
|
|
|
|
: compiled-xref ( word dependencies generic-dependencies -- )
|
2009-11-08 07:22:39 -05:00
|
|
|
[ [ drop crossref? ] { } assoc-filter-as ] bi@
|
2009-11-08 07:08:04 -05:00
|
|
|
[ "compiled-uses" compiled-crossref (compiled-xref) ]
|
|
|
|
[ "compiled-generic-uses" compiled-generic-crossref (compiled-xref) ]
|
|
|
|
bi-curry* bi ;
|
|
|
|
|
|
|
|
: (compiled-unxref) ( word word-prop variable -- )
|
2010-01-20 18:06:28 -05:00
|
|
|
[ '[ dup _ word-prop 2 <groups> _ get remove-vertex* ] ]
|
|
|
|
[ drop '[ _ remove-word-prop ] ]
|
2009-11-08 07:08:04 -05:00
|
|
|
2bi bi ;
|
|
|
|
|
|
|
|
: compiled-unxref ( word -- )
|
|
|
|
[ "compiled-uses" compiled-crossref (compiled-unxref) ]
|
|
|
|
[ "compiled-generic-uses" compiled-generic-crossref (compiled-unxref) ]
|
2010-01-29 09:12:29 -05:00
|
|
|
[ f "dependency-checks" set-word-prop ]
|
2010-01-29 03:40:09 -05:00
|
|
|
tri ;
|
2009-11-08 07:08:04 -05:00
|
|
|
|
|
|
|
: delete-compiled-xref ( word -- )
|
|
|
|
[ compiled-unxref ]
|
|
|
|
[ compiled-crossref get delete-at ]
|
|
|
|
[ compiled-generic-crossref get delete-at ]
|
|
|
|
tri ;
|
2010-01-29 03:40:09 -05:00
|
|
|
|
|
|
|
: save-conditional-dependencies ( word deps -- )
|
2010-01-29 09:12:29 -05:00
|
|
|
>array f like "dependency-checks" set-word-prop ;
|