From 9382c674372f55be58cd64ce903c87c3d08d2d4d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 15 Sep 2009 16:24:58 -0500 Subject: [PATCH 1/2] alien.syntax: improve C-ENUM: docs --- basis/alien/syntax/syntax-docs.factor | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index c9190f68c0..e56c83a154 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -73,10 +73,12 @@ HELP: C-ENUM: { $syntax "C-ENUM: words... ;" } { $values { "words" "a sequence of word names" } } { $description "Creates a sequence of word definitions in the current vocabulary. Each word pushes an integer according to its index in the enumeration definition. The first word pushes 0." } -{ $notes "This word emulates a C-style " { $snippet "enum" } " in Factor. While this feature can be used for any purpose, using integer constants is discouraged unless it is for interfacing with C libraries. Factor code should use symbolic constants instead." } +{ $notes "This word emulates a C-style " { $snippet "enum" } " in Factor. While this feature can be used for any purpose, using integer constants is discouraged unless it is for interfacing with C libraries. Factor code should use " { $link "words.symbol" } " or " { $link "singletons" } " instead." } { $examples - "The following two lines are equivalent:" - { $code "C-ENUM: red green blue ;" ": red 0 ; : green 1 ; : blue 2 ;" } + "Here is an example enumeration definition:" + { $code "C-ENUM: red green blue ;" } + "It is equivalent to the following series of definitions:" + { $code "CONSTANT: red 0" "CONSTANT: green 1" "CONSTANT: blue 2" } } ; HELP: &: From 172219e93105f0e7bffa8c70334cc7209b816b0c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 15 Sep 2009 14:30:20 -0700 Subject: [PATCH 2/2] compiler.tree.propagation: fix unary-op type functions with complex number inputs --- .../compiler/tree/propagation/known-words/known-words.factor | 5 ++++- basis/compiler/tree/propagation/propagation-tests.factor | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/basis/compiler/tree/propagation/known-words/known-words.factor b/basis/compiler/tree/propagation/known-words/known-words.factor index 63d2df543d..621b8d082b 100644 --- a/basis/compiler/tree/propagation/known-words/known-words.factor +++ b/basis/compiler/tree/propagation/known-words/known-words.factor @@ -81,7 +81,10 @@ IN: compiler.tree.propagation.known-words class>> dup null-class? [ drop null ] [ math-closure ] if ; : unary-op-interval ( info quot -- newinterval ) - [ interval>> ] dip call ; inline + [ + dup class>> real classes-intersect? + [ interval>> ] [ drop full-interval ] if + ] dip call ; inline : unary-op ( word interval-quot post-proc-quot -- ) '[ diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index ec5fbd95cd..0c220542ca 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -186,6 +186,10 @@ IN: compiler.tree.propagation.tests [ t ] [ [ { complex } declare absq ] final-info first interval>> [0,inf] = ] unit-test +[ t ] [ [ { float float } declare rect> C{ 0.0 0.0 } + absq ] final-info first interval>> [0,inf] = ] unit-test + +[ V{ float } ] [ [ { float float } declare rect> C{ 0.0 0.0 } + absq ] final-classes ] unit-test + [ t ] [ [ [ - absq ] [ + ] 2map-reduce ] final-info first interval>> [0,inf] = ] unit-test [ t ] [ [ { double-array double-array } declare [ - absq ] [ + ] 2map-reduce ] final-info first interval>> [0,inf] = ] unit-test