1 ! Copyright (C) 2006, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: kernel sequences namespaces assocs graphs ;
6 ERROR: no-compilation-unit definition ;
8 SYMBOL: changed-definitions
13 : changed-definition ( defspec how -- )
14 swap changed-definitions get
15 [ set-at ] [ no-compilation-unit ] if* ;
19 : new-class ( word -- )
21 [ set-at ] [ no-compilation-unit ] if* ;
23 : new-class? ( word -- ? )
24 new-classes get key? ;
26 GENERIC: where ( defspec -- loc )
28 M: object where drop f ;
30 GENERIC: set-where ( loc defspec -- )
32 GENERIC: forget* ( defspec -- )
34 M: object forget* drop ;
36 SYMBOL: forgotten-definitions
38 : forgotten-definition ( defspec -- )
39 dup forgotten-definitions get
40 [ no-compilation-unit ] unless*
43 : forget ( defspec -- ) dup forgotten-definition forget* ;
45 : forget-all ( definitions -- ) [ forget ] each ;
47 GENERIC: synopsis* ( defspec -- )
49 GENERIC: definer ( defspec -- start end )
51 GENERIC: definition ( defspec -- seq )
55 GENERIC: uses ( defspec -- seq )
57 M: object uses drop f ;
59 : xref ( defspec -- ) dup uses crossref get add-vertex ;
61 : usage ( defspec -- seq ) crossref get at keys ;
63 GENERIC: irrelevant? ( defspec -- ? )
65 M: object irrelevant? drop f ;
67 GENERIC: smart-usage ( defspec -- seq )
69 M: f smart-usage drop \ f smart-usage ;
71 M: object smart-usage usage [ irrelevant? not ] filter ;
73 : unxref ( defspec -- )
74 dup uses crossref get remove-vertex ;
76 : delete-xref ( defspec -- )
77 dup unxref crossref get delete-at ;