]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix bug with values and deployment, add new to: sugar
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 28 Sep 2008 05:40:41 +0000 (00:40 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 28 Sep 2008 05:40:41 +0000 (00:40 -0500)
basis/io/encodings/iana/iana.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/test/6/6.factor [new file with mode: 0644]
basis/tools/deploy/test/6/deploy.factor [new file with mode: 0644]
basis/unicode/breaks/breaks.factor
basis/unicode/collation/collation.factor
basis/unicode/data/data.factor
basis/unicode/script/script.factor
basis/values/values-docs.factor
basis/values/values-tests.factor
basis/values/values.factor

index dcd806d9a07f44807bc747ead05b0f0857ef7b1a..19b887cd75c6b586d3793f57d0c861b90ebadfc0 100755 (executable)
@@ -59,4 +59,4 @@ PRIVATE>
 PRIVATE>
 
 "resource:basis/io/encodings/iana/character-sets"
-ascii <file-reader> make-n>e \ n>e-table set-value
+ascii <file-reader> make-n>e to: n>e-table
index acee098b8ff53a22c56cfca37956644fe2d0b72d..1d5b59bf0cf2312d204334c28e2ead00b5830207 100755 (executable)
@@ -43,6 +43,11 @@ namespaces continuations layouts accessors ;
 \r
 [ t ] [ 2500000 small-enough? ] unit-test\r
 \r
+: run-temp-image ( -- )\r
+    vm\r
+    "-i=" "test.image" temp-file append\r
+    2array try-process ;\r
+\r
 {\r
     "tools.deploy.test.1"\r
     "tools.deploy.test.2"\r
@@ -51,9 +56,7 @@ namespaces continuations layouts accessors ;
 } [\r
     [ ] swap [\r
         shake-and-bake\r
-        vm\r
-        "-i=" "test.image" temp-file append\r
-        2array try-process\r
+        run-temp-image\r
     ] curry unit-test\r
 ] each\r
 \r
@@ -88,9 +91,12 @@ M: quit-responder call-responder*
 \r
 [ ] [\r
     "tools.deploy.test.5" shake-and-bake\r
-    vm\r
-    "-i=" "test.image" temp-file append\r
-    2array try-process\r
+    run-temp-image\r
 ] unit-test\r
 \r
 [ ] [ "http://localhost:1237/quit" http-get 2drop ] unit-test\r
+\r
+[ ] [\r
+    "tools.deploy.test.6" shake-and-bake\r
+    run-temp-image\r
+] unit-test\r
diff --git a/basis/tools/deploy/test/6/6.factor b/basis/tools/deploy/test/6/6.factor
new file mode 100644 (file)
index 0000000..da64bb6
--- /dev/null
@@ -0,0 +1,13 @@
+IN: tools.deploy.test.6
+USING: values math kernel ;
+
+VALUE: x
+
+VALUE: y
+
+: deploy-test-6 ( -- )
+    1 to: x
+    2 to: y
+    x y + 3 assert= ;
+
+MAIN: deploy-test-6
diff --git a/basis/tools/deploy/test/6/deploy.factor b/basis/tools/deploy/test/6/deploy.factor
new file mode 100644 (file)
index 0000000..410bb77
--- /dev/null
@@ -0,0 +1,15 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-threads? f }
+    { deploy-ui? f }
+    { deploy-io 1 }
+    { deploy-c-types? f }
+    { deploy-name "tools.deploy.test.6" }
+    { deploy-compiler? t }
+    { deploy-reflection 1 }
+    { deploy-word-props? f }
+    { deploy-word-defs? f }
+    { "stop-after-last-window?" t }
+    { deploy-random? f }
+    { deploy-math? f }
+}
index 88381ca7d704ad6fd0fb32bb13f0cd58f57e9552..6aa3e606473104000688dcdfbea27d4760cf94a0 100755 (executable)
@@ -98,5 +98,4 @@ VALUE: grapheme-table
 
 init-grapheme-table table
 [ make-grapheme-table finish-table ] with-variable
-\ grapheme-table set-value
-
+to: grapheme-table
index 3ebb474a8195d681bcfc2590ad2b38119f3d3066..8e9e2963a8cea0be9c49e0f2a59025d53914d755 100755 (executable)
@@ -27,7 +27,7 @@ TUPLE: weight primary secondary tertiary ignorable? ;
     [ parse-line ] H{ } map>assoc ;\r
 \r
 "resource:basis/unicode/collation/allkeys.txt"\r
-ascii <file-reader> parse-ducet \ ducet set-value\r
+ascii <file-reader> parse-ducet to: ducet\r
 \r
 ! Fix up table for long contractions\r
 : help-one ( assoc key -- )\r
