]> gitweb.factorcode.org Git - factor.git/blob - core/definitions/definitions.factor
Fixing everything for mandatory stack effects
[factor.git] / core / definitions / definitions.factor
1 ! Copyright (C) 2006, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: definitions
4 USING: kernel sequences namespaces assocs graphs ;
5
6 ERROR: no-compilation-unit definition ;
7
8 SYMBOL: changed-definitions
9
10 SYMBOL: +inlined+
11 SYMBOL: +called+
12
13 : changed-definition ( defspec how -- )
14     swap changed-definitions get
15     [ set-at ] [ no-compilation-unit ] if* ;
16
17 SYMBOL: new-classes
18
19 : new-class ( word -- )
20     dup new-classes get
21     [ set-at ] [ no-compilation-unit ] if* ;
22
23 : new-class? ( word -- ? )
24     new-classes get key? ;
25
26 GENERIC: where ( defspec -- loc )
27
28 M: object where drop f ;
29
30 GENERIC: set-where ( loc defspec -- )
31
32 GENERIC: forget* ( defspec -- )
33
34 M: object forget* drop ;
35
36 SYMBOL: forgotten-definitions
37
38 : forgotten-definition ( defspec -- )
39     dup forgotten-definitions get
40     [ no-compilation-unit ] unless*
41     set-at ;
42
43 : forget ( defspec -- ) dup forgotten-definition forget* ;
44
45 : forget-all ( definitions -- ) [ forget ] each ;
46
47 GENERIC: synopsis* ( defspec -- )
48
49 GENERIC: definer ( defspec -- start end )
50
51 GENERIC: definition ( defspec -- seq )
52
53 SYMBOL: crossref
54
55 GENERIC: uses ( defspec -- seq )
56
57 M: object uses drop f ;
58
59 : xref ( defspec -- ) dup uses crossref get add-vertex ;
60
61 : usage ( defspec -- seq ) crossref get at keys ;
62
63 GENERIC: irrelevant? ( defspec -- ? )
64
65 M: object irrelevant? drop f ;
66
67 GENERIC: smart-usage ( defspec -- seq )
68
69 M: f smart-usage drop \ f smart-usage ;
70
71 M: object smart-usage usage [ irrelevant? not ] filter ;
72
73 : unxref ( defspec -- )
74     dup uses crossref get remove-vertex ;
75
76 : delete-xref ( defspec -- )
77     dup unxref crossref get delete-at ;