]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/stack-checker/stack-checker.factor
Infer non-callables as though they're self-evaluating
[factor.git] / basis / stack-checker / stack-checker.factor
index c990a51cc184bd807adce0a04ba6bc4c7515209e..09cdc08b256b8ada7355705a70226a3f83b9dca8 100644 (file)
@@ -1,27 +1,20 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel io effects namespaces sequences quotations vocabs
-generic words stack-checker.backend stack-checker.state
+USING: accessors kernel io effects namespaces sequences
+quotations vocabs vocabs.loader generic words
+stack-checker.backend stack-checker.state
 stack-checker.known-words stack-checker.transforms
 stack-checker.errors stack-checker.inlining
 stack-checker.visitor.dummy ;
 IN: stack-checker
 
-GENERIC: infer ( quot -- effect )
-
-M: callable infer ( quot -- effect )
-    [ infer-quot-here ] with-infer drop ;
+: infer ( quot -- effect )
+    dup callable?
+    [ [ infer-quot-here ] with-infer drop ]
+    [ drop ( -- x ) ] if ;
 
 : infer. ( quot -- )
-    #! Safe to call from inference transforms.
+    ! Safe to call from inference transforms.
     infer effect>string print ;
 
-: forget-errors ( -- )
-    all-words [
-        dup subwords [ f "cannot-infer" set-word-prop ] each
-        f "cannot-infer" set-word-prop
-    ] each ;
-
-: forget-effects ( -- )
-    forget-errors
-    all-words [ f "inferred-effect" set-word-prop ] each ;
+M: callable stack-effect infer ;