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 inspector effects debugger
8 M: inference-error error.
10 keys [ dup value? [ value-literal ] when ] map
11 dup empty? [ "Word: " write dup peek . ] unless
12 swap error>> error. "Nesting: " write . ;
14 M: inference-error error-help drop f ;
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" ;
33 "Unable to infer stack effect of " write word>> . ;
35 M: no-recursive-declaration error.
36 "The recursive word " write
38 " must declare a stack effect" print ;
40 M: effect-error error.
41 "Stack effects of the word " write
43 " do not match." print
45 dup word>> stack-effect effect>string .
46 "Inferred: " write effect>> effect>string . ;
48 M: recursive-quotation-error error.
49 "The quotation " write
51 " calls itself." print
52 "Stack effect inference is undecidable when quotation-level recursion is permitted." print ;
54 M: cannot-unify-specials summary
56 "Cannot unify branches with inconsistent special values" ;