]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'bags' of git://github.com/littledan/Factor
authorDaniel Ehrenberg <littledan@Macintosh-122.local>
Tue, 16 Mar 2010 17:28:00 +0000 (13:28 -0400)
committerDaniel Ehrenberg <littledan@Macintosh-122.local>
Tue, 16 Mar 2010 17:28:00 +0000 (13:28 -0400)
Conflicts:

basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor
basis/furnace/auth/auth.factor
basis/stack-checker/backend/backend.factor

14 files changed:
1  2 
basis/compiler/cfg/representations/preferred/preferred.factor
basis/compiler/cfg/representations/representations.factor
basis/compiler/cfg/rpo/rpo.factor
basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor
basis/compiler/tree/recursive/recursive.factor
basis/farkup/farkup.factor
basis/furnace/auth/auth.factor
basis/help/lint/checks/checks.factor
basis/regexp/minimize/minimize.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/dependencies/dependencies.factor
basis/stack-checker/transforms/transforms.factor
core/combinators/combinators.factor
extra/mason/test/test.factor

index 9ba78dbf46f62af019cf1e5f754c898a688d1817,3be96515de4727509735550a962e0cad8a77cd87..ffb8f9a390023fae41aac499002aa28efab21b04
@@@ -5,6 -5,7 +5,7 @@@ words sets combinators generalizations 
  compiler.cfg.utilities compiler.cfg compiler.cfg.rpo
  compiler.cfg.instructions compiler.cfg.def-use ;
  FROM: compiler.cfg.instructions.syntax => insn-def-slot insn-use-slots insn-temp-slots scalar-rep ;
+ FROM: namespaces => set ;
  IN: compiler.cfg.representations.preferred
  
  GENERIC: defs-vreg-rep ( insn -- rep/f )
