From cc90da3690239d181fe5c975f7e56a9ea772c4d8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Aug 2005 07:31:20 +0000 Subject: [PATCH] a few regression fixes --- TODO.FACTOR.txt | 3 ++- library/compiler/compiler.factor | 3 +-- library/compiler/intrinsics.factor | 2 +- library/compiler/simplifier.factor | 2 +- library/inference/optimizer.factor | 31 +++++++++++++------------ library/test/gadgets/gradients.factor | 33 ++++++++++++--------------- library/test/inspector.factor | 17 ++++++++------ library/test/lists/namespaces.factor | 7 ------ library/test/redefine.factor | 4 +--- library/test/strings.factor | 2 +- 10 files changed, 48 insertions(+), 56 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 5a84c7dc9b..cd64d841d0 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,6 +1,6 @@ - reader syntax for arrays, byte arrays, displaced aliens - out of memory error when printing global namespace -- decompile is broken +- removing unneeded #label + ui: @@ -49,6 +49,7 @@ - value type structs - bitfields in C structs - setting struct members that are not * +- callbacks + compiler: diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index cc9b882818..e5f6fc447e 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -50,8 +50,7 @@ M: compound (compile) ( word -- ) : decompile ( word -- ) dup compiled? [ - "Decompiling " write dup . - [ word-primitive ] keep set-word-primitive + "Decompiling " write dup . update-xt ] [ drop ] ifte ; diff --git a/library/compiler/intrinsics.factor b/library/compiler/intrinsics.factor index 3dfe44a471..00d33f4d62 100644 --- a/library/compiler/intrinsics.factor +++ b/library/compiler/intrinsics.factor @@ -201,7 +201,7 @@ sequences vectors words ; \ fixnum* [ ! Turn multiplication by a power of two into a left shift. - dup node-peek dup literal-fixnum? [ + dup node-peek dup literal-immediate? [ literal-value dup power-of-2? [ nip fast-fixnum* ] [ diff --git a/library/compiler/simplifier.factor b/library/compiler/simplifier.factor index 37cc99569f..2a2e1c1482 100644 --- a/library/compiler/simplifier.factor +++ b/library/compiler/simplifier.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: compiler-backend -USING: generic inference kernel lists math namespaces +USING: generic kernel lists math namespaces prettyprint sequences strings words ; ! A peephole optimizer operating on the linear IR. diff --git a/library/inference/optimizer.factor b/library/inference/optimizer.factor index d0f250103f..29f9479902 100644 --- a/library/inference/optimizer.factor +++ b/library/inference/optimizer.factor @@ -82,20 +82,23 @@ M: #return optimize-node* ( node -- node/t ) optimize-fold ; ! #label -GENERIC: calls-label? ( label node -- ? ) +GENERIC: calls-label* ( label node -- ? ) -M: node calls-label? 2drop f ; +M: node calls-label* 2drop f ; -M: #call-label calls-label? node-param eq? ; +M: #call-label calls-label* node-param eq? ; -M: #label optimize-node* ( node -- node/t ) - dup node-param over node-children first calls-label? [ - drop t - ] [ - dup node-children first dup node-successor [ - dup penultimate-node rot - node-successor swap set-node-successor - ] [ - drop node-successor - ] ifte - ] ifte ; +: calls-label? ( label node -- ? ) + [ calls-label? not ] all-nodes-with? not ; + +! M: #label optimize-node* ( node -- node/t ) +! dup node-param over node-children first calls-label? [ +! drop t +! ] [ +! dup node-children first dup node-successor [ +! dup penultimate-node rot +! node-successor swap set-node-successor +! ] [ +! drop node-successor +! ] ifte +! ] ifte ; diff --git a/library/test/gadgets/gradients.factor b/library/test/gadgets/gradients.factor index 6a4870b9e5..b3a8270254 100644 --- a/library/test/gadgets/gradients.factor +++ b/library/test/gadgets/gradients.factor @@ -1,22 +1,17 @@ IN: temporary USING: gadgets namespaces styles test ; -[ - 0 x set - 0 y set - - [ { 255 0 0 } ] [ { 1 0 0 } red green 0 gradient-color ] unit-test - [ { 0 255 0 } ] [ { 1 0 0 } red green 1 gradient-color ] unit-test - - [ 0 100 0 { 255 0 0 } ] - [ { 0 1 0 } red green { 100 200 0 } 0 (gradient-x) ] unit-test - - [ 0 100 100 { 255/2 255/2 0 } ] - [ { 0 1 0 } red green { 100 200 0 } 100 (gradient-x) ] unit-test - - [ 0 0 200 { 255 0 0 } ] - [ { 1 0 0 } red green { 100 200 0 } 0 (gradient-y) ] unit-test - - [ 50 0 200 { 255/2 255/2 0 } ] - [ { 1 0 0 } red green { 100 200 0 } 50 (gradient-y) ] unit-test -] with-scope +[ { 255 0 0 } ] [ { 1 0 0 } red green 0 gradient-color ] unit-test +[ { 0 255 0 } ] [ { 1 0 0 } red green 1 gradient-color ] unit-test + +[ 0 100 0 { 255 0 0 } ] +[ { 0 1 0 } red green { 100 200 0 } 0 (gradient-x) ] unit-test + +[ 0 100 100 { 255/2 255/2 0 } ] +[ { 0 1 0 } red green { 100 200 0 } 100 (gradient-x) ] unit-test + +[ 0 0 200 { 255 0 0 } ] +[ { 1 0 0 } red green { 100 200 0 } 0 (gradient-y) ] unit-test + +[ 50 0 200 { 255/2 255/2 0 } ] +[ { 1 0 0 } red green { 100 200 0 } 50 (gradient-y) ] unit-test diff --git a/library/test/inspector.factor b/library/test/inspector.factor index 7c08ce93b0..5236988e39 100644 --- a/library/test/inspector.factor +++ b/library/test/inspector.factor @@ -1,11 +1,14 @@ IN: temporary -USING: inspector math namespaces prettyprint test ; +USING: kernel inspector math namespaces prettyprint test +sequences ; -[[ "hello" "world" ]] inspect +{ } clone inspector-stack set -[ "hello" ] [ 0 get ] unit-test -[ "world" ] [ 1 get ] unit-test +[[ "hello" "world" ]] (inspect) -[ 1 2 3 ] inspect -f inspect -\ + inspect +[ "hello" ] [ 0 inspector-slots get nth ] unit-test +[ "world" ] [ 1 inspector-slots get nth ] unit-test + +[ 1 2 3 ] (inspect) +f (inspect) +\ + (inspect) diff --git a/library/test/lists/namespaces.factor b/library/test/lists/namespaces.factor index f16a1aacb0..46d795d78e 100644 --- a/library/test/lists/namespaces.factor +++ b/library/test/lists/namespaces.factor @@ -32,10 +32,3 @@ USE: sequences "hello" "x" unique@ "x" get ] unit-test - -[ [ "xyz" #{ 3 2 }# 1/5 [ { } ] ] ] [ - [ "xyz" , "xyz" unique, - #{ 3 2 }# , #{ 3 2 }# unique, - 1/5 , 1/5 unique, - [ { } unique, ] [ ] make , ] [ ] make -] unit-test diff --git a/library/test/redefine.factor b/library/test/redefine.factor index eb08293aeb..8cad84c759 100644 --- a/library/test/redefine.factor +++ b/library/test/redefine.factor @@ -1,7 +1,5 @@ IN: temporary -USING: compiler inference math generic parser ; - -USE: test +USING: compiler inference math generic parser test ; : foo 1 2 ; : bar foo foo ; compiled diff --git a/library/test/strings.factor b/library/test/strings.factor index de36d62a93..03b59d067e 100644 --- a/library/test/strings.factor +++ b/library/test/strings.factor @@ -73,7 +73,7 @@ unit-test [ f ] [ [ 0 10 "hello" subseq ] [ not ] catch ] unit-test -[ [ "hell" "o wo" "rld" ] ] [ 4 "hello world" group ] unit-test +[ { "hell" "o wo" "rld" } ] [ 4 "hello world" group ] unit-test [ 4 ] [ 0 "There are Four Upper Case characters"