]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/compiler/tree/propagation/inlining/inlining.factor
Merge branch 'master' of git://factorcode.org/git/factor into propagation
[factor.git] / basis / compiler / tree / propagation / inlining / inlining.factor
index 5375ff68819b246ebc1ec373aaee31cfd019f940..e6c63f149ad827bef29e21ac0f112097e56c8d67 100644 (file)
@@ -5,6 +5,7 @@ math.partial-dispatch generic generic.standard generic.single generic.math
 classes.algebra classes.union sets quotations assocs combinators
 combinators.short-circuit words namespaces continuations classes
 fry hints locals
+stack-checker.dependencies
 compiler.tree
 compiler.tree.builder
 compiler.tree.recursive
@@ -47,12 +48,31 @@ M: callable splicing-nodes splicing-body ;
         ] if
     ] [ 2drop undo-inlining ] if ;
 
+ERROR: bad-splitting class generic ;
+
+:: split-code ( class generic -- quot/f )
+    class generic method :> my-method
+    my-method [ class generic bad-splitting ] unless
+    class generic my-method depends-on-method-is
+    generic dispatch# (picker) :> picker
+    [
+        picker call class instance?
+        [ my-method execute ]
+        [ generic no-method ] if
+    ] ;
+
+:: split-method-call ( class generic -- quot/f )
+    class generic subclass-with-only-method [
+        [ class generic depends-on-single-method ]
+        [ generic split-code ] bi
+    ] [ f ] if* ;
+
 : inlining-standard-method ( #call word -- class/f method/f )
     dup "methods" word-prop assoc-empty? [ 2drop f f ] [
         2dup [ in-d>> length ] [ dispatch# ] bi* <= [ 2drop f f ] [
             [ in-d>> <reversed> ] [ [ dispatch# ] keep ] bi*
             [ swap nth value-info class>> dup ] dip
-            method-for-class
+            { [ method-for-class ] [ split-method-call ] } 2||
         ] if
     ] if ;