]> gitweb.factorcode.org Git - factor.git/blob - basis/fixups/fixups.factor
01472a032608f461a52966cac024a28ecadde5e3
[factor.git] / basis / fixups / fixups.factor
1 ! Copyright (C) 2021 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs classes.tuple continuations kernel sequences
4 slots.private vocabs vocabs.parser ;
5 IN: fixups
6
7 CONSTANT: vocab-renames {
8     { "math.intervals" { "intervals" "0.99" } }
9     { "math.ranges" { "ranges" "0.99" } }
10 }
11
12 CONSTANT: word-renames {
13     { "32bit?" { "layouts:32-bit?" "0.99" } }
14     { "64bit?" { "layouts:64-bit?" "0.99" } }
15     { "lines" { "io:read-lines" "0.99" } }
16     { "words" { "splitting:split-words" "0.99" } }
17     { "contents" { "io:read-contents" "0.99" } }
18     { "exists?" { "io.files:file-exists?" "0.99" } }
19     { "string-lines" { "splitting:split-lines" "0.99" } }
20     { "[-inf,a)" { "math.intervals:[-inf,b)" "0.99" } }
21     { "[-inf,a]" { "math.intervals:[-inf,b]" "0.99" } }
22     { "(a,b)" { "ranges:(a..b)" "0.99" } }
23     { "(a,b]" { "ranges:(a..b]" "0.99" } }
24     { "[a,b)" { "ranges:[a..b)" "0.99" } }
25     { "[a,b]" { "ranges:[a..b]" "0.99" } }
26     { "[0,b)" { "ranges:[0..b)" "0.99" } }
27     { "[0,b]" { "ranges:[0..b]" "0.99" } }
28     { "[1,b)" { "ranges:[1..b)" "0.99" } }
29     { "[1,b]" { "ranges:[1..b]" "0.99" } }
30     { "assoc-combine" { "assocs:assoc-union-all" "0.99" } }
31     { "assoc-refine" { "assocs:assoc-intersect-all" "0.99" } }
32     { "assoc-merge" { "assocs.extras:assoc-collect" "0.99" } }
33     { "assoc-merge!" { "assocs.extras:assoc-collect!" "0.99" } }
34     { "peek-from" { "modern.html:peek1-from" "0.99" } }
35     { "in?" { "interval-sets:interval-in?" "0.99" } }
36     { "substitute" { "regexp.classes:(substitute)" "0.99" } }
37     { "combine" { "sets:union-all" "0.99" } }
38     { "refine" { "sets:intersect-all" "0.99" } }
39     { "read-json-objects" { "json.reader:read-json" "0.99" } }
40     { "init-namespaces" { "namespaces:init-namestack" "0.99" } }
41     { "iota" { "sequences:<iota>" ".98" } }
42     { "git-checkout-existing-branch" { "git-checkout-existing" "0.99" } }
43     { "git-checkout-existing-branch*" { "git-checkout-existing*" "0.99" } }
44     { "tags" { "chloe-tags" "0.99" } }
45     { "(each)" { "sequence-operator" "0.99" } }
46     { "(each-integer)" { "each-integer-from" "0.99" } }
47     { "(find-integer)" { "find-integer-from" "0.99" } }
48     { "(all-integers?)" { "all-integers-from?" "0.99" } }
49     { "short" { "index-or-length" "0.99" } }
50     { "map-integers" { "map-integers-as" "0.99" } }
51     { "deep-subseq?" { "deep-subseq-index?" "0.99" } }
52 }
53
54 : compute-assoc-fixups ( continuation name assoc -- seq )
55     swap '[ drop _ = ] assoc-filter [
56         drop { }
57     ] [
58         swap '[
59             first2 dupd first2
60             " in Factor " glue " renamed to " glue "Fixup: " prepend
61             swap drop no-op-restart
62             _ <restart>
63         ] map
64     ] if-empty ;
65
66 GENERIC: compute-fixups ( continuation error -- seq )
67
68 M: object compute-fixups
69     "error" over ?offset-of-slot
70     [ slot compute-fixups ] [ 2drop { } ] if* ;
71
72 M: f compute-fixups 2drop { } ;
73
74 M: no-vocab compute-fixups
75     [ name>> vocab-renames compute-assoc-fixups ] [ drop { } ] if* ;
76
77 M: no-word-error compute-fixups
78     [ name>> word-renames compute-assoc-fixups ] [ drop { } ] if* ;