]> gitweb.factorcode.org Git - factor.git/commitdiff
new is inlined in the propagation pass when the class is known
authorDaniel Ehrenberg <littledan@Macintosh-122.local>
Tue, 14 Jul 2009 19:16:39 +0000 (14:16 -0500)
committerDaniel Ehrenberg <littledan@Macintosh-122.local>
Tue, 14 Jul 2009 19:16:39 +0000 (14:16 -0500)
basis/compiler/tree/propagation/known-words/known-words.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/stack-checker/transforms/transforms.factor

index b3c8026bc45fd9685cf69cb8623299fbc8f199ca..aec61608f1cb9ca83e7fe63b6840c0f2072ab4b6 100644 (file)
@@ -6,7 +6,7 @@ math.parser math.order layouts words sequences sequences.private
 arrays assocs classes classes.algebra combinators generic.math
 splitting fry locals classes.tuple alien.accessors
 classes.tuple.private slots.private definitions strings.private
-vectors hashtables generic
+vectors hashtables generic quotations
 stack-checker.state
 compiler.tree.comparisons
 compiler.tree.propagation.info
@@ -360,3 +360,15 @@ generic-comparison-ops [
         [ swap equal? ] f ?
     ] [ drop f ] if
 ] "custom-inlining" set-word-prop
+
+: inline-new ( class -- quot/f )
+    dup tuple-class? [
+        dup inlined-dependency depends-on
+        [ all-slots [ initial>> literalize ] map ]
+        [ tuple-layout '[ _ <tuple-boa> ] ]
+        bi append [ drop ] prepend >quotation
+    ] [ drop f ] if ;
+
+\ new [
+    in-d>> first value-info literal>> inline-new
+] "custom-inlining" set-word-prop
index 32c9f4ed0be60a08968722dc8fcd3e25aad055d5..108afad2960ce254cbd5d47d5675aab97c9e8823 100644 (file)
@@ -704,3 +704,16 @@ TUPLE: circle me ;
 
 ! Joe found an oversight
 [ V{ integer } ] [ [ >integer ] final-classes ] unit-test
+
+TUPLE: foo bar ;
+
+[ t ] [ [ foo new ] { new } inlined? ] unit-test
+
+GENERIC: whatever ( x -- y )
+M: number whatever drop foo ;
+
+[ t ] [ [ 1 whatever new ] { new } inlined? ] unit-test
+
+: that-thing ( -- class ) foo ;
+
+[ f ] [ [ that-thing new ] { new } inlined? ] unit-test
index 017594a4ebb9a108287545758c09b7da0ba0bd6d..9d1ab1332a3f8c80aacd710350d203f57fe6cbdd 100755 (executable)
@@ -108,15 +108,6 @@ IN: stack-checker.transforms
 
 \ boa t "no-compile" set-word-prop
 
-\ new [
-    dup tuple-class? [
-        dup inlined-dependency depends-on
-        [ all-slots [ initial>> literalize ] map ]
-        [ tuple-layout '[ _ <tuple-boa> ] ]
-        bi append
-    ] [ drop f ] if
-] 1 define-transform
-
 ! Fast at for integer maps
 CONSTANT: lookup-table-at-max 256