1 ! Copyright (C) 2006, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: inference.backend inference.dataflow kernel generic
5 sequences prettyprint io words arrays summary effects debugger
8 M: inference-error error-help error>> error-help ;
10 M: inference-error error.
12 keys [ dup value? [ value-literal ] when ] map
13 dup empty? [ "Word: " write dup peek . ] unless
14 swap error>> error. "Nesting: " write . ;
16 M: unbalanced-branches-error error.
17 "Unbalanced branches:" print
18 [ quots>> ] [ in>> ] [ out>> [ length ] map ] tri 3array flip
19 [ [ bl ] [ pprint ] interleave nl ] each ;
21 M: literal-expected summary
22 drop "Literal value expected" ;
24 M: too-many->r summary
26 "Quotation pushes elements on retain stack without popping them" ;
28 M: too-many-r> summary
30 "Quotation pops retain stack elements which it did not push" ;
32 M: cannot-infer-effect error.
33 "Unable to infer stack effect of " write word>> . ;
35 M: missing-effect error.
38 " must declare a stack effect" print ;
40 M: effect-error error.
41 "Stack effects of the word " write
42 [ word>> pprint " do not match." print ]
43 [ "Inferred: " write inferred>> effect>string . ]
44 [ "Declared: " write declared>> effect>string . ] tri ;
46 M: recursive-quotation-error error.
47 "The quotation " write
49 " calls itself." print
50 "Stack effect inference is undecidable when quotation-level recursion is permitted." print ;
52 M: cannot-unify-specials summary
54 "Cannot unify branches with inconsistent special values" ;