@@@ -67,16 -68,16 +68,16 @@@ PRIVATE
      tri
  ] with-compilation-unit
  
 -: each-def-rep ( insn vreg-quot: ( vreg rep -- ) -- )
 +: each-def-rep ( ... insn vreg-quot: ( ... vreg rep -- ... ) -- ... )
      [ [ defs-vreg ] [ defs-vreg-rep ] bi ] dip with when* ; inline
  
 -: each-use-rep ( insn vreg-quot: ( vreg rep -- ) -- )
 +: each-use-rep ( ... insn vreg-quot: ( ... vreg rep -- ... ) -- ... )
      [ [ uses-vregs ] [ uses-vreg-reps ] bi ] dip 2each ; inline
  
 -: each-temp-rep ( insn vreg-quot: ( vreg rep -- ) -- )
 +: each-temp-rep ( ... insn vreg-quot: ( ... vreg rep -- ... ) -- ... )
      [ [ temp-vregs ] [ temp-vreg-reps ] bi ] dip 2each ; inline
  
 -: with-vreg-reps ( cfg vreg-quot: ( vreg rep -- ) -- )
 +: with-vreg-reps ( ..a cfg vreg-quot: ( ..a vreg rep -- ..b ) -- ..b )
      '[
          [ basic-block set ] [
              [
index b14390e9802be0d540a9301d4abffa28032ad408,eaea3b94c86c21847986087e121638f28c64eaef..05e365e5e4258a80e59ddf158b2f45c7e62d72da
@@@ -15,6 -15,7 +15,7 @@@ compiler.cfg.utilitie
  compiler.cfg.loop-detection
  compiler.cfg.renaming.functor
  compiler.cfg.representations.preferred ;
+ FROM: namespaces => set ;
  IN: compiler.cfg.representations
  
  ! Virtual register representation selection.
@@@ -187,7 -188,7 +188,7 @@@ SYMBOLS: renaming-set needs-renaming? 
  : record-renaming ( from to -- )
      2array renaming-set get push needs-renaming? on ;
  
 -:: (compute-renaming-set) ( vreg required quot: ( vreg preferred required -- ) -- )
 +:: (compute-renaming-set) ( ..a vreg required quot: ( ..a vreg preferred required -- ..b ) -- ..b )
      vreg rep-of :> preferred
      preferred required eq?
      [ vreg no-renaming ]
index b569327c83648eb1e45041e6f306ab0268954ada,e99b9c6c1e8ddcd4557c3d13cef36171cd73a525..6e09d9885f32078a8cc74750d3f8647a0e5ed706
@@@ -2,6 -2,7 +2,7 @@@
  ! See http://factorcode.org/license.txt for BSD license.
  USING: kernel accessors namespaces make math sequences sets
  assocs fry compiler.cfg compiler.cfg.instructions ;
+ FROM: namespaces => set ;
  IN: compiler.cfg.rpo
  
  SYMBOL: visited
@@@ -38,7 -39,7 +39,7 @@@
      [ drop basic-block set ]
      [ change-instructions drop ] 2bi ; inline
  
 -: local-optimization ( cfg quot: ( insns -- insns' ) -- cfg' )
 +: local-optimization ( ... cfg quot: ( ... insns -- ... insns' ) -- ... cfg' )
      dupd '[ _ optimize-basic-block ] each-basic-block ; inline
  
  : needs-post-order ( cfg -- cfg' )
index 837b41e47f2a7820cc1443be210f92604f193265,4c2210c493b679bb659dd64cf911da3f89329eda..51eb3c8a98e09006cc41b95eb4eb920dc963c0db
@@@ -3,6 -3,7 +3,7 @@@
  USING: accessors arrays assocs bit-arrays bit-sets fry
  hashtables hints kernel locals math namespaces sequences sets
  compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ;
+ FROM: namespaces => set ;
  IN: compiler.cfg.ssa.construction.tdmsc
  
  ! TDMSC-I algorithm from "A Practical and Fast Iterative Algorithm for
@@@ -15,7 -16,7 +16,7 @@@
  SYMBOLS: visited merge-sets levels again? ;
  
  : init-merge-sets ( cfg -- )
-     post-order dup length '[ _ <bit-array> ] H{ } map>assoc merge-sets set ;
+     post-order dup length '[ _ <bit-set> ] H{ } map>assoc merge-sets set ;
  
  : compute-levels ( cfg -- )
      0 over entry>> associate [
  
  : level ( bb -- n ) levels get at ; inline
  
- : set-bit ( bit-array n -- )
-     [ t ] 2dip swap set-nth ;
  : update-merge-set ( tmp to -- )
      [ merge-sets get ] dip
      '[
          _
-         [ merge-sets get at bit-set-union ]
-         [ dupd number>> set-bit ]
+         [ merge-sets get at union ]
+         [ number>> over adjoin ]
          bi
      ] change-at ;
  
          tmp dom-parent to tmp walk
      ] [ lnode ] if ;
  
 -: each-incoming-j-edge ( bb quot: ( from to -- ) -- )
 +: each-incoming-j-edge ( ... bb quot: ( ... from to -- ... ) -- ... )
      [ [ predecessors>> ] keep ] dip
      '[ _ 2dup j-edge? _ [ 2drop ] if ] each ; inline
  
- : visited? ( pair -- ? ) visited get key? ;
+ : visited? ( pair -- ? ) visited get in? ;
  
  : consistent? ( snode lnode -- ? )
-     [ merge-sets get at ] bi@ swap bit-set-subset? ;
+     [ merge-sets get at ] bi@ subset? ;
  
  : (process-edge) ( from to -- )
      f walk [
@@@ -65,7 -63,7 +63,7 @@@
  
  : process-edge ( from to -- )
      2dup 2array dup visited? [ 3drop ] [
-         visited get conjoin
+         visited get adjoin
          (process-edge)
      ] if ;
  
@@@ -73,7 -71,7 +71,7 @@@
      [ process-edge ] each-incoming-j-edge ;
  
  : compute-merge-set-step ( bfo -- )
-     visited get clear-assoc
+     HS{ } clone visited set
      [ process-block ] each ;
  
  : compute-merge-set-loop ( cfg -- )
      loop ;
  
  : (merge-set) ( bbs -- flags rpo )
-     merge-sets get '[ _ at ] [ bit-set-union ] map-reduce
+     merge-sets get '[ _ at ] [ union ] map-reduce
      cfg get reverse-post-order ; inline
  
- : filter-by ( flags seq -- seq' )
-     [ drop ] selector [ 2each ] dip ;
- HINTS: filter-by { bit-array object } ;
  PRIVATE>
  
  : compute-merge-sets ( cfg -- )
      needs-dominance
  
-     H{ } clone visited set
+     HS{ } clone visited set
      [ compute-levels ]
      [ init-merge-sets ]
      [ compute-merge-set-loop ]
      tri ;
  
- : merge-set-each ( ... bbs quot: ( ... bb -- ... ) -- ... )
-     [ (merge-set) ] dip '[
-         swap _ [ drop ] if
-     ] 2each ; inline
  : merge-set ( bbs -- bbs' )
-      (merge-set) filter-by ;
+      (merge-set) [ members ] dip nths ;
+ : merge-set-each ( bbs quot: ( bb -- ) -- )
+     [ merge-set ] dip each ; inline
index af76cda90384f01f52bb5d81e4a3d26359a234ff,0771b978a71fa43880c4a20aa59a9b0e9d0a1f86..0473e3a3a4cc602a6c0e7cec50161cc1a96bf1f2
@@@ -2,6 -2,7 +2,7 @@@
  ! See http://factorcode.org/license.txt for BSD license.
  USING: kernel assocs arrays namespaces accessors sequences deques fry
  search-deques dlists combinators.short-circuit make sets compiler.tree ;
+ FROM: namespaces => set ;
  IN: compiler.tree.recursive
  
  TUPLE: call-site tail? node label ;
@@@ -102,7 -103,7 +103,7 @@@ SYMBOL: changed
          recursive-nesting get pop*
      ] each ;
  
 -: while-changing ( quot: ( -- ) -- )
 +: while-changing ( ... quot: ( ... -- ... ) -- ... )
      changed? off
      [ call ] [ changed? get [ while-changing ] [ drop ] if ] bi ;
      inline recursive
index 7707c2a2c74e6acd81b2dd6b25c60ad859af9941,fe9bc78ec622014de5f6cf007e5db703f49c208b..406dada1454dee054c277cfd259530693a7fd38b
@@@ -4,6 -4,7 +4,7 @@@ USING: sequences kernel splitting list
  math combinators namespaces urls.encoding xml.syntax xmode.code2html
  xml.data arrays strings vectors xml.writer io.streams.string locals
  unicode.categories ;
+ FROM: namespaces => set ;
  IN: farkup
  
  SYMBOL: relative-link-prefix
@@@ -70,7 -71,7 +71,7 @@@ DEFER: (parse-paragraph
          { CHAR: % inline-code }
      } at ;
  
 -: or-simple-title ( url title/f quot: ( title -- title' ) -- url title' )
 +: or-simple-title ( ... url title/f quot: ( ... title -- ... title' ) -- ... url title' )
      [ "" like dup simple-link-title ] if* ; inline
  
  : parse-link ( string -- paragraph-list )
index 29ab04fe1bfe51f543058b7ad89d01d9cabc9ca8,e7f868759f3ea2b3e7d8ad144b43a779dad3c836..2acb09919d8aa2a0fd35a3d8a154a7e315dab5bb
@@@ -14,7 -14,7 +14,8 @@@ furnace.redirectio
  furnace.boilerplate\r
  furnace.auth.providers\r
  furnace.auth.providers.db ;\r
 +FROM: assocs => change-at ;\r
+ FROM: namespaces => set ;\r
  IN: furnace.auth\r
  \r
  SYMBOL: logged-in-user\r
index 85fa50f2b9638474a5b9ac21224d154344a5e9af,47e171422981bc62e3cf74f57c36ab9ddc5cf6ec..87b44595d27e9d10db7108a13153754f158ae2d2
@@@ -6,6 -6,7 +6,7 @@@ help help.markup help.topics io.streams
  namespaces sequences sequences.deep sets sorting splitting
  strings unicode.categories values vocabs vocabs.loader words
  words.symbol summary debugger io ;
+ FROM: sets => members ;
  IN: help.lint.checks
  
  ERROR: simple-lint-error message ;
@@@ -36,27 -37,11 +37,27 @@@ SYMBOL: vocab-article
          first rest [ first ] map
      ] unless ;
  
 +: extract-value-effects ( element -- seq )
 +    \ $values swap elements dup empty? [
 +        first rest [ 
 +            \ $quotation swap elements dup empty? [ drop f ] [
 +                first second
 +            ] if
 +        ] map
 +    ] unless ;
 +
  : effect-values ( word -- seq )
      stack-effect
      [ in>> ] [ out>> ] bi append
-     [ dup pair? [ first ] when effect>string ] map prune ;
+     [ dup pair? [ first ] when effect>string ] map members ;
  
 +: effect-effects ( word -- seq )
 +    stack-effect in>> [
 +        dup pair?
 +        [ second dup effect? [ effect>string ] [ drop f ] if ]
 +        [ drop f ] if
 +    ] map ;
 +
  : contains-funky-elements? ( element -- ? )
      {
          $shuffle
              [ effect-values ]
              [ extract-values ]
              bi* sequence=
 -        ]
 +        ] 
      } 2|| [ "$values don't match stack effect" simple-lint-error ] unless ;
  
 +: check-value-effects ( word element -- )
 +    [ effect-effects ]
 +    [ extract-value-effects ]
 +    bi* [ 2dup and [ = ] [ 2drop t ] if ] 2all?
 +    [ "$quotation documentation in $values don't match stack effect" simple-lint-error ]
 +    unless ;
 +
  : check-nulls ( element -- )
      \ $values swap elements
      null swap deep-member?
  
  : check-see-also ( element -- )
      \ $see-also swap elements [
-         rest dup prune [ length ] bi@ assert=
+         rest all-unique? t assert=
      ] each ;
  
  : vocab-exists? ( name -- ? )
index 08f7b1da5860e172e3a6d6d1d7036ba6433e471e,832622e6e1388c14549530fe1722a7b1bffd1ed6..7991efb047f1df9eab29ba7ddab01a6890bae709
@@@ -3,7 -3,6 +3,7 @@@
  USING: kernel sequences regexp.transition-tables fry assocs
  accessors locals math sorting arrays sets hashtables regexp.dfa
  combinators.short-circuit regexp.classes ;
 +FROM: assocs => change-at ;
  IN: regexp.minimize
  
  : table>state-numbers ( table -- assoc )
@@@ -19,7 -18,7 +19,7 @@@
      {
          [ drop <= ]
          [ transitions>> '[ _ at keys ] bi@ set= ]
-         [ final-states>> '[ _ key? ] bi@ = ]
+         [ final-states>> '[ _ in? ] bi@ = ]
      } 3&& ;
  
  :: initialize-partitions ( transition-table -- partitions )
@@@ -52,7 -51,7 +52,7 @@@
      <reversed>
      >hashtable ;
  
 -:: (while-changes) ( obj quot: ( obj -- obj' ) comp: ( obj -- key ) old-key -- obj )
 +:: (while-changes) ( ..a obj quot: ( ..a obj -- ..b obj' ) comp: ( ..b obj' -- ..a key ) old-key -- ..a obj )
      obj quot call :> new-obj
      new-obj comp call :> new-key
      new-key old-key =
index 1e7ae5a9f3a98805ee33e1946a6e7d2039e5124e,ddb1fd0021b75d878dc74fa03d3dd3efff78e72f..51b5f0cdaf6cf58d1294727c17df26534d36f7b7
@@@ -3,10 -3,10 +3,11 @@@
  USING: fry arrays generic io io.streams.string kernel math namespaces
  parser sequences strings vectors words quotations effects classes
  continuations assocs combinators compiler.errors accessors math.order
 -definitions sets hints macros stack-checker.state
 +definitions locals sets hints macros stack-checker.state
  stack-checker.visitor stack-checker.errors stack-checker.values
  stack-checker.recursive-state stack-checker.dependencies summary ;
 +FROM: sequences.private => from-end ;
+ FROM: namespaces => set ;
  IN: stack-checker.backend
  
  : push-d ( obj -- ) meta-d push ;
      [ #introduce, ]
      tri ;
  
 +: update-inner-d ( new -- )
 +    inner-d-index get min inner-d-index set ;
 +
  : pop-d  ( -- obj )
 -    meta-d [ <value> dup 1array introduce-values ] [ pop ] if-empty ;
 +    meta-d
 +    [ <value> dup 1array introduce-values ]
 +    [ pop meta-d length update-inner-d ] if-empty ;
  
  : peek-d ( -- obj ) pop-d dup push-d ;
  
          [ nip >array ] [ length - make-values ] [ nip delete-all ] 2tri
          [ introduce-values ] [ meta-d push-all ] bi
          meta-d push-all
 -    ] when swap tail* ;
 +    ] when
 +    swap from-end [ tail ] [ update-inner-d ] bi ;
  
  : shorten-by ( n seq -- )
      [ length swap - ] keep shorten ; inline
  
 +: shorten-d ( n -- )
 +    meta-d shorten-by meta-d length update-inner-d ;
 +
  : consume-d ( n -- seq )
 -    [ ensure-d ] [ meta-d shorten-by ] bi ;
 +    [ ensure-d ] [ shorten-d ] bi ;
  
  : output-d ( values -- ) meta-d push-all ;
  
@@@ -136,7 -127,7 +137,7 @@@ M: bad-call summar
  : infer-r> ( n -- )
      consume-r dup copy-values [ nip output-d ] [ #r>, ] 2bi ;
  
 -: consume/produce ( effect quot: ( inputs outputs -- ) -- )
 +: consume/produce ( ..a effect quot: ( ..a inputs outputs -- ..b ) -- ..b )
      '[ [ in>> length consume-d ] [ out>> length produce-d ] bi @ ]
      [ terminated?>> [ terminate ] when ]
      bi ; inline
          current-effect
          stack-visitor get
      ] with-scope ; inline
 +
 +: (infer) ( quot -- effect )
 +    [ infer-quot-here ] with-infer drop ;
 +
 +: ?quotation-effect ( in -- effect/f )
 +    dup pair? [ second dup effect? [ drop f ] unless ] [ drop f ] if ;
 +
 +:: declare-effect-d ( word effect variables branches n -- )
 +    meta-d length :> d-length
 +    n d-length < [
 +        d-length 1 - n - :> n'
 +        n' meta-d nth :> value
 +        value known :> known
 +        known word effect variables branches <declared-effect> :> known'
 +        known' value set-known
 +        known' branches push
 +    ] [ word unknown-macro-input ] if ;
 +
 +:: declare-input-effects ( word -- )
 +    H{ } clone :> variables
 +    V{ } clone :> branches
 +    word stack-effect in>> <reversed> [| in n |
 +        in ?quotation-effect [| effect |
 +            word effect variables branches n declare-effect-d
 +        ] when*
 +    ] each-index ;
 +
index 7110fa77abd6b32b718c9c46b442457086679eb4,dcfb3db6bf2b69a1e98754b3594149607ff35447..50d5ff6189f70932793d083f2692d40247c8011e
@@@ -5,6 -5,7 +5,7 @@@ generic kernel math namespaces sequence
  combinators.short-circuit classes.tuple alien.c-types ;
  FROM: classes.tuple.private => tuple-layout ;
  FROM: assocs => change-at ;
+ FROM: namespaces => set ;
  IN: stack-checker.dependencies
  
  ! Words that the current quotation depends on
@@@ -141,7 -142,7 +142,7 @@@ TUPLE: depends-on-final class 
      [ \ depends-on-final add-conditional-dependency ] bi ;
  
  M: depends-on-final satisfied?
 -    class>> final-class? ;
 +    class>> { [ class? ] [ final-class? ] } 1&& ;
  
  : init-dependencies ( -- )
      H{ } clone dependencies set
index 98e20e53303902d2dc310227c2430c2aeeb715c9,9f966bd8b823f07c200fe0ae81e5c14d3acf4993..610d3f8600ea131684e7327b0268544264ed41b5
@@@ -9,6 -9,7 +9,7 @@@ sequences.private generalizations stack
  stack-checker.state stack-checker.visitor stack-checker.errors
  stack-checker.values stack-checker.recursive-state
  stack-checker.dependencies ;
+ FROM: namespaces => set ;
  IN: stack-checker.transforms
  
  : call-transformer ( stack quot -- newquot )
@@@ -18,7 -19,7 +19,7 @@@
  
  :: ((apply-transform)) ( quot values stack rstate -- )
      rstate recursive-state [ stack quot call-transformer ] with-variable
 -    values [ length meta-d shorten-by ] [ #drop, ] bi
 +    values [ length shorten-d ] [ #drop, ] bi
      rstate infer-quot ;
  
  : literal-values? ( values -- ? ) [ literal-value? ] all? ;
index d14564f7b26845ad8933c563e03dee06ef7ebfa8,ce0d04c73c0e6f47940962df6ca89a45bc67fe31..7ef2ed5f9fd9d7dabc0632d81147b1365994dadc
@@@ -147,7 -147,7 +147,7 @@@ ERROR: no-case object 
  : contiguous-range? ( keys -- ? )
      dup [ fixnum? ] all? [
          dup all-unique? [
-             [ prune length ]
+             [ length ]
              [ [ supremum ] [ infimum ] bi - ]
              bi - 1 =
          ] [ drop f ] if
@@@ -193,5 -193,5 +193,5 @@@ M: hashtable hashcode
          [ assoc-hashcode ] [ nip assoc-size ] if
      ] recursive-hashcode ;
  
 -: to-fixed-point ( object quot: ( object(n) -- object(n+1) ) -- object(n) )
 +: to-fixed-point ( ... object quot: ( ... object(n) -- ... object(n+1) ) -- ... object(n) )
      [ keep over = ] keep [ to-fixed-point ] curry unless ; inline recursive
index 2421a288ee17b0adff6b6761109994d46fc2b01d,8593e4741313b65e18d30275f4a1c4a7312022a7..fba3ed58c47e452a8ae8f0124a08cbc47e5da3b2
@@@ -1,12 -1,11 +1,12 @@@
 -! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov.
 +! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
  ! See http://factorcode.org/license.txt for BSD license.
 -USING: accessors assocs benchmark bootstrap.stage2 compiler.errors
 -source-files.errors generic help.html help.lint io.directories
 -io.encodings.utf8 io.files kernel mason.common math namespaces
 -prettyprint sequences sets sorting tools.test tools.time
 -words system io tools.errors vocabs.hierarchy vocabs.errors
 -vocabs.refresh locals ;
 +USING: accessors assocs benchmark bootstrap.stage2
 +compiler.errors source-files.errors generic help.html help.lint
 +io.directories io.encodings.utf8 io.files kernel mason.common
 +math namespaces prettyprint sequences sets sorting tools.test
 +tools.time words system io tools.errors vocabs vocabs.files
 +vocabs.hierarchy vocabs.errors vocabs.refresh locals
 +source-files compiler.units ;
  IN: mason.test
  
  : do-load ( -- )
@@@ -24,7 -23,7 +24,7 @@@ M: method word-vocabulary "method-gener
  :: do-step ( errors summary-file details-file -- )
      errors
      [ error-type +linkage-error+ eq? not ] filter
-     [ file>> ] map prune natural-sort summary-file to-file
+     [ file>> ] map members natural-sort summary-file to-file
      errors details-file utf8 [ errors. ] with-file-writer ;
  
  : do-tests ( -- )
      test-all-errors-file
      do-step ;
  
 +: cleanup-tests ( -- )
 +    ! Free up some code heap space
 +    [
 +        vocabs [ vocab-tests [ forget-source ] each ] each
 +    ] with-compilation-unit ;
 +
  : do-help-lint ( -- )
      help-lint-all lint-failures get values
      help-lint-vocabs-file
@@@ -62,7 -55,7 +62,7 @@@
      "" to-refresh drop 2dup [ empty? not ] either?
      [
          "Boot image is out of date. Changed vocabs:" print
-         append prune [ print ] each
+         members [ print ] each
          flush
          1 exit
      ] [ 2drop ] if ;
@@@ -74,7 -67,6 +74,7 @@@
          [ do-load ] benchmark load-time-file to-file
          [ generate-help ] benchmark html-help-time-file to-file
          [ do-tests ] benchmark test-time-file to-file
 +        cleanup-tests
          [ do-help-lint ] benchmark help-lint-time-file to-file
          [ do-benchmarks ] benchmark benchmark-time-file to-file
          do-compile-errors