index 6d6ed276a8848a86d17317af1887308887902b8f..cd54b93f2a258bb1b255647db5c03baf68600c58 100755 (executable)
@@ -164,18 +164,16 @@ C: <code-point> code-point
     [ [ set-code-point ] each ] H{ } make-assoc ;
 
 load-data {
-    [ process-names \ name-map set-value ]
-    [ 13 swap process-data \ simple-lower set-value ]
-    [ 12 swap process-data \ simple-upper set-value ]
-    [ 14 swap process-data
-        simple-upper assoc-union \ simple-title set-value ]
-    [ process-combining \ class-map set-value ]
-    [ process-canonical \ canonical-map set-value
-        \ combine-map set-value ]
-    [ process-compatibility \ compatibility-map set-value ]
-    [ process-category \ category-map set-value ]
+    [ process-names to: name-map ]
+    [ 13 swap process-data to: simple-lower ]
+    [ 12 swap process-data to: simple-upper ]
+    [ 14 swap process-data simple-upper assoc-union to: simple-title ]
+    [ process-combining to: class-map ]
+    [ process-canonical to: canonical-map to: combine-map ]
+    [ process-compatibility to: compatibility-map ]
+    [ process-category to: category-map ]
 } cleave
 
-load-special-casing \ special-casing set-value
+load-special-casing to: special-casing
 
-load-properties \ properties set-value
+load-properties to: properties
index aa9ca843bd17a9853c83b780b8bb1edabe0e3c5a..103beb4d2a0d1c24c5865d15ee94870366f2d506 100755 (executable)
@@ -32,7 +32,7 @@ SYMBOL: interned
 
 : process-script ( ranges -- )
     dup values prune >symbols interned [
-        expand-ranges \ script-table set-value
+        expand-ranges to: script-table
     ] with-variable ;
 
 : load-script ( -- )
index 4984b03f039bb7470dcd3cbb97029967b1e73863..c96ea0f8cfbdc5a0512d79eb1633ac4c9bd2ce23 100755 (executable)
@@ -7,6 +7,7 @@ ARTICLE: "values" "Global values"
 "To get the value, just call the word. The following words manipulate values:"\r
 { $subsection get-value }\r
 { $subsection set-value }\r
+{ $subsection POSTPONE: to: }\r
 { $subsection change-value } ;\r
 \r
 HELP: VALUE:\r
@@ -20,8 +21,19 @@ HELP: get-value
 \r
 HELP: set-value\r
 { $values { "value" "a new value" } { "word" "a value word" } }\r
-{ $description "Sets the value word." } ;\r
+{ $description "Sets a value word." } ;\r
+\r
+HELP: to:\r
+{ $syntax "... to: value" }\r
+{ $values { "word" "a value word" } }\r
+{ $description "Sets a value word." }\r
+{ $notes\r
+    "Note that"\r
+    { $code "foo to: value" }\r
+    "is just sugar for"\r
+    { $code "foo \\ value set-value" }\r
+} ;\r
 \r
 HELP: change-value\r
-{ $values { "word" "a value word" } { "quot" "a quotation ( oldvalue -- newvalue )" } }\r
+{ $values { "word" "a value word" } { "quot" "a quotation with stack effect " { $snippet "( oldvalue -- newvalue )" } } }\r
 { $description "Changes the value using the given quotation." } ;\r
index 31b44be99eff0c5827f5019ed4381b622525025f..6ad5e7dee61fc74310d750798da49404a154e375 100755 (executable)
@@ -3,7 +3,7 @@ IN: values.tests
 \r
 VALUE: foo\r
 [ f ] [ foo ] unit-test\r
-[ ] [ 3 \ foo set-value ] unit-test\r
+[ ] [ 3 to: foo ] unit-test\r
 [ 3 ] [ foo ] unit-test\r
 [ ] [ \ foo [ 1+ ] change-value ] unit-test\r
 [ 4 ] [ foo ] unit-test\r
index 7f19898b18ab1eecf0bcb90f6c762a78d9fdd3f9..0dd1058370a75ab334c984b88bcffd45d74a410d 100755 (executable)
@@ -1,15 +1,42 @@
-USING: accessors kernel parser sequences words effects ;
+! Copyright (C) 2008 Daniel Ehrenberg.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel parser words sequences quotations ;
 IN: values
 
+! Mutating literals in word definitions is not really allowed,
+! and the deploy tool takes advantage of this fact to perform
+! some aggressive stripping and compression. However, this
+! breaks a naive implementation of values. We need to do two
+! things:
+! 1) Store the value in a subclass of identity-tuple, so that
+! two quotations from different value words are never equal.
+! This avoids bogus merging of values.
+! 2) Set the "no-def-strip" word-prop, so that the shaker leaves
+! the def>> slot alone, allowing us to introspect it. Otherwise,
+! it will get set to [ ] and we would lose access to the
+! value-holder.
+
+<PRIVATE
+
+TUPLE: value-holder < identity-tuple obj ;
+
+PRIVATE>
+
 : VALUE:
-    CREATE-WORD { f } clone [ first ] curry
+    CREATE-WORD
+    dup t "no-def-strip" set-word-prop
+    T{ value-holder } clone [ obj>> ] curry
     (( -- value )) define-declared ; parsing
 
 : set-value ( value word -- )
-    def>> first set-first ;
+    def>> first (>>obj) ;
+
+: to:
+    scan-word literalize parsed
+    \ set-value parsed ; parsing
 
 : get-value ( word -- value )
-    def>> first first ;
+    def>> first obj>> ;
 
 : change-value ( word quot -- )
-    over >r >r get-value r> call r> set-value ; inline
+    [ [ get-value ] dip call ] [ drop ] 2bi set-value ; inline