]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorJoe Groff <joe@victoria.(none)>
Fri, 14 Aug 2009 14:55:05 +0000 (10:55 -0400)
committerJoe Groff <joe@victoria.(none)>
Fri, 14 Aug 2009 14:55:05 +0000 (10:55 -0400)
828 files changed:
basis/alarms/alarms-tests.factor
basis/alarms/alarms.factor
basis/alien/arrays/arrays.factor
basis/alien/c-types/c-types-tests.factor
basis/alien/c-types/c-types.factor
basis/alien/complex/complex-tests.factor
basis/alien/complex/complex.factor
basis/alien/complex/functor/functor-tests.factor [deleted file]
basis/alien/complex/functor/functor.factor
basis/alien/destructors/destructors-tests.factor [deleted file]
basis/alien/fortran/fortran.factor
basis/alien/libraries/libraries-tests.factor
basis/alien/structs/structs-tests.factor
basis/alien/structs/structs.factor
basis/alien/syntax/syntax.factor
basis/ascii/ascii-tests.factor
basis/base64/base64.factor
basis/biassocs/biassocs-tests.factor
basis/binary-search/binary-search-tests.factor
basis/bit-arrays/bit-arrays.factor
basis/bit-sets/bit-sets-tests.factor
basis/bit-vectors/bit-vectors-tests.factor
basis/bitstreams/bitstreams-tests.factor
basis/bitstreams/bitstreams.factor
basis/bootstrap/compiler/timing/timing.factor
basis/bootstrap/image/image-tests.factor
basis/bootstrap/image/image.factor
basis/bootstrap/image/upload/upload.factor
basis/bootstrap/math/math.factor
basis/boxes/boxes-tests.factor
basis/byte-arrays/hex/hex.factor
basis/cache/cache-tests.factor [deleted file]
basis/cache/cache.factor
basis/cairo/cairo-tests.factor
basis/calendar/calendar-docs.factor
basis/calendar/calendar.factor
basis/calendar/format/format.factor
basis/channels/examples/examples.factor
basis/checksums/fnv1/fnv1.factor
basis/checksums/md5/md5-tests.factor
basis/circular/circular-tests.factor
basis/circular/circular.factor
basis/cocoa/callbacks/callbacks.factor
basis/cocoa/cocoa-tests.factor
basis/cocoa/messages/messages.factor
basis/cocoa/plists/plists-tests.factor
basis/colors/hsv/hsv-tests.factor
basis/columns/columns-tests.factor
basis/combinators/short-circuit/short-circuit-docs.factor
basis/combinators/short-circuit/smart/smart-tests.factor
basis/combinators/short-circuit/smart/smart.factor
basis/combinators/smart/smart-docs.factor
basis/combinators/smart/smart-tests.factor
basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor [deleted file]
basis/compiler/cfg/alias-analysis/alias-analysis.factor
basis/compiler/cfg/block-joining/block-joining.factor
basis/compiler/cfg/branch-splitting/branch-splitting-tests.factor
basis/compiler/cfg/branch-splitting/branch-splitting.factor
basis/compiler/cfg/build-stack-frame/build-stack-frame.factor
basis/compiler/cfg/builder/builder-tests.factor
basis/compiler/cfg/builder/builder.factor
basis/compiler/cfg/cfg-tests.factor [deleted file]
basis/compiler/cfg/cfg.factor
basis/compiler/cfg/copy-prop/copy-prop.factor
basis/compiler/cfg/critical-edges/critical-edges-tests.factor [deleted file]
basis/compiler/cfg/critical-edges/critical-edges.factor [deleted file]
basis/compiler/cfg/dataflow-analysis/dataflow-analysis.factor
basis/compiler/cfg/dce/dce-tests.factor
basis/compiler/cfg/dce/dce.factor
basis/compiler/cfg/debugger/debugger.factor
basis/compiler/cfg/def-use/def-use-tests.factor
basis/compiler/cfg/def-use/def-use.factor
basis/compiler/cfg/dominance/dominance-tests.factor
basis/compiler/cfg/dominance/dominance.factor
basis/compiler/cfg/empty-blocks/empty-blocks.factor
basis/compiler/cfg/gc-checks/gc-checks-tests.factor
basis/compiler/cfg/gc-checks/gc-checks.factor
basis/compiler/cfg/hats/hats.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/intrinsics/alien/alien.factor
basis/compiler/cfg/intrinsics/allot/allot.factor
basis/compiler/cfg/intrinsics/float/float.factor
basis/compiler/cfg/intrinsics/intrinsics.factor
basis/compiler/cfg/intrinsics/slots/slots.factor
basis/compiler/cfg/linear-scan/allocation/allocation.factor
basis/compiler/cfg/linear-scan/allocation/coalescing/coalescing.factor [deleted file]
basis/compiler/cfg/linear-scan/allocation/splitting/splitting.factor
basis/compiler/cfg/linear-scan/allocation/state/state.factor
basis/compiler/cfg/linear-scan/assignment/assignment.factor
basis/compiler/cfg/linear-scan/debugger/debugger.factor
basis/compiler/cfg/linear-scan/linear-scan-tests.factor
basis/compiler/cfg/linear-scan/linear-scan.factor
basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor
basis/compiler/cfg/linear-scan/numbering/numbering.factor
basis/compiler/cfg/linear-scan/resolve/resolve-tests.factor
basis/compiler/cfg/linear-scan/resolve/resolve.factor
basis/compiler/cfg/linearization/linearization-tests.factor [deleted file]
basis/compiler/cfg/linearization/linearization.factor
basis/compiler/cfg/linearization/order/order.factor
basis/compiler/cfg/liveness/liveness-tests.factor
basis/compiler/cfg/liveness/liveness.factor
basis/compiler/cfg/liveness/ssa/ssa.factor [new file with mode: 0644]
basis/compiler/cfg/loop-detection/loop-detection-tests.factor [new file with mode: 0644]
basis/compiler/cfg/loop-detection/loop-detection.factor [new file with mode: 0644]
basis/compiler/cfg/mr/mr.factor
basis/compiler/cfg/optimizer/optimizer-tests.factor [deleted file]
basis/compiler/cfg/optimizer/optimizer.factor
basis/compiler/cfg/parallel-copy/parallel-copy-tests.factor
basis/compiler/cfg/parallel-copy/parallel-copy.factor
basis/compiler/cfg/predecessors/predecessors.factor
basis/compiler/cfg/registers/registers.factor
basis/compiler/cfg/renaming/renaming.factor
basis/compiler/cfg/representations/preferred/preferred.factor [new file with mode: 0644]
basis/compiler/cfg/representations/representations-tests.factor [new file with mode: 0644]
basis/compiler/cfg/representations/representations.factor [new file with mode: 0644]
basis/compiler/cfg/rpo/rpo.factor
basis/compiler/cfg/ssa/construction/construction-tests.factor
basis/compiler/cfg/ssa/construction/construction.factor
basis/compiler/cfg/ssa/construction/tdmsc/tdmsc-tests.factor
basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor
basis/compiler/cfg/ssa/cssa/cssa.factor
basis/compiler/cfg/ssa/destruction/destruction.factor
basis/compiler/cfg/ssa/interference/interference-tests.factor
basis/compiler/cfg/ssa/interference/interference.factor
basis/compiler/cfg/ssa/interference/live-ranges/live-ranges.factor
basis/compiler/cfg/ssa/liveness/liveness-tests.factor
basis/compiler/cfg/ssa/liveness/liveness.factor
basis/compiler/cfg/stack-frame/stack-frame.factor
basis/compiler/cfg/stacks/finalize/finalize.factor
basis/compiler/cfg/stacks/global/global.factor
basis/compiler/cfg/stacks/local/local.factor
basis/compiler/cfg/stacks/stacks.factor
basis/compiler/cfg/stacks/uninitialized/uninitialized-tests.factor
basis/compiler/cfg/stacks/uninitialized/uninitialized.factor
basis/compiler/cfg/tco/tco.factor
basis/compiler/cfg/two-operand/two-operand-tests.factor
basis/compiler/cfg/two-operand/two-operand.factor
basis/compiler/cfg/useless-conditionals/useless-conditionals.factor
basis/compiler/cfg/utilities/utilities.factor
basis/compiler/cfg/value-numbering/rewrite/rewrite.factor
basis/compiler/cfg/value-numbering/simplify/simplify.factor
basis/compiler/cfg/value-numbering/value-numbering-tests.factor
basis/compiler/cfg/value-numbering/value-numbering.factor
basis/compiler/cfg/write-barrier/authors.txt [new file with mode: 0644]
basis/compiler/cfg/write-barrier/write-barrier-tests.factor
basis/compiler/cfg/write-barrier/write-barrier.factor
basis/compiler/codegen/codegen-tests.factor
basis/compiler/codegen/codegen.factor
basis/compiler/compiler.factor
basis/compiler/tests/alien.factor
basis/compiler/tests/call-effect.factor
basis/compiler/tests/codegen.factor
basis/compiler/tests/float.factor
basis/compiler/tests/generic.factor
basis/compiler/tests/low-level-ir.factor
basis/compiler/tests/optimizer.factor
basis/compiler/tests/peg-regression-2.factor
basis/compiler/tests/pic-problem-1.factor
basis/compiler/tests/redefine0.factor
basis/compiler/tests/redefine15.factor
basis/compiler/tests/redefine16.factor
basis/compiler/tests/redefine17.factor
basis/compiler/tests/redefine2.factor
basis/compiler/tests/redefine3.factor
basis/compiler/tests/redefine4.factor
basis/compiler/tests/reload.factor
basis/compiler/tests/stack-trace.factor
basis/compiler/tests/tuples.factor
basis/compiler/tree/builder/builder-docs.factor
basis/compiler/tree/builder/builder-tests.factor
basis/compiler/tree/builder/builder.factor
basis/compiler/tree/checker/checker-tests.factor [deleted file]
basis/compiler/tree/checker/checker.factor
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/combinators/combinators-tests.factor
basis/compiler/tree/dead-code/branches/branches.factor
basis/compiler/tree/dead-code/recursive/recursive.factor
basis/compiler/tree/debugger/debugger-tests.factor
basis/compiler/tree/debugger/debugger.factor
basis/compiler/tree/def-use/def-use.factor
basis/compiler/tree/escape-analysis/allocations/allocations.factor
basis/compiler/tree/escape-analysis/check/check-tests.factor [new file with mode: 0644]
basis/compiler/tree/escape-analysis/check/check.factor
basis/compiler/tree/escape-analysis/escape-analysis-tests.factor
basis/compiler/tree/escape-analysis/escape-analysis.factor
basis/compiler/tree/escape-analysis/nodes/nodes.factor
basis/compiler/tree/escape-analysis/recursive/recursive-tests.factor
basis/compiler/tree/escape-analysis/recursive/recursive.factor
basis/compiler/tree/escape-analysis/simple/simple.factor
basis/compiler/tree/modular-arithmetic/modular-arithmetic-tests.factor
basis/compiler/tree/normalization/normalization-tests.factor
basis/compiler/tree/optimizer/optimizer-tests.factor [deleted file]
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/compiler/tree/propagation/copy/copy-tests.factor
basis/compiler/tree/propagation/info/info-tests.factor
basis/compiler/tree/propagation/info/info.factor
basis/compiler/tree/propagation/inlining/inlining.factor
basis/compiler/tree/propagation/known-words/known-words.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/compiler/tree/propagation/recursive/recursive-tests.factor
basis/compiler/tree/propagation/recursive/recursive.factor
basis/compiler/tree/propagation/slots/slots.factor
basis/compiler/tree/propagation/transforms/transforms.factor
basis/compiler/tree/recursive/recursive-tests.factor
basis/compiler/tree/recursive/recursive.factor
basis/compiler/tree/tree.factor
basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor
basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor
basis/compiler/utilities/utilities.factor
basis/compression/huffman/huffman.factor
basis/compression/inflate/inflate.factor
basis/compression/lzw/lzw-tests.factor [deleted file]
basis/concurrency/combinators/combinators-tests.factor
basis/concurrency/count-downs/count-downs.factor
basis/concurrency/distributed/distributed-tests.factor
basis/concurrency/exchangers/exchangers-tests.factor
basis/concurrency/flags/flags-tests.factor
basis/concurrency/futures/futures-tests.factor
basis/concurrency/locks/locks-tests.factor
basis/concurrency/locks/locks.factor
basis/concurrency/mailboxes/mailboxes-tests.factor
basis/concurrency/mailboxes/mailboxes.factor
basis/concurrency/promises/promises-tests.factor
basis/concurrency/semaphores/semaphores.factor
basis/cords/cords-tests.factor
basis/core-foundation/numbers/numbers-tests.factor [deleted file]
basis/core-foundation/run-loop/run-loop.factor
basis/core-foundation/utilities/utilities-tests.factor [deleted file]
basis/core-graphics/types/types-tests.factor [deleted file]
basis/core-text/fonts/fonts-tests.factor [deleted file]
basis/core-text/utilities/utilities-tests.factor [deleted file]
basis/cpu/architecture/architecture.factor
basis/cpu/ppc/assembler/assembler-tests.factor
basis/cpu/ppc/bootstrap.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/32/32.factor
basis/cpu/x86/64/64.factor
basis/cpu/x86/64/unix/unix.factor
basis/cpu/x86/64/winnt/winnt.factor
basis/cpu/x86/assembler/assembler.factor
basis/cpu/x86/assembler/operands/operands.factor
basis/cpu/x86/bootstrap.factor
basis/cpu/x86/features/features-tests.factor
basis/cpu/x86/x86.factor
basis/db/queries/queries.factor
basis/db/tuples/tuples-tests.factor
basis/debugger/debugger-tests.factor
basis/debugger/debugger.factor
basis/debugger/unix/unix.factor
basis/definitions/icons/icons-tests.factor [deleted file]
basis/delegate/delegate-tests.factor
basis/disjoint-sets/disjoint-sets-tests.factor
basis/disjoint-sets/disjoint-sets.factor
basis/documents/documents-tests.factor
basis/documents/documents.factor
basis/documents/elements/elements.factor
basis/editors/editors-docs.factor
basis/editors/editors.factor
basis/editors/gvim/gvim-docs.factor [new file with mode: 0644]
basis/editors/macvim/macvim.factor
basis/editors/textmate/textmate.factor
basis/editors/vim/vim-docs.factor
basis/editors/vim/vim.factor
basis/eval/eval-tests.factor
basis/farkup/farkup.factor
basis/formatting/formatting-tests.factor
basis/formatting/formatting.factor
basis/fry/fry-tests.factor
basis/fry/fry.factor
basis/functors/functors-tests.factor
basis/functors/functors.factor
basis/furnace/actions/actions-docs.factor
basis/furnace/actions/actions.factor
basis/furnace/auth/auth-tests.factor [deleted file]
basis/furnace/auth/features/edit-profile/edit-profile-tests.factor [deleted file]
basis/furnace/auth/features/recover-password/recover-password-tests.factor [deleted file]
basis/furnace/auth/features/registration/registration-tests.factor [deleted file]
basis/furnace/auth/login/login-tests.factor [deleted file]
basis/furnace/auth/login/permits/permits.factor
basis/furnace/auth/providers/assoc/assoc-tests.factor
basis/furnace/auth/providers/assoc/assoc.factor
basis/furnace/auth/providers/db/db-tests.factor
basis/furnace/db/db-tests.factor [deleted file]
basis/furnace/furnace-tests.factor
basis/furnace/sessions/sessions-tests.factor
basis/furnace/utilities/utilities-docs.factor
basis/furnace/utilities/utilities.factor
basis/game-input/game-input-tests.factor
basis/game-input/game-input.factor
basis/game-input/iokit/iokit.factor
basis/generalizations/generalizations.factor
basis/globs/globs-tests.factor
basis/grouping/grouping-docs.factor
basis/grouping/grouping.factor
basis/heaps/heaps-tests.factor
basis/heaps/heaps.factor
basis/help/apropos/apropos-tests.factor
basis/help/cookbook/cookbook.factor
basis/help/crossref/crossref-tests.factor
basis/help/handbook/handbook-tests.factor
basis/help/help-tests.factor
basis/help/html/html-tests.factor
basis/help/html/html.factor
basis/help/tutorial/tutorial.factor
basis/help/vocabs/vocabs-tests.factor
basis/hints/hints.factor
basis/html/components/components-tests.factor
basis/html/forms/forms-tests.factor
basis/html/forms/forms.factor
basis/html/templates/fhtml/fhtml.factor
basis/http/client/client-tests.factor
basis/http/client/post-data/post-data-tests.factor [deleted file]
basis/http/parsers/parsers-tests.factor
basis/http/server/redirection/redirection-tests.factor
basis/http/server/rewrite/rewrite-docs.factor [new file with mode: 0644]
basis/http/server/rewrite/rewrite-tests.factor [new file with mode: 0644]
basis/http/server/rewrite/rewrite.factor [new file with mode: 0644]
basis/http/server/server-docs.factor
basis/http/server/server.factor
basis/http/server/static/static-tests.factor
basis/images/jpeg/jpeg.factor
basis/interval-maps/interval-maps.factor
basis/inverse/inverse-tests.factor
basis/inverse/inverse.factor
basis/io/backend/unix/multiplexers/select/select.factor
basis/io/backend/windows/privileges/privileges-tests.factor
basis/io/encodings/ascii/ascii.factor
basis/io/files/info/windows/windows.factor
basis/io/files/links/links.factor
basis/io/files/links/unix/unix-tests.factor
basis/io/launcher/windows/windows.factor
basis/io/monitors/recursive/recursive-tests.factor
basis/io/pipes/pipes.factor
basis/io/sockets/secure/openssl/openssl.factor
basis/io/sockets/unix/unix.factor
basis/lcs/lcs.factor
basis/linked-assocs/linked-assocs-tests.factor
basis/lists/lazy/lazy.factor
basis/lists/lists-tests.factor
basis/lists/lists.factor
basis/literals/literals-docs.factor
basis/locals/locals-docs.factor
basis/locals/locals-tests.factor
basis/logging/server/server.factor
basis/math/bits/bits.factor
basis/math/combinatorics/combinatorics-docs.factor
basis/math/functions/functions-docs.factor
basis/math/functions/functions.factor
basis/math/intervals/intervals-tests.factor
basis/math/intervals/intervals.factor
basis/math/matrices/elimination/elimination.factor
basis/math/primes/erato/erato.factor
basis/math/primes/factors/factors.factor
basis/math/ratios/ratios-tests.factor
basis/math/ratios/ratios.factor
basis/math/vectors/specialization/specialization-tests.factor [new file with mode: 0644]
basis/math/vectors/specialization/specialization.factor [new file with mode: 0644]
basis/math/vectors/vectors.factor
basis/memoize/memoize-tests.factor
basis/mime/multipart/multipart.factor
basis/models/arrow/arrow-tests.factor
basis/models/illusion/authors.txt [new file with mode: 0644]
basis/models/illusion/illusion.factor [new file with mode: 0644]
basis/models/illusion/summary.txt [new file with mode: 0644]
basis/models/models.factor
basis/models/product/product-tests.factor
basis/multiline/multiline.factor
basis/opengl/gl/extensions/extensions.factor
basis/peg/parsers/parsers.factor
basis/peg/peg.factor
basis/persistent/hashtables/config/config.factor
basis/persistent/hashtables/hashtables.factor
basis/persistent/hashtables/nodes/bitmap/bitmap.factor
basis/persistent/vectors/vectors.factor
basis/porter-stemmer/porter-stemmer.factor
basis/prettyprint/prettyprint.factor
basis/prettyprint/sections/sections.factor
basis/quoted-printable/quoted-printable.factor
basis/random/dummy/dummy.factor
basis/random/mersenne-twister/mersenne-twister.factor
basis/random/random.factor
basis/regexp/ast/ast.factor
basis/regexp/compiler/compiler.factor
basis/regexp/regexp.factor
basis/sequences/complex/complex.factor
basis/serialize/serialize.factor
basis/sorting/insertion/insertion.factor
basis/specialized-arrays/double/double.factor
basis/specialized-arrays/functor/functor.factor
basis/splitting/monotonic/monotonic.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/known-words/known-words.factor
basis/stuff.factor [deleted file]
basis/suffix-arrays/suffix-arrays.factor
basis/tools/annotations/annotations-tests.factor
basis/tools/completion/completion.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/errors/errors.factor
basis/tools/test/test.factor
basis/ui/backend/windows/windows.factor
basis/ui/gadgets/editors/editors.factor
basis/ui/gadgets/frames/frames.factor
basis/ui/gadgets/gadgets-tests.factor
basis/ui/gadgets/gadgets.factor
basis/ui/gadgets/line-support/line-support.factor
basis/ui/gadgets/menus/menus.factor
basis/ui/gadgets/search-tables/search-tables.factor
basis/ui/gadgets/tables/tables-docs.factor
basis/ui/gadgets/tables/tables-tests.factor
basis/ui/gadgets/tables/tables.factor
basis/ui/pens/gradient/gradient.factor
basis/ui/text/uniscribe/uniscribe.factor
basis/ui/tools/debugger/debugger.factor
basis/ui/tools/error-list/error-list-docs.factor
basis/ui/tools/error-list/error-list.factor
basis/ui/tools/inspector/inspector.factor
basis/ui/tools/listener/history/history.factor
basis/ui/tools/listener/listener.factor
basis/ui/tools/profiler/profiler.factor
basis/ui/traverse/traverse.factor
basis/ui/ui.factor
basis/unicode/breaks/breaks.factor
basis/unicode/normalize/normalize-tests.factor
basis/unicode/normalize/normalize.factor
basis/unix/groups/groups.factor
basis/unix/process/process.factor
basis/unrolled-lists/unrolled-lists.factor
basis/urls/encoding/encoding.factor
basis/values/values-tests.factor
basis/vlists/vlists.factor
basis/vocabs/hierarchy/hierarchy.factor
basis/vocabs/prettyprint/prettyprint.factor
basis/windows/com/wrapper/wrapper.factor
basis/windows/dragdrop-listener/dragdrop-listener.factor
basis/windows/errors/errors.factor
basis/windows/uniscribe/uniscribe.factor
basis/xml/syntax/syntax.factor
basis/xml/tokenize/tokenize.factor
basis/xmode/marker/state/state.factor
core/arrays/arrays.factor
core/assocs/assocs-tests.factor
core/bootstrap/primitives.factor
core/bootstrap/syntax-docs.factor [deleted file]
core/byte-arrays/byte-arrays-tests.factor
core/byte-vectors/byte-vectors-tests.factor
core/checksums/checksums-tests.factor [deleted file]
core/checksums/checksums.factor
core/classes/algebra/algebra-docs.factor
core/classes/algebra/algebra.factor
core/classes/builtin/builtin-tests.factor
core/classes/builtin/builtin.factor
core/classes/intersection/intersection-tests.factor [new file with mode: 0644]
core/classes/intersection/intersection.factor
core/classes/predicate/predicate-tests.factor
core/classes/tuple/parser/parser-tests.factor
core/classes/tuple/tuple-docs.factor
core/combinators/combinators-docs.factor
core/combinators/combinators.factor
core/destructors/destructors-docs.factor
core/effects/effects-tests.factor
core/effects/parser/parser.factor
core/generic/generic-docs.factor
core/generic/math/math-tests.factor
core/generic/single/single-tests.factor
core/generic/single/single.factor
core/hashtables/hashtables-tests.factor
core/io/backend/backend-tests.factor
core/io/binary/binary.factor
core/io/encodings/utf8/utf8.factor
core/io/io-docs.factor
core/io/streams/memory/memory.factor
core/kernel/kernel-docs.factor
core/layouts/layouts-tests.factor
core/lexer/lexer.factor
core/make/make-docs.factor
core/math/integers/integers.factor
core/math/math-docs.factor
core/math/math.factor
core/math/order/order-docs.factor
core/math/parser/parser.factor
core/memory/memory-docs.factor
core/parser/parser-docs.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
core/slots/slots-tests.factor
core/sorting/sorting-docs.factor
core/sorting/sorting.factor
core/source-files/errors/errors.factor
core/splitting/splitting.factor
core/vocabs/parser/parser.factor [changed mode: 0644->0755]
core/words/words-docs.factor
extra/adsoda/adsoda.factor
extra/adsoda/combinators/combinators.factor
extra/adsoda/solution2/solution2.factor
extra/annotations/annotations-tests.factor
extra/benchmark/beust2/beust2.factor
extra/benchmark/chameneos-redux/authors.txt [new file with mode: 0644]
extra/benchmark/chameneos-redux/chameneos-redux.factor [new file with mode: 0644]
extra/benchmark/fannkuch/fannkuch.factor
extra/benchmark/fasta/fasta.factor
extra/benchmark/fib4/fib4.factor
extra/benchmark/fib6/fib6.factor
extra/benchmark/gc1/gc1.factor
extra/benchmark/knucleotide/knucleotide.factor
extra/benchmark/mandel/colors/colors.factor
extra/benchmark/nbody/nbody.factor
extra/benchmark/nsieve-bits/nsieve-bits.factor
extra/benchmark/nsieve-bytes/nsieve-bytes.factor
extra/benchmark/nsieve/nsieve.factor
extra/benchmark/partial-sums/partial-sums.factor
extra/benchmark/raytracer/raytracer.factor
extra/benchmark/recursive/recursive.factor
extra/benchmark/tuple-arrays/tuple-arrays.factor
extra/benchmark/yuv-to-rgb/yuv-to-rgb.factor [new file with mode: 0644]
extra/bunny/bunny.factor
extra/c/lexer/authors.txt [new file with mode: 0644]
extra/c/lexer/lexer-tests.factor [new file with mode: 0644]
extra/c/lexer/lexer.factor [new file with mode: 0644]
extra/c/preprocessor/preprocessor.factor
extra/central/central-tests.factor
extra/closures/closures.factor [new file with mode: 0644]
extra/compiler/cfg/graphviz/graphviz.factor [deleted file]
extra/compiler/graphviz/graphviz.factor [new file with mode: 0644]
extra/coroutines/coroutines-tests.factor
extra/crypto/barrett/barrett.factor
extra/crypto/passwd-md5/passwd-md5.factor
extra/crypto/rsa/rsa.factor
extra/ctags/etags/etags.factor
extra/cursors/cursors.factor
extra/db/info/info.factor [new file with mode: 0644]
extra/descriptive/descriptive-tests.factor
extra/dns/misc/misc.factor
extra/dns/server/server.factor
extra/dns/util/util.factor
extra/drills/deployed/deploy.factor
extra/drills/deployed/deployed.factor
extra/drills/drills.factor
extra/ecdsa/ecdsa.factor
extra/enter/authors.txt [new file with mode: 0644]
extra/enter/enter.factor [new file with mode: 0644]
extra/file-trees/file-trees-tests.factor [deleted file]
extra/file-trees/file-trees.factor [deleted file]
extra/fonts/syntax/authors.txt [new file with mode: 0644]
extra/fonts/syntax/summary.txt [new file with mode: 0644]
extra/fonts/syntax/syntax-docs.factor [new file with mode: 0644]
extra/fonts/syntax/syntax.factor [new file with mode: 0644]
extra/fries/authors.txt [new file with mode: 0644]
extra/fries/fries.factor [new file with mode: 0644]
extra/fries/summary.txt [new file with mode: 0644]
extra/fuel/xref/xref.factor
extra/game-loop/game-loop.factor
extra/gpu/render/render.factor
extra/hashcash/hashcash.factor
extra/html/parser/analyzer/analyzer.factor
extra/id3/id3.factor
extra/irc/client/internals/internals.factor
extra/jamshred/tunnel/tunnel.factor
extra/key-handlers/authors.txt [new file with mode: 0644]
extra/key-handlers/key-handlers.factor [new file with mode: 0644]
extra/koszul/koszul.factor
extra/math/analysis/analysis.factor
extra/math/dual/dual.factor
extra/math/finance/finance.factor
extra/math/primes/lists/lists.factor
extra/math/text/english/english-docs.factor
extra/math/text/english/english-tests.factor
extra/math/text/english/english.factor
extra/math/text/french/french.factor
extra/math/text/utils/utils-docs.factor [changed mode: 0644->0755]
extra/math/text/utils/utils-tests.factor [changed mode: 0644->0755]
extra/math/text/utils/utils.factor [changed mode: 0644->0755]
extra/merger/deploy.factor
extra/merger/merger.factor
extra/models/combinators/authors.txt [new file with mode: 0644]
extra/models/combinators/combinators-docs.factor [new file with mode: 0644]
extra/models/combinators/combinators.factor [new file with mode: 0644]
extra/models/combinators/summary.txt [new file with mode: 0644]
extra/models/combinators/templates/templates.factor [new file with mode: 0644]
extra/models/conditional/authors.txt [new file with mode: 0644]
extra/models/conditional/conditional.factor [new file with mode: 0644]
extra/modules/rpc-server/authors.txt [new file with mode: 0644]
extra/modules/rpc-server/rpc-server-docs.factor [new file with mode: 0644]
extra/modules/rpc-server/rpc-server.factor [new file with mode: 0644]
extra/modules/rpc-server/summary.txt [new file with mode: 0644]
extra/modules/rpc/authors.txt [new file with mode: 0644]
extra/modules/rpc/rpc-docs.factor [new file with mode: 0644]
extra/modules/rpc/rpc.factor [new file with mode: 0644]
extra/modules/rpc/summary.txt [new file with mode: 0644]
extra/modules/using/authors.txt [new file with mode: 0644]
extra/modules/using/summary.txt [new file with mode: 0644]
extra/modules/using/using-docs.factor [new file with mode: 0644]
extra/modules/using/using.factor [new file with mode: 0644]
extra/monads/monads-tests.factor
extra/monads/monads.factor
extra/money/money.factor
extra/opengl/demo-support/demo-support.factor
extra/pair-methods/pair-methods.factor
extra/parser-combinators/parser-combinators.factor
extra/peg-lexer/peg-lexer.factor
extra/persistency/authors.txt [new file with mode: 0644]
extra/persistency/persistency.factor [new file with mode: 0644]
extra/project-euler/001/001.factor
extra/project-euler/012/012.factor
extra/project-euler/014/014.factor
extra/project-euler/022/022.factor
extra/project-euler/025/025.factor
extra/project-euler/026/026.factor
extra/project-euler/027/027.factor
extra/project-euler/030/030.factor
extra/project-euler/035/035.factor
extra/project-euler/038/038.factor
extra/project-euler/039/039.factor
extra/project-euler/040/040.factor
extra/project-euler/042/042.factor
extra/project-euler/043/043.factor
extra/project-euler/044/044.factor
extra/project-euler/045/045.factor
extra/project-euler/046/046.factor
extra/project-euler/047/047.factor
extra/project-euler/048/048.factor
extra/project-euler/049/049.factor
extra/project-euler/050/050.factor
extra/project-euler/052/052.factor
extra/project-euler/058/058.factor
extra/project-euler/069/069.factor
extra/project-euler/075/075.factor
extra/project-euler/076/076.factor
extra/project-euler/092/092.factor
extra/project-euler/097/097.factor
extra/project-euler/099/099.factor
extra/project-euler/100/100.factor
extra/project-euler/116/116.factor
extra/project-euler/148/148.factor
extra/project-euler/150/150.factor
extra/project-euler/151/151-tests.factor [new file with mode: 0644]
extra/project-euler/151/151.factor
extra/project-euler/169/169.factor
extra/project-euler/175/175.factor
extra/project-euler/186/186.factor
extra/project-euler/190/190.factor
extra/project-euler/203/203.factor
extra/project-euler/215/215.factor
extra/project-euler/ave-time/ave-time.factor
extra/project-euler/common/common.factor
extra/recipes/authors.txt [new file with mode: 0644]
extra/recipes/icons/back.tiff [new file with mode: 0644]
extra/recipes/icons/hate.tiff [new file with mode: 0644]
extra/recipes/icons/love.tiff [new file with mode: 0644]
extra/recipes/icons/more.tiff [new file with mode: 0644]
extra/recipes/icons/submit.tiff [new file with mode: 0644]
extra/recipes/recipes.factor [new file with mode: 0644]
extra/recipes/summary.txt [new file with mode: 0644]
extra/run-desc/run-desc.factor [new file with mode: 0644]
extra/sequence-parser/sequence-parser-tests.factor
extra/sequence-parser/sequence-parser.factor
extra/sequences/extras/extras.factor [new file with mode: 0644]
extra/sequences/product/product.factor
extra/set-n/set-n.factor [new file with mode: 0644]
extra/slides/slides.factor
extra/smalltalk/compiler/compiler.factor
extra/spider/spider.factor
extra/str-fry/authors.txt [deleted file]
extra/str-fry/str-fry.factor [deleted file]
extra/str-fry/summary.txt [deleted file]
extra/sudoku/sudoku.factor
extra/sudokus/authors.txt [new file with mode: 0644]
extra/sudokus/sudokus.factor [new file with mode: 0644]
extra/sudokus/summary.txt [new file with mode: 0644]
extra/svg/svg.factor
extra/system-info/windows/nt/nt.factor
extra/terrain/terrain.factor
extra/tetris/game/game.factor
extra/tetris/tetromino/tetromino.factor
extra/trees/trees.factor
extra/ui/frp/authors.txt [deleted file]
extra/ui/frp/frp-docs.factor [deleted file]
extra/ui/frp/frp.factor [deleted file]
extra/ui/frp/summary.txt [deleted file]
extra/ui/gadgets/alerts/alerts.factor
extra/ui/gadgets/book-extras/book-extras.factor
extra/ui/gadgets/comboboxes/comboboxes.factor
extra/ui/gadgets/controls/authors.txt [new file with mode: 0644]
extra/ui/gadgets/controls/controls-docs.factor [new file with mode: 0644]
extra/ui/gadgets/controls/controls.factor [new file with mode: 0644]
extra/ui/gadgets/controls/summary.txt [new file with mode: 0644]
extra/ui/gadgets/layout/authors.txt [new file with mode: 0644]
extra/ui/gadgets/layout/layout-docs.factor [new file with mode: 0644]
extra/ui/gadgets/layout/layout.factor [new file with mode: 0644]
extra/ui/gadgets/layout/summary.txt [new file with mode: 0644]
extra/ui/gadgets/lists/lists.factor
extra/ui/gadgets/poppers/authors.txt [new file with mode: 0644]
extra/ui/gadgets/poppers/poppers.factor [new file with mode: 0644]
extra/webapps/blogs/blogs.factor
extra/webapps/pastebin/pastebin.factor
extra/webapps/planet/planet.factor
extra/webapps/wiki/wiki.factor
extra/wordtimer/wordtimer.factor
misc/Factor.tmbundle/Commands/Cycle Vocabs-Docs-Tests.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Edit Vocab.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Edit Word Docs.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Edit Word.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Expand Selection.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Fix Word.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Help for Word.tmCommand
misc/Factor.tmbundle/Commands/Infer Effect of Selection.tmCommand [deleted file]
misc/Factor.tmbundle/Commands/Infer Selection.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Insert Inferrence.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Profile.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Reload in Listener.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Reset Word.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/See Word.tmCommand
misc/Factor.tmbundle/Commands/Set Breakpoint.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Show Using.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Usage.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Vocab Usage.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Vocab Uses.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Walk Selection.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Commands/Watch Word.tmCommand [new file with mode: 0644]
misc/Factor.tmbundle/Macros/Extract as New Word.tmMacro [new file with mode: 0644]
misc/Factor.tmbundle/Preferences/Miscellaneous.tmPreferences [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/[ expanded.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/[.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/bi.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/cleave.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/cond.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/functor.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/if.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/lambda word def.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/let.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/spread.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/tri.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/word def.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/{ expanded.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Snippets/{.tmSnippet [new file with mode: 0644]
misc/Factor.tmbundle/Support/lib/tm_factor.rb
misc/Factor.tmbundle/Templates/Vocabulary.tmTemplate/info.plist [new file with mode: 0644]
misc/Factor.tmbundle/info.plist
misc/factor.vim.fgen
misc/fuel/fuel-log.el
misc/vim/README
misc/vim/syntax/factor.vim [changed mode: 0755->0644]
unmaintained/modules/remote-loading/authors.txt [deleted file]
unmaintained/modules/remote-loading/remote-loading.factor [deleted file]
unmaintained/modules/remote-loading/summary.txt [deleted file]
unmaintained/modules/rpc-server/authors.txt [deleted file]
unmaintained/modules/rpc-server/rpc-server.factor [deleted file]
unmaintained/modules/rpc-server/summary.txt [deleted file]
unmaintained/modules/rpc/authors.txt [deleted file]
unmaintained/modules/rpc/rpc-docs.factor [deleted file]
unmaintained/modules/rpc/rpc.factor [deleted file]
unmaintained/modules/rpc/summary.txt [deleted file]
unmaintained/modules/uploads/authors.txt [deleted file]
unmaintained/modules/uploads/summary.txt [deleted file]
unmaintained/modules/uploads/uploads.factor [deleted file]
unmaintained/modules/using/authors.txt [deleted file]
unmaintained/modules/using/summary.txt [deleted file]
unmaintained/modules/using/tests/tags.txt [deleted file]
unmaintained/modules/using/tests/test-server.factor [deleted file]
unmaintained/modules/using/tests/tests.factor [deleted file]
unmaintained/modules/using/using-docs.factor [deleted file]
unmaintained/modules/using/using.factor [deleted file]
vm/Config.unix [changed mode: 0755->0644]
vm/Config.windows.ce.arm [changed mode: 0755->0644]
vm/alien.cpp [changed mode: 0755->0644]
vm/alien.hpp [changed mode: 0755->0644]
vm/arrays.hpp [changed mode: 0755->0644]
vm/bignum.cpp [changed mode: 0755->0644]
vm/byte_arrays.hpp [changed mode: 0755->0644]
vm/callstack.cpp [changed mode: 0755->0644]
vm/callstack.hpp [changed mode: 0755->0644]
vm/code_block.cpp [changed mode: 0755->0644]
vm/code_gc.cpp [changed mode: 0755->0644]
vm/code_gc.hpp [changed mode: 0755->0644]
vm/code_heap.cpp [changed mode: 0755->0644]
vm/code_heap.hpp [changed mode: 0755->0644]
vm/cpu-arm.S [changed mode: 0755->0644]
vm/cpu-arm.hpp [changed mode: 0755->0644]
vm/cpu-ppc.S [changed mode: 0755->0644]
vm/cpu-ppc.hpp [changed mode: 0755->0644]
vm/cpu-x86.32.S [changed mode: 0755->0644]
vm/cpu-x86.32.hpp [changed mode: 0755->0644]
vm/cpu-x86.64.hpp [changed mode: 0755->0644]
vm/cpu-x86.S [changed mode: 0755->0644]
vm/cpu-x86.hpp [changed mode: 0755->0644]
vm/data_gc.cpp [changed mode: 0755->0644]
vm/data_gc.hpp [changed mode: 0755->0644]
vm/data_heap.cpp [changed mode: 0755->0644]
vm/data_heap.hpp [changed mode: 0755->0644]
vm/debug.cpp [changed mode: 0755->0644]
vm/debug.hpp [changed mode: 0755->0644]
vm/dispatch.cpp [changed mode: 0755->0644]
vm/errors.cpp [changed mode: 0755->0644]
vm/errors.hpp [changed mode: 0755->0644]
vm/factor.cpp [changed mode: 0755->0644]
vm/ffi_test.c [changed mode: 0755->0644]
vm/ffi_test.h [changed mode: 0755->0644]
vm/image.cpp [changed mode: 0755->0644]
vm/image.hpp [changed mode: 0755->0644]
vm/inline_cache.cpp [changed mode: 0755->0644]
vm/io.cpp [changed mode: 0755->0644]
vm/io.hpp [changed mode: 0755->0644]
vm/layouts.hpp [changed mode: 0755->0644]
vm/main-windows-nt.cpp [changed mode: 0755->0644]
vm/master.hpp [changed mode: 0755->0644]
vm/math.cpp [changed mode: 0755->0644]
vm/os-genunix.cpp [changed mode: 0755->0644]
vm/os-netbsd.cpp [changed mode: 0755->0644]
vm/os-unix.cpp [changed mode: 0755->0644]
vm/os-unix.hpp [changed mode: 0755->0644]
vm/os-windows-ce.cpp [changed mode: 0755->0644]
vm/os-windows-ce.hpp [changed mode: 0755->0644]
vm/os-windows-nt.cpp [changed mode: 0755->0644]
vm/os-windows-nt.hpp [changed mode: 0755->0644]
vm/os-windows.cpp [changed mode: 0755->0644]
vm/os-windows.hpp [changed mode: 0755->0644]
vm/primitives.cpp [changed mode: 0755->0644]
vm/profiler.cpp [changed mode: 0755->0644]
vm/profiler.hpp [changed mode: 0755->0644]
vm/quotations.cpp [changed mode: 0755->0644]
vm/quotations.hpp [changed mode: 0755->0644]
vm/run.cpp [changed mode: 0755->0644]
vm/run.hpp [changed mode: 0755->0644]
vm/tagged.hpp [changed mode: 0755->0644]
vm/utilities.cpp [changed mode: 0755->0644]
vm/utilities.hpp [changed mode: 0755->0644]
vm/write_barrier.cpp [changed mode: 0755->0644]
vm/write_barrier.hpp [changed mode: 0755->0644]

index 7c64680a834b297b197c73d1502de3538fcb68cd..2379e3e80d809baba9cd08424a94a6955f28c67a 100644 (file)
@@ -1,6 +1,6 @@
-IN: alarms.tests\r
 USING: alarms alarms.private kernel calendar sequences\r
 tools.test threads concurrency.count-downs ;\r
+IN: alarms.tests\r
 \r
 [ ] [\r
     1 <count-down>\r
index f9fdce806f5f606bd1ef5532e19ab42f8ac3694c..9943d39ad194a6d0efe5d356d3873afa6099ed94 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays calendar combinators generic init
-kernel math namespaces sequences heaps boxes threads
-quotations assocs math.order ;
+USING: accessors assocs boxes calendar
+combinators.short-circuit fry heaps init kernel math.order
+namespaces quotations threads ;
 IN: alarms
 
 TUPLE: alarm
@@ -21,21 +21,21 @@ SYMBOL: alarm-thread
 
 ERROR: bad-alarm-frequency frequency ;
 : check-alarm ( frequency/f -- frequency/f )
-    dup [ duration? ] [ not ] bi or [ bad-alarm-frequency ] unless ;
+    dup { [ duration? ] [ not ] } 1|| [ bad-alarm-frequency ] unless ;
 
 : <alarm> ( quot time frequency -- alarm )
     check-alarm <box> alarm boa ;
 
 : register-alarm ( alarm -- )
-    dup dup time>> alarms get-global heap-push*
-    swap entry>> >box
+    [ dup time>> alarms get-global heap-push* ]
+    [ entry>> >box ] bi
     notify-alarm-thread ;
 
 : alarm-expired? ( alarm now -- ? )
     [ time>> ] dip before=? ;
 
 : reschedule-alarm ( alarm -- )
-    dup [ swap interval>> time+ now max ] change-time register-alarm ;
+    dup '[ _ interval>> time+ now max ] change-time register-alarm ;
 
 : call-alarm ( alarm -- )
     [ entry>> box> drop ]
index e4a0e4dcf0a6cf51d27dd9270b3ee8db0345e4bf..d793814c28925225b1ae9ff13ff5df2b5790c4c4 100755 (executable)
@@ -11,6 +11,8 @@ M: array c-type ;
 
 M: array c-type-class drop object ;
 
+M: array c-type-boxed-class drop object ;
+
 M: array heap-size unclip [ product ] [ heap-size ] bi* * ;
 
 M: array c-type-align first c-type-align ;
@@ -31,7 +33,7 @@ M: array c-type-boxer-quot drop [ ] ;
 
 M: array c-type-unboxer-quot drop [ >c-ptr ] ;
 
-M: value-type c-type-reg-class drop int-regs ;
+M: value-type c-type-rep drop int-rep ;
 
 M: value-type c-type-getter
     drop [ swap <displaced-alien> ] ;
@@ -45,8 +47,9 @@ PREDICATE: string-type < pair
 
 M: string-type c-type ;
 
-M: string-type c-type-class
-    drop object ;
+M: string-type c-type-class drop object ;
+
+M: string-type c-type-boxed-class drop object ;
 
 M: string-type heap-size
     drop "void*" heap-size ;
@@ -72,8 +75,8 @@ M: string-type box-return
 M: string-type stack-size
     drop "void*" stack-size ;
 
-M: string-type c-type-reg-class
-    drop int-regs ;
+M: string-type c-type-rep
+    drop int-rep ;
 
 M: string-type c-type-boxer
     drop "void*" c-type-boxer ;
index ea9e881fd4d9e9c9f9a3c42c7af6c2c174e3acee..0de26aad20e2309331301c141c5c54404c37cd25 100644 (file)
@@ -1,6 +1,6 @@
-IN: alien.c-types.tests
 USING: alien alien.syntax alien.c-types kernel tools.test
 sequences system libc alien.strings io.encodings.utf8 ;
+IN: alien.c-types.tests
 
 CONSTANT: xyz 123
 
index 6e398667ec374cfc43ae1cb53cf82f80260eee9c..2eba6a2b9e76cd9cb47434716a7df391c82248ec 100755 (executable)
@@ -13,17 +13,20 @@ DEFER: *char
 
 : little-endian? ( -- ? ) 1 <int> *char 1 = ; foldable
 
-TUPLE: c-type
+TUPLE: abstract-c-type
 { class class initial: object }
-boxer
+{ boxed-class class initial: object }
 { boxer-quot callable }
-unboxer
 { unboxer-quot callable }
 { getter callable }
 { setter callable }
-{ reg-class initial: int-regs }
 size
-align
+align ;
+
+TUPLE: c-type < abstract-c-type
+boxer
+unboxer
+{ rep initial: int-rep }
 stack-align? ;
 
 : <c-type> ( -- type )
@@ -70,10 +73,16 @@ M: string c-type ( name -- type )
 
 GENERIC: c-type-class ( name -- class )
 
-M: c-type c-type-class class>> ;
+M: abstract-c-type c-type-class class>> ;
 
 M: string c-type-class c-type c-type-class ;
 
+GENERIC: c-type-boxed-class ( name -- class )
+
+M: abstract-c-type c-type-boxed-class boxed-class>> ;
+
+M: string c-type-boxed-class c-type c-type-boxed-class ;
+
 GENERIC: c-type-boxer ( name -- boxer )
 
 M: c-type c-type-boxer boxer>> ;
@@ -82,7 +91,7 @@ M: string c-type-boxer c-type c-type-boxer ;
 
 GENERIC: c-type-boxer-quot ( name -- quot )
 
-M: c-type c-type-boxer-quot boxer-quot>> ;
+M: abstract-c-type c-type-boxer-quot boxer-quot>> ;
 
 M: string c-type-boxer-quot c-type c-type-boxer-quot ;
 
@@ -94,15 +103,15 @@ M: string c-type-unboxer c-type c-type-unboxer ;
 
 GENERIC: c-type-unboxer-quot ( name -- quot )
 
-M: c-type c-type-unboxer-quot unboxer-quot>> ;
+M: abstract-c-type c-type-unboxer-quot unboxer-quot>> ;
 
 M: string c-type-unboxer-quot c-type c-type-unboxer-quot ;
 
-GENERIC: c-type-reg-class ( name -- reg-class )
+GENERIC: c-type-rep ( name -- rep )
 
-M: c-type c-type-reg-class reg-class>> ;
+M: c-type c-type-rep rep>> ;
 
-M: string c-type-reg-class c-type c-type-reg-class ;
+M: string c-type-rep c-type c-type-rep ;
 
 GENERIC: c-type-getter ( name -- quot )
 
@@ -118,7 +127,7 @@ M: string c-type-setter c-type c-type-setter ;
 
 GENERIC: c-type-align ( name -- n )
 
-M: c-type c-type-align align>> ;
+M: abstract-c-type c-type-align align>> ;
 
 M: string c-type-align c-type c-type-align ;
 
@@ -129,13 +138,11 @@ M: c-type c-type-stack-align? stack-align?>> ;
 M: string c-type-stack-align? c-type c-type-stack-align? ;
 
 : c-type-box ( n type -- )
-    dup c-type-reg-class
-    swap c-type-boxer [ "No boxer" throw ] unless*
+    [ c-type-rep ] [ c-type-boxer [ "No boxer" throw ] unless* ] bi
     %box ;
 
 : c-type-unbox ( n ctype -- )
-    dup c-type-reg-class
-    swap c-type-unboxer [ "No unboxer" throw ] unless*
+    [ c-type-rep ] [ c-type-unboxer [ "No unboxer" throw ] unless* ] bi
     %unbox ;
 
 GENERIC: box-parameter ( n ctype -- )
@@ -169,7 +176,7 @@ GENERIC: heap-size ( type -- size ) foldable
 
 M: string heap-size c-type heap-size ;
 
-M: c-type heap-size size>> ;
+M: abstract-c-type heap-size size>> ;
 
 GENERIC: stack-size ( type -- size ) foldable
 
@@ -300,6 +307,7 @@ CONSTANT: primitive-types
 [
     <c-type>
         c-ptr >>class
+        c-ptr >>boxed-class
         [ alien-cell ] >>getter
         [ [ >c-ptr ] 2dip set-alien-cell ] >>setter
         bootstrap-cell >>size
@@ -311,6 +319,7 @@ CONSTANT: primitive-types
 
     <long-long-type>
         integer >>class
+        integer >>boxed-class
         [ alien-signed-8 ] >>getter
         [ set-alien-signed-8 ] >>setter
         8 >>size
@@ -321,6 +330,7 @@ CONSTANT: primitive-types
 
     <long-long-type>
         integer >>class
+        integer >>boxed-class
         [ alien-unsigned-8 ] >>getter
         [ set-alien-unsigned-8 ] >>setter
         8 >>size
@@ -331,6 +341,7 @@ CONSTANT: primitive-types
 
     <c-type>
         integer >>class
+        integer >>boxed-class
         [ alien-signed-cell ] >>getter
         [ set-alien-signed-cell ] >>setter
         bootstrap-cell >>size
@@ -341,6 +352,7 @@ CONSTANT: primitive-types
 
     <c-type>
         integer >>class
+        integer >>boxed-class
         [ alien-unsigned-cell ] >>getter
         [ set-alien-unsigned-cell ] >>setter
         bootstrap-cell >>size
@@ -351,6 +363,7 @@ CONSTANT: primitive-types
 
     <c-type>
         integer >>class
+        integer >>boxed-class
         [ alien-signed-4 ] >>getter
         [ set-alien-signed-4 ] >>setter
         4 >>size
@@ -361,6 +374,7 @@ CONSTANT: primitive-types
 
     <c-type>
         integer >>class
+        integer >>boxed-class
         [ alien-unsigned-4 ] >>getter
         [ set-alien-unsigned-4 ] >>setter
         4 >>size
@@ -371,6 +385,7 @@ CONSTANT: primitive-types
 
     <c-type>
         fixnum >>class
+        fixnum >>boxed-class
         [ alien-signed-2 ] >>getter
         [ set-alien-signed-2 ] >>setter
         2 >>size
@@ -381,6 +396,7 @@ CONSTANT: primitive-types
 
     <c-type>
         fixnum >>class
+        fixnum >>boxed-class
         [ alien-unsigned-2 ] >>getter
         [ set-alien-unsigned-2 ] >>setter
         2 >>size
@@ -391,6 +407,7 @@ CONSTANT: primitive-types
 
     <c-type>
         fixnum >>class
+        fixnum >>boxed-class
         [ alien-signed-1 ] >>getter
         [ set-alien-signed-1 ] >>setter
         1 >>size
@@ -401,6 +418,7 @@ CONSTANT: primitive-types
 
     <c-type>
         fixnum >>class
+        fixnum >>boxed-class
         [ alien-unsigned-1 ] >>getter
         [ set-alien-unsigned-1 ] >>setter
         1 >>size
@@ -420,25 +438,27 @@ CONSTANT: primitive-types
 
     <c-type>
         float >>class
+        float >>boxed-class
         [ alien-float ] >>getter
         [ [ >float ] 2dip set-alien-float ] >>setter
         4 >>size
         4 >>align
         "box_float" >>boxer
         "to_float" >>unboxer
-        single-float-regs >>reg-class
+        single-float-rep >>rep
         [ >float ] >>unboxer-quot
     "float" define-primitive-type
 
     <c-type>
         float >>class
+        float >>boxed-class
         [ alien-double ] >>getter
         [ [ >float ] 2dip set-alien-double ] >>setter
         8 >>size
         8 >>align
         "box_double" >>boxer
         "to_double" >>unboxer
-        double-float-regs >>reg-class
+        double-float-rep >>rep
         [ >float ] >>unboxer-quot
     "double" define-primitive-type
 
index 0bff73b898dae2ddc88e873c4c0d3d722461275c..2844e505b5ae181ccb588fc23594095654e93a79 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.test alien.complex kernel alien.c-types alien.syntax
-namespaces ;
+namespaces math ;
 IN: alien.complex.tests
 
 C-STRUCT: complex-holder
@@ -16,3 +16,7 @@ C-STRUCT: complex-holder
 ] unit-test
 
 [ C{ 1.0 2.0 } ] [ "h" get complex-holder-z ] unit-test
+
+[ number ] [ "complex-float" c-type-boxed-class ] unit-test
+
+[ number ] [ "complex-double" c-type-boxed-class ] unit-test
\ No newline at end of file
index c80ead73f0bf701d6173abf0ccd234681572713b..b0229358d1f1893b6cffc5b92fab3b34f506cb18 100644 (file)
@@ -10,4 +10,4 @@ IN: alien.complex
 ! This overrides the fact that small structures are never returned
 ! in registers on NetBSD, Linux and Solaris running on 32-bit x86.
 "complex-float" c-type t >>return-in-registers? drop
- >>
+>>
diff --git a/basis/alien/complex/functor/functor-tests.factor b/basis/alien/complex/functor/functor-tests.factor
deleted file mode 100644 (file)
index c2df22b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test alien.complex.functor ;
-IN: alien.complex.functor.tests
index fc9e594be57824f4cb3dbda092498b2f58ca7634..98d412639f8c239a0b50e76848b1a559fad8a5f6 100644 (file)
@@ -30,6 +30,7 @@ define-struct
 T c-type
 <T> 1quotation >>unboxer-quot
 *T 1quotation >>boxer-quot
+number >>boxed-class
 drop
 
 ;FUNCTOR
diff --git a/basis/alien/destructors/destructors-tests.factor b/basis/alien/destructors/destructors-tests.factor
deleted file mode 100644 (file)
index 4f43445..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test alien.destructors ;
-IN: alien.destructors.tests
index 54b799f6750f2b9d3d3fb54ef72a58a43638f0b4..013c4d6f6a8c92a5e7fc8db76f971a492065602b 100644 (file)
@@ -357,15 +357,15 @@ M: character-type (<fortran-result>)
 
 : (shuffle-map) ( return parameters -- ret par )
     [
-        fortran-ret-type>c-type length swap "void" = [ 1+ ] unless
+        fortran-ret-type>c-type length swap "void" = [ 1 + ] unless
         letters swap head [ "ret" swap suffix ] map
     ] [
-        [ fortran-arg-type>c-type nip length 1+ ] map letters swap zip
+        [ fortran-arg-type>c-type nip length 1 + ] map letters swap zip
         [ first2 letters swap head [ "" 2sequence ] with map ] map concat
     ] bi* ;
 
 : (fortran-in-shuffle) ( ret par -- seq )
-    [ [ second ] bi@ <=> ] sort append ;
+    [ second ] sort-with append ;
 
 : (fortran-out-shuffle) ( ret par -- seq )
     append ;
index 13eb134ea9bc557865eceacdb18fec59e8619c81..f1dc228d83ed74cfa7edeca32cd6ccaf8779559d 100644 (file)
@@ -1,5 +1,5 @@
-IN: alien.libraries.tests
 USING: alien.libraries alien.syntax tools.test kernel ;
+IN: alien.libraries.tests
 
 [ f ] [ DLL" fadfasdfsada" dll-valid? ] unit-test
 
@@ -7,4 +7,4 @@ USING: alien.libraries alien.syntax tools.test kernel ;
 
 [ ] [ "doesnotexist" dlopen dlclose ] unit-test
 
-[ "fdasfsf" dll-valid? drop ] must-fail
\ No newline at end of file
+[ "fdasfsf" dll-valid? drop ] must-fail
index 231f1bd42876a1e4f842fc97e0cd5a7b816604ff..3f84377d5c8164a22e2ac4518b826d8620832132 100755 (executable)
@@ -1,6 +1,6 @@
-IN: alien.structs.tests
 USING: alien alien.syntax alien.c-types kernel tools.test
 sequences system libc words vocabs namespaces layouts ;
+IN: alien.structs.tests
 
 C-STRUCT: bar
     { "int" "x" }
index b618e7974bc76cd9647f5fcd0f3f4a2c39f12616..5c1fb4063b90f78dff63428173bc87be66eb558c 100755 (executable)
@@ -6,30 +6,12 @@ alien.c-types alien.structs.fields cpu.architecture math.order
 quotations byte-arrays ;
 IN: alien.structs
 
-TUPLE: struct-type
-size
-align
-fields
-{ boxer-quot callable }
-{ unboxer-quot callable }
-{ getter callable }
-{ setter callable }
-return-in-registers? ;
+TUPLE: struct-type < abstract-c-type fields return-in-registers? ;
 
 M: struct-type c-type ;
 
-M: struct-type heap-size size>> ;
-
-M: struct-type c-type-class drop byte-array ;
-
-M: struct-type c-type-align align>> ;
-
 M: struct-type c-type-stack-align? drop f ;
 
-M: struct-type c-type-boxer-quot boxer-quot>> ;
-
-M: struct-type c-type-unboxer-quot unboxer-quot>> ;
-
 : if-value-struct ( ctype true false -- )
     [ dup value-struct? ] 2dip '[ drop "void*" @ ] if ; inline
 
@@ -56,6 +38,8 @@ M: struct-type stack-size
 : (define-struct) ( name size align fields -- )
     [ [ align ] keep ] dip
     struct-type new
+        byte-array >>class
+        byte-array >>boxed-class
         swap >>fields
         swap >>align
         swap >>size
index d479e6d498e5a37b46ab5326f07300c1b3d22223..b70aa3557c9f2afabc6665f7b92762914f36b397 100644 (file)
@@ -31,8 +31,10 @@ SYNTAX: C-ENUM:
     ";" parse-tokens
     [ [ create-in ] dip define-constant ] each-index ;
 
+ERROR: no-such-symbol name library ;
+
 : address-of ( name library -- value )
-    load-library dlsym [ "No such symbol" throw ] unless* ;
+    2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
 
 SYNTAX: &:
     scan "c-library" get '[ _ _ address-of ] over push-all ;
index 6f39b32a0110c906865162ff2ce1895e0479df18..8551ba53efc7c6dc715b6f4f20c1ff1e2221774b 100644 (file)
@@ -10,7 +10,7 @@ IN: ascii.tests
 
 [ 4 ] [
     0 "There are Four Upper Case characters"
-    [ LETTER? [ 1+ ] when ] each
+    [ LETTER? [ 1 + ] when ] each
 ] unit-test
 
 [ t f ] [ CHAR: \s ascii? 400 ascii? ] unit-test
index 47147fa3066f90711f64dc5d6d1266f17b6c7fca..eb2c9193a374b35e61a33a2f510f4c2582eaf04e 100644 (file)
@@ -34,7 +34,7 @@ SYMBOL: column
 : write1-lines ( ch -- )
     write1
     column get [
-        1+ [ 76 = [ crlf ] when ]
+        1 + [ 76 = [ crlf ] when ]
         [ 76 mod column set ] bi
     ] when* ;
 
@@ -48,7 +48,7 @@ SYMBOL: column
 
 : encode-pad ( seq n -- )
     [ 3 0 pad-tail binary [ encode3 ] with-byte-writer ]
-    [ 1+ ] bi* head-slice 4 CHAR: = pad-tail write-lines ; inline
+    [ 1 + ] bi* head-slice 4 CHAR: = pad-tail write-lines ; inline
 
 : decode4 ( seq -- )
     [ 0 [ base64>ch swap 6 shift bitor ] reduce 3 >be ]
index f408cc82a8be1ffabd378af6814a78c11b65fa05..2ef54441e14f838a0eaac7a1dd92e95e50cdfb81 100644 (file)
@@ -1,5 +1,5 @@
-IN: biassocs.tests
 USING: biassocs assocs namespaces tools.test ;
+IN: biassocs.tests
 
 <bihash> "h" set
 
@@ -29,4 +29,4 @@ H{ { "a" "A" } { "b" "B" } } "a" set
 
 [ "A" ] [ "a" "b" get at ] unit-test
 
-[ "a" ] [ "A" "b" get value-at ] unit-test
\ No newline at end of file
+[ "a" ] [ "A" "b" get value-at ] unit-test
index 63d2697418b3c297ae78e5c894433d68059d0e67..f2ea7503f4851f8a8ac6bdb371a21237053d03ce 100644 (file)
@@ -1,5 +1,5 @@
-IN: binary-search.tests
 USING: binary-search math.order vectors kernel tools.test ;
+IN: binary-search.tests
 
 [ f ] [ 3 { } [ <=> ] with search drop ] unit-test
 [ 0 ] [ 3 { 3 } [ <=> ] with search drop ] unit-test
@@ -9,7 +9,7 @@ USING: binary-search math.order vectors kernel tools.test ;
 [ 4 ] [ 5.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
 [ 10 ] [ 10 20 >vector [ <=> ] with search drop ] unit-test
 
-[ t ] [ "hello" { "alligrator" "cat" "fish" "hello" "ikarus" "java" } sorted-member? ] unit-test
-[ 3 ] [ "hey" { "alligrator" "cat" "fish" "hello" "ikarus" "java" } sorted-index ] unit-test
-[ f ] [ "hello" { "alligrator" "cat" "fish" "ikarus" "java" } sorted-member? ] unit-test
-[ f ] [ "zebra" { "alligrator" "cat" "fish" "ikarus" "java" } sorted-member? ] unit-test
+[ t ] [ "hello" { "alligator" "cat" "fish" "hello" "ikarus" "java" } sorted-member? ] unit-test
+[ 3 ] [ "hey" { "alligator" "cat" "fish" "hello" "ikarus" "java" } sorted-index ] unit-test
+[ f ] [ "hello" { "alligator" "cat" "fish" "ikarus" "java" } sorted-member? ] unit-test
+[ f ] [ "zebra" { "alligator" "cat" "fish" "ikarus" "java" } sorted-member? ] unit-test
index cdec87b61dc1f2f4a31689ea9e74fce89e560266..7aea3c458ae297b67103ac316f14ddfb371571d0 100644 (file)
@@ -91,10 +91,10 @@ SYNTAX: ?{ \ } [ >bit-array ] parse-literal ;
     dup 0 = [
         <bit-array>
     ] [
-        [ log2 1+ <bit-array> 0 ] keep
+        [ log2 1 + <bit-array> 0 ] keep
         [ dup 0 = ] [
             [ pick underlying>> pick set-alien-unsigned-1 ] keep
-            [ 1+ ] [ -8 shift ] bi*
+            [ 1 + ] [ -8 shift ] bi*
         ] until 2drop
     ] if ;
 
index e77bb43986adf1e29216ab148daccc03d7dff023..6a1366a1ea3a9956bffd889de5c2e9662d897cff 100644 (file)
@@ -1,5 +1,5 @@
-IN: bit-sets.tests
 USING: bit-sets tools.test bit-arrays ;
+IN: bit-sets.tests
 
 [ ?{ t f t f t f } ] [
     ?{ t f f f t f }
index 41efdbd0d22b491fda2eca30d89b61a5381deba0..5af44b59f7f30577e24a753a74c4565fe1f03689 100644 (file)
@@ -1,5 +1,5 @@
-IN: bit-vectors.tests\r
 USING: tools.test bit-vectors vectors sequences kernel math ;\r
+IN: bit-vectors.tests\r
 \r
 [ 0 ] [ 123 <bit-vector> length ] unit-test\r
 \r
index a5b1b43acd0995061099bdc37f5d4a341b3a817d..794faa6055fc399f5c6a092ca62872b0fc125880 100644 (file)
@@ -5,7 +5,6 @@ grouping compression.lzw multiline byte-arrays io.encodings.binary
 io.streams.byte-array ;
 IN: bitstreams.tests
 
-
 [ BIN: 1111111111 ]
 [
     B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
index 2aa0059542862372be8010dd7a721da64c20fec0..0eef54dc66c6ae2f6738d992c38da26d080216a1 100644 (file)
@@ -70,7 +70,7 @@ GENERIC: poke ( value n bitstream -- )
     [ get-abp + ] [ set-abp ] bi ; inline
     
 : (align) ( n m -- n' )
-    [ /mod 0 > [ 1+ ] when ] [ * ] bi ; inline
+    [ /mod 0 > [ 1 + ] when ] [ * ] bi ; inline
     
 : align ( n bitstream -- )
     [ get-abp swap (align) ] [ set-abp ] bi ; inline
index e1466e340947c7a62f6e1dc0a6cd0451654fd3d7..04c75c549d8852546dff1c4903a50437c1228a76 100644 (file)
@@ -1,38 +1,42 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors compiler.cfg.builder compiler.cfg.linear-scan
-compiler.cfg.liveness compiler.cfg.mr compiler.cfg.optimizer
-compiler.cfg.stacks.finalize compiler.cfg.stacks.global
-compiler.codegen compiler.tree.builder compiler.tree.optimizer
-kernel make sequences tools.annotations tools.crossref ;
+USING: accessors kernel make sequences tools.annotations tools.crossref ;
+QUALIFIED: compiler.cfg.builder
+QUALIFIED: compiler.cfg.linear-scan
+QUALIFIED: compiler.cfg.mr
+QUALIFIED: compiler.cfg.optimizer
+QUALIFIED: compiler.cfg.stacks.finalize
+QUALIFIED: compiler.cfg.stacks.global
+QUALIFIED: compiler.codegen
+QUALIFIED: compiler.tree.builder
+QUALIFIED: compiler.tree.optimizer
 IN: bootstrap.compiler.timing
 
 : passes ( word -- seq )
     def>> uses [ vocabulary>> "compiler." head? ] filter ;
 
-: high-level-passes ( -- seq ) \ optimize-tree passes ;
+: high-level-passes ( -- seq ) \ compiler.tree.optimizer:optimize-tree passes ;
 
-: low-level-passes ( -- seq ) \ optimize-cfg passes ;
+: low-level-passes ( -- seq ) \ compiler.cfg.optimizer:optimize-cfg passes ;
 
-: machine-passes ( -- seq ) \ build-mr passes ;
+: machine-passes ( -- seq ) \ compiler.cfg.mr:build-mr passes ;
 
-: linear-scan-passes ( -- seq ) \ (linear-scan) passes ;
+: linear-scan-passes ( -- seq ) \ compiler.cfg.linear-scan:(linear-scan) passes ;
 
 : all-passes ( -- seq )
     [
-        \ build-tree ,
-        \ optimize-tree ,
+        \ compiler.tree.builder:build-tree ,
+        \ compiler.tree.optimizer:optimize-tree ,
         high-level-passes %
-        \ build-cfg ,
-        \ compute-global-sets ,
-        \ finalize-stack-shuffling ,
-        \ optimize-cfg ,
+        \ compiler.cfg.builder:build-cfg ,
+        \ compiler.cfg.stacks.global:compute-global-sets ,
+        \ compiler.cfg.stacks.finalize:finalize-stack-shuffling ,
+        \ compiler.cfg.optimizer:optimize-cfg ,
         low-level-passes %
-        \ compute-live-sets ,
-        \ build-mr ,
+        \ compiler.cfg.mr:build-mr ,
         machine-passes %
         linear-scan-passes %
-        \ generate ,
+        \ compiler.codegen:generate ,
     ] { } make ;
 
 all-passes [ [ reset ] [ add-timing ] bi ] each
\ No newline at end of file
index e7070d3cf2435a11297966168b0399a88dc8a28e..c5c6460041ecdf495180307b9745b4758fcf317e 100644 (file)
@@ -1,6 +1,6 @@
-IN: bootstrap.image.tests
 USING: bootstrap.image bootstrap.image.private tools.test
 kernel math ;
+IN: bootstrap.image.tests
 
 [ f ] [ { 1 2 3 } [ 1 2 3 ] eql? ] unit-test
 
index d76588e4e461c4870d0106054278a1747554a96b..38cb5c12fe1156e38278e4e7b9fd3fb320189475 100644 (file)
@@ -234,7 +234,7 @@ GENERIC: ' ( obj -- ptr )
 
 : bignum-bits ( -- n ) bootstrap-cell-bits 2 - ;
 
-: bignum-radix ( -- n ) bignum-bits 2^ 1- ;
+: bignum-radix ( -- n ) bignum-bits 2^ 1 - ;
 
 : bignum>seq ( n -- seq )
     #! n is positive or zero.
@@ -244,7 +244,7 @@ GENERIC: ' ( obj -- ptr )
 
 : emit-bignum ( n -- )
     dup dup 0 < [ neg ] when bignum>seq
-    [ nip length 1+ emit-fixnum ]
+    [ nip length 1 + emit-fixnum ]
     [ drop 0 < 1 0 ? emit ]
     [ nip emit-seq ]
     2tri ;
index d70a253e5f46a90cc3231205e2f3061b17d9636a..7f25ce9c017d7c4f934dc404d96addd525728440 100644 (file)
@@ -9,9 +9,9 @@ IN: bootstrap.image.upload
 SYMBOL: upload-images-destination
 
 : destination ( -- dest )
-  upload-images-destination get
-  "slava@factorcode.org:/var/www/factorcode.org/newsite/images/latest/"
-  or ;
+    upload-images-destination get
+    "slava@factorcode.org:/var/www/factorcode.org/newsite/images/latest/"
+    or ;
 
 : checksums ( -- temp ) "checksums.txt" temp-file ;
 
index 27b2f6b181f79f322c8185af743261099237a9f5..3bab31daeb0501ef6176113f164c73fea92e3aa1 100644 (file)
@@ -2,4 +2,4 @@ USING: vocabs vocabs.loader kernel ;
 
 "math.ratios" require
 "math.floats" require
-"math.complex" require
\ No newline at end of file
+"math.complex" require
index 71fc1c9a7b04788dbf1d781a53e60dfde27bb4c2..3bcb735217f9a79e2295c0af32c919d56bb32171 100644 (file)
@@ -1,5 +1,5 @@
-IN: boxes.tests\r
 USING: boxes namespaces tools.test accessors ;\r
+IN: boxes.tests\r
 \r
 [ ] [ <box> "b" set ] unit-test\r
 \r
index f1b9a5230334de5c4bcf701327d13c68200842f6..5c381b7db0a07253de2d4d5367d102d5fcfb945e 100644 (file)
@@ -8,4 +8,3 @@ SYNTAX: HEX{
     [ blank? not ] filter
     2 group [ hex> ] B{ } map-as
     parsed ;
-
diff --git a/basis/cache/cache-tests.factor b/basis/cache/cache-tests.factor
deleted file mode 100644 (file)
index cbf4f64..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test cache ;
-IN: cache.tests
index f16461bf450b994375afd92262db8366686a2024..3dab1acac8c8f865e5211494e2ab0978e01ad6c7 100644 (file)
@@ -38,6 +38,6 @@ PRIVATE>
 
 : purge-cache ( cache -- )
     dup max-age>> '[
-        [ nip [ 1+ ] change-age age>> _ >= ] assoc-partition
+        [ nip [ 1 + ] change-age age>> _ >= ] assoc-partition
         [ values dispose-each ] dip
-    ] change-assoc drop ;
\ No newline at end of file
+    ] change-assoc drop ;
index bf7c468774814c92e87dc29a7d5674a7dc84870a..cb19259984e0a0d9ec9ab25217c94a7422e38c6a 100644 (file)
@@ -1,8 +1,8 @@
-IN: cairo.tests
 USING: cairo tools.test math.rectangles accessors ;
+IN: cairo.tests
 
 [ { 10 20 } ] [
     { 10 20 } [
         { 0 1 } { 3 4 } <rect> fill-rect
     ] make-bitmap-image dim>>
-] unit-test
\ No newline at end of file
+] unit-test
index 3aae10f6a7461ef0d7b8cd7257da5d2c0429d134..71e052bb6cd12116180100ffe32697f9036221a3 100644 (file)
@@ -20,14 +20,14 @@ HELP: <date>
 { $values { "year" integer } { "month" integer } { "day" integer } { "timestamp" timestamp } }
 { $description "Returns a timestamp object representing the start of the specified day in your current timezone." }
 { $examples
-    { $example "USING: calendar prettyprint ;"
-               "2010 12 25 <date> >gmt midnight ."
+    { $example "USING: accessors calendar prettyprint ;"
+               "2010 12 25 <date> instant >>gmt-offset ."
                "T{ timestamp { year 2010 } { month 12 } { day 25 } }"
     }
 } ;
 
 HELP: month-names
-{ $values { "array" array } }
+{ $values { "value" object } }
 { $description "Returns an array with the English names of all the months." }
 { $warning "Do not use this array for looking up a month name directly. Use month-name instead." } ;
 
index 4b58b1b496b825302690c82dca6bbd9312d9189f..a8bb60cbf36396f4098e37c23baf3b0b52a67d80 100644 (file)
@@ -34,25 +34,25 @@ C: <timestamp> timestamp
 : <date> ( year month day -- timestamp )
     0 0 0 gmt-offset-duration <timestamp> ;
 
-ERROR: not-a-month ;
+ERROR: not-a-month ;
 M: not-a-month summary
     drop "Months are indexed starting at 1" ;
 
 <PRIVATE
 
 : check-month ( n -- n )
-    dup zero? [ not-a-month ] when ;
+    [ not-a-month ] when-zero ;
 
 PRIVATE>
 
-: month-names ( -- array )
+CONSTANT: month-names 
     {
         "January" "February" "March" "April" "May" "June"
         "July" "August" "September" "October" "November" "December"
-    } ;
+    }
 
 : month-name ( n -- string )
-    check-month 1- month-names nth ;
+    check-month 1 - month-names nth ;
 
 CONSTANT: month-abbreviations
     {
@@ -61,7 +61,7 @@ CONSTANT: month-abbreviations
     }
 
 : month-abbreviation ( n -- string )
-    check-month 1- month-abbreviations nth ;
+    check-month 1 - month-abbreviations nth ;
 
 CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 }
 
@@ -113,7 +113,7 @@ CONSTANT: day-abbreviations3
     100 b * d + 4800 -
     m 10 /i + m 3 +
     12 m 10 /i * -
-    e 153 m * 2 + 5 /i - 1+ ;
+    e 153 m * 2 + 5 /i - 1 + ;
 
 GENERIC: easter ( obj -- obj' )
 
@@ -186,9 +186,6 @@ GENERIC: +second ( timestamp x -- timestamp )
     { [ day>> 29 = ] [ month>> 2 = ] [ leap-year? not ] } 1&&
     [ 3 >>month 1 >>day ] when ;
 
-: unless-zero ( n quot -- )
-    [ dup zero? [ drop ] ] dip if ; inline
-
 M: integer +year ( timestamp n -- timestamp )
     [ [ + ] curry change-year adjust-leap-year ] unless-zero ;
 
@@ -196,7 +193,7 @@ M: real +year ( timestamp n -- timestamp )
     [ float>whole-part swapd days-per-year * +day swap +year ] unless-zero ;
 
 : months/years ( n -- months years )
-    12 /rem dup zero? [ drop 1- 12 ] when swap ; inline
+    12 /rem [ 1 - 12 ] when-zero swap ; inline
 
 M: integer +month ( timestamp n -- timestamp )
     [ over month>> + months/years [ >>month ] dip +year ] unless-zero ;
@@ -371,10 +368,10 @@ M: duration time-
     #! http://web.textfiles.com/computers/formulas.txt
     #! good for any date since October 15, 1582
     [
-        dup 2 <= [ [ 1- ] [ 12 + ] bi* ] when
+        dup 2 <= [ [ 1 - ] [ 12 + ] bi* ] when
         [ dup [ 4 /i + ] [ 100 /i - ] [ 400 /i + ] tri ] dip
-        [ 1+ 3 * 5 /i + ] keep 2 * +
-    ] dip 1+ + 7 mod ;
+        [ 1 + 3 * 5 /i + ] keep 2 * +
+    ] dip 1 + + 7 mod ;
 
 GENERIC: days-in-year ( obj -- n )
 
@@ -395,7 +392,7 @@ M: timestamp days-in-year ( timestamp -- n ) year>> days-in-year ;
     year leap-year? [
         year month day <date>
         year 3 1 <date>
-        after=? [ 1+ ] when
+        after=? [ 1 + ] when
     ] when ;
 
 : day-of-year ( timestamp -- n )
index ad43cc2f1d6d17fd811c14c4fbfce6aa641f9e55..6aa4126ff920f913ea4a7cd3e7b986793020c122 100644 (file)
@@ -68,8 +68,8 @@ M: array month. ( pair -- )
     [ (days-in-month) day-abbreviations2 " " join print ] 2tri\r
     over "   " <repetition> concat write\r
     [\r
-        [ 1+ day. ] keep\r
-        1+ + 7 mod zero? [ nl ] [ bl ] if\r
+        [ 1 + day. ] keep\r
+        1 + + 7 mod zero? [ nl ] [ bl ] if\r
     ] with each nl ;\r
 \r
 M: timestamp month. ( timestamp -- )\r
@@ -78,7 +78,7 @@ M: timestamp month. ( timestamp -- )
 GENERIC: year. ( obj -- )\r
 \r
 M: integer year. ( n -- )\r
-    12 [ 1+ 2array month. nl ] with each ;\r
+    12 [ 1 + 2array month. nl ] with each ;\r
 \r
 M: timestamp year. ( timestamp -- )\r
     year>> year. ;\r
@@ -162,7 +162,7 @@ M: timestamp year. ( timestamp -- )
 \r
 : read-rfc3339-seconds ( s -- s' ch )\r
     "+-Z" read-until [\r
-        [ string>number ] [ length 10 swap ^ ] bi / +\r
+        [ string>number ] [ length 10^ ] bi / +\r
     ] dip ;\r
 \r
 : (rfc3339>timestamp) ( -- timestamp )\r
@@ -201,7 +201,7 @@ ERROR: invalid-timestamp-format ;
         "," read-token day-abbreviations3 member? check-timestamp drop\r
         read1 CHAR: \s assert=\r
         read-sp checked-number >>day\r
-        read-sp month-abbreviations index 1+ check-timestamp >>month\r
+        read-sp month-abbreviations index 1 + check-timestamp >>month\r
         read-sp checked-number >>year\r
         ":" read-token checked-number >>hour\r
         ":" read-token checked-number >>minute\r
@@ -220,7 +220,7 @@ ERROR: invalid-timestamp-format ;
         "," read-token check-day-name\r
         read1 CHAR: \s assert=\r
         "-" read-token checked-number >>day\r
-        "-" read-token month-abbreviations index 1+ check-timestamp >>month\r
+        "-" read-token month-abbreviations index 1 + check-timestamp >>month\r
         read-sp checked-number >>year\r
         ":" read-token checked-number >>hour\r
         ":" read-token checked-number >>minute\r
@@ -233,7 +233,7 @@ ERROR: invalid-timestamp-format ;
 : (cookie-string>timestamp-2) ( -- timestamp )\r
     timestamp new\r
         read-sp check-day-name\r
-        read-sp month-abbreviations index 1+ check-timestamp >>month\r
+        read-sp month-abbreviations index 1 + check-timestamp >>month\r
         read-sp checked-number >>day\r
         ":" read-token checked-number >>hour\r
         ":" read-token checked-number >>minute\r
index 1e51fb06d8f68106bef94558503014e69635edc8..99fa41cd400e7788dc76a2046ca124f7b3d05760 100644 (file)
@@ -7,7 +7,7 @@ locals sequences ;
 IN: channels.examples
 
 : (counter) ( channel n -- )
-    [ swap to ] 2keep 1+ (counter) ;
+    [ swap to ] 2keep 1 + (counter) ;
     
 : counter ( channel -- )
     2 (counter) ;    
index f221cefef2193ebd1079f9199908d1cc27666e26..5cc6b0242572fd512a4b32fdb58306578d637b5e 100644 (file)
@@ -1,9 +1,7 @@
 ! Copyright (C) 2009 Alaric Snell-Pym
 ! See http://factorcode.org/license.txt for BSD license.
-
 USING: checksums classes.singleton kernel math math.ranges
 math.vectors sequences ;
-
 IN: checksums.fnv1
 
 SINGLETON: fnv1-32
index b7f388c0029d104adf044db5a755545ea14fecf3..730c0b851662d93fef29e13475ed6b4d56299d50 100644 (file)
@@ -1,6 +1,8 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
 USING: byte-arrays checksums checksums.md5 io.encodings.binary
 io.streams.byte-array kernel math namespaces tools.test ;
-
+IN: checksums.md5.tests 
 
 [ "d41d8cd98f00b204e9800998ecf8427e" ] [ "" >byte-array md5 checksum-bytes hex-string ] unit-test
 [ "0cc175b9c0f1b6a831c399e269772661" ] [ "a" >byte-array md5 checksum-bytes hex-string ] unit-test
index b4a9d547f2edc888bde7efce60371f3f53616502..c3c4860f953a3e51b1f219f811ec4c015f561374 100644 (file)
@@ -2,6 +2,7 @@
 ! See http;//factorcode.org/license.txt for BSD license
 USING: arrays kernel tools.test sequences sequences.private
 circular strings ;
+IN: circular.tests
 
 [ 0 ] [ { 0 1 2 3 4 } <circular> 0 swap virtual@ drop ] unit-test
 [ 2 ] [ { 0 1 2 3 4 } <circular> 2 swap virtual@ drop ] unit-test
index 9995567ec899c93f047e0f07f97343cf34d6e737..b3be4651cd627799269edbefa72ac168f97718ba 100644 (file)
@@ -51,7 +51,7 @@ PRIVATE>
 
 : push-growing-circular ( elt circular -- )
     dup full? [ push-circular ]
-    [ [ 1+ ] change-length set-last ] if ;
+    [ [ 1 + ] change-length set-last ] if ;
 
 : <growing-circular> ( capacity -- growing-circular )
     { } new-sequence 0 0 growing-circular boa ;
index 4ed9d7de67bf3f78160fa82ac012f0c9d3396d53..a798eb15ba0cee9e917d744f1ad87a8aacec9ca5 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2005, 2006 Kevin Reid.
 ! See http://factorcode.org/license.txt for BSD license.
-IN: cocoa.callbacks
 USING: assocs kernel namespaces cocoa cocoa.classes
 cocoa.subclassing debugger ;
+IN: cocoa.callbacks
 
 SYMBOL: callbacks
 
index 4b5af2e39d3ce533aa8b24b0a7512df388b15edc..c657a5e6e896c82cc63cb5ffa0428e97c56b2c3c 100644 (file)
@@ -1,7 +1,7 @@
-IN: cocoa.tests
 USING: cocoa cocoa.messages cocoa.subclassing cocoa.types
 compiler kernel namespaces cocoa.classes tools.test memory
 compiler.units math core-graphics.types ;
+IN: cocoa.tests
 
 CLASS: {
     { +superclass+ "NSObject" }
index a3fa788f209986f9edb9d92b9fd63d0fcab7fa15..9da285f34c157980de5d51d3a57f3d4275467019 100644 (file)
@@ -172,7 +172,7 @@ ERROR: no-objc-type name ;
     [ ] [ no-objc-type ] ?if ;
 
 : (parse-objc-type) ( i string -- ctype )
-    [ [ 1+ ] dip ] [ nth ] 2bi {
+    [ [ 1 + ] dip ] [ nth ] 2bi {
         { [ dup "rnNoORV" member? ] [ drop (parse-objc-type) ] }
         { [ dup CHAR: ^ = ] [ 3drop "void*" ] }
         { [ dup CHAR: { = ] [ drop objc-struct-type ] }
index 4f74cd850acd65bd523dba682a8f8ec2e96f416d..e5d7dfd2399403a09201b54bff1cb3625bae6c2c 100644 (file)
@@ -1,7 +1,7 @@
-IN: cocoa.plists.tests
 USING: tools.test cocoa.plists colors kernel hashtables
 core-foundation.utilities core-foundation destructors
 assocs cocoa.enumeration ;
+IN: cocoa.plists.tests
 
 [
     [ V{ } ] [ H{ } >cf &CFRelease [ ] NSFastEnumeration-map ] unit-test
@@ -37,4 +37,4 @@ assocs cocoa.enumeration ;
     [ 3.5 ] [
         3.5 >cf &CFRelease plist>
     ] unit-test
-] with-destructors
\ No newline at end of file
+] with-destructors
index a825cacda8d2526a1e3707feccf2c1f5bbbe2582..278906ce0ea3b3ea2c27fc4eedd7075def8df3cd 100644 (file)
@@ -1,5 +1,5 @@
-IN: colors.hsv.tests
 USING: accessors kernel colors colors.hsv tools.test math ;
+IN: colors.hsv.tests
 
 : hsv>rgb ( h s v -- r g b )
     [ 360 * ] 2dip
@@ -25,4 +25,4 @@ USING: accessors kernel colors colors.hsv tools.test math ;
 [ 5/6 5/36 5/6 ] [ 5/6 5/6 5/6 hsv>rgb ] unit-test
 [ 1/6 0 1/6 ] [ 5/6 1 1/6 hsv>rgb ] unit-test
 
-[ 0.5 ] [ 180 0.1 0.2 0.5 <hsva> alpha>> ] unit-test
\ No newline at end of file
+[ 0.5 ] [ 180 0.1 0.2 0.5 <hsva> alpha>> ] unit-test
index 657b9e0a25b286b02beeedb512fadba230602ead..a53f5c11853fa3c9d0fdf7c22b6bfffcfee455d3 100644 (file)
@@ -1,5 +1,5 @@
-IN: columns.tests
 USING: columns sequences kernel namespaces arrays tools.test math ;
+IN: columns.tests
 
 ! Columns
 { { 1 2 3 } { 4 5 6 } { 7 8 9 } } [ clone ] map "seq" set
index 66ba001094fe01c14adb1e5038418e279c14009d..db7056bd5a278cfccaf531dcac0af00cc4284937 100644 (file)
@@ -13,27 +13,27 @@ HELP: 0||
 { $description "If every quotation in the sequence outputs " { $link f } ", outputs " { $link f } ", otherwise outputs the result of the first quotation that did not yield " { $link f } "." } ;
 
 HELP: 1&&
-{ $values { "obj" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( -- )" } } { "?" "the result of the last quotation, or " { $link f } } }
+{ $values { "obj" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj -- )" } } { "?" "the result of the last quotation, or " { $link f } } }
 { $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
 
 HELP: 1||
-{ $values { "obj" object } { "quots" "a sequence of quotations" } { "?" "the first true result, or " { $link f } } }
+{ $values { "obj" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj -- )" } } { "?" "the first true result, or " { $link f } } }
 { $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same element from the datastack and must return a boolean." } ;
 
 HELP: 2&&
-{ $values { "obj1" object } { "obj2" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( -- )" } } { "?" "the result of the last quotation, or " { $link f } } }
+{ $values { "obj1" object } { "obj2" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 -- )" } } { "?" "the result of the last quotation, or " { $link f } } }
 { $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
 
 HELP: 2||
-{ $values { "obj1" object } { "obj2" object } { "quots" "a sequence of quotations" } { "?" "the first true result, or " { $link f } } }
+{ $values { "obj1" object } { "obj2" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 -- )" } } { "?" "the first true result, or " { $link f } } }
 { $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same two elements from the datastack and must return a boolean." } ;
 
 HELP: 3&&
-{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( -- )" } } { "?" "the result of the last quotation, or " { $link f } } }
+{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 obj3 -- )" } } { "?" "the result of the last quotation, or " { $link f } } }
 { $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
 
 HELP: 3||
-{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quots" "a sequence of quotations" } { "?" "the first true result, or " { $link f } } }
+{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 obj3 -- )" } } { "?" "the first true result, or " { $link f } } }
 { $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same three elements from the datastack and must return a boolean." } ;
 
 HELP: n&&
index 7ec4a0e6572a0818a39fcabc623d425e9f9957d5..c8cf8ffc1bb3afc37a2845421e52426e61359f7d 100644 (file)
@@ -1,32 +1,18 @@
-
 USING: kernel math tools.test combinators.short-circuit.smart ;
-
 IN: combinators.short-circuit.smart.tests
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: must-be-t ( in -- ) [ t ] swap unit-test ;
-: must-be-f ( in -- ) [ f ] swap unit-test ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-[       { [ 1 ] [ 2 ] [ 3 ] }          &&  3 = ] must-be-t
-[ 3     { [ 0 > ] [ odd? ] [ 2 + ] }    &&  5 = ] must-be-t
-[ 10 20 { [ + 0 > ] [ - even? ] [ + ] } && 30 = ] must-be-t
-
-[       { [ 1 ] [ f ] [ 3 ] } &&  3 = ]          must-be-f
-[ 3     { [ 0 > ] [ even? ] [ 2 + ] } && ]       must-be-f
-[ 10 20 { [ + 0 > ] [ - odd? ] [ + ] } && 30 = ] must-be-f
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-[ { [ 10 0 < ] [ f ] [ "factor" ] } || "factor" = ] must-be-t
+[ t ] [       { [ 1 ] [ 2 ] [ 3 ] }          &&  3 = ] unit-test
+[ t ] [ 3     { [ 0 > ] [ odd? ] [ 2 + ] }    &&  5 = ] unit-test
+[ t ] [ 10 20 { [ + 0 > ] [ - even? ] [ + ] } && 30 = ] unit-test
 
-[ 10 { [ odd? ] [ 100 > ] [ 1 + ] } || 11 = ]       must-be-t
+[ f ] [       { [ 1 ] [ f ] [ 3 ] } &&  3 = ]          unit-test
+[ f ] [ 3     { [ 0 > ] [ even? ] [ 2 + ] } && ]       unit-test
+[ f ] [ 10 20 { [ + 0 > ] [ - odd? ] [ + ] } && 30 = ] unit-test
 
-[ 10 20 { [ + odd? ] [ + 100 > ] [ + ] } || 30 = ]  must-be-t
+[ t ] [ { [ 10 0 < ] [ f ] [ "factor" ] } || "factor" = ] unit-test
 
-[ { [ 10 0 < ] [ f ] [ 0 1 = ] } || ] must-be-f
+[ t ] [ 10 { [ odd? ] [ 100 > ] [ 1 + ] } || 11 = ]       unit-test
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+[ t ] [ 10 20 { [ + odd? ] [ + 100 > ] [ + ] } || 30 = ]  unit-test
 
+[ f ] [ { [ 10 0 < ] [ f ] [ 0 1 = ] } || ] unit-test
index b80e7294d15e064c926a36a09ff732c2cb1eaebe..7264a07917a1867fd933efc750f96ec5240741f5 100644 (file)
@@ -1,13 +1,15 @@
-USING: kernel sequences math stack-checker effects accessors macros
-fry combinators.short-circuit ;
+USING: kernel sequences math stack-checker effects accessors
+macros fry combinators.short-circuit ;
 IN: combinators.short-circuit.smart
 
 <PRIVATE
 
+ERROR: cannot-determine-arity ;
+
 : arity ( quots -- n )
     first infer
-    dup terminated?>> [ "Cannot determine arity" throw ] when
-    effect-height neg 1+ ;
+    dup terminated?>> [ cannot-determine-arity ] when
+    effect-height neg 1 + ;
 
 PRIVATE>
 
index d8ee89ef2d5d7ecea076936d5973261a09760f85..59b65d91cd2128f62497af370d46b4e31df4f894 100644 (file)
@@ -28,7 +28,7 @@ HELP: output>array
     { $example
         <" USING: combinators combinators.smart math prettyprint ;
 9 [
-    { [ 1- ] [ 1+ ] [ sq ] } cleave
+    { [ 1 - ] [ 1 + ] [ sq ] } cleave
 ] output>array .">
     "{ 8 10 81 }"
     }
@@ -71,7 +71,7 @@ HELP: sum-outputs
 { $examples
     { $example
         "USING: combinators.smart kernel math prettyprint ;"
-        "10 [ [ 1- ] [ 1+ ] bi ] sum-outputs ."
+        "10 [ [ 1 - ] [ 1 + ] bi ] sum-outputs ."
         "20"
     }
 } ;
index a18ef1f3b8804f69cefa6a3525e5904833e5474e..399b4dc36fe35feaf226288c2944ea555094265c 100644 (file)
@@ -4,7 +4,7 @@ USING: tools.test combinators.smart math kernel accessors ;
 IN: combinators.smart.tests
 
 : test-bi ( -- 9 11 )
-    10 [ 1- ] [ 1+ ] bi ;
+    10 [ 1 - ] [ 1 + ] bi ;
 
 [ [ test-bi ] output>array ] must-infer
 [ { 9 11 } ] [ [ test-bi ] output>array ] unit-test
@@ -46,4 +46,4 @@ IN: combinators.smart.tests
 
 [ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test
 
-[ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test
\ No newline at end of file
+[ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test
diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor b/basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor
deleted file mode 100644 (file)
index 79165f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-IN: compiler.cfg.alias-analysis.tests
index f6834c131d48f94de7759a8c037ae0cea7c2f022..526df79cb3018abd7eadfe5e6063d503eae4a48a 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math namespaces assocs hashtables sequences arrays
-accessors vectors combinators sets classes compiler.cfg
+accessors vectors combinators sets classes cpu.architecture compiler.cfg
 compiler.cfg.registers compiler.cfg.instructions
 compiler.cfg.copy-prop compiler.cfg.rpo compiler.cfg.liveness ;
 IN: compiler.cfg.alias-analysis
@@ -144,7 +144,7 @@ ERROR: vreg-has-no-slots vreg ;
 SYMBOL: ac-counter
 
 : next-ac ( -- n )
-    ac-counter [ dup 1+ ] change ;
+    ac-counter [ dup 1 + ] change ;
 
 ! Alias class for objects which are loaded from the data stack
 ! or other object slots. We pessimistically assume that they
@@ -226,7 +226,7 @@ M: ##read analyze-aliases*
     call-next-method
     dup [ dst>> ] [ insn-slot# ] [ insn-object ] tri
     2dup live-slot dup [
-        2nip \ ##copy new-insn analyze-aliases* nip
+        2nip any-rep \ ##copy new-insn analyze-aliases* nip
     ] [
         drop remember-slot
     ] if ;
@@ -285,4 +285,4 @@ M: insn eliminate-dead-stores* ;
     eliminate-dead-stores ;
 
 : alias-analysis ( cfg -- cfg' )
-    [ alias-analysis-step ] local-optimization ;
\ No newline at end of file
+    [ alias-analysis-step ] local-optimization ;
index 08c43f203ccd451876f411d07045d336bc5f51db..60528a61bbdf1f32ba621cd670988bed14c798f7 100644 (file)
@@ -2,12 +2,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators.short-circuit kernel sequences math
 compiler.utilities compiler.cfg compiler.cfg.instructions compiler.cfg.rpo
-compiler.cfg.utilities ;
+compiler.cfg.predecessors compiler.cfg.utilities ;
 IN: compiler.cfg.block-joining
 
 ! Joining blocks that are not calls and are connected by a single CFG edge.
-! Predecessors must be recomputed after this. Also this pass does not
-! update ##phi nodes and should therefore only run before stack analysis.
+! This pass does not update ##phi nodes and should therefore only run
+! before stack analysis.
 : join-block? ( bb -- ? )
     {
         [ kill-block? not ]
@@ -27,8 +27,11 @@ IN: compiler.cfg.block-joining
     [ join-instructions ] [ update-successors ] 2bi ;
 
 : join-blocks ( cfg -- cfg' )
+    needs-predecessors
+
     dup post-order [
         dup join-block?
         [ dup predecessor join-block ] [ drop ] if
     ] each
-    cfg-changed ;
+
+    cfg-changed predecessors-changed ;
index d73bd866a0bb1013880372de12ab54ee14c2e5d1..f3790fd33810d7edc766d865723cbac9546cfc51 100644 (file)
@@ -9,11 +9,11 @@ IN: compiler.cfg.branch-splitting.tests
 
 : check-predecessors ( cfg -- )
     [ get-predecessors ]
-    [ compute-predecessors drop ]
+    [ needs-predecessors drop ]
     [ get-predecessors ] tri assert= ;
 
 : check-branch-splitting ( cfg -- )
-    compute-predecessors
+    needs-predecessors
     split-branches
     check-predecessors ;
 
index e5583a14ab0f2f4ec39ecf0b3762aca94cb3f7e4..1daabf6f0efaee6fdb49b0124121ab1f3a2901da 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators.short-circuit kernel math math.order
 sequences assocs namespaces vectors fry arrays splitting
-compiler.cfg.def-use compiler.cfg compiler.cfg.rpo
+compiler.cfg.def-use compiler.cfg compiler.cfg.rpo compiler.cfg.predecessors
 compiler.cfg.renaming compiler.cfg.instructions compiler.cfg.utilities ;
 IN: compiler.cfg.branch-splitting
 
@@ -81,7 +81,10 @@ UNION: irrelevant ##peek ##replace ##inc-d ##inc-r ;
     ] if ;
 
 : split-branches ( cfg -- cfg' )
+    needs-predecessors
+    
     dup [
         dup split-branch? [ split-branch ] [ drop ] if
     ] each-basic-block
+
     cfg-changed ;
index 76b10dda01611324466292afd6092b1fceb76bc2..0155ea519d48bd07a0244b54fc4f8595e0816305 100644 (file)
@@ -1,15 +1,13 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces accessors math.order assocs kernel sequences
-combinators make classes words cpu.architecture
+combinators make classes words cpu.architecture layouts
 compiler.cfg.instructions compiler.cfg.registers
 compiler.cfg.stack-frame ;
 IN: compiler.cfg.build-stack-frame
 
 SYMBOL: frame-required?
 
-SYMBOL: spill-counts
-
 GENERIC: compute-stack-frame* ( insn -- )
 
 : request-stack-frame ( stack-frame -- )
@@ -30,11 +28,11 @@ M: ##call compute-stack-frame*
 
 M: _gc compute-stack-frame*
     frame-required? on
-    stack-frame new swap gc-root-size>> >>gc-root-size
+    stack-frame new swap tagged-values>> length cells >>gc-root-size
     request-stack-frame ;
 
-M: _spill-counts compute-stack-frame*
-    counts>> stack-frame get (>>spill-counts) ;
+M: _spill-area-size compute-stack-frame*
+    n>> stack-frame get (>>spill-area-size) ;
 
 M: insn compute-stack-frame*
     class frame-required? word-prop [
@@ -45,7 +43,7 @@ M: insn compute-stack-frame*
 
 : compute-stack-frame ( insns -- )
     frame-required? off
-    T{ stack-frame } clone stack-frame set
+    stack-frame new stack-frame set
     [ compute-stack-frame* ] each
     stack-frame get dup stack-frame-size >>total-size drop ;
 
index 2de7c7c3d1ed0bc31aca942a9515c324f92adf35..b2f25fdeb18ec7092ca3712cc33ae764196f0f6b 100644 (file)
@@ -1,14 +1,15 @@
-IN: compiler.cfg.builder.tests
 USING: tools.test kernel sequences words sequences.private fry
 prettyprint alien alien.accessors math.private compiler.tree.builder
 compiler.tree.optimizer compiler.cfg.builder compiler.cfg.debugger
 compiler.cfg.optimizer compiler.cfg.predecessors compiler.cfg.checker
-arrays locals byte-arrays kernel.private math slots.private vectors sbufs
-strings math.partial-dispatch strings.private ;
+compiler.cfg arrays locals byte-arrays kernel.private math
+slots.private vectors sbufs strings math.partial-dispatch
+strings.private ;
+IN: compiler.cfg.builder.tests
 
 ! Just ensure that various CFGs build correctly.
 : unit-test-cfg ( quot -- )
-    '[ _ test-cfg [ optimize-cfg check-cfg ] each ] [ ] swap unit-test ;
+    '[ _ test-cfg [ [ optimize-cfg check-cfg ] with-cfg ] each ] [ ] swap unit-test ;
 
 : blahblah ( nodes -- ? )
     { fixnum } declare [
index 0c40b93ba6ed27957e01c0b31a91e101972b4418..7b74d1c25807b74a6b2b082c61bfafa29b1614c2 100755 (executable)
@@ -19,6 +19,7 @@ compiler.cfg.instructions
 compiler.cfg.predecessors
 compiler.cfg.builder.blocks
 compiler.cfg.stacks
+compiler.cfg.stacks.local
 compiler.alien ;
 IN: compiler.cfg.builder
 
@@ -144,7 +145,7 @@ M: #dispatch emit-node
     ! Inputs to the final instruction need to be copied because of
     ! loc>vreg sync. ^^offset>slot always returns a fresh vreg,
     ! though.
-    ds-pop ^^offset>slot i ##dispatch emit-if ;
+    ds-pop ^^offset>slot next-vreg ##dispatch emit-if ;
 
 ! #call
 M: #call emit-node
@@ -159,14 +160,32 @@ M: #push emit-node
     literal>> ^^load-literal ds-push ;
 
 ! #shuffle
+
+! Even though low level IR has its own dead code elimination pass,
+! we try not to introduce useless ##peeks here, since this reduces
+! the accuracy of global stack analysis.
+
+: make-input-map ( #shuffle -- assoc )
+    ! Assoc maps high-level IR values to stack locations.
+    [
+        [ in-d>> <reversed> [ <ds-loc> swap set ] each-index ]
+        [ in-r>> <reversed> [ <rs-loc> swap set ] each-index ] bi
+    ] H{ } make-assoc ;
+
+: make-output-seq ( values mapping input-map -- vregs )
+    '[ _ at _ at peek-loc ] map ;
+
+: load-shuffle ( #shuffle mapping input-map -- ds-vregs rs-vregs )
+    [ [ out-d>> ] 2dip make-output-seq ]
+    [ [ out-r>> ] 2dip make-output-seq ] 3bi ;
+
+: store-shuffle ( #shuffle ds-vregs rs-vregs -- )
+    [ [ in-d>> length neg inc-d ] dip ds-store ]
+    [ [ in-r>> length neg inc-r ] dip rs-store ]
+    bi-curry* bi ;
+
 M: #shuffle emit-node
-    dup
-    H{ } clone
-    [ [ in-d>> [ length ds-load ] keep ] dip '[ _ set-at ] 2each ]
-    [ [ in-r>> [ length rs-load ] keep ] dip '[ _ set-at ] 2each ]
-    [ nip ] 2tri
-    [ [ [ out-d>> ] [ mapping>> ] bi ] dip '[ _ at _ at ] map ds-store ]
-    [ [ [ out-r>> ] [ mapping>> ] bi ] dip '[ _ at _ at ] map rs-store ] 2bi ;
+    dup dup [ mapping>> ] [ make-input-map ] bi load-shuffle store-shuffle ;
 
 ! #return
 : emit-return ( -- )
@@ -227,3 +246,5 @@ M: #copy emit-node drop ;
 M: #enter-recursive emit-node drop ;
 
 M: #phi emit-node drop ;
+
+M: #declare emit-node drop ;
\ No newline at end of file
diff --git a/basis/compiler/cfg/cfg-tests.factor b/basis/compiler/cfg/cfg-tests.factor
deleted file mode 100644 (file)
index e69de29..0000000
index f856efac78fd6df6c16e04feb1f1a53250a8cf80..369e6ebc32631f8177b338225cc12f8e79da93cb 100644 (file)
@@ -19,11 +19,28 @@ M: basic-block hashcode* nip id>> ;
         V{ } clone >>predecessors
         \ basic-block counter >>id ;
 
-TUPLE: cfg { entry basic-block } word label spill-counts post-order ;
+TUPLE: cfg { entry basic-block } word label
+spill-area-size reps
+post-order linear-order
+predecessors-valid? dominance-valid? loops-valid? ;
 
-: <cfg> ( entry word label -- cfg ) f f cfg boa ;
+: <cfg> ( entry word label -- cfg )
+    cfg new
+        swap >>label
+        swap >>word
+        swap >>entry ;
+
+: cfg-changed ( cfg -- cfg )
+    f >>post-order
+    f >>linear-order
+    f >>dominance-valid?
+    f >>loops-valid? ; inline
+
+: predecessors-changed ( cfg -- cfg )
+    f >>predecessors-valid? ;
 
-: cfg-changed ( cfg -- cfg ) f >>post-order ; inline
+: with-cfg ( cfg quot: ( cfg -- ) -- )
+    [ dup cfg ] dip with-variable ; inline
 
 TUPLE: mr { instructions array } word label ;
 
index 812a5a1a7fb236e796011ee93be63d46a47c317c..6919ba8b9b06eb7d1b9fa4d81fa24f7690bfe42d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel namespaces assocs accessors sequences grouping
 combinators compiler.cfg.rpo compiler.cfg.renaming
-compiler.cfg.instructions ;
+compiler.cfg.instructions compiler.cfg.predecessors ;
 IN: compiler.cfg.copy-prop
 
 ! The first three definitions are also used in compiler.cfg.alias-analysis.
@@ -70,6 +70,8 @@ M: insn update-insn rename-insn-uses t ;
 PRIVATE>
 
 : copy-propagation ( cfg -- cfg' )
+    needs-predecessors
+
     [ collect-copies ]
     [ rename-copies ]
     [ ]
diff --git a/basis/compiler/cfg/critical-edges/critical-edges-tests.factor b/basis/compiler/cfg/critical-edges/critical-edges-tests.factor
deleted file mode 100644 (file)
index 88383e2..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-USING: accessors assocs compiler.cfg
-compiler.cfg.critical-edges compiler.cfg.debugger
-compiler.cfg.instructions compiler.cfg.predecessors
-compiler.cfg.registers cpu.architecture kernel namespaces
-sequences tools.test compiler.cfg.utilities ;
-IN: compiler.cfg.critical-edges.tests
-
-! Make sure we update phi nodes when splitting critical edges
-
-: test-critical-edges ( -- )
-    cfg new 0 get >>entry
-    compute-predecessors
-    split-critical-edges ;
-
-V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##branch }
-} 0 test-bb
-
-V{
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##branch }
-} 1 test-bb
-
-V{
-    T{ ##phi f V int-regs 2 H{ { 0 V int-regs 0 } { 1 V int-regs 1 } } }
-    T{ ##return }
-} 2 test-bb
-
-0 { 1 2 } edges
-1 2 edge
-
-[ ] [ test-critical-edges ] unit-test
-
-[ t ] [ 0 get successors>> second successors>> first 2 get eq? ] unit-test
-
-[ V int-regs 0 ] [ 2 get instructions>> first inputs>> 0 get successors>> second swap at ] unit-test
\ No newline at end of file
diff --git a/basis/compiler/cfg/critical-edges/critical-edges.factor b/basis/compiler/cfg/critical-edges/critical-edges.factor
deleted file mode 100644 (file)
index 2a42df4..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math accessors sequences locals assocs fry
-compiler.cfg compiler.cfg.rpo compiler.cfg.utilities ;
-IN: compiler.cfg.critical-edges
-
-: critical-edge? ( from to -- ? )
-    [ successors>> length 1 > ] [ predecessors>> length 1 > ] bi* and ;
-
-: new-key ( new-key old-key assoc -- )
-    [ delete-at* ] keep '[ swap _ set-at ] [ 2drop ] if ;
-
-:: update-phis ( from to bb -- )
-    ! Any phi nodes in 'to' which reference 'from'
-    ! should now reference 'bb'.
-    to [ [ bb from ] dip inputs>> new-key ] each-phi ;
-
-: split-critical-edge ( from to -- )
-    f <simple-block> [ insert-basic-block ] [ update-phis ] 3bi ; 
-
-: split-critical-edges ( cfg -- )
-    dup [
-        dup successors>> [
-            2dup critical-edge?
-            [ split-critical-edge ] [ 2drop ] if
-        ] with each
-    ] each-basic-block
-    cfg-changed
-    drop ;
\ No newline at end of file
index 975adfa6cb19ab2ec6e130bbb90822755d812fb6..275a4585b001c3c050cf64e08c7c850b01312dea 100644 (file)
@@ -2,10 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs deques dlists kernel locals sequences lexer
 namespaces functors compiler.cfg.rpo compiler.cfg.utilities
-compiler.cfg ;
+compiler.cfg.predecessors compiler.cfg ;
 IN: compiler.cfg.dataflow-analysis
 
-GENERIC: join-sets ( sets dfa -- set )
+GENERIC: join-sets ( sets bb dfa -- set )
 GENERIC: transfer-set ( in-set bb dfa -- out-set )
 GENERIC: block-order ( cfg dfa -- bbs )
 GENERIC: successors ( bb dfa -- seq )
@@ -23,7 +23,7 @@ GENERIC# compute-in-set 2 ( bb out-sets dfa -- set )
 M: kill-block compute-in-set 3drop f ;
 
 M:: basic-block compute-in-set ( bb out-sets dfa -- set )
-    bb dfa predecessors [ out-sets at ] map dfa join-sets ;
+    bb dfa predecessors [ out-sets at ] map bb dfa join-sets ;
 
 :: update-in-set ( bb in-sets out-sets dfa -- ? )
     bb out-sets dfa compute-in-set
@@ -48,6 +48,7 @@ M:: basic-block compute-out-set ( bb in-sets dfa -- set )
     ] when ; inline
 
 :: run-dataflow-analysis ( cfg dfa -- in-sets out-sets )
+    cfg needs-predecessors drop
     H{ } clone :> in-sets
     H{ } clone :> out-sets
     cfg dfa <dfa-worklist> :> work-list
@@ -55,7 +56,7 @@ M:: basic-block compute-out-set ( bb in-sets dfa -- set )
     in-sets
     out-sets ; inline
 
-M: dataflow-analysis join-sets drop assoc-refine ;
+M: dataflow-analysis join-sets 2drop assoc-refine ;
 
 FUNCTOR: define-analysis ( name -- )
 
index de2ed787b757a73e3bb9b1bc15f76315ba8188f5..6a7ef08257a0ed0a34bd60877f7138e3ba0ed7f3 100644 (file)
@@ -11,62 +11,62 @@ IN: compiler.cfg.dce.tests
     entry>> instructions>> ; 
 
 [ V{
-    T{ ##load-immediate { dst V int-regs 1 } { val 8 } }
-    T{ ##load-immediate { dst V int-regs 2 } { val 16 } }
-    T{ ##add { dst V int-regs 3 } { src1 V int-regs 1 } { src2 V int-regs 2 } }
-    T{ ##replace { src V int-regs 3 } { loc D 0 } }
+    T{ ##load-immediate { dst 1 } { val 8 } }
+    T{ ##load-immediate { dst 2 } { val 16 } }
+    T{ ##add { dst 3 } { src1 1 } { src2 2 } }
+    T{ ##replace { src 3 } { loc D 0 } }
 } ] [ V{
-    T{ ##load-immediate { dst V int-regs 1 } { val 8 } }
-    T{ ##load-immediate { dst V int-regs 2 } { val 16 } }
-    T{ ##add { dst V int-regs 3 } { src1 V int-regs 1 } { src2 V int-regs 2 } }
-    T{ ##replace { src V int-regs 3 } { loc D 0 } }
+    T{ ##load-immediate { dst 1 } { val 8 } }
+    T{ ##load-immediate { dst 2 } { val 16 } }
+    T{ ##add { dst 3 } { src1 1 } { src2 2 } }
+    T{ ##replace { src 3 } { loc D 0 } }
 } test-dce ] unit-test
 
 [ V{ } ] [ V{
-    T{ ##load-immediate { dst V int-regs 1 } { val 8 } }
-    T{ ##load-immediate { dst V int-regs 2 } { val 16 } }
-    T{ ##add { dst V int-regs 3 } { src1 V int-regs 1 } { src2 V int-regs 2 } }
+    T{ ##load-immediate { dst 1 } { val 8 } }
+    T{ ##load-immediate { dst 2 } { val 16 } }
+    T{ ##add { dst 3 } { src1 1 } { src2 2 } }
 } test-dce ] unit-test
 
 [ V{ } ] [ V{
-    T{ ##load-immediate { dst V int-regs 3 } { val 8 } }
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
+    T{ ##load-immediate { dst 3 } { val 8 } }
+    T{ ##allot { dst 1 } { temp 2 } }
 } test-dce ] unit-test
 
 [ V{ } ] [ V{
-    T{ ##load-immediate { dst V int-regs 3 } { val 8 } }
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##set-slot-imm { obj V int-regs 1 } { src V int-regs 3 } }
+    T{ ##load-immediate { dst 3 } { val 8 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##set-slot-imm { obj 1 } { src 3 } }
 } test-dce ] unit-test
 
 [ V{
-    T{ ##load-immediate { dst V int-regs 3 } { val 8 } }
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##set-slot-imm { obj V int-regs 1 } { src V int-regs 3 } }
-    T{ ##replace { src V int-regs 1 } { loc D 0 } }
+    T{ ##load-immediate { dst 3 } { val 8 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##set-slot-imm { obj 1 } { src 3 } }
+    T{ ##replace { src 1 } { loc D 0 } }
 } ] [ V{
-    T{ ##load-immediate { dst V int-regs 3 } { val 8 } }
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##set-slot-imm { obj V int-regs 1 } { src V int-regs 3 } }
-    T{ ##replace { src V int-regs 1 } { loc D 0 } }
+    T{ ##load-immediate { dst 3 } { val 8 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##set-slot-imm { obj 1 } { src 3 } }
+    T{ ##replace { src 1 } { loc D 0 } }
 } test-dce ] unit-test
 
 [ V{
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##replace { src V int-regs 1 } { loc D 0 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##replace { src 1 } { loc D 0 } }
 } ] [ V{
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##replace { src V int-regs 1 } { loc D 0 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##replace { src 1 } { loc D 0 } }
 } test-dce ] unit-test
 
 [ V{
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##replace { src V int-regs 1 } { loc D 0 } }
-    T{ ##load-immediate { dst V int-regs 3 } { val 8 } }
-    T{ ##set-slot-imm { obj V int-regs 1 } { src V int-regs 3 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##replace { src 1 } { loc D 0 } }
+    T{ ##load-immediate { dst 3 } { val 8 } }
+    T{ ##set-slot-imm { obj 1 } { src 3 } }
 } ] [ V{
-    T{ ##allot { dst V int-regs 1 } { temp V int-regs 2 } }
-    T{ ##replace { src V int-regs 1 } { loc D 0 } }
-    T{ ##load-immediate { dst V int-regs 3 } { val 8 } }
-    T{ ##set-slot-imm { obj V int-regs 1 } { src V int-regs 3 } }
+    T{ ##allot { dst 1 } { temp 2 } }
+    T{ ##replace { src 1 } { loc D 0 } }
+    T{ ##load-immediate { dst 3 } { val 8 } }
+    T{ ##set-slot-imm { obj 1 } { src 3 } }
 } test-dce ] unit-test
index fdc6601de41c1d0009334ed42f87a0e234f31ed5..dd42475a138a0667390cba6e60727d2fa253801b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs sets kernel namespaces sequences
 compiler.cfg.instructions compiler.cfg.def-use
-compiler.cfg.rpo ;
+compiler.cfg.rpo compiler.cfg.predecessors ;
 IN: compiler.cfg.dce
 
 ! Maps vregs to sequences of vregs
@@ -95,6 +95,8 @@ M: ##write-barrier live-insn? src>> live-vreg? ;
 M: insn live-insn? drop t ;
 
 : eliminate-dead-code ( cfg -- cfg' )
+    needs-predecessors
+
     init-dead-code
     dup
     [ [ instructions>> [ build-liveness-graph ] each ] each-basic-block ]
index 26bf0eca564fe73d73d078be64217b9ccc7d23f5..33f87ff1d417fde17fc6f0e810f5980d5e24f35e 100644 (file)
@@ -4,11 +4,12 @@ USING: kernel words sequences quotations namespaces io vectors
 classes.tuple accessors prettyprint prettyprint.config assocs
 prettyprint.backend prettyprint.custom prettyprint.sections
 parser compiler.tree.builder compiler.tree.optimizer
-compiler.cfg.builder compiler.cfg.linearization
+cpu.architecture compiler.cfg.builder compiler.cfg.linearization
 compiler.cfg.registers compiler.cfg.stack-frame
 compiler.cfg.linear-scan compiler.cfg.two-operand
 compiler.cfg.optimizer compiler.cfg.instructions
-compiler.cfg.utilities compiler.cfg.mr compiler.cfg ;
+compiler.cfg.utilities compiler.cfg.def-use
+compiler.cfg.rpo compiler.cfg.mr compiler.cfg ;
 IN: compiler.cfg.debugger
 
 GENERIC: test-cfg ( quot -- cfgs )
@@ -23,8 +24,10 @@ M: word test-cfg
 
 : test-mr ( quot -- mrs )
     test-cfg [
-        optimize-cfg
-        build-mr
+        [
+            optimize-cfg
+            build-mr
+        ] with-cfg
     ] map ;
 
 : insn. ( insn -- )
@@ -41,11 +44,6 @@ M: word test-cfg
     ] each ;
 
 ! Prettyprinting
-M: vreg pprint*
-    <block
-    \ V pprint-word [ reg-class>> pprint* ] [ n>> pprint* ] bi
-    block> ;
-
 : pprint-loc ( loc word -- ) <block pprint-word n>> pprint* block> ;
 
 M: ds-loc pprint* \ D pprint-loc ;
@@ -71,4 +69,12 @@ M: rs-loc pprint* \ R pprint-loc ;
     0 1 edge
     1 { 2 3 } edges
     2 4 edge
-    3 4 edge ;
\ No newline at end of file
+    3 4 edge ;
+
+: fake-representations ( cfg -- )
+    post-order [
+        instructions>>
+        [ [ temp-vregs ] [ defs-vreg ] bi [ suffix ] when* ]
+        map concat
+    ] map concat
+    [ int-rep ] H{ } map>assoc representations set ;
\ No newline at end of file
index 1153d9ea81e3608ae4c506c88443062f7a3a0b3d..a4f0819397bfe701d6e39a23dbf02bf0f3ba4196 100644 (file)
@@ -8,30 +8,29 @@ compiler.cfg
 compiler.cfg.debugger
 compiler.cfg.instructions
 compiler.cfg.registers ;
+IN: compiler.cfg.def-use.tests
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 1 D 0 }
-    T{ ##peek f V int-regs 2 D 0 }
+    T{ ##peek f 0 D 0 }
+    T{ ##peek f 1 D 0 }
+    T{ ##peek f 2 D 0 }
 } 1 test-bb
 V{
-    T{ ##replace f V int-regs 2 D 0 }
+    T{ ##replace f 2 D 0 }
 } 2 test-bb
-1 get 2 get 1vector >>successors drop
+1 2 edge
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
 } 3 test-bb
-2 get 3 get 1vector >>successors drop
+2 3 edge
 V{ } 4 test-bb
 V{ } 5 test-bb
-3 get 4 get 5 get V{ } 2sequence >>successors drop
-V int-regs 2
-    2 get V int-regs 0 2array
-    3 get V int-regs 1 2array
-2array \ ##phi new-insn 1vector
-6 test-bb
-4 get 6 get 1vector >>successors drop
-5 get 6 get 1vector >>successors drop
+3 { 4 5 } edges
+V{
+    T{ ##phi f 2 H{ { 2 0 } { 3 1 } } }
+} 6 test-bb
+4 6 edge
+5 6 edge
 
 cfg new 1 get >>entry 0 set
-[ ] [ 0 get compute-def-use ] unit-test
+[ ] [ 0 get [ compute-defs ] [ compute-uses ] bi ] unit-test
index 8e8fbf3a2d1f8e6a7e39f8706440e1bf7a163e4f..c56bd807791b765a1913d4f069dd57b797bda5b8 100644 (file)
@@ -92,6 +92,3 @@ SYMBOLS: defs insns uses ;
         ] each
     ] each-basic-block
     use [ keys ] assoc-map uses set ;
-
-: compute-def-use ( cfg -- )
-    [ compute-defs ] [ compute-uses ] [ compute-insns ] tri ;
index a3b9fc0223d2411ae314290d2726d2a2b89f0c69..b24e51abfb923942597b7bebd95c9c96c81575e6 100644 (file)
@@ -1,12 +1,11 @@
-IN: compiler.cfg.dominance.tests
 USING: tools.test sequences vectors namespaces kernel accessors assocs sets
 math.ranges arrays compiler.cfg compiler.cfg.dominance compiler.cfg.debugger
 compiler.cfg.predecessors ;
+IN: compiler.cfg.dominance.tests
 
 : test-dominance ( -- )
     cfg new 0 get >>entry
-    compute-predecessors
-    compute-dominance ;
+    needs-dominance drop ;
 
 ! Example with no back edges
 V{ } 0 test-bb
index 325bed74ff99142532b310dbfa998e78aca1e886..d21e81526e426d2299f6475b9cfe36f7bc503c8d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs combinators sets math fry kernel math.order
 dlists deques vectors namespaces sequences sorting locals
-compiler.cfg.rpo ;
+compiler.cfg.rpo compiler.cfg.predecessors ;
 IN: compiler.cfg.dominance
 
 ! Reference:
@@ -83,10 +83,14 @@ PRIVATE>
     H{ } clone maxpreorder set
     [ 0 ] dip entry>> (compute-dfs) drop ;
 
+: compute-dominance ( cfg -- cfg' )
+    [ compute-dom-parents compute-dom-children ] [ compute-dfs ] [ ] tri ;
+
 PRIVATE>
 
-: compute-dominance ( cfg -- )
-    [ compute-dom-parents compute-dom-children ] [ compute-dfs ] bi ;
+: needs-dominance ( cfg -- cfg' )
+    needs-predecessors
+    dup dominance-valid?>> [ compute-dominance t >>dominance-valid? ] unless ;
 
 : dominates? ( bb1 bb2 -- ? )
     swap [ pre-of ] [ [ pre-of ] [ maxpre-of ] bi ] bi* between? ;
index 2a31a20b72d0d14548637db6484c69b0b56132e0..605c572cb3b548b9e3a60b264b34399561e42b53 100644 (file)
@@ -1,9 +1,12 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors sequences combinators combinators.short-circuit
-classes vectors compiler.cfg compiler.cfg.instructions compiler.cfg.rpo ;
+USING: kernel accessors sequences namespaces combinators
+combinators.short-circuit classes vectors compiler.cfg
+compiler.cfg.instructions compiler.cfg.rpo ;
 IN: compiler.cfg.empty-blocks
+
+<PRIVATE
+
 : update-predecessor ( bb -- )
     ! We have to replace occurrences of bb with bb's successor
     ! in bb's predecessor's list of successors.
@@ -21,9 +24,12 @@ IN: compiler.cfg.empty-blocks
             2dup eq? [ drop predecessors>> first ] [ nip ] if
         ] with map
     ] change-predecessors drop ;
+
+SYMBOL: changed?
+
 : delete-basic-block ( bb -- )
-    [ update-predecessor ] [ update-successor ] bi ;
+    [ update-predecessor ] [ update-successor ] bi
+    changed? on ;
  
 : delete-basic-block? ( bb -- ? )
     {
@@ -32,7 +38,10 @@ IN: compiler.cfg.empty-blocks
         [ successors>> length 1 = ]
         [ instructions>> first ##branch? ]
     } 1&& ;
+
+PRIVATE>
+
 : delete-empty-blocks ( cfg -- cfg' )
+    changed? off
     dup [ dup delete-basic-block? [ delete-basic-block ] [ drop ] if ] each-basic-block
-    cfg-changed ;
\ No newline at end of file
+    changed? get [ cfg-changed ] when ;
\ No newline at end of file
index b324214602cb8d06808ba34ad566892cf8e2dde7..5580de9a478b1af64839ea6ac40aca7431b31845 100644 (file)
@@ -1,26 +1,26 @@
-IN: compiler.cfg.gc-checks.tests
 USING: compiler.cfg.gc-checks compiler.cfg.debugger
 compiler.cfg.registers compiler.cfg.instructions compiler.cfg
 compiler.cfg.predecessors cpu.architecture tools.test kernel vectors
 namespaces accessors sequences ;
+IN: compiler.cfg.gc-checks.tests
 
 : test-gc-checks ( -- )
+    H{ } clone representations set
     cfg new 0 get >>entry
-    compute-predecessors
     insert-gc-checks
     drop ;
 
 V{
     T{ ##inc-d f 3 }
-    T{ ##replace f V int-regs 0 D 1 }
+    T{ ##replace f 0 D 1 }
 } 0 test-bb
 
 V{
-    T{ ##box-float f V int-regs 0 V int-regs 1 }
+    T{ ##box-float f 0 1 }
 } 1 test-bb
 
 0 1 edge
 
 [ ] [ test-gc-checks ] unit-test
 
-[ V{ D 0 D 2 } ] [ 1 get instructions>> first uninitialized-locs>> ] unit-test
\ No newline at end of file
+[ V{ D 0 D 2 } ] [ 1 get instructions>> first uninitialized-locs>> ] unit-test
index c34f2c42a38ac64b854cac7a7ae397638ec65b3d..21a60768ea27edb96a7412d2eba4ba09b2d548f1 100644 (file)
@@ -1,13 +1,16 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel sequences assocs fry
+cpu.architecture
 compiler.cfg.rpo
-compiler.cfg.hats
 compiler.cfg.registers
 compiler.cfg.instructions
 compiler.cfg.stacks.uninitialized ;
 IN: compiler.cfg.gc-checks
 
+! Garbage collection check insertion. This pass runs after representation
+! selection, so it must keep track of representations.
+
 : insert-gc-check? ( bb -- ? )
     instructions>> [ ##allocation? ] any? ;
 
@@ -16,7 +19,9 @@ IN: compiler.cfg.gc-checks
 
 : insert-gc-check ( bb -- )
     dup '[
-        i i f _ uninitialized-locs \ ##gc new-insn
+        int-rep next-vreg-rep
+        int-rep next-vreg-rep
+        f f _ uninitialized-locs \ ##gc new-insn
         prefix
     ] change-instructions drop ;
 
index 4c1999943f44b67fcfad8d7669d752de07d2ea28..04fddbb2036ae83711bb8953975e9c5b11a76f87 100644 (file)
@@ -1,83 +1,74 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays byte-arrays kernel layouts math namespaces
+USING: accessors arrays byte-arrays kernel layouts math namespaces
 sequences classes.tuple cpu.architecture compiler.cfg.registers
 compiler.cfg.instructions ;
 IN: compiler.cfg.hats
 
-: i ( -- vreg ) int-regs next-vreg ; inline
-: ^^i ( -- vreg vreg ) i dup ; inline
-: ^^i1 ( obj -- vreg vreg obj ) [ ^^i ] dip ; inline
-: ^^i2 ( obj obj -- vreg vreg obj obj ) [ ^^i ] 2dip ; inline
-: ^^i3 ( obj obj obj -- vreg vreg obj obj obj ) [ ^^i ] 3dip ; inline
+: ^^r ( -- vreg vreg ) next-vreg dup ; inline
+: ^^r1 ( obj -- vreg vreg obj ) [ ^^r ] dip ; inline
+: ^^r2 ( obj obj -- vreg vreg obj obj ) [ ^^r ] 2dip ; inline
+: ^^r3 ( obj obj obj -- vreg vreg obj obj obj ) [ ^^r ] 3dip ; inline
 
-: d ( -- vreg ) double-float-regs next-vreg ; inline
-: ^^d  ( -- vreg vreg ) d dup ; inline
-: ^^d1 ( obj -- vreg vreg obj ) [ ^^d ] dip ; inline
-: ^^d2 ( obj obj -- vreg vreg obj obj ) [ ^^d ] 2dip ; inline
-: ^^d3 ( obj obj obj -- vreg vreg obj obj obj ) [ ^^d ] 3dip ; inline
-
-: ^^load-literal ( obj -- dst ) ^^i1 ##load-literal ; inline
-: ^^copy ( src -- dst ) ^^i1 ##copy ; inline
-: ^^slot ( obj slot tag -- dst ) ^^i3 i ##slot ; inline
-: ^^slot-imm ( obj slot tag -- dst ) ^^i3 ##slot-imm ; inline
-: ^^set-slot ( src obj slot tag -- ) i ##set-slot ; inline
-: ^^string-nth ( obj index -- dst ) ^^i2 i ##string-nth ; inline
-: ^^add ( src1 src2 -- dst ) ^^i2 ##add ; inline
-: ^^add-imm ( src1 src2 -- dst ) ^^i2 ##add-imm ; inline
-: ^^sub ( src1 src2 -- dst ) ^^i2 ##sub ; inline
-: ^^sub-imm ( src1 src2 -- dst ) ^^i2 ##sub-imm ; inline
+: ^^load-literal ( obj -- dst ) ^^r1 ##load-literal ; inline
+: ^^copy ( src -- dst ) ^^r1 any-rep ##copy ; inline
+: ^^slot ( obj slot tag -- dst ) ^^r3 next-vreg ##slot ; inline
+: ^^slot-imm ( obj slot tag -- dst ) ^^r3 ##slot-imm ; inline
+: ^^set-slot ( src obj slot tag -- ) next-vreg ##set-slot ; inline
+: ^^string-nth ( obj index -- dst ) ^^r2 next-vreg ##string-nth ; inline
+: ^^add ( src1 src2 -- dst ) ^^r2 ##add ; inline
+: ^^add-imm ( src1 src2 -- dst ) ^^r2 ##add-imm ; inline
+: ^^sub ( src1 src2 -- dst ) ^^r2 ##sub ; inline
+: ^^sub-imm ( src1 src2 -- dst ) ^^r2 ##sub-imm ; inline
 : ^^neg ( src -- dst ) [ 0 ^^load-literal ] dip ^^sub ; inline
-: ^^mul ( src1 src2 -- dst ) ^^i2 ##mul ; inline
-: ^^mul-imm ( src1 src2 -- dst ) ^^i2 ##mul-imm ; inline
-: ^^and ( input mask -- output ) ^^i2 ##and ; inline
-: ^^and-imm ( input mask -- output ) ^^i2 ##and-imm ; inline
-: ^^or ( src1 src2 -- dst ) ^^i2 ##or ; inline
-: ^^or-imm ( src1 src2 -- dst ) ^^i2 ##or-imm ; inline
-: ^^xor ( src1 src2 -- dst ) ^^i2 ##xor ; inline
-: ^^xor-imm ( src1 src2 -- dst ) ^^i2 ##xor-imm ; inline
-: ^^shl ( src1 src2 -- dst ) ^^i2 ##shl ; inline
-: ^^shl-imm ( src1 src2 -- dst ) ^^i2 ##shl-imm ; inline
-: ^^shr ( src1 src2 -- dst ) ^^i2 ##shr ; inline
-: ^^shr-imm ( src1 src2 -- dst ) ^^i2 ##shr-imm ; inline
-: ^^sar ( src1 src2 -- dst ) ^^i2 ##sar ; inline
-: ^^sar-imm ( src1 src2 -- dst ) ^^i2 ##sar-imm ; inline
-: ^^not ( src -- dst ) ^^i1 ##not ; inline
-: ^^log2 ( src -- dst ) ^^i1 ##log2 ; inline
-: ^^bignum>integer ( src -- dst ) ^^i1 i ##bignum>integer ; inline
-: ^^integer>bignum ( src -- dst ) ^^i1 i ##integer>bignum ; inline
-: ^^add-float ( src1 src2 -- dst ) ^^d2 ##add-float ; inline
-: ^^sub-float ( src1 src2 -- dst ) ^^d2 ##sub-float ; inline
-: ^^mul-float ( src1 src2 -- dst ) ^^d2 ##mul-float ; inline
-: ^^div-float ( src1 src2 -- dst ) ^^d2 ##div-float ; inline
-: ^^float>integer ( src -- dst ) ^^i1 ##float>integer ; inline
-: ^^integer>float ( src -- dst ) ^^d1 ##integer>float ; inline
-: ^^allot ( size class -- dst ) ^^i2 i ##allot ; inline
+: ^^mul ( src1 src2 -- dst ) ^^r2 ##mul ; inline
+: ^^mul-imm ( src1 src2 -- dst ) ^^r2 ##mul-imm ; inline
+: ^^and ( input mask -- output ) ^^r2 ##and ; inline
+: ^^and-imm ( input mask -- output ) ^^r2 ##and-imm ; inline
+: ^^or ( src1 src2 -- dst ) ^^r2 ##or ; inline
+: ^^or-imm ( src1 src2 -- dst ) ^^r2 ##or-imm ; inline
+: ^^xor ( src1 src2 -- dst ) ^^r2 ##xor ; inline
+: ^^xor-imm ( src1 src2 -- dst ) ^^r2 ##xor-imm ; inline
+: ^^shl ( src1 src2 -- dst ) ^^r2 ##shl ; inline
+: ^^shl-imm ( src1 src2 -- dst ) ^^r2 ##shl-imm ; inline
+: ^^shr ( src1 src2 -- dst ) ^^r2 ##shr ; inline
+: ^^shr-imm ( src1 src2 -- dst ) ^^r2 ##shr-imm ; inline
+: ^^sar ( src1 src2 -- dst ) ^^r2 ##sar ; inline
+: ^^sar-imm ( src1 src2 -- dst ) ^^r2 ##sar-imm ; inline
+: ^^not ( src -- dst ) ^^r1 ##not ; inline
+: ^^log2 ( src -- dst ) ^^r1 ##log2 ; inline
+: ^^bignum>integer ( src -- dst ) ^^r1 next-vreg ##bignum>integer ; inline
+: ^^integer>bignum ( src -- dst ) ^^r1 next-vreg ##integer>bignum ; inline
+: ^^add-float ( src1 src2 -- dst ) ^^r2 ##add-float ; inline
+: ^^sub-float ( src1 src2 -- dst ) ^^r2 ##sub-float ; inline
+: ^^mul-float ( src1 src2 -- dst ) ^^r2 ##mul-float ; inline
+: ^^div-float ( src1 src2 -- dst ) ^^r2 ##div-float ; inline
+: ^^float>integer ( src -- dst ) ^^r1 ##float>integer ; inline
+: ^^integer>float ( src -- dst ) ^^r1 ##integer>float ; inline
+: ^^allot ( size class -- dst ) ^^r2 next-vreg ##allot ; inline
 : ^^allot-tuple ( n -- dst ) 2 + cells tuple ^^allot ; inline
 : ^^allot-array ( n -- dst ) 2 + cells array ^^allot ; inline
 : ^^allot-byte-array ( n -- dst ) 2 cells + byte-array ^^allot ; inline
-: ^^box-float ( src -- dst ) ^^i1 i ##box-float ; inline
-: ^^unbox-float ( src -- dst ) ^^d1 ##unbox-float ; inline
-: ^^box-alien ( src -- dst ) ^^i1 i ##box-alien ; inline
-: ^^unbox-alien ( src -- dst ) ^^i1 ##unbox-alien ; inline
-: ^^unbox-c-ptr ( src class -- dst ) ^^i2 i ##unbox-c-ptr ;
-: ^^alien-unsigned-1 ( src -- dst ) ^^i1 ##alien-unsigned-1 ; inline
-: ^^alien-unsigned-2 ( src -- dst ) ^^i1 ##alien-unsigned-2 ; inline
-: ^^alien-unsigned-4 ( src -- dst ) ^^i1 ##alien-unsigned-4 ; inline
-: ^^alien-signed-1 ( src -- dst ) ^^i1 ##alien-signed-1 ; inline
-: ^^alien-signed-2 ( src -- dst ) ^^i1 ##alien-signed-2 ; inline
-: ^^alien-signed-4 ( src -- dst ) ^^i1 ##alien-signed-4 ; inline
-: ^^alien-cell ( src -- dst ) ^^i1 ##alien-cell ; inline
-: ^^alien-float ( src -- dst ) ^^d1 ##alien-float ; inline
-: ^^alien-double ( src -- dst ) ^^d1 ##alien-double ; inline
-: ^^alien-global ( symbol library -- dst ) ^^i2 ##alien-global ; inline
-: ^^compare ( src1 src2 cc -- dst ) ^^i3 i ##compare ; inline
-: ^^compare-imm ( src1 src2 cc -- dst ) ^^i3 i ##compare-imm ; inline
-: ^^compare-float ( src1 src2 cc -- dst ) ^^i3 i ##compare-float ; inline
+: ^^box-alien ( src -- dst ) ^^r1 next-vreg ##box-alien ; inline
+: ^^unbox-alien ( src -- dst ) ^^r1 ##unbox-alien ; inline
+: ^^unbox-c-ptr ( src class -- dst ) ^^r2 next-vreg ##unbox-c-ptr ;
+: ^^alien-unsigned-1 ( src -- dst ) ^^r1 ##alien-unsigned-1 ; inline
+: ^^alien-unsigned-2 ( src -- dst ) ^^r1 ##alien-unsigned-2 ; inline
+: ^^alien-unsigned-4 ( src -- dst ) ^^r1 ##alien-unsigned-4 ; inline
+: ^^alien-signed-1 ( src -- dst ) ^^r1 ##alien-signed-1 ; inline
+: ^^alien-signed-2 ( src -- dst ) ^^r1 ##alien-signed-2 ; inline
+: ^^alien-signed-4 ( src -- dst ) ^^r1 ##alien-signed-4 ; inline
+: ^^alien-cell ( src -- dst ) ^^r1 ##alien-cell ; inline
+: ^^alien-float ( src -- dst ) ^^r1 ##alien-float ; inline
+: ^^alien-double ( src -- dst ) ^^r1 ##alien-double ; inline
+: ^^alien-global ( symbol library -- dst ) ^^r2 ##alien-global ; inline
+: ^^compare ( src1 src2 cc -- dst ) ^^r3 next-vreg ##compare ; inline
+: ^^compare-imm ( src1 src2 cc -- dst ) ^^r3 next-vreg ##compare-imm ; inline
+: ^^compare-float ( src1 src2 cc -- dst ) ^^r3 next-vreg ##compare-float ; inline
 : ^^offset>slot ( vreg -- vreg' ) cell 4 = [ 1 ^^shr-imm ] [ ^^copy ] if ; inline
-: ^^tag-fixnum ( src -- dst ) ^^i1 ##tag-fixnum ; inline
-: ^^untag-fixnum ( src -- dst ) ^^i1 ##untag-fixnum ; inline
-: ^^fixnum-add ( src1 src2 -- dst ) ^^i2 ##fixnum-add ; inline
-: ^^fixnum-sub ( src1 src2 -- dst ) ^^i2 ##fixnum-sub ; inline
-: ^^fixnum-mul ( src1 src2 -- dst ) ^^i2 ##fixnum-mul ; inline
-: ^^phi ( inputs -- dst ) ^^i1 ##phi ; inline
\ No newline at end of file
+: ^^tag-fixnum ( src -- dst ) ^^r1 ##tag-fixnum ; inline
+: ^^untag-fixnum ( src -- dst ) ^^r1 ##untag-fixnum ; inline
+: ^^fixnum-add ( src1 src2 -- dst ) ^^r2 ##fixnum-add ; inline
+: ^^fixnum-sub ( src1 src2 -- dst ) ^^r2 ##fixnum-sub ; inline
+: ^^fixnum-mul ( src1 src2 -- dst ) ^^r2 ##fixnum-mul ; inline
+: ^^phi ( inputs -- dst ) ^^r1 ##phi ; inline
\ No newline at end of file
index 0a52f1aa94b518ed2dfdfc3fc3f6c5335a163334..4cf4340bd776ffe1fccddc8bb6682bff7f1645a4 100644 (file)
@@ -112,8 +112,7 @@ INSN: ##float>integer < ##unary ;
 INSN: ##integer>float < ##unary ;
 
 ! Boxing and unboxing
-INSN: ##copy < ##unary ;
-INSN: ##copy-float < ##unary ;
+INSN: ##copy < ##unary rep ;
 INSN: ##unbox-float < ##unary ;
 INSN: ##unbox-any-c-ptr < ##unary/temp ;
 INSN: ##box-float < ##unary/temp ;
@@ -190,7 +189,7 @@ INSN: ##fixnum-add < ##fixnum-overflow ;
 INSN: ##fixnum-sub < ##fixnum-overflow ;
 INSN: ##fixnum-mul < ##fixnum-overflow ;
 
-INSN: ##gc temp1 temp2 live-values uninitialized-locs ;
+INSN: ##gc temp1 temp2 data-values tagged-values uninitialized-locs ;
 
 ! Instructions used by machine IR only.
 INSN: _prologue stack-frame ;
@@ -219,14 +218,13 @@ INSN: _fixnum-mul < _fixnum-overflow ;
 
 TUPLE: spill-slot n ; C: <spill-slot> spill-slot
 
-INSN: _gc temp1 temp2 gc-roots gc-root-count gc-root-size uninitialized-locs ;
+INSN: _gc temp1 temp2 data-values tagged-values uninitialized-locs ;
 
 ! These instructions operate on machine registers and not
 ! virtual registers
-INSN: _spill src class n ;
-INSN: _reload dst class n ;
-INSN: _copy dst src class ;
-INSN: _spill-counts counts ;
+INSN: _spill src rep n ;
+INSN: _reload dst rep n ;
+INSN: _spill-area-size n ;
 
 ! Instructions that use vregs
 UNION: vreg-insn
@@ -252,6 +250,34 @@ UNION: kill-vreg-insn
     ##alien-indirect
     ##alien-callback ;
 
+! Instructions that output floats
+UNION: output-float-insn
+    ##add-float
+    ##sub-float
+    ##mul-float
+    ##div-float
+    ##integer>float
+    ##unbox-float
+    ##alien-float
+    ##alien-double ;
+
+! Instructions that take floats as inputs
+UNION: input-float-insn
+    ##add-float
+    ##sub-float
+    ##mul-float
+    ##div-float
+    ##float>integer
+    ##box-float
+    ##set-alien-float
+    ##set-alien-double
+    ##compare-float
+    ##compare-float-branch ;
+
+! Smackdown
+INTERSECTION: ##unary-float ##unary input-float-insn ;
+INTERSECTION: ##binary-float ##binary input-float-insn ;
+
 ! Instructions that have complex expansions and require that the
 ! output registers are not equal to any of the input registers
 UNION: def-is-use-insn
index 04d841f2d1f407bc1f0145ebe37e51f9f518607e..246a2cb92480535602cb866337af3f53dc6f9052 100644 (file)
@@ -53,7 +53,7 @@ IN: compiler.cfg.intrinsics.alien
     inline-alien ; inline
 
 : inline-alien-float-setter ( node quot -- )
-    '[ ds-pop ^^unbox-float @ ]
+    '[ ds-pop @ ]
     [ float inline-alien-setter? ]
     inline-alien ; inline
 
@@ -90,18 +90,18 @@ IN: compiler.cfg.intrinsics.alien
 : emit-alien-cell-setter ( node -- )
     [ ##set-alien-cell ] inline-alien-cell-setter ;
 
-: emit-alien-float-getter ( node reg-class -- )
+: emit-alien-float-getter ( node rep -- )
     '[
         _ {
-            { single-float-regs [ ^^alien-float ] }
-            { double-float-regs [ ^^alien-double ] }
-        } case ^^box-float
+            { single-float-rep [ ^^alien-float ] }
+            { double-float-rep [ ^^alien-double ] }
+        } case
     ] inline-alien-getter ;
 
-: emit-alien-float-setter ( node reg-class -- )
+: emit-alien-float-setter ( node rep -- )
     '[
         _ {
-            { single-float-regs [ ##set-alien-float ] }
-            { double-float-regs [ ##set-alien-double ] }
+            { single-float-rep [ ##set-alien-float ] }
+            { double-float-rep [ ##set-alien-double ] }
         } case
     ] inline-alien-float-setter ;
index 8afd9f80ca29fcedb989bdedfdeeddb5afdf12d9..d4aa2750c002ccab82d6314da37591ac24539dc0 100644 (file)
@@ -8,11 +8,11 @@ compiler.cfg.utilities compiler.cfg.builder.blocks ;
 IN: compiler.cfg.intrinsics.allot
 
 : ##set-slots ( regs obj class -- )
-    '[ _ swap 1+ _ tag-number ##set-slot-imm ] each-index ;
+    '[ _ swap 1 + _ tag-number ##set-slot-imm ] each-index ;
 
 : emit-simple-allot ( node -- )
     [ in-d>> length ] [ node-output-infos first class>> ] bi
-    [ drop ds-load ] [ [ 1+ cells ] dip ^^allot ] [ nip ] 2tri
+    [ drop ds-load ] [ [ 1 + cells ] dip ^^allot ] [ nip ] 2tri
     [ ##set-slots ] [ [ drop ] [ ds-push ] [ drop ] tri* ] 3bi ;
 
 : tuple-slot-regs ( layout -- vregs )
index 84a0bc9ca0762b4a4989ccc559e9ff0d47493e32..152be80286b4a1cc3e49dc7a2d594f08fe46dd0a 100644 (file)
@@ -1,19 +1,17 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel compiler.cfg.stacks compiler.cfg.hats
 compiler.cfg.instructions compiler.cfg.utilities ;
 IN: compiler.cfg.intrinsics.float
 
 : emit-float-op ( insn -- )
-    [ 2inputs [ ^^unbox-float ] bi@ ] dip call ^^box-float
-    ds-push ; inline
+    [ 2inputs ] dip call ds-push ; inline
 
 : emit-float-comparison ( cc -- )
-    [ 2inputs [ ^^unbox-float ] bi@ ] dip ^^compare-float
-    ds-push ; inline
+    [ 2inputs ] dip ^^compare-float ds-push ; inline
 
 : emit-float>fixnum ( -- )
-    ds-pop ^^unbox-float ^^float>integer ^^tag-fixnum ds-push ;
+    ds-pop ^^float>integer ^^tag-fixnum ds-push ;
 
 : emit-fixnum>float ( -- )
-    ds-pop ^^untag-fixnum ^^integer>float ^^box-float ds-push ;
+    ds-pop ^^untag-fixnum ^^integer>float ds-push ;
index 2618db0904d2ac0add69564a92233c91a3a90ec8..363197c3c01fb810d37ce8b671c5e510fa0fdb74 100644 (file)
@@ -153,8 +153,8 @@ IN: compiler.cfg.intrinsics
         { \ alien.accessors:set-alien-signed-4 [ 4 emit-alien-integer-setter ] }
         { \ alien.accessors:alien-cell [ emit-alien-cell-getter ] }
         { \ alien.accessors:set-alien-cell [ emit-alien-cell-setter ] }
-        { \ alien.accessors:alien-float [ single-float-regs emit-alien-float-getter ] }
-        { \ alien.accessors:set-alien-float [ single-float-regs emit-alien-float-setter ] }
-        { \ alien.accessors:alien-double [ double-float-regs emit-alien-float-getter ] }
-        { \ alien.accessors:set-alien-double [ double-float-regs emit-alien-float-setter ] }
+        { \ alien.accessors:alien-float [ single-float-rep emit-alien-float-getter ] }
+        { \ alien.accessors:set-alien-float [ single-float-rep emit-alien-float-setter ] }
+        { \ alien.accessors:alien-double [ double-float-rep emit-alien-float-getter ] }
+        { \ alien.accessors:set-alien-double [ double-float-rep emit-alien-float-setter ] }
     } case ;
index 93139a19a3169098cd6b47337ace561ed20af11f..79e56c08ad171c0c464a6bc0fe3f464eafbb8f22 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: layouts namespaces kernel accessors sequences
-classes.algebra compiler.tree.propagation.info
-compiler.cfg.stacks compiler.cfg.hats compiler.cfg.instructions
+USING: layouts namespaces kernel accessors sequences classes.algebra
+compiler.tree.propagation.info compiler.cfg.stacks compiler.cfg.hats
+compiler.cfg.registers compiler.cfg.instructions
 compiler.cfg.utilities compiler.cfg.builder.blocks ;
 IN: compiler.cfg.intrinsics.slots
 
@@ -45,7 +45,7 @@ IN: compiler.cfg.intrinsics.slots
             dup third value-info-small-fixnum?
             [ (emit-set-slot-imm) ] [ (emit-set-slot) ] if
         ] [ first class>> immediate class<= ] bi
-        [ drop ] [ i i ##write-barrier ] if
+        [ drop ] [ next-vreg next-vreg ##write-barrier ] if
     ] [ drop emit-primitive ] if ;
 
 : emit-string-nth ( -- )
@@ -53,4 +53,4 @@ IN: compiler.cfg.intrinsics.slots
 
 : emit-set-string-nth-fast ( -- )
     3inputs [ ^^untag-fixnum ] [ ^^untag-fixnum ] [ ] tri*
-    swap i ##set-string-nth-fast ;
+    swap next-vreg ##set-string-nth-fast ;
index d55266e6e4b63ef5bc3b939eaf0327ee77decf97..4b504d97f55d82743c628f7fb373a60e59809900 100644 (file)
@@ -3,7 +3,6 @@
 USING: accessors assocs heaps kernel namespaces sequences fry math
 math.order combinators arrays sorting compiler.utilities
 compiler.cfg.linear-scan.live-intervals
-compiler.cfg.linear-scan.allocation.coalescing
 compiler.cfg.linear-scan.allocation.spilling
 compiler.cfg.linear-scan.allocation.splitting
 compiler.cfg.linear-scan.allocation.state ;
@@ -29,13 +28,11 @@ IN: compiler.cfg.linear-scan.allocation
     second 0 = ; inline
 
 : assign-register ( new -- )
-    dup coalesce? [ coalesce ] [
-        dup register-status {
-            { [ dup no-free-registers? ] [ drop assign-blocked-register ] }
-            { [ 2dup register-available? ] [ register-available ] }
-            [ drop assign-blocked-register ]
-        } cond
-    ] if ;
+    dup register-status {
+        { [ dup no-free-registers? ] [ drop assign-blocked-register ] }
+        { [ 2dup register-available? ] [ register-available ] }
+        [ drop assign-blocked-register ]
+    } cond ;
 
 : handle-interval ( live-interval -- )
     [
diff --git a/basis/compiler/cfg/linear-scan/allocation/coalescing/coalescing.factor b/basis/compiler/cfg/linear-scan/allocation/coalescing/coalescing.factor
deleted file mode 100644 (file)
index ef8a9c5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel sequences namespaces assocs fry
-combinators.short-circuit
-compiler.cfg.linear-scan.live-intervals
-compiler.cfg.linear-scan.allocation.state ;
-IN: compiler.cfg.linear-scan.allocation.coalescing
-
-: active-interval ( vreg -- live-interval )
-    dup [ dup active-intervals-for [ vreg>> = ] with find nip ] when ;
-
-: avoids-inactive-intervals? ( live-interval -- ? )
-    dup vreg>> inactive-intervals-for
-    [ intervals-intersect? not ] with all? ;
-
-: coalesce? ( live-interval -- ? )
-    {
-        [ copy-from>> active-interval ]
-        [ [ start>> ] [ copy-from>> active-interval end>> ] bi = ]
-        [ avoids-inactive-intervals? ]
-    } 1&& ;
-
-: reuse-spill-slot ( old new -- )
-    [ vreg>> spill-slots get at ] dip '[ _ vreg>> spill-slots get set-at ] when* ;
-
-: reuse-register ( old new -- )
-    reg>> >>reg drop ;
-
-: (coalesce) ( old new -- )
-    [ add-active ] [ [ delete-active ] [ add-handled ] bi ] bi* ;
-
-: coalesce ( live-interval -- )
-    dup copy-from>> active-interval
-    [ reuse-spill-slot ] [ reuse-register ] [ (coalesce) ] 2tri ;
\ No newline at end of file
index 874523d70a7fb57e2653fda036d4cd9425390ef2..1a2b0f2f2bdceae154b0e8b71d3a2691f1fdd1ef 100644 (file)
@@ -45,7 +45,7 @@ ERROR: splitting-atomic-interval ;
     f >>spill-to ; inline
 
 : split-after ( after -- after' )
-    f >>copy-from f >>reg f >>reload-from ; inline
+    f >>reg f >>reload-from ; inline
 
 :: split-interval ( live-interval n -- before after )
     live-interval n check-split
index 3e646b40f04b6644c24927b8133c5b4fcde546df..cf120eae3beba13223b203280f98e58f3357f413 100644 (file)
@@ -2,6 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs combinators cpu.architecture fry heaps
 kernel math math.order namespaces sequences vectors
+compiler.cfg compiler.cfg.registers
 compiler.cfg.linear-scan.live-intervals ;
 IN: compiler.cfg.linear-scan.allocation.state
 
@@ -26,7 +27,7 @@ SYMBOL: registers
 SYMBOL: active-intervals
 
 : active-intervals-for ( vreg -- seq )
-    reg-class>> active-intervals get at ;
+    rep-of reg-class-of active-intervals get at ;
 
 : add-active ( live-interval -- )
     dup vreg>> active-intervals-for push ;
@@ -41,7 +42,7 @@ SYMBOL: active-intervals
 SYMBOL: inactive-intervals
 
 : inactive-intervals-for ( vreg -- seq )
-    reg-class>> inactive-intervals get at ;
+    rep-of reg-class-of inactive-intervals get at ;
 
 : add-inactive ( live-interval -- )
     dup vreg>> inactive-intervals-for push ;
@@ -112,22 +113,18 @@ SYMBOL: unhandled-intervals
     [ dup start>> unhandled-intervals get heap-push ]
     bi ;
 
-CONSTANT: reg-classes { int-regs double-float-regs }
-
 : reg-class-assoc ( quot -- assoc )
     [ reg-classes ] dip { } map>assoc ; inline
 
-! Mapping from register classes to spill counts
-SYMBOL: spill-counts
-
-: next-spill-slot ( reg-class -- n )
-    spill-counts get [ dup 1 + ] change-at ;
+: next-spill-slot ( rep -- n )
+    rep-size cfg get
+    [ swap [ align dup ] [ + ] bi ] change-spill-area-size drop ;
 
 ! Mapping from vregs to spill slots
 SYMBOL: spill-slots
 
 : assign-spill-slot ( vreg -- n )
-    spill-slots get [ reg-class>> next-spill-slot ] cache ;
+    spill-slots get [ rep-of next-spill-slot ] cache ;
 
 : init-allocator ( registers -- )
     registers set
@@ -135,7 +132,7 @@ SYMBOL: spill-slots
     [ V{ } clone ] reg-class-assoc active-intervals set
     [ V{ } clone ] reg-class-assoc inactive-intervals set
     V{ } clone handled-intervals set
-    [ 0 ] reg-class-assoc spill-counts set
+    cfg get 0 >>spill-area-size drop
     H{ } clone spill-slots set
     -1 progress set ;
 
@@ -145,7 +142,7 @@ SYMBOL: spill-slots
 
 ! A utility used by register-status and spill-status words
 : free-positions ( new -- assoc )
-    vreg>> reg-class>> registers get at [ 1/0. ] H{ } map>assoc ;
+    vreg>> rep-of reg-class-of registers get at [ 1/0. ] H{ } map>assoc ;
 
 : add-use-position ( n reg assoc -- ) [ [ min ] when* ] change-at ;
 
index 071118d60fde715d04c6824d1038b60b4da4d6eb..16f1ccf96a1e4ff2e62b1ee6df2d2a97da624cdf 100644 (file)
@@ -1,15 +1,15 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel math assocs namespaces sequences heaps
-fry make combinators sets locals
+fry make combinators sets locals arrays
 cpu.architecture
 compiler.cfg
-compiler.cfg.rpo
 compiler.cfg.def-use
 compiler.cfg.liveness
 compiler.cfg.registers
 compiler.cfg.instructions
 compiler.cfg.renaming.functor
+compiler.cfg.linearization.order
 compiler.cfg.linear-scan.allocation
 compiler.cfg.linear-scan.allocation.state
 compiler.cfg.linear-scan.live-intervals ;
@@ -52,7 +52,7 @@ SYMBOL: register-live-outs
     init-unhandled ;
 
 : insert-spill ( live-interval -- )
-    [ reg>> ] [ vreg>> reg-class>> ] [ spill-to>> ] tri _spill ;
+    [ reg>> ] [ vreg>> rep-of ] [ spill-to>> ] tri _spill ;
 
 : handle-spill ( live-interval -- )
     dup spill-to>> [ insert-spill ] [ drop ] if ;
@@ -72,7 +72,7 @@ SYMBOL: register-live-outs
     pending-interval-heap get (expire-old-intervals) ;
 
 : insert-reload ( live-interval -- )
-    [ reg>> ] [ vreg>> reg-class>> ] [ reload-from>> ] tri _reload ;
+    [ reg>> ] [ vreg>> rep-of ] [ reload-from>> ] tri _reload ;
 
 : handle-reload ( live-interval -- )
     dup reload-from>> [ insert-reload ] [ drop ] if ;
@@ -103,11 +103,36 @@ RENAMING: assign [ vreg>reg ] [ vreg>reg ] [ vreg>reg ]
 M: vreg-insn assign-registers-in-insn
     [ assign-insn-defs ] [ assign-insn-uses ] [ assign-insn-temps ] tri ;
 
+! TODO: needs tagged-rep
+
+: trace-on-gc ( assoc -- assoc' )
+    ! When a GC occurs, virtual registers which contain tagged data
+    ! are traced by the GC. Outputs a sequence physical registers.
+    [ drop rep-of int-rep eq? ] { } assoc-filter-as values ;
+
+: spill-on-gc? ( vreg reg -- ? )
+    [ rep-of int-rep? not ] [ spill-slot? not ] bi* and ;
+
+: spill-on-gc ( assoc -- assoc' )
+    ! When a GC occurs, virtual registers which contain untagged data,
+    ! and are stored in physical registers, are saved to their spill
+    ! slots. Outputs sequence of triples:
+    ! - physical register
+    ! - spill slot
+    ! - representation
+    [
+        [
+            2dup spill-on-gc?
+            [ swap [ assign-spill-slot ] [ rep-of ] bi 3array , ] [ 2drop ] if
+        ] assoc-each
+    ] { } make ;
+
 M: ##gc assign-registers-in-insn
-    ! This works because ##gc is always the first instruction
-    ! in a block.
+    ! Since ##gc is always the first instruction in a block, the set of
+    ! values live at the ##gc is just live-in.
     dup call-next-method
-    basic-block get register-live-ins get at >>live-values
+    basic-block get register-live-ins get at
+    [ trace-on-gc >>tagged-values ] [ spill-on-gc >>data-values ] bi
     drop ;
 
 M: insn assign-registers-in-insn drop ;
@@ -156,4 +181,4 @@ ERROR: bad-vreg vreg ;
 
 : assign-registers ( live-intervals cfg -- )
     [ init-assignment ] dip
-    [ assign-registers-in-block ] each-basic-block ;
+    linearization-order [ assign-registers-in-block ] each ;
index c9c1b77a0dedb68240fc7194cfac7c2474ba7483..68ff8d4f886559f7d134bd41226a7d66e7cac391 100644 (file)
@@ -18,9 +18,8 @@ IN: compiler.cfg.linear-scan.debugger
 
 : interval-picture ( interval -- str )
     [ uses>> picture ]
-    [ copy-from>> unparse ]
     [ vreg>> unparse ]
-    tri 3array ;
+    bi 2array ;
 
 : live-intervals. ( seq -- )
     [ interval-picture ] map simple-table. ;
index 2164cef4291758c8918a1f9d1783911bc9a65a09..b7a97e75c6d80e16c0eb9403e80238d3d88b42a9 100644 (file)
@@ -1,7 +1,7 @@
 IN: compiler.cfg.linear-scan.tests
 USING: tools.test random sorting sequences sets hashtables assocs
 kernel fry arrays splitting namespaces math accessors vectors locals
-math.order grouping strings strings.private classes
+math.order grouping strings strings.private classes layouts
 cpu.architecture
 compiler.cfg
 compiler.cfg.optimizer
@@ -11,6 +11,7 @@ compiler.cfg.predecessors
 compiler.cfg.rpo
 compiler.cfg.linearization
 compiler.cfg.debugger
+compiler.cfg.def-use
 compiler.cfg.comparisons
 compiler.cfg.linear-scan
 compiler.cfg.linear-scan.numbering
@@ -75,29 +76,35 @@ check-numbering? on
     { T{ live-range f 0 5 } } 0 split-ranges
 ] unit-test
 
-H{ { int-regs 10 } { float-regs 20 } } clone spill-counts set
+cfg new 0 >>spill-area-size cfg set
 H{ } spill-slots set
 
+H{
+    { 1 single-float-rep }
+    { 2 single-float-rep }
+    { 3 single-float-rep }
+} representations set
+
 [
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 1 } } }
+       { vreg 1 }
        { start 0 }
        { end 2 }
        { uses V{ 0 1 } }
        { ranges V{ T{ live-range f 0 2 } } }
-       { spill-to 10 }
+       { spill-to 0 }
     }
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 1 } } }
+       { vreg 1 }
        { start 5 }
        { end 5 }
        { uses V{ 5 } }
        { ranges V{ T{ live-range f 5 5 } } }
-       { reload-from 10 }
+       { reload-from 0 }
     }
 ] [
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 1 } } }
+       { vreg 1 }
        { start 0 }
        { end 5 }
        { uses V{ 0 1 5 } }
@@ -107,24 +114,24 @@ H{ } spill-slots set
 
 [
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 2 } } }
+       { vreg 2 }
        { start 0 }
        { end 1 }
        { uses V{ 0 } }
        { ranges V{ T{ live-range f 0 1 } } }
-       { spill-to 11 }
+       { spill-to 4 }
     }
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 2 } } }
+       { vreg 2 }
        { start 1 }
        { end 5 }
        { uses V{ 1 5 } }
        { ranges V{ T{ live-range f 1 5 } } }
-       { reload-from 11 }
+       { reload-from 4 }
     }
 ] [
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 2 } } }
+       { vreg 2 }
        { start 0 }
        { end 5 }
        { uses V{ 0 1 5 } }
@@ -134,24 +141,24 @@ H{ } spill-slots set
 
 [
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 3 } } }
+       { vreg 3 }
        { start 0 }
        { end 1 }
        { uses V{ 0 } }
        { ranges V{ T{ live-range f 0 1 } } }
-       { spill-to 12 }
+       { spill-to 8 }
     }
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 3 } } }
+       { vreg 3 }
        { start 20 }
        { end 30 }
        { uses V{ 20 30 } }
        { ranges V{ T{ live-range f 20 30 } } }
-       { reload-from 12 }
+       { reload-from 8 }
     }
 ] [
     T{ live-interval
-       { vreg T{ vreg { reg-class int-regs } { n 3 } } }
+       { vreg 3 }
        { start 0 }
        { end 30 }
        { uses V{ 0 20 30 } }
@@ -159,6 +166,12 @@ H{ } spill-slots set
     } 10 split-for-spill
 ] unit-test
 
+H{
+    { 1 int-rep }
+    { 2 int-rep }
+    { 3 int-rep }
+} representations set
+
 [
     {
         3
@@ -169,21 +182,21 @@ H{ } spill-slots set
         { int-regs
           V{
               T{ live-interval
-                 { vreg T{ vreg { reg-class int-regs } { n 1 } } }
+                 { vreg 1 }
                  { reg 1 }
                  { start 1 }
                  { end 15 }
                  { uses V{ 1 3 7 10 15 } }
               }
               T{ live-interval
-                 { vreg T{ vreg { reg-class int-regs } { n 2 } } }
+                 { vreg 2 }
                  { reg 2 }
                  { start 3 }
                  { end 8 }
                  { uses V{ 3 4 8 } }
               }
               T{ live-interval
-                 { vreg T{ vreg { reg-class int-regs } { n 3 } } }
+                 { vreg 3 }
                  { reg 3 }
                  { start 3 }
                  { end 10 }
@@ -194,7 +207,7 @@ H{ } spill-slots set
     } active-intervals set
     H{ } inactive-intervals set
     T{ live-interval
-        { vreg T{ vreg { reg-class int-regs } { n 1 } } }
+        { vreg 1 }
         { start 5 }
         { end 5 }
         { uses V{ 5 } }
@@ -212,14 +225,14 @@ H{ } spill-slots set
         { int-regs
           V{
               T{ live-interval
-                 { vreg T{ vreg { reg-class int-regs } { n 1 } } }
+                 { vreg 1 }
                  { reg 1 }
                  { start 1 }
                  { end 15 }
                  { uses V{ 1 } }
               }
               T{ live-interval
-                 { vreg T{ vreg { reg-class int-regs } { n 2 } } }
+                 { vreg 2 }
                  { reg 2 }
                  { start 3 }
                  { end 8 }
@@ -230,7 +243,7 @@ H{ } spill-slots set
     } active-intervals set
     H{ } inactive-intervals set
     T{ live-interval
-        { vreg T{ vreg { reg-class int-regs } { n 3 } } }
+        { vreg 3 }
         { start 5 }
         { end 5 }
         { uses V{ 5 } }
@@ -238,10 +251,12 @@ H{ } spill-slots set
     spill-status
 ] unit-test
 
+H{ { 1 int-rep } { 2 int-rep } } representations set
+
 [ ] [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 100 }
            { uses V{ 0 100 } }
@@ -255,14 +270,14 @@ H{ } spill-slots set
 [ ] [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 10 }
            { uses V{ 0 10 } }
            { ranges V{ T{ live-range f 0 10 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 2 } { reg-class int-regs } } }
+           { vreg 2 }
            { start 11 }
            { end 20 }
            { uses V{ 11 20 } }
@@ -276,14 +291,14 @@ H{ } spill-slots set
 [ ] [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 100 }
            { uses V{ 0 100 } }
            { ranges V{ T{ live-range f 0 100 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 2 } { reg-class int-regs } } }
+           { vreg 2 }
            { start 30 }
            { end 60 }
            { uses V{ 30 60 } }
@@ -297,14 +312,14 @@ H{ } spill-slots set
 [ ] [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 100 }
            { uses V{ 0 100 } }
            { ranges V{ T{ live-range f 0 100 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 2 } { reg-class int-regs } } }
+           { vreg 2 }
            { start 30 }
            { end 200 }
            { uses V{ 30 200 } }
@@ -318,14 +333,14 @@ H{ } spill-slots set
 [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 100 }
            { uses V{ 0 100 } }
            { ranges V{ T{ live-range f 0 100 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 2 } { reg-class int-regs } } }
+           { vreg 2 }
            { start 30 }
            { end 100 }
            { uses V{ 30 100 } }
@@ -337,32 +352,39 @@ H{ } spill-slots set
 ] must-fail
 
 ! Problem with spilling intervals with no more usages after the spill location
+H{
+    { 1 int-rep }
+    { 2 int-rep }
+    { 3 int-rep }
+    { 4 int-rep }
+    { 5 int-rep }
+} representations set
 
 [ ] [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 20 }
            { uses V{ 0 10 20 } }
            { ranges V{ T{ live-range f 0 2 } T{ live-range f 10 20 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 2 } { reg-class int-regs } } }
+           { vreg 2 }
            { start 0 }
            { end 20 }
            { uses V{ 0 10 20 } }
            { ranges V{ T{ live-range f 0 2 } T{ live-range f 10 20 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 3 } { reg-class int-regs } } }
+           { vreg 3 }
            { start 4 }
            { end 8 }
            { uses V{ 6 } }
            { ranges V{ T{ live-range f 4 8 } } }
         }
         T{ live-interval
-           { vreg T{ vreg { n 4 } { reg-class int-regs } } }
+           { vreg 4 }
            { start 4 }
            { end 8 }
            { uses V{ 8 } }
@@ -371,7 +393,7 @@ H{ } spill-slots set
 
         ! This guy will invoke the 'spill partially available' code path
         T{ live-interval
-           { vreg T{ vreg { n 5 } { reg-class int-regs } } }
+           { vreg 5 }
            { start 4 }
            { end 8 }
            { uses V{ 8 } }
@@ -382,13 +404,12 @@ H{ } spill-slots set
     check-linear-scan
 ] unit-test
 
-
 ! Test spill-new code path
 
 [ ] [
     {
         T{ live-interval
-           { vreg T{ vreg { n 1 } { reg-class int-regs } } }
+           { vreg 1 }
            { start 0 }
            { end 10 }
            { uses V{ 0 6 10 } }
@@ -397,7 +418,7 @@ H{ } spill-slots set
 
         ! This guy will invoke the 'spill new' code path
         T{ live-interval
-           { vreg T{ vreg { n 5 } { reg-class int-regs } } }
+           { vreg 5 }
            { start 2 }
            { end 8 }
            { uses V{ 8 } }
@@ -408,968 +429,6 @@ H{ } spill-slots set
     check-linear-scan
 ] unit-test
 
-SYMBOL: available
-
-SYMBOL: taken
-
-SYMBOL: max-registers
-
-SYMBOL: max-insns
-
-SYMBOL: max-uses
-
-: not-taken ( -- n )
-    available get keys dup empty? [ "Oops" throw ] when
-    random
-    dup taken get nth 1 + max-registers get = [
-        dup available get delete-at
-    ] [
-        dup taken get [ 1 + ] change-nth
-    ] if ;
-
-: random-live-intervals ( num-intervals max-uses max-registers max-insns -- seq )
-    [
-        max-insns set
-        max-registers set
-        max-uses set
-        max-insns get [ 0 ] replicate taken set
-        max-insns get [ dup ] H{ } map>assoc available set
-        [
-            \ live-interval new
-                swap int-regs swap vreg boa >>vreg
-                max-uses get random 2 max [ not-taken 2 * ] replicate natural-sort
-                [ >>uses ] [ first >>start ] bi
-                dup uses>> last >>end
-                dup [ start>> ] [ end>> ] bi <live-range> 1vector >>ranges
-        ] map
-    ] with-scope ;
-
-: random-test ( num-intervals max-uses max-registers max-insns -- )
-    over [ random-live-intervals ] dip int-regs associate check-linear-scan ;
-
-[ ] [ 30 2 1 60 random-test ] unit-test
-[ ] [ 60 2 2 60 random-test ] unit-test
-[ ] [ 80 2 3 200 random-test ] unit-test
-[ ] [ 70 2 5 30 random-test ] unit-test
-[ ] [ 60 2 6 30 random-test ] unit-test
-[ ] [ 1 2 10 10 random-test ] unit-test
-
-[ ] [ 10 4 2 60 random-test ] unit-test
-[ ] [ 10 20 2 400 random-test ] unit-test
-[ ] [ 10 20 4 300 random-test ] unit-test
-
-USING: math.private ;
-
-[ ] [
-    [ float+ float>fixnum 3 fixnum*fast ]
-    test-cfg first optimize-cfg linear-scan drop
-] unit-test
-
-: fake-live-ranges ( seq -- seq' )
-    [
-        clone dup [ start>> ] [ end>> ] bi <live-range> 1vector >>ranges
-    ] map ;
-
-! Coalescing interacted badly with splitting
-[ ] [
-    {
-        T{ live-interval
-            { vreg V int-regs 70 }
-            { start 14 }
-            { end 17 }
-            { uses V{ 14 15 16 17 } }
-            { copy-from V int-regs 67 }
-        }
-        T{ live-interval
-            { vreg V int-regs 67 }
-            { start 13 }
-            { end 14 }
-            { uses V{ 13 14 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 30 }
-            { start 4 }
-            { end 18 }
-            { uses V{ 4 12 16 17 18 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 27 }
-            { start 3 }
-            { end 13 }
-            { uses V{ 3 7 13 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 59 }
-            { start 10 }
-            { end 18 }
-            { uses V{ 10 11 12 18 } }
-            { copy-from V int-regs 56 }
-        }
-        T{ live-interval
-            { vreg V int-regs 60 }
-            { start 12 }
-            { end 17 }
-            { uses V{ 12 17 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 56 }
-            { start 9 }
-            { end 10 }
-            { uses V{ 9 10 } }
-        }
-    } fake-live-ranges
-    { { int-regs { 0 1 2 3 } } }
-    allocate-registers drop
-] unit-test
-
-[ ] [
-    {
-        T{ live-interval
-            { vreg V int-regs 3687168 }
-            { start 106 }
-            { end 112 }
-            { uses V{ 106 112 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687169 }
-            { start 107 }
-            { end 113 }
-            { uses V{ 107 113 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687727 }
-            { start 190 }
-            { end 198 }
-            { uses V{ 190 195 198 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686445 }
-            { start 43 }
-            { end 44 }
-            { uses V{ 43 44 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686195 }
-            { start 5 }
-            { end 11 }
-            { uses V{ 5 11 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686449 }
-            { start 44 }
-            { end 56 }
-            { uses V{ 44 45 45 46 56 } }
-            { copy-from V int-regs 3686445 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686198 }
-            { start 8 }
-            { end 10 }
-            { uses V{ 8 9 10 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686454 }
-            { start 46 }
-            { end 49 }
-            { uses V{ 46 47 47 49 } }
-            { copy-from V int-regs 3686449 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686196 }
-            { start 6 }
-            { end 12 }
-            { uses V{ 6 12 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686197 }
-            { start 7 }
-            { end 14 }
-            { uses V{ 7 13 14 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686455 }
-            { start 48 }
-            { end 51 }
-            { uses V{ 48 51 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686463 }
-            { start 52 }
-            { end 53 }
-            { uses V{ 52 53 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686460 }
-            { start 49 }
-            { end 52 }
-            { uses V{ 49 50 50 52 } }
-            { copy-from V int-regs 3686454 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686461 }
-            { start 51 }
-            { end 71 }
-            { uses V{ 51 52 64 68 71 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686464 }
-            { start 53 }
-            { end 54 }
-            { uses V{ 53 54 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686465 }
-            { start 54 }
-            { end 76 }
-            { uses V{ 54 55 55 76 } }
-            { copy-from V int-regs 3686464 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686470 }
-            { start 58 }
-            { end 60 }
-            { uses V{ 58 59 59 60 } }
-            { copy-from V int-regs 3686469 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686469 }
-            { start 56 }
-            { end 58 }
-            { uses V{ 56 57 57 58 } }
-            { copy-from V int-regs 3686449 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686473 }
-            { start 60 }
-            { end 62 }
-            { uses V{ 60 61 61 62 } }
-            { copy-from V int-regs 3686470 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686479 }
-            { start 62 }
-            { end 64 }
-            { uses V{ 62 63 63 64 } }
-            { copy-from V int-regs 3686473 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686735 }
-            { start 78 }
-            { end 96 }
-            { uses V{ 78 79 79 96 } }
-            { copy-from V int-regs 3686372 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686482 }
-            { start 64 }
-            { end 65 }
-            { uses V{ 64 65 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686483 }
-            { start 65 }
-            { end 66 }
-            { uses V{ 65 66 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687510 }
-            { start 168 }
-            { end 171 }
-            { uses V{ 168 171 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687511 }
-            { start 169 }
-            { end 176 }
-            { uses V{ 169 176 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686484 }
-            { start 66 }
-            { end 75 }
-            { uses V{ 66 67 67 75 } }
-            { copy-from V int-regs 3686483 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687509 }
-            { start 162 }
-            { end 163 }
-            { uses V{ 162 163 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686491 }
-            { start 68 }
-            { end 69 }
-            { uses V{ 68 69 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687512 }
-            { start 170 }
-            { end 178 }
-            { uses V{ 170 177 178 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687515 }
-            { start 172 }
-            { end 173 }
-            { uses V{ 172 173 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686492 }
-            { start 69 }
-            { end 74 }
-            { uses V{ 69 70 70 74 } }
-            { copy-from V int-regs 3686491 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687778 }
-            { start 202 }
-            { end 208 }
-            { uses V{ 202 208 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686499 }
-            { start 71 }
-            { end 72 }
-            { uses V{ 71 72 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687520 }
-            { start 174 }
-            { end 175 }
-            { uses V{ 174 175 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687779 }
-            { start 203 }
-            { end 209 }
-            { uses V{ 203 209 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687782 }
-            { start 206 }
-            { end 207 }
-            { uses V{ 206 207 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686503 }
-            { start 74 }
-            { end 75 }
-            { uses V{ 74 75 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686500 }
-            { start 72 }
-            { end 74 }
-            { uses V{ 72 73 73 74 } }
-            { copy-from V int-regs 3686499 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687780 }
-            { start 204 }
-            { end 210 }
-            { uses V{ 204 210 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686506 }
-            { start 75 }
-            { end 76 }
-            { uses V{ 75 76 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687530 }
-            { start 185 }
-            { end 192 }
-            { uses V{ 185 192 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687528 }
-            { start 183 }
-            { end 198 }
-            { uses V{ 183 198 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687529 }
-            { start 184 }
-            { end 197 }
-            { uses V{ 184 197 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687781 }
-            { start 205 }
-            { end 211 }
-            { uses V{ 205 211 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687535 }
-            { start 187 }
-            { end 194 }
-            { uses V{ 187 194 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686252 }
-            { start 9 }
-            { end 17 }
-            { uses V{ 9 15 17 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686509 }
-            { start 76 }
-            { end 90 }
-            { uses V{ 76 87 90 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687532 }
-            { start 186 }
-            { end 196 }
-            { uses V{ 186 196 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687538 }
-            { start 188 }
-            { end 193 }
-            { uses V{ 188 193 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687827 }
-            { start 217 }
-            { end 219 }
-            { uses V{ 217 219 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687825 }
-            { start 215 }
-            { end 218 }
-            { uses V{ 215 216 218 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687831 }
-            { start 218 }
-            { end 219 }
-            { uses V{ 218 219 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686296 }
-            { start 16 }
-            { end 18 }
-            { uses V{ 16 18 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686302 }
-            { start 29 }
-            { end 31 }
-            { uses V{ 29 31 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687838 }
-            { start 231 }
-            { end 232 }
-            { uses V{ 231 232 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686300 }
-            { start 26 }
-            { end 27 }
-            { uses V{ 26 27 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686301 }
-            { start 27 }
-            { end 30 }
-            { uses V{ 27 28 28 30 } }
-            { copy-from V int-regs 3686300 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686306 }
-            { start 37 }
-            { end 93 }
-            { uses V{ 37 82 93 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686307 }
-            { start 38 }
-            { end 88 }
-            { uses V{ 38 85 88 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687837 }
-            { start 222 }
-            { end 223 }
-            { uses V{ 222 223 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686305 }
-            { start 36 }
-            { end 81 }
-            { uses V{ 36 42 77 81 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686310 }
-            { start 39 }
-            { end 95 }
-            { uses V{ 39 84 95 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687836 }
-            { start 227 }
-            { end 228 }
-            { uses V{ 227 228 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687839 }
-            { start 239 }
-            { end 246 }
-            { uses V{ 239 245 246 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687841 }
-            { start 240 }
-            { end 241 }
-            { uses V{ 240 241 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687845 }
-            { start 241 }
-            { end 243 }
-            { uses V{ 241 243 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686315 }
-            { start 40 }
-            { end 94 }
-            { uses V{ 40 83 94 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687846 }
-            { start 242 }
-            { end 245 }
-            { uses V{ 242 245 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687849 }
-            { start 243 }
-            { end 245 }
-            { uses V{ 243 244 244 245 } }
-            { copy-from V int-regs 3687845 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687850 }
-            { start 245 }
-            { end 245 }
-            { uses V{ 245 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687851 }
-            { start 246 }
-            { end 246 }
-            { uses V{ 246 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687852 }
-            { start 246 }
-            { end 246 }
-            { uses V{ 246 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687853 }
-            { start 247 }
-            { end 248 }
-            { uses V{ 247 248 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687854 }
-            { start 249 }
-            { end 250 }
-            { uses V{ 249 250 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687855 }
-            { start 258 }
-            { end 259 }
-            { uses V{ 258 259 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687080 }
-            { start 280 }
-            { end 285 }
-            { uses V{ 280 285 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687081 }
-            { start 281 }
-            { end 286 }
-            { uses V{ 281 286 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687082 }
-            { start 282 }
-            { end 287 }
-            { uses V{ 282 287 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687083 }
-            { start 283 }
-            { end 288 }
-            { uses V{ 283 288 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687085 }
-            { start 284 }
-            { end 299 }
-            { uses V{ 284 285 286 287 288 296 299 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687086 }
-            { start 284 }
-            { end 284 }
-            { uses V{ 284 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687087 }
-            { start 289 }
-            { end 293 }
-            { uses V{ 289 293 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687088 }
-            { start 290 }
-            { end 294 }
-            { uses V{ 290 294 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687089 }
-            { start 291 }
-            { end 297 }
-            { uses V{ 291 297 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687090 }
-            { start 292 }
-            { end 298 }
-            { uses V{ 292 298 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687363 }
-            { start 118 }
-            { end 119 }
-            { uses V{ 118 119 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686599 }
-            { start 77 }
-            { end 89 }
-            { uses V{ 77 86 89 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687370 }
-            { start 131 }
-            { end 132 }
-            { uses V{ 131 132 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687371 }
-            { start 138 }
-            { end 143 }
-            { uses V{ 138 143 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687368 }
-            { start 127 }
-            { end 128 }
-            { uses V{ 127 128 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687369 }
-            { start 122 }
-            { end 123 }
-            { uses V{ 122 123 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687373 }
-            { start 139 }
-            { end 140 }
-            { uses V{ 139 140 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686352 }
-            { start 41 }
-            { end 91 }
-            { uses V{ 41 43 79 91 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687377 }
-            { start 140 }
-            { end 141 }
-            { uses V{ 140 141 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687382 }
-            { start 143 }
-            { end 143 }
-            { uses V{ 143 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687383 }
-            { start 144 }
-            { end 161 }
-            { uses V{ 144 159 161 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687380 }
-            { start 141 }
-            { end 143 }
-            { uses V{ 141 142 142 143 } }
-            { copy-from V int-regs 3687377 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687381 }
-            { start 143 }
-            { end 160 }
-            { uses V{ 143 160 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687384 }
-            { start 145 }
-            { end 158 }
-            { uses V{ 145 158 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687385 }
-            { start 146 }
-            { end 157 }
-            { uses V{ 146 157 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687640 }
-            { start 189 }
-            { end 191 }
-            { uses V{ 189 191 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687388 }
-            { start 147 }
-            { end 152 }
-            { uses V{ 147 152 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687393 }
-            { start 148 }
-            { end 153 }
-            { uses V{ 148 153 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687398 }
-            { start 149 }
-            { end 154 }
-            { uses V{ 149 154 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686372 }
-            { start 42 }
-            { end 92 }
-            { uses V{ 42 45 78 80 92 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687140 }
-            { start 293 }
-            { end 295 }
-            { uses V{ 293 294 294 295 } }
-            { copy-from V int-regs 3687087 }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687403 }
-            { start 150 }
-            { end 155 }
-            { uses V{ 150 155 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687150 }
-            { start 304 }
-            { end 306 }
-            { uses V{ 304 306 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687151 }
-            { start 305 }
-            { end 307 }
-            { uses V{ 305 307 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687408 }
-            { start 151 }
-            { end 156 }
-            { uses V{ 151 156 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687153 }
-            { start 312 }
-            { end 313 }
-            { uses V{ 312 313 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686902 }
-            { start 267 }
-            { end 272 }
-            { uses V{ 267 272 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686903 }
-            { start 268 }
-            { end 273 }
-            { uses V{ 268 273 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686900 }
-            { start 265 }
-            { end 270 }
-            { uses V{ 265 270 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686901 }
-            { start 266 }
-            { end 271 }
-            { uses V{ 266 271 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687162 }
-            { start 100 }
-            { end 119 }
-            { uses V{ 100 114 117 119 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687163 }
-            { start 101 }
-            { end 118 }
-            { uses V{ 101 115 116 118 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3686904 }
-            { start 269 }
-            { end 274 }
-            { uses V{ 269 274 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687166 }
-            { start 104 }
-            { end 110 }
-            { uses V{ 104 110 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687167 }
-            { start 105 }
-            { end 111 }
-            { uses V{ 105 111 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687164 }
-            { start 102 }
-            { end 108 }
-            { uses V{ 102 108 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 3687165 }
-            { start 103 }
-            { end 109 }
-            { uses V{ 103 109 } }
-        }
-    } fake-live-ranges
-    { { int-regs { 0 1 2 3 4 } } }
-    allocate-registers drop
-] unit-test
-
-! A reduction of the above
-[ ] [
-    {
-        T{ live-interval
-            { vreg V int-regs 6449 }
-            { start 44 }
-            { end 56 }
-            { uses V{ 44 45 46 56 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6454 }
-            { start 46 }
-            { end 49 }
-            { uses V{ 46 47 49 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6455 }
-            { start 48 }
-            { end 51 }
-            { uses V{ 48 51 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6460 }
-            { start 49 }
-            { end 52 }
-            { uses V{ 49 50 52 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6461 }
-            { start 51 }
-            { end 71 }
-            { uses V{ 51 52 64 68 71 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6464 }
-            { start 53 }
-            { end 54 }
-            { uses V{ 53 54 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6470 }
-            { start 58 }
-            { end 60 }
-            { uses V{ 58 59 60 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6469 }
-            { start 56 }
-            { end 58 }
-            { uses V{ 56 57 58 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6473 }
-            { start 60 }
-            { end 62 }
-            { uses V{ 60 61 62 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6479 }
-            { start 62 }
-            { end 64 }
-            { uses V{ 62 63 64 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6735 }
-            { start 78 }
-            { end 96 }
-            { uses V{ 78 79 96 } }
-            { copy-from V int-regs 6372 }
-        }
-        T{ live-interval
-            { vreg V int-regs 6483 }
-            { start 65 }
-            { end 66 }
-            { uses V{ 65 66 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 7845 }
-            { start 91 }
-            { end 93 }
-            { uses V{ 91 93 } }
-        }
-        T{ live-interval
-            { vreg V int-regs 6372 }
-            { start 42 }
-            { end 92 }
-            { uses V{ 42 45 78 80 92 } }
-        }
-    } fake-live-ranges
-    { { int-regs { 0 1 2 3 } } }
-    allocate-registers drop
-] unit-test
-
 [ f ] [
     T{ live-range f 0 10 }
     T{ live-range f 20 30 }
@@ -1446,13 +505,20 @@ USING: math.private ;
 
 ! register-status had problems because it used map>assoc where the sequence
 ! had multiple keys
+H{
+    { 1 int-rep }
+    { 2 int-rep }
+    { 3 int-rep }
+    { 4 int-rep }
+} representations set
+
 [ { 0 10 } ] [
     H{ { int-regs { 0 1 } } } registers set
     H{
         { int-regs
           {
               T{ live-interval
-                 { vreg V int-regs 1 }
+                 { vreg 1 }
                  { start 0 }
                  { end 20 }
                  { reg 0 }
@@ -1461,7 +527,7 @@ USING: math.private ;
               }
 
               T{ live-interval
-                 { vreg V int-regs 2 }
+                 { vreg 2 }
                  { start 4 }
                  { end 40 }
                  { reg 0 }
@@ -1475,7 +541,7 @@ USING: math.private ;
         { int-regs
           {
               T{ live-interval
-                 { vreg V int-regs 3 }
+                 { vreg 3 }
                  { start 0 }
                  { end 40 }
                  { reg 1 }
@@ -1487,7 +553,7 @@ USING: math.private ;
     } active-intervals set
 
     T{ live-interval
-       { vreg V int-regs 4 }
+       { vreg 4 }
         { start 8 }
         { end 10 }
         { ranges V{ T{ live-range f 8 10 } } }
@@ -1496,29 +562,38 @@ USING: math.private ;
     register-status
 ] unit-test
 
+:: test-linear-scan-on-cfg ( regs -- )
+    [
+        cfg new 0 get >>entry
+        dup cfg set
+        dup fake-representations
+        dup { { int-regs regs } } (linear-scan)
+        flatten-cfg 1array mr.
+    ] with-scope ;
+
 ! Bug in live spill slots calculation
 
 V{ T{ ##prologue } T{ ##branch } } 0 test-bb
 
 V{
     T{ ##peek
-       { dst V int-regs 703128 }
+       { dst 703128 }
        { loc D 1 }
     }
     T{ ##peek
-       { dst V int-regs 703129 }
+       { dst 703129 }
        { loc D 0 }
     }
     T{ ##copy
-       { dst V int-regs 703134 }
-       { src V int-regs 703128 }
+       { dst 703134 }
+       { src 703128 }
     }
     T{ ##copy
-       { dst V int-regs 703135 }
-       { src V int-regs 703129 }
+       { dst 703135 }
+       { src 703129 }
     }
     T{ ##compare-imm-branch
-       { src1 V int-regs 703128 }
+       { src1 703128 }
        { src2 5 }
        { cc cc/= }
     }
@@ -1526,23 +601,23 @@ V{
 
 V{
     T{ ##copy
-       { dst V int-regs 703134 }
-       { src V int-regs 703129 }
+       { dst 703134 }
+       { src 703129 }
     }
     T{ ##copy
-       { dst V int-regs 703135 }
-       { src V int-regs 703128 }
+       { dst 703135 }
+       { src 703128 }
     }
     T{ ##branch }
 } 2 test-bb
 
 V{
     T{ ##replace
-       { src V int-regs 703134 }
+       { src 703134 }
        { loc D 0 }
     }
     T{ ##replace
-       { src V int-regs 703135 }
+       { src 703135 }
        { loc D 1 }
     }
     T{ ##epilogue }
@@ -1553,38 +628,25 @@ V{
 1 { 2 3 } edges
 2 3 edge
 
-SYMBOL: linear-scan-result
-
-:: test-linear-scan-on-cfg ( regs -- )
-    [
-        cfg new 0 get >>entry
-        compute-predecessors
-        dup { { int-regs regs } } (linear-scan)
-        cfg-changed
-        flatten-cfg 1array mr.
-    ] with-scope ;
-
-[ ] [ { 1 2 } test-linear-scan-on-cfg ] unit-test
-
 ! Bug in inactive interval handling
 ! [ rot dup [ -rot ] when ]
 V{ T{ ##prologue } T{ ##branch } } 0 test-bb
     
 V{
     T{ ##peek
-       { dst V int-regs 689473 }
+       { dst 689473 }
        { loc D 2 }
     }
     T{ ##peek
-       { dst V int-regs 689474 }
+       { dst 689474 }
        { loc D 1 }
     }
     T{ ##peek
-       { dst V int-regs 689475 }
+       { dst 689475 }
        { loc D 0 }
     }
     T{ ##compare-imm-branch
-       { src1 V int-regs 689473 }
+       { src1 689473 }
        { src2 5 }
        { cc cc/= }
     }
@@ -1592,47 +654,47 @@ V{
 
 V{
     T{ ##copy
-       { dst V int-regs 689481 }
-       { src V int-regs 689475 }
+       { dst 689481 }
+       { src 689475 }
     }
     T{ ##copy
-       { dst V int-regs 689482 }
-       { src V int-regs 689474 }
+       { dst 689482 }
+       { src 689474 }
     }
     T{ ##copy
-       { dst V int-regs 689483 }
-       { src V int-regs 689473 }
+       { dst 689483 }
+       { src 689473 }
     }
     T{ ##branch }
 } 2 test-bb
 
 V{
     T{ ##copy
-       { dst V int-regs 689481 }
-       { src V int-regs 689473 }
+       { dst 689481 }
+       { src 689473 }
     }
     T{ ##copy
-       { dst V int-regs 689482 }
-       { src V int-regs 689475 }
+       { dst 689482 }
+       { src 689475 }
     }
     T{ ##copy
-       { dst V int-regs 689483 }
-       { src V int-regs 689474 }
+       { dst 689483 }
+       { src 689474 }
     }
     T{ ##branch }
 } 3 test-bb
 
 V{
     T{ ##replace
-       { src V int-regs 689481 }
+       { src 689481 }
        { loc D 0 }
     }
     T{ ##replace
-       { src V int-regs 689482 }
+       { src 689482 }
        { loc D 1 }
     }
     T{ ##replace
-       { src V int-regs 689483 }
+       { src 689483 }
        { loc D 2 }
     }
     T{ ##epilogue }
@@ -1654,15 +716,15 @@ T{ basic-block
     
 V{
     T{ ##peek
-       { dst V int-regs 689600 }
+       { dst 689600 }
        { loc D 1 }
     }
     T{ ##peek
-       { dst V int-regs 689601 }
+       { dst 689601 }
        { loc D 0 }
     }
     T{ ##compare-imm-branch
-       { src1 V int-regs 689600 }
+       { src1 689600 }
        { src2 5 }
        { cc cc/= }
     }
@@ -1670,55 +732,55 @@ V{
     
 V{
     T{ ##peek
-       { dst V int-regs 689604 }
+       { dst 689604 }
        { loc D 2 }
     }
     T{ ##copy
-       { dst V int-regs 689607 }
-       { src V int-regs 689604 }
+       { dst 689607 }
+       { src 689604 }
     }
     T{ ##copy
-       { dst V int-regs 689608 }
-       { src V int-regs 689600 }
+       { dst 689608 }
+       { src 689600 }
     }
     T{ ##copy
-       { dst V int-regs 689610 }
-       { src V int-regs 689601 }
+       { dst 689610 }
+       { src 689601 }
     }
     T{ ##branch }
 } 2 test-bb
     
 V{
     T{ ##peek
-       { dst V int-regs 689609 }
+       { dst 689609 }
        { loc D 2 }
     }
     T{ ##copy
-       { dst V int-regs 689607 }
-       { src V int-regs 689600 }
+       { dst 689607 }
+       { src 689600 }
     }
     T{ ##copy
-       { dst V int-regs 689608 }
-       { src V int-regs 689601 }
+       { dst 689608 }
+       { src 689601 }
     }
     T{ ##copy
-       { dst V int-regs 689610 }
-       { src V int-regs 689609 }
+       { dst 689610 }
+       { src 689609 }
     }
     T{ ##branch }
 } 3 test-bb
     
 V{
     T{ ##replace
-       { src V int-regs 689607 }
+       { src 689607 }
        { loc D 0 }
     }
     T{ ##replace
-       { src V int-regs 689608 }
+       { src 689608 }
        { loc D 1 }
     }
     T{ ##replace
-       { src V int-regs 689610 }
+       { src 689610 }
        { loc D 2 }
     }
     T{ ##epilogue }
@@ -1736,11 +798,11 @@ V{ T{ ##prologue } T{ ##branch } } 0 test-bb
 
 V{
     T{ ##peek
-       { dst V int-regs 0 }
+       { dst 0 }
        { loc D 0 }
     }
     T{ ##compare-imm-branch
-       { src1 V int-regs 0 }
+       { src1 0 }
        { src2 5 }
        { cc cc/= }
     }
@@ -1748,31 +810,31 @@ V{
 
 V{
     T{ ##peek
-       { dst V int-regs 1 }
+       { dst 1 }
        { loc D 1 }
     }
     T{ ##copy
-       { dst V int-regs 2 }
-       { src V int-regs 1 }
+       { dst 2 }
+       { src 1 }
     }
     T{ ##branch }
 } 2 test-bb
 
 V{
     T{ ##peek
-       { dst V int-regs 3 }
+       { dst 3 }
        { loc D 2 }
     }
     T{ ##copy
-       { dst V int-regs 2 }
-       { src V int-regs 3 }
+       { dst 2 }
+       { src 3 }
     }
     T{ ##branch }
 } 3 test-bb
 
 V{
     T{ ##replace
-       { src V int-regs 2 }
+       { src 2 }
        { loc D 0 }
     }
     T{ ##return }
@@ -1785,29 +847,29 @@ test-diamond
 ! Inactive interval handling: splitting active interval
 ! if it fits in lifetime hole only partially
 
-V{ T{ ##peek f V int-regs 3 R 1 } T{ ##branch } } 0 test-bb
+V{ T{ ##peek f 3 R 1 } T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 2 R 0 }
-    T{ ##compare-imm-branch f V int-regs 2 5 cc= }
+    T{ ##peek f 2 R 0 }
+    T{ ##compare-imm-branch f 2 5 cc= }
 } 1 test-bb
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
+    T{ ##peek f 0 D 0 }
     T{ ##branch }
 } 2 test-bb
 
 
 V{
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 1 D 2 }
+    T{ ##peek f 1 D 1 }
+    T{ ##peek f 0 D 0 }
+    T{ ##replace f 1 D 2 }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 R 2 }
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 3 R 2 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 4 test-bb
 
@@ -1819,11 +881,11 @@ test-diamond
 ! [ _copy ] [ 3 get instructions>> second class ] unit-test
 
 ! Resolve pass; make sure the spilling is done correctly
-V{ T{ ##peek f V int-regs 3 R 1 } T{ ##branch } } 0 test-bb
+V{ T{ ##peek f 3 R 1 } T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 2 R 0 }
-    T{ ##compare-imm-branch f V int-regs 2 5 cc= }
+    T{ ##peek f 2 R 0 }
+    T{ ##compare-imm-branch f 2 5 cc= }
 } 1 test-bb
 
 V{
@@ -1831,16 +893,16 @@ V{
 } 2 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 R 1 }
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 1 D 2 }
-    T{ ##replace f V int-regs 0 D 2 }
+    T{ ##replace f 3 R 1 }
+    T{ ##peek f 1 D 1 }
+    T{ ##peek f 0 D 0 }
+    T{ ##replace f 1 D 2 }
+    T{ ##replace f 0 D 2 }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 R 2 }
+    T{ ##replace f 3 R 2 }
     T{ ##return }
 } 4 test-bb
 
@@ -1862,16 +924,16 @@ V{
 } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##compare-imm-branch f V int-regs 0 5 cc= }
+    T{ ##peek f 0 D 0 }
+    T{ ##compare-imm-branch f 0 5 cc= }
 } 1 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 1 D 0 }
-    T{ ##peek f V int-regs 2 D 0 }
-    T{ ##replace f V int-regs 1 D 0 }
-    T{ ##replace f V int-regs 2 D 0 }
+    T{ ##replace f 0 D 0 }
+    T{ ##peek f 1 D 0 }
+    T{ ##peek f 2 D 0 }
+    T{ ##replace f 1 D 0 }
+    T{ ##replace f 2 D 0 }
     T{ ##branch }
 } 2 test-bb
 
@@ -1880,17 +942,17 @@ V{
 } 3 test-bb
 
 V{
-    T{ ##peek f V int-regs 1 D 0 }
-    T{ ##compare-imm-branch f V int-regs 1 5 cc= }
+    T{ ##peek f 1 D 0 }
+    T{ ##compare-imm-branch f 1 5 cc= }
 } 4 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 5 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 6 test-bb
 
@@ -1912,45 +974,45 @@ V{
 ! got fixed
 V{ T{ ##branch } } 0 test-bb
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 2 D 2 }
-    T{ ##peek f V int-regs 3 D 3 }
-    T{ ##peek f V int-regs 4 D 0 }
+    T{ ##peek f 0 D 0 }
+    T{ ##peek f 1 D 1 }
+    T{ ##peek f 2 D 2 }
+    T{ ##peek f 3 D 3 }
+    T{ ##peek f 4 D 0 }
     T{ ##branch }
 } 1 test-bb
 V{ T{ ##branch } } 2 test-bb
 V{ T{ ##branch } } 3 test-bb
 V{
     
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 3 D 3 }
-    T{ ##replace f V int-regs 4 D 4 }
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 1 D 1 }
+    T{ ##replace f 2 D 2 }
+    T{ ##replace f 3 D 3 }
+    T{ ##replace f 4 D 4 }
+    T{ ##replace f 0 D 0 }
     T{ ##branch }
 } 4 test-bb
-V{ T{ ##replace f V int-regs 0 D 0 } T{ ##branch } } 5 test-bb
+V{ T{ ##replace f 0 D 0 } T{ ##branch } } 5 test-bb
 V{ T{ ##return } } 6 test-bb
 V{ T{ ##branch } } 7 test-bb
 V{
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 3 D 3 }
-    T{ ##peek f V int-regs 5 D 1 }
-    T{ ##peek f V int-regs 6 D 2 }
-    T{ ##peek f V int-regs 7 D 3 }
-    T{ ##peek f V int-regs 8 D 4 }
-    T{ ##replace f V int-regs 5 D 1 }
-    T{ ##replace f V int-regs 6 D 2 }
-    T{ ##replace f V int-regs 7 D 3 }
-    T{ ##replace f V int-regs 8 D 4 }
+    T{ ##replace f 1 D 1 }
+    T{ ##replace f 2 D 2 }
+    T{ ##replace f 3 D 3 }
+    T{ ##peek f 5 D 1 }
+    T{ ##peek f 6 D 2 }
+    T{ ##peek f 7 D 3 }
+    T{ ##peek f 8 D 4 }
+    T{ ##replace f 5 D 1 }
+    T{ ##replace f 6 D 2 }
+    T{ ##replace f 7 D 3 }
+    T{ ##replace f 8 D 4 }
     T{ ##branch }
 } 8 test-bb
 V{
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 3 D 3 }
+    T{ ##replace f 1 D 1 }
+    T{ ##replace f 2 D 2 }
+    T{ ##replace f 3 D 3 }
     T{ ##return }
 } 9 test-bb
 
@@ -1967,32 +1029,32 @@ V{
 
 [ _spill ] [ 1 get instructions>> second class ] unit-test
 [ _reload ] [ 4 get instructions>> 4 swap nth class ] unit-test
-[ V{ 3 2 1 } ] [ 8 get instructions>> [ _spill? ] filter [ n>> ] map ] unit-test
-[ V{ 3 2 1 } ] [ 9 get instructions>> [ _reload? ] filter [ n>> ] map ] unit-test
+[ V{ 3 2 1 } ] [ 8 get instructions>> [ _spill? ] filter [ n>> cell / ] map ] unit-test
+[ V{ 3 2 1 } ] [ 9 get instructions>> [ _reload? ] filter [ n>> cell / ] map ] unit-test
 
 ! Resolve pass should insert this
 [ _reload ] [ 5 get predecessors>> first instructions>> first class ] unit-test
 
 ! Some random bug
 V{
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 2 D 2 }
-    T{ ##peek f V int-regs 3 D 0 }
-    T{ ##peek f V int-regs 0 D 0 }
+    T{ ##peek f 1 D 1 }
+    T{ ##peek f 2 D 2 }
+    T{ ##replace f 1 D 1 }
+    T{ ##replace f 2 D 2 }
+    T{ ##peek f 3 D 0 }
+    T{ ##peek f 0 D 0 }
     T{ ##branch }
 } 0 test-bb
 
 V{ T{ ##branch } } 1 test-bb
 
 V{
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 3 D 3 }
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 0 D 3 }
+    T{ ##peek f 1 D 1 }
+    T{ ##peek f 2 D 2 }
+    T{ ##replace f 3 D 3 }
+    T{ ##replace f 1 D 1 }
+    T{ ##replace f 2 D 2 }
+    T{ ##replace f 0 D 3 }
     T{ ##branch }
 } 2 test-bb
 
@@ -2009,40 +1071,40 @@ test-diamond
 ! Spilling an interval immediately after its activated;
 ! and the interval does not have a use at the activation point
 V{
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 2 D 2 }
-    T{ ##peek f V int-regs 0 D 0 }
+    T{ ##peek f 1 D 1 }
+    T{ ##peek f 2 D 2 }
+    T{ ##replace f 1 D 1 }
+    T{ ##replace f 2 D 2 }
+    T{ ##peek f 0 D 0 }
     T{ ##branch }
 } 0 test-bb
 
 V{ T{ ##branch } } 1 test-bb
 
 V{
-    T{ ##peek f V int-regs 1 D 1 }
+    T{ ##peek f 1 D 1 }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 2 D 2 }
-    T{ ##replace f V int-regs 2 D 2 }
+    T{ ##replace f 1 D 1 }
+    T{ ##peek f 2 D 2 }
+    T{ ##replace f 2 D 2 }
     T{ ##branch }
 } 3 test-bb
 
 V{ T{ ##branch } } 4 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 5 test-bb
 
-1 get 1vector 0 get (>>successors)
-2 get 4 get V{ } 2sequence 1 get (>>successors)
-5 get 1vector 4 get (>>successors)
-3 get 1vector 2 get (>>successors)
-5 get 1vector 3 get (>>successors)
+0 1 edge
+1 { 2 4 } edges
+4 5 edge
+2 3 edge
+3 5 edge
 
 [ ] [ { 1 2 } test-linear-scan-on-cfg ] unit-test
 
@@ -2050,89 +1112,89 @@ V{
 V{ T{ ##prologue } T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##load-immediate { dst V int-regs 61 } }
-    T{ ##peek { dst V int-regs 62 } { loc D 0 } }
-    T{ ##peek { dst V int-regs 64 } { loc D 1 } }
+    T{ ##load-immediate { dst 61 } }
+    T{ ##peek { dst 62 } { loc D 0 } }
+    T{ ##peek { dst 64 } { loc D 1 } }
     T{ ##slot-imm
-        { dst V int-regs 69 }
-        { obj V int-regs 64 }
+        { dst 69 }
+        { obj 64 }
         { slot 1 }
         { tag 2 }
     }
-    T{ ##copy { dst V int-regs 79 } { src V int-regs 69 } }
+    T{ ##copy { dst 79 } { src 69 } }
     T{ ##slot-imm
-        { dst V int-regs 85 }
-        { obj V int-regs 62 }
+        { dst 85 }
+        { obj 62 }
         { slot 2 }
         { tag 7 }
     }
     T{ ##compare-branch
-        { src1 V int-regs 69 }
-        { src2 V int-regs 85 }
+        { src1 69 }
+        { src2 85 }
         { cc cc> }
     }
 } 1 test-bb
 
 V{
     T{ ##slot-imm
-        { dst V int-regs 97 }
-        { obj V int-regs 62 }
+        { dst 97 }
+        { obj 62 }
         { slot 2 }
         { tag 7 }
     }
-    T{ ##replace { src V int-regs 79 } { loc D 3 } }
-    T{ ##replace { src V int-regs 62 } { loc D 4 } }
-    T{ ##replace { src V int-regs 79 } { loc D 1 } }
-    T{ ##replace { src V int-regs 62 } { loc D 2 } }
-    T{ ##replace { src V int-regs 61 } { loc D 5 } }
-    T{ ##replace { src V int-regs 62 } { loc R 0 } }
-    T{ ##replace { src V int-regs 69 } { loc R 1 } }
-    T{ ##replace { src V int-regs 97 } { loc D 0 } }
+    T{ ##replace { src 79 } { loc D 3 } }
+    T{ ##replace { src 62 } { loc D 4 } }
+    T{ ##replace { src 79 } { loc D 1 } }
+    T{ ##replace { src 62 } { loc D 2 } }
+    T{ ##replace { src 61 } { loc D 5 } }
+    T{ ##replace { src 62 } { loc R 0 } }
+    T{ ##replace { src 69 } { loc R 1 } }
+    T{ ##replace { src 97 } { loc D 0 } }
     T{ ##call { word resize-array } }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##peek { dst V int-regs 98 } { loc R 0 } }
-    T{ ##peek { dst V int-regs 100 } { loc D 0 } }
+    T{ ##peek { dst 98 } { loc R 0 } }
+    T{ ##peek { dst 100 } { loc D 0 } }
     T{ ##set-slot-imm
-        { src V int-regs 100 }
-        { obj V int-regs 98 }
+        { src 100 }
+        { obj 98 }
         { slot 2 }
         { tag 7 }
     }
-    T{ ##peek { dst V int-regs 108 } { loc D 2 } }
-    T{ ##peek { dst V int-regs 110 } { loc D 3 } }
-    T{ ##peek { dst V int-regs 112 } { loc D 0 } }
-    T{ ##peek { dst V int-regs 114 } { loc D 1 } }
-    T{ ##peek { dst V int-regs 116 } { loc D 4 } }
-    T{ ##peek { dst V int-regs 119 } { loc R 0 } }
-    T{ ##copy { dst V int-regs 109 } { src V int-regs 108 } }
-    T{ ##copy { dst V int-regs 111 } { src V int-regs 110 } }
-    T{ ##copy { dst V int-regs 113 } { src V int-regs 112 } }
-    T{ ##copy { dst V int-regs 115 } { src V int-regs 114 } }
-    T{ ##copy { dst V int-regs 117 } { src V int-regs 116 } }
-    T{ ##copy { dst V int-regs 120 } { src V int-regs 119 } }
+    T{ ##peek { dst 108 } { loc D 2 } }
+    T{ ##peek { dst 110 } { loc D 3 } }
+    T{ ##peek { dst 112 } { loc D 0 } }
+    T{ ##peek { dst 114 } { loc D 1 } }
+    T{ ##peek { dst 116 } { loc D 4 } }
+    T{ ##peek { dst 119 } { loc R 0 } }
+    T{ ##copy { dst 109 } { src 108 } }
+    T{ ##copy { dst 111 } { src 110 } }
+    T{ ##copy { dst 113 } { src 112 } }
+    T{ ##copy { dst 115 } { src 114 } }
+    T{ ##copy { dst 117 } { src 116 } }
+    T{ ##copy { dst 120 } { src 119 } }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##copy { dst V int-regs 109 } { src V int-regs 62 } }
-    T{ ##copy { dst V int-regs 111 } { src V int-regs 61 } }
-    T{ ##copy { dst V int-regs 113 } { src V int-regs 62 } }
-    T{ ##copy { dst V int-regs 115 } { src V int-regs 79 } }
-    T{ ##copy { dst V int-regs 117 } { src V int-regs 64 } }
-    T{ ##copy { dst V int-regs 120 } { src V int-regs 69 } }
+    T{ ##copy { dst 109 } { src 62 } }
+    T{ ##copy { dst 111 } { src 61 } }
+    T{ ##copy { dst 113 } { src 62 } }
+    T{ ##copy { dst 115 } { src 79 } }
+    T{ ##copy { dst 117 } { src 64 } }
+    T{ ##copy { dst 120 } { src 69 } }
     T{ ##branch }
 } 4 test-bb
 
 V{
-    T{ ##replace { src V int-regs 120 } { loc D 0 } }
-    T{ ##replace { src V int-regs 109 } { loc D 3 } }
-    T{ ##replace { src V int-regs 111 } { loc D 4 } }
-    T{ ##replace { src V int-regs 113 } { loc D 1 } }
-    T{ ##replace { src V int-regs 115 } { loc D 2 } }
-    T{ ##replace { src V int-regs 117 } { loc D 5 } }
+    T{ ##replace { src 120 } { loc D 0 } }
+    T{ ##replace { src 109 } { loc D 3 } }
+    T{ ##replace { src 111 } { loc D 4 } }
+    T{ ##replace { src 113 } { loc D 1 } }
+    T{ ##replace { src 115 } { loc D 2 } }
+    T{ ##replace { src 117 } { loc D 5 } }
     T{ ##epilogue }
     T{ ##return }
 } 5 test-bb
 V{ T{ ##prologue } T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek { dst V int-regs 85 } { loc D 0 } }
+    T{ ##peek { dst 85 } { loc D 0 } }
     T{ ##slot-imm
-        { dst V int-regs 89 }
-        { obj V int-regs 85 }
+        { dst 89 }
+        { obj 85 }
         { slot 3 }
         { tag 7 }
     }
-    T{ ##peek { dst V int-regs 91 } { loc D 1 } }
+    T{ ##peek { dst 91 } { loc D 1 } }
     T{ ##slot-imm
-        { dst V int-regs 96 }
-        { obj V int-regs 91 }
+        { dst 96 }
+        { obj 91 }
         { slot 1 }
         { tag 2 }
     }
     T{ ##add
-        { dst V int-regs 109 }
-        { src1 V int-regs 89 }
-        { src2 V int-regs 96 }
+        { dst 109 }
+        { src1 89 }
+        { src2 96 }
     }
     T{ ##slot-imm
-        { dst V int-regs 115 }
-        { obj V int-regs 85 }
+        { dst 115 }
+        { obj 85 }
         { slot 2 }
         { tag 7 }
     }
     T{ ##slot-imm
-        { dst V int-regs 118 }
-        { obj V int-regs 115 }
+        { dst 118 }
+        { obj 115 }
         { slot 1 }
         { tag 2 }
     }
     T{ ##compare-branch
-        { src1 V int-regs 109 }
-        { src2 V int-regs 118 }
+        { src1 109 }
+        { src2 118 }
         { cc cc> }
     }
 } 1 test-bb
 
 V{
     T{ ##add-imm
-        { dst V int-regs 128 }
-        { src1 V int-regs 109 }
+        { dst 128 }
+        { src1 109 }
         { src2 8 }
     }
-    T{ ##load-immediate { dst V int-regs 129 } { val 24 } }
+    T{ ##load-immediate { dst 129 } { val 24 } }
     T{ ##inc-d { n 4 } }
     T{ ##inc-r { n 1 } }
-    T{ ##replace { src V int-regs 109 } { loc D 2 } }
-    T{ ##replace { src V int-regs 85 } { loc D 3 } }
-    T{ ##replace { src V int-regs 128 } { loc D 0 } }
-    T{ ##replace { src V int-regs 85 } { loc D 1 } }
-    T{ ##replace { src V int-regs 89 } { loc D 4 } }
-    T{ ##replace { src V int-regs 96 } { loc R 0 } }
-    T{ ##replace { src V int-regs 129 } { loc R 0 } }
+    T{ ##replace { src 109 } { loc D 2 } }
+    T{ ##replace { src 85 } { loc D 3 } }
+    T{ ##replace { src 128 } { loc D 0 } }
+    T{ ##replace { src 85 } { loc D 1 } }
+    T{ ##replace { src 89 } { loc D 4 } }
+    T{ ##replace { src 96 } { loc R 0 } }
+    T{ ##replace { src 129 } { loc R 0 } }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##peek { dst V int-regs 134 } { loc D 1 } }
+    T{ ##peek { dst 134 } { loc D 1 } }
     T{ ##slot-imm
-        { dst V int-regs 140 }
-        { obj V int-regs 134 }
+        { dst 140 }
+        { obj 134 }
         { slot 2 }
         { tag 7 }
     }
     T{ ##inc-d { n 1 } }
     T{ ##inc-r { n 1 } }
-    T{ ##replace { src V int-regs 140 } { loc D 0 } }
-    T{ ##replace { src V int-regs 134 } { loc R 0 } }
+    T{ ##replace { src 140 } { loc D 0 } }
+    T{ ##replace { src 134 } { loc R 0 } }
     T{ ##call { word resize-array } }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##peek { dst V int-regs 141 } { loc R 0 } }
-    T{ ##peek { dst V int-regs 143 } { loc D 0 } }
+    T{ ##peek { dst 141 } { loc R 0 } }
+    T{ ##peek { dst 143 } { loc D 0 } }
     T{ ##set-slot-imm
-        { src V int-regs 143 }
-        { obj V int-regs 141 }
+        { src 143 }
+        { obj 141 }
         { slot 2 }
         { tag 7 }
     }
     T{ ##write-barrier
-        { src V int-regs 141 }
-        { card# V int-regs 145 }
-        { table V int-regs 146 }
+        { src 141 }
+        { card# 145 }
+        { table 146 }
     }
     T{ ##inc-d { n -1 } }
     T{ ##inc-r { n -1 } }
-    T{ ##peek { dst V int-regs 156 } { loc D 2 } }
-    T{ ##peek { dst V int-regs 158 } { loc D 3 } }
-    T{ ##peek { dst V int-regs 160 } { loc D 0 } }
-    T{ ##peek { dst V int-regs 162 } { loc D 1 } }
-    T{ ##peek { dst V int-regs 164 } { loc D 4 } }
-    T{ ##peek { dst V int-regs 167 } { loc R 0 } }
-    T{ ##copy { dst V int-regs 157 } { src V int-regs 156 } }
-    T{ ##copy { dst V int-regs 159 } { src V int-regs 158 } }
-    T{ ##copy { dst V int-regs 161 } { src V int-regs 160 } }
-    T{ ##copy { dst V int-regs 163 } { src V int-regs 162 } }
-    T{ ##copy { dst V int-regs 165 } { src V int-regs 164 } }
-    T{ ##copy { dst V int-regs 168 } { src V int-regs 167 } }
+    T{ ##peek { dst 156 } { loc D 2 } }
+    T{ ##peek { dst 158 } { loc D 3 } }
+    T{ ##peek { dst 160 } { loc D 0 } }
+    T{ ##peek { dst 162 } { loc D 1 } }
+    T{ ##peek { dst 164 } { loc D 4 } }
+    T{ ##peek { dst 167 } { loc R 0 } }
+    T{ ##copy { dst 157 } { src 156 } }
+    T{ ##copy { dst 159 } { src 158 } }
+    T{ ##copy { dst 161 } { src 160 } }
+    T{ ##copy { dst 163 } { src 162 } }
+    T{ ##copy { dst 165 } { src 164 } }
+    T{ ##copy { dst 168 } { src 167 } }
     T{ ##branch }
 } 4 test-bb
 
 V{
     T{ ##inc-d { n 3 } }
     T{ ##inc-r { n 1 } }
-    T{ ##copy { dst V int-regs 157 } { src V int-regs 85 } }
-    T{ ##copy { dst V int-regs 159 } { src V int-regs 89 } }
-    T{ ##copy { dst V int-regs 161 } { src V int-regs 85 } }
-    T{ ##copy { dst V int-regs 163 } { src V int-regs 109 } }
-    T{ ##copy { dst V int-regs 165 } { src V int-regs 91 } }
-    T{ ##copy { dst V int-regs 168 } { src V int-regs 96 } }
+    T{ ##copy { dst 157 } { src 85 } }
+    T{ ##copy { dst 159 } { src 89 } }
+    T{ ##copy { dst 161 } { src 85 } }
+    T{ ##copy { dst 163 } { src 109 } }
+    T{ ##copy { dst 165 } { src 91 } }
+    T{ ##copy { dst 168 } { src 96 } }
     T{ ##branch }
 } 5 test-bb
 
 V{
     T{ ##set-slot-imm
-        { src V int-regs 163 }
-        { obj V int-regs 161 }
+        { src 163 }
+        { obj 161 }
         { slot 3 }
         { tag 7 }
     }
     T{ ##inc-d { n 1 } }
     T{ ##inc-r { n -1 } }
-    T{ ##replace { src V int-regs 168 } { loc D 0 } }
-    T{ ##replace { src V int-regs 157 } { loc D 3 } }
-    T{ ##replace { src V int-regs 159 } { loc D 4 } }
-    T{ ##replace { src V int-regs 161 } { loc D 1 } }
-    T{ ##replace { src V int-regs 163 } { loc D 2 } }
-    T{ ##replace { src V int-regs 165 } { loc D 5 } }
+    T{ ##replace { src 168 } { loc D 0 } }
+    T{ ##replace { src 157 } { loc D 3 } }
+    T{ ##replace { src 159 } { loc D 4 } }
+    T{ ##replace { src 161 } { loc D 1 } }
+    T{ ##replace { src 163 } { loc D 2 } }
+    T{ ##replace { src 165 } { loc D 5 } }
     T{ ##epilogue }
     T{ ##return }
 } 6 test-bb
@@ -2297,22 +1359,22 @@ V{
 V{ T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##compare-imm-branch f V int-regs 0 5 cc= }
+    T{ ##peek f 0 D 0 }
+    T{ ##compare-imm-branch f 0 5 cc= }
 } 1 test-bb
 
 V{ T{ ##branch } } 2 test-bb
 
 V{
-    T{ ##peek f V int-regs 1 D 0 }
-    T{ ##peek f V int-regs 2 D 0 }
-    T{ ##replace f V int-regs 1 D 0 }
-    T{ ##replace f V int-regs 2 D 0 }
+    T{ ##peek f 1 D 0 }
+    T{ ##peek f 2 D 0 }
+    T{ ##replace f 1 D 0 }
+    T{ ##replace f 2 D 0 }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 4 test-bb
 
@@ -2332,16 +1394,16 @@ test-diamond
 V{ T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##compare-imm-branch f V int-regs 0 5 cc= }
+    T{ ##peek f 0 D 0 }
+    T{ ##compare-imm-branch f 0 5 cc= }
 } 1 test-bb
 
 V{
-    T{ ##peek f V int-regs 1 D 0 }
-    T{ ##peek f V int-regs 2 D 0 }
-    T{ ##replace f V int-regs 1 D 0 }
-    T{ ##replace f V int-regs 2 D 0 }
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##peek f 1 D 0 }
+    T{ ##peek f 2 D 0 }
+    T{ ##replace f 1 D 0 }
+    T{ ##replace f 2 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##branch }
 } 2 test-bb
 
@@ -2350,7 +1412,7 @@ V{
 } 3 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 4 test-bb
 
@@ -2368,52 +1430,20 @@ test-diamond
 
 [ 0 ] [ 4 get instructions>> [ _reload? ] count ] unit-test
 
-! GC check tests
-
-! Spill slot liveness was computed incorrectly, leading to a FEP
-! early in bootstrap on x86-32
-[ t ] [
-    [
-        T{ basic-block
-           { id 12345 }
-           { instructions
-             V{
-                 T{ ##gc f V int-regs 6 V int-regs 7 }
-                 T{ ##peek f V int-regs 0 D 0 }
-                 T{ ##peek f V int-regs 1 D 1 }
-                 T{ ##peek f V int-regs 2 D 2 }
-                 T{ ##peek f V int-regs 3 D 3 }
-                 T{ ##peek f V int-regs 4 D 4 }
-                 T{ ##peek f V int-regs 5 D 5 }
-                 T{ ##replace f V int-regs 0 D 1 }
-                 T{ ##replace f V int-regs 1 D 2 }
-                 T{ ##replace f V int-regs 2 D 3 }
-                 T{ ##replace f V int-regs 3 D 4 }
-                 T{ ##replace f V int-regs 4 D 5 }
-                 T{ ##replace f V int-regs 5 D 0 }
-             }
-           }
-        } cfg new over >>entry
-        { { int-regs V{ 0 1 2 3 } } } (linear-scan)
-        instructions>> first
-        live-values>> assoc-empty?
-    ] with-scope
-] unit-test
-
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##replace f V int-regs 1 D 1 }
+    T{ ##peek f 0 D 0 }
+    T{ ##peek f 1 D 1 }
+    T{ ##replace f 1 D 1 }
     T{ ##branch }
 } 0 test-bb
 
 V{
-    T{ ##gc f V int-regs 2 V int-regs 3 }
+    T{ ##gc f 2 3 }
     T{ ##branch }
 } 1 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 2 test-bb
 
@@ -2422,19 +1452,17 @@ V{
 
 [ ] [ { 1 2 3 } test-linear-scan-on-cfg ] unit-test
 
-[ H{ { V int-regs 0 3 } } ] [ 1 get instructions>> first live-values>> ] unit-test
-
-
+[ { 3 } ] [ 1 get instructions>> first tagged-values>> ] unit-test
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##compare-imm-branch f V int-regs 1 5 cc= }
+    T{ ##peek f 0 D 0 }
+    T{ ##peek f 1 D 1 }
+    T{ ##compare-imm-branch f 1 5 cc= }
 } 0 test-bb
 
 V{
-    T{ ##gc f V int-regs 2 V int-regs 3 }
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##gc f 2 3 }
+    T{ ##replace f 0 D 0 }
     T{ ##return }
 } 1 test-bb
 
@@ -2446,4 +1474,4 @@ V{
 
 [ ] [ { 1 2 3 } test-linear-scan-on-cfg ] unit-test
 
-[ H{ { V int-regs 0 3 } } ] [ 1 get instructions>> first live-values>> ] unit-test
+[ { 3 } ] [ 1 get instructions>> first tagged-values>> ] unit-test
index 51b2f6db1b19362b1d16db4f57e3ea3052b2baec..5e723f098a06dcbd9f8c7a5f675179c8864d6210 100644 (file)
@@ -5,6 +5,7 @@ cpu.architecture
 compiler.cfg
 compiler.cfg.rpo
 compiler.cfg.liveness
+compiler.cfg.registers
 compiler.cfg.instructions
 compiler.cfg.linear-scan.numbering
 compiler.cfg.linear-scan.live-intervals
@@ -37,8 +38,4 @@ IN: compiler.cfg.linear-scan
     cfg check-numbering ;
 
 : linear-scan ( cfg -- cfg' )
-    [
-        dup machine-registers (linear-scan)
-        spill-counts get >>spill-counts
-        cfg-changed
-    ] with-scope ;
+    dup machine-registers (linear-scan) ;
index 48bef197e62b2284ae55ec576a420296369a03c9..2301d26f8069a23ac8a42eff0ab8d4f927530ae1 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces kernel assocs accessors sequences math math.order fry
 combinators binary-search compiler.cfg.instructions compiler.cfg.registers
-compiler.cfg.def-use compiler.cfg.liveness compiler.cfg.rpo
+compiler.cfg.def-use compiler.cfg.liveness compiler.cfg.linearization.order
 compiler.cfg ;
 IN: compiler.cfg.linear-scan.live-intervals
 
@@ -13,8 +13,7 @@ C: <live-range> live-range
 TUPLE: live-interval
 vreg
 reg spill-to reload-from
-start end ranges uses
-copy-from ;
+start end ranges uses ;
 
 GENERIC: covers? ( insn# obj -- ? )
 
@@ -102,15 +101,6 @@ M: vreg-insn compute-live-intervals*
     [ [ temp-vregs ] 2dip '[ [ _ ] dip _ handle-temp ] each ]
     3tri ;
 
-: record-copy ( insn -- )
-    [ dst>> live-intervals get at ] [ src>> ] bi >>copy-from drop ;
-
-M: ##copy compute-live-intervals*
-    [ call-next-method ] [ record-copy ] bi ;
-
-M: ##copy-float compute-live-intervals*
-    [ call-next-method ] [ record-copy ] bi ;
-
 : handle-live-out ( bb -- )
     live-out keys
     basic-block get [ block-from ] [ block-to ] bi
@@ -147,7 +137,8 @@ ERROR: bad-live-interval live-interval ;
 : compute-live-intervals ( cfg -- live-intervals )
     H{ } clone [
         live-intervals set
-        post-order [ compute-live-intervals-step ] each
+        linearization-order <reversed>
+        [ compute-live-intervals-step ] each
     ] keep values dup finish-live-intervals ;
 
 : relevant-ranges ( interval1 interval2 -- ranges1 ranges2 )
index 2976680857140e49aae8608322f8733edc995123..6fd97c64dad30f66d915b633e757901543cbf577 100644 (file)
@@ -1,15 +1,15 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors math sequences grouping namespaces
-compiler.cfg.rpo ;
+compiler.cfg.linearization.order ;
 IN: compiler.cfg.linear-scan.numbering
 
 : number-instructions ( rpo -- )
-    [ 0 ] dip [
+    linearization-order 0 [
         instructions>> [
             [ (>>insn#) ] [ drop 2 + ] 2bi
         ] each
-    ] each-basic-block drop ;
+    ] reduce drop ;
 
 SYMBOL: check-numbering?
 
@@ -20,4 +20,5 @@ ERROR: bad-numbering bb ;
     [ drop ] [ bad-numbering ] if ;
 
 : check-numbering ( cfg -- )
-    check-numbering? get [ [ check-block-numbering ] each-basic-block ] [ drop ] if ;
\ No newline at end of file
+    check-numbering? get
+    [ linearization-order [ check-block-numbering ] each ] [ drop ] if ;
\ No newline at end of file
index ee3595dd065a598f740f4abd8c54e22f7c6874ba..47c1f0ae76e673c6bc0b211708494cd933bf33e7 100644 (file)
@@ -1,65 +1,67 @@
-IN: compiler.cfg.linear-scan.resolve.tests
 USING: compiler.cfg.linear-scan.resolve tools.test kernel namespaces
+accessors
+compiler.cfg
 compiler.cfg.instructions cpu.architecture make sequences
 compiler.cfg.linear-scan.allocation.state ;
+IN: compiler.cfg.linear-scan.resolve.tests
 
 [
     {
-        { { T{ spill-slot f 0 } int-regs } { 1 int-regs } }
+        { { T{ spill-slot f 0 } int-rep } { 1 int-rep } }
     }
 ] [
     [
-        0 <spill-slot> 1 int-regs add-mapping
+        0 <spill-slot> 1 int-rep add-mapping
     ] { } make
 ] unit-test
 
 [
     {
-        T{ _reload { dst 1 } { class int-regs } { n 0 } }
+        T{ _reload { dst 1 } { rep int-rep } { n 0 } }
     }
 ] [
     [
-        { T{ spill-slot f 0 } int-regs } { 1 int-regs } >insn
+        { T{ spill-slot f 0 } int-rep } { 1 int-rep } >insn
     ] { } make
 ] unit-test
 
 [
     {
-        T{ _spill { src 1 } { class int-regs } { n 0 } }
+        T{ _spill { src 1 } { rep int-rep } { n 0 } }
     }
 ] [
     [
-        { 1 int-regs } { T{ spill-slot f 0 } int-regs } >insn
+        { 1 int-rep } { T{ spill-slot f 0 } int-rep } >insn
     ] { } make
 ] unit-test
 
 [
     {
-        T{ _copy { src 1 } { dst 2 } { class int-regs } }
+        T{ ##copy { src 1 } { dst 2 } { rep int-rep } }
     }
 ] [
     [
-        { 1 int-regs } { 2 int-regs } >insn
+        { 1 int-rep } { 2 int-rep } >insn
     ] { } make
 ] unit-test
 
-H{ { int-regs 10 } { float-regs 20 } } clone spill-counts set
+cfg new 8 >>spill-area-size cfg set
 H{ } clone spill-temps set
 
 [
     t
 ] [
-    { { { 0 int-regs } { 1 int-regs } } { { 1 int-regs } { 0 int-regs } } }
+    { { { 0 int-rep } { 1 int-rep } } { { 1 int-rep } { 0 int-rep } } }
     mapping-instructions {
         {
-            T{ _spill { src 0 } { class int-regs } { n 10 } }
-            T{ _copy { dst 0 } { src 1 } { class int-regs } }
-            T{ _reload { dst 1 } { class int-regs } { n 10 } }
+            T{ _spill { src 0 } { rep int-rep } { n 8 } }
+            T{ ##copy { dst 0 } { src 1 } { rep int-rep } }
+            T{ _reload { dst 1 } { rep int-rep } { n 8 } }
         }
         {
-            T{ _spill { src 1 } { class int-regs } { n 10 } }
-            T{ _copy { dst 1 } { src 0 } { class int-regs } }
-            T{ _reload { dst 0 } { class int-regs } { n 10 } }
+            T{ _spill { src 1 } { rep int-rep } { n 8 } }
+            T{ ##copy { dst 1 } { src 0 } { rep int-rep } }
+            T{ _reload { dst 0 } { rep int-rep } { n 8 } }
         }
     } member?
-] unit-test
\ No newline at end of file
+] unit-test
index b1fe1572cdaae94c8f9fa3c1776d6096f8a36d39..b45e2c959733ea8d789e8f884d3b361489338bff 100644 (file)
@@ -3,10 +3,13 @@
 USING: accessors arrays assocs combinators
 combinators.short-circuit fry kernel locals namespaces
 make math sequences hashtables
+compiler.cfg
 compiler.cfg.rpo
 compiler.cfg.liveness
+compiler.cfg.registers
 compiler.cfg.utilities
 compiler.cfg.instructions
+compiler.cfg.predecessors
 compiler.cfg.parallel-copy
 compiler.cfg.linear-scan.assignment
 compiler.cfg.linear-scan.allocation.state ;
@@ -14,16 +17,16 @@ IN: compiler.cfg.linear-scan.resolve
 
 SYMBOL: spill-temps
 
-: spill-temp ( reg-class -- n )
+: spill-temp ( rep -- n )
     spill-temps get [ next-spill-slot ] cache ;
 
-: add-mapping ( from to reg-class -- )
+: add-mapping ( from to rep -- )
     '[ _ 2array ] bi@ 2array , ;
 
 :: resolve-value-data-flow ( bb to vreg -- )
     vreg bb vreg-at-end
     vreg to vreg-at-start
-    2dup = [ 2drop ] [ vreg reg-class>> add-mapping ] if ;
+    2dup = [ 2drop ] [ vreg rep-of add-mapping ] if ;
 
 : compute-mappings ( bb to -- mappings )
     dup live-in dup assoc-empty? [ 3drop f ] [
@@ -43,7 +46,7 @@ SYMBOL: spill-temps
     drop [ first2 ] [ second spill-temp ] bi _spill ;
 
 : register->register ( from to -- )
-    swap [ first ] [ first2 ] bi* _copy ;
+    swap [ first ] [ first2 ] bi* ##copy ;
 
 SYMBOL: temp
 
@@ -62,8 +65,8 @@ SYMBOL: temp
 
 : perform-mappings ( bb to mappings -- )
     dup empty? [ 3drop ] [
-        mapping-instructions <simple-block>
-        insert-basic-block
+        mapping-instructions <simple-block> insert-basic-block
+        cfg get cfg-changed drop
     ] if ;
 
 : resolve-edge-data-flow ( bb to -- )
@@ -73,5 +76,7 @@ SYMBOL: temp
     dup successors>> [ resolve-edge-data-flow ] with each ;
 
 : resolve-data-flow ( cfg -- )
+    needs-predecessors
+
     H{ } clone spill-temps set
     [ resolve-block-data-flow ] each-basic-block ;
diff --git a/basis/compiler/cfg/linearization/linearization-tests.factor b/basis/compiler/cfg/linearization/linearization-tests.factor
deleted file mode 100644 (file)
index fe8b4fd..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: compiler.cfg.linearization.tests
-USING: compiler.cfg.linearization tools.test ;
-
-
index cbeb301901b12dc4dbf2425598c3301975af712f..32df6233bd49f54fd203b6930fbc358fd238cdb7 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math accessors sequences namespaces make
-combinators assocs arrays locals cpu.architecture
+combinators assocs arrays locals layouts hashtables
+cpu.architecture
 compiler.cfg
 compiler.cfg.comparisons
 compiler.cfg.stack-frame
@@ -10,6 +11,14 @@ compiler.cfg.utilities
 compiler.cfg.linearization.order ;
 IN: compiler.cfg.linearization
 
+<PRIVATE
+
+SYMBOL: numbers
+
+: block-number ( bb -- n ) numbers get at ;
+
+: number-blocks ( bbs -- ) [ 2array ] map-index >hashtable numbers set ;
+
 ! Convert CFG IR to machine IR.
 GENERIC: linearize-insn ( basic-block insn -- )
 
@@ -70,55 +79,32 @@ M: ##dispatch linearize-insn
     [ successors>> [ block-number _dispatch-label ] each ]
     bi* ;
 
-: (compute-gc-roots) ( n live-values -- n )
-    [
-        [ nip 2array , ]
-        [ drop reg-class>> reg-size + ]
-        3bi
-    ] assoc-each ;
-
-: oop-values ( regs -- regs' )
-    [ drop reg-class>> int-regs eq? ] assoc-filter ;
-
-: data-values ( regs -- regs' )
-    [ drop reg-class>> double-float-regs eq? ] assoc-filter ;
-
-: compute-gc-roots ( live-values -- alist )
-    [
-        [ 0 ] dip
-        ! we put float registers last; the GC doesn't actually scan them
-        [ oop-values (compute-gc-roots) ]
-        [ data-values (compute-gc-roots) ] bi
-        drop
-    ] { } make ;
-
-: count-gc-roots ( live-values -- n )
-    ! Size of GC root area, minus the float registers
-    oop-values assoc-size ;
+: gc-root-offsets ( registers -- alist )
+    ! Outputs a sequence of { offset register/spill-slot } pairs
+    [ length iota [ cell * ] map ] keep zip ;
 
 M: ##gc linearize-insn
     nip
     {
         [ temp1>> ]
         [ temp2>> ]
-        [
-            live-values>>
-            [ compute-gc-roots ]
-            [ count-gc-roots ]
-            [ gc-roots-size ]
-            tri
-        ]
+        [ data-values>> ]
+        [ tagged-values>> gc-root-offsets ]
         [ uninitialized-locs>> ]
     } cleave
     _gc ;
 
 : linearize-basic-blocks ( cfg -- insns )
     [
-        [ linearization-order [ linearize-basic-block ] each ]
-        [ spill-counts>> _spill-counts ]
-        bi
+        [
+            linearization-order
+            [ number-blocks ]
+            [ [ linearize-basic-block ] each ] bi
+        ] [ spill-area-size>> _spill-area-size ] bi
     ] { } make ;
 
+PRIVATE>
+        
 : flatten-cfg ( cfg -- mr )
     [ linearize-basic-blocks ] [ word>> ] [ label>> ] tri
     <mr> ;
index c09c2969bad0d35f8e083b414406a3d4f15ea5ae..703db8e5167c5d7f96dcd10987ba16d7e34068b9 100644 (file)
@@ -1,15 +1,16 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs deques dlists kernel make
+USING: accessors assocs deques dlists kernel make sorting
 namespaces sequences combinators combinators.short-circuit
-fry math sets compiler.cfg.rpo compiler.cfg.utilities ;
+fry math sets compiler.cfg.rpo compiler.cfg.utilities
+compiler.cfg.loop-detection ;
 IN: compiler.cfg.linearization.order
 
 ! This is RPO except loops are rotated. Based on SBCL's src/compiler/control.lisp
 
 <PRIVATE
 
-SYMBOLS: work-list loop-heads visited numbers next-number ;
+SYMBOLS: work-list loop-heads visited ;
 
 : visited? ( bb -- ? ) visited get key? ;
 
@@ -18,6 +19,11 @@ SYMBOLS: work-list loop-heads visited numbers next-number ;
         work-list get push-back
     ] if ;
 
+: init-linearization-order ( cfg -- )
+    <dlist> work-list set
+    H{ } clone visited set
+    entry>> add-to-work-list ;
+
 : (find-alternate-loop-head) ( bb -- bb' )
     dup {
         [ predecessor visited? not ]
@@ -46,28 +52,26 @@ SYMBOLS: work-list loop-heads visited numbers next-number ;
         add-to-work-list
     ] [ drop ] if ;
 
-: assign-number ( bb -- )
-    next-number [ get ] [ inc ] bi swap numbers get set-at ;
+: sorted-successors ( bb -- seq )
+    successors>> <reversed> [ loop-nesting-at ] sort-with ;
 
 : process-block ( bb -- )
-    {
-        [ , ]
-        [ assign-number ]
-        [ visited get conjoin ]
-        [ successors>> <reversed> [ process-successor ] each ]
-    } cleave ;
+    [ , ]
+    [ visited get conjoin ]
+    [ sorted-successors [ process-successor ] each ]
+    tri ;
+
+: (linearization-order) ( cfg -- bbs )
+    init-linearization-order
+
+    [ work-list get [ process-block ] slurp-deque ] { } make ;
 
 PRIVATE>
 
 : linearization-order ( cfg -- bbs )
-    ! We call 'post-order drop' to ensure blocks receive their
-    ! RPO numbers.
-    <dlist> work-list set
-    H{ } clone visited set
-    H{ } clone numbers set
-    0 next-number set
-    [ post-order drop ]
-    [ entry>> add-to-work-list ] bi
-    [ work-list get [ process-block ] slurp-deque ] { } make ;
+    needs-post-order needs-loops
 
-: block-number ( bb -- n ) numbers get at ;
+    dup linear-order>> [ ] [
+        dup (linearization-order)
+        >>linear-order linear-order>>
+    ] ?if ;
\ No newline at end of file
index 0bb5f85fa5e177ce8123c1a620927bef51564357..e4f5144e1f8a42122c229c922e9813ce7ce37112 100644 (file)
@@ -6,26 +6,25 @@ IN: compiler.cfg.liveness.tests
 
 : test-liveness ( -- )
     cfg new 1 get >>entry
-    compute-predecessors
     compute-live-sets ;
 
 ! Sanity check...
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 1 D 1 }
-    T{ ##peek f V int-regs 1 D 1 }
+    T{ ##peek f 0 D 0 }
+    T{ ##replace f 0 D 0 }
+    T{ ##replace f 1 D 1 }
+    T{ ##peek f 1 D 1 }
     T{ ##branch }
 } 1 test-bb
 
 V{
-    T{ ##replace f V int-regs 2 D 0 }
+    T{ ##replace f 2 D 0 }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 D 0 }
+    T{ ##replace f 3 D 0 }
     T{ ##return }
 } 3 test-bb
 
@@ -35,9 +34,9 @@ test-liveness
 
 [
     H{
-        { V int-regs 1 V int-regs 1 }
-        { V int-regs 2 V int-regs 2 }
-        { V int-regs 3 V int-regs 3 }
+        { 1 1 }
+        { 2 2 }
+        { 3 3 }
     }
 ]
 [ 1 get live-in ]
@@ -46,12 +45,12 @@ unit-test
 ! Tricky case; defs must be killed before uses
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
+    T{ ##peek f 0 D 0 }
     T{ ##branch }
 } 1 test-bb
 
 V{
-    T{ ##add-imm f V int-regs 0 V int-regs 0 10 }
+    T{ ##add-imm f 0 0 10 }
     T{ ##return }
 } 2 test-bb
 
@@ -59,4 +58,4 @@ V{
 
 test-liveness
 
-[ H{ { V int-regs 0 V int-regs 0 } } ] [ 2 get live-in ] unit-test
\ No newline at end of file
+[ H{ { 0 0 } } ] [ 2 get live-in ] unit-test
\ No newline at end of file
index 6c67769a45858b0580e68c792a569b79f8af7a08..a10b48cc0ce034332acc1dbda673ca6d11290b59 100644 (file)
@@ -28,4 +28,4 @@ M: live-analysis transfer-set
     drop instructions>> transfer-liveness ;
 
 M: live-analysis join-sets
-    drop assoc-combine ;
\ No newline at end of file
+    2drop assoc-combine ;
diff --git a/basis/compiler/cfg/liveness/ssa/ssa.factor b/basis/compiler/cfg/liveness/ssa/ssa.factor
new file mode 100644 (file)
index 0000000..81263c8
--- /dev/null
@@ -0,0 +1,62 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel namespaces deques accessors sets sequences assocs fry
+hashtables dlists compiler.cfg.def-use compiler.cfg.instructions
+compiler.cfg.rpo compiler.cfg.liveness compiler.cfg.utilities
+compiler.cfg.predecessors ;
+IN: compiler.cfg.liveness.ssa
+
+! TODO: merge with compiler.cfg.liveness
+
+! Assoc mapping basic blocks to sequences of sets of vregs; each sequence
+! is in correspondence with a predecessor
+SYMBOL: phi-live-ins
+
+: phi-live-in ( predecessor basic-block -- set ) phi-live-ins get at at ;
+
+SYMBOL: work-list
+
+: add-to-work-list ( basic-blocks -- )
+    work-list get '[ _ push-front ] each ;
+
+: compute-live-in ( basic-block -- live-in )
+    [ live-out ] keep instructions>> transfer-liveness ;
+
+: compute-phi-live-in ( basic-block -- phi-live-in )
+    H{ } clone [
+        '[ inputs>> [ swap _ conjoin-at ] assoc-each ] each-phi
+    ] keep ;
+
+: update-live-in ( basic-block -- changed? )
+    [ [ compute-live-in ] keep live-ins get maybe-set-at ]
+    [ [ compute-phi-live-in ] keep phi-live-ins get maybe-set-at ]
+    bi or ;
+
+: compute-live-out ( basic-block -- live-out )
+    [ successors>> [ live-in ] map ]
+    [ dup successors>> [ phi-live-in ] with map ] bi
+    append assoc-combine ;
+
+: update-live-out ( basic-block -- changed? )
+    [ compute-live-out ] keep
+    live-outs get maybe-set-at ;
+
+: liveness-step ( basic-block -- )
+    dup update-live-out [
+        dup update-live-in
+        [ predecessors>> add-to-work-list ] [ drop ] if
+    ] [ drop ] if ;
+
+: compute-ssa-live-sets ( cfg -- cfg' )
+    needs-predecessors
+
+    <hashed-dlist> work-list set
+    H{ } clone live-ins set
+    H{ } clone phi-live-ins set
+    H{ } clone live-outs set
+    dup post-order add-to-work-list
+    work-list get [ liveness-step ] slurp-deque ;
+
+: live-in? ( vreg bb -- ? ) live-in key? ;
+
+: live-out? ( vreg bb -- ? ) live-out key? ;
\ No newline at end of file
diff --git a/basis/compiler/cfg/loop-detection/loop-detection-tests.factor b/basis/compiler/cfg/loop-detection/loop-detection-tests.factor
new file mode 100644 (file)
index 0000000..80203c6
--- /dev/null
@@ -0,0 +1,20 @@
+USING: compiler.cfg compiler.cfg.loop-detection
+compiler.cfg.predecessors
+compiler.cfg.debugger
+tools.test kernel namespaces accessors ;
+IN: compiler.cfg.loop-detection.tests
+
+V{ } 0 test-bb
+V{ } 1 test-bb
+V{ } 2 test-bb
+
+0 { 1 2 } edges
+2 0 edge
+
+: test-loop-detection ( -- ) cfg new 0 get >>entry needs-loops drop ;
+
+[ ] [ test-loop-detection ] unit-test
+
+[ 1 ] [ 0 get loop-nesting-at ] unit-test
+[ 0 ] [ 1 get loop-nesting-at ] unit-test
+[ 1 ] [ 2 get loop-nesting-at ] unit-test
diff --git a/basis/compiler/cfg/loop-detection/loop-detection.factor b/basis/compiler/cfg/loop-detection/loop-detection.factor
new file mode 100644 (file)
index 0000000..dc70656
--- /dev/null
@@ -0,0 +1,83 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs combinators deques dlists fry kernel
+namespaces sequences sets compiler.cfg compiler.cfg.predecessors ;
+IN: compiler.cfg.loop-detection
+
+TUPLE: natural-loop header index ends blocks ;
+
+<PRIVATE
+
+SYMBOL: loops
+
+: <natural-loop> ( header index -- loop )
+    H{ } clone H{ } clone natural-loop boa ;
+
+: lookup-header ( header -- loop )
+    loops get [
+        loops get assoc-size <natural-loop>
+    ] cache ;
+
+SYMBOLS: visited active ;
+
+: record-back-edge ( from to -- )
+    lookup-header ends>> conjoin ;
+
+DEFER: find-loop-headers
+
+: visit-edge ( from to -- )
+    dup active get key?
+    [ record-back-edge ]
+    [ nip find-loop-headers ]
+    if ;
+
+: find-loop-headers ( bb -- )
+    dup visited get key? [ drop ] [
+        {
+            [ visited get conjoin ]
+            [ active get conjoin ]
+            [ dup successors>> [ visit-edge ] with each ]
+            [ active get delete-at ]
+        } cleave
+    ] if ;
+
+SYMBOL: work-list
+
+: process-loop-block ( bb loop -- )
+    2dup blocks>> key? [ 2drop ] [
+        [ blocks>> conjoin ] [
+            2dup header>> eq? [ 2drop ] [
+                drop predecessors>> work-list get push-all-front
+            ] if
+        ] 2bi
+    ] if ;
+
+: process-loop-ends ( loop -- )
+    [ ends>> keys <dlist> [ push-all-front ] [ work-list set ] [ ] tri ] keep
+    '[ _ process-loop-block ] slurp-deque ;
+
+: process-loop-headers ( -- )
+    loops get values [ process-loop-ends ] each ;
+
+SYMBOL: loop-nesting
+
+: compute-loop-nesting ( -- )
+    loops get H{ } clone [
+        [ values ] dip '[ blocks>> values [ _ inc-at ] each ] each
+    ] keep loop-nesting set ;
+
+: detect-loops ( cfg -- cfg' )
+    needs-predecessors
+    H{ } clone loops set
+    H{ } clone visited set
+    H{ } clone active set
+    H{ } clone loop-nesting set
+    dup entry>> find-loop-headers process-loop-headers compute-loop-nesting ;
+
+PRIVATE>
+
+: loop-nesting-at ( bb -- n ) loop-nesting get at 0 or ;
+
+: needs-loops ( cfg -- cfg' )
+    needs-predecessors
+    dup loops-valid?>> [ detect-loops t >>loops-valid? ] unless ;
\ No newline at end of file
index cb198d51498069facfe8b27456f2e1506899e28b..de679cbcc2e2ec0c0e9dc7f5168c86e12eb705a7 100644 (file)
@@ -1,12 +1,11 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: compiler.cfg.linearization compiler.cfg.two-operand
-compiler.cfg.gc-checks compiler.cfg.linear-scan
-compiler.cfg.build-stack-frame compiler.cfg.rpo ;
+USING: kernel namespaces accessors compiler.cfg
+compiler.cfg.linearization compiler.cfg.gc-checks
+compiler.cfg.linear-scan compiler.cfg.build-stack-frame ;
 IN: compiler.cfg.mr
 
 : build-mr ( cfg -- mr )
-    convert-two-operand
     insert-gc-checks
     linear-scan
     flatten-cfg
diff --git a/basis/compiler/cfg/optimizer/optimizer-tests.factor b/basis/compiler/cfg/optimizer/optimizer-tests.factor
deleted file mode 100755 (executable)
index e69de29..0000000
index 8e2df04ccaeb9a0eb083acaf68e4ecc01df22e00..649032b46936d958d214ea39a85fdfb5ed78d365 100644 (file)
@@ -11,10 +11,10 @@ compiler.cfg.value-numbering
 compiler.cfg.copy-prop
 compiler.cfg.dce
 compiler.cfg.write-barrier
+compiler.cfg.representations
+compiler.cfg.two-operand
 compiler.cfg.ssa.destruction
 compiler.cfg.empty-blocks
-compiler.cfg.predecessors
-compiler.cfg.rpo
 compiler.cfg.checker ;
 IN: compiler.cfg.optimizer
 
@@ -26,23 +26,18 @@ SYMBOL: check-optimizer?
     ] when ;
 
 : optimize-cfg ( cfg -- cfg' )
-    ! Note that compute-predecessors has to be called several times.
-    ! The passes that need this document it.
-    [
-        optimize-tail-calls
-        delete-useless-conditionals
-        compute-predecessors
-        split-branches
-        join-blocks
-        compute-predecessors
-        construct-ssa
-        alias-analysis
-        value-numbering
-        compute-predecessors
-        copy-propagation
-        eliminate-dead-code
-        eliminate-write-barriers
-        destruct-ssa
-        delete-empty-blocks
-        ?check
-    ] with-scope ;
+    optimize-tail-calls
+    delete-useless-conditionals
+    split-branches
+    join-blocks
+    construct-ssa
+    alias-analysis
+    value-numbering
+    copy-propagation
+    eliminate-dead-code
+    eliminate-write-barriers
+    select-representations
+    convert-two-operand
+    destruct-ssa
+    delete-empty-blocks
+    ?check ;
index 17b043c1b764d0f4c666bf50832e209373fdfcb0..66cc87beffb6e2032fb5c52563688d623b9e5d35 100644 (file)
@@ -11,53 +11,53 @@ SYMBOL: temp
 
 [
     {
-        T{ ##copy f V int-regs 4 V int-regs 2 }
-        T{ ##copy f V int-regs 2 V int-regs 1 }
-        T{ ##copy f V int-regs 1 V int-regs 4 }
+        T{ ##copy f 4 2 any-rep }
+        T{ ##copy f 2 1 any-rep }
+        T{ ##copy f 1 4 any-rep }
     }
 ] [
     H{
-        { V int-regs 1 V int-regs 2 }
-        { V int-regs 2 V int-regs 1 }
+        { 1 2 }
+        { 2 1 }
     } test-parallel-copy
 ] unit-test
 
 [
     {
-        T{ ##copy f V int-regs 1 V int-regs 2 }
-        T{ ##copy f V int-regs 3 V int-regs 4 }
+        T{ ##copy f 1 2 any-rep }
+        T{ ##copy f 3 4 any-rep }
     }
 ] [
     H{
-        { V int-regs 1 V int-regs 2 }
-        { V int-regs 3 V int-regs 4 }
+        { 1 2 }
+        { 3 4 }
     } test-parallel-copy
 ] unit-test
 
 [
     {
-        T{ ##copy f V int-regs 1 V int-regs 3 }
-        T{ ##copy f V int-regs 2 V int-regs 1 }
+        T{ ##copy f 1 3 any-rep }
+        T{ ##copy f 2 1 any-rep }
     }
 ] [
     H{
-        { V int-regs 1 V int-regs 3 }
-        { V int-regs 2 V int-regs 3 }
+        { 1 3 }
+        { 2 3 }
     } test-parallel-copy
 ] unit-test
 
 [
     {
-        T{ ##copy f V int-regs 4 V int-regs 3 }
-        T{ ##copy f V int-regs 3 V int-regs 2 }
-        T{ ##copy f V int-regs 2 V int-regs 1 }
-        T{ ##copy f V int-regs 1 V int-regs 4 }
+        T{ ##copy f 4 3 any-rep }
+        T{ ##copy f 3 2 any-rep }
+        T{ ##copy f 2 1 any-rep }
+        T{ ##copy f 1 4 any-rep }
     }
 ] [
     {
-        { V int-regs 2 V int-regs 1 }
-        { V int-regs 3 V int-regs 2 }
-        { V int-regs 1 V int-regs 3 }
-        { V int-regs 4 V int-regs 3 }
+        { 2 1 }
+        { 3 2 }
+        { 1 3 }
+        { 4 3 }
     } test-parallel-copy
 ] unit-test
\ No newline at end of file
index 5a1bfcd111dd15e3e06697f4c7b65e1fde2cc478..ef4bada633508e2a3bce4261d8d0011f38e465b5 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs compiler.cfg.hats compiler.cfg.instructions
-deques dlists fry kernel locals namespaces sequences
-hashtables ;
+USING: assocs cpu.architecture compiler.cfg.registers
+compiler.cfg.instructions deques dlists fry kernel locals namespaces
+sequences hashtables ;
 IN: compiler.cfg.parallel-copy
 
 ! Revisiting Out-of-SSA Translation for Correctness, Code Quality, and Efficiency
@@ -57,4 +57,5 @@ PRIVATE>
         ] slurp-deque
     ] with-scope ; inline
 
-: parallel-copy ( mapping -- ) i [ ##copy ] parallel-mapping ;
\ No newline at end of file
+: parallel-copy ( mapping -- )
+    next-vreg [ any-rep ##copy ] parallel-mapping ;
\ No newline at end of file
index c972197dd8459e22d6e76b16f0c678fc59aba0d0..8ab9f316a726c357945f2a59da4f3a679d778911 100644 (file)
@@ -4,6 +4,8 @@ USING: kernel accessors combinators fry sequences assocs compiler.cfg.rpo
 compiler.cfg.instructions compiler.cfg.utilities ;
 IN: compiler.cfg.predecessors
 
+<PRIVATE
+
 : update-predecessors ( bb -- )
     dup successors>> [ predecessors>> push ] with each ;
 
@@ -23,3 +25,9 @@ IN: compiler.cfg.predecessors
         [ [ update-phis ] each-basic-block ]
         [ ]
     } cleave ;
+
+PRIVATE>
+
+: needs-predecessors ( cfg -- cfg' )
+    dup predecessors-valid?>>
+    [ compute-predecessors t >>predecessors-valid? ] unless ;
\ No newline at end of file
index c5b39071534d303cffa7f16455e9b9ba78e1d64b..0d518735afb337dcd004acca4a297ebc9b5e4f79 100644 (file)
@@ -1,18 +1,32 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors namespaces kernel arrays parser math math.order ;
+USING: accessors namespaces kernel parser assocs ;
 IN: compiler.cfg.registers
 
-! Virtual registers, used by CFG and machine IRs
-TUPLE: vreg { reg-class read-only } { n fixnum read-only } ;
+! Virtual registers, used by CFG and machine IRs, are just integers
+SYMBOL: vreg-counter
 
-M: vreg equal? over vreg? [ [ n>> ] bi@ eq? ] [ 2drop f ] if ;
+: next-vreg ( -- vreg )
+    ! This word cannot be called AFTER representation selection has run;
+    ! use next-vreg-rep in that case
+    \ vreg-counter counter ;
 
-M: vreg hashcode* nip n>> ;
+SYMBOL: representations
 
-SYMBOL: vreg-counter
+ERROR: bad-vreg vreg ;
+
+: rep-of ( vreg -- rep )
+    ! This word cannot be called BEFORE representation selection has run;
+    ! use any-rep for ##copy instructions and so on
+    representations get ?at [ bad-vreg ] unless ;
+
+: set-rep-of ( rep vreg -- )
+    representations get set-at ;
 
-: next-vreg ( reg-class -- vreg ) \ vreg-counter counter vreg boa ;
+: next-vreg-rep ( rep -- vreg )
+    ! This word cannot be called BEFORE representation selection has run;
+    ! use next-vreg in that case
+    next-vreg [ set-rep-of ] keep ;
 
 ! Stack locations -- 'n' is an index starting from the top of the stack
 ! going down. So 0 is the top of the stack, 1 is what would be the top
@@ -28,6 +42,5 @@ C: <ds-loc> ds-loc
 TUPLE: rs-loc < loc ;
 C: <rs-loc> rs-loc
 
-SYNTAX: V scan-word scan-word vreg boa parsed ;
 SYNTAX: D scan-word <ds-loc> parsed ;
 SYNTAX: R scan-word <rs-loc> parsed ;
index 3d032f75102443677d9057504877dbcb043f6355..92a69547866b64a0d2783041b7395b3d58de997a 100644 (file)
@@ -10,7 +10,4 @@ SYMBOL: renamings
 : rename-value ( vreg -- vreg' )
     renamings get ?at drop ;
 
-: fresh-value ( vreg -- vreg' )
-    reg-class>> next-vreg ;
-
-RENAMING: rename [ rename-value ] [ rename-value ] [ fresh-value ]
+RENAMING: rename [ rename-value ] [ rename-value ] [ drop next-vreg ]
diff --git a/basis/compiler/cfg/representations/preferred/preferred.factor b/basis/compiler/cfg/representations/preferred/preferred.factor
new file mode 100644 (file)
index 0000000..e9ec7e8
--- /dev/null
@@ -0,0 +1,83 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors sequences arrays fry namespaces
+cpu.architecture compiler.cfg.utilities compiler.cfg compiler.cfg.rpo
+compiler.cfg.instructions compiler.cfg.def-use ;
+IN: compiler.cfg.representations.preferred
+
+GENERIC: defs-vreg-rep ( insn -- rep/f )
+GENERIC: temp-vreg-reps ( insn -- reps )
+GENERIC: uses-vreg-reps ( insn -- reps )
+
+M: ##flushable defs-vreg-rep drop int-rep ;
+M: ##copy defs-vreg-rep rep>> ;
+M: output-float-insn defs-vreg-rep drop double-float-rep ;
+M: ##fixnum-overflow defs-vreg-rep drop int-rep ;
+M: _fixnum-overflow defs-vreg-rep drop int-rep ;
+M: ##phi defs-vreg-rep drop "##phi must be special-cased" throw ;
+M: insn defs-vreg-rep drop f ;
+
+M: ##write-barrier temp-vreg-reps drop { int-rep int-rep } ;
+M: ##unary/temp temp-vreg-reps drop { int-rep } ;
+M: ##allot temp-vreg-reps drop { int-rep } ;
+M: ##dispatch temp-vreg-reps drop { int-rep } ;
+M: ##slot temp-vreg-reps drop { int-rep } ;
+M: ##set-slot temp-vreg-reps drop { int-rep } ;
+M: ##string-nth temp-vreg-reps drop { int-rep } ;
+M: ##set-string-nth-fast temp-vreg-reps drop { int-rep } ;
+M: ##compare temp-vreg-reps drop { int-rep } ;
+M: ##compare-imm temp-vreg-reps drop { int-rep } ;
+M: ##compare-float temp-vreg-reps drop { int-rep } ;
+M: ##gc temp-vreg-reps drop { int-rep int-rep } ;
+M: _dispatch temp-vreg-reps drop { int-rep } ;
+M: insn temp-vreg-reps drop f ;
+
+M: ##copy uses-vreg-reps rep>> 1array ;
+M: ##unary uses-vreg-reps drop { int-rep } ;
+M: ##unary-float uses-vreg-reps drop { double-float-rep } ;
+M: ##binary uses-vreg-reps drop { int-rep int-rep } ;
+M: ##binary-imm uses-vreg-reps drop { int-rep } ;
+M: ##binary-float uses-vreg-reps drop { double-float-rep double-float-rep } ;
+M: ##effect uses-vreg-reps drop { int-rep } ;
+M: ##slot uses-vreg-reps drop { int-rep int-rep } ;
+M: ##slot-imm uses-vreg-reps drop { int-rep } ;
+M: ##set-slot uses-vreg-reps drop { int-rep int-rep int-rep } ;
+M: ##set-slot-imm uses-vreg-reps drop { int-rep int-rep } ;
+M: ##string-nth uses-vreg-reps drop { int-rep int-rep } ;
+M: ##set-string-nth-fast uses-vreg-reps drop { int-rep int-rep int-rep } ;
+M: ##compare-branch uses-vreg-reps drop { int-rep int-rep } ;
+M: ##compare-imm-branch uses-vreg-reps drop { int-rep } ;
+M: ##compare-float-branch uses-vreg-reps drop { double-float-rep double-float-rep } ;
+M: ##dispatch uses-vreg-reps drop { int-rep } ;
+M: ##alien-getter uses-vreg-reps drop { int-rep } ;
+M: ##alien-setter uses-vreg-reps drop { int-rep int-rep } ;
+M: ##set-alien-float uses-vreg-reps drop { int-rep double-float-rep } ;
+M: ##set-alien-double uses-vreg-reps drop { int-rep double-float-rep } ;
+M: ##fixnum-overflow uses-vreg-reps drop { int-rep int-rep } ;
+M: _compare-imm-branch uses-vreg-reps drop { int-rep } ;
+M: _compare-branch uses-vreg-reps drop { int-rep int-rep } ;
+M: _compare-float-branch uses-vreg-reps drop { double-float-rep double-float-rep } ;
+M: _dispatch uses-vreg-reps drop { int-rep } ;
+M: ##phi uses-vreg-reps drop "##phi must be special-cased" throw ;
+M: insn uses-vreg-reps drop f ;
+
+: 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 -- ) -- )
+    [ [ uses-vregs ] [ uses-vreg-reps ] bi ] dip 2each ; inline
+
+: 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 -- ) -- )
+    '[
+        [ basic-block set ] [
+            [
+                _
+                [ each-def-rep ]
+                [ each-use-rep ]
+                [ each-temp-rep ] 2tri
+            ] each-non-phi
+        ] bi
+    ] each-basic-block ; inline
diff --git a/basis/compiler/cfg/representations/representations-tests.factor b/basis/compiler/cfg/representations/representations-tests.factor
new file mode 100644 (file)
index 0000000..29f0fa0
--- /dev/null
@@ -0,0 +1,19 @@
+USING: tools.test cpu.architecture
+compiler.cfg.registers compiler.cfg.instructions
+compiler.cfg.representations.preferred ;
+IN: compiler.cfg.representations
+
+[ { double-float-rep double-float-rep } ] [
+    T{ ##add-float
+       { dst 5 }
+       { src1 3 }
+       { src2 4 }
+    } uses-vreg-reps
+] unit-test
+
+[ double-float-rep ] [
+    T{ ##alien-double
+       { dst 5 }
+       { src 3 }
+    } defs-vreg-rep
+] unit-test
\ No newline at end of file
diff --git a/basis/compiler/cfg/representations/representations.factor b/basis/compiler/cfg/representations/representations.factor
new file mode 100644 (file)
index 0000000..cb98eb0
--- /dev/null
@@ -0,0 +1,229 @@
+! Copyright (C) 2009 Slava Pestov
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel fry accessors sequences assocs sets namespaces
+arrays combinators make locals deques dlists
+cpu.architecture compiler.utilities
+compiler.cfg
+compiler.cfg.rpo
+compiler.cfg.registers
+compiler.cfg.instructions
+compiler.cfg.def-use
+compiler.cfg.utilities
+compiler.cfg.loop-detection
+compiler.cfg.renaming.functor
+compiler.cfg.representations.preferred ;
+IN: compiler.cfg.representations
+
+! Virtual register representation selection.
+
+: emit-conversion ( dst src dst-rep src-rep -- )
+    2array {
+        { { int-rep int-rep } [ int-rep ##copy ] }
+        { { double-float-rep double-float-rep } [ double-float-rep ##copy ] }
+        { { double-float-rep int-rep } [ ##unbox-float ] }
+        { { int-rep double-float-rep } [ int-rep next-vreg-rep ##box-float ] }
+    } case ;
+
+<PRIVATE
+
+! For every vreg, compute possible representations.
+SYMBOL: possibilities
+
+: possible ( vreg -- reps ) possibilities get at ;
+
+: compute-possibilities ( cfg -- )
+    H{ } clone [ '[ swap _ conjoin-at ] with-vreg-reps ] keep
+    [ keys ] assoc-map possibilities set ;
+
+! Compute vregs which must remain tagged for their lifetime.
+SYMBOL: always-boxed
+
+:: (compute-always-boxed) ( vreg rep assoc -- )
+    rep int-rep eq? [
+        int-rep vreg assoc set-at
+    ] when ;
+
+: compute-always-boxed ( cfg -- assoc )
+    H{ } clone [
+        '[
+            [
+                dup ##load-reference? [ drop ] [
+                    [ _ (compute-always-boxed) ] each-def-rep
+                ] if
+            ] each-non-phi
+        ] each-basic-block
+    ] keep ;
+
+! For every vreg, compute the cost of keeping it in every possible
+! representation.
+
+! Cost map maps vreg to representation to cost.
+SYMBOL: costs
+
+: init-costs ( -- )
+    possibilities get [ [ 0 ] H{ } map>assoc ] assoc-map costs set ;
+
+: increase-cost ( rep vreg -- )
+    ! Increase cost of keeping vreg in rep, making a choice of rep less
+    ! likely.
+    [ basic-block get loop-nesting-at ] 2dip costs get at at+ ;
+
+: maybe-increase-cost ( possible vreg preferred -- )
+    pick eq? [ 2drop ] [ increase-cost ] if ;
+
+: representation-cost ( vreg preferred -- )
+    ! 'preferred' is a representation that the instruction can accept with no cost.
+    ! So, for each representation that's not preferred, increase the cost of keeping
+    ! the vreg in that representation.
+    [ drop possible ]
+    [ '[ _ _ maybe-increase-cost ] ]
+    2bi each ;
+
+: compute-costs ( cfg -- costs )
+    init-costs [ representation-cost ] with-vreg-reps costs get ;
+
+! For every vreg, compute preferred representation, that minimizes costs.
+: minimize-costs ( costs -- representations )
+    [ >alist alist-min first ] assoc-map ;
+
+: compute-representations ( cfg -- )
+    [ compute-costs minimize-costs ]
+    [ compute-always-boxed ]
+    bi assoc-union
+    representations set ;
+
+! Insert conversions. This introduces new temporaries, so we need
+! to rename opearands too.
+
+:: emit-def-conversion ( dst preferred required -- new-dst' )
+    ! If an instruction defines a register with representation 'required',
+    ! but the register has preferred representation 'preferred', then
+    ! we rename the instruction's definition to a new register, which
+    ! becomes the input of a conversion instruction.
+    dst required next-vreg-rep [ preferred required emit-conversion ] keep ;
+
+:: emit-use-conversion ( src preferred required -- new-src' )
+    ! If an instruction uses a register with representation 'required',
+    ! but the register has preferred representation 'preferred', then
+    ! we rename the instruction's input to a new register, which
+    ! becomes the output of a conversion instruction.
+    required next-vreg-rep [ src required preferred emit-conversion ] keep ;
+
+SYMBOLS: renaming-set needs-renaming? ;
+
+: init-renaming-set ( -- )
+    needs-renaming? off
+    V{ } clone renaming-set set ;
+
+: no-renaming ( vreg -- )
+    dup 2array renaming-set get push ;
+
+: record-renaming ( from to -- )
+    2array renaming-set get push needs-renaming? on ;
+
+:: (compute-renaming-set) ( vreg required quot: ( vreg preferred required -- ) -- )
+    vreg rep-of :> preferred
+    preferred required eq?
+    [ vreg no-renaming ]
+    [ vreg vreg preferred required quot call record-renaming ] if ; inline
+
+: compute-renaming-set ( insn -- )
+    ! temp vregs don't need conversions since they're always in their
+    ! preferred representation
+    init-renaming-set
+    [ [ [ emit-use-conversion ] (compute-renaming-set) ] each-use-rep ]
+    [ , ]
+    [ [ [ emit-def-conversion ] (compute-renaming-set) ] each-def-rep ]
+    tri ;
+
+: converted-value ( vreg -- vreg' )
+    renaming-set get pop first2 [ assert= ] dip ;
+
+RENAMING: convert [ converted-value ] [ converted-value ] [ ]
+
+: perform-renaming ( insn -- )
+    needs-renaming? get [
+        renaming-set get reverse-here
+        [ convert-insn-uses ] [ convert-insn-defs ] bi
+        renaming-set get length 0 assert=
+    ] [ drop ] if ;
+
+GENERIC: conversions-for-insn ( insn -- )
+
+SYMBOL: phi-mappings
+
+! compiler.cfg.cssa inserts conversions which convert phi inputs into
+!  the representation of the output. However, we still have to do some
+!  processing here, because if the only node that uses the output of
+!  the phi instruction is another phi instruction then this phi node's
+! output won't have a representation assigned.
+M: ##phi conversions-for-insn
+    [ , ] [ [ inputs>> values ] [ dst>> ] bi phi-mappings get set-at ] bi ;
+
+M: vreg-insn conversions-for-insn
+    [ compute-renaming-set ] [ perform-renaming ] bi ;
+
+M: insn conversions-for-insn , ;
+
+: conversions-for-block ( bb -- )
+    dup kill-block? [ drop ] [
+        [
+            [
+                [ conversions-for-insn ] each
+            ] V{ } make
+        ] change-instructions drop
+    ] if ;
+
+! If the output of a phi instruction is only used as the input to another
+! phi instruction, then we want to use the same representation for both
+! if possible.
+SYMBOL: work-list
+
+: add-to-work-list ( vregs -- )
+    work-list get push-all-front ;
+
+: rep-assigned ( vregs -- vregs' )
+    representations get '[ _ key? ] filter ;
+
+: rep-not-assigned ( vregs -- vregs' )
+    representations get '[ _ key? not ] filter ;
+
+: add-ready-phis ( -- )
+    phi-mappings get keys rep-assigned add-to-work-list ;
+
+: process-phi-mapping ( dst -- )
+    ! If dst = phi(src1,src2,...) and dst's representation has been
+    ! determined, assign that representation to each one of src1,...
+    ! that does not have a representation yet, and process those, too.
+    dup phi-mappings get at* [
+        [ rep-of ] [ rep-not-assigned ] bi*
+        [ [ set-rep-of ] with each ] [ add-to-work-list ] bi
+    ] [ 2drop ] if ;
+
+: remaining-phi-mappings ( -- )
+    phi-mappings get keys rep-not-assigned
+    [ [ int-rep ] dip set-rep-of ] each ;
+
+: process-phi-mappings ( -- )
+    <hashed-dlist> work-list set
+    add-ready-phis
+    work-list get [ process-phi-mapping ] slurp-deque
+    remaining-phi-mappings ;
+
+: insert-conversions ( cfg -- )
+    H{ } clone phi-mappings set
+    [ conversions-for-block ] each-basic-block
+    process-phi-mappings ;
+
+PRIVATE>
+
+: select-representations ( cfg -- cfg' )
+    needs-loops
+
+    {
+        [ compute-possibilities ]
+        [ compute-representations ]
+        [ insert-conversions ]
+        [ ]
+    } cleave
+    representations get cfg get (>>reps) ;
\ No newline at end of file
index 1ddacdf8abbab4ebc784d492ae57683fe46ce499..b6322730ee72bd2a80ff881a8e95f5e17dd0a901 100644 (file)
@@ -39,4 +39,7 @@ SYMBOL: visited
     [ change-instructions drop ] 2bi ; inline
 
 : local-optimization ( cfg quot: ( insns -- insns' ) -- cfg' )
-    dupd '[ _ optimize-basic-block ] each-basic-block ; inline
\ No newline at end of file
+    dupd '[ _ optimize-basic-block ] each-basic-block ; inline
+
+: needs-post-order ( cfg -- cfg' )
+    dup post-order drop ;
\ No newline at end of file
index e7ba5bbabacb3593445494c27704a1cc50464942..3d743176b139338df8a6ec33c432c3a5f5d03f35 100644 (file)
@@ -13,24 +13,24 @@ IN: compiler.cfg.ssa.construction.tests
 reset-counters
 
 V{
-    T{ ##load-immediate f V int-regs 1 100 }
-    T{ ##add-imm f V int-regs 2 V int-regs 1 50 }
-    T{ ##add-imm f V int-regs 2 V int-regs 2 10 }
+    T{ ##load-immediate f 1 100 }
+    T{ ##add-imm f 2 1 50 }
+    T{ ##add-imm f 2 2 10 }
     T{ ##branch }
 } 0 test-bb
 
 V{
-    T{ ##load-immediate f V int-regs 3 3 }
+    T{ ##load-immediate f 3 3 }
     T{ ##branch }
 } 1 test-bb
 
 V{
-    T{ ##load-immediate f V int-regs 3 4 }
+    T{ ##load-immediate f 3 4 }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 D 0 }
+    T{ ##replace f 3 D 0 }
     T{ ##return }
 } 3 test-bb
 
@@ -40,7 +40,7 @@ V{
 
 : test-ssa ( -- )
     cfg new 0 get >>entry
-    compute-predecessors
+    dup cfg set
     construct-ssa
     drop ;
 
@@ -48,23 +48,23 @@ V{
 
 [
     V{
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 1 50 }
-        T{ ##add-imm f V int-regs 3 V int-regs 2 10 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 1 50 }
+        T{ ##add-imm f 3 2 10 }
         T{ ##branch }
     }
 ] [ 0 get instructions>> ] unit-test
 
 [
     V{
-        T{ ##load-immediate f V int-regs 4 3 }
+        T{ ##load-immediate f 4 3 }
         T{ ##branch }
     }
 ] [ 1 get instructions>> ] unit-test
 
 [
     V{
-        T{ ##load-immediate f V int-regs 5 4 }
+        T{ ##load-immediate f 5 4 }
         T{ ##branch }
     }
 ] [ 2 get instructions>> ] unit-test
@@ -74,8 +74,8 @@ V{
 
 [
     V{
-        T{ ##phi f V int-regs 6 H{ { 1 V int-regs 4 } { 2 V int-regs 5 } } }
-        T{ ##replace f V int-regs 6 D 0 }
+        T{ ##phi f 6 H{ { 1 4 } { 2 5 } } }
+        T{ ##replace f 6 D 0 }
         T{ ##return }
     }
 ] [
@@ -87,9 +87,9 @@ reset-counters
 
 V{ } 0 test-bb
 V{ } 1 test-bb
-V{ T{ ##peek f V int-regs 0 D 0 } } 2 test-bb
-V{ T{ ##peek f V int-regs 0 D 0 } } 3 test-bb
-V{ T{ ##replace f V int-regs 0 D 0 } } 4 test-bb
+V{ T{ ##peek f 0 D 0 } } 2 test-bb
+V{ T{ ##peek f 0 D 0 } } 3 test-bb
+V{ T{ ##replace f 0 D 0 } } 4 test-bb
 V{ } 5 test-bb
 V{ } 6 test-bb
 
@@ -104,8 +104,8 @@ V{ } 6 test-bb
 
 [
     V{
-        T{ ##phi f V int-regs 3 H{ { 2 V int-regs 1 } { 3 V int-regs 2 } } }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##phi f 3 H{ { 2 1 } { 3 2 } } }
+        T{ ##replace f 3 D 0 }
     }
 ] [
     4 get instructions>>
index d2c7698999e7a39211e64aea3ce75c904e97f360..7662b8ab01093fd288fd340b5b998ed220a9fa2d 100644 (file)
@@ -9,12 +9,11 @@ compiler.cfg.liveness
 compiler.cfg.registers
 compiler.cfg.dominance
 compiler.cfg.instructions
+compiler.cfg.renaming
 compiler.cfg.renaming.functor
 compiler.cfg.ssa.construction.tdmsc ;
 IN: compiler.cfg.ssa.construction
 
-! SSA construction. Predecessors must be computed first.
-
 ! The phi placement algorithm is implemented in
 ! compiler.cfg.ssa.construction.tdmsc.
 
@@ -75,7 +74,7 @@ SYMBOLS: stacks pushed ;
     H{ } clone stacks set ;
 
 : gen-name ( vreg -- vreg' )
-    [ reg-class>> next-vreg dup ] keep
+    [ next-vreg dup ] dip
     dup pushed get 2dup key?
     [ 2drop stacks get at set-last ]
     [ conjoin stacks get push-at ]
@@ -131,10 +130,9 @@ PRIVATE>
 
 : construct-ssa ( cfg -- cfg' )
     {
-        [ ]
         [ compute-live-sets ]
-        [ compute-dominance ]
         [ compute-merge-sets ]
         [ compute-defs compute-phi-nodes insert-phi-nodes ]
         [ rename ]
+        [ ]
     } cleave ;
\ No newline at end of file
index 433dcfee64996742a9d15c42bc15582ea566d6a1..955d41814fe6e39f2b61169dc92ea1df83873f85 100644 (file)
@@ -5,9 +5,7 @@ tools.test vectors sets ;
 IN: compiler.cfg.ssa.construction.tdmsc.tests
 
 : test-tdmsc ( -- )
-    cfg new 0 get >>entry
-    compute-predecessors
-    dup compute-dominance
+    cfg new 0 get >>entry dup cfg set
     compute-merge-sets ;
 
 V{ } 0 test-bb
index 1c1abefe1bc4938fab1de77bddf212d74ec50510..647c97d6c3f3b0f3ecc61bb76c8471219140848c 100644 (file)
@@ -93,7 +93,8 @@ HINTS: filter-by { bit-array object } ;
 PRIVATE>
 
 : compute-merge-sets ( cfg -- )
-    dup cfg set
+    needs-dominance
+
     H{ } clone visited set
     [ compute-levels ]
     [ init-merge-sets ]
index 37fa790453210c77508861d616a5dc7b0872b720..14287e900f7a60539758f562e4d178eae845818d 100644 (file)
@@ -1,21 +1,25 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs kernel locals
+USING: accessors assocs kernel locals fry
+cpu.architecture
 compiler.cfg.rpo
-compiler.cfg.hats
 compiler.cfg.utilities
-compiler.cfg.instructions ;
+compiler.cfg.registers
+compiler.cfg.instructions
+compiler.cfg.representations ;
 IN: compiler.cfg.ssa.cssa
 
-! Convert SSA to conventional SSA.
+! Convert SSA to conventional SSA. This pass runs after representation
+! selection, so it must keep track of representations when introducing
+! new values.
 
-:: insert-copy ( bb src -- bb dst )
-    i :> dst
-    bb [ dst src ##copy ] add-instructions
+:: insert-copy ( bb src rep -- bb dst )
+    rep next-vreg-rep :> dst
+    bb [ dst src rep src rep-of emit-conversion ] add-instructions
     bb dst ;
 
 : convert-phi ( ##phi -- )
-    [ [ insert-copy ] assoc-map ] change-inputs drop ;
+    dup dst>> rep-of '[ [ _ insert-copy ] assoc-map ] change-inputs drop ;
 
 : construct-cssa ( cfg -- )
     [ [ convert-phi ] each-phi ] each-basic-block ;
\ No newline at end of file
index 535dc6db86e7feae129e535887a68273b4ad3ad5..424be91e2ba4850c86c78e43de76d06b42ea8e4b 100644 (file)
@@ -8,7 +8,7 @@ compiler.cfg.def-use
 compiler.cfg.renaming
 compiler.cfg.dominance
 compiler.cfg.instructions
-compiler.cfg.ssa.liveness
+compiler.cfg.liveness.ssa
 compiler.cfg.ssa.cssa
 compiler.cfg.ssa.interference
 compiler.cfg.ssa.interference.live-ranges
@@ -49,7 +49,9 @@ SYMBOL: copies
 : eliminate-copy ( vreg1 vreg2 -- )
     [ leader ] bi@
     2dup eq? [ 2drop ] [
-        [ update-leaders ] [ merge-classes ] 2bi
+        [ update-leaders ]
+        [ merge-classes ]
+        2bi
     ] if ;
 
 : introduce-vreg ( vreg -- )
@@ -95,13 +97,12 @@ M: insn prepare-insn drop ;
     ] each-basic-block ;
 
 : destruct-ssa ( cfg -- cfg' )
-    dup cfg-has-phis? [
-        dup construct-cssa
-        dup precompute-liveness
-        dup compute-defs
-        dup compute-dominance
-        dup compute-live-ranges
-        dup prepare-coalescing
-        process-copies
-        dup perform-renaming
-    ] when ;
+    needs-dominance
+
+    dup construct-cssa
+    dup compute-defs
+    compute-ssa-live-sets
+    dup compute-live-ranges
+    dup prepare-coalescing
+    process-copies
+    dup perform-renaming ;
\ No newline at end of file
index 9075d3b01098790df4c97f1c1f09c9b69e2c55a3..2f13331024c3a957baff7e1e1736c5124d9642d8 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors compiler.cfg compiler.cfg.debugger
 compiler.cfg.def-use compiler.cfg.dominance
-compiler.cfg.instructions compiler.cfg.ssa.liveness
+compiler.cfg.instructions compiler.cfg.liveness.ssa
 compiler.cfg.registers compiler.cfg.predecessors
 compiler.cfg.ssa.interference
 compiler.cfg.ssa.interference.live-ranges cpu.architecture
@@ -9,26 +9,24 @@ IN: compiler.cfg.ssa.interference.tests
 
 : test-interference ( -- )
     cfg new 0 get >>entry
-    compute-predecessors
-    dup precompute-liveness
+    compute-ssa-live-sets
     dup compute-defs
-    dup compute-dominance
     compute-live-ranges ;
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 2 D 0 }
-    T{ ##copy f V int-regs 1 V int-regs 0 }
-    T{ ##copy f V int-regs 3 V int-regs 2 }
+    T{ ##peek f 0 D 0 }
+    T{ ##peek f 2 D 0 }
+    T{ ##copy f 1 0 }
+    T{ ##copy f 3 2 }
     T{ ##branch }
 } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 4 D 0 }
-    T{ ##peek f V int-regs 5 D 0 }
-    T{ ##replace f V int-regs 3 D 0 }
-    T{ ##peek f V int-regs 6 D 0 }
-    T{ ##replace f V int-regs 5 D 0 }
+    T{ ##peek f 4 D 0 }
+    T{ ##peek f 5 D 0 }
+    T{ ##replace f 3 D 0 }
+    T{ ##peek f 6 D 0 }
+    T{ ##replace f 5 D 0 }
     T{ ##return }
 } 1 test-bb
 
@@ -36,17 +34,17 @@ V{
 
 [ ] [ test-interference ] unit-test
 
-[ f ] [ V int-regs 0 V int-regs 1 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 1 V int-regs 0 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 2 V int-regs 3 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 3 V int-regs 2 vregs-interfere? ] unit-test
-[ t ] [ V int-regs 0 V int-regs 2 vregs-interfere? ] unit-test
-[ t ] [ V int-regs 2 V int-regs 0 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 1 V int-regs 3 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 3 V int-regs 1 vregs-interfere? ] unit-test
-[ t ] [ V int-regs 3 V int-regs 4 vregs-interfere? ] unit-test
-[ t ] [ V int-regs 4 V int-regs 3 vregs-interfere? ] unit-test
-[ t ] [ V int-regs 3 V int-regs 5 vregs-interfere? ] unit-test
-[ t ] [ V int-regs 5 V int-regs 3 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 3 V int-regs 6 vregs-interfere? ] unit-test
-[ f ] [ V int-regs 6 V int-regs 3 vregs-interfere? ] unit-test
+[ f ] [ 0 1 vregs-interfere? ] unit-test
+[ f ] [ 1 0 vregs-interfere? ] unit-test
+[ f ] [ 2 3 vregs-interfere? ] unit-test
+[ f ] [ 3 2 vregs-interfere? ] unit-test
+[ t ] [ 0 2 vregs-interfere? ] unit-test
+[ t ] [ 2 0 vregs-interfere? ] unit-test
+[ f ] [ 1 3 vregs-interfere? ] unit-test
+[ f ] [ 3 1 vregs-interfere? ] unit-test
+[ t ] [ 3 4 vregs-interfere? ] unit-test
+[ t ] [ 4 3 vregs-interfere? ] unit-test
+[ t ] [ 3 5 vregs-interfere? ] unit-test
+[ t ] [ 5 3 vregs-interfere? ] unit-test
+[ f ] [ 3 6 vregs-interfere? ] unit-test
+[ f ] [ 6 3 vregs-interfere? ] unit-test
\ No newline at end of file
index f8553ec9de27eac9b5e7cd66fdbd8cb0569adb16..a76b55cd83dcc8fecd489af7f800e10d05ea85ae 100644 (file)
@@ -6,6 +6,11 @@ compiler.cfg.def-use compiler.cfg.dominance
 compiler.cfg.ssa.interference.live-ranges ;
 IN: compiler.cfg.ssa.interference
 
+! Interference testing using SSA properties. Actually the only SSA property
+! used here is that definitions dominate uses; because of this, the input
+! is allowed to have multiple definitions of each vreg as long as they're
+! all in the same basic block. This is needed because two-operand conversion
+! runs before coalescing, which uses SSA interference testing.
 <PRIVATE
 
 :: kill-after-def? ( vreg1 vreg2 bb -- ? )
@@ -47,9 +52,10 @@ PRIVATE>
         [ 2drop 2drop f ]
     } cond ;
 
-! Debug this stuff later
 <PRIVATE
 
+! Debug this stuff later
+
 : quadratic-test? ( seq1 seq2 -- ? ) [ length ] bi@ + 10 < ;
 
 : quadratic-test ( seq1 seq2 -- ? )
@@ -58,7 +64,7 @@ PRIVATE>
 : sort-vregs-by-bb ( vregs -- alist )
     defs get
     '[ dup _ at ] { } map>assoc
-    [ [ second pre-of ] compare ] sort ;
+    [ second pre-of ] sort-with ;
 
 : ?last ( seq -- elt/f ) [ f ] [ last ] if-empty ; inline
 
index c29b69cf36804b6d3e0f0c0d23ed249aa629cc87..fd1f09a900e4c9bb6f4fc4a6a17960bc87e74d83 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs fry kernel namespaces sequences math
 arrays compiler.cfg.def-use compiler.cfg.instructions
-compiler.cfg.ssa.liveness compiler.cfg.rpo ;
+compiler.cfg.liveness.ssa compiler.cfg.rpo compiler.cfg.dominance ;
 IN: compiler.cfg.ssa.interference.live-ranges
 
 ! Live ranges for interference testing
@@ -11,8 +11,13 @@ IN: compiler.cfg.ssa.interference.live-ranges
 
 SYMBOLS: local-def-indices local-kill-indices ;
 
-: record-def ( n vregs -- )
-    dup [ local-def-indices get set-at ] [ 2drop ] if ;
+: record-def ( n vreg -- )
+    ! We allow multiple defs of a vreg as long as they're
+    ! all in the same basic block
+    dup [
+        local-def-indices get 2dup key?
+        [ 3drop ] [ set-at ] if
+    ] [ 2drop ] if ;
 
 : record-uses ( n vregs -- )
     local-kill-indices get '[ _ set-at ] with each ;
@@ -42,6 +47,8 @@ SYMBOLS: def-indices kill-indices ;
 PRIVATE>
 
 : compute-live-ranges ( cfg -- )
+    needs-dominance
+
     H{ } clone def-indices set
     H{ } clone kill-indices set
     [ compute-local-live-ranges ] each-basic-block ;
index 137fa0371fed7475a167671344cf26aceb419521..bc5807087da7d95b60bd44805d4794251f9a5b15 100644 (file)
@@ -9,7 +9,9 @@ compiler.cfg.ssa.liveness
 compiler.cfg.debugger
 compiler.cfg.instructions
 compiler.cfg.predecessors
-compiler.cfg.registers ;
+compiler.cfg.registers
+compiler.cfg.dominance
+compiler.cfg.def-use ;
 IN: compiler.cfg.ssa.liveness
 
 [ t ] [ { 1 } 1 only? ] unit-test
@@ -17,138 +19,140 @@ IN: compiler.cfg.ssa.liveness
 [ f ] [ { 2 1 } 1 only? ] unit-test
 [ f ] [ { 2 } 1 only? ] unit-test
 
-V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 1 D 1 }
-} 1 test-bb
+: test-liveness ( -- )
+    cfg new 0 get >>entry
+    dup compute-defs
+    dup compute-uses
+    needs-dominance
+    precompute-liveness ;
 
 V{
-    T{ ##replace f V int-regs 2 D 0 }
-} 2 test-bb
+    T{ ##peek f 0 D 0 }
+    T{ ##replace f 0 D 0 }
+    T{ ##replace f 1 D 1 }
+} 0 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 D 0 }
-} 3 test-bb
+    T{ ##replace f 2 D 0 }
+} 1 test-bb
 
-1 { 2 3 } edges
+V{
+    T{ ##replace f 3 D 0 }
+} 2 test-bb
 
-cfg new 1 get >>entry 4 set
+0 { 1 2 } edges
 
-[ ] [ 4 get compute-predecessors drop ] unit-test
-[ ] [ 4 get precompute-liveness ] unit-test
+[ ] [ test-liveness ] unit-test
 
 [ H{ } ] [ back-edge-targets get ] unit-test
-[ H{ } ] [ phi-outs get ] unit-test
-[ t ] [ 1 get R_q { 1 2 3 } [ get ] map unique = ] unit-test
+[ t ] [ 0 get R_q { 0 1 2 } [ get ] map unique = ] unit-test
+[ t ] [ 1 get R_q { 1 } [ get ] map unique = ] unit-test
 [ t ] [ 2 get R_q { 2 } [ get ] map unique = ] unit-test
-[ t ] [ 3 get R_q { 3 } [ get ] map unique = ] unit-test
 
 : self-T_q ( n -- ? )
     get [ T_q ] [ 1array unique ] bi = ;
 
+[ t ] [ 0 self-T_q ] unit-test
 [ t ] [ 1 self-T_q ] unit-test
 [ t ] [ 2 self-T_q ] unit-test
-[ t ] [ 3 self-T_q ] unit-test
-
-[ f ] [ V int-regs 0 1 get live-in? ] unit-test
-[ t ] [ V int-regs 1 1 get live-in? ] unit-test
-[ t ] [ V int-regs 2 1 get live-in? ] unit-test
-[ t ] [ V int-regs 3 1 get live-in? ] unit-test
-
-[ f ] [ V int-regs 0 1 get live-out? ] unit-test
-[ f ] [ V int-regs 1 1 get live-out? ] unit-test
-[ t ] [ V int-regs 2 1 get live-out? ] unit-test
-[ t ] [ V int-regs 3 1 get live-out? ] unit-test
-
-[ f ] [ V int-regs 0 2 get live-in? ] unit-test
-[ f ] [ V int-regs 1 2 get live-in? ] unit-test
-[ t ] [ V int-regs 2 2 get live-in? ] unit-test
-[ f ] [ V int-regs 3 2 get live-in? ] unit-test
-
-[ f ] [ V int-regs 0 2 get live-out? ] unit-test
-[ f ] [ V int-regs 1 2 get live-out? ] unit-test
-[ f ] [ V int-regs 2 2 get live-out? ] unit-test
-[ f ] [ V int-regs 3 2 get live-out? ] unit-test
-
-[ f ] [ V int-regs 0 3 get live-in? ] unit-test
-[ f ] [ V int-regs 1 3 get live-in? ] unit-test
-[ f ] [ V int-regs 2 3 get live-in? ] unit-test
-[ t ] [ V int-regs 3 3 get live-in? ] unit-test
-
-[ f ] [ V int-regs 0 3 get live-out? ] unit-test
-[ f ] [ V int-regs 1 3 get live-out? ] unit-test
-[ f ] [ V int-regs 2 3 get live-out? ] unit-test
-[ f ] [ V int-regs 3 3 get live-out? ] unit-test
+
+[ f ] [ 0 0 get live-in? ] unit-test
+[ t ] [ 1 0 get live-in? ] unit-test
+[ t ] [ 2 0 get live-in? ] unit-test
+[ t ] [ 3 0 get live-in? ] unit-test
+
+[ f ] [ 0 0 get live-out? ] unit-test
+[ f ] [ 1 0 get live-out? ] unit-test
+[ t ] [ 2 0 get live-out? ] unit-test
+[ t ] [ 3 0 get live-out? ] unit-test
+
+[ f ] [ 0 1 get live-in? ] unit-test
+[ f ] [ 1 1 get live-in? ] unit-test
+[ t ] [ 2 1 get live-in? ] unit-test
+[ f ] [ 3 1 get live-in? ] unit-test
+
+[ f ] [ 0 1 get live-out? ] unit-test
+[ f ] [ 1 1 get live-out? ] unit-test
+[ f ] [ 2 1 get live-out? ] unit-test
+[ f ] [ 3 1 get live-out? ] unit-test
+
+[ f ] [ 0 2 get live-in? ] unit-test
+[ f ] [ 1 2 get live-in? ] unit-test
+[ f ] [ 2 2 get live-in? ] unit-test
+[ t ] [ 3 2 get live-in? ] unit-test
+
+[ f ] [ 0 2 get live-out? ] unit-test
+[ f ] [ 1 2 get live-out? ] unit-test
+[ f ] [ 2 2 get live-out? ] unit-test
+[ f ] [ 3 2 get live-out? ] unit-test
 
 V{ } 0 test-bb
 V{ } 1 test-bb
 V{ } 2 test-bb
 V{ } 3 test-bb
 V{
-    T{ ##phi f V int-regs 2 H{ { 2 V int-regs 0 } { 3 V int-regs 1 } } }
+    T{ ##phi f 2 H{ { 2 0 } { 3 1 } } }
 } 4 test-bb
 test-diamond
 
-cfg new 1 get >>entry 5 set
-
-[ ] [ 5 get compute-predecessors drop ] unit-test
-[ ] [ 5 get precompute-liveness ] unit-test
+[ ] [ test-liveness ] unit-test
 
-[ t ] [ V int-regs 0 1 get live-in? ] unit-test
-[ t ] [ V int-regs 1 1 get live-in? ] unit-test
-[ f ] [ V int-regs 2 1 get live-in? ] unit-test
+[ t ] [ 0 1 get live-in? ] unit-test
+[ t ] [ 1 1 get live-in? ] unit-test
+[ f ] [ 2 1 get live-in? ] unit-test
 
-[ t ] [ V int-regs 0 1 get live-out? ] unit-test
-[ t ] [ V int-regs 1 1 get live-out? ] unit-test
-[ f ] [ V int-regs 2 1 get live-out? ] unit-test
+[ t ] [ 0 1 get live-out? ] unit-test
+[ t ] [ 1 1 get live-out? ] unit-test
+[ f ] [ 2 1 get live-out? ] unit-test
 
-[ t ] [ V int-regs 0 2 get live-in? ] unit-test
-[ f ] [ V int-regs 1 2 get live-in? ] unit-test
-[ f ] [ V int-regs 2 2 get live-in? ] unit-test
+[ t ] [ 0 2 get live-in? ] unit-test
+[ f ] [ 1 2 get live-in? ] unit-test
+[ f ] [ 2 2 get live-in? ] unit-test
 
-[ t ] [ V int-regs 0 2 get live-out? ] unit-test
-[ f ] [ V int-regs 1 2 get live-out? ] unit-test
-[ f ] [ V int-regs 2 2 get live-out? ] unit-test
+[ f ] [ 0 2 get live-out? ] unit-test
+[ f ] [ 1 2 get live-out? ] unit-test
+[ f ] [ 2 2 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 3 get live-in? ] unit-test
-[ t ] [ V int-regs 1 3 get live-in? ] unit-test
-[ f ] [ V int-regs 2 3 get live-in? ] unit-test
+[ f ] [ 0 3 get live-in? ] unit-test
+[ t ] [ 1 3 get live-in? ] unit-test
+[ f ] [ 2 3 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 3 get live-out? ] unit-test
-[ t ] [ V int-regs 1 3 get live-out? ] unit-test
-[ f ] [ V int-regs 2 3 get live-out? ] unit-test
+[ f ] [ 0 3 get live-out? ] unit-test
+[ f ] [ 1 3 get live-out? ] unit-test
+[ f ] [ 2 3 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 4 get live-in? ] unit-test
-[ f ] [ V int-regs 1 4 get live-in? ] unit-test
-[ f ] [ V int-regs 2 4 get live-in? ] unit-test
+[ f ] [ 0 4 get live-in? ] unit-test
+[ f ] [ 1 4 get live-in? ] unit-test
+[ f ] [ 2 4 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 4 get live-out? ] unit-test
-[ f ] [ V int-regs 1 4 get live-out? ] unit-test
-[ f ] [ V int-regs 2 4 get live-out? ] unit-test
+[ f ] [ 0 4 get live-out? ] unit-test
+[ f ] [ 1 4 get live-out? ] unit-test
+[ f ] [ 2 4 get live-out? ] unit-test
 
 ! This is the CFG in Figure 3 from the paper
+V{ } 0 test-bb
 V{ } 1 test-bb
+0 1 edge
 V{ } 2 test-bb
 1 2 edge
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##peek f V int-regs 1 D 0 }
-    T{ ##peek f V int-regs 2 D 0 }
+    T{ ##peek f 0 D 0 }
+    T{ ##peek f 1 D 0 }
+    T{ ##peek f 2 D 0 }
 } 3 test-bb
 V{ } 11 test-bb
 2 { 3 11 } edges
 V{
-    T{ ##replace f V int-regs 0 D 0 }
+    T{ ##replace f 0 D 0 }
 } 4 test-bb
 V{ } 8 test-bb
 3 { 8 4 } edges
 V{
-    T{ ##replace f V int-regs 1 D 0 }
+    T{ ##replace f 1 D 0 }
 } 9 test-bb
 8 9 edge
 V{
-    T{ ##replace f V int-regs 2 D 0 }
+    T{ ##replace f 2 D 0 }
 } 5 test-bb
 4 5 edge
 V{ } 10 test-bb
@@ -160,9 +164,7 @@ V{ } 7 test-bb
 10 8 edge
 7 2 edge
 
-cfg new 1 get >>entry 0 set
-[ ] [ 0 get compute-predecessors drop ] unit-test
-[ ] [ 0 get precompute-liveness ] unit-test
+[ ] [ test-liveness ] unit-test
 
 [ t ] [ 1 get R_q 1 11 [a,b] [ get ] map unique = ] unit-test
 [ t ] [ 2 get R_q 2 11 [a,b] [ get ] map unique = ] unit-test
@@ -200,92 +202,90 @@ cfg new 1 get >>entry 0 set
 [ f ] [ 10 get back-edge-target? ] unit-test
 [ f ] [ 11 get back-edge-target? ] unit-test
 
-[ f ] [ 1 11 [a,b] [ get phi-outs get at ] any? ] unit-test
-
-[ f ] [ V int-regs 0 1 get live-in? ] unit-test
-[ f ] [ V int-regs 1 1 get live-in? ] unit-test
-[ f ] [ V int-regs 2 1 get live-in? ] unit-test
+[ f ] [ 0 1 get live-in? ] unit-test
+[ f ] [ 1 1 get live-in? ] unit-test
+[ f ] [ 2 1 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 1 get live-out? ] unit-test
-[ f ] [ V int-regs 1 1 get live-out? ] unit-test
-[ f ] [ V int-regs 2 1 get live-out? ] unit-test
+[ f ] [ 0 1 get live-out? ] unit-test
+[ f ] [ 1 1 get live-out? ] unit-test
+[ f ] [ 2 1 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 2 get live-in? ] unit-test
-[ f ] [ V int-regs 1 2 get live-in? ] unit-test
-[ f ] [ V int-regs 2 2 get live-in? ] unit-test
+[ f ] [ 0 2 get live-in? ] unit-test
+[ f ] [ 1 2 get live-in? ] unit-test
+[ f ] [ 2 2 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 2 get live-out? ] unit-test
-[ f ] [ V int-regs 1 2 get live-out? ] unit-test
-[ f ] [ V int-regs 2 2 get live-out? ] unit-test
+[ f ] [ 0 2 get live-out? ] unit-test
+[ f ] [ 1 2 get live-out? ] unit-test
+[ f ] [ 2 2 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 3 get live-in? ] unit-test
-[ f ] [ V int-regs 1 3 get live-in? ] unit-test
-[ f ] [ V int-regs 2 3 get live-in? ] unit-test
+[ f ] [ 0 3 get live-in? ] unit-test
+[ f ] [ 1 3 get live-in? ] unit-test
+[ f ] [ 2 3 get live-in? ] unit-test
 
-[ t ] [ V int-regs 0 3 get live-out? ] unit-test
-[ t ] [ V int-regs 1 3 get live-out? ] unit-test
-[ t ] [ V int-regs 2 3 get live-out? ] unit-test
+[ t ] [ 0 3 get live-out? ] unit-test
+[ t ] [ 1 3 get live-out? ] unit-test
+[ t ] [ 2 3 get live-out? ] unit-test
 
-[ t ] [ V int-regs 0 4 get live-in? ] unit-test
-[ f ] [ V int-regs 1 4 get live-in? ] unit-test
-[ t ] [ V int-regs 2 4 get live-in? ] unit-test
+[ t ] [ 0 4 get live-in? ] unit-test
+[ f ] [ 1 4 get live-in? ] unit-test
+[ t ] [ 2 4 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 4 get live-out? ] unit-test
-[ f ] [ V int-regs 1 4 get live-out? ] unit-test
-[ t ] [ V int-regs 2 4 get live-out? ] unit-test
+[ f ] [ 0 4 get live-out? ] unit-test
+[ f ] [ 1 4 get live-out? ] unit-test
+[ t ] [ 2 4 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 5 get live-in? ] unit-test
-[ f ] [ V int-regs 1 5 get live-in? ] unit-test
-[ t ] [ V int-regs 2 5 get live-in? ] unit-test
+[ f ] [ 0 5 get live-in? ] unit-test
+[ f ] [ 1 5 get live-in? ] unit-test
+[ t ] [ 2 5 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 5 get live-out? ] unit-test
-[ f ] [ V int-regs 1 5 get live-out? ] unit-test
-[ t ] [ V int-regs 2 5 get live-out? ] unit-test
+[ f ] [ 0 5 get live-out? ] unit-test
+[ f ] [ 1 5 get live-out? ] unit-test
+[ t ] [ 2 5 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 6 get live-in? ] unit-test
-[ f ] [ V int-regs 1 6 get live-in? ] unit-test
-[ t ] [ V int-regs 2 6 get live-in? ] unit-test
+[ f ] [ 0 6 get live-in? ] unit-test
+[ f ] [ 1 6 get live-in? ] unit-test
+[ t ] [ 2 6 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 6 get live-out? ] unit-test
-[ f ] [ V int-regs 1 6 get live-out? ] unit-test
-[ t ] [ V int-regs 2 6 get live-out? ] unit-test
+[ f ] [ 0 6 get live-out? ] unit-test
+[ f ] [ 1 6 get live-out? ] unit-test
+[ t ] [ 2 6 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 7 get live-in? ] unit-test
-[ f ] [ V int-regs 1 7 get live-in? ] unit-test
-[ f ] [ V int-regs 2 7 get live-in? ] unit-test
+[ f ] [ 0 7 get live-in? ] unit-test
+[ f ] [ 1 7 get live-in? ] unit-test
+[ f ] [ 2 7 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 7 get live-out? ] unit-test
-[ f ] [ V int-regs 1 7 get live-out? ] unit-test
-[ f ] [ V int-regs 2 7 get live-out? ] unit-test
+[ f ] [ 0 7 get live-out? ] unit-test
+[ f ] [ 1 7 get live-out? ] unit-test
+[ f ] [ 2 7 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 8 get live-in? ] unit-test
-[ t ] [ V int-regs 1 8 get live-in? ] unit-test
-[ t ] [ V int-regs 2 8 get live-in? ] unit-test
+[ f ] [ 0 8 get live-in? ] unit-test
+[ t ] [ 1 8 get live-in? ] unit-test
+[ t ] [ 2 8 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 8 get live-out? ] unit-test
-[ t ] [ V int-regs 1 8 get live-out? ] unit-test
-[ t ] [ V int-regs 2 8 get live-out? ] unit-test
+[ f ] [ 0 8 get live-out? ] unit-test
+[ t ] [ 1 8 get live-out? ] unit-test
+[ t ] [ 2 8 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 9 get live-in? ] unit-test
-[ t ] [ V int-regs 1 9 get live-in? ] unit-test
-[ t ] [ V int-regs 2 9 get live-in? ] unit-test
+[ f ] [ 0 9 get live-in? ] unit-test
+[ t ] [ 1 9 get live-in? ] unit-test
+[ t ] [ 2 9 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 9 get live-out? ] unit-test
-[ t ] [ V int-regs 1 9 get live-out? ] unit-test
-[ t ] [ V int-regs 2 9 get live-out? ] unit-test
+[ f ] [ 0 9 get live-out? ] unit-test
+[ t ] [ 1 9 get live-out? ] unit-test
+[ t ] [ 2 9 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 10 get live-in? ] unit-test
-[ t ] [ V int-regs 1 10 get live-in? ] unit-test
-[ t ] [ V int-regs 2 10 get live-in? ] unit-test
+[ f ] [ 0 10 get live-in? ] unit-test
+[ t ] [ 1 10 get live-in? ] unit-test
+[ t ] [ 2 10 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 10 get live-out? ] unit-test
-[ t ] [ V int-regs 1 10 get live-out? ] unit-test
-[ t ] [ V int-regs 2 10 get live-out? ] unit-test
+[ f ] [ 0 10 get live-out? ] unit-test
+[ t ] [ 1 10 get live-out? ] unit-test
+[ t ] [ 2 10 get live-out? ] unit-test
 
-[ f ] [ V int-regs 0 11 get live-in? ] unit-test
-[ f ] [ V int-regs 1 11 get live-in? ] unit-test
-[ f ] [ V int-regs 2 11 get live-in? ] unit-test
+[ f ] [ 0 11 get live-in? ] unit-test
+[ f ] [ 1 11 get live-in? ] unit-test
+[ f ] [ 2 11 get live-in? ] unit-test
 
-[ f ] [ V int-regs 0 11 get live-out? ] unit-test
-[ f ] [ V int-regs 1 11 get live-out? ] unit-test
-[ f ] [ V int-regs 2 11 get live-out? ] unit-test
+[ f ] [ 0 11 get live-out? ] unit-test
+[ f ] [ 1 11 get live-out? ] unit-test
+[ f ] [ 2 11 get live-out? ] unit-test
index f2a195eb243599a49d1672c16803380ef64630a2..1ed6010dbe894bf16fff9362a5d47d51d7f31c81 100644 (file)
@@ -21,10 +21,6 @@ SYMBOL: R_q-sets
 ! Targets of back edges
 SYMBOL: back-edge-targets
 
-! hashtable of nodes => sets of vregs, where the vregs are inputs
-! to phi nodes in a successor node
-SYMBOL: phi-outs
-
 : T_q ( q -- T_q )
     T_q-sets get at ;
 
@@ -34,9 +30,6 @@ SYMBOL: phi-outs
 : back-edge-target? ( block -- ? )
     back-edge-targets get key? ;
 
-: phi-out? ( vreg node -- ? )
-    phi-outs get at key? ;
-
 : next-R_q ( q -- R_q )
     [ ] [ successors>> ] [ number>> ] tri
     '[ number>> _ >= ] filter
@@ -52,27 +45,14 @@ SYMBOL: phi-outs
         [ back-edge-targets get conjoin ] [ drop ] if
     ] each ;
 
-: set-phi-out ( block vreg -- )
-    swap phi-outs get [ drop H{ } clone ] cache conjoin ;
-
-: set-phi-outs ( q -- )
-    instructions>> [
-        dup ##phi? [
-            inputs>> [ set-phi-out ] assoc-each
-        ] [ drop ] if
-    ] each ;
-
 : init-R_q ( -- )
     H{ } clone R_q-sets set
-    H{ } clone back-edge-targets set
-    H{ } clone phi-outs set ;
+    H{ } clone back-edge-targets set ;
 
 : compute-R_q ( cfg -- )
     init-R_q
     post-order [
-        [ set-R_q ]
-        [ set-back-edges ]
-        [ set-phi-outs ] tri
+        [ set-R_q ] [ set-back-edges ] bi
     ] each ;
 
 ! This algorithm for computing T_q uses equation (1)
@@ -100,13 +80,7 @@ SYMBOL: phi-outs
 PRIVATE>
 
 : precompute-liveness ( cfg -- )
-    ! Maybe dominance and def-use should be called before this, separately
-    {
-        [ compute-dominance ]
-        [ compute-def-use ]
-        [ compute-R_q ]
-        [ compute-T_q ]
-    } cleave ;
+    [ compute-R_q ] [ compute-T_q ] bi ;
 
 <PRIVATE
 
@@ -150,7 +124,6 @@ PRIVATE>
     [let | def [ vreg def-of ] |
         {
             { [ node def eq? ] [ vreg uses-of def only? not ] }
-            { [ vreg node phi-out? ] [ t ] }
             { [ def node strictly-dominates? ] [ vreg node (live-out?) ] }
             [ f ]
         } cond
index 9eb6d27521cde24a5360cde0677ffcfb33cf23aa..4b071cb43c21fbd1649238c89c2d82f7f7548290 100644 (file)
@@ -9,41 +9,27 @@ TUPLE: stack-frame
 { return integer }
 { total-size integer }
 { gc-root-size integer }
-spill-counts ;
+{ spill-area-size integer } ;
 
 ! Stack frame utilities
 : param-base ( -- n )
     stack-frame get [ params>> ] [ return>> ] bi + ;
 
-: spill-float-offset ( n -- offset )
-    double-float-regs reg-size * ;
-
-: spill-integer-base ( -- n )
-    stack-frame get spill-counts>> double-float-regs [ swap at ] keep reg-size *
+: spill-offset ( n -- offset )
     param-base + ;
 
-: spill-integer-offset ( n -- offset )
-    cells spill-integer-base + ;
-
-: spill-area-size ( stack-frame -- n )
-    spill-counts>> [ swap reg-size * ] { } assoc>map sum ;
-
 : gc-root-base ( -- n )
-    stack-frame get spill-area-size
-    param-base + ;
+    stack-frame get spill-area-size>> param-base + ;
 
 : gc-root-offset ( n -- n' ) gc-root-base + ;
 
-: gc-roots-size ( live-values -- n )
-    keys [ reg-class>> reg-size ] sigma ;
-
 : (stack-frame-size) ( stack-frame -- n )
     [
         {
-            [ spill-area-size ]
-            [ gc-root-size>> ]
             [ params>> ]
             [ return>> ]
+            [ gc-root-size>> ]
+            [ spill-area-size>> ]
         } cleave
     ] sum-outputs ;
 
index 094b3c5f1edb320510ac77db70f304fb78df955f..ca81c69bc0a6fc2db01e90dcdf4114828f571045 100644 (file)
@@ -1,20 +1,31 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces assocs kernel fry accessors sequences make math
+USING: namespaces assocs kernel fry accessors sequences make math locals
 combinators compiler.cfg compiler.cfg.hats compiler.cfg.instructions
 compiler.cfg.utilities compiler.cfg.rpo compiler.cfg.stacks.local
-compiler.cfg.stacks.global compiler.cfg.stacks.height ;
+compiler.cfg.stacks.global compiler.cfg.stacks.height
+compiler.cfg.predecessors ;
 IN: compiler.cfg.stacks.finalize
 
 ! This pass inserts peeks and replaces.
 
-: inserting-peeks ( from to -- assoc )
-    peek-in swap [ peek-out ] [ avail-out ] bi
-    assoc-union assoc-diff ;
-
-: inserting-replaces ( from to -- assoc )
-    [ replace-out ] [ [ kill-in ] [ replace-in ] bi ] bi*
-    assoc-union assoc-diff ;
+:: inserting-peeks ( from to -- assoc )
+    ! A peek is inserted on an edge if the destination anticipates
+    ! the stack location, the source does not anticipate it and
+    ! it is not available from the source in a register.
+    to anticip-in
+    from anticip-out from avail-out assoc-union
+    assoc-diff ;
+
+:: inserting-replaces ( from to -- assoc )
+    ! A replace is inserted on an edge if two conditions hold:
+    ! - the location is not dead at the destination, OR
+    !   the location is live at the destination but not available
+    !   at the destination
+    ! - the location is pending in the source but not the destination
+    from pending-out to pending-in assoc-diff
+    to dead-in to live-in to anticip-in assoc-diff assoc-diff
+    assoc-diff ;
 
 : each-insertion ( assoc bb quot: ( vreg loc -- ) -- )
     '[ drop [ loc>vreg ] [ _ untranslate-loc ] bi @ ] assoc-each ; inline
@@ -33,7 +44,7 @@ ERROR: bad-peek dst loc ;
     ! If both blocks are subroutine calls, don't bother
     ! computing anything.
     2dup [ kill-block? ] both? [ 2drop ] [
-        2dup [ [ insert-peeks ] [ insert-replaces ] 2bi ] V{ } make
+        2dup [ [ insert-replaces ] [ insert-peeks ] 2bi ] V{ } make
         [ 2drop ] [ <simple-block> insert-basic-block ] if-empty
     ] if ;
 
@@ -41,5 +52,8 @@ ERROR: bad-peek dst loc ;
     [ predecessors>> ] keep '[ _ visit-edge ] each ;
 
 : finalize-stack-shuffling ( cfg -- cfg' )
+    needs-predecessors
+
     dup [ visit-block ] each-basic-block
+
     cfg-changed ;
\ No newline at end of file
index 2062815787bbe8bf1a97b4fa1f6b820d3c1993ca..30a999064ad1f6ce46e31edde7a68fe241b62728 100644 (file)
@@ -4,36 +4,56 @@ USING: assocs kernel combinators compiler.cfg.dataflow-analysis
 compiler.cfg.stacks.local ;
 IN: compiler.cfg.stacks.global
 
-! Peek analysis. Peek-in is the set of all locations anticipated at
-! the start of a basic block.
-BACKWARD-ANALYSIS: peek
+: transfer-peeked-locs ( assoc bb -- assoc' )
+    [ replace-set assoc-diff ] [ peek-set assoc-union ] bi ;
 
-M: peek-analysis transfer-set drop [ replace-set assoc-diff ] keep peek-set assoc-union ;
+! A stack location is anticipated at a location if every path from
+! the location to an exit block will read the stack location
+! before writing it.
+BACKWARD-ANALYSIS: anticip
 
-! Replace analysis. Replace-in is the set of all locations which
-! will be overwritten at some point after the start of a basic block.
-FORWARD-ANALYSIS: replace
+M: anticip-analysis transfer-set drop transfer-peeked-locs ;
 
-M: replace-analysis transfer-set drop replace-set assoc-union ;
+! A stack location is live at a location if some path from
+! the location to an exit block will read the stack location
+! before writing it.
+BACKWARD-ANALYSIS: live
 
-! Availability analysis. Avail-out is the set of all locations
-! in registers at the end of a basic block.
+M: live-analysis transfer-set drop transfer-peeked-locs ;
+
+M: live-analysis join-sets 2drop assoc-combine ;
+
+! A stack location is available at a location if all paths from
+! the entry block to the location load the location into a
+! register.
 FORWARD-ANALYSIS: avail
 
-M: avail-analysis transfer-set drop [ peek-set ] [ replace-set ] bi assoc-union assoc-union ;
+M: avail-analysis transfer-set
+    drop [ peek-set assoc-union ] [ replace-set assoc-union ] bi ;
+
+! A stack location is pending at a location if all paths from
+! the entry block to the location write the location.
+FORWARD-ANALYSIS: pending
+
+M: pending-analysis transfer-set
+    drop replace-set assoc-union ;
 
-! Kill analysis. Kill-in is the set of all locations
-! which are going to be overwritten.
-BACKWARD-ANALYSIS: kill
+! A stack location is dead at a location if no paths from the
+! location to the exit block read the location before writing it.
+BACKWARD-ANALYSIS: dead
 
-M: kill-analysis transfer-set drop kill-set assoc-union ;
+M: dead-analysis transfer-set
+    drop
+    [ kill-set assoc-union ]
+    [ replace-set assoc-union ] bi ;
 
 ! Main word
 : compute-global-sets ( cfg -- cfg' )
     {
-        [ compute-peek-sets ]
-        [ compute-replace-sets ]
+        [ compute-anticip-sets ]
+        [ compute-live-sets ]
+        [ compute-pending-sets ]
+        [ compute-dead-sets ]
         [ compute-avail-sets ]
-        [ compute-kill-sets ]
         [ ]
-    } cleave ;
\ No newline at end of file
+    } cleave ;
index 4d3ed36be9c941fe9b408971a84d0de6724f604e..4878dbe3ab6b338ffd48624b014b3bd01c54031c 100644 (file)
@@ -10,14 +10,19 @@ compiler.cfg.stacks.height
 compiler.cfg.parallel-copy ;
 IN: compiler.cfg.stacks.local
 
-! Local stack analysis. We build local peek and replace sets for every basic
-! block while constructing the CFG.
+! Local stack analysis. We build three sets for every basic block
+! in the CFG:
+! - peek-set: all stack locations that the block reads before writing
+! - replace-set: all stack locations that the block writes
+! - kill-set: all stack locations which become unavailable after the
+!   block ends because of the stack height being decremented
+! This is done while constructing the CFG.
 
 SYMBOLS: peek-sets replace-sets kill-sets ;
 
 SYMBOL: locs>vregs
 
-: loc>vreg ( loc -- vreg ) locs>vregs get [ drop i ] cache ;
+: loc>vreg ( loc -- vreg ) locs>vregs get [ drop next-vreg ] cache ;
 : vreg>loc ( vreg -- loc/f ) locs>vregs get value-at ;
 
 TUPLE: current-height
@@ -80,9 +85,8 @@ M: rs-loc translate-local-loc n>> current-height get r>> - <rs-loc> ;
 : compute-local-kill-set ( -- assoc )
     basic-block get current-height get
     [ [ ds-heights get at dup ] [ d>> ] bi* [-] iota [ swap - <ds-loc> ] with map ]
-    [ [ rs-heights get at dup ] [ r>> ] bi* [-] iota [ swap - <rs-loc> ] with map ]
-    [ drop local-replace-set get at ] 2tri
-    [ append unique dup ] dip update ;
+    [ [ rs-heights get at dup ] [ r>> ] bi* [-] iota [ swap - <rs-loc> ] with map ] 2bi
+    append unique ;
 
 : begin-local-analysis ( -- )
     H{ } clone local-peek-set set
index 1896b0a7fb5fb54e9b17657a7f12335f06cea695..ce673ba5bb4da2a317347c3763ffb9bb29ec18dc 100755 (executable)
@@ -18,7 +18,6 @@ IN: compiler.cfg.stacks
 
 : end-stack-analysis ( -- )
     cfg get
-    compute-predecessors
     compute-global-sets
     finalize-stack-shuffling
     drop ;
index 39b2f7747c4bb76cc9520fcda145c3a4d6a2b0d7..61c3cd67d1ffc5a309b1026d22867c74c37d47bb 100644 (file)
@@ -1,12 +1,11 @@
-IN: compiler.cfg.stacks.uninitialized.tests
 USING: compiler.cfg.stacks.uninitialized compiler.cfg.debugger
 compiler.cfg.registers compiler.cfg.instructions compiler.cfg
 compiler.cfg.predecessors cpu.architecture tools.test kernel vectors
 namespaces accessors sequences ;
+IN: compiler.cfg.stacks.uninitialized.tests
 
 : test-uninitialized ( -- )
     cfg new 0 get >>entry
-    compute-predecessors
     compute-uninitialized-sets ;
 
 V{
@@ -14,14 +13,14 @@ V{
 } 0 test-bb
 
 V{
-    T{ ##replace f V int-regs 0 D 0 }
-    T{ ##replace f V int-regs 0 D 1 }
-    T{ ##replace f V int-regs 0 D 2 }
+    T{ ##replace f 0 D 0 }
+    T{ ##replace f 0 D 1 }
+    T{ ##replace f 0 D 2 }
     T{ ##inc-r f 1 }
 } 1 test-bb
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
+    T{ ##peek f 0 D 0 }
     T{ ##inc-d f 1 }
 } 2 test-bb
 
index ee60c4bd7aa48e034e9d601d4c75f0aed3f92d91..ce0e98de5f3095eee23a89feb8784011c5285225 100644 (file)
@@ -52,7 +52,7 @@ M: insn visit-insn drop ;
 : finish ( -- pair ) ds-loc get rs-loc get 2array ;
 
 : (join-sets) ( seq1 seq2 -- seq )
-    2dup [ length ] bi@ max '[ _ 1 pad-tail ] bi@ [ min ] 2map ;
+    2dup [ length ] bi@ max '[ _ 1 pad-tail ] bi@ [ bitand ] 2map ;
 
 : (uninitialized-locs) ( seq quot -- seq' )
     [ dup length [ drop 0 = ] pusher [ 2each ] dip ] dip map ; inline
@@ -65,7 +65,7 @@ M: uninitialized-analysis transfer-set ( pair bb analysis -- pair' )
     drop [ prepare ] dip visit-block finish ;
 
 M: uninitialized-analysis join-sets ( sets analysis -- pair )
-    drop sift [ f ] [ [ ] [ [ (join-sets) ] 2map ] map-reduce ] if-empty ;
+    2drop sift [ f ] [ [ ] [ [ (join-sets) ] 2map ] map-reduce ] if-empty ;
 
 : uninitialized-locs ( bb -- locs )
     uninitialized-in dup [
@@ -73,4 +73,4 @@ M: uninitialized-analysis join-sets ( sets analysis -- pair )
         [ [ <ds-loc> ] (uninitialized-locs) ]
         [ [ <rs-loc> ] (uninitialized-locs) ]
         bi* append
-    ] when ;
\ No newline at end of file
+    ] when ;
index 3dbdf148e97f6430d87009b050934db7eceb1225..810b9010130d47716f9cd3d1a0cad8613efbfd9d 100644 (file)
@@ -10,7 +10,7 @@ compiler.cfg.instructions
 compiler.cfg.utilities ;
 IN: compiler.cfg.tco
 
-! Tail call optimization. You must run compute-predecessors after this
+! Tail call optimization.
 
 : return? ( bb -- ? )
     skip-empty-blocks
@@ -63,6 +63,6 @@ IN: compiler.cfg.tco
     ] [ drop ] if ;
 
 : optimize-tail-calls ( cfg -- cfg' )
-    dup cfg set
     dup [ optimize-tail-call ] each-basic-block
-    cfg-changed ;
\ No newline at end of file
+
+    cfg-changed predecessors-changed ;
\ No newline at end of file
index 0717f1c536238621b861ec3ca1925971b3ac2564..09d88a29598c676fe569f66f3eac837821ee239a 100644 (file)
@@ -1,38 +1,52 @@
-IN: compiler.cfg.two-operand.tests
-USING: compiler.cfg.two-operand compiler.cfg.instructions
+USING: kernel compiler.cfg.two-operand compiler.cfg.instructions
 compiler.cfg.registers cpu.architecture namespaces tools.test ;
+IN: compiler.cfg.two-operand.tests
 
 3 vreg-counter set-global
 
 [
     V{
-        T{ ##copy f V int-regs 1 V int-regs 2 }
-        T{ ##sub f V int-regs 1 V int-regs 1 V int-regs 3 }
+        T{ ##copy f 1 2 int-rep }
+        T{ ##sub f 1 1 3 }
     }
 ] [
+    H{
+        { 1 int-rep }
+        { 2 int-rep }
+        { 3 int-rep }
+    } clone representations set
     {
-        T{ ##sub f V int-regs 1 V int-regs 2 V int-regs 3 }
+        T{ ##sub f 1 2 3 }
     } (convert-two-operand)
 ] unit-test
 
 [
     V{
-        T{ ##sub f V int-regs 1 V int-regs 1 V int-regs 2 }
+        T{ ##copy f 1 2 double-float-rep }
+        T{ ##sub-float f 1 1 3 }
     }
 ] [
+    H{
+        { 1 double-float-rep }
+        { 2 double-float-rep }
+        { 3 double-float-rep }
+    } clone representations set
     {
-        T{ ##sub f V int-regs 1 V int-regs 1 V int-regs 2 }
+        T{ ##sub-float f 1 2 3 }
     } (convert-two-operand)
 ] unit-test
 
 [
     V{
-        T{ ##copy f V int-regs 4 V int-regs 1 }
-        T{ ##copy f V int-regs 1 V int-regs 2 }
-        T{ ##sub f V int-regs 1 V int-regs 1 V int-regs 4 }
+        T{ ##copy f 1 2 double-float-rep }
+        T{ ##mul-float f 1 1 1 }
     }
 ] [
+    H{
+        { 1 double-float-rep }
+        { 2 double-float-rep }
+    } clone representations set
     {
-        T{ ##sub f V int-regs 1 V int-regs 2 V int-regs 1 }
+        T{ ##mul-float f 1 2 2 }
     } (convert-two-operand)
 ] unit-test
index 7a8b160acdcd8b9e1803968a55dc0a125d0a7240..1705355842fb717d1b52e1c799f77775434727d4 100644 (file)
@@ -5,27 +5,17 @@ compiler.cfg.registers compiler.cfg.instructions
 compiler.cfg.rpo cpu.architecture ;
 IN: compiler.cfg.two-operand
 
-! This pass runs after SSA coalescing and normalizes instructions
-! to fit the x86 two-address scheme. Possibilities are:
-
-! 1) x = x op y
-! 2) x = y op x
-! 3) x = y op z
-
-! In case 1, there is nothing to do.
-
-! In case 2, we convert to
-! z = y
-! z = z op x
-! x = z
-
-! In case 3, we convert to
+! This pass runs before SSA coalescing and normalizes instructions
+! to fit the x86 two-address scheme. Since the input is in SSA,
+! it suffices to convert
+!
+! x = y op z
+!
+! to
+!
 ! x = y
 ! x = x op z
-
-! In case 2 and case 3, linear scan coalescing will eliminate a
-! copy if the value y is never used again.
-
+!
 ! We don't bother with ##add, ##add-imm, ##sub-imm or ##mul-imm
 ! since x86 has LEA and IMUL instructions which are effectively
 ! three-operand addition and multiplication, respectively.
@@ -54,42 +44,19 @@ UNION: two-operand-insn
 GENERIC: convert-two-operand* ( insn -- )
 
 : emit-copy ( dst src -- )
-    dup reg-class>> {
-        { int-regs [ ##copy ] }
-        { double-float-regs [ ##copy-float ] }
-    } case ; inline
-
-: case-1? ( insn -- ? ) [ dst>> ] [ src1>> ] bi = ; inline
-
-: case-1 ( insn -- ) , ; inline
-
-: case-2? ( insn -- ? ) [ dst>> ] [ src2>> ] bi = ; inline
-
-: case-2 ( insn -- )
-    dup dst>> reg-class>> next-vreg
-    [ swap src2>> emit-copy ]
-    [ drop [ src2>> ] [ src1>> ] bi emit-copy ]
-    [ >>src2 dup dst>> >>src1 , ]
-    2tri ; inline
-
-: case-3 ( insn -- )
-    [ [ dst>> ] [ src1>> ] bi emit-copy ]
-    [ dup dst>> >>src1 , ]
-    bi ; inline
+    dup rep-of ##copy ; inline
 
 M: two-operand-insn convert-two-operand*
-    {
-        { [ dup case-1? ] [ case-1 ] }
-        { [ dup case-2? ] [ case-2 ] }
-        [ case-3 ]
-    } cond ; inline
+    [ [ dst>> ] [ src1>> ] bi emit-copy ]
+    [
+        dup [ src1>> ] [ src2>> ] bi = [ dup dst>> >>src2 ] when
+        dup dst>> >>src1 ,
+    ] bi ;
 
 M: ##not convert-two-operand*
-    dup [ dst>> ] [ src>> ] bi = [
-        [ [ dst>> ] [ src>> ] bi ##copy ]
-        [ dup dst>> >>src ]
-        bi
-    ] unless , ;
+    [ [ dst>> ] [ src>> ] bi emit-copy ]
+    [ dup dst>> >>src , ]
+    bi ;
 
 M: insn convert-two-operand* , ;
 
index cc98d0804204dbd2d91cfb9b3763cca8a3ab80d2..d480ad97d1fcd6142b658404bb8e8e474875f7ef 100644 (file)
@@ -19,4 +19,5 @@ IN: compiler.cfg.useless-conditionals
     dup [
         dup delete-conditional? [ delete-conditional ] [ drop ] if
     ] each-basic-block
-    cfg-changed ;
+    
+    cfg-changed predecessors-changed ;
index 9246084325e482be75f550d08f2c1a6fe02ade6d..6d68bca4b9fd9d907754b5b9187cd0bc968b3be6 100644 (file)
@@ -69,6 +69,10 @@ SYMBOL: visited
     [ instructions>> ] dip
     '[ dup ##phi? [ @ t ] [ drop f ] if ] all? drop ; inline
 
+: each-non-phi ( bb quot: ( insn -- ) -- )
+    [ instructions>> ] dip
+    '[ dup ##phi? [ drop ] _ if ] each ; inline
+
 : predecessor ( bb -- pred )
     predecessors>> first ; inline
 
index 4b8ee2a1ae50915328f0db78ce219048d359ba35..50f809cc99ac6e3d6aad33406e79be6892feee47 100755 (executable)
@@ -4,7 +4,7 @@ USING: accessors combinators combinators.short-circuit arrays
 fry kernel layouts math namespaces sequences cpu.architecture
 math.bitwise math.order classes vectors
 compiler.cfg
-compiler.cfg.hats
+compiler.cfg.registers
 compiler.cfg.comparisons
 compiler.cfg.instructions
 compiler.cfg.value-numbering.expressions
@@ -77,7 +77,7 @@ M: ##compare-imm-branch rewrite-tagged-comparison
 
 M: ##compare-imm rewrite-tagged-comparison
     [ dst>> ] [ (rewrite-tagged-comparison) ] bi
-    i \ ##compare-imm new-insn ;
+    next-vreg \ ##compare-imm new-insn ;
 
 : rewrite-redundant-comparison? ( insn -- ? )
     {
@@ -88,9 +88,9 @@ M: ##compare-imm rewrite-tagged-comparison
 
 : rewrite-redundant-comparison ( insn -- insn' )
     [ cc>> ] [ dst>> ] [ src1>> vreg>expr dup op>> ] tri {
-        { \ ##compare [ >compare-expr< i \ ##compare new-insn ] }
-        { \ ##compare-imm [ >compare-imm-expr< i \ ##compare-imm new-insn ] }
-        { \ ##compare-float [ >compare-expr< i \ ##compare-float new-insn ] }
+        { \ ##compare [ >compare-expr< next-vreg \ ##compare new-insn ] }
+        { \ ##compare-imm [ >compare-imm-expr< next-vreg \ ##compare-imm new-insn ] }
+        { \ ##compare-float [ >compare-expr< next-vreg \ ##compare-float new-insn ] }
     } case
     swap cc= eq? [ [ negate-cc ] change-cc ] when ;
 
@@ -169,7 +169,7 @@ M: ##compare-branch rewrite
     ] dip
     swap-compare
     [ vreg>constant ] dip
-    i \ ##compare-imm new-insn ; inline
+    next-vreg \ ##compare-imm new-insn ; inline
 
 : >boolean-insn ( insn ? -- insn' )
     [ dst>> ] dip
index 6bd84021b36189b811f3520506a8e47856c0cf2f..b805d7834c7e3c69c150ce0721407c90eb792322 100644 (file)
@@ -9,22 +9,14 @@ IN: compiler.cfg.value-numbering.simplify
 ! Return value of f means we didn't simplify.
 GENERIC: simplify* ( expr -- vn/expr/f )
 
-: simplify-unbox ( in boxer -- vn/expr/f )
-    over op>> eq? [ in>> ] [ drop f ] if ; inline
-
-: simplify-unbox-float ( in -- vn/expr/f )
-    \ ##box-float simplify-unbox ; inline
-
 : simplify-unbox-alien ( in -- vn/expr/f )
-    \ ##box-alien simplify-unbox ; inline
+    dup op>> \ ##box-alien eq? [ in>> ] [ drop f ] if ; inline
 
 M: unary-expr simplify*
     #! Note the copy propagation: a copy always simplifies to
     #! its source VN.
     [ in>> vn>expr ] [ op>> ] bi {
         { \ ##copy [ ] }
-        { \ ##copy-float [ ] }
-        { \ ##unbox-float [ simplify-unbox-float ] }
         { \ ##unbox-alien [ simplify-unbox-alien ] }
         { \ ##unbox-any-c-ptr [ simplify-unbox-alien ] }
         [ 2drop f ]
index 519cea617a73f9dc8ddb828c67fee58be6b8ec7e..f3c950679a5657ac3e31b383d4cf6def5887602c 100644 (file)
@@ -1,10 +1,11 @@
-IN: compiler.cfg.value-numbering.tests
 USING: compiler.cfg.value-numbering compiler.cfg.instructions
 compiler.cfg.registers compiler.cfg.debugger compiler.cfg.comparisons
 cpu.architecture tools.test kernel math combinators.short-circuit
-accessors sequences compiler.cfg.predecessors locals
-compiler.cfg.dce compiler.cfg.ssa.destruction
-compiler.cfg assocs vectors arrays layouts namespaces ;
+accessors sequences compiler.cfg.predecessors locals compiler.cfg.dce
+compiler.cfg.ssa.destruction compiler.cfg.loop-detection
+compiler.cfg.representations compiler.cfg assocs vectors arrays
+layouts namespaces ;
+IN: compiler.cfg.value-numbering.tests
 
 : trim-temps ( insns -- insns )
     [
@@ -18,853 +19,853 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
 ! Folding constants together
 [
     {
-        T{ ##load-reference f V int-regs 0 0.0 }
-        T{ ##load-reference f V int-regs 1 -0.0 }
-        T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 1 D 1 }
+        T{ ##load-reference f 0 0.0 }
+        T{ ##load-reference f 1 -0.0 }
+        T{ ##replace f 0 D 0 }
+        T{ ##replace f 1 D 1 }
     }
 ] [
     {
-        T{ ##load-reference f V int-regs 0 0.0 }
-        T{ ##load-reference f V int-regs 1 -0.0 }
-        T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 1 D 1 }
+        T{ ##load-reference f 0 0.0 }
+        T{ ##load-reference f 1 -0.0 }
+        T{ ##replace f 0 D 0 }
+        T{ ##replace f 1 D 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##load-reference f V int-regs 0 0.0 }
-        T{ ##copy f V int-regs 1 V int-regs 0 }
-        T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 1 D 1 }
+        T{ ##load-reference f 0 0.0 }
+        T{ ##copy f 1 0 any-rep }
+        T{ ##replace f 0 D 0 }
+        T{ ##replace f 1 D 1 }
     }
 ] [
     {
-        T{ ##load-reference f V int-regs 0 0.0 }
-        T{ ##load-reference f V int-regs 1 0.0 }
-        T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 1 D 1 }
+        T{ ##load-reference f 0 0.0 }
+        T{ ##load-reference f 1 0.0 }
+        T{ ##replace f 0 D 0 }
+        T{ ##replace f 1 D 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##load-reference f V int-regs 0 t }
-        T{ ##copy f V int-regs 1 V int-regs 0 }
-        T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 1 D 1 }
+        T{ ##load-reference f 0 t }
+        T{ ##copy f 1 0 any-rep }
+        T{ ##replace f 0 D 0 }
+        T{ ##replace f 1 D 1 }
     }
 ] [
     {
-        T{ ##load-reference f V int-regs 0 t }
-        T{ ##load-reference f V int-regs 1 t }
-        T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 1 D 1 }
+        T{ ##load-reference f 0 t }
+        T{ ##load-reference f 1 t }
+        T{ ##replace f 0 D 0 }
+        T{ ##replace f 1 D 1 }
     } value-numbering-step
 ] unit-test
 
 ! Compare propagation
 [
     {
-        T{ ##load-reference f V int-regs 1 + }
-        T{ ##peek f V int-regs 2 D 0 }
-        T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc> }
-        T{ ##copy f V int-regs 6 V int-regs 4 }
-        T{ ##replace f V int-regs 6 D 0 }
+        T{ ##load-reference f 1 + }
+        T{ ##peek f 2 D 0 }
+        T{ ##compare f 4 2 1 cc> }
+        T{ ##copy f 6 4 any-rep }
+        T{ ##replace f 6 D 0 }
     }
 ] [
     {
-        T{ ##load-reference f V int-regs 1 + }
-        T{ ##peek f V int-regs 2 D 0 }
-        T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc> }
-        T{ ##compare-imm f V int-regs 6 V int-regs 4 5 cc/= }
-        T{ ##replace f V int-regs 6 D 0 }
+        T{ ##load-reference f 1 + }
+        T{ ##peek f 2 D 0 }
+        T{ ##compare f 4 2 1 cc> }
+        T{ ##compare-imm f 6 4 5 cc/= }
+        T{ ##replace f 6 D 0 }
     } value-numbering-step trim-temps
 ] unit-test
 
 [
     {
-        T{ ##load-reference f V int-regs 1 + }
-        T{ ##peek f V int-regs 2 D 0 }
-        T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc<= }
-        T{ ##compare f V int-regs 6 V int-regs 2 V int-regs 1 cc> }
-        T{ ##replace f V int-regs 6 D 0 }
+        T{ ##load-reference f 1 + }
+        T{ ##peek f 2 D 0 }
+        T{ ##compare f 4 2 1 cc<= }
+        T{ ##compare f 6 2 1 cc> }
+        T{ ##replace f 6 D 0 }
     }
 ] [
     {
-        T{ ##load-reference f V int-regs 1 + }
-        T{ ##peek f V int-regs 2 D 0 }
-        T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc<= }
-        T{ ##compare-imm f V int-regs 6 V int-regs 4 5 cc= }
-        T{ ##replace f V int-regs 6 D 0 }
+        T{ ##load-reference f 1 + }
+        T{ ##peek f 2 D 0 }
+        T{ ##compare f 4 2 1 cc<= }
+        T{ ##compare-imm f 6 4 5 cc= }
+        T{ ##replace f 6 D 0 }
     } value-numbering-step trim-temps
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 8 D 0 }
-        T{ ##peek f V int-regs 9 D -1 }
-        T{ ##unbox-float f V double-float-regs 10 V int-regs 8 }
-        T{ ##unbox-float f V double-float-regs 11 V int-regs 9 }
-        T{ ##compare-float f V int-regs 12 V double-float-regs 10 V double-float-regs 11 cc< }
-        T{ ##compare-float f V int-regs 14 V double-float-regs 10 V double-float-regs 11 cc>= }
-        T{ ##replace f V int-regs 14 D 0 }
+        T{ ##peek f 8 D 0 }
+        T{ ##peek f 9 D -1 }
+        T{ ##unbox-float f 10 8 }
+        T{ ##unbox-float f 11 9 }
+        T{ ##compare-float f 12 10 11 cc< }
+        T{ ##compare-float f 14 10 11 cc>= }
+        T{ ##replace f 14 D 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 8 D 0 }
-        T{ ##peek f V int-regs 9 D -1 }
-        T{ ##unbox-float f V double-float-regs 10 V int-regs 8 }
-        T{ ##unbox-float f V double-float-regs 11 V int-regs 9 }
-        T{ ##compare-float f V int-regs 12 V double-float-regs 10 V double-float-regs 11 cc< }
-        T{ ##compare-imm f V int-regs 14 V int-regs 12 5 cc= }
-        T{ ##replace f V int-regs 14 D 0 }
+        T{ ##peek f 8 D 0 }
+        T{ ##peek f 9 D -1 }
+        T{ ##unbox-float f 10 8 }
+        T{ ##unbox-float f 11 9 }
+        T{ ##compare-float f 12 10 11 cc< }
+        T{ ##compare-imm f 14 12 5 cc= }
+        T{ ##replace f 14 D 0 }
     } value-numbering-step trim-temps
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 29 D -1 }
-        T{ ##peek f V int-regs 30 D -2 }
-        T{ ##compare f V int-regs 33 V int-regs 29 V int-regs 30 cc<= }
-        T{ ##compare-branch f V int-regs 29 V int-regs 30 cc<= }
+        T{ ##peek f 29 D -1 }
+        T{ ##peek f 30 D -2 }
+        T{ ##compare f 33 29 30 cc<= }
+        T{ ##compare-branch f 29 30 cc<= }
     }
 ] [
     {
-        T{ ##peek f V int-regs 29 D -1 }
-        T{ ##peek f V int-regs 30 D -2 }
-        T{ ##compare f V int-regs 33 V int-regs 29 V int-regs 30 cc<= }
-        T{ ##compare-imm-branch f V int-regs 33 5 cc/= }
+        T{ ##peek f 29 D -1 }
+        T{ ##peek f 30 D -2 }
+        T{ ##compare f 33 29 30 cc<= }
+        T{ ##compare-imm-branch f 33 5 cc/= }
     } value-numbering-step trim-temps
 ] unit-test
 
 ! Immediate operand conversion
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add f V int-regs 2 V int-regs 0 V int-regs 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add f 2 0 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add f V int-regs 2 V int-regs 1 V int-regs 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add f 2 1 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 -100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 -100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##sub f V int-regs 2 V int-regs 0 V int-regs 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##sub f 2 0 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##sub f V int-regs 1 V int-regs 0 V int-regs 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##sub f 1 0 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul f V int-regs 2 V int-regs 0 V int-regs 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul f 2 0 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul f V int-regs 2 V int-regs 1 V int-regs 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul f 2 1 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 1 D 0 }
-        T{ ##shl-imm f V int-regs 2 V int-regs 1 3 }
+        T{ ##peek f 1 D 0 }
+        T{ ##shl-imm f 2 1 3 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 1 D 0 }
-        T{ ##mul-imm f V int-regs 2 V int-regs 1 8 }
+        T{ ##peek f 1 D 0 }
+        T{ ##mul-imm f 2 1 8 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and f V int-regs 2 V int-regs 0 V int-regs 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and f 2 0 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and f V int-regs 2 V int-regs 1 V int-regs 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and f 2 1 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or f V int-regs 2 V int-regs 0 V int-regs 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or f 2 0 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or f V int-regs 2 V int-regs 1 V int-regs 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or f 2 1 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor f V int-regs 2 V int-regs 0 V int-regs 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor f 2 0 1 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor-imm f V int-regs 2 V int-regs 0 100 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor-imm f 2 0 100 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor f V int-regs 2 V int-regs 1 V int-regs 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor f 2 1 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare-imm f V int-regs 2 V int-regs 0 100 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare-imm f 2 0 100 cc<= }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare f V int-regs 2 V int-regs 0 V int-regs 1 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare f 2 0 1 cc<= }
     } value-numbering-step trim-temps
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare-imm f V int-regs 2 V int-regs 0 100 cc>= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare-imm f 2 0 100 cc>= }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare f V int-regs 2 V int-regs 1 V int-regs 0 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare f 2 1 0 cc<= }
     } value-numbering-step trim-temps
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare-imm-branch f V int-regs 0 100 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare-imm-branch f 0 100 cc<= }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 1 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare-branch f 0 1 cc<= }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare-imm-branch f V int-regs 0 100 cc>= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare-imm-branch f 0 100 cc>= }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##compare-branch f V int-regs 1 V int-regs 0 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##compare-branch f 1 0 cc<= }
     } value-numbering-step trim-temps
 ] unit-test
 
 ! Reassociation
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##add-imm f V int-regs 4 V int-regs 0 150 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##add-imm f 4 0 150 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##add f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##add f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##add-imm f V int-regs 4 V int-regs 0 150 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##add-imm f 4 0 150 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add f V int-regs 2 V int-regs 1 V int-regs 0 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##add f V int-regs 4 V int-regs 3 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add f 2 1 0 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##add f 4 3 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##add-imm f V int-regs 4 V int-regs 0 50 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##add-imm f 4 0 50 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##sub f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##sub f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##add-imm f V int-regs 2 V int-regs 0 -100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##add-imm f V int-regs 4 V int-regs 0 -150 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##add-imm f 2 0 -100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##add-imm f 4 0 -150 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##sub f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##sub f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##sub f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##sub f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##mul-imm f V int-regs 4 V int-regs 0 5000 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##mul-imm f 4 0 5000 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##mul f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##mul f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##mul-imm f V int-regs 4 V int-regs 0 5000 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##mul-imm f 4 0 5000 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##mul f V int-regs 2 V int-regs 1 V int-regs 0 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##mul f V int-regs 4 V int-regs 3 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##mul f 2 1 0 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##mul f 4 3 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##and-imm f V int-regs 4 V int-regs 0 32 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##and-imm f 4 0 32 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##and f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##and f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##and-imm f V int-regs 4 V int-regs 0 32 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##and-imm f 4 0 32 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##and f V int-regs 2 V int-regs 1 V int-regs 0 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##and f V int-regs 4 V int-regs 3 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##and f 2 1 0 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##and f 4 3 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##or-imm f V int-regs 4 V int-regs 0 118 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##or-imm f 4 0 118 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##or f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##or f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##or-imm f V int-regs 4 V int-regs 0 118 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##or-imm f 4 0 118 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##or f V int-regs 2 V int-regs 1 V int-regs 0 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##or f V int-regs 4 V int-regs 3 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##or f 2 1 0 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##or f 4 3 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##xor-imm f V int-regs 4 V int-regs 0 86 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##xor-imm f 4 0 86 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##xor f V int-regs 4 V int-regs 2 V int-regs 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor f 2 0 1 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##xor f 4 2 3 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor-imm f V int-regs 2 V int-regs 0 100 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##xor-imm f V int-regs 4 V int-regs 0 86 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor-imm f 2 0 100 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##xor-imm f 4 0 86 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 100 }
-        T{ ##xor f V int-regs 2 V int-regs 1 V int-regs 0 }
-        T{ ##load-immediate f V int-regs 3 50 }
-        T{ ##xor f V int-regs 4 V int-regs 3 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 100 }
+        T{ ##xor f 2 1 0 }
+        T{ ##load-immediate f 3 50 }
+        T{ ##xor f 4 3 2 }
     } value-numbering-step
 ] unit-test
 
 ! Simplification
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##copy f V int-regs 3 V int-regs 0 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##load-immediate f 2 0 }
+        T{ ##copy f 3 0 any-rep }
+        T{ ##replace f 3 D 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##sub f V int-regs 2 V int-regs 1 V int-regs 1 }
-        T{ ##add f V int-regs 3 V int-regs 0 V int-regs 2 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##sub f 2 1 1 }
+        T{ ##add f 3 0 2 }
+        T{ ##replace f 3 D 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##copy f V int-regs 3 V int-regs 0 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##load-immediate f 2 0 }
+        T{ ##copy f 3 0 any-rep }
+        T{ ##replace f 3 D 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##sub f V int-regs 2 V int-regs 1 V int-regs 1 }
-        T{ ##sub f V int-regs 3 V int-regs 0 V int-regs 2 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##sub f 2 1 1 }
+        T{ ##sub f 3 0 2 }
+        T{ ##replace f 3 D 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##copy f V int-regs 3 V int-regs 0 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##load-immediate f 2 0 }
+        T{ ##copy f 3 0 any-rep }
+        T{ ##replace f 3 D 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##sub f V int-regs 2 V int-regs 1 V int-regs 1 }
-        T{ ##or f V int-regs 3 V int-regs 0 V int-regs 2 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##sub f 2 1 1 }
+        T{ ##or f 3 0 2 }
+        T{ ##replace f 3 D 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##copy f V int-regs 3 V int-regs 0 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##load-immediate f 2 0 }
+        T{ ##copy f 3 0 any-rep }
+        T{ ##replace f 3 D 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##peek f V int-regs 1 D 1 }
-        T{ ##sub f V int-regs 2 V int-regs 1 V int-regs 1 }
-        T{ ##xor f V int-regs 3 V int-regs 0 V int-regs 2 }
-        T{ ##replace f V int-regs 3 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##peek f 1 D 1 }
+        T{ ##sub f 2 1 1 }
+        T{ ##xor f 3 0 2 }
+        T{ ##replace f 3 D 0 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##copy f V int-regs 2 V int-regs 0 }
-        T{ ##replace f V int-regs 2 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##copy f 2 0 any-rep }
+        T{ ##replace f 2 D 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##mul f V int-regs 2 V int-regs 0 V int-regs 1 }
-        T{ ##replace f V int-regs 2 D 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##mul f 2 0 1 }
+        T{ ##replace f 2 D 0 }
     } value-numbering-step
 ] unit-test
 
 ! Constant folding
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##load-immediate f V int-regs 3 4 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##load-immediate f 3 4 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##add f V int-regs 3 V int-regs 1 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##add f 3 1 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##load-immediate f V int-regs 3 -2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##load-immediate f 3 -2 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##sub f V int-regs 3 V int-regs 1 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##sub f 3 1 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##load-immediate f V int-regs 3 6 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##load-immediate f 3 6 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##mul f V int-regs 3 V int-regs 1 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##mul f 3 1 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 1 }
-        T{ ##load-immediate f V int-regs 3 0 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 1 }
+        T{ ##load-immediate f 3 0 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 1 }
-        T{ ##and f V int-regs 3 V int-regs 1 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 1 }
+        T{ ##and f 3 1 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 1 }
-        T{ ##load-immediate f V int-regs 3 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 1 }
+        T{ ##load-immediate f 3 3 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 1 }
-        T{ ##or f V int-regs 3 V int-regs 1 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 1 }
+        T{ ##or f 3 1 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##load-immediate f V int-regs 3 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##load-immediate f 3 1 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 2 }
-        T{ ##load-immediate f V int-regs 2 3 }
-        T{ ##xor f V int-regs 3 V int-regs 1 V int-regs 2 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 2 }
+        T{ ##load-immediate f 2 3 }
+        T{ ##xor f 3 1 2 }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 3 8 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 3 8 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##shl-imm f V int-regs 3 V int-regs 1 3 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##shl-imm f 3 1 3 }
     } value-numbering-step
 ] unit-test
 
 cell 8 = [
     [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 1 -1 }
-            T{ ##load-immediate f V int-regs 3 HEX: ffffffffffff }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 1 -1 }
+            T{ ##load-immediate f 3 HEX: ffffffffffff }
         }
     ] [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 1 -1 }
-            T{ ##shr-imm f V int-regs 3 V int-regs 1 16 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 1 -1 }
+            T{ ##shr-imm f 3 1 16 }
         } value-numbering-step
     ] unit-test
 ] when
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 -8 }
-        T{ ##load-immediate f V int-regs 3 -4 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 -8 }
+        T{ ##load-immediate f 3 -4 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 -8 }
-        T{ ##sar-imm f V int-regs 3 V int-regs 1 1 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 -8 }
+        T{ ##sar-imm f 3 1 1 }
     } value-numbering-step
 ] unit-test
 
 cell 8 = [
     [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 1 65536 }
-            T{ ##load-immediate f V int-regs 2 140737488355328 }
-            T{ ##add f V int-regs 3 V int-regs 0 V int-regs 2 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 1 65536 }
+            T{ ##load-immediate f 2 140737488355328 }
+            T{ ##add f 3 0 2 }
         }
     ] [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 1 65536 }
-            T{ ##shl-imm f V int-regs 2 V int-regs 1 31 }
-            T{ ##add f V int-regs 3 V int-regs 0 V int-regs 2 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 1 65536 }
+            T{ ##shl-imm f 2 1 31 }
+            T{ ##add f 3 0 2 }
         } value-numbering-step
     ] unit-test
 
     [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 2 140737488355328 }
-            T{ ##add f V int-regs 3 V int-regs 0 V int-regs 2 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 2 140737488355328 }
+            T{ ##add f 3 0 2 }
         }
     ] [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 2 140737488355328 }
-            T{ ##add f V int-regs 3 V int-regs 0 V int-regs 2 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 2 140737488355328 }
+            T{ ##add f 3 0 2 }
         } value-numbering-step
     ] unit-test
 
     [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 2 2147483647 }
-            T{ ##add-imm f V int-regs 3 V int-regs 0 2147483647 }
-            T{ ##add-imm f V int-regs 4 V int-regs 3 2147483647 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 2 2147483647 }
+            T{ ##add-imm f 3 0 2147483647 }
+            T{ ##add-imm f 4 3 2147483647 }
         }
     ] [
         {
-            T{ ##peek f V int-regs 0 D 0 }
-            T{ ##load-immediate f V int-regs 2 2147483647 }
-            T{ ##add f V int-regs 3 V int-regs 0 V int-regs 2 }
-            T{ ##add f V int-regs 4 V int-regs 3 V int-regs 2 }
+            T{ ##peek f 0 D 0 }
+            T{ ##load-immediate f 2 2147483647 }
+            T{ ##add f 3 0 2 }
+            T{ ##add f 4 3 2 }
         } value-numbering-step
     ] unit-test
 ] when
@@ -872,129 +873,129 @@ cell 8 = [
 ! Branch folding
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##load-immediate f V int-regs 3 5 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##load-immediate f 3 5 }
     }
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare f V int-regs 3 V int-regs 1 V int-regs 2 cc= }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare f 3 1 2 cc= }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##load-reference f V int-regs 3 t }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##load-reference f 3 t }
     }
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare f V int-regs 3 V int-regs 1 V int-regs 2 cc/= }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare f 3 1 2 cc/= }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##load-reference f V int-regs 3 t }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##load-reference f 3 t }
     }
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare f V int-regs 3 V int-regs 1 V int-regs 2 cc< }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare f 3 1 2 cc< }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##load-immediate f V int-regs 3 5 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##load-immediate f 3 5 }
     }
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare f V int-regs 3 V int-regs 2 V int-regs 1 cc< }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare f 3 2 1 cc< }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 5 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 5 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc< }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc< }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-reference f V int-regs 1 t }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-reference f 1 t }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc<= }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 5 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 5 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc> }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc> }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-reference f V int-regs 1 t }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-reference f 1 t }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc>= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc>= }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-immediate f V int-regs 1 5 }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-immediate f 1 5 }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc/= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc/= }
     } value-numbering-step
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-reference f V int-regs 1 t }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-reference f 1 t }
     }
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc= }
     } value-numbering-step
 ] unit-test
 
@@ -1005,154 +1006,154 @@ cell 8 = [
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
         T{ ##branch }
     }
     1
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare-branch f V int-regs 1 V int-regs 2 cc= }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare-branch f 1 2 cc= }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
         T{ ##branch }
     }
     0
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare-branch f V int-regs 1 V int-regs 2 cc/= }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare-branch f 1 2 cc/= }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
         T{ ##branch }
     }
     0
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare-branch f V int-regs 1 V int-regs 2 cc< }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare-branch f 1 2 cc< }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
         T{ ##branch }
     }
     1
 ] [
     {
-        T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##load-immediate f V int-regs 2 2 }
-        T{ ##compare-branch f V int-regs 2 V int-regs 1 cc< }
+        T{ ##load-immediate f 1 1 }
+        T{ ##load-immediate f 2 2 }
+        T{ ##compare-branch f 2 1 cc< }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
+        T{ ##peek f 0 D 0 }
         T{ ##branch }
     }
     1
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 0 cc< }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare-branch f 0 0 cc< }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
+        T{ ##peek f 0 D 0 }
         T{ ##branch }
     }
     0
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 0 cc<= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare-branch f 0 0 cc<= }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
+        T{ ##peek f 0 D 0 }
         T{ ##branch }
     }
     1
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 0 cc> }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare-branch f 0 0 cc> }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
+        T{ ##peek f 0 D 0 }
         T{ ##branch }
     }
     0
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 0 cc>= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare-branch f 0 0 cc>= }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
+        T{ ##peek f 0 D 0 }
         T{ ##branch }
     }
     0
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 0 cc= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare-branch f 0 0 cc= }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
+        T{ ##peek f 0 D 0 }
         T{ ##branch }
     }
     1
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare-branch f V int-regs 0 V int-regs 0 cc/= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare-branch f 0 0 cc/= }
     } test-branch-folding
 ] unit-test
 
 [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##load-reference f V int-regs 1 t }
+        T{ ##peek f 0 D 0 }
+        T{ ##load-reference f 1 t }
         T{ ##branch }
     }
     0
 ] [
     {
-        T{ ##peek f V int-regs 0 D 0 }
-        T{ ##compare f V int-regs 1 V int-regs 0 V int-regs 0 cc<= }
-        T{ ##compare-imm-branch f V int-regs 1 5 cc/= }
+        T{ ##peek f 0 D 0 }
+        T{ ##compare f 1 0 0 cc<= }
+        T{ ##compare-imm-branch f 1 5 cc/= }
     } test-branch-folding
 ] unit-test
 
@@ -1160,32 +1161,32 @@ cell 8 = [
 V{ T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
-    T{ ##compare-branch f V int-regs 0 V int-regs 0 cc< }
+    T{ ##peek f 0 D 0 }
+    T{ ##compare-branch f 0 0 cc< }
 } 1 test-bb
 
 V{
-    T{ ##load-immediate f V int-regs 1 1 }
+    T{ ##load-immediate f 1 1 }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##load-immediate f V int-regs 2 2 }
+    T{ ##load-immediate f 2 2 }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##phi f V int-regs 3 H{ { 2 V int-regs 1 } { 3 V int-regs 2 } } }
-    T{ ##replace f V int-regs 3 D 0 }
+    T{ ##phi f 3 H{ { 2 1 } { 3 2 } } }
+    T{ ##replace f 3 D 0 }
     T{ ##return }
 } 4 test-bb
 
 test-diamond
 
 [ ] [
-    cfg new 0 get >>entry
+    cfg new 0 get >>entry dup cfg set
     value-numbering
-    compute-predecessors
+    select-representations
     destruct-ssa drop
 ] unit-test
 
@@ -1196,40 +1197,38 @@ test-diamond
 [ 2 ] [ 4 get instructions>> length ] unit-test
 
 V{
-    T{ ##peek f V int-regs 0 D 0 }
+    T{ ##peek f 0 D 0 }
     T{ ##branch }
 } 0 test-bb
 
 V{
-    T{ ##peek f V int-regs 1 D 1 }
-    T{ ##compare-branch f V int-regs 1 V int-regs 1 cc< }
+    T{ ##peek f 1 D 1 }
+    T{ ##compare-branch f 1 1 cc< }
 } 1 test-bb
 
 V{
-    T{ ##copy f V int-regs 2 V int-regs 0 }
+    T{ ##copy f 2 0 any-rep }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##phi f V int-regs 3 V{ } }
+    T{ ##phi f 3 V{ } }
     T{ ##branch }
 } 3 test-bb
 
 V{
-    T{ ##replace f V int-regs 3 D 0 }
+    T{ ##replace f 3 D 0 }
     T{ ##return }
 } 4 test-bb
 
-1 get V int-regs 1 2array
-2 get V int-regs 0 2array 2array 3 get instructions>> first (>>inputs)
+1 get 1 2array
+2 get 0 2array 2array 3 get instructions>> first (>>inputs)
 
 test-diamond
 
 [ ] [
     cfg new 0 get >>entry
-    compute-predecessors
     value-numbering
-    compute-predecessors
     eliminate-dead-code
     drop
 ] unit-test
@@ -1241,52 +1240,52 @@ test-diamond
 V{ T{ ##prologue } T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##peek { dst V int-regs 15 } { loc D 0 } }
-    T{ ##copy { dst V int-regs 16 } { src V int-regs 15 } }
-    T{ ##copy { dst V int-regs 17 } { src V int-regs 15 } }
-    T{ ##copy { dst V int-regs 18 } { src V int-regs 15 } }
-    T{ ##copy { dst V int-regs 19 } { src V int-regs 15 } }
+    T{ ##peek { dst 15 } { loc D 0 } }
+    T{ ##copy { dst 16 } { src 15 } { rep any-rep } }
+    T{ ##copy { dst 17 } { src 15 } { rep any-rep } }
+    T{ ##copy { dst 18 } { src 15 } { rep any-rep } }
+    T{ ##copy { dst 19 } { src 15 } { rep any-rep } }
     T{ ##compare
-        { dst V int-regs 20 }
-        { src1 V int-regs 18 }
-        { src2 V int-regs 19 }
+        { dst 20 }
+        { src1 18 }
+        { src2 19 }
         { cc cc= }
-        { temp V int-regs 22 }
+        { temp 22 }
     }
-    T{ ##copy { dst V int-regs 21 } { src V int-regs 20 } }
+    T{ ##copy { dst 21 } { src 20 } { rep any-rep } }
     T{ ##compare-imm-branch
-        { src1 V int-regs 21 }
+        { src1 21 }
         { src2 5 }
         { cc cc/= }
     }
 } 1 test-bb
 
 V{
-    T{ ##copy { dst V int-regs 23 } { src V int-regs 15 } }
-    T{ ##copy { dst V int-regs 24 } { src V int-regs 15 } }
-    T{ ##load-reference { dst V int-regs 25 } { obj t } }
+    T{ ##copy { dst 23 } { src 15 } { rep any-rep } }
+    T{ ##copy { dst 24 } { src 15 } { rep any-rep } }
+    T{ ##load-reference { dst 25 } { obj t } }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##replace { src V int-regs 25 } { loc D 0 } }
+    T{ ##replace { src 25 } { loc D 0 } }
     T{ ##epilogue }
     T{ ##return }
 } 3 test-bb
 
 V{
-    T{ ##copy { dst V int-regs 26 } { src V int-regs 15 } }
-    T{ ##copy { dst V int-regs 27 } { src V int-regs 15 } }
+    T{ ##copy { dst 26 } { src 15 } { rep any-rep } }
+    T{ ##copy { dst 27 } { src 15 } { rep any-rep } }
     T{ ##add
-        { dst V int-regs 28 }
-        { src1 V int-regs 26 }
-        { src2 V int-regs 27 }
+        { dst 28 }
+        { src1 26 }
+        { src2 27 }
     }
     T{ ##branch }
 } 4 test-bb
 
 V{
-    T{ ##replace { src V int-regs 28 } { loc D 0 } }
+    T{ ##replace { src 28 } { loc D 0 } }
     T{ ##epilogue }
     T{ ##return }
 } 5 test-bb
index a249f71c023d7e7802f54aae35e59baea4a2e072..689d1d32c67666e51dbfe58f183444aa5afeb39f 100644 (file)
@@ -2,6 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces assocs kernel accessors
 sorting sets sequences
+cpu.architecture
 compiler.cfg
 compiler.cfg.rpo
 compiler.cfg.instructions
@@ -11,10 +12,11 @@ compiler.cfg.value-numbering.simplify
 compiler.cfg.value-numbering.rewrite ;
 IN: compiler.cfg.value-numbering
 
-! Local value numbering. Predecessors must be recomputed after this
+! Local value numbering.
+
 : >copy ( insn -- insn/##copy )
     dup dst>> dup vreg>vn vn>vreg
-    2dup eq? [ 2drop ] [ \ ##copy new-insn nip ] if ;
+    2dup eq? [ 2drop ] [ any-rep \ ##copy new-insn nip ] if ;
 
 : rewrite-loop ( insn -- insn' )
     dup rewrite [ rewrite-loop ] [ ] ?if ;
@@ -36,4 +38,6 @@ M: insn process-instruction
     [ process-instruction ] map ;
 
 : value-numbering ( cfg -- cfg' )
-    [ value-numbering-step ] local-optimization cfg-changed ;
+    [ value-numbering-step ] local-optimization
+
+    cfg-changed predecessors-changed ;
diff --git a/basis/compiler/cfg/write-barrier/authors.txt b/basis/compiler/cfg/write-barrier/authors.txt
new file mode 100644 (file)
index 0000000..a44f8d7
--- /dev/null
@@ -0,0 +1,2 @@
+Slava Pestov
+Daniel Ehrenberg
index 14197bc3f74830f5cd3f26911d822fe557262f1b..dd010f0dbc1f140c7c09edfdce5f67be1f0fd201 100644 (file)
@@ -1,7 +1,9 @@
+! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
+! See http://factorcode.org/license.txt for BSD license.
 USING: compiler.cfg.write-barrier compiler.cfg.instructions
 compiler.cfg.registers compiler.cfg.debugger cpu.architecture
 arrays tools.test vectors compiler.cfg kernel accessors
-compiler.cfg.utilities ;
+compiler.cfg.utilities namespaces sequences ;
 IN: compiler.cfg.write-barrier.tests
 
 : test-write-barrier ( insns -- insns )
@@ -9,64 +11,132 @@ IN: compiler.cfg.write-barrier.tests
 
 [
     V{
-        T{ ##peek f V int-regs 4 D 0 f }
-        T{ ##allot f V int-regs 7 24 array V int-regs 8 f }
-        T{ ##load-immediate f V int-regs 9 8 f }
-        T{ ##set-slot-imm f V int-regs 9 V int-regs 7 1 3 f }
-        T{ ##set-slot-imm f V int-regs 4 V int-regs 7 2 3 f }
-        T{ ##replace f V int-regs 7 D 0 f }
+        T{ ##peek f 4 D 0 f }
+        T{ ##allot f 7 24 array 8 f }
+        T{ ##load-immediate f 9 8 f }
+        T{ ##set-slot-imm f 9 7 1 3 f }
+        T{ ##set-slot-imm f 4 7 2 3 f }
+        T{ ##replace f 7 D 0 f }
         T{ ##branch }
     }
 ] [
     {
-        T{ ##peek f V int-regs 4 D 0 }
-        T{ ##allot f V int-regs 7 24 array V int-regs 8 }
-        T{ ##load-immediate f V int-regs 9 8 }
-        T{ ##set-slot-imm f V int-regs 9 V int-regs 7 1 3 }
-        T{ ##write-barrier f V int-regs 7 V int-regs 10 V int-regs 11 }
-        T{ ##set-slot-imm f V int-regs 4 V int-regs 7 2 3 }
-        T{ ##write-barrier f V int-regs 7 V int-regs 12 V int-regs 13 }
-        T{ ##replace f V int-regs 7 D 0 }
+        T{ ##peek f 4 D 0 }
+        T{ ##allot f 7 24 array 8 }
+        T{ ##load-immediate f 9 8 }
+        T{ ##set-slot-imm f 9 7 1 3 }
+        T{ ##write-barrier f 7 10 11 }
+        T{ ##set-slot-imm f 4 7 2 3 }
+        T{ ##write-barrier f 7 12 13 }
+        T{ ##replace f 7 D 0 }
     } test-write-barrier
 ] unit-test
 
 [
     V{
-        T{ ##load-immediate f V int-regs 4 24 }
-        T{ ##peek f V int-regs 5 D -1 }
-        T{ ##peek f V int-regs 6 D -2 }
-        T{ ##set-slot-imm f V int-regs 5 V int-regs 6 3 2 }
-        T{ ##write-barrier f V int-regs 6 V int-regs 7 V int-regs 8 }
+        T{ ##load-immediate f 4 24 }
+        T{ ##peek f 5 D -1 }
+        T{ ##peek f 6 D -2 }
+        T{ ##set-slot-imm f 5 6 3 2 }
+        T{ ##write-barrier f 6 7 8 }
         T{ ##branch }
     }
 ] [
     {
-        T{ ##load-immediate f V int-regs 4 24 }
-        T{ ##peek f V int-regs 5 D -1 }
-        T{ ##peek f V int-regs 6 D -2 }
-        T{ ##set-slot-imm f V int-regs 5 V int-regs 6 3 2 }
-        T{ ##write-barrier f V int-regs 6 V int-regs 7 V int-regs 8 }
+        T{ ##load-immediate f 4 24 }
+        T{ ##peek f 5 D -1 }
+        T{ ##peek f 6 D -2 }
+        T{ ##set-slot-imm f 5 6 3 2 }
+        T{ ##write-barrier f 6 7 8 }
     } test-write-barrier
 ] unit-test
 
 [
     V{
-        T{ ##peek f V int-regs 19 D -3 }
-        T{ ##peek f V int-regs 22 D -2 }
-        T{ ##set-slot-imm f V int-regs 22 V int-regs 19 3 2 }
-        T{ ##write-barrier f V int-regs 19 V int-regs 24 V int-regs 25 }
-        T{ ##peek f V int-regs 28 D -1 }
-        T{ ##set-slot-imm f V int-regs 28 V int-regs 19 4 2 }
+        T{ ##peek f 19 D -3 }
+        T{ ##peek f 22 D -2 }
+        T{ ##set-slot-imm f 22 19 3 2 }
+        T{ ##write-barrier f 19 24 25 }
+        T{ ##peek f 28 D -1 }
+        T{ ##set-slot-imm f 28 19 4 2 }
         T{ ##branch }
     }
 ] [
     {
-        T{ ##peek f V int-regs 19 D -3 }
-        T{ ##peek f V int-regs 22 D -2 }
-        T{ ##set-slot-imm f V int-regs 22 V int-regs 19 3 2 }
-        T{ ##write-barrier f V int-regs 19 V int-regs 24 V int-regs 25 }
-        T{ ##peek f V int-regs 28 D -1 }
-        T{ ##set-slot-imm f V int-regs 28 V int-regs 19 4 2 }
-        T{ ##write-barrier f V int-regs 19 V int-regs 30 V int-regs 3 }
+        T{ ##peek f 19 D -3 }
+        T{ ##peek f 22 D -2 }
+        T{ ##set-slot-imm f 22 19 3 2 }
+        T{ ##write-barrier f 19 24 25 }
+        T{ ##peek f 28 D -1 }
+        T{ ##set-slot-imm f 28 19 4 2 }
+        T{ ##write-barrier f 19 30 3 }
     } test-write-barrier
 ] unit-test
+
+V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} 1 test-bb
+V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} 2 test-bb
+1 get 2 get 1vector >>successors drop
+cfg new 1 get >>entry 0 set
+
+[ ] [ 0 [ eliminate-write-barriers ] change ] unit-test
+[ V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} ] [ 1 get instructions>> ] unit-test
+[ V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+} ] [ 2 get instructions>> ] unit-test
+
+V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} 1 test-bb
+V{
+    T{ ##allot }
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} 2 test-bb
+1 get 2 get 1vector >>successors drop
+cfg new 1 get >>entry 0 set
+
+[ ] [ 0 [ eliminate-write-barriers ] change ] unit-test
+[ V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} ] [ 1 get instructions>> ] unit-test
+[ V{
+    T{ ##allot }
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} ] [ 2 get instructions>> ] unit-test
+
+V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} 1 test-bb
+V{
+    T{ ##allot }
+} 2 test-bb
+1 get 2 get 1vector >>successors drop
+V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} 3 test-bb
+2 get 3 get 1vector >>successors drop
+cfg new 1 get >>entry 0 set
+[ ] [ 0 [ eliminate-write-barriers ] change ] unit-test
+[ V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} ] [ 1 get instructions>> ] unit-test
+[ V{ T{ ##allot } } ] [ 2 get instructions>> ] unit-test
+[ V{
+    T{ ##set-slot-imm f 2 1 3 4 }
+    T{ ##write-barrier f 1 2 3 }
+} ] [ 3 get instructions>> ] unit-test
index 2f32a4ca81a0931906656e2c2203f0ce73103263..2375075df5cb85ea0fb2f76168ed169dfd2cf75c 100644 (file)
@@ -1,7 +1,8 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors namespaces assocs sets sequences
-compiler.cfg compiler.cfg.instructions compiler.cfg.rpo ;
+compiler.cfg compiler.cfg.instructions compiler.cfg.rpo
+compiler.cfg.dataflow-analysis fry combinators.short-circuit ;
 IN: compiler.cfg.write-barrier
 
 ! Eliminate redundant write barrier hits.
@@ -30,10 +31,27 @@ M: ##set-slot-imm eliminate-write-barrier
 
 M: insn eliminate-write-barrier drop t ;
 
+FORWARD-ANALYSIS: safe
+
+: has-allocation? ( bb -- ? )
+    instructions>> [ { [ ##allocation? ] [ ##call? ] } 1|| ] any? ;
+
+M: safe-analysis transfer-set
+    drop [ H{ } assoc-clone-like ] dip
+    instructions>> over '[
+        dup ##write-barrier? [
+            src>> _ conjoin
+        ] [ drop ] if
+    ] each ;
+
+M: safe-analysis join-sets
+    drop has-allocation? [ drop H{ } clone ] [ assoc-refine ] if ;
+
 : write-barriers-step ( bb -- )
-    H{ } clone safe set
+    dup safe-in H{ } assoc-clone-like safe set
     H{ } clone mutated set
     instructions>> [ eliminate-write-barrier ] filter-here ;
 
 : eliminate-write-barriers ( cfg -- cfg' )
+     dup compute-safe-sets
     dup [ write-barriers-step ] each-basic-block ;
index 9c3817bad626457085bd64a8656a02cddb28e4b2..225577d0b949b9feb8db8a7d9ef9fe4d5973ffd2 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.codegen.tests
 USING: compiler.codegen.fixup tools.test cpu.architecture math kernel make
 compiler.constants ;
+IN: compiler.codegen.tests
 
 [ ] [ [ ] with-fixup drop ] unit-test
 [ ] [ [ \ + %call ] with-fixup drop ] unit-test
index 672ed9ce02aaf5c668c663490e6c6b5d98084ab5..d1a09394cd99374c611054e5c97cc2dcb00a58ec 100755 (executable)
@@ -173,12 +173,12 @@ M: ##div-float generate-insn dst/src1/src2 %div-float ;
 M: ##integer>float generate-insn dst/src %integer>float ;
 M: ##float>integer generate-insn dst/src %float>integer ;
 
-M: ##copy             generate-insn dst/src %copy ;
-M: ##copy-float       generate-insn dst/src %copy-float ;
-M: ##unbox-float      generate-insn dst/src %unbox-float ;
-M: ##unbox-any-c-ptr  generate-insn dst/src/temp %unbox-any-c-ptr ;
-M: ##box-float        generate-insn dst/src/temp %box-float ;
-M: ##box-alien        generate-insn dst/src/temp %box-alien ;
+M: ##copy generate-insn [ dst/src ] [ rep>> ] bi %copy ;
+
+M: ##unbox-float     generate-insn dst/src %unbox-float ;
+M: ##unbox-any-c-ptr generate-insn dst/src/temp %unbox-any-c-ptr ;
+M: ##box-float       generate-insn dst/src/temp %box-float ;
+M: ##box-alien       generate-insn dst/src/temp %box-alien ;
 
 M: ##alien-unsigned-1 generate-insn dst/src %alien-unsigned-1 ;
 M: ##alien-unsigned-2 generate-insn dst/src %alien-unsigned-2 ;
@@ -226,31 +226,37 @@ M: ##write-barrier generate-insn
 GENERIC# save-gc-root 1 ( gc-root operand temp -- )
 
 M:: spill-slot save-gc-root ( gc-root operand temp -- )
-    temp operand n>> %reload-integer
+    temp operand n>> int-rep %reload
     gc-root temp %save-gc-root ;
 
 M: object save-gc-root drop %save-gc-root ;
 
 : save-gc-roots ( gc-roots temp -- ) '[ _ save-gc-root ] assoc-each ;
 
+: save-data-regs ( data-regs -- ) [ first3 %spill ] each ;
+
 GENERIC# load-gc-root 1 ( gc-root operand temp -- )
 
 M:: spill-slot load-gc-root ( gc-root operand temp -- )
     gc-root temp %load-gc-root
-    temp operand n>> %spill-integer ;
+    temp operand n>> int-rep %spill ;
 
 M: object load-gc-root drop %load-gc-root ;
 
 : load-gc-roots ( gc-roots temp -- ) '[ _ load-gc-root ] assoc-each ;
 
+: load-data-regs ( data-regs -- ) [ first3 %reload ] each ;
+
 M: _gc generate-insn
     "no-gc" define-label
     {
         [ [ "no-gc" get ] dip [ temp1>> ] [ temp2>> ] bi %check-nursery ]
         [ [ uninitialized-locs>> ] [ temp1>> ] bi wipe-locs ]
-        [ [ gc-roots>> ] [ temp1>> ] bi save-gc-roots ]
-        [ gc-root-count>> %call-gc ]
-        [ [ gc-roots>> ] [ temp1>> ] bi load-gc-roots ]
+        [ data-values>> save-data-regs ]
+        [ [ tagged-values>> ] [ temp1>> ] bi save-gc-roots ]
+        [ tagged-values>> length %call-gc ]
+        [ [ tagged-values>> ] [ temp1>> ] bi load-gc-roots ]
+        [ data-values>> load-data-regs ]
     } cleave
     "no-gc" resolve-label ;
 
@@ -261,54 +267,45 @@ M: ##alien-global generate-insn
     %alien-global ;
 
 ! ##alien-invoke
-GENERIC: reg-class-variable ( register-class -- symbol )
-
-M: reg-class reg-class-variable ;
-
-M: float-regs reg-class-variable drop float-regs ;
+GENERIC: next-fastcall-param ( reg-class -- )
 
-GENERIC: inc-reg-class ( register-class -- )
+: ?dummy-stack-params ( rep -- )
+    dummy-stack-params? [ rep-size cell align stack-params +@ ] [ drop ] if ;
 
-: ?dummy-stack-params ( reg-class -- )
-    dummy-stack-params? [ reg-size cell align stack-params +@ ] [ drop ] if ;
+: ?dummy-int-params ( rep -- )
+    dummy-int-params? [ rep-size cell /i 1 max int-regs +@ ] [ drop ] if ;
 
-: ?dummy-int-params ( reg-class -- )
-    dummy-int-params? [ reg-size cell /i 1 max int-regs +@ ] [ drop ] if ;
-
-: ?dummy-fp-params ( reg-class -- )
+: ?dummy-fp-params ( rep -- )
     drop dummy-fp-params? [ float-regs inc ] when ;
 
-M: int-regs inc-reg-class
-    [ reg-class-variable inc ]
-    [ ?dummy-stack-params ]
-    [ ?dummy-fp-params ]
-    tri ;
+M: int-rep next-fastcall-param
+    int-regs inc [ ?dummy-stack-params ] [ ?dummy-fp-params ] bi ;
 
-M: float-regs inc-reg-class
-    [ reg-class-variable inc ]
-    [ ?dummy-stack-params ]
-    [ ?dummy-int-params ]
-    tri ;
+M: single-float-rep next-fastcall-param
+    float-regs inc [ ?dummy-stack-params ] [ ?dummy-int-params ] bi ;
 
-GENERIC: reg-class-full? ( class -- ? )
+M: double-float-rep next-fastcall-param
+    float-regs inc [ ?dummy-stack-params ] [ ?dummy-int-params ] bi ;
+
+GENERIC: reg-class-full? ( reg-class -- ? )
 
 M: stack-params reg-class-full? drop t ;
 
-M: object reg-class-full?
-    [ reg-class-variable get ] [ param-regs length ] bi >= ;
+M: reg-class reg-class-full?
+    [ get ] [ param-regs length ] bi >= ;
 
-: spill-param ( reg-class -- n reg-class )
+: alloc-stack-param ( rep -- n reg-class rep )
     stack-params get
-    [ reg-size cell align stack-params +@ ] dip
-    stack-params ;
+    [ rep-size cell align stack-params +@ ] dip
+    stack-params dup ;
 
-: fastcall-param ( reg-class -- n reg-class )
-    [ reg-class-variable get ] [ inc-reg-class ] [ ] tri ;
+: alloc-fastcall-param ( rep -- n reg-class rep )
+    [ reg-class-of [ get ] [ inc ] [ ] tri ] keep ;
 
-: alloc-parameter ( parameter -- reg reg-class )
-    c-type-reg-class dup reg-class-full?
-    [ spill-param ] [ fastcall-param ] if
-    [ param-reg ] keep ;
+: alloc-parameter ( parameter -- reg rep )
+    c-type-rep dup reg-class-of reg-class-full?
+    [ alloc-stack-param ] [ alloc-fastcall-param ] if
+    [ param-reg ] dip ;
 
 : (flatten-int-type) ( size -- seq )
     cell /i "void*" c-type <repetition> ;
@@ -340,12 +337,12 @@ M: long-long-type flatten-value-type ( type -- types )
 : reverse-each-parameter ( parameters quot -- )
     [ [ parameter-sizes nip ] keep ] dip 2reverse-each ; inline
 
-: reset-freg-counts ( -- )
+: reset-fastcall-counts ( -- )
     { int-regs float-regs stack-params } [ 0 swap set ] each ;
 
 : with-param-regs ( quot -- )
     #! In quot you can call alloc-parameter
-    [ reset-freg-counts call ] with-scope ; inline
+    [ reset-fastcall-counts call ] with-scope ; inline
 
 : move-parameters ( node word -- )
     #! Moves values from C stack to registers (if word is
@@ -431,6 +428,7 @@ M: ##alien-indirect generate-insn
     alien-parameters [ box-parameter ] each-parameter ;
 
 : registers>objects ( node -- )
+    ! Generate code for boxing input parameters in a callback.
     [
         dup \ %save-param-reg move-parameters
         "nest_stacks" f %alien-invoke
@@ -528,21 +526,9 @@ M: _compare-float-branch generate-insn
     >binary-branch< %compare-float-branch ;
 
 M: _spill generate-insn
-    [ src>> ] [ n>> ] [ class>> ] tri {
-        { int-regs [ %spill-integer ] }
-        { double-float-regs [ %spill-float ] }
-    } case ;
+    [ src>> ] [ n>> ] [ rep>> ] tri %spill ;
 
 M: _reload generate-insn
-    [ dst>> ] [ n>> ] [ class>> ] tri {
-        { int-regs [ %reload-integer ] }
-        { double-float-regs [ %reload-float ] }
-    } case ;
-
-M: _copy generate-insn
-    [ dst>> ] [ src>> ] [ class>> ] tri {
-        { int-regs [ %copy ] }
-        { double-float-regs [ %copy-float ] }
-    } case ;
-
-M: _spill-counts generate-insn drop ;
+    [ dst>> ] [ n>> ] [ rep>> ] tri %reload ;
+
+M: _spill-area-size generate-insn drop ;
index 6d0f6f3acefdaf3643709c83cfe9e5e9ca79a555..3b8d996f3437a8005afbbea4ff31d60c00bac129 100644 (file)
@@ -12,6 +12,7 @@ compiler.errors compiler.units compiler.utilities
 compiler.tree.builder
 compiler.tree.optimizer
 
+compiler.cfg
 compiler.cfg.builder
 compiler.cfg.optimizer
 compiler.cfg.mr
@@ -152,8 +153,7 @@ t compile-dependencies? set-global
 
 : backend ( tree word -- )
     build-cfg [
-        optimize-cfg
-        build-mr
+        [ optimize-cfg build-mr ] with-cfg
         generate
         save-asm
     ] each ;
index 91215baf19dc401c35328ee9da5a1c0d7e9c110a..e3c5dee91746a6d2e3802d68f93d52a556173a25 100755 (executable)
@@ -395,7 +395,7 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 
 : callback-9 ( -- callback )
     "int" { "int" "int" "int" } "cdecl" [
-        + + 1+
+        + + 1 +
     ] alien-callback ;
 
 FUNCTION: void ffi_test_36_point_5 ( ) ;
@@ -599,4 +599,4 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ;
 [ 123 ] [
     "bool-field-test" <c-object> 123 over set-bool-field-test-parents
     ffi_test_48
-] unit-test
\ No newline at end of file
+] unit-test
index a9fd313d646eddffcc0e87c04417a76c136432f4..f90897bc9bd34c4e1b5e682972f0cdc702838c43 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.call-effect
 USING: tools.test combinators generic.single sequences kernel ;
+IN: compiler.tests.call-effect
 
 : execute-ic-test ( a b -- c ) execute( a -- c ) ;
 
@@ -11,4 +11,4 @@ USING: tools.test combinators generic.single sequences kernel ;
 [ ] [ [ ] call-test ] unit-test
 [ ] [ f [ drop ] curry call-test ] unit-test
 [ ] [ [ ] [ ] compose call-test ] unit-test
-[ [ 1 2 3 ] call-test ] [ wrong-values? ] must-fail-with
\ No newline at end of file
+[ [ 1 2 3 ] call-test ] [ wrong-values? ] must-fail-with
index ffd729550116cf1e3f31439e5c233ba9c48c6341..5f06fc8d2a617d3782245aadae2b971f0783c57e 100644 (file)
@@ -392,4 +392,13 @@ cell 4 = [
  [ 3 3 2 ] [ 4 3 "" coalescing-bug-4 ] unit-test
  [ 2 3 1 ] [ 2 3 V{ } coalescing-bug-4 ] unit-test
  [ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test
- [ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test
\ No newline at end of file
+ [ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test
+! Global stack analysis dataflow equations are wrong
+: some-word ( a -- b ) 2 + ;
+: global-dcn-bug-1 ( a b -- c d )
+    dup [ [ drop 1 ] dip ] [ [ some-word ] dip ] if
+    dup [ [ 1 fixnum+fast ] dip ] [ [ drop 1 ] dip ] if ;
+
+[ 2 t ] [ 0 t global-dcn-bug-1 ] unit-test
+[ 1 f ] [ 0 f global-dcn-bug-1 ] unit-test
\ No newline at end of file
index 7074b73845e46aacafbf77d71d5844840d33cd6f..138437543e8b15f782933e066114d9e253af67e5 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.tests.float
 USING: compiler.units compiler kernel kernel.private memory math
 math.private tools.test math.floats.private ;
+IN: compiler.tests.float
 
 [ 5.0 ] [ [ 5.0 ] compile-call gc gc gc ] unit-test
 [ 2.0 3.0 ] [ 3.0 [ 2.0 swap ] compile-call ] unit-test
index 6b0ef2d4393d859b8107c1747071c3ab831cb947..30392f159844204da9c0c565c8fc12c4b215b13d 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.generic
 USING: tools.test math kernel compiler.units definitions ;
+IN: compiler.tests.generic
 
 GENERIC: bad ( -- )
 M: integer bad ;
@@ -8,4 +8,4 @@ M: object bad ;
 [ 0 bad ] must-fail
 [ "" bad ] must-fail
 
-[ ] [ [ \ bad forget ] with-compilation-unit ] unit-test
\ No newline at end of file
+[ ] [ [ \ bad forget ] with-compilation-unit ] unit-test
index f1ebeded7bbaa49bb1755e0a6c4e5db1669e095c..ececac303772e6fd5eb2895caf373a504290b3ab 100644 (file)
@@ -12,15 +12,16 @@ IN: compiler.tests.low-level-ir
     [ associate >alist modify-code-heap ] keep ;
 
 : compile-test-cfg ( -- word )
-    cfg new
-    0 get >>entry
+    cfg new 0 get >>entry
+    dup cfg set
+    dup fake-representations representations get >>reps
     compile-cfg ;
 
 : compile-test-bb ( insns -- result )
     V{ T{ ##prologue } T{ ##branch } } 0 test-bb
     V{
         T{ ##inc-d f 1 }
-        T{ ##replace f V int-regs 0 D 0 }
+        T{ ##replace f 0 D 0 }
         T{ ##branch }
     } [ clone ] map append 1 test-bb
     V{
@@ -35,13 +36,13 @@ IN: compiler.tests.low-level-ir
 ! loading immediates
 [ f ] [
     V{
-        T{ ##load-immediate f V int-regs 0 5 }
+        T{ ##load-immediate f 0 5 }
     } compile-test-bb
 ] unit-test
 
 [ "hello" ] [
     V{
-        T{ ##load-reference f V int-regs 0 "hello" }
+        T{ ##load-reference f 0 "hello" }
     } compile-test-bb
 ] unit-test
 
@@ -49,72 +50,72 @@ IN: compiler.tests.low-level-ir
 ! one of the sources
 [ t ] [
     V{
-        T{ ##load-immediate f V int-regs 1 $[ 2 cell log2 shift ] }
-        T{ ##load-reference f V int-regs 0 { t f t } }
-        T{ ##slot f V int-regs 0 V int-regs 0 V int-regs 1 $[ array tag-number ] V int-regs 2 }
+        T{ ##load-immediate f 1 $[ 2 cell log2 shift ] }
+        T{ ##load-reference f 0 { t f t } }
+        T{ ##slot f 0 0 1 $[ array tag-number ] 2 }
     } compile-test-bb
 ] unit-test
 
 [ t ] [
     V{
-        T{ ##load-reference f V int-regs 0 { t f t } }
-        T{ ##slot-imm f V int-regs 0 V int-regs 0 2 $[ array tag-number ] V int-regs 2 }
+        T{ ##load-reference f 0 { t f t } }
+        T{ ##slot-imm f 0 0 2 $[ array tag-number ] 2 }
     } compile-test-bb
 ] unit-test
 
 [ t ] [
     V{
-        T{ ##load-immediate f V int-regs 1 $[ 2 cell log2 shift ] }
-        T{ ##load-reference f V int-regs 0 { t f t } }
-        T{ ##set-slot f V int-regs 0 V int-regs 0 V int-regs 1 $[ array tag-number ] V int-regs 2 }
+        T{ ##load-immediate f 1 $[ 2 cell log2 shift ] }
+        T{ ##load-reference f 0 { t f t } }
+        T{ ##set-slot f 0 0 1 $[ array tag-number ] 2 }
     } compile-test-bb
     dup first eq?
 ] unit-test
 
 [ t ] [
     V{
-        T{ ##load-reference f V int-regs 0 { t f t } }
-        T{ ##set-slot-imm f V int-regs 0 V int-regs 0 2 $[ array tag-number ] }
+        T{ ##load-reference f 0 { t f t } }
+        T{ ##set-slot-imm f 0 0 2 $[ array tag-number ] }
     } compile-test-bb
     dup first eq?
 ] unit-test
 
 [ 8 ] [
     V{
-        T{ ##load-immediate f V int-regs 0 4 }
-        T{ ##shl f V int-regs 0 V int-regs 0 V int-regs 0 }
+        T{ ##load-immediate f 0 4 }
+        T{ ##shl f 0 0 0 }
     } compile-test-bb
 ] unit-test
 
 [ 4 ] [
     V{
-        T{ ##load-immediate f V int-regs 0 4 }
-        T{ ##shl-imm f V int-regs 0 V int-regs 0 3 }
+        T{ ##load-immediate f 0 4 }
+        T{ ##shl-imm f 0 0 3 }
     } compile-test-bb
 ] unit-test
 
 [ 31 ] [
     V{
-        T{ ##load-reference f V int-regs 1 B{ 31 67 52 } }
-        T{ ##unbox-any-c-ptr f V int-regs 0 V int-regs 1 V int-regs 2 }
-        T{ ##alien-unsigned-1 f V int-regs 0 V int-regs 0 }
-        T{ ##shl-imm f V int-regs 0 V int-regs 0 3 }
+        T{ ##load-reference f 1 B{ 31 67 52 } }
+        T{ ##unbox-any-c-ptr f 0 1 2 }
+        T{ ##alien-unsigned-1 f 0 0 }
+        T{ ##shl-imm f 0 0 3 }
     } compile-test-bb
 ] unit-test
 
 [ CHAR: l ] [
     V{
-        T{ ##load-reference f V int-regs 0 "hello world" }
-        T{ ##load-immediate f V int-regs 1 3 }
-        T{ ##string-nth f V int-regs 0 V int-regs 0 V int-regs 1 V int-regs 2 }
-        T{ ##shl-imm f V int-regs 0 V int-regs 0 3 }
+        T{ ##load-reference f 0 "hello world" }
+        T{ ##load-immediate f 1 3 }
+        T{ ##string-nth f 0 0 1 2 }
+        T{ ##shl-imm f 0 0 3 }
     } compile-test-bb
 ] unit-test
 
 [ 1 ] [
     V{
-        T{ ##load-immediate f V int-regs 0 16 }
-        T{ ##add-imm f V int-regs 0 V int-regs 0 -8 }
+        T{ ##load-immediate f 0 16 }
+        T{ ##add-imm f 0 0 -8 }
     } compile-test-bb
 ] unit-test
 
@@ -125,15 +126,15 @@ USE: multiline
 
 [ 100 ] [
     V{
-        T{ ##load-immediate f V int-regs 0 100 }
-        T{ ##integer>bignum f V int-regs 0 V int-regs 0 V int-regs 1 }
+        T{ ##load-immediate f 0 100 }
+        T{ ##integer>bignum f 0 0 1 }
     } compile-test-bb
 ] unit-test
 
 [ 1 ] [
     V{
-        T{ ##load-reference f V int-regs 0 ALIEN: 8 }
-        T{ ##unbox-any-c-ptr f V int-regs 0 V int-regs 0 V int-regs 1 }
+        T{ ##load-reference f 0 ALIEN: 8 }
+        T{ ##unbox-any-c-ptr f 0 0 1 }
     } compile-test-bb
 ] unit-test
 
index 72618db4569740d4d583d83e9c1dc30bae19fa2d..9cd6cfaef2b6da4d371fd6d48b16eda905088285 100644 (file)
@@ -100,7 +100,7 @@ GENERIC: void-generic ( obj -- * )
 
 ! regression
 : branch-fold-regression-0 ( m -- n )
-    t [ ] [ 1+ branch-fold-regression-0 ] if ; inline recursive
+    t [ ] [ 1 + branch-fold-regression-0 ] if ; inline recursive
 
 : branch-fold-regression-1 ( -- m )
     10 branch-fold-regression-0 ;
@@ -348,12 +348,12 @@ TUPLE: some-tuple x ;
 
 [ T{ some-tuple f [ 3 ] } ] [ 3 allot-regression ] unit-test
 
-[ 1 ] [ B{ 0 0 0 0 } [ 0 alien-signed-4 1+ ] compile-call ] unit-test
-[ 1 ] [ B{ 0 0 0 0 } [ 0 alien-unsigned-4 1+ ] compile-call ] unit-test
-[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-signed-8 1+ ] compile-call ] unit-test
-[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-unsigned-8 1+ ] compile-call ] unit-test
-[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-signed-cell 1+ ] compile-call ] unit-test
-[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-unsigned-cell 1+ ] compile-call ] unit-test
+[ 1 ] [ B{ 0 0 0 0 } [ 0 alien-signed-4 1 + ] compile-call ] unit-test
+[ 1 ] [ B{ 0 0 0 0 } [ 0 alien-unsigned-4 1 + ] compile-call ] unit-test
+[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-signed-8 1 + ] compile-call ] unit-test
+[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-unsigned-8 1 + ] compile-call ] unit-test
+[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-signed-cell 1 + ] compile-call ] unit-test
+[ 1 ] [ B{ 0 0 0 0 0 0 0 0 } [ 0 alien-unsigned-cell 1 + ] compile-call ] unit-test
 
 : deep-find-test ( seq -- ? ) [ 5 = ] deep-find ;
 
@@ -382,7 +382,7 @@ DEFER: loop-bbb
 ! Type inference issue
 [ 4 3 ] [
     1 >bignum 2 >bignum
-    [ { bignum integer } declare [ shift ] keep 1+ ] compile-call
+    [ { bignum integer } declare [ shift ] keep 1 + ] compile-call
 ] unit-test
 
 : broken-declaration ( -- ) \ + declare ;
@@ -391,6 +391,17 @@ DEFER: loop-bbb
 
 [ ] [ [ \ broken-declaration forget ] with-compilation-unit ] unit-test
 
+! Interval inference issue
+[ f ] [
+    10 70
+    [
+        dup 70 >=
+        [ dup 700 <= [ swap 1024 rem rem ] [ 2drop 70 ] if ]
+        [ 2drop 70 ] if
+        70 >=
+    ] compile-call
+] unit-test
+
 ! Modular arithmetic bug
 : modular-arithmetic-bug ( a -- b ) >integer 256 mod ;
 
@@ -411,4 +422,4 @@ M: object bad-dispatch-position-test* ;
         \ bad-dispatch-position-test forget
         \ bad-dispatch-position-test* forget
     ] with-compilation-unit
-] unit-test
\ No newline at end of file
+] unit-test
index 7929d9e6f6c13b6f211fad969f604d419d725e34..cae57e5bd9a3914b6745ba6c8f114a6a6cbc25bc 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.peg-regression-2
 USING: peg.ebnf strings tools.test ;
+IN: compiler.tests.peg-regression-2
 
 GENERIC: <times> ( times -- term' )
 M: string <times> ;
index 4adf0b36b93dd04dff53d3f62a662844df2b9be5..4da83f53e4a0b9d50d167fd30b8ccb4a6f2b6565 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.pic-problem-1
 USING: kernel sequences prettyprint memory tools.test ;
+IN: compiler.tests.pic-problem-1
 
 TUPLE: x ;
 
@@ -11,4 +11,4 @@ INSTANCE: x sequence
 
 CONSTANT: blah T{ x }
 
-[ T{ x } ] [ blah ] unit-test
\ No newline at end of file
+[ T{ x } ] [ blah ] unit-test
index 3d7a05a74b8ae274403f5bd29ced99fd9ea5b4c9..4de6d952c8fce6156067fc8e2c929aff49314614 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.tests.redefine0
 USING: tools.test eval compiler compiler.errors compiler.units definitions kernel math
 namespaces macros assocs ;
+IN: compiler.tests.redefine0
 
 ! Test ripple-up behavior
 : test-1 ( -- a ) 3 ;
index 33aa080bacb4955fa4762323b865f6cb8a6fde8f..54066c690d41f4c8244ef4df35ad0e4a39565e48 100644 (file)
@@ -11,7 +11,7 @@ DEFER: word-1
 
 : word-3 ( a -- b ) 1 + ;
 
-: word-4 ( a -- b c ) 0 swap word-3 swap 1+ ;
+: word-4 ( a -- b c ) 0 swap word-3 swap 1 + ;
 
 [ 1 1 ] [ 0 word-4 ] unit-test
 
index 3bef30f9f1bc15b6d06e5684ee9154f05e8f5b90..ac879a7c75799b23477dfa9f4acb0c3ed0a3c7ba 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.tests.redefine16
 USING: eval tools.test definitions words compiler.units
 quotations stack-checker ;
+IN: compiler.tests.redefine16
 
 [ ] [ [ "blah" "compiler.tests.redefine16" lookup forget ] with-compilation-unit ] unit-test
 
index 4ed3e36f4dff23466dd753671e35239451e8d627..5a1c33ad27849ddfdb0a3677b2001665672c8a99 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.tests.redefine17
 USING: tools.test classes.mixin compiler.units arrays kernel.private
 strings sequences vocabs definitions kernel ;
+IN: compiler.tests.redefine17
 
 << "compiler.tests.redefine17" words forget-all >>
 
index 9112a1e1afb439bf6b173e236785a9a19555ae4d..b6a46fc0df520487bc11dc67848303eb95e1a5f5 100644 (file)
@@ -1,7 +1,7 @@
-IN: compiler.tests.redefine2
 USING: compiler compiler.units tools.test math parser kernel
 sequences sequences.private classes.mixin generic definitions
 arrays words assocs eval words.symbol ;
+IN: compiler.tests.redefine2
 
 DEFER: redefine2-test
 
index 0a5eb8457918921af36e133abc398780af86ddca..38842696d7cc5539e2a61617892bec5482d4ea43 100644 (file)
@@ -1,7 +1,7 @@
-IN: compiler.tests.redefine3
 USING: accessors compiler compiler.units tools.test math parser
 kernel sequences sequences.private classes.mixin generic
 definitions arrays words assocs eval ;
+IN: compiler.tests.redefine3
 
 GENERIC: sheeple ( obj -- x )
 
index 2320f64af60a6da4ddbad5d66cd2795bd803a198..cc74e5a783c03ffeaa7470f9f8373b33b0c9fe46 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.redefine4
 USING: io.streams.string kernel tools.test eval ;
+IN: compiler.tests.redefine4
 
 : declaration-test-1 ( -- a ) 3 ; flushable
 
index 62c7c31bc2bd3975a6750ec2f4209d0659aedcaf..3bbfca876b175a1750a9df61b3dea1fe2467d78b 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.reload
 USE: vocabs.loader
+IN: compiler.tests.reload
 
 ! "parser" reload
 ! "sequences" reload
index 1cb11571ef7fa833712c08c55f4cc96d646b6f52..a160272b2118f20b894c8e614406bcf9cd82b2f3 100755 (executable)
@@ -1,7 +1,7 @@
-IN: compiler.tests.stack-trace
 USING: compiler tools.test namespaces sequences
 kernel.private kernel math continuations continuations.private
 words splitting grouping sorting accessors ;
+IN: compiler.tests.stack-trace
 
 : symbolic-stack-trace ( -- newseq )
     error-continuation get call>> callstack>array
index fc249d99db30fa1b36b6fa33df68d1954a451928..3d6301249f41ee44be25b1eb97f9e08450b4f94d 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tests.tuples
 USING: kernel tools.test compiler.units compiler ;
+IN: compiler.tests.tuples
 
 TUPLE: color red green blue ;
 
index b7ee51834b600128b5e1c6ba76108abd5ab05374..83093470c9e0168731429b3f789938718186dc5a 100644 (file)
@@ -9,5 +9,5 @@ HELP: build-tree
 { $errors "Throws an " { $link inference-error } " if stack effect inference fails." } ;
 
 HELP: build-sub-tree
-{ $values { "#call" #call } { "word/quot" { $or word quotation } } { "nodes/f" { $maybe "a sequence of nodes" } } }
+{ $values { "in-d" "a sequence of values" } { "out-d" "a sequence of values" } { "word/quot" { $or word quotation } } { "nodes/f" { $maybe "a sequence of nodes" } } }
 { $description "Attempts to construct tree SSA IR from a quotation, starting with an initial data stack of values from the call site. Outputs " { $link f } " if stack effect inference fails." } ;
index f3a2b99db623fe223c07f70277a92e4e5e421fe5..8359334550aa904d89ada27c877336ac15342ba9 100755 (executable)
@@ -1,6 +1,6 @@
-IN: compiler.tree.builder.tests
 USING: compiler.tree.builder tools.test sequences kernel
 compiler.tree stack-checker stack-checker.errors ;
+IN: compiler.tree.builder.tests
 
 : inline-recursive ( -- ) inline-recursive ; inline recursive
 
index 00325f5a72184ee5ef7024835ef35ce373f06060..e4523deb9ff7515575f0223e8e4afdac85f87582 100644 (file)
@@ -49,19 +49,18 @@ PRIVATE>
 : build-tree ( word/quot -- nodes )
     [ f ] dip build-tree-with ;
 
-:: build-sub-tree ( #call word/quot -- nodes/f )
+:: build-sub-tree ( in-d out-d word/quot -- nodes/f )
     #! We don't want methods on mixins to have a declaration for that mixin.
     #! This slows down compiler.tree.propagation.inlining since then every
     #! inlined usage of a method has an inline-dependency on the mixin, and
     #! not the more specific type at the call site.
     f specialize-method? [
         [
-            #call in-d>> word/quot build-tree-with unclip-last in-d>> :> in-d
+            in-d word/quot build-tree-with unclip-last in-d>> :> in-d'
             {
                 { [ dup not ] [ ] }
-                { [ dup ends-with-terminate? ] [ #call out-d>> [ f swap #push ] map append ] }
-                [ in-d #call out-d>> #copy suffix ]
+                { [ dup ends-with-terminate? ] [ out-d [ f swap #push ] map append ] }
+                [ in-d' out-d [ [ length ] bi@ assert= ] [ #copy suffix ] 2bi ]
             } cond
         ] [ dup inference-error? [ drop f ] [ rethrow ] if ] recover
-    ] with-variable ;
-
+    ] with-variable ;
\ No newline at end of file
diff --git a/basis/compiler/tree/checker/checker-tests.factor b/basis/compiler/tree/checker/checker-tests.factor
deleted file mode 100644 (file)
index d9591e7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: compiler.tree.checker.tests
-USING: compiler.tree.checker tools.test ;
-
-
index e25f152aefeda508316a10d7788b47416e898e64..0b3b46fe336da1463d13c1e0118fa6415a8c6a4e 100755 (executable)
@@ -5,6 +5,7 @@ arrays combinators continuations columns math vectors
 grouping stack-checker.branches
 compiler.tree
 compiler.tree.def-use
+compiler.tree.recursive
 compiler.tree.combinators ;
 IN: compiler.tree.checker
 
index 228a4e3efb003bc8a46008189364b03bfc80d85f..bc8a7b0765092a6139d122bb9d2b16eb33d6f94a 100755 (executable)
@@ -1,4 +1,3 @@
-IN: compiler.tree.cleanup.tests
 USING: tools.test kernel.private kernel arrays sequences
 math.private math generic words quotations alien alien.c-types
 strings sbufs sequences.private slots.private combinators
@@ -17,6 +16,7 @@ compiler.tree.propagation
 compiler.tree.propagation.info
 compiler.tree.checker
 compiler.tree.debugger ;
+IN: compiler.tree.cleanup.tests
 
 [ t ] [ [ [ 1 ] [ 2 ] if ] cleaned-up-tree [ #if? ] contains-node? ] unit-test
 
@@ -88,7 +88,7 @@ M: object xyz ;
     2over dup xyz drop >= [
         3drop
     ] [
-        [ swap [ call 1+ ] dip ] keep (i-repeat)
+        [ swap [ call 1 + ] dip ] keep (i-repeat)
     ] if ; inline recursive
 
 : i-repeat ( n quot -- ) [ { integer } declare ] dip 0 -rot (i-repeat) ; inline
@@ -543,4 +543,4 @@ cell-bits 32 = [
         [ 12 swap nth ] keep
         14 ndrop
     ] cleaned-up-tree nodes>quot
-] unit-test
\ No newline at end of file
+] unit-test
index 1b0343faa991400e09a0c2b5799b1438b31c1851..1cd9589065334bd27e5701829a9d545a7a1ffbee 100644 (file)
@@ -20,7 +20,7 @@ IN: compiler.tree.cleanup
 GENERIC: delete-node ( node -- )
 
 M: #call-recursive delete-node
-    dup label>> [ [ eq? not ] with filter ] change-calls drop ;
+    dup label>> calls>> [ node>> eq? not ] with filter-here ;
 
 M: #return-recursive delete-node
     label>> f >>return drop ;
@@ -89,8 +89,6 @@ M: #call cleanup*
         [ ]
     } cond ;
 
-M: #declare cleanup* drop f ;
-
 : delete-unreachable-branches ( #branch -- )
     dup live-branches>> '[
         _
index d012b5f6583f50dcc5fa519ef199cab1161d117b..305ba5b2b50687ef5724fe67cbf356bcfcb1d29f 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tree.combinators.tests
 USING: compiler.tree.combinators tools.test kernel ;
+IN: compiler.tree.combinators.tests
 
 { 1 0 } [ [ drop ] each-node ] must-infer-as
 { 1 1 } [ [ ] map-nodes ] must-infer-as
index fd1b2d5adb4cbfe7b1208ae410356a6a69932c1d..f09593824eb1babe838684bdaf56cd83e000d92a 100644 (file)
@@ -3,8 +3,7 @@
 USING: sequences namespaces kernel accessors assocs sets fry
 arrays combinators columns stack-checker.backend
 stack-checker.branches compiler.tree compiler.tree.combinators
-compiler.tree.dead-code.liveness compiler.tree.dead-code.simple
-;
+compiler.tree.dead-code.liveness compiler.tree.dead-code.simple ;
 IN: compiler.tree.dead-code.branches
 
 M: #if mark-live-values* look-at-inputs ;
index 71830d07e7e16b268fde37a767e5dc2ef10a03bc..b0ab864c80f2cb2bf3ac34c7e672c319ee7634a7 100644 (file)
@@ -3,6 +3,7 @@
 USING: accessors arrays assocs sequences kernel locals fry
 combinators stack-checker.backend
 compiler.tree
+compiler.tree.recursive
 compiler.tree.dead-code.branches
 compiler.tree.dead-code.liveness
 compiler.tree.dead-code.simple ;
index 9bacd51be14eb8c731d2b165118910447b002d62..3cdbbf594436217af2d7447fc348b856cd63f9ce 100644 (file)
@@ -1,5 +1,5 @@
-IN: compiler.tree.debugger.tests
 USING: compiler.tree.debugger tools.test sorting sequences io math.order ;
+IN: compiler.tree.debugger.tests
 
 [ [ <=> ] sort ] optimized.
-[ <reversed> [ print ] each ] optimizer-report.
\ No newline at end of file
+[ <reversed> [ print ] each ] optimizer-report.
index d6906d63482d5fa650b6ca0aacc6ca6499c346b2..a99e547b31f1affef730e3843c902660e2ea3fb9 100644 (file)
@@ -16,6 +16,7 @@ compiler.tree.builder
 compiler.tree.optimizer
 compiler.tree.combinators
 compiler.tree.checker
+compiler.tree.identities
 compiler.tree.dead-code
 compiler.tree.modular-arithmetic ;
 FROM: fry => _ ;
@@ -153,7 +154,7 @@ SYMBOL: node-count
         H{ } clone intrinsics-called set
 
         0 swap [
-            [ 1+ ] dip
+            [ 1 + ] dip
             dup #call? [
                 word>> {
                     { [ dup "intrinsic" word-prop ] [ intrinsics-called ] }
@@ -208,6 +209,7 @@ SYMBOL: node-count
         normalize
         propagate
         cleanup
+        apply-identities
         compute-def-use
         remove-dead-code
         compute-def-use
index fa504919a33e9695d3df5b2290d05a81fbed5ac6..21e79eb6c4cda2e9adf84bc717c83f38291123a4 100644 (file)
@@ -43,7 +43,7 @@ GENERIC: node-uses-values ( node -- values )
 M: #introduce node-uses-values drop f ;
 M: #push node-uses-values drop f ;
 M: #phi node-uses-values phi-in-d>> concat remove-bottom prune ;
-M: #declare node-uses-values declaration>> keys ;
+M: #declare node-uses-values drop f ;
 M: #terminate node-uses-values [ in-d>> ] [ in-r>> ] bi append ;
 M: #shuffle node-uses-values [ in-d>> ] [ in-r>> ] bi append ;
 M: #alien-callback node-uses-values drop f ;
index 5d34eaad1561b9e8a8dcb08e0b799d716f2f5646..5291c5e81f69195f3a93ff0c79ce366e6ab92a76 100644 (file)
@@ -1,9 +1,16 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs namespaces sequences kernel math
 combinators sets disjoint-sets fry stack-checker.values ;
 IN: compiler.tree.escape-analysis.allocations
 
+! A map from values to classes. Only for #introduce outputs
+SYMBOL: value-classes
+
+: value-class ( value -- class ) value-classes get at ;
+
+: set-value-class ( class value -- ) value-classes get set-at ;
+
 ! A map from values to one of the following:
 ! - f -- initial status, assigned to values we have not seen yet;
 !        may potentially become an allocation later
diff --git a/basis/compiler/tree/escape-analysis/check/check-tests.factor b/basis/compiler/tree/escape-analysis/check/check-tests.factor
new file mode 100644 (file)
index 0000000..bd91dd5
--- /dev/null
@@ -0,0 +1,27 @@
+USING: compiler.tree.escape-analysis.check tools.test accessors kernel
+kernel.private math compiler.tree.builder compiler.tree.normalization
+compiler.tree.propagation compiler.tree.cleanup ;
+IN: compiler.tree.escape-analysis.check.tests
+
+: test-checker ( quot -- ? )
+    build-tree normalize propagate cleanup run-escape-analysis? ;
+
+[ t ] [
+    [ { complex } declare [ real>> ] [ imaginary>> ] bi ]
+    test-checker
+] unit-test
+
+[ t ] [
+    [ complex boa [ real>> ] [ imaginary>> ] bi ]
+    test-checker
+] unit-test
+
+[ t ] [
+    [ [ complex boa [ real>> ] [ imaginary>> ] bi ] when ]
+    test-checker
+] unit-test
+
+[ f ] [
+    [ swap 1 2 ? ]
+    test-checker
+] unit-test
index ed253ad89bedd73fc621f12e3bbaa27bcf1a736c..4679dfe3424c54e6b87b0997777fdd4b63b9fb9b 100644 (file)
@@ -1,22 +1,32 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes classes.tuple math math.private accessors
-combinators kernel compiler.tree compiler.tree.combinators
-compiler.tree.propagation.info ;
+USING: classes classes.tuple math math.private accessors sequences
+combinators.short-circuit kernel compiler.tree
+compiler.tree.combinators compiler.tree.propagation.info ;
 IN: compiler.tree.escape-analysis.check
 
 GENERIC: run-escape-analysis* ( node -- ? )
 
+: unbox-inputs? ( nodes -- ? )
+    {
+        [ length 2 >= ]
+        [ first #introduce? ]
+        [ second #declare? ]
+    } 1&& ;
+
+: run-escape-analysis? ( nodes -- ? )
+    { [ unbox-inputs? ] [ [ run-escape-analysis* ] any? ] } 1|| ;
+
 M: #push run-escape-analysis*
-    literal>> [ class immutable-tuple-class? ] [ complex? ] bi or ;
+    literal>> class immutable-tuple-class? ;
 
 M: #call run-escape-analysis*
-    {
-        { [ dup immutable-tuple-boa? ] [ t ] }
-        [ f ] 
-    } cond nip ;
+    immutable-tuple-boa? ;
 
-M: node run-escape-analysis* drop f ;
+M: #recursive run-escape-analysis*
+    child>> run-escape-analysis? ;
 
-: run-escape-analysis? ( nodes -- ? )
-    [ run-escape-analysis* ] contains-node? ;
+M: #branch run-escape-analysis*
+    children>> [ run-escape-analysis? ] any? ;
+
+M: node run-escape-analysis* drop f ;
index 4fb01608f0270b321dde330d91c3c6732407ab98..debb66b8d42044589aee98489e6d00b849b95a39 100644 (file)
@@ -1,4 +1,3 @@
-IN: compiler.tree.escape-analysis.tests
 USING: compiler.tree.escape-analysis
 compiler.tree.escape-analysis.allocations compiler.tree.builder
 compiler.tree.recursive compiler.tree.normalization
@@ -9,12 +8,13 @@ quotations.private prettyprint classes.tuple.private classes
 classes.tuple namespaces
 compiler.tree.propagation.info stack-checker.errors
 compiler.tree.checker
-kernel.private ;
+kernel.private vectors ;
+IN: compiler.tree.escape-analysis.tests
 
 GENERIC: count-unboxed-allocations* ( m node -- n )
 
 : (count-unboxed-allocations) ( m node -- n )
-    out-d>> first escaping-allocation? [ 1+ ] unless ;
+    out-d>> first escaping-allocation? [ 1 + ] unless ;
 
 M: #call count-unboxed-allocations*
     dup immutable-tuple-boa?
@@ -24,6 +24,9 @@ M: #push count-unboxed-allocations*
     dup literal>> class immutable-tuple-class?
     [ (count-unboxed-allocations) ] [ drop ] if ;
 
+M: #introduce count-unboxed-allocations*
+    out-d>> [ escaping-allocation? [ 1 + ] unless ] each ;
+
 M: node count-unboxed-allocations* drop ;
 
 : count-unboxed-allocations ( quot -- sizes )
@@ -209,10 +212,10 @@ C: <ro-box> ro-box
     dup i>> 1 <= [
         drop 1 <ro-box>
     ] [
-        i>> 1- <ro-box>
+        i>> 1 - <ro-box>
         dup tuple-fib
         swap
-        i>> 1- <ro-box>
+        i>> 1 - <ro-box>
         tuple-fib
         swap i>> swap i>> + <ro-box>
     ] if ; inline recursive
@@ -222,7 +225,7 @@ C: <ro-box> ro-box
 [ 3 ] [ [ <ro-box> tuple-fib ] count-unboxed-allocations ] unit-test
 
 : tuple-fib' ( m -- n )
-    dup 1 <= [ 1- tuple-fib' i>> ] when <ro-box> ; inline recursive
+    dup 1 <= [ 1 - tuple-fib' i>> ] when <ro-box> ; inline recursive
 
 [ 0 ] [ [ tuple-fib' ] count-unboxed-allocations ] unit-test
 
@@ -230,10 +233,10 @@ C: <ro-box> ro-box
     dup i>> 1 <= [
         drop 1 <ro-box>
     ] [
-        i>> 1- <ro-box>
+        i>> 1 - <ro-box>
         dup bad-tuple-fib-1
         swap
-        i>> 1- <ro-box>
+        i>> 1 - <ro-box>
         bad-tuple-fib-1 dup .
         swap i>> swap i>> + <ro-box>
     ] if ; inline recursive
@@ -245,10 +248,10 @@ C: <ro-box> ro-box
     dup i>> 1 <= [
         drop 1 <ro-box>
     ] [
-        i>> 1- <ro-box>
+        i>> 1 - <ro-box>
         dup bad-tuple-fib-2
         swap
-        i>> 1- <ro-box>
+        i>> 1 - <ro-box>
         bad-tuple-fib-2
         swap i>> swap i>> + <ro-box>
     ] if ; inline recursive
@@ -259,9 +262,9 @@ C: <ro-box> ro-box
     dup 1 <= [
         drop 1 <ro-box>
     ] [
-        1- dup tuple-fib-2
+        1 - dup tuple-fib-2
         swap
-        1- tuple-fib-2
+        1 - tuple-fib-2
         swap i>> swap i>> + <ro-box>
     ] if ; inline recursive
 
@@ -271,9 +274,9 @@ C: <ro-box> ro-box
     dup 1 <= [
         drop 1 <ro-box>
     ] [
-        1- dup tuple-fib-3
+        1 - dup tuple-fib-3
         swap
-        1- tuple-fib-3 dup .
+        1 - tuple-fib-3 dup .
         swap i>> swap i>> + <ro-box>
     ] if ; inline recursive
 
@@ -283,9 +286,9 @@ C: <ro-box> ro-box
     dup 1 <= [
         drop 1 <ro-box>
     ] [
-        1- dup bad-tuple-fib-3
+        1 - dup bad-tuple-fib-3
         swap
-        1- bad-tuple-fib-3
+        1 - bad-tuple-fib-3
         2drop f
     ] if ; inline recursive
 
@@ -328,3 +331,17 @@ C: <ro-box> ro-box
 TUPLE: empty-tuple ;
 
 [ ] [ [ empty-tuple boa layout-of ] count-unboxed-allocations drop ] unit-test
+
+! New feature!
+
+[ 1 ] [ [ { complex } declare real>> ] count-unboxed-allocations ] unit-test
+
+[ 1 ] [
+    [ { complex } declare [ real>> ] [ imaginary>> ] bi ]
+    count-unboxed-allocations
+] unit-test
+
+[ 0 ] [
+    [ { vector } declare length>> ]
+    count-unboxed-allocations
+] unit-test
index 82e41d7b495a332760a27eed1b47c11b692981c4..dcad55742b80fc820863cf047131de18d7720f77 100644 (file)
@@ -15,5 +15,6 @@ IN: compiler.tree.escape-analysis
     init-escaping-values
     H{ } clone allocations set
     H{ } clone slot-accesses set
+    H{ } clone value-classes set
     dup (escape-analysis)
     compute-escaping-allocations ;
index 3fdde22bd8bd8241eccabac062b58af1e63d57c1..3451750a344ef656584f8c0bb32a44a5610ee744 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences
+USING: kernel sequences fry math namespaces
 compiler.tree
 compiler.tree.def-use
 compiler.tree.escape-analysis.allocations ;
@@ -8,9 +8,14 @@ IN: compiler.tree.escape-analysis.nodes
 
 GENERIC: escape-analysis* ( node -- )
 
+SYMBOL: next-node
+
+: each-with-next ( seq quot: ( elt -- ) -- )
+    dupd '[ 1 + _ ?nth next-node set @ ] each-index ; inline
+
 : (escape-analysis) ( node -- )
     [
         [ node-defs-values introduce-values ]
         [ escape-analysis* ]
         bi
-    ] each ;
+    ] each-with-next ;
index 033d5b01ccaddf0aa9e295362b6d8fe69a2dfd0a..c26f3ddefc02a26a7f779ed1c69aea5829d04649 100644 (file)
@@ -1,7 +1,7 @@
-IN: compiler.tree.escape-analysis.recursive.tests
 USING: kernel tools.test namespaces sequences
 compiler.tree.escape-analysis.recursive
 compiler.tree.escape-analysis.allocations ;
+IN: compiler.tree.escape-analysis.recursive.tests
 
 H{ } clone allocations set
 <escaping-values> escaping-values set
index 5aece23d1784a8933a8245b77ec86325ba50ae9a..ad6572a35c27e4beb248d8625a6afdf1bae13f4f 100644 (file)
@@ -3,6 +3,7 @@
 USING: kernel sequences math combinators accessors namespaces
 fry disjoint-sets
 compiler.tree
+compiler.tree.recursive
 compiler.tree.combinators
 compiler.tree.escape-analysis.nodes
 compiler.tree.escape-analysis.branches
@@ -67,5 +68,5 @@ M: #return-recursive escape-analysis* ( #return-recursive -- )
     [ call-next-method ]
     [
         [ in-d>> ] [ label>> calls>> ] bi
-        [ out-d>> escaping-values get '[ _ equate ] 2each ] with each
+        [ node>> out-d>> escaping-values get '[ _ equate ] 2each ] with each
     ] bi ;
index c0b3982c0edd7cc0bb6bda38a42812ee7f46eb04..c053b15f29704aaa002b4e57418c2e7fa123e385 100644 (file)
@@ -1,20 +1,36 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors sequences classes.tuple
 classes.tuple.private arrays math math.private slots.private
 combinators deques search-deques namespaces fry classes
-classes.algebra stack-checker.state
+classes.algebra assocs stack-checker.state
 compiler.tree
 compiler.tree.propagation.info
 compiler.tree.escape-analysis.nodes
 compiler.tree.escape-analysis.allocations ;
 IN: compiler.tree.escape-analysis.simple
 
+M: #declare escape-analysis* drop ;
+
 M: #terminate escape-analysis* drop ;
 
 M: #renaming escape-analysis* inputs/outputs copy-values ;
 
-M: #introduce escape-analysis* out-d>> unknown-allocations ;
+: declared-class ( value -- class/f )
+    next-node get dup #declare? [ declaration>> at ] [ 2drop f ] if ;
+
+: record-param-allocation ( value class -- )
+    dup immutable-tuple-class? [
+        [ swap set-value-class ] [
+            all-slots [
+                [ <slot-value> dup ] [ class>> ] bi*
+                record-param-allocation
+            ] map swap record-allocation
+        ] 2bi
+    ] [ drop unknown-allocation ] if ;
+
+M: #introduce escape-analysis*
+    out-d>> [ dup declared-class record-param-allocation ] each ;
 
 DEFER: record-literal-allocation
 
@@ -24,7 +40,6 @@ DEFER: record-literal-allocation
 : object-slots ( object -- slots/f )
     {
         { [ dup class immutable-tuple-class? ] [ tuple-slots ] }
-        { [ dup complex? ] [ [ real-part ] [ imaginary-part ] bi 2array ] }
         [ drop f ]
     } cond ;
 
index 13555d45f7b7d663d7a0440720602fc66f46c106..7d40bf3fc16c7ee123646c0fbeef2e710cfc9362 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-IN: compiler.tree.modular-arithmetic.tests
 USING: kernel kernel.private tools.test math math.partial-dispatch
-math.private accessors slots.private sequences strings sbufs
+math.private accessors slots.private sequences sequences.private strings sbufs
 compiler.tree.builder
 compiler.tree.normalization
 compiler.tree.debugger
 alien.accessors layouts combinators byte-arrays ;
+IN: compiler.tree.modular-arithmetic.tests
 
 : test-modular-arithmetic ( quot -- quot' )
     cleaned-up-tree nodes>quot ;
@@ -171,3 +171,8 @@ cell {
 [ [ [ { fixnum fixnum } declare + ] 2dip set-alien-signed-8 ] test-modular-arithmetic ] unit-test
 
 [ t ] [ [ { fixnum byte-array } declare [ + ] with map ] { + fixnum+ >fixnum } inlined? ] unit-test
+
+[ t ] [
+    [ 0 10 <byte-array> 10 [ 1 pick 0 + >fixnum pick set-nth-unsafe [ 1 + >fixnum ] dip ] times ]
+    { >fixnum } inlined?
+] unit-test
index 3b4574effe4b1751e91e2ff52c5e0363f06b97c3..19669c22399e4493081616ff771674301b8d78bb 100644 (file)
@@ -1,10 +1,10 @@
-IN: compiler.tree.normalization.tests
 USING: compiler.tree.builder compiler.tree.recursive
 compiler.tree.normalization
 compiler.tree.normalization.introductions
 compiler.tree.normalization.renaming
 compiler.tree compiler.tree.checker
 sequences accessors tools.test kernel math ;
+IN: compiler.tree.normalization.tests
 
 [ 3 ] [ [ 3drop 1 2 3 ] build-tree count-introductions ] unit-test
 
diff --git a/basis/compiler/tree/optimizer/optimizer-tests.factor b/basis/compiler/tree/optimizer/optimizer-tests.factor
deleted file mode 100644 (file)
index 5d05947..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: compiler.tree.optimizer tools.test ;
-IN: compiler.tree.optimizer.tests
-
-
index ec2a4b1ece4edbaae8f3aee9a26c870c7ed347a5..a667ea727f69cfc371f3ced4ba3e6cb0511a0f25 100644 (file)
@@ -35,7 +35,7 @@ M: +unknown+ curry-effect ;
 
 M: effect curry-effect
     [ in>> length ] [ out>> length ] [ terminated?>> ] tri
-    pick 0 = [ [ 1+ ] dip ] [ [ 1- ] 2dip ] if
+    pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if
     effect boa ;
 
 M: curry cached-effect
index a99c2a2447c7a83a225ff33c54dacb4baf6eb708..b546e56e4ba2462746d1b7b694f9589f0563b6f7 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.tree.propagation.copy.tests
 USING: compiler.tree.propagation.copy tools.test namespaces kernel
 assocs ;
+IN: compiler.tree.propagation.copy.tests
 
 H{ } clone copies set
 
index 72c08dbf1c5f3cd92435e87f452eae28e1c78961..826131ab612525013b49a2c37c14488d238bbafe 100644 (file)
@@ -74,3 +74,13 @@ TUPLE: test-tuple { x read-only } ;
 [ t ] [
     null-info 3 <literal-info> value-info<=
 ] unit-test
+
+[ t t ] [
+    f <literal-info>
+    fixnum 0 40 [a,b] <class/interval-info>
+    value-info-union
+    \ f class-not <class-info>
+    value-info-intersect
+    [ class>> fixnum class= ]
+    [ interval>> 0 40 [a,b] = ] bi
+] unit-test
index a2dec1227942a2a97d220c656cb4a986f7e79296..0a04b48160c12af21a908a36b7471c72431ec761 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs classes classes.algebra classes.tuple
-classes.tuple.private kernel accessors math math.intervals
-namespaces sequences words combinators byte-arrays strings
-arrays layouts cpu.architecture compiler.tree.propagation.copy ;
+classes.tuple.private kernel accessors math math.intervals namespaces
+sequences sequences.private words combinators memoize
+combinators.short-circuit byte-arrays strings arrays layouts
+cpu.architecture compiler.tree.propagation.copy ;
 IN: compiler.tree.propagation.info
 
 : false-class? ( class -- ? ) \ f class<= ;
@@ -36,10 +37,6 @@ CONSTANT: null-info T{ value-info f null empty-interval }
 
 CONSTANT: object-info T{ value-info f object full-interval }
 
-: class-interval ( class -- interval )
-    dup real class<=
-    [ "interval" word-prop [-inf,inf] or ] [ drop f ] if ;
-
 : interval>literal ( class interval -- literal literal? )
     #! If interval has zero length and the class is sufficiently
     #! precise, we can turn it into a literal
@@ -69,7 +66,7 @@ DEFER: <literal-info>
 UNION: fixed-length array byte-array string ;
 
 : init-literal-info ( info -- info )
-    [-inf,inf] >>interval
+    empty-interval >>interval
     dup literal>> class >>class
     dup literal>> {
         { [ dup real? ] [ [a,a] >>interval ] }
@@ -78,16 +75,54 @@ UNION: fixed-length array byte-array string ;
         [ drop ]
     } cond ; inline
 
+: empty-set? ( info -- ? )
+    {
+        [ class>> null-class? ]
+        [ [ interval>> empty-interval eq? ] [ class>> real class<= ] bi and ]
+    } 1|| ;
+
+: min-value ( class -- n )
+    {
+        { fixnum [ most-negative-fixnum ] }
+        { array-capacity [ 0 ] }
+        [ drop -1/0. ]
+    } case ;
+
+: max-value ( class -- n )
+    {
+        { fixnum [ most-positive-fixnum ] }
+        { array-capacity [ max-array-capacity ] }
+        [ drop 1/0. ]
+    } case ;
+
+: class-interval ( class -- i )
+    {
+        { fixnum [ fixnum-interval ] }
+        { array-capacity [ array-capacity-interval ] }
+        [ drop full-interval ]
+    } case ;
+
+: wrap-interval ( interval class -- interval' )
+    {
+        { [ over empty-interval eq? ] [ drop ] }
+        { [ over full-interval eq? ] [ nip class-interval ] }
+        { [ 2dup class-interval interval-subset? not ] [ nip class-interval ] }
+        [ drop ]
+    } cond ;
+
+: init-interval ( info -- info )
+    dup [ interval>> full-interval or ] [ class>> ] bi wrap-interval >>interval
+    dup class>> integer class<= [ [ integral-closure ] change-interval ] when ; inline
+
 : init-value-info ( info -- info )
     dup literal?>> [
         init-literal-info
     ] [
-        dup [ class>> null-class? ] [ interval>> empty-interval eq? ] bi or [
+        dup empty-set? [
             null >>class
             empty-interval >>interval
         ] [
-            [ [-inf,inf] or ] change-interval
-            dup class>> integer class<= [ [ integral-closure ] change-interval ] when
+            init-interval
             dup [ class>> ] [ interval>> ] bi interval>literal
             [ >>literal ] [ >>literal? ] bi*
         ] if
@@ -100,8 +135,7 @@ UNION: fixed-length array byte-array string ;
     init-value-info ; foldable
 
 : <class-info> ( class -- info )
-    dup word? [ dup "interval" word-prop ] [ f ] if [-inf,inf] or
-    <class/interval-info> ; foldable
+    f <class/interval-info> ; foldable
 
 : <interval-info> ( interval -- info )
     <value-info>
index 4d54dc5e397d777a4439245a4ace2ca938bf312a..8f8c0773aaf6e71f473f90d5cd8b94875177afbd 100755 (executable)
@@ -19,7 +19,7 @@ IN: compiler.tree.propagation.inlining
 SYMBOL: node-count
 
 : count-nodes ( nodes -- n )
-    0 swap [ drop 1+ ] each-node ;
+    0 swap [ drop 1 + ] each-node ;
 
 : compute-node-count ( nodes -- ) count-nodes node-count set ;
 
@@ -31,8 +31,11 @@ SYMBOL: inlining-count
 : splicing-call ( #call word -- nodes )
     [ [ in-d>> ] [ out-d>> ] bi ] dip #call 1array ;
 
+: open-code-#call ( #call word/quot -- nodes/f )
+    [ [ in-d>> ] [ out-d>> ] bi ] dip build-sub-tree ;
+
 : splicing-body ( #call quot/word -- nodes/f )
-    build-sub-tree dup [ analyze-recursive normalize ] when ;
+    open-code-#call dup [ analyze-recursive normalize ] when ;
 
 ! Dispatch elimination
 : undo-inlining ( #call -- ? )
index f5ea64bc0a48348dce16161570f3baf6bc9f88e1..7c684f5b7f6892daa3eba9aa90d3be27523498a4 100644 (file)
@@ -18,14 +18,6 @@ compiler.tree.propagation.call-effect
 compiler.tree.propagation.transforms ;
 IN: compiler.tree.propagation.known-words
 
-\ fixnum
-most-negative-fixnum most-positive-fixnum [a,b]
-"interval" set-word-prop
-
-\ array-capacity
-0 max-array-capacity [a,b]
-"interval" set-word-prop
-
 { + - * / }
 [ { number number } "input-classes" set-word-prop ] each
 
@@ -53,8 +45,8 @@ most-negative-fixnum most-positive-fixnum [a,b]
     { fixnum bignum integer rational float real number object }
     [ class<= ] with find nip ;
 
-: fits? ( interval class -- ? )
-    "interval" word-prop interval-subset? ;
+: fits-in-fixnum? ( interval -- ? )
+    fixnum-interval interval-subset? ;
 
 : binary-op-class ( info1 info2 -- newclass )
     [ class>> ] bi@
@@ -66,7 +58,7 @@ most-negative-fixnum most-positive-fixnum [a,b]
     [ [ interval>> ] bi@ ] dip call ; inline
 
 : won't-overflow? ( class interval -- ? )
-    [ fixnum class<= ] [ fixnum fits? ] bi* and ;
+    [ fixnum class<= ] [ fits-in-fixnum? ] bi* and ;
 
 : may-overflow ( class interval -- class' interval' )
     over null-class? [
@@ -173,7 +165,8 @@ generic-comparison-ops [
     [ object-info ] [ f <literal-info> ] if ;
 
 : info-intervals-intersect? ( info1 info2 -- ? )
-    [ interval>> ] bi@ intervals-intersect? ;
+    2dup [ class>> real class<= ] both?
+    [ [ interval>> ] bi@ intervals-intersect? ] [ 2drop t ] if ;
 
 { number= bignum= float= } [
     [
@@ -218,14 +211,7 @@ generic-comparison-ops [
 
     { >integer integer }
 } [
-    '[
-        _
-        [ nip ] [
-            [ interval>> ] [ class-interval ] bi*
-            interval-intersect
-        ] 2bi
-        <class/interval-info>
-    ] "outputs" set-word-prop
+    '[ _ swap interval>> <class/interval-info> ] "outputs" set-word-prop
 ] assoc-each
 
 { numerator denominator }
@@ -254,14 +240,14 @@ generic-comparison-ops [
     dup name>> {
         {
             [ "alien-signed-" ?head ]
-            [ string>number 8 * 1- 2^ dup neg swap 1- [a,b] ]
+            [ string>number 8 * 1 - 2^ dup neg swap 1 - [a,b] ]
         }
         {
             [ "alien-unsigned-" ?head ]
-            [ string>number 8 * 2^ 1- 0 swap [a,b] ]
+            [ string>number 8 * 2^ 1 - 0 swap [a,b] ]
         }
     } cond
-    [ fixnum fits? fixnum integer ? ] keep <class/interval-info>
+    [ fits-in-fixnum? fixnum integer ? ] keep <class/interval-info>
     '[ 2drop _ ] "outputs" set-word-prop
 ] each
 
index 8ec98ccc66c4e7d7e5ebd51715e9c45786e576dd..eb9591c40cc96751b4824ed0891032d01769a1bd 100644 (file)
@@ -149,6 +149,14 @@ IN: compiler.tree.propagation.tests
     ] final-literals
 ] unit-test
 
+[ V{ t } ] [ [ 40 mod 40 < ] final-literals ] unit-test
+
+[ V{ f } ] [ [ 40 mod 0 >= ] final-literals ] unit-test
+
+[ V{ t } ] [ [ 40 rem 0 >= ] final-literals ] unit-test
+
+[ V{ t } ] [ [ abs 40 mod 0 >= ] final-literals ] unit-test
+
 [ V{ string } ] [
     [ dup string? not [ "Oops" throw ] [ ] if ] final-classes
 ] unit-test
@@ -270,11 +278,11 @@ IN: compiler.tree.propagation.tests
 ] unit-test
 
 [ V{ fixnum } ] [
-    [ >fixnum dup 100 < [ 1+ ] [ "Oops" throw ] if ] final-classes
+    [ >fixnum dup 100 < [ 1 + ] [ "Oops" throw ] if ] final-classes
 ] unit-test
 
 [ V{ -1 } ] [
-    [ 0 dup 100 < not [ 1+ ] [ 1- ] if ] final-literals
+    [ 0 dup 100 < not [ 1 + ] [ 1 - ] if ] final-literals
 ] unit-test
 
 [ V{ 2 } ] [
@@ -464,7 +472,7 @@ TUPLE: mixed-mutable-immutable { x integer } { y sequence read-only } ;
 ] unit-test
 
 : recursive-test-4 ( i n -- )
-    2dup < [ [ 1+ ] dip recursive-test-4 ] [ 2drop ] if ; inline recursive
+    2dup < [ [ 1 + ] dip recursive-test-4 ] [ 2drop ] if ; inline recursive
 
 [ ] [ [ recursive-test-4 ] final-info drop ] unit-test
 
@@ -479,7 +487,7 @@ TUPLE: mixed-mutable-immutable { x integer } { y sequence read-only } ;
 [ V{ integer } ] [ [ { fixnum } declare recursive-test-6 ] final-classes ] unit-test
 
 : recursive-test-7 ( a -- b )
-    dup 10 < [ 1+ recursive-test-7 ] when ; inline recursive
+    dup 10 < [ 1 + recursive-test-7 ] when ; inline recursive
 
 [ V{ fixnum } ] [ [ 0 recursive-test-7 ] final-classes ] unit-test
 
@@ -632,8 +640,12 @@ MIXIN: empty-mixin
     [ { integer } declare 127 bitand ] final-info first interval>>
 ] unit-test
 
+[ V{ t } ] [
+    [ [ 123 bitand ] [ drop f ] if dup [ 0 >= ] [ not ] if ] final-literals
+] unit-test
+  
 [ V{ bignum } ] [
-    [ { bignum } declare dup 1- bitxor ] final-classes
+    [ { bignum } declare dup 1 - bitxor ] final-classes
 ] unit-test
 
 [ V{ bignum integer } ] [
@@ -673,7 +685,7 @@ MIXIN: empty-mixin
 
 TUPLE: littledan-1 { a read-only } ;
 
-: (littledan-1-test) ( a -- ) a>> 1+ littledan-1 boa (littledan-1-test) ; inline recursive
+: (littledan-1-test) ( a -- ) a>> 1 + littledan-1 boa (littledan-1-test) ; inline recursive
 
 : littledan-1-test ( -- ) 0 littledan-1 boa (littledan-1-test) ; inline
 
@@ -690,7 +702,7 @@ TUPLE: littledan-2 { from read-only } { to read-only } ;
 [ ] [ [ littledan-2-test ] final-classes drop ] unit-test
 
 : (littledan-3-test) ( x -- )
-    length 1+ f <array> (littledan-3-test) ; inline recursive
+    length 1 + f <array> (littledan-3-test) ; inline recursive
 
 : littledan-3-test ( -- )
     0 f <array> (littledan-3-test) ; inline
@@ -699,7 +711,21 @@ TUPLE: littledan-2 { from read-only } { to read-only } ;
 
 [ V{ 0 } ] [ [ { } length ] final-literals ] unit-test
 
-[ V{ 1 } ] [ [ { } length 1+ f <array> length ] final-literals ] unit-test
+[ V{ 1 } ] [ [ { } length 1 + f <array> length ] final-literals ] unit-test
+
+! generalize-counter is not tight enough
+[ V{ fixnum } ] [ [ 0 10 [ 1 + >fixnum ] times ] final-classes ] unit-test
+
+[ V{ fixnum } ] [ [ 0 10 [ 1 + >fixnum ] times 0 + ] final-classes ] unit-test
+
+! Coercions need to update intervals
+[ V{ f } ] [ [ 1 2 ? 100 shift >fixnum 1 = ] final-literals ] unit-test
+
+[ V{ t } ] [ [ >fixnum 1 + >fixnum most-positive-fixnum <= ] final-literals ] unit-test
+
+[ V{ t } ] [ [ >fixnum 1 + >fixnum most-negative-fixnum >= ] final-literals ] unit-test
+
+[ V{ f } ] [ [ >fixnum 1 + >fixnum most-negative-fixnum > ] final-literals ] unit-test
 
 ! Mutable tuples with circularity should not cause problems
 TUPLE: circle me ;
index cf72a2a135e809f34ecb2c9a1952d1cbffe9f478..974bb584eba38b70b82bb59611e59a34908626ae 100644 (file)
@@ -1,19 +1,51 @@
-IN: compiler.tree.propagation.recursive.tests
 USING: tools.test compiler.tree.propagation.recursive
-math.intervals kernel ;
+math.intervals kernel math literals layouts ;
+IN: compiler.tree.propagation.recursive.tests
 
 [ T{ interval f { 0 t } { 1/0. t } } ] [
     T{ interval f { 1 t } { 1 t } }
-    T{ interval f { 0 t } { 0 t } } generalize-counter-interval
+    T{ interval f { 0 t } { 0 t } }
+    integer generalize-counter-interval
+] unit-test
+
+[ T{ interval f { 0 t } { $[ most-positive-fixnum ] t } } ] [
+    T{ interval f { 1 t } { 1 t } }
+    T{ interval f { 0 t } { 0 t } }
+    fixnum generalize-counter-interval
 ] unit-test
 
 [ T{ interval f { -1/0. t } { 10 t } } ] [
     T{ interval f { -1 t } { -1 t } }
-    T{ interval f { 10 t } { 10 t } } generalize-counter-interval
+    T{ interval f { 10 t } { 10 t } }
+    integer generalize-counter-interval
+] unit-test
+
+[ T{ interval f { $[ most-negative-fixnum ] t } { 10 t } } ] [
+    T{ interval f { -1 t } { -1 t } }
+    T{ interval f { 10 t } { 10 t } }
+    fixnum generalize-counter-interval
 ] unit-test
 
 [ t ] [
     T{ interval f { 1 t } { 268435455 t } }
     T{ interval f { -268435456 t } { 268435455 t } } tuck
-    generalize-counter-interval =
+    integer generalize-counter-interval =
+] unit-test
+
+[ t ] [
+    T{ interval f { 1 t } { 268435455 t } }
+    T{ interval f { -268435456 t } { 268435455 t } } tuck
+    fixnum generalize-counter-interval =
+] unit-test
+
+[ full-interval ] [
+    T{ interval f { -5 t } { 3 t } }
+    T{ interval f { 2 t } { 11 t } }
+    integer generalize-counter-interval
+] unit-test
+
+[ $[ fixnum-interval ] ] [
+    T{ interval f { -5 t } { 3 t } }
+    T{ interval f { 2 t } { 11 t } }
+    fixnum generalize-counter-interval
 ] unit-test
index b8d1760a0b4edaf7aca4e780b8fe858a54e4f931..eb4158e7563ec7487460a3aff2958a8afd8dff2c 100644 (file)
@@ -1,7 +1,7 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences accessors arrays fry math.intervals
-combinators namespaces
+USING: kernel sequences accessors arrays fry math math.intervals
+layouts combinators namespaces locals
 stack-checker.inlining
 compiler.tree
 compiler.tree.combinators
@@ -21,23 +21,29 @@ IN: compiler.tree.propagation.recursive
     in-d>> [ value-info ] map ;
 
 : recursive-stacks ( #enter-recursive -- stacks initial )
-    [ label>> calls>> [ node-input-infos ] map flip ]
+    [ label>> calls>> [ node>> node-input-infos ] map flip ]
     [ latest-input-infos ] bi ;
 
-: generalize-counter-interval ( interval initial-interval -- interval' )
+:: generalize-counter-interval ( interval initial-interval class -- interval' )
     {
-        { [ 2dup interval-subset? ] [ empty-interval ] }
-        { [ over empty-interval eq? ] [ empty-interval ] }
-        { [ 2dup interval>= t eq? ] [ 1/0. [a,a] ] }
-        { [ 2dup interval<= t eq? ] [ -1/0. [a,a] ] }
-        [ [-inf,inf] ]
-    } cond interval-union nip ;
+        { [ interval initial-interval interval-subset? ] [ initial-interval ] }
+        { [ interval empty-interval eq? ] [ initial-interval ] }
+        {
+            [ interval initial-interval interval>= t eq? ]
+            [ class max-value [a,a] initial-interval interval-union ]
+        }
+        {
+            [ interval initial-interval interval<= t eq? ]
+            [ class min-value [a,a] initial-interval interval-union ]
+        }
+        [ class class-interval ]
+    } cond ;
 
 : generalize-counter ( info' initial -- info )
     2dup [ not ] either? [ drop ] [
         2dup [ class>> null-class? ] either? [ drop ] [
             [ clone ] dip
-            [ [ drop ] [ [ interval>> ] bi@ generalize-counter-interval ] 2bi >>interval ]
+            [ [ drop ] [ [ [ interval>> ] bi@ ] [ drop class>> ] 2bi generalize-counter-interval ] 2bi >>interval ]
             [ [ drop ] [ [ slots>> ] bi@ [ generalize-counter ] 2map ] 2bi >>slots ]
             [ [ drop ] [ [ length>> ] bi@ generalize-counter ] 2bi >>length ]
             tri
index 86114772f752a4e185881d349a8bae89637dc0fd..4996729ded72a235de05968f5931dd8f8fbf8674 100644 (file)
@@ -63,5 +63,5 @@ UNION: fixed-length-sequence array byte-array string ;
         { [ over 0 = ] [ 2drop fixnum <class-info> ] }
         { [ 2dup length-accessor? ] [ nip length>> ] }
         { [ dup literal?>> ] [ literal>> literal-info-slot ] }
-        [ [ 1- ] [ slots>> ] bi* ?nth ]
+        [ [ 1 - ] [ slots>> ] bi* ?nth ]
     } cond [ object-info ] unless* ;
index 3fd7af0324a7d74d7eee65aa33909ed86c956167..d6c107b74beb2733491bf3f43476a3d3ed921256 100644 (file)
@@ -20,7 +20,7 @@ IN: compiler.tree.propagation.transforms
 
 : rem-custom-inlining ( #call -- quot/f )
     second value-info literal>> dup integer?
-    [ power-of-2? [ 1- bitand ] f ? ] [ drop f ] if ;
+    [ power-of-2? [ 1 - bitand ] f ? ] [ drop f ] if ;
 
 {
     mod-integer-integer
@@ -162,7 +162,7 @@ CONSTANT: lookup-table-at-max 256
     } 1&& ;
 
 : lookup-table-seq ( assoc -- table )
-    [ keys supremum 1+ ] keep '[ _ at ] { } map-as ;
+    [ keys supremum 1 + ] keep '[ _ at ] { } map-as ;
 
 : lookup-table-quot ( seq -- newquot )
     lookup-table-seq
index 80edae076f75b5459cc091d21905e8f68561583d..a1cbf15438e2d5ebe0e6ab80c76f166c2634614d 100644 (file)
@@ -1,9 +1,10 @@
-IN: compiler.tree.recursive.tests
-USING: compiler.tree.recursive tools.test
-kernel combinators.short-circuit math sequences accessors
+USING: tools.test kernel combinators.short-circuit math sequences accessors
 compiler.tree
 compiler.tree.builder
-compiler.tree.combinators ;
+compiler.tree.combinators
+compiler.tree.recursive
+compiler.tree.recursive.private ;
+IN: compiler.tree.recursive.tests
 
 [ { f f f f } ] [ f { f t f f } (tail-calls) ] unit-test
 [ { f f f t } ] [ t { f t f f } (tail-calls) ] unit-test
@@ -29,7 +30,7 @@ compiler.tree.combinators ;
     ] curry contains-node? ;
 
 : loop-test-1 ( a -- )
-    dup [ 1+ loop-test-1 ] [ drop ] if ; inline recursive
+    dup [ 1 + loop-test-1 ] [ drop ] if ; inline recursive
                           
 [ t ] [
     [ loop-test-1 ] build-tree analyze-recursive
@@ -52,7 +53,7 @@ compiler.tree.combinators ;
 ] unit-test
 
 : loop-test-2 ( a b -- a' )
-    dup [ 1+ loop-test-2 1- ] [ drop ] if ; inline recursive
+    dup [ 1+ loop-test-2 1 - ] [ drop ] if ; inline recursive
 
 [ t ] [
     [ loop-test-2 ] build-tree analyze-recursive
@@ -67,13 +68,6 @@ compiler.tree.combinators ;
     \ loop-test-3 label-is-not-loop?
 ] unit-test
 
-: loop-test-4 ( a -- )
-    dup [
-        loop-test-4
-    ] [
-        drop
-    ] if ; inline recursive
-
 [ f ] [
     [ [ [ ] map ] map ] build-tree analyze-recursive
     [
@@ -145,17 +139,32 @@ DEFER: a'
 
 DEFER: a''
 
-: b'' ( -- )
+: b'' ( a -- b )
     a'' ; inline recursive
 
-: a'' ( -- )
-    b'' a'' ; inline recursive
+: a'' ( a -- b )
+    dup [ b'' a'' ] when ; inline recursive
 
 [ t ] [
     [ a'' ] build-tree analyze-recursive
     \ a'' label-is-not-loop?
 ] unit-test
 
+[ t ] [
+    [ a'' ] build-tree analyze-recursive
+    \ b'' label-is-loop?
+] unit-test
+
+[ t ] [
+    [ b'' ] build-tree analyze-recursive
+    \ a'' label-is-loop?
+] unit-test
+
+[ t ] [
+    [ b'' ] build-tree analyze-recursive
+    \ b'' label-is-not-loop?
+] unit-test
+
 : loop-in-non-loop ( x quot: ( i -- ) -- )
     over 0 > [
         [ [ 1 - ] dip loop-in-non-loop ] [ call ] 2bi
@@ -166,3 +175,27 @@ DEFER: a''
     build-tree analyze-recursive
     \ (each-integer) label-is-loop?
 ] unit-test
+
+DEFER: a'''
+
+: b''' ( -- )
+    blah [ b''' ] [ a''' b''' ] if ; inline recursive
+
+: a''' ( -- )
+    blah [ b''' ] [ a''' ] if ; inline recursive
+
+[ t ] [
+    [ b''' ] build-tree analyze-recursive
+    \ a''' label-is-loop?
+] unit-test
+
+DEFER: b4
+
+: a4 ( a -- b ) dup [ b4 ] when ; inline recursive
+
+: b4 ( a -- b ) dup [ a4 reverse ] when ; inline recursive
+
+[ t ] [ [ b4 ] build-tree analyze-recursive \ a4 label-is-loop? ] unit-test
+[ t ] [ [ b4 ] build-tree analyze-recursive \ b4 label-is-not-loop? ] unit-test
+[ t ] [ [ a4 ] build-tree analyze-recursive \ a4 label-is-not-loop? ] unit-test
+[ t ] [ [ a4 ] build-tree analyze-recursive \ b4 label-is-loop? ] unit-test
index 2e40693e6982df2fa5961eec6d964a87a940d5eb..bc6243e1381d795b2a937324d12231bd824c55dd 100644 (file)
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel assocs arrays namespaces accessors sequences deques
-search-deques dlists compiler.tree compiler.tree.combinators ;
+USING: kernel assocs arrays namespaces accessors sequences deques fry
+search-deques dlists combinators.short-circuit make sets compiler.tree ;
 IN: compiler.tree.recursive
 
-! Collect label info
-GENERIC: collect-label-info ( node -- )
+TUPLE: call-site tail? node label ;
 
-M: #return-recursive collect-label-info
-    dup label>> (>>return) ;
+: recursive-phi-in ( #enter-recursive -- seq )
+    [ label>> calls>> [ node>> in-d>> ] map ] [ in-d>> ] bi suffix ;
 
-M: #call-recursive collect-label-info
-    dup label>> calls>> push ;
+<PRIVATE
 
-M: #recursive collect-label-info
-    label>> V{ } clone >>calls drop ;
+TUPLE: call-graph-node tail? label children calls ;
 
-M: node collect-label-info drop ;
-
-! A loop is a #recursive which only tail calls itself, and those
-! calls are nested inside other loops only. We optimistically
-! assume all #recursive nodes are loops, disqualifying them as
-! we see evidence to the contrary.
 : (tail-calls) ( tail? seq -- seq' )
     reverse [ swap [ and ] keep ] map nip reverse ;
 
 : tail-calls ( tail? node -- seq )
     [
-        [ #phi? ]
-        [ #return? ]
-        [ #return-recursive? ]
-        tri or or
+        {
+            [ #phi? ]
+            [ #return? ]
+            [ #return-recursive? ]
+        } 1||
     ] map (tail-calls) ;
 
-SYMBOL: loop-heights
-SYMBOL: loop-calls
-SYMBOL: loop-stack
-SYMBOL: work-list
+SYMBOLS: children calls ;
+
+GENERIC: node-call-graph ( tail? node -- )
 
-GENERIC: collect-loop-info* ( tail? node -- )
+: (build-call-graph) ( tail? nodes -- )
+    [ tail-calls ] keep
+    [ node-call-graph ] 2each ;
 
-: non-tail-label-info ( nodes -- )
-    [ f swap collect-loop-info* ] each ;
+: build-call-graph ( nodes -- labels calls )
+    [
+        V{ } clone children set
+        V{ } clone calls set
+        [ t ] dip (build-call-graph)
+        children get
+        calls get
+    ] with-scope ;
 
-: (collect-loop-info) ( tail? nodes -- )
-    [ tail-calls ] keep [ collect-loop-info* ] 2each ;
+M: #return-recursive node-call-graph
+    nip dup label>> (>>return) ;
 
-: remember-loop-info ( label -- )
-    loop-stack get length swap loop-heights get set-at ;
+M: #call-recursive node-call-graph
+    [ dup label>> call-site boa ] keep
+    [ drop calls get push ]
+    [ label>> calls>> push ] 2bi ;
 
-M: #recursive collect-loop-info*
+M: #recursive node-call-graph
+    [ label>> V{ } clone >>calls drop ]
     [
-        [
-            label>>
-            [ swap 2array loop-stack [ swap suffix ] change ]
-            [ remember-loop-info ]
-            [ t >>loop? drop ]
-            tri
-        ]
-        [ t swap child>> (collect-loop-info) ] bi
-    ] with-scope ;
+        [ label>> ] [ child>> build-call-graph ] bi
+        call-graph-node boa children get push
+    ] bi ;
 
-: current-loop-nesting ( label -- alist )
-    loop-stack get swap loop-heights get at tail ;
+M: #branch node-call-graph
+    children>> [ (build-call-graph) ] with each ;
 
-: disqualify-loop ( label -- )
-    work-list get push-front ;
+M: node node-call-graph 2drop ;
 
-M: #call-recursive collect-loop-info*
-    label>>
-    swap [ dup disqualify-loop ] unless
-    dup current-loop-nesting
-    [ keys [ loop-calls get push-at ] with each ]
-    [ [ nip not ] assoc-filter keys [ disqualify-loop ] each ]
-    bi ;
+SYMBOLS: not-loops recursive-nesting ;
 
-M: #if collect-loop-info*
-    children>> [ (collect-loop-info) ] with each ;
+: not-a-loop ( label -- ) not-loops get conjoin ;
 
-M: #dispatch collect-loop-info*
-    children>> [ (collect-loop-info) ] with each ;
+: not-a-loop? ( label -- ? ) not-loops get key? ;
 
-M: node collect-loop-info* 2drop ;
+: non-tail-calls ( call-graph-node -- seq )
+    calls>> [ tail?>> not ] filter ;
+
+: visit-back-edges ( call-graph -- )
+    [
+        [ non-tail-calls [ label>> not-a-loop ] each ]
+        [ children>> visit-back-edges ]
+        bi
+    ] each ;
+
+SYMBOL: changed?
+
+: check-cross-frame-call ( call-site -- )
+    label>> dup not-a-loop? [ drop ] [
+        recursive-nesting get <reversed> [
+            2dup label>> eq? [ 2drop f ] [
+                [ label>> not-a-loop? ] [ tail?>> not ] bi or
+                [ not-a-loop changed? on ] [ drop ] if t
+            ] if
+        ] with all? drop
+    ] if ;
+
+: detect-cross-frame-calls ( call-graph -- )
+    ! Suppose we have a nesting of recursives A --> B --> C
+    ! B tail-calls A, and C non-tail-calls B. Then A cannot be
+    ! a loop, it needs its own procedure, since the call from
+    ! C to A crosses a call-frame boundary.
+    [
+        [ recursive-nesting get push ]
+        [ calls>> [ check-cross-frame-call ] each ]
+        [ children>> detect-cross-frame-calls ] tri
+        recursive-nesting get pop*
+    ] each ;
+
+: while-changing ( quot: ( -- ) -- )
+    changed? off
+    [ call ] [ changed? get [ while-changing ] [ drop ] if ] bi ;
+    inline recursive
+
+: detect-loops ( call-graph -- )
+    H{ } clone not-loops set
+    V{ } clone recursive-nesting set
+    [ visit-back-edges ]
+    [ '[ _ detect-cross-frame-calls ] while-changing ]
+    bi ;
+
+: mark-loops ( call-graph -- )
+    [
+        [ label>> dup not-a-loop? [ t >>loop? ] unless drop ]
+        [ children>> mark-loops ]
+        bi
+    ] each ;
 
-: collect-loop-info ( node -- )
-    { } loop-stack set
-    H{ } clone loop-calls set
-    H{ } clone loop-heights set
-    <hashed-dlist> work-list set
-    t swap (collect-loop-info) ;
+PRIVATE>
 
-: disqualify-loops ( -- )
-    work-list get [
-        dup loop?>> [
-            [ f >>loop? drop ]
-            [ loop-calls get at [ disqualify-loop ] each ]
-            bi
-        ] [ drop ] if
-    ] slurp-deque ;
+SYMBOL: call-graph
 
 : analyze-recursive ( nodes -- nodes )
-    dup [ collect-label-info ] each-node
-    dup collect-loop-info disqualify-loops ;
+    dup build-call-graph drop
+    [ call-graph set ]
+    [ detect-loops ]
+    [ mark-loops ]
+    tri ;
index c73f2211f04b378a33ee1ad5ebddbeaf42bf8f3e..7fa096b62392f828aef97bee34568b97cf5c93dd 100644 (file)
@@ -165,9 +165,6 @@ M: #shuffle inputs/outputs mapping>> unzip swap ;
 M: #copy inputs/outputs [ in-d>> ] [ out-d>> ] bi ;
 M: #return-recursive inputs/outputs [ in-d>> ] [ out-d>> ] bi ;
 
-: recursive-phi-in ( #enter-recursive -- seq )
-    [ label>> calls>> [ in-d>> ] map ] [ in-d>> ] bi suffix ;
-
 : ends-with-terminate? ( nodes -- ? )
     [ f ] [ last #terminate? ] if-empty ;
 
index a96fc0501d3e15c5a76187d75dd73eaaa33b2eca..d73368867d0a25706ab5e3813dd99b85db7a176c 100644 (file)
@@ -1,4 +1,3 @@
-IN: compiler.tree.tuple-unboxing.tests
 USING: tools.test compiler.tree
 compiler.tree.builder compiler.tree.recursive
 compiler.tree.normalization compiler.tree.propagation
@@ -7,6 +6,7 @@ compiler.tree.tuple-unboxing compiler.tree.checker
 compiler.tree.def-use kernel accessors sequences math
 math.private sorting math.order binary-search sequences.private
 slots.private ;
+IN: compiler.tree.tuple-unboxing.tests
 
 : test-unboxing ( quot -- )
     build-tree
index 6bed4407b892307ffc6b21f62ed5cf689c9691f6..de2848ea78dffeb78041ab8708baad15cc351b60 100755 (executable)
@@ -1,12 +1,15 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces assocs accessors kernel combinators
+USING: namespaces assocs accessors kernel kernel.private combinators
 classes.algebra sequences slots.private fry vectors
 classes.tuple.private math math.private arrays
-stack-checker.branches
+stack-checker.branches stack-checker.values
 compiler.utilities
 compiler.tree
+compiler.tree.builder
+compiler.tree.cleanup
 compiler.tree.combinators
+compiler.tree.propagation
 compiler.tree.propagation.info
 compiler.tree.escape-analysis.simple
 compiler.tree.escape-analysis.allocations ;
@@ -72,8 +75,8 @@ M: #call unbox-tuples*
     } case ;
 
 M: #declare unbox-tuples*
-    #! We don't look at declarations after propagation anyway.
-    f >>declaration ;
+    #! We don't look at declarations after escape analysis anyway.
+    drop f ;
 
 M: #copy unbox-tuples*
     [ flatten-values ] change-in-d
@@ -113,6 +116,44 @@ M: #return-recursive unbox-tuples*
     [ flatten-values ] change-in-d
     [ flatten-values ] change-out-d ;
 
+: value-declaration ( value -- quot )
+    value-class [ 1array '[ _ declare ] ] [ [ ] ] if* ;
+
+: unbox-parameter-quot ( allocation -- quot )
+    dup unboxed-allocation {
+        { [ dup not ] [ 2drop [ ] ] }
+        { [ dup array? ] [
+            [ value-declaration ] [
+                [
+                    [ unbox-parameter-quot ] [ 2 + '[ _ slot ] ] bi*
+                    prepose
+                ] map-index
+            ] bi* '[ @ _ cleave ]
+        ] }
+    } cond ;
+
+: unbox-parameters-quot ( values -- quot )
+    [ unbox-parameter-quot ] map
+    dup [ [ ] = ] all? [ drop [ ] ] [ '[ _ spread ] ] if ;
+
+: unbox-parameters-nodes ( new-values old-values -- nodes )
+    [ flatten-values ] [ unbox-parameters-quot ] bi build-sub-tree ;
+
+: new-and-old-values ( values -- new-values old-values )
+    [ length [ <value> ] replicate ] keep ;
+
+: unbox-hairy-introduce ( #introduce -- nodes )
+    dup out-d>> new-and-old-values
+    [ drop >>out-d ] [ unbox-parameters-nodes ] 2bi
+    swap prefix propagate ;
+
+M: #introduce unbox-tuples*
+    ! For every output that is unboxed, insert slot accessors
+    ! to convert the stack value into its unboxed form
+    dup out-d>> [ unboxed-allocation ] any? [
+        unbox-hairy-introduce
+    ] when ;
+
 ! These nodes never participate in unboxing
 : assert-not-unboxed ( values -- )
     dup array?
@@ -123,8 +164,6 @@ M: #branch unbox-tuples* dup in-d>> assert-not-unboxed ;
 
 M: #return unbox-tuples* dup in-d>> assert-not-unboxed ;
 
-M: #introduce unbox-tuples* dup out-d>> assert-not-unboxed ;
-
 M: #alien-invoke unbox-tuples* dup in-d>> assert-not-unboxed ;
 
 M: #alien-indirect unbox-tuples* dup in-d>> assert-not-unboxed ;
index c6b7b2adc5286876fd4180aaee7971ad4c9f8df8..d8df81fc0dfc52d1aed2258d0f353c4fedea09d6 100644 (file)
@@ -9,7 +9,7 @@ IN: compiler.utilities
         dup
         '[
             @ [
-                dup array?
+                dup [ array? ] [ vector? ] bi or
                 [ _ push-all ] [ _ push ] if
             ] when*
         ]
@@ -26,8 +26,12 @@ SYMBOL: yield-hook
 
 yield-hook [ [ ] ] initialize
 
-: alist-max ( alist -- pair )
-    [ ] [ [ [ second ] bi@ > ] most ] map-reduce ;
+: alist-most ( alist quot -- pair )
+    [ [ ] ] dip '[ [ [ second ] bi@ @ ] most ] map-reduce ; inline
+
+: alist-min ( alist -- pair ) [ before? ] alist-most ;
+
+: alist-max ( alist -- pair ) [ after? ] alist-most ;
 
 : penultimate ( seq -- elt ) [ length 2 - ] keep nth ;
 
index 9ece36e6cd8f87572bb45eb2b984affc3128cb56..2df4dce916a5f5807f54540bb4349188fac608c3 100755 (executable)
@@ -17,8 +17,8 @@ TUPLE: huffman-code
     { code } ;\r
 \r
 : <huffman-code> ( -- code ) 0 0 0 huffman-code boa ;\r
-: next-size ( code -- ) [ 1+ ] change-size [ 2 * ] change-code drop ;\r
-: next-code ( code -- ) [ 1+ ] change-code drop ;\r
+: next-size ( code -- ) [ 1 + ] change-size [ 2 * ] change-code drop ;\r
+: next-code ( code -- ) [ 1 + ] change-code drop ;\r
 \r
 :: all-patterns ( huff n -- seq )\r
     n log2 huff size>> - :> free-bits\r
index 05ec94a794daa8c79f4b9322d6028987fcd23b8c..ff38f94c68a236521540f498c56656f86049ac2c 100644 (file)
@@ -64,7 +64,7 @@ CONSTANT: clen-shuffle { 16 17 18 0 8 7 9 6 10 5 11 4 12 3 13 2 14 1 15 }
         k swap - dup k! 0 >
     ] 
     [ ] produce swap suffix
-    { } [ dup array? [ dup first 16 = ] [ f ] if [ [ unclip-last ] [ second 1+ swap <repetition> append ] bi* ] [ suffix ] if ] reduce
+    { } [ dup array? [ dup first 16 = ] [ f ] if [ [ unclip-last ] [ second 1 + swap <repetition> append ] bi* ] [ suffix ] if ] reduce
     [ dup array? [ second 0 <repetition> ] [ 1array ] if ] map concat
     nip swap cut 2array [ [ length>> [0,b) ] [ ] bi get-table ] map ;
     
@@ -91,14 +91,14 @@ CONSTANT: dist-table
     }
 
 : nth* ( n seq -- elt )
-    [ length 1- swap - ] [ nth ] bi ;
+    [ length 1 - swap - ] [ nth ] bi ;
 
 :: inflate-lz77 ( seq -- bytes )
     1000 <byte-vector> :> bytes
     seq
     [
         dup array?
-        [ first2 '[ _ 1- bytes nth* bytes push ] times ]
+        [ first2 '[ _ 1 - bytes nth* bytes push ] times ]
         [ bytes push ] if
     ] each 
     bytes ;
diff --git a/basis/compression/lzw/lzw-tests.factor b/basis/compression/lzw/lzw-tests.factor
deleted file mode 100644 (file)
index 698e35d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors tools.test compression.lzw ;
-IN: compression.lzw.tests
index 1c2dea2d79ce62305457be3cb4b306316eb5591c..d3f3229171bb279522c8d01d0e6c869d62a00077 100644 (file)
@@ -1,7 +1,7 @@
-IN: concurrency.combinators.tests\r
 USING: concurrency.combinators tools.test random kernel math \r
 concurrency.mailboxes threads sequences accessors arrays\r
 math.parser ;\r
+IN: concurrency.combinators.tests\r
 \r
 [ [ drop ] parallel-each ] must-infer\r
 { 2 0 } [ [ 2drop ] 2parallel-each ] must-infer-as\r
@@ -49,7 +49,7 @@ math.parser ;
 \r
 [ "1a" "4b" "3c" ] [\r
     2\r
-    { [ 1- ] [ sq ] [ 1+ ] } parallel-cleave\r
+    { [ 1 - ] [ sq ] [ 1 + ] } parallel-cleave\r
     [ number>string ] 3 parallel-napply\r
     { [ "a" append ] [ "b" append ] [ "c" append ] } parallel-spread\r
 ] unit-test\r
index d79cfbf1c91b9863801cd9dcc03eec2cae4634d0..d88fcef6093199984a386ee9f6e7df170852b7e4 100644 (file)
@@ -23,7 +23,7 @@ ERROR: count-down-already-done ;
 : count-down ( count-down -- )\r
     dup n>> dup zero?\r
     [ count-down-already-done ]\r
-    [ 1- >>n count-down-check ] if ;\r
+    [ 1 - >>n count-down-check ] if ;\r
 \r
 : await-timeout ( count-down timeout -- )\r
     [ promise>> ] dip ?promise-timeout ?linked t assert= ;\r
index 6c0d882cacfd56f93fc1f4f2fede094b20fcac5f..b2a28519260ee4ed1ec7b98e39fadfc5605f7bae 100644 (file)
@@ -1,9 +1,9 @@
-IN: concurrency.distributed.tests
 USING: tools.test concurrency.distributed kernel io.files
 io.files.temp io.directories arrays io.sockets system
 combinators threads math sequences concurrency.messaging
 continuations accessors prettyprint ;
 FROM: concurrency.messaging => receive send ;
+IN: concurrency.distributed.tests
 
 : test-node ( -- addrspec )
     {
index 7ec9db8ad96a21ea1748828c3e4af477817ccd8b..a8214cf42f2301a5712a034df555f20053c3bbf3 100644 (file)
@@ -1,8 +1,8 @@
-IN: concurrency.exchangers.tests\r
 USING: tools.test concurrency.exchangers\r
 concurrency.count-downs concurrency.promises locals kernel\r
 threads ;\r
 FROM: sequences => 3append ;\r
+IN: concurrency.exchangers.tests\r
 \r
 :: exchanger-test ( -- string )\r
     [let |\r
index 05ff74b03f27236dcf436e2e74aef8688ba07aa3..4fc00b71dd74df1c5c604b7d0703bc6c38b384a1 100644 (file)
@@ -1,6 +1,6 @@
-IN: concurrency.flags.tests\r
 USING: tools.test concurrency.flags concurrency.combinators\r
 kernel threads locals accessors calendar ;\r
+IN: concurrency.flags.tests\r
 \r
 :: flag-test-1 ( -- val )\r
     [let | f [ <flag> ] |\r
index 208a72f820ebfe6e218e4a2349d14483c9663a33..07466e5ffdec0cdee9c7065263681d809eae36f8 100644 (file)
@@ -1,5 +1,5 @@
-IN: concurrency.futures.tests\r
 USING: concurrency.futures kernel tools.test threads ;\r
+IN: concurrency.futures.tests\r
 \r
 [ 50 ] [\r
     [ 50 ] future ?future\r
index 8f82aa88baa997c56780e6b51e6b17117a7fa71f..f199876fd0c5d360c564debc1439724130f1ec08 100644 (file)
@@ -1,7 +1,7 @@
-IN: concurrency.locks.tests\r
 USING: tools.test concurrency.locks concurrency.count-downs\r
 concurrency.messaging concurrency.mailboxes locals kernel\r
 threads sequences calendar accessors ;\r
+IN: concurrency.locks.tests\r
 \r
 :: lock-test-0 ( -- v )\r
     [let | v [ V{ } clone ]\r
index 0094f3323d709d26f22850b02ee2a206ab12a537..18cd86fa53470dcaf00944a203f86482871e3e56 100644 (file)
@@ -57,7 +57,7 @@ TUPLE: rw-lock readers writers reader# writer ;
 <PRIVATE\r
 \r
 : add-reader ( lock -- )\r
-    [ 1+ ] change-reader# drop ;\r
+    [ 1 + ] change-reader# drop ;\r
 \r
 : acquire-read-lock ( lock timeout -- )\r
     over writer>>\r
@@ -68,7 +68,7 @@ TUPLE: rw-lock readers writers reader# writer ;
     writers>> notify-1 ;\r
 \r
 : remove-reader ( lock -- )\r
-    [ 1- ] change-reader# drop ;\r
+    [ 1 - ] change-reader# drop ;\r
 \r
 : release-read-lock ( lock -- )\r
     dup remove-reader\r
index 81e54f18078d907f7740ec97dafd371140eaf837..56d579d6c71cd987a10ebb8ccd22f7fb77ef7c4a 100644 (file)
@@ -1,7 +1,7 @@
-IN: concurrency.mailboxes.tests\r
 USING: concurrency.mailboxes concurrency.count-downs concurrency.conditions\r
 vectors sequences threads tools.test math kernel strings namespaces\r
 continuations calendar destructors ;\r
+IN: concurrency.mailboxes.tests\r
 \r
 { 1 1 } [ [ integer? ] mailbox-get? ] must-infer-as\r
 \r
@@ -86,4 +86,4 @@ continuations calendar destructors ;
 [\r
     <mailbox> 1 seconds mailbox-get-timeout\r
 ] [ wait-timeout? ] must-fail-with\r
-    
\ No newline at end of file
+    \r
index 200adb14aea9148793785c66458504ce70e6e8e7..419277647d778d7679ff74f765ae59de6b2af94f 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2005, 2008 Chris Double, Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-IN: concurrency.mailboxes\r
 USING: dlists deques threads sequences continuations\r
 destructors namespaces math quotations words kernel\r
 arrays assocs init system concurrency.conditions accessors\r
 debugger debugger.threads locals fry ;\r
+IN: concurrency.mailboxes\r
 \r
 TUPLE: mailbox threads data disposed ;\r
 \r
index 36fe4ef907244b481b449b01cd7aafa38432d68c..353f4a69b7cd62d58b64bab270e4c925d2c5cb66 100644 (file)
@@ -1,6 +1,6 @@
-IN: concurrency.promises.tests\r
 USING: vectors concurrency.promises kernel threads sequences\r
 tools.test ;\r
+IN: concurrency.promises.tests\r
 \r
 [ V{ 50 50 50 } ] [\r
     0 <vector>\r
index 59518f4c8d7320d449f092345d519a24ad322048..dcd0ed9a2c8c31e07f9f52d80b3d6a9ae993affd 100644 (file)
@@ -21,13 +21,13 @@ M: negative-count-semaphore summary
 : acquire-timeout ( semaphore timeout -- )\r
     over count>> zero?\r
     [ dupd wait-to-acquire ] [ drop ] if\r
-    [ 1- ] change-count drop ;\r
+    [ 1 - ] change-count drop ;\r
 \r
 : acquire ( semaphore -- )\r
     f acquire-timeout ;\r
 \r
 : release ( semaphore -- )\r
-    [ 1+ ] change-count\r
+    [ 1 + ] change-count\r
     threads>> notify-1 ;\r
 \r
 :: with-semaphore-timeout ( semaphore timeout quot -- )\r
index 0058c8f07a6c59045d92bbc3ff2d835579df1ae2..898e4e51c804fc4a94b91e2072842115a406366a 100644 (file)
@@ -1,5 +1,5 @@
-IN: cords.tests
 USING: cords strings tools.test kernel sequences ;
+IN: cords.tests
 
 [ "hello world" ] [ "hello" " world" cord-append dup like ] unit-test
 [ "hello world" ] [ { "he" "llo" " world" } cord-concat dup like ] unit-test
diff --git a/basis/core-foundation/numbers/numbers-tests.factor b/basis/core-foundation/numbers/numbers-tests.factor
deleted file mode 100644 (file)
index 1c50f2d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test core-foundation.numbers ;
-IN: core-foundation.numbers.tests
index a63a3ea6747af3ca3be40ab72fb4b2c5fa61c3c8..6446eacd08045d3cf91e9e485a0f5c8a22ad3829 100644 (file)
@@ -103,7 +103,7 @@ TUPLE: run-loop fds sources timers ;
 : (reset-timer) ( timer counter -- )
     yield {
         { [ dup 0 = ] [ now ((reset-timer)) ] }
-        { [ run-queue deque-empty? not ] [ 1- (reset-timer) ] }
+        { [ run-queue deque-empty? not ] [ 1 - (reset-timer) ] }
         { [ sleep-queue heap-empty? ] [ 5 minutes hence ((reset-timer)) ] }
         [ sleep-queue heap-peek nip micros>timestamp ((reset-timer)) ]
     } cond ;
diff --git a/basis/core-foundation/utilities/utilities-tests.factor b/basis/core-foundation/utilities/utilities-tests.factor
deleted file mode 100644 (file)
index fb3deb2..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test core-foundation.utilities ;
-IN: core-foundation.utilities.tests
diff --git a/basis/core-graphics/types/types-tests.factor b/basis/core-graphics/types/types-tests.factor
deleted file mode 100644 (file)
index d3b081f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test core-graphics.types ;
-IN: core-graphics.types.tests
diff --git a/basis/core-text/fonts/fonts-tests.factor b/basis/core-text/fonts/fonts-tests.factor
deleted file mode 100644 (file)
index 45fa2bc..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test core-text.fonts ;
-IN: core-text.fonts.tests
diff --git a/basis/core-text/utilities/utilities-tests.factor b/basis/core-text/utilities/utilities-tests.factor
deleted file mode 100644 (file)
index 65914a3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test core-text.utilities ;
-IN: core-text.utilities.tests
index e4c8f3246da7479311fe4873acafa475a078bbe6..7bb9caec9b10b9c9843860ab242dc81a0873deeb 100644 (file)
@@ -1,42 +1,56 @@
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays generic kernel kernel.private math
 memory namespaces make sequences layouts system hashtables
 classes alien byte-arrays combinators words sets fry ;
 IN: cpu.architecture
 
-! Register classes
-SINGLETON: int-regs
-SINGLETON: single-float-regs
-SINGLETON: double-float-regs
-UNION: float-regs single-float-regs double-float-regs ;
-UNION: reg-class int-regs float-regs ;
-
-! A pseudo-register class for parameters spilled on the stack
-SINGLETON: stack-params
-
-GENERIC: reg-size ( register-class -- n )
+! Representations -- these are like low-level types
 
-M: int-regs reg-size drop cell ;
+! Unknown representation; this is used for ##copy instructions which
+! get eliminated later
+SINGLETON: any-rep
 
-M: single-float-regs reg-size drop 4 ;
+! Integer registers can contain data with one of these three representations
+! tagged-rep: tagged pointer or fixnum
+! int-rep: untagged fixnum, not a pointer
+SINGLETONS: tagged-rep int-rep ;
 
-M: double-float-regs reg-size drop 8 ;
+! Floating point registers can contain data with
+! one of these representations
+SINGLETONS: single-float-rep double-float-rep ;
 
-M: stack-params reg-size drop cell ;
+UNION: representation any-rep tagged-rep int-rep single-float-rep double-float-rep ;
 
-! Mapping from register class to machine registers
-HOOK: machine-registers cpu ( -- assoc )
+! Register classes
+SINGLETONS: int-regs float-regs ;
 
-! Return values of this class go here
-GENERIC: return-reg ( register-class -- reg )
+UNION: reg-class int-regs float-regs ;
+CONSTANT: reg-classes { int-regs float-regs }
 
-! Sequence of registers used for parameter passing in class
-GENERIC: param-regs ( register-class -- regs )
+! A pseudo-register class for parameters spilled on the stack
+SINGLETON: stack-params
 
-GENERIC: param-reg ( n register-class -- reg )
+: reg-class-of ( rep -- reg-class )
+    {
+        { tagged-rep [ int-regs ] }
+        { int-rep [ int-regs ] }
+        { single-float-rep [ float-regs ] }
+        { double-float-rep [ float-regs ] }
+        { stack-params [ stack-params ] }
+    } case ;
+
+: rep-size ( rep -- n )
+    {
+        { tagged-rep [ cell ] }
+        { int-rep [ cell ] }
+        { single-float-rep [ 4 ] }
+        { double-float-rep [ 8 ] }
+        { stack-params [ cell ] }
+    } case ;
 
-M: object param-reg param-regs nth ;
+! Mapping from register class to machine registers
+HOOK: machine-registers cpu ( -- assoc )
 
 HOOK: two-operand? cpu ( -- ? )
 
@@ -100,8 +114,7 @@ HOOK: %div-float cpu ( dst src1 src2 -- )
 HOOK: %integer>float cpu ( dst src -- )
 HOOK: %float>integer cpu ( dst src -- )
 
-HOOK: %copy cpu ( dst src -- )
-HOOK: %copy-float cpu ( dst src -- )
+HOOK: %copy cpu ( dst src rep -- )
 HOOK: %unbox-float cpu ( dst src -- )
 HOOK: %unbox-any-c-ptr cpu ( dst src temp -- )
 HOOK: %box-float cpu ( dst src temp -- )
@@ -146,15 +159,27 @@ HOOK: %compare-branch cpu ( label cc src1 src2 -- )
 HOOK: %compare-imm-branch cpu ( label cc src1 src2 -- )
 HOOK: %compare-float-branch cpu ( label cc src1 src2 -- )
 
-HOOK: %spill-integer cpu ( src n -- )
-HOOK: %spill-float cpu ( src n -- )
-HOOK: %reload-integer cpu ( dst n -- )
-HOOK: %reload-float cpu ( dst n -- )
+HOOK: %spill cpu ( src n rep -- )
+HOOK: %reload cpu ( dst n rep -- )
 
 HOOK: %loop-entry cpu ( -- )
 
 ! FFI stuff
 
+! Return values of this class go here
+GENERIC: return-reg ( reg-class -- reg )
+
+! Sequence of registers used for parameter passing in class
+GENERIC: param-regs ( reg-class -- regs )
+
+M: stack-params param-regs drop f ;
+
+GENERIC: param-reg ( n reg-class -- reg )
+
+M: reg-class param-reg param-regs nth ;
+
+M: stack-params param-reg drop ;
+
 ! Is this integer small enough to appear in value template
 ! slots?
 HOOK: small-enough? cpu ( n -- ? )
@@ -176,7 +201,7 @@ HOOK: dummy-fp-params? cpu ( -- ? )
 
 HOOK: %prepare-unbox cpu ( -- )
 
-HOOK: %unbox cpu ( n reg-class func -- )
+HOOK: %unbox cpu ( n rep func -- )
 
 HOOK: %unbox-long-long cpu ( n func -- )
 
@@ -184,7 +209,7 @@ HOOK: %unbox-small-struct cpu ( c-type -- )
 
 HOOK: %unbox-large-struct cpu ( n c-type -- )
 
-HOOK: %box cpu ( n reg-class func -- )
+HOOK: %box cpu ( n rep func -- )
 
 HOOK: %box-long-long cpu ( n func -- )
 
@@ -194,9 +219,9 @@ HOOK: %box-small-struct cpu ( c-type -- )
 
 HOOK: %box-large-struct cpu ( n c-type -- )
 
-GENERIC: %save-param-reg ( stack reg reg-class -- )
+HOOK: %save-param-reg cpu ( stack reg rep -- )
 
-GENERIC: %load-param-reg ( stack reg reg-class -- )
+HOOK: %load-param-reg cpu ( stack reg rep -- )
 
 HOOK: %prepare-alien-invoke cpu ( -- )
 
@@ -222,7 +247,3 @@ HOOK: %callback-value cpu ( ctype -- )
 HOOK: %callback-return cpu ( params -- )
 
 M: object %callback-return drop %return ;
-
-M: stack-params param-reg drop ;
-
-M: stack-params param-regs drop f ;
index 23b1d1e6f422d343529def975ec841d74aaee96d..6ee1c84558d8e15d16269c0d04592cf766376fca 100644 (file)
@@ -1,7 +1,7 @@
-IN: cpu.ppc.assembler.tests
 USING: cpu.ppc.assembler tools.test arrays kernel namespaces
 make vocabs sequences ;
 FROM: cpu.ppc.assembler => B ;
+IN: cpu.ppc.assembler.tests
 
 : test-assembler ( expected quot -- )
     [ 1array ] [ [ B{ } make ] curry ] bi* unit-test ;
index cbb914121ea2eb02444ca70340235d3a2c7c7fdc..c63372fa3f8d36358ccb838409637197929c0351 100644 (file)
@@ -226,7 +226,7 @@ CONSTANT: rs-reg 14
     ! key = class\r
     5 4 MR\r
     ! key &= cache.length - 1\r
-    5 5 mega-cache-size get 1- bootstrap-cell * ANDI\r
+    5 5 mega-cache-size get 1 - bootstrap-cell * ANDI\r
     ! cache += array-start-offset\r
     3 3 array-start-offset ADDI\r
     ! cache += key\r
index 14d271c31c99b6f78d3ff81ec3b6c9d4ea437e20..a169982445848870581b6883b1df12cd535bdada 100644 (file)
@@ -32,7 +32,7 @@ enable-float-intrinsics
 M: ppc machine-registers
     {
         { int-regs $[ 2 12 [a,b] 15 29 [a,b] append ] }
-        { double-float-regs $[ 0 29 [a,b] ] }
+        { float-regs $[ 0 29 [a,b] ] }
     } ;
 
 CONSTANT: scratch-reg 30
@@ -217,7 +217,7 @@ M:: ppc %integer>bignum ( dst src temp -- )
         temp dst 1 bignum@ STW
         ! Compute sign
         temp src MR
-        temp temp cell-bits 1- SRAWI
+        temp temp cell-bits 1 - SRAWI
         temp temp 1 ANDI
         ! Store sign
         temp dst 2 bignum@ STW
@@ -493,26 +493,18 @@ M: float-regs return-reg drop 1 ;
 M: int-regs %save-param-reg drop 1 rot local@ STW ;
 M: int-regs %load-param-reg drop 1 rot local@ LWZ ;
 
-GENERIC: STF ( src dst off reg-class -- )
+M: single-float-rep %save-param-reg drop 1 rot local@ STFS ;
+M: single-float-rep %load-param-reg 1 rot local@ LFS ;
 
-M: single-float-regs STF drop STFS ;
-M: double-float-regs STF drop STFD ;
+M: double-float-rep %save-param-reg drop 1 rot local@ STFD ;
+M: double-float-rep %load-param-reg 1 rot local@ LFD ;
 
-M: float-regs %save-param-reg [ 1 rot local@ ] dip STF ;
-
-GENERIC: LF ( dst src off reg-class -- )
-
-M: single-float-regs LF drop LFS ;
-M: double-float-regs LF drop LFD ;
-
-M: float-regs %load-param-reg [ 1 rot local@ ] dip LF ;
-
-M: stack-params %load-param-reg ( stack reg reg-class -- )
+M: stack-params %load-param-reg ( stack reg rep -- )
     drop [ 0 1 rot local@ LWZ 0 1 ] dip param@ STW ;
 
 : next-param@ ( n -- x ) param@ stack-frame get total-size>> + ;
 
-M: stack-params %save-param-reg ( stack reg reg-class -- )
+M: stack-params %save-param-reg ( stack reg rep -- )
     #! Funky. Read the parameter from the caller's stack frame.
     #! This word is used in callbacks
     drop
@@ -524,12 +516,12 @@ M: ppc %prepare-unbox ( -- )
     3 ds-reg 0 LWZ
     ds-reg dup cell SUBI ;
 
-M: ppc %unbox ( n reg-class func -- )
+M: ppc %unbox ( n rep func -- )
     ! Value must be in r3
     ! Call the unboxer
     f %alien-invoke
     ! Store the return value on the C stack
-    over [ [ return-reg ] keep %save-param-reg ] [ 2drop ] if ;
+    over [ [ reg-class-of return-reg ] keep %save-param-reg ] [ 2drop ] if ;
 
 M: ppc %unbox-long-long ( n func -- )
     ! Value must be in r3:r4
@@ -548,11 +540,11 @@ M: ppc %unbox-large-struct ( n c-type -- )
     ! Call the function
     "to_value_struct" f %alien-invoke ;
 
-M: ppc %box ( n reg-class func -- )
+M: ppc %box ( n rep func -- )
     ! If the source is a stack location, load it into freg #0.
     ! If the source is f, then we assume the value is already in
     ! freg #0.
-    [ over [ 0 over param-reg swap %load-param-reg ] [ 2drop ] if ] dip
+    [ over [ 0 over reg-class-of param-reg swap %load-param-reg ] [ 2drop ] if ] dip
     f %alien-invoke ;
 
 M: ppc %box-long-long ( n func -- )
index 76699c1306c09b142622f0d18d96ffaaf60ccd80..bd03b47302e5c379fdcc88920f51472ee23e8b2c 100755 (executable)
@@ -10,21 +10,18 @@ cpu.x86.assembler.operands cpu.x86 cpu.architecture ;
 IN: cpu.x86.32
 
 ! We implement the FFI for Linux, OS X and Windows all at once.
-! OS X requires that the stack be 16-byte aligned, and we do
-! this on all platforms, sacrificing some stack space for
-! code simplicity.
+! OS X requires that the stack be 16-byte aligned.
 
 M: x86.32 machine-registers
     {
         { int-regs { EAX ECX EDX EBP EBX } }
-        { double-float-regs { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } }
+        { float-regs { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } }
     } ;
 
 M: x86.32 ds-reg ESI ;
 M: x86.32 rs-reg EDI ;
 M: x86.32 stack-reg ESP ;
-M: x86.32 temp-reg-1 ECX ;
-M: x86.32 temp-reg-2 EDX ;
+M: x86.32 temp-reg ECX ;
 
 M:: x86.32 %dispatch ( src temp -- )
     ! Load jump table base.
@@ -63,29 +60,23 @@ M: x86.32 return-struct-in-registers? ( c-type -- ? )
 ! On x86, parameters are never passed in registers.
 M: int-regs return-reg drop EAX ;
 M: int-regs param-regs drop { } ;
-M: int-regs push-return-reg return-reg PUSH ;
-
-M: int-regs load-return-reg
-    return-reg swap next-stack@ MOV ;
-
-M: int-regs store-return-reg
-    [ stack@ ] [ return-reg ] bi* MOV ;
-
 M: float-regs param-regs drop { } ;
 
-: FSTP ( operand size -- ) 4 = [ FSTPS ] [ FSTPL ] if ;
-
-M: float-regs push-return-reg
-    stack-reg swap reg-size
-    [ SUB ] [ [ [] ] dip FSTP ] 2bi ;
+GENERIC: push-return-reg ( rep -- )
+GENERIC: load-return-reg ( n rep -- )
+GENERIC: store-return-reg ( n rep -- )
 
-: FLD ( operand size -- ) 4 = [ FLDS ] [ FLDL ] if ;
+M: int-rep push-return-reg drop EAX PUSH ;
+M: int-rep load-return-reg drop EAX swap next-stack@ MOV ;
+M: int-rep store-return-reg drop stack@ EAX MOV ;
 
-M: float-regs load-return-reg
-    [ next-stack@ ] [ reg-size ] bi* FLD ;
+M: single-float-rep push-return-reg drop ESP 4 SUB ESP [] FSTPS ;
+M: single-float-rep load-return-reg drop next-stack@ FLDS ;
+M: single-float-rep store-return-reg drop stack@ FSTPS ;
 
-M: float-regs store-return-reg
-    [ stack@ ] [ reg-size ] bi* FSTP ;
+M: double-float-rep push-return-reg drop ESP 8 SUB ESP [] FSTPL ;
+M: double-float-rep load-return-reg drop next-stack@ FLDL ;
+M: double-float-rep store-return-reg drop stack@ FSTPL ;
 
 : align-sub ( n -- )
     [ align-stack ] keep - decr-stack-reg ;
@@ -101,21 +92,21 @@ M: x86.32 %prologue ( n -- )
     0 PUSH rc-absolute-cell rel-this
     3 cells - decr-stack-reg ;
 
-M: object %load-param-reg 3drop ;
+M: x86.32 %load-param-reg 3drop ;
 
-M: object %save-param-reg 3drop ;
+M: x86.32 %save-param-reg 3drop ;
 
-: (%box) ( n reg-class -- )
+: (%box) ( n rep -- )
     #! If n is f, push the return register onto the stack; we
     #! are boxing a return value of a C function. If n is an
     #! integer, push [ESP+n] on the stack; we are boxing a
     #! parameter being passed to a callback from C.
     over [ load-return-reg ] [ 2drop ] if ;
 
-M:: x86.32 %box ( n reg-class func -- )
-    n reg-class (%box)
-    reg-class reg-size [
-        reg-class push-return-reg
+M:: x86.32 %box ( n rep func -- )
+    n rep (%box)
+    rep rep-size [
+        rep push-return-reg
         func f %alien-invoke
     ] with-aligned-stack ;
     
@@ -165,7 +156,7 @@ M: x86.32 %prepare-unbox ( -- )
     EAX ESI [] MOV
     ESI 4 SUB ;
 
-: (%unbox) ( func -- )
+: call-unbox-func ( func -- )
     4 [
         ! Push parameter
         EAX PUSH
@@ -173,17 +164,17 @@ M: x86.32 %prepare-unbox ( -- )
         f %alien-invoke
     ] with-aligned-stack ;
 
-M: x86.32 %unbox ( n reg-class func -- )
+M: x86.32 %unbox ( n rep func -- )
     #! The value being unboxed must already be in EAX.
     #! If n is f, we're unboxing a return value about to be
     #! returned by the callback. Otherwise, we're unboxing
     #! a parameter to a C function about to be called.
-    (%unbox)
+    call-unbox-func
     ! Store the return value on the C stack
     over [ store-return-reg ] [ 2drop ] if ;
 
 M: x86.32 %unbox-long-long ( n func -- )
-    (%unbox)
+    call-unbox-func
     ! Store the return value on the C stack
     [
         dup stack@ EAX MOV
index f837c7de7300cd3542fc7fde298653a4e1b4b359..7c832fe66c27b5be9638ea52fbd0edf4d5229bb3 100644 (file)
@@ -11,7 +11,7 @@ IN: cpu.x86.64
 M: x86.64 machine-registers
     {
         { int-regs { RAX RCX RDX RBX RBP RSI RDI R8 R9 R10 R11 R12 R13 } }
-        { double-float-regs {
+        { float-regs {
             XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7
             XMM8 XMM9 XMM10 XMM11 XMM12 XMM13 XMM14 XMM15
         } }
@@ -46,20 +46,21 @@ M: int-regs return-reg drop RAX ;
 M: float-regs return-reg drop XMM0 ;
 
 M: x86.64 %prologue ( n -- )
-    temp-reg-1 0 MOV rc-absolute-cell rel-this
+    temp-reg 0 MOV rc-absolute-cell rel-this
     dup PUSH
-    temp-reg-1 PUSH
+    temp-reg PUSH
     stack-reg swap 3 cells - SUB ;
 
-M: stack-params %load-param-reg
+M: stack-params copy-register*
     drop
-    [ R11 swap param@ MOV ] dip
-    param@ R11 MOV ;
+    {
+        { [ dup  integer? ] [ R11 swap next-stack@ MOV  R11 MOV ] }
+        { [ over integer? ] [ R11 swap MOV              param@ R11 MOV ] }
+    } cond ;
 
-M: stack-params %save-param-reg
-    drop
-    R11 swap next-stack@ MOV
-    param@ R11 MOV ;
+M: x86 %save-param-reg [ param@ ] 2dip copy-register ;
+
+M: x86 %load-param-reg [ swap param@ ] dip copy-register ;
 
 : with-return-regs ( quot -- )
     [
@@ -73,20 +74,22 @@ M: x86.64 %prepare-unbox ( -- )
     param-reg-1 R14 [] MOV
     R14 cell SUB ;
 
-M: x86.64 %unbox ( n reg-class func -- )
+M:: x86.64 %unbox ( n rep func -- )
     ! Call the unboxer
-    f %alien-invoke
-    ! Store the return value on the C stack
-    over [ [ return-reg ] keep %save-param-reg ] [ 2drop ] if ;
+    func f %alien-invoke
+    ! Store the return value on the C stack if this is an
+    ! alien-invoke, otherwise leave it the return register if
+    ! this is the end of alien-callback
+    n [ n rep reg-class-of return-reg rep %save-param-reg ] when ;
 
 M: x86.64 %unbox-long-long ( n func -- )
-    int-regs swap %unbox ;
+    [ int-rep ] dip %unbox ;
 
 : %unbox-struct-field ( c-type i -- )
     ! Alien must be in param-reg-1.
-    R11 swap cells [+] swap reg-class>> {
+    R11 swap cells [+] swap rep>> reg-class-of {
         { int-regs [ int-regs get pop swap MOV ] }
-        { double-float-regs [ float-regs get pop swap MOVSD ] }
+        { float-regs [ float-regs get pop swap MOVSD ] }
     } case ;
 
 M: x86.64 %unbox-small-struct ( c-type -- )
@@ -109,27 +112,31 @@ M: x86.64 %unbox-large-struct ( n c-type -- )
     ! Copy the struct to the C stack
     "to_value_struct" f %alien-invoke ;
 
-: load-return-value ( reg-class -- )
-    0 over param-reg swap return-reg
-    2dup eq? [ 2drop ] [ MOV ] if ;
-
-M: x86.64 %box ( n reg-class func -- )
-    rot [
-        rot [ 0 swap param-reg ] keep %load-param-reg
+: load-return-value ( rep -- )
+    [ [ 0 ] dip reg-class-of param-reg ]
+    [ reg-class-of return-reg ]
+    [ ]
+    tri copy-register ;
+
+M:: x86.64 %box ( n rep func -- )
+    n [
+        n
+        0 rep reg-class-of param-reg
+        rep %load-param-reg
     ] [
-        swap load-return-value
-    ] if*
-    f %alien-invoke ;
+        rep load-return-value
+    ] if
+    func f %alien-invoke ;
 
 M: x86.64 %box-long-long ( n func -- )
-    int-regs swap %box ;
+    [ int-rep ] dip %box ;
 
-: box-struct-field@ ( i -- operand ) 1+ cells param@ ;
+: box-struct-field@ ( i -- operand ) 1 + cells param@ ;
 
 : %box-struct-field ( c-type i -- )
-    box-struct-field@ swap reg-class>> {
+    box-struct-field@ swap c-type-rep reg-class-of {
         { int-regs [ int-regs get pop MOV ] }
-        { double-float-regs [ float-regs get pop MOVSD ] }
+        { float-regs [ float-regs get pop MOVSD ] }
     } case ;
 
 M: x86.64 %box-small-struct ( c-type -- )
index 7ab25b6d3f2f04ed944178e4f807a39fd7872461..e06c026d39702bfa562f9526f12fa21cdd2acb1e 100644 (file)
@@ -6,7 +6,8 @@ cpu.x86.assembler cpu.x86.assembler.operands cpu.x86 compiler.codegen
 compiler.cfg.registers ;
 IN: cpu.x86.64.unix
 
-M: int-regs param-regs drop { RDI RSI RDX RCX R8 R9 } ;
+M: int-regs param-regs
+    drop { RDI RSI RDX RCX R8 R9 } ;
 
 M: float-regs param-regs
     drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ;
@@ -15,7 +16,7 @@ M: x86.64 reserved-area-size 0 ;
 
 ! The ABI for passing structs by value is pretty messed up
 << "void*" c-type clone "__stack_value" define-primitive-type
-stack-params "__stack_value" c-type (>>reg-class) >>
+stack-params "__stack_value" c-type (>>rep) >>
 
 : struct-types&offset ( struct-type -- pairs )
     fields>> [
@@ -29,7 +30,7 @@ stack-params "__stack_value" c-type (>>reg-class) >>
 
 : flatten-small-struct ( c-type -- seq )
     struct-types&offset split-struct [
-        [ c-type c-type-reg-class ] map
+        [ c-type c-type-rep reg-class-of ] map
         int-regs swap member? "void*" "double" ? c-type
     ] map ;
 
@@ -53,6 +54,4 @@ M: x86.64 dummy-int-params? f ;
 
 M: x86.64 dummy-fp-params? f ;
 
-M: x86.64 temp-reg-1 R8 ;
-
-M: x86.64 temp-reg-2 R9 ;
+M: x86.64 temp-reg R8 ;
index 44e85686589990b76c04aa6b08d4efb3648ed4a0..d9f83612e60394729cc9bda88fc8701fb21de26d 100644 (file)
@@ -22,9 +22,7 @@ M: x86.64 dummy-int-params? t ;
 
 M: x86.64 dummy-fp-params? t ;
 
-M: x86.64 temp-reg-1 RAX ;
-
-M: x86.64 temp-reg-2 RCX ;
+M: x86.64 temp-reg RAX ;
 
 <<
 "longlong" "ptrdiff_t" typedef
index 2b99513fc16f525d043c4e1168a24e414e1cd1c9..b2de0cc6e4f93ac32df39cd0af224244cbe53cc0 100644 (file)
@@ -606,6 +606,8 @@ ALIAS: PINSRQ PINSRD
 : PSHUFLW    ( dest src imm -- ) HEX: 70 HEX: f2 3-operand-rm-sse ;
 : PSHUFHW    ( dest src imm -- ) HEX: 70 HEX: f3 3-operand-rm-sse ;
 
+<PRIVATE
+
 : (PSRLW-imm) ( dest imm -- ) BIN: 010 HEX: 71 HEX: 66 2-operand-sse-shift ;
 : (PSRAW-imm) ( dest imm -- ) BIN: 100 HEX: 71 HEX: 66 2-operand-sse-shift ;
 : (PSLLW-imm) ( dest imm -- ) BIN: 110 HEX: 71 HEX: 66 2-operand-sse-shift ;
@@ -624,6 +626,8 @@ ALIAS: PINSRQ PINSRD
 : (PSLLD-reg) ( dest src -- ) HEX: f2 HEX: 66 2-operand-rm-sse ;
 : (PSLLQ-reg) ( dest src -- ) HEX: f3 HEX: 66 2-operand-rm-sse ;
 
+PRIVATE>
+
 : PSRLW ( dest src -- ) dup integer? [ (PSRLW-imm) ] [ (PSRLW-reg) ] if ;
 : PSRAW ( dest src -- ) dup integer? [ (PSRAW-imm) ] [ (PSRAW-reg) ] if ;
 : PSLLW ( dest src -- ) dup integer? [ (PSLLW-imm) ] [ (PSLLW-reg) ] if ;
index d3cb66ff125153a2746860ea2054c022f9707302..df49ae0a15f8c085cce8881b638158fb0db8c009 100644 (file)
@@ -26,15 +26,11 @@ REGISTERS: 128
 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7
 XMM8 XMM9 XMM10 XMM11 XMM12 XMM13 XMM14 XMM15 ;
 
-<PRIVATE
-
-GENERIC: extended? ( op -- ? )
-
-M: object extended? drop f ;
-
 PREDICATE: register < word
     "register" word-prop ;
 
+<PRIVATE
+
 PREDICATE: register-8 < register
     "register-size" word-prop 8 = ;
 
@@ -50,6 +46,10 @@ PREDICATE: register-64 < register
 PREDICATE: register-128 < register
     "register-size" word-prop 128 = ;
 
+GENERIC: extended? ( op -- ? )
+
+M: object extended? drop f ;
+
 M: register extended? "register" word-prop 7 > ;
 
 ! Addressing modes
index 6363f17e48053eebdd0973b00735a9eb0f8cacc7..0dafc3d9c4d1cf5f84d08e8832673917a6d0b63c 100644 (file)
@@ -226,7 +226,7 @@ big-endian off
     temp2 temp1 MOV
     bootstrap-cell 8 = [ temp2 1 SHL ] when
     ! key &= cache.length - 1
-    temp2 mega-cache-size get 1- bootstrap-cell * AND
+    temp2 mega-cache-size get 1 - bootstrap-cell * AND
     ! cache += array-start-offset
     temp0 array-start-offset ADD
     ! cache += key
@@ -496,7 +496,7 @@ big-endian off
     ! make a copy
     mod-arg div-arg MOV
     ! sign-extend
-    mod-arg bootstrap-cell-bits 1- SAR
+    mod-arg bootstrap-cell-bits 1 - SAR
     ! divide
     temp3 IDIV ;
 
index 69847cacfa6166b1325ed80a3c6b884790dac225..680e6559959dff4a0bf5867fecdcddb5e9d07925 100644 (file)
@@ -1,7 +1,7 @@
-IN: cpu.x86.features.tests
 USING: cpu.x86.features tools.test kernel sequences math system ;
+IN: cpu.x86.features.tests
 
 cpu x86? [
     [ t ] [ sse2? { t f } member? ] unit-test
     [ t ] [ [ 10000 [ ] times ] count-instructions integer? ] unit-test
-] when
\ No newline at end of file
+] when
index 34b1b63581e2f5a979244010d0ec279178c71245..a6c958083cbc95a71dc098561264a13c972f23f9 100644 (file)
@@ -30,9 +30,7 @@ HOOK: reserved-area-size cpu ( -- n )
 
 : param@ ( n -- op ) reserved-area-size + stack@ ;
 
-: spill-integer@ ( n -- op ) spill-integer-offset param@ ;
-
-: spill-float@ ( n -- op ) spill-float-offset param@ ;
+: spill@ ( n -- op ) spill-offset param@ ;
 
 : gc-root@ ( n -- op ) gc-root-offset param@ ;
 
@@ -48,9 +46,11 @@ HOOK: reserved-area-size cpu ( -- n )
 M: x86 stack-frame-size ( stack-frame -- i )
     (stack-frame-size) 3 cells reserved-area-size + + align-stack ;
 
-HOOK: temp-reg-1 cpu ( -- reg )
-HOOK: temp-reg-2 cpu ( -- reg )
+! Must be a volatile register not used for parameter passing, for safe
+! use in calls in and out of C
+HOOK: temp-reg cpu ( -- reg )
 
+! Fastcall calling convention
 HOOK: param-reg-1 cpu ( -- reg )
 HOOK: param-reg-2 cpu ( -- reg )
 
@@ -126,9 +126,6 @@ M: x86 %sar-imm nip SAR ;
 M: x86 %not     drop NOT ;
 M: x86 %log2    BSR ;
 
-: ?MOV ( dst src -- )
-    2dup = [ 2drop ] [ MOV ] if ; inline
-
 :: overflow-template ( label dst src1 src2 insn -- )
     src1 src2 insn call
     label JO ; inline
@@ -165,7 +162,7 @@ M:: x86 %integer>bignum ( dst src temp -- )
         dst 3 bignum@ src MOV
         ! Compute sign
         temp src MOV
-        temp cell-bits 1- SAR
+        temp cell-bits 1 - SAR
         temp 1 AND
         ! Store sign
         dst 2 bignum@ temp MOV
@@ -210,10 +207,17 @@ M: x86 %div-float nip DIVSD ;
 M: x86 %integer>float CVTSI2SD ;
 M: x86 %float>integer CVTTSD2SI ;
 
-M: x86 %copy ( dst src -- ) ?MOV ;
+GENERIC: copy-register* ( dst src rep -- )
 
-M: x86 %copy-float ( dst src -- )
-    2dup = [ 2drop ] [ MOVSD ] if ;
+M: int-rep copy-register* drop MOV ;
+M: tagged-rep copy-register* drop MOV ;
+M: single-float-rep copy-register* drop MOVSS ;
+M: double-float-rep copy-register* drop MOVSD ;
+
+: copy-register ( dst src rep -- )
+    2over eq? [ 3drop ] [ copy-register* ] if ;
+
+M: x86 %copy ( dst src rep -- ) copy-register ;
 
 M: x86 %unbox-float ( dst src -- )
     float-offset [+] MOVSD ;
@@ -301,6 +305,9 @@ M: x86.64 has-small-reg? 2drop t ;
         [ quot call ] with-save/restore
     ] if ; inline
 
+: ?MOV ( dst src -- )
+    2dup = [ 2drop ] [ MOV ] if ; inline
+
 M:: x86 %string-nth ( dst src index temp -- )
     ! We request a small-reg of size 8 since those of size 16 are
     ! a superset.
@@ -512,39 +519,21 @@ M: x86 %compare-float-branch ( label cc src1 src2 -- )
         { cc/= [ JNE ] }
     } case ;
 
-M: x86 %spill-integer ( src n -- ) spill-integer@ swap MOV ;
-M: x86 %reload-integer ( dst n -- ) spill-integer@ MOV ;
-
-M: x86 %spill-float ( src n -- ) spill-float@ swap MOVSD ;
-M: x86 %reload-float ( dst n -- ) spill-float@ MOVSD ;
+M: x86 %spill ( src n rep -- ) [ spill@ swap ] dip copy-register ;
+M: x86 %reload ( dst n rep -- ) [ spill@ ] dip copy-register ;
 
 M: x86 %loop-entry 16 code-alignment [ NOP ] times ;
 
-M: int-regs %save-param-reg drop [ param@ ] dip MOV ;
-M: int-regs %load-param-reg drop swap param@ MOV ;
-
-GENERIC: MOVSS/D ( dst src reg-class -- )
-
-M: single-float-regs MOVSS/D drop MOVSS ;
-M: double-float-regs MOVSS/D drop MOVSD ;
-
-M: float-regs %save-param-reg [ param@ ] 2dip MOVSS/D ;
-M: float-regs %load-param-reg [ swap param@ ] dip MOVSS/D ;
-
-GENERIC: push-return-reg ( reg-class -- )
-GENERIC: load-return-reg ( n reg-class -- )
-GENERIC: store-return-reg ( n reg-class -- )
-
 M: x86 %prepare-alien-invoke
     #! Save Factor stack pointers in case the C code calls a
     #! callback which does a GC, which must reliably trace
     #! all roots.
-    temp-reg-1 "stack_chain" f %alien-global
-    temp-reg-1 temp-reg-1 [] MOV
-    temp-reg-1 [] stack-reg MOV
-    temp-reg-1 [] cell SUB
-    temp-reg-1 2 cells [+] ds-reg MOV
-    temp-reg-1 3 cells [+] rs-reg MOV ;
+    temp-reg "stack_chain" f %alien-global
+    temp-reg temp-reg [] MOV
+    temp-reg [] stack-reg MOV
+    temp-reg [] cell SUB
+    temp-reg 2 cells [+] ds-reg MOV
+    temp-reg 3 cells [+] rs-reg MOV ;
 
 M: x86 value-struct? drop t ;
 
index c4aa47d383b3a1281ff091887449bb6e6ad39be6..e9aa01feb4bb9568486c4a9b37268c247664311d 100755 (executable)
@@ -75,7 +75,7 @@ M: db-connection <update-tuple-statement> ( class -- statement )
 M: random-id-generator eval-generator ( singleton -- obj )
     drop
     system-random-generator get [
-        63 [ random-bits ] keep 1- set-bit
+        63 [ random-bits ] keep 1 - set-bit
     ] with-random ;
 
 : interval-comparison ( ? str -- str )
index 6bf8dd3075ffe24b1146605be0d17e36645b9fa8..7f109d80e03a9736286ede656991e80a9dbc5909 100644 (file)
@@ -469,7 +469,7 @@ TUPLE: bignum-test id m n o ;
     } define-persistent
     [ bignum-test drop-table ] ignore-errors
     [ ] [ bignum-test ensure-table ] unit-test
-    [ ] [ 63 2^ 1- dup dup <bignum-test> insert-tuple ] unit-test ;
+    [ ] [ 63 2^ 1 - dup dup <bignum-test> insert-tuple ] unit-test ;
 
     ! sqlite only
     ! [ T{ bignum-test f 1
index 08f84d9335b566ac3fc3c28897ed08cfc3876372..6800c83a9ca4a0df0cfa87f6c3e351fcc46083f4 100644 (file)
@@ -1,7 +1,7 @@
-IN: debugger.tests\r
 USING: debugger kernel continuations tools.test ;\r
+IN: debugger.tests\r
 \r
 [ ] [ [ drop ] [ error. ] recover ] unit-test\r
 \r
 [ f ] [ { } vm-error? ] unit-test\r
-[ f ] [ { "A" "B" } vm-error? ] unit-test
\ No newline at end of file
+[ f ] [ { "A" "B" } vm-error? ] unit-test\r
index 6c0985ce06d5a8d816faf78b23c4699b7d6efbc7..ce9496291c6ff94a4bfeb9b188087b8a48ec1006 100644 (file)
@@ -36,7 +36,7 @@ M: string error. print ;
     error-continuation get name>> assoc-stack ;
 
 : :res ( n -- * )
-    1- restarts get-global nth f restarts set-global restart ;
+    1 - restarts get-global nth f restarts set-global restart ;
 
 : :1 ( -- * ) 1 :res ;
 : :2 ( -- * ) 2 :res ;
@@ -44,7 +44,7 @@ M: string error. print ;
 
 : restart. ( restart n -- )
     [
-        1+ dup 3 <= [ ":" % # "    " % ] [ # " :res  " % ] if
+        1 + dup 3 <= [ ":" % # "    " % ] [ # " :res  " % ] if
         name>> %
     ] "" make print ;
 
@@ -92,7 +92,7 @@ HOOK: signal-error. os ( obj -- )
 
 : array-size-error. ( obj -- )
     "Invalid array size: " write dup third .
-    "Maximum: " write fourth 1- . ;
+    "Maximum: " write fourth 1 - . ;
 
 : c-string-error. ( obj -- )
     "Cannot convert to C string: " write third . ;
index 212908b2fdb0f315fd8b64ba964986d86e1eefe8..1eb916487cce6b223bcc21465a958ee441d0f750 100644 (file)
@@ -13,7 +13,7 @@ CONSTANT: signal-names
     "SIGUSR1" "SIGUSR2"
 }
 
-: signal-name ( n -- str/f ) 1- signal-names ?nth ;
+: signal-name ( n -- str/f ) 1 - signal-names ?nth ;
 
 : signal-name. ( n -- )
     signal-name [ " (" ")" surround write ] when* ;
diff --git a/basis/definitions/icons/icons-tests.factor b/basis/definitions/icons/icons-tests.factor
deleted file mode 100644 (file)
index 47e106f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test definitions.icons ;
-IN: definitions.icons.tests
index 9f9aca87029a07b2fa7cb994d3e86c4ee7d04213..d9581152e1014c3f2998b396667af2f5141daca4 100644 (file)
@@ -55,8 +55,8 @@ PROTOCOL: beta three ;
 
 TUPLE: hey value ;
 C: <hey> hey
-CONSULT: alpha hey value>> 1+ ;
-CONSULT: beta hey value>> 1- ;
+CONSULT: alpha hey value>> 1 + ;
+CONSULT: beta hey value>> 1 - ;
 
 [ 2 ] [ 1 <hey> one ] unit-test
 [ 2 ] [ 1 <hey> two ] unit-test
index 74746f1a3adffd950e20a4079cc5a35a0c6777c6..cb9233343e7b37daf781a3992bd227896d461665 100644 (file)
@@ -1,5 +1,5 @@
-IN: disjoint-sets.testes
 USING: tools.test disjoint-sets namespaces slots.private ;
+IN: disjoint-sets.testes
 
 SYMBOL: +blah+
 -405534154 +blah+ 1 set-slot
index 80ab2f58bf4a0ae467bc18db6d8e940d500acd0e..05df13f07347d20ef427e2a876d8463f0502a83a 100644 (file)
@@ -30,7 +30,7 @@ TUPLE: disjoint-set
     ranks>> at ; inline
 
 : inc-rank ( a disjoint-set -- )
-    ranks>> [ 1+ ] change-at ; inline
+    ranks>> [ 1 + ] change-at ; inline
 
 : representative? ( a disjoint-set -- ? )
     dupd parent = ; inline
index 9f7f25c56ea23d7a912ece51dac2b6e85124545e..41d93c889ec4acf9c5f32b56f85f4a7f53337014 100644 (file)
@@ -1,6 +1,6 @@
-IN: documents.tests
 USING: documents documents.private accessors sequences
 namespaces tools.test make arrays kernel fry ;
+IN: documents.tests
 
 ! Tests
 
index cc2466053b8718f80b1c382990f863c796186435..b05c86c36556a7bdca5bff8e6d5aef42a5649099 100644 (file)
@@ -45,7 +45,7 @@ TUPLE: document < model locs undos redos inside-undo? ;
     [ drop ] [ doc-line length ] 2bi 2array ;
 
 : doc-lines ( from to document -- slice )
-    [ 1+ ] [ value>> ] bi* <slice> ;
+    [ 1 + ] [ value>> ] bi* <slice> ;
 
 : start-on-line ( from line# document -- n1 )
     drop over first =
@@ -67,7 +67,7 @@ TUPLE: document < model locs undos redos inside-undo? ;
     [ start-on-line ] [ end-on-line ] bi-curry bi-curry bi* ;
 
 : last-line# ( document -- line )
-    value>> length 1- ;
+    value>> length 1 - ;
 
 CONSTANT: doc-start { 0 0 }
 
@@ -84,7 +84,7 @@ CONSTANT: doc-start { 0 0 }
         over length 1 = [
             nip first2
         ] [
-            first swap length 1- + 0
+            first swap length 1 - + 0
         ] if
     ] dip last length + 2array ;
 
@@ -92,7 +92,7 @@ CONSTANT: doc-start { 0 0 }
     0 swap [ append ] change-nth ;
 
 : append-last ( str seq -- )
-    [ length 1- ] keep [ prepend ] change-nth ;
+    [ length 1 - ] keep [ prepend ] change-nth ;
 
 : loc-col/str ( loc document -- str col )
     [ first2 swap ] dip nth swap ;
@@ -103,7 +103,7 @@ CONSTANT: doc-start { 0 0 }
 
 : (set-doc-range) ( doc-lines from to lines -- changed-lines )
     [ prepare-insert ] 3keep
-    [ [ first ] bi@ 1+ ] dip
+    [ [ first ] bi@ 1 + ] dip
     replace-slice ;
 
 : entire-doc ( document -- start end document )
index 0776f8f1583dabea37e170842920d022786020d8..7ba3cb8a6eddf866f6a61e69d461c911f616958a 100644 (file)
@@ -23,14 +23,14 @@ SINGLETON: char-elt
 : prev ( loc document quot: ( loc document -- loc ) -- loc )
     {
         { [ pick { 0 0 } = ] [ 2drop ] }
-        { [ pick second zero? ] [ drop [ first 1- ] dip line-end ] }
+        { [ pick second zero? ] [ drop [ first 1 - ] dip line-end ] }
         [ call ]
     } cond ; inline
 
 : next ( loc document quot: ( loc document -- loc ) -- loc )
     {
         { [ 2over doc-end = ] [ 2drop ] }
-        { [ 2over line-end? ] [ 2drop first 1+ 0 2array ] }
+        { [ 2over line-end? ] [ 2drop first 1 + 0 2array ] }
         [ call ]
     } cond ; inline
 
@@ -73,7 +73,7 @@ SINGLETON: one-word-elt
 
 M: one-word-elt prev-elt
     drop
-    [ [ 1- ] dip f prev-word ] modify-col ;
+    [ [ 1 - ] dip f prev-word ] modify-col ;
 
 M: one-word-elt next-elt
     drop
@@ -90,7 +90,7 @@ SINGLETON: word-elt
 
 M: word-elt prev-elt
     drop
-    [ [ [ 1- ] dip blank-at? prev-word ] modify-col ]
+    [ [ [ 1 - ] dip blank-at? prev-word ] modify-col ]
     prev ;
 
 M: word-elt next-elt
index 30611ca699297f0b3b7e736653fb3cd10506adad..43fd679e3ada108c2ef0c5f7f68396f232f71fba 100644 (file)
@@ -5,8 +5,10 @@ IN: editors
 ARTICLE: "editor" "Editor integration"
 "Factor development is best done with one of the supported editors; this allows you to quickly jump to definitions from the Factor environment."
 { $subsection edit }
-"Depending on the editor you are using, you must load one of the child vocabularies of the " { $vocab-link "editors" } " vocabulary, for example " { $vocab-link "editors.emacs" } ", for example:"
+"Depending on the editor you are using, you must load one of the child vocabularies of the " { $vocab-link "editors" } " vocabulary, for example " { $vocab-link "editors.emacs" } ":"
 { $code "USE: editors.emacs" }
+"If you intend to always use the same editor, it helps to have it load during stage 2 bootstrap. Place the code to load and possibly configure it in the " { $link "factor-boot-rc" } "."
+$nl
 "Editor integration vocabularies store a quotation in a global variable when loaded:"
 { $subsection edit-hook }
 "If a syntax error was thrown while loading a source file, you can jump to the location of the error in your editor:"
index da6a589031ed0ae9aa8d1aff2ef0f361f500f990..4a6dd9b5bef93fa6e0850491a607b32fdc2f0f7e 100644 (file)
@@ -47,43 +47,12 @@ M: cannot-find-source error.
 : edit-vocab ( name -- )
     >vocab-link edit ;
 
-GENERIC: error-file ( error -- file )
-
-GENERIC: error-line ( error -- line )
-
-M: lexer-error error-file
-    error>> error-file ;
-
-M: lexer-error error-line
-    [ error>> error-line ] [ line>> ] bi or ;
-
-M: source-file-error error-file
-    [ error>> error-file ] [ file>> ] bi or ;
-
-M: source-file-error error-line
-    error>> error-line ;
-
-M: condition error-file
-    error>> error-file ;
-
-M: condition error-line
-    error>> error-line ;
-
-M: object error-file
-    drop f ;
-
-M: object error-line
-    drop f ;
-
-: (:edit) ( error -- )
+: edit-error ( error -- )
     [ error-file ] [ error-line ] bi
     2dup and [ edit-location ] [ 2drop ] if ;
 
 : :edit ( -- )
-    error get (:edit) ;
-
-: edit-error ( error -- )
-    [ file>> ] [ line#>> ] bi 2dup and [ edit-location ] [ 2drop ] if ;
+    error get edit-error ;
 
 : edit-each ( seq -- )
     [
diff --git a/basis/editors/gvim/gvim-docs.factor b/basis/editors/gvim/gvim-docs.factor
new file mode 100644 (file)
index 0000000..fb8682b
--- /dev/null
@@ -0,0 +1,3 @@
+USING: help.syntax ;
+IN: editors.gvim
+ABOUT: { "vim" "vim" }
index c178207e49dc85b4a3c544a9af9d95938dfc60d1..6dcf724e8ee9840065f74d9319d357bff7e220c7 100644 (file)
@@ -1,6 +1,5 @@
 USING: definitions io.launcher kernel math math.parser parser
 namespaces prettyprint editors make ;
-
 IN: editors.macvim
 
 : macvim ( file line -- )
index 65395bd590d5eb9c60a2b3434e441d6979bf4971..561beee4e3887f8724e221a3fbcd232a5417e191 100644 (file)
@@ -6,4 +6,4 @@ IN: editors.textmate
     [ "mate" , "-a" , "-l" , number>string , , ] { } make
     run-detached drop ;
 
-[ textmate ] edit-hook set-global
+[ textmate ] edit-hook set-global
\ No newline at end of file
index 1ec3a37061e0bf3de47eefc72dd098f6b2717142..522ac826de1fbbcd5e42f575a5cd603385b2a18f 100644 (file)
@@ -1,17 +1,18 @@
-USING: definitions editors help help.markup help.syntax io io.files
-    io.pathnames words ;
+USING: definitions editors help help.markup help.syntax
+io io.files io.pathnames words ;
 IN: editors.vim
 
+ABOUT: { "vim" "vim" }
+
 ARTICLE: { "vim" "vim" } "Vim support"
-"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim } ". The " { $link vim-path } " variable contains the name of the vim executable.  The default " { $link vim-path } " is " { $snippet "\"gvim\"" } "."
+"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim } "."
 $nl
-"If you intend to use this module regularly, it helps to have it load during stage 2 bootstrap. On Windows, place the following example " { $snippet ".factor-boot-rc" } " in the directory returned by " { $link home } ":"
-{ $code
-"USING: modules namespaces ;"
-"REQUIRES: libs/vim ;"
-"USE: vim"
-"\"c:\\\\program files\\\\vim\\\\vim70\\\\gvim\" vim-path set-global"
+"The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"vim\"" } ". Which is not very useful, as it starts vim in the same terminal where you started factor."
+{ $list
+    { "If you want to use gvim instead or are on a Windows platform use " { $vocab-link "editors.gvim" } "." }
+    { "If you want to start vim in an extra terminal, use something like this:" { $code "{ \"urxvt\" \"-e\" \"vim\" } vim-path set-global" } "Replace " { $snippet "urxvt" } " by your terminal of choice." }
 }
-"On Unix, you may omit the last line if " { $snippet "\"vim\"" } " is in your " { $snippet "$PATH" } "." 
 $nl
-"You may also wish to install Vim support files to enable syntax hilighting and other features. These are in the " { $link resource-path } " in " { $snippet "misc/vim" } "." ; 
+"You may also wish to install Vim support files to enable syntax hilighting and other features. These are in the " { $link resource-path } " in " { $snippet "misc/vim" } "."
+{ $see-also "editor" }
+;
index 88c8b8051e859b23160488b1339c5ba782411c78..a62ed9e0a5af6dc176085fcec20d50912f24c4fa 100644 (file)
@@ -1,6 +1,6 @@
 USING: definitions io io.launcher kernel math math.parser
 namespaces parser prettyprint sequences editors accessors
-make ;
+make strings ;
 IN: editors.vim
 
 SYMBOL: vim-path
@@ -11,7 +11,7 @@ SINGLETON: vim
 
 M: vim vim-command
     [
-        vim-path get ,
+        vim-path get dup string? [ , ] [ % ] if
         [ , ] [ number>string "+" prepend , ] bi*
     ] { } make ;
 
index d27e66119346609f0fc9ef1a4d83488c2ed52967..09c7533b285e2def0e58f91208be90a210a42275 100644 (file)
@@ -1,5 +1,5 @@
-IN: eval.tests
 USING: eval tools.test ;
+IN: eval.tests
 
 [ 4 ] [ "USE: math 2 2 +" eval( -- result ) ] unit-test
 [ "USE: math 2 2 +" eval( -- ) ] must-fail
index 4acd1eeab81dcc3d2cc373b9d20b7189bbb405a0..2a1ac85de06312fffc8e526f6433ff24fc95d9fe 100644 (file)
@@ -50,7 +50,7 @@ DEFER: (parse-paragraph)
     parse-paragraph paragraph boa ;
 
 : cut-half-slice ( string i -- before after-slice )
-    [ head ] [ 1+ short tail-slice ] 2bi ;
+    [ head ] [ 1 + short tail-slice ] 2bi ;
 
 : find-cut ( string quot -- before after delimiter )
     dupd find
index c56372f023d19f337a388bd84217541c9465f91f..5710ceb985d582607ebd2f0c56cb671b584686ba 100644 (file)
@@ -1,8 +1,6 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
-
 USING: calendar kernel formatting tools.test ;
-
 IN: formatting.tests
 
 [ "%s" printf ] must-infer 
index f8b9ba501ba68e5c953bb0e5f7aa2f855269f2bb..1b1bc8c2afb5cce2ccab3a9ba5e44c1eaced9056 100644 (file)
@@ -1,11 +1,9 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
-
 USING: accessors arrays assocs calendar combinators fry kernel
 generalizations io io.streams.string macros math math.functions
 math.parser peg.ebnf quotations sequences splitting strings
 unicode.categories unicode.case vectors combinators.smart ;
-
 IN: formatting
 
 <PRIVATE
@@ -16,10 +14,10 @@ IN: formatting
 : fix-sign ( string -- string )
     dup CHAR: 0 swap index 0 = 
       [ dup 0 swap [ [ CHAR: 0 = not ] keep digit? and ] find-from
-         [ dup 1- rot dup [ nth ] dip swap
+         [ dup 1 - rot dup [ nth ] dip swap
             {
-               { CHAR: - [ [ 1- ] dip remove-nth "-" prepend ] }
-               { CHAR: + [ [ 1- ] dip remove-nth "+" prepend ] }
+               { CHAR: - [ [ 1 - ] dip remove-nth "-" prepend ] }
+               { CHAR: + [ [ 1 - ] dip remove-nth "+" prepend ] }
                [ drop swap drop ] 
             } case 
          ] [ drop ] if
@@ -32,15 +30,15 @@ IN: formatting
     [ "." split1 ] dip [ CHAR: 0 pad-tail ] [ head-slice ] bi "." glue ;
 
 : max-digits ( n digits -- n' )
-    10 swap ^ [ * round ] keep / ; inline
+    10^ [ * round ] keep / ; inline
 
 : >exp ( x -- exp base )
     [ 
         abs 0 swap
         [ dup [ 10.0 >= ] [ 1.0 < ] bi or ]
         [ dup 10.0 >=
-          [ 10.0 / [ 1+ ] dip ]
-          [ 10.0 * [ 1- ] dip ] if
+          [ 10.0 / [ 1 + ] dip ]
+          [ 10.0 * [ 1 - ] dip ] if
         ] while 
      ] keep 0 < [ neg ] when ;
 
index 88ecae66addbb2dc29f8c7bed661c822dea6f44d..549db25e09e96e76639dbfe6fa44e411c98968b7 100644 (file)
@@ -1,6 +1,6 @@
-IN: fry.tests
 USING: fry tools.test math prettyprint kernel io arrays
 sequences eval accessors ;
+IN: fry.tests
 
 [ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
 
index d50fd9442bf72dd62baf65525f6a30e7e803b952..fd029cc329f8c61551ca0149e7ed1b1787398c99 100644 (file)
@@ -26,7 +26,7 @@ M: >r/r>-in-fry-error summary
 
 : check-fry ( quot -- quot )
     dup { load-local load-locals get-local drop-locals } intersect
-    empty? [ >r/r>-in-fry-error ] unless ;
+    [ >r/r>-in-fry-error ] unless-empty ;
 
 PREDICATE: fry-specifier < word { _ @ } memq? ;
 
@@ -42,7 +42,7 @@ GENERIC: deep-fry ( obj -- )
     check-fry
     [ [ deep-fry ] each ] [ ] make
     [ dup \ @ = [ drop [ _ call ] ] [ 1array ] if ] map concat
-    { _ } split [ spread>quot ] [ length 1- ] bi ;
+    { _ } split [ spread>quot ] [ length 1 - ] bi ;
 
 PRIVATE>
 
index 03bd21e58c379e60c5e3c5510cc0d0f59633c821..a21313312bbb173e8bd38731e4fa0cd38bd91684 100644 (file)
@@ -1,6 +1,6 @@
-IN: functors.tests
 USING: functors tools.test math words kernel multiline parser
 io.streams.string generic ;
+IN: functors.tests
 
 <<
 
index 51295159807cd5441e72b737ed06612fea5e106a..5f519aeecefe41ad70e489bafe35c84d9f963859 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays classes.mixin classes.parser classes.singleton
-classes.tuple classes.tuple.parser combinators effects effects.parser
-fry generic generic.parser generic.standard interpolate
-io.streams.string kernel lexer locals.parser locals.rewrite.closures
-locals.types make namespaces parser quotations sequences vocabs.parser
-words words.symbol ;
+USING: accessors arrays classes.mixin classes.parser
+classes.singleton classes.tuple classes.tuple.parser
+combinators effects.parser fry generic generic.parser
+generic.standard interpolate io.streams.string kernel lexer
+locals.parser locals.types macros make namespaces parser
+quotations sequences vocabs.parser words words.symbol ;
 IN: functors
 
 ! This is a hack
@@ -117,6 +117,11 @@ SYNTAX: `GENERIC:
     complete-effect parsed
     \ define-simple-generic* parsed ;
 
+SYNTAX: `MACRO:
+    scan-param parsed
+    parse-declared*
+    \ define-macro parsed ;
+
 SYNTAX: `inline [ word make-inline ] over push-all ;
 
 SYNTAX: `call-next-method T{ fake-call-next-method } parsed ;
@@ -152,6 +157,7 @@ DEFER: ;FUNCTOR delimiter
         { "SYNTAX:" POSTPONE: `SYNTAX: }
         { "SYMBOL:" POSTPONE: `SYMBOL: }
         { "inline" POSTPONE: `inline }
+        { "MACRO:" POSTPONE: `MACRO: }
         { "call-next-method" POSTPONE: `call-next-method }
     } ;
 
index 83ed00ca1b8d34256b0197b33d2c6adbf1b619de..6468b8deb721e90962b30a569229249e36d5a49f 100644 (file)
@@ -33,18 +33,6 @@ HELP: new-action
 HELP: page-action
 { $class-description "The class of Chloe page actions. These are actions whose " { $slot "display" } " slot is pre-set to serve the Chloe template stored in the " { $slot "page" } " slot." } ;
 
-HELP: param
-{ $values
-     { "name" string }
-     { "value" string }
-}
-{ $description "Outputs the value of a query parameter (if the current request is a GET or HEAD request) or a POST parameter (if the current request is a POST request)." }
-{ $notes "Instead of using this word, it is better to use " { $link validate-params } " and then access parameters via " { $link "html.forms.values" } " words." } ;
-
-HELP: params
-{ $var-description "A variable holding an assoc of query parameters (if the current request is a GET or HEAD request) or POST parameters (if the current request is a POST request)." }
-{ $notes "Instead of using this word, it is better to use " { $link validate-params } " and then access parameters via " { $link "html.forms.values" } " words." } ;
-
 HELP: validate-integer-id
 { $description "A utility word which validates an integer parameter named " { $snippet "id" } "." }
 { $examples
@@ -103,7 +91,7 @@ $nl
 ARTICLE: "furnace.actions.config" "Furnace action configuration"
 "Actions have the following slots:"
 { $table
-    { { $slot "rest" } { "A parameter name to map the rest of the URL, after the action name, to. If this is not set, then navigating to a URL where the action is not the last path component will return to the client with an error." } }
+  { { $slot "rest" } { "A parameter name to map the rest of the URL, after the action name, to. If this is not set, then navigating to a URL where the action is not the last path component will return to the client with an error. A more general facility can be found in the " { $vocab-link "http.server.rewrite" } " vocabulary." } }
     { { $slot "init" } { "A quotation called at the beginning of a GET or HEAD request. Typically this quotation configures " { $link "html.forms" } " and parses query parameters." } }
     { { $slot "authorize" } { "A quotation called at the beginning of a GET, HEAD or POST request. In GET requests, it is called after the " { $slot "init" } " quotation; in POST requests, it is called after the " { $slot "validate" } " quotation. By convention, this quotation performs custom authorization checks which depend on query parameters or POST parameters." } }
     { { $slot "display" } { "A quotation called after the " { $slot "init" } " quotation in a GET request. This quotation must return an HTTP " { $link response } "." } }
@@ -144,10 +132,8 @@ ARTICLE: "furnace.actions.lifecycle" "Furnace action lifecycle"
 "Any one of the above steps can perform validation; if " { $link validation-failed } " is called during a POST request, the client is sent back to the page containing the form submission, with current form values and validation errors passed in a " { $link "furnace.conversations" } "." ;
 
 ARTICLE: "furnace.actions.impl" "Furnace actions implementation"
-"The following words are used by the action implementation and there is rarely any reason to call them directly:"
-{ $subsection new-action }
-{ $subsection param }
-{ $subsection params } ;
+"The following parametrized constructor should be called from constructors for subclasses of " { $link action } ":"
+{ $subsection new-action } ;
 
 ARTICLE: "furnace.actions" "Furnace actions"
 "The " { $vocab-link "furnace.actions" } " vocabulary implements a type of responder, called an " { $emphasis "action" } ", which handles the form validation lifecycle."
index 06e743e967a78926a891c90e8fb2ea0978fe195c..aca03b9029258b7a4109a408e4c8c2fa15aca5c1 100644 (file)
@@ -17,8 +17,6 @@ html.templates.chloe.syntax
 html.templates.chloe.compiler ;\r
 IN: furnace.actions\r
 \r
-SYMBOL: params\r
-\r
 SYMBOL: rest\r
 \r
 TUPLE: action rest init authorize display validate submit ;\r
@@ -60,9 +58,6 @@ TUPLE: action rest init authorize display validate submit ;
         ] [ drop <400> ] if\r
     ] with-exit-continuation ;\r
 \r
-: param ( name -- value )\r
-    params get at ;\r
-\r
 CONSTANT: revalidate-url-key "__u"\r
 \r
 : revalidate-url ( -- url/f )\r
@@ -88,13 +83,12 @@ CONSTANT: revalidate-url-key "__u"
         ] [ drop <400> ] if\r
     ] with-exit-continuation ;\r
 \r
-: handle-rest ( path action -- assoc )\r
-    rest>> dup [ [ "/" join ] dip associate ] [ 2drop f ] if ;\r
+: handle-rest ( path action -- )\r
+    rest>> dup [ [ "/" join ] dip set-param ] [ 2drop ] if ;\r
 \r
 : init-action ( path action -- )\r
     begin-form\r
-    handle-rest\r
-    request get request-params assoc-union params set ;\r
+    handle-rest ;\r
 \r
 M: action call-responder* ( path action -- response )\r
     [ init-action ] keep\r
diff --git a/basis/furnace/auth/auth-tests.factor b/basis/furnace/auth/auth-tests.factor
deleted file mode 100644 (file)
index 54c32e7..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-USING: furnace.auth tools.test ;
-IN: furnace.auth.tests
-
diff --git a/basis/furnace/auth/features/edit-profile/edit-profile-tests.factor b/basis/furnace/auth/features/edit-profile/edit-profile-tests.factor
deleted file mode 100644 (file)
index 996047e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: furnace.auth.features.edit-profile.tests
-USING: tools.test furnace.auth.features.edit-profile ;
-
-
diff --git a/basis/furnace/auth/features/recover-password/recover-password-tests.factor b/basis/furnace/auth/features/recover-password/recover-password-tests.factor
deleted file mode 100644 (file)
index 313b8ef..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: furnace.auth.features.recover-password
-USING: tools.test furnace.auth.features.recover-password ;
-
-
diff --git a/basis/furnace/auth/features/registration/registration-tests.factor b/basis/furnace/auth/features/registration/registration-tests.factor
deleted file mode 100644 (file)
index 42acda4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: furnace.auth.features.registration.tests
-USING: tools.test furnace.auth.features.registration ;
-
-
diff --git a/basis/furnace/auth/login/login-tests.factor b/basis/furnace/auth/login/login-tests.factor
deleted file mode 100644 (file)
index aabd0c5..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: furnace.auth.login.tests\r
-USING: tools.test furnace.auth.login ;\r
-\r
-\r
index 1a9784f1478d011b152d942c8b14f16ff3bb1044..c6a037cea17a86dd7fd57ce52890d7cb35fc4094 100644 (file)
@@ -1,6 +1,5 @@
 USING: accessors namespaces kernel combinators.short-circuit
 db.tuples db.types furnace.auth furnace.sessions furnace.cache ;
-
 IN: furnace.auth.login.permits
 
 TUPLE: permit < server-state session uid ;
index 8fe1dd4dd4c5d678ea7e1c640f7a030e34fd4307..44a20e7ae39688857fc8bae7f6b8b90a65d42a8c 100644 (file)
@@ -1,7 +1,7 @@
-IN: furnace.auth.providers.assoc.tests\r
 USING: furnace.actions furnace.auth furnace.auth.providers \r
 furnace.auth.providers.assoc furnace.auth.login\r
 tools.test namespaces accessors kernel ;\r
+IN: furnace.auth.providers.assoc.tests\r
 \r
 <action> "Test" <login-realm>\r
     <users-in-memory> >>users\r
index f5a79d701bc21d9d6a99d7ea3c2db8bda96aaf9d..a7a48307c999eb6f3c265d114320f303e8d3a330 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-IN: furnace.auth.providers.assoc\r
 USING: accessors assocs kernel furnace.auth.providers ;\r
+IN: furnace.auth.providers.assoc\r
 \r
 TUPLE: users-in-memory assoc ;\r
 \r
index de7650d9ef2da9accdeb6ce1343084de475f2552..f23a4a852730508aedff03b7b58568d49c368440 100644 (file)
@@ -1,4 +1,3 @@
-IN: furnace.auth.providers.db.tests\r
 USING: furnace.actions\r
 furnace.auth\r
 furnace.auth.login\r
@@ -6,6 +5,7 @@ furnace.auth.providers
 furnace.auth.providers.db tools.test\r
 namespaces db db.sqlite db.tuples continuations\r
 io.files io.files.temp io.directories accessors kernel ;\r
+IN: furnace.auth.providers.db.tests\r
 \r
 <action> "test" <login-realm> realm set\r
 \r
diff --git a/basis/furnace/db/db-tests.factor b/basis/furnace/db/db-tests.factor
deleted file mode 100644 (file)
index 15698d8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-IN: furnace.db.tests
-USING: tools.test furnace.db ;
-
-
index 1d5aa43c7b18c99b3f1a0719d3da20c60a36becd..6fe2633031ae934eda8f2700f726371347b014d3 100644 (file)
@@ -1,7 +1,8 @@
-IN: furnace.tests
 USING: http http.server.dispatchers http.server.responses
 http.server furnace furnace.utilities tools.test kernel
 namespaces accessors io.streams.string urls xml.writer ;
+IN: furnace.tests
+
 TUPLE: funny-dispatcher < dispatcher ;
 
 : <funny-dispatcher> ( -- dispatcher ) funny-dispatcher new-dispatcher ;
index 99855c76fa8fc09a05841a2343381233f1de03bf..49311ee8913bf563666116577eadf14fab6f50fe 100644 (file)
@@ -1,10 +1,10 @@
-IN: furnace.sessions.tests\r
 USING: tools.test http furnace.sessions furnace.actions\r
 http.server http.server.responses math namespaces make kernel\r
 accessors io.sockets io.servers.connection prettyprint\r
 io.streams.string io.files io.files.temp io.directories\r
 splitting destructors sequences db db.tuples db.sqlite\r
 continuations urls math.parser furnace furnace.utilities ;\r
+IN: furnace.sessions.tests\r
 \r
 : with-session ( session quot -- )\r
     [\r
@@ -19,7 +19,7 @@ M: foo init-session* drop 0 "x" sset ;
 \r
 M: foo call-responder*\r
     2drop\r
-    "x" [ 1+ ] schange\r
+    "x" [ 1 + ] schange\r
     "x" sget number>string "text/html" <content> ;\r
 \r
 : url-responder-mock-test ( -- string )\r
@@ -53,7 +53,7 @@ M: foo call-responder*
 \r
 "auth-test.db" temp-file <sqlite-db> [\r
 \r
-    <request> init-request\r
+    <request> "GET" >>method init-request\r
     session ensure-table\r
 \r
     "127.0.0.1" 1234 <inet4> remote-address set\r
@@ -73,7 +73,7 @@ M: foo call-responder*
 \r
         [ 9 ] [ "x" sget sq ] unit-test\r
 \r
-        [ ] [ "x" [ 1- ] schange ] unit-test\r
+        [ ] [ "x" [ 1 - ] schange ] unit-test\r
 \r
         [ 4 ] [ "x" sget sq ] unit-test\r
 \r
index e7fdaf64d61a4da273b47649e29cc03a8cb01596..b00f7fa523706d9a0e822ba0cdc339b6cf8abd23 100644 (file)
@@ -63,10 +63,6 @@ HELP: referrer
 { $values { "referrer/f" { $maybe string } } }
 { $description "Outputs the current request's referrer URL." } ;
 
-HELP: request-params
-{ $values { "request" request } { "assoc" assoc } }
-{ $description "Outputs the query parameters (if the current request is a GET or HEAD request) or the POST parameters (if the current request is a POST request)." } ;
-
 HELP: resolve-base-path
 { $values { "string" string } { "string'" string } }
 { $description "Resolves a responder-relative URL." } ;
@@ -121,6 +117,5 @@ ARTICLE: "furnace.misc" "Miscellaneous Furnace features"
 { $subsection exit-with }
 "Other useful words:"
 { $subsection hidden-form-field }
-{ $subsection request-params }
 { $subsection client-state }
 { $subsection user-agent } ;
index a43466489cb6d3c23bcf8bd6944e444cec9da891..dc90ad4e8c5c12a0bce4ca08d45540ebaa81b176 100755 (executable)
@@ -91,13 +91,6 @@ M: object modify-form drop f ;
 
 CONSTANT: nested-forms-key "__n"
 
-: request-params ( request -- assoc )
-    dup method>> {
-        { "GET" [ url>> query>> ] }
-        { "HEAD" [ url>> query>> ] }
-        { "POST" [ post-data>> params>> ] }
-    } case ;
-
 : referrer ( -- referrer/f )
     #! Typo is intentional, it's in the HTTP spec!
     "referer" request get header>> at
index 3cce0da575fd1cf890d9363e987ec61e7cb0f361..10f3b5d7f59eb8840e615a89aa416bb968e9b194 100644 (file)
@@ -1,8 +1,9 @@
+USING: ui game-input tools.test kernel system threads calendar
+combinators.short-circuit ;
 IN: game-input.tests
-USING: ui game-input tools.test kernel system threads calendar ;
 
-os windows? os macosx? or [
+os { [ windows? ] [ macosx? ] } 1|| [
     [ ] [ open-game-input ] unit-test
     [ ] [ 1 seconds sleep ] unit-test
     [ ] [ close-game-input ] unit-test
-] when
\ No newline at end of file
+] when
index 922906df483ffac80a4d7a029433b9c20a3c84c9..c21b900d8cf437d3a14d1262985c2a13b8aa9360 100755 (executable)
@@ -45,12 +45,12 @@ ERROR: game-input-not-open ;
     game-input-opened? [
         (open-game-input) 
     ] unless
-    game-input-opened [ 1+ ] change-global
+    game-input-opened [ 1 + ] change-global
     reset-mouse ;
 : close-game-input ( -- )
     game-input-opened [
         dup zero? [ game-input-not-open ] when
-        1-
+        1 -
     ] change-global
     game-input-opened? [
         (close-game-input) 
index 92c0c7173ae6b9d6948f307437e0c48379e42622..71d547ad29ed7521f7ac1c78678a524ea117cc9f 100755 (executable)
@@ -153,7 +153,7 @@ CONSTANT: pov-values
     IOHIDValueGetIntegerValue pov-values ?nth [ pov-neutral ] unless* ;
 
 : record-button ( state hid-value element -- )
-    [ buttons>> ] [ button-value ] [ IOHIDElementGetUsage 1- ] tri* rot set-nth ;
+    [ buttons>> ] [ button-value ] [ IOHIDElementGetUsage 1 - ] tri* rot set-nth ;
 
 : record-controller ( controller-state value -- )
     dup IOHIDValueGetElement {
index abcbd54cab9072969c2868419ac94abcab47510e..e7b3ee82525da5f74b974e6526d5290fd880039b 100644 (file)
@@ -24,20 +24,20 @@ MACRO: narray ( n -- )
     '[ _ { } nsequence ] ;
 
 MACRO: nsum ( n -- )
-    1- [ + ] n*quot ;
+    1 - [ + ] n*quot ;
 
 MACRO: firstn-unsafe ( n -- )
     [ '[ [ _ ] dip nth-unsafe ] ] map '[ _ cleave ] ;
 
 MACRO: firstn ( n -- )
     dup zero? [ drop [ drop ] ] [
-        [ 1- swap bounds-check 2drop ]
+        [ 1 - swap bounds-check 2drop ]
         [ firstn-unsafe ]
         bi-curry '[ _ _ bi ]
     ] if ;
 
 MACRO: npick ( n -- )
-    1- [ dup ] [ '[ _ dip swap ] ] repeat ;
+    1 - [ dup ] [ '[ _ dip swap ] ] repeat ;
 
 MACRO: nover ( n -- )
     dup 1 + '[ _ npick ] n*quot ;
@@ -46,10 +46,10 @@ MACRO: ndup ( n -- )
     dup '[ _ npick ] n*quot ;
 
 MACRO: nrot ( n -- )
-    1- [ ] [ '[ _ dip swap ] ] repeat ;
+    1 - [ ] [ '[ _ dip swap ] ] repeat ;
 
 MACRO: -nrot ( n -- )
-    1- [ ] [ '[ swap _ dip ] ] repeat ;
+    1 - [ ] [ '[ swap _ dip ] ] repeat ;
 
 MACRO: ndrop ( n -- )
     [ drop ] n*quot ;
@@ -91,7 +91,7 @@ MACRO: napply ( quot n -- )
     swap <repetition> spread>quot ;
 
 MACRO: mnswap ( m n -- )
-    1+ '[ _ -nrot ] swap '[ _ _ napply ] ;
+    1 + '[ _ -nrot ] swap '[ _ _ napply ] ;
 
 MACRO: nweave ( n -- )
     [ dup <reversed> [ '[ _ _ mnswap ] ] with map ] keep
index 45eb27ea62e338c433fa1abf82dcfcec8e311e7c..bdc0623d5413eb591589a8f35420f59b8c356d26 100644 (file)
@@ -1,5 +1,5 @@
-IN: globs.tests
 USING: tools.test globs ;
+IN: globs.tests
 
 [ f ] [ "abd" "fdf" glob-matches? ] unit-test
 [ f ] [ "fdsafas" "?" glob-matches? ] unit-test
index 50ffa65474c839a0aa71dde94741b0bcfff58a3c..07250058ae9148dcea9ada4a406faae7539e7c54 100644 (file)
@@ -17,10 +17,16 @@ ARTICLE: "grouping" "Groups and clumps"
 "The difference can be summarized as the following:"
 { $list
     { "With groups, the subsequences form the original sequence when concatenated:"
-        { $unchecked-example "dup n groups concat sequence= ." "t" }
+        { $unchecked-example
+            "USING: grouping ;"
+            "{ 1 2 3 4 } dup" "2 <groups> concat sequence= ." "t"
+        }
     }
     { "With clumps, collecting the first element of each subsequence but the last one, together with the last subseqence, yields the original sequence:"
-        { $unchecked-example "dup n clumps unclip-last [ [ first ] map ] dip append sequence= ." "t" }
+        { $unchecked-example
+            "USING: grouping ;"
+            "{ 1 2 3 4 } dup" "2 <clumps> unclip-last [ [ first ] map ] dip append sequence= ." "t"
+        }
     }
 }
 "A combinator built using clumps:"
index ec13e3a75083fe3e34c42c59d3e5e71007d75d4c..f68760a4e18e881d08d80507edd2223a90a7d99d 100644 (file)
@@ -35,7 +35,7 @@ M: slice-chunking nth-unsafe group@ slice boa ;
 TUPLE: abstract-groups < chunking-seq ;
 
 M: abstract-groups length
-    [ seq>> length ] [ n>> ] bi [ + 1- ] keep /i ;
+    [ seq>> length ] [ n>> ] bi [ + 1 - ] keep /i ;
 
 M: abstract-groups set-length
     [ n>> * ] [ seq>> ] bi set-length ;
@@ -46,10 +46,10 @@ M: abstract-groups group@
 TUPLE: abstract-clumps < chunking-seq ;
 
 M: abstract-clumps length
-    [ seq>> length ] [ n>> ] bi - 1+ ;
+    [ seq>> length ] [ n>> ] bi - 1 + ;
 
 M: abstract-clumps set-length
-    [ n>> + 1- ] [ seq>> ] bi set-length ;
+    [ n>> + 1 - ] [ seq>> ] bi set-length ;
 
 M: abstract-clumps group@
     [ n>> over + ] [ seq>> ] bi ;
@@ -100,4 +100,4 @@ INSTANCE: sliced-clumps slice-chunking
 
 : all-equal? ( seq -- ? ) [ = ] monotonic? ;
 
-: all-eq? ( seq -- ? ) [ eq? ] monotonic? ;
\ No newline at end of file
+: all-eq? ( seq -- ? ) [ eq? ] monotonic? ;
index b4761075628044451643170673cbabd6267c3d9b..c1985c516f995cdee7c614985f4e9330a4b7c36e 100644 (file)
@@ -52,7 +52,7 @@ IN: heaps.tests
 ] each
 
 : sort-entries ( entries -- entries' )
-    [ [ key>> ] compare ] sort ;
+    [ key>> ] sort-with ;
 
 : delete-test ( n -- obj1 obj2 )
     [
index 32ed10d8f26f6c4b043fafb83da462c746916ff5..677daca69de52e85006fbfe78c9b4388248614f2 100644 (file)
@@ -46,7 +46,7 @@ M: heap heap-size ( heap -- n )
 
 : right ( n -- m ) 1 shift 2 + ; inline
 
-: up ( n -- m ) 1- 2/ ; inline
+: up ( n -- m ) 1 - 2/ ; inline
 
 : data-nth ( n heap -- entry )
     data>> nth-unsafe ; inline
@@ -164,7 +164,7 @@ M: bad-heap-delete summary
 
 M: heap heap-delete ( entry heap -- )
     [ entry>index ] keep
-    2dup heap-size 1- = [
+    2dup heap-size 1 - = [
         nip data-pop*
     ] [
         [ nip data-pop ] 2keep
index 3dbda475de891b421c2a795709c018e5faca622e..6fa4217522590af3b737a37b80ebdb20848a8533 100644 (file)
@@ -1,4 +1,4 @@
-IN: help.apropos.tests
 USING: help.apropos tools.test ;
+IN: help.apropos.tests
 
 [ ] [ "swp" apropos ] unit-test
index ff385f9a65a55af5928a3def203861bc401b84f5..6bf88f8f03bb29ba537b97c1aedf06197ff0e2f8 100644 (file)
@@ -45,7 +45,7 @@ ARTICLE: "cookbook-colon-defs" "Shuffle word and definition cookbook"
 { $code ": sq ( x -- y ) dup * ;" }
 "(You could have looked this up yourself by clicking on the " { $link sq } " word itself.)"
 $nl
-"Note the key elements in a word definition: The colon " { $link POSTPONE: : } " denotes the start of a word definition. The name of the new word must immediately follow. The word definition then continues on until the " { $link POSTPONE: ; } " token signifies the end of the definition. This type of word definition is called a " { $emphasis "compound definition." }
+"Note the key elements in a word definition: The colon " { $link POSTPONE: : } " denotes the start of a word definition. The name of the new word and a stack effect declaration must immediately follow. The word definition then continues on until the " { $link POSTPONE: ; } " token signifies the end of the definition. This type of word definition is called a " { $emphasis "compound definition." }
 $nl
 "Factor is all about code reuse through short and logical colon definitions. Breaking up a problem into small pieces which are easy to test is called " { $emphasis "factoring." }
 $nl
@@ -154,11 +154,11 @@ $nl
 }
 "Note that words must be defined before being referenced. The following is generally invalid:"
 { $code
-    ": frob accelerate particles ;"
-    ": accelerate accelerator on ;"
-    ": particles [ (particles) ] each ;"
+    ": frob ( what -- ) accelerate particles ;"
+    ": accelerate ( -- ) accelerator on ;"
+    ": particles ( what -- ) [ (particles) ] each ;"
 }
-"You would have to place the first definition after the two others for the parser to accept the file."
+"You would have to place the first definition after the two others for the parser to accept the file. If you have a set of mutually recursive words, you can use " { $link POSTPONE: DEFER: } "."
 { $references
     { }
     "word-search"
@@ -277,7 +277,7 @@ $nl
     "Don't worry about efficiency unless your program is too slow. Don't prefer complex code to simple code just because you feel it will be more efficient. The Factor compiler is designed to make idiomatic code run fast."
     { "None of the above are hard-and-fast rules: there are exceptions to all of them. But one rule unconditionally holds: " { $emphasis "there is always a simpler way" } "." }
 }
-"Factor tries to implement as much of itself as possible, because this improves simplicity and performance. One consequence is that Factor exposes its internals for extension and study. You even have the option of using low-level features not usually found in high-level languages, such manual memory management, pointer arithmetic, and inline assembly code."
+"Factor tries to implement as much of itself as possible, because this improves simplicity and performance. One consequence is that Factor exposes its internals for extension and study. You even have the option of using low-level features not usually found in high-level languages, such as manual memory management, pointer arithmetic, and inline assembly code."
 $nl
 "Unsafe features are tucked away so that you will not invoke them by accident, or have to use them to solve conventional programming problems. However when the need arises, unsafe features are invaluable, for example you might have to do some pointer arithmetic when interfacing directly with C libraries." ;
 
@@ -287,6 +287,7 @@ ARTICLE: "cookbook-pitfalls" "Pitfalls to avoid"
     "Factor only makes use of one native thread, and Factor threads are scheduled co-operatively. C library calls block the entire VM."
     "Factor does not hide anything from the programmer, all internals are exposed. It is your responsibility to avoid writing fragile code which depends too much on implementation detail."
     { "If a literal object appears in a word definition, the object itself is pushed on the stack when the word executes, not a copy. If you intend to mutate this object, you must " { $link clone } " it first. See " { $link "syntax-literals" } "." }
+    { "Also, " { $link dup } " and related shuffle words don't copy entire objects or arrays; they only duplicate the reference to them. If you want to guard an object against mutation, use " { $link clone } "." }
     { "For a discussion of potential issues surrounding the " { $link f } " object, see " { $link "booleans" } "." }
     { "Factor's object system is quite flexible. Careless usage of union, mixin and predicate classes can lead to similar problems to those caused by “multiple inheritance” in other languages. In particular, it is possible to have two classes such that they have a non-empty intersection and yet neither is a subclass of the other. If a generic word defines methods on two such classes, various disambiguation rules are applied to ensure method dispatch remains deterministic, however they may not be what you expect. See " { $link "method-order" } " for details." }
     { "Be careful when calling words which access variables from a " { $link make-assoc } " which constructs an assoc with arbitrary keys, since those keys might shadow variables." }
index 95d4612cbed90b31ca9a781605973ed7c8c31afd..4022d3bd382a2ac8ccb5fcea0d24cf8f4d50e170 100644 (file)
@@ -1,7 +1,7 @@
-IN: help.crossref.tests
 USING: help.crossref help.topics help.markup tools.test words
 definitions assocs sequences kernel namespaces parser arrays
 io.streams.string continuations debugger compiler.units eval ;
+IN: help.crossref.tests
 
 [ ] [
     "IN: help.crossref.tests USING: help.syntax help.markup ; : foo ( -- ) ; HELP: foo \"foo is great\" ; ARTICLE: \"foo\" \"Foo\" { $subsection foo } ;" eval( -- )
index 240ce672400d3a0bd451546d88d576674638625f..709d56c5d61712dfe97476118a81e259fcc1fcb4 100644 (file)
@@ -1,5 +1,5 @@
-IN: help.handbook.tests
 USING: help tools.test ;
+IN: help.handbook.tests
 
 [ ] [ "article-index" print-topic ] unit-test
 [ ] [ "primitive-index" print-topic ] unit-test
index e09127835977c3e1ad57387c26f2ffa5582b092b..d8c5a32f3dbd17dfd7ba76a97f2ab4f209aaf270 100644 (file)
@@ -1,6 +1,6 @@
-IN: help.tests
 USING: tools.test help kernel ;
+IN: help.tests
 
 [ 3 throw ] must-fail
 [ ] [ :help ] unit-test
-[ ] [ f print-topic ] unit-test
\ No newline at end of file
+[ ] [ f print-topic ] unit-test
index 3ba336be0bff6604596047d2f27dd96c74e04109..90ff6c110faefadb101325f9f3dc773942534d3a 100644 (file)
@@ -1,6 +1,6 @@
-IN: help.html.tests
 USING: help.html tools.test help.topics kernel ;
+IN: help.html.tests
 
 [ ] [ "xml" >link help>html drop ] unit-test
 
-[ "article-foobar.html" ] [ "foobar" >link topic>filename ] unit-test
\ No newline at end of file
+[ "article-foobar.html" ] [ "foobar" >link topic>filename ] unit-test
index 84f708a6870a4a39754061286c4b6355ad7f6a0b..e8cc7e04c544fc878e480593842b95c3053a7423 100644 (file)
@@ -73,7 +73,7 @@ M: topic url-of topic>filename ;
     dup topic>filename utf8 [ help>html write-xml ] with-file-writer ;
 
 : all-vocabs-really ( -- seq )
-    all-vocabs >hashtable f over delete-at no-roots remove-redundant-prefixes ;
+    all-vocabs-recursive >hashtable f over delete-at no-roots remove-redundant-prefixes ;
 
 : all-topics ( -- topics )
     [
@@ -115,7 +115,7 @@ TUPLE: result title href ;
     load-index swap >lower
     '[ [ drop _ ] dip >lower subseq? ] assoc-filter
     [ swap result boa ] { } assoc>map
-    [ [ title>> ] compare ] sort ;
+    [ title>> ] sort-with ;
 
 : article-apropos ( string -- results )
     "articles.idx" offline-apropos ;
index a46e57735706b428fee004f7fe37ecc79f735eb2..7df196a79f9df82deadb31775d743916ca0c8ee3 100644 (file)
@@ -11,25 +11,30 @@ $nl
 { $code "USE: tools.scaffold" }
 "Then, ask the scaffold tool to create a new vocabulary named " { $snippet "palindrome" } ":"
 { $code "\"resource:work\" \"palindrome\" scaffold-vocab" }
-"If you look at the output, you will see that a few files were created in your “work” directory. The following phrase will print the full path of your work directory:"
+"If you look at the output, you will see that a few files were created in your “work” directory, and that the new source file was loaded."
+$nl
+"The following phrase will print the full path of your work directory:"
 { $code "\"work\" resource-path ." }
 "The work directory is one of several " { $link "vocabs.roots" } " where Factor searches for vocabularies. It is possible to define new vocabulary roots; see " { $link "add-vocab-roots" } ". To keep things simple in this tutorial, we'll just use the work directory, though."
 $nl
-"Open the work directory in your file manager, and open the subdirectory named " { $snippet "palindrome" } ". Inside this subdirectory you will see a file named " { $snippet "palindrome.factor" } ". We will be editing this file."
-$nl
-"Notice that the file ends with an " { $link POSTPONE: IN: } " form telling Factor that all definitions in this source file should go into the " { $snippet "palindrome" } " vocabulary using the " { $link POSTPONE: IN: } " word:"
-{ $code "IN: palindrome" }
-"We will add new definitions after the " { $link POSTPONE: IN: } " form."
+"Open the work directory in your file manager, and open the subdirectory named " { $snippet "palindrome" } ". Inside this subdirectory you will see a file named " { $snippet "palindrome.factor" } ". Open this file in your text editor."
 $nl
 "You are now ready to go on to the next section: " { $link "first-program-logic" } "." ;
 
 ARTICLE: "first-program-logic" "Writing some logic in your first program"
 "Your " { $snippet "palindrome.factor" } " file should look like the following after the previous section:"
 { $code
-    "! Copyright (C) 2008 <your name here>"
+    "! Copyright (C) 2009 <your name here>"
     "! See http://factorcode.org/license.txt for BSD license."
+    "USING: ;"
     "IN: palindrome"
 }
+"Notice that the file ends with an " { $link POSTPONE: IN: } " form telling Factor that all definitions in this source file should go into the " { $snippet "palindrome" } " vocabulary using the " { $link POSTPONE: IN: } " word. We will add new definitions after the " { $link POSTPONE: IN: } " form."
+$nl
+"In order to be able to call the words defined in the " { $snippet "palindrome" } " vocabulary, you need to issue the following command in the listener:"
+{ $code "USE: palindrome" }
+"Now, we will be making some additions to the file. Since the file was loaded by the scaffold tool in the previous step, you need to tell Factor to reload it if it changes. Factor has a handy feature for this; pressing " { $command tool "common" refresh-all } " in the listener window will reload any changed source files. You can also force a single vocabulary to reload:"
+{ $code "\"palindrome\" reload" }
 "We will now write our first word using " { $link POSTPONE: : } ". This word will test if a string is a palindrome; it will take a string as input, and give back a boolean as output. We will call this word " { $snippet "palindrome?" } ", following a naming convention that words returning booleans have names ending with " { $snippet "?" } "."
 $nl
 "Recall that a string is a palindrome if it is spelled the same forwards or backwards; that is, if the string is equal to its reverse. We can express this in Factor as follows:"
@@ -42,7 +47,7 @@ $nl
 $nl
 "To add the word to the search path, first convince yourself that this word is in the " { $vocab-link "kernel" } " vocabulary. Enter " { $snippet "dup" } " in the listener's input area, and press " { $operation com-browse } ". This will open the documentation browser tool, viewing the help for the " { $link dup } " word. One of the subheadings in the help article will mention the word's vocabulary."
 $nl
-"So now, add the following at the start of the source file:"
+"Go back to the third line in your source file and change it to:"
 { $code "USING: kernel ;" }
 "Next, find out what vocabulary " { $link reverse } " lives in; type the word name " { $snippet "reverse" } " in the listener's input area, and press " { $operation com-browse } "."
 $nl
@@ -55,15 +60,15 @@ $nl
 ARTICLE: "first-program-test" "Testing your first program"
 "Your " { $snippet "palindrome.factor" } " file should look like the following after the previous section:"
 { $code
-    "! Copyright (C) 2008 <your name here>"
+    "! Copyright (C) 2009 <your name here>"
     "! See http://factorcode.org/license.txt for BSD license."
-    "IN: palindrome"
     "USING: kernel sequences ;"
+    "IN: palindrome"
     ""
     ": palindrome? ( str -- ? ) dup reverse = ;"
 }
-"We will now test our new word in the listener. First we have add the palindrome vocabulary to the listener's vocabulary search path:"
-{ $code "USE: palindrome"}
+"We will now test our new word in the listener. If you haven't done so already, add the palindrome vocabulary to the listener's vocabulary search path:"
+{ $code "USE: palindrome" }
 "Next, push a string on the stack:"
 { $code "\"hello\"" }
 "Note that the stack display in the listener now shows this string. Having supplied the input, we call our word:"
@@ -82,9 +87,8 @@ $nl
 $nl
 "We will add some unit tests, which are similar to the interactive tests we did above. Unit tests are defined with the " { $link POSTPONE: unit-test } " word, which takes a sequence of expected outputs, and a piece of code. It runs the code, and asserts that it outputs the expected values."
 $nl
-"Add the following three lines to " { $snippet "palindrome-tests.factor" } ":"
+"Add the following two lines to " { $snippet "palindrome-tests.factor" } ":"
 { $code
-    "USING: palindrome tools.test ;"
     "[ f ] [ \"hello\" palindrome? ] unit-test"
     "[ t ] [ \"racecar\" palindrome? ] unit-test"
 }
@@ -105,7 +109,7 @@ $nl
 { $code "\"palindrome\" test" }
 "The next step is to, of course, fix our code so that the unit test can pass."
 $nl
-"We begin by writing a word called " { $snippet "normalize" } " which removes blanks and non-alphabetical characters from a string, and then converts the string to lower case. We call this word " { $snippet "normalize" } ". To figure out how to write this word, we begin with some interactive experimentation in the listener."
+"We begin by writing a word which removes blanks and non-alphabetical characters from a string, and then converts the string to lower case. We call this word " { $snippet "normalize" } ". To figure out how to write this word, we begin with some interactive experimentation in the listener."
 $nl
 "Start by pushing a character on the stack; notice that characters are really just integers:"
 { $code "CHAR: a" }
@@ -132,7 +136,7 @@ $nl
 { $code "[ Letter? ] filter >lower" }
 "This code starts with a string on the stack, removes non-alphabetical characters, and converts the result to lower case, leaving a new string on the stack. We put this code in a new word, and add the new word to " { $snippet "palindrome.factor" } ":"
 { $code ": normalize ( str -- newstr ) [ Letter? ] filter >lower ;" }
-"You will need to add " { $vocab-link "unicode.case" } " and " { $vocab-link "unicode.categories" } " to the vocabulary search path, so that " { $link Letter? } " can be used in the source file."
+"You will need to add " { $vocab-link "unicode.case" } " and " { $vocab-link "unicode.categories" } " to the vocabulary search path, so that " { $link >lower } " and " { $link Letter? } " can be used in the source file."
 $nl
 "We modify " { $snippet "palindrome?" } " to first apply " { $snippet "normalize" } " to its input:"
 { $code ": palindrome? ( str -- ? ) normalize dup reverse = ;" }
index f03e0b33370ae571e62f42fac670a9ae396e516e..5637dd92f450d549426c25107c78a28d0c041355 100644 (file)
@@ -1,5 +1,5 @@
-IN: help.vocabs.tests
 USING: help.vocabs tools.test help.markup help vocabs ;
+IN: help.vocabs.tests
 
 [ ] [ { $vocab "scratchpad" } print-content ] unit-test
-[ ] [ "classes" vocab print-topic ] unit-test
\ No newline at end of file
+[ ] [ "classes" vocab print-topic ] unit-test
index d10bd5f8a97f1fb35201e9ebe36abbdfa206328a..6b7a6ae8cae224014a3e8ed7d8d9e78318d19c35 100644 (file)
@@ -69,7 +69,7 @@ t specialize-method? set-global
     dup [ array? ] all? [ first ] when length ;
 
 SYNTAX: HINTS:
-    scan-object
+    scan-object dup wrapper? [ wrapped>> ] when
     [ changed-definition ]
     [ parse-definition { } like "specializer" set-word-prop ] bi ;
 
index c901e35e3e8262cdefeaa359f77425cdd76627d2..d1d43c762cc7d27ef34c6ef0478185db0d55c156 100644 (file)
@@ -1,9 +1,9 @@
-IN: html.components.tests
 USING: tools.test kernel io.streams.string
 io.streams.null accessors inspector html.streams
 html.components html.forms namespaces
 xml.writer ;
 FROM: html.components => inspector ;
+IN: html.components.tests
 
 [ ] [ begin-form ] unit-test
 
index 006a435cf0e8b54243a5ca7d503a5ecb36aa7084..b1596e9aa677c4dccdfdd4e595ac4d34a060a7b5 100644 (file)
@@ -1,7 +1,7 @@
-IN: html.forms.tests
 USING: kernel sequences tools.test assocs html.forms validators accessors
 namespaces ;
 FROM: html.forms => values ;
+IN: html.forms.tests
 
 : with-validation ( quot -- messages )
     [
index cc8b4f0a1595cc36566fae4b4dc08b5f2e1a5cd0..5cf318bcafd0c7b003b9377e78d42124e28e8bd9 100644 (file)
@@ -44,7 +44,7 @@ M: form clone
     [ value ] dip '[
         [
             form [ clone ] change
-            1+ "index" set-value
+            1 + "index" set-value
             "value" set-value
             @
         ] with-scope
@@ -54,7 +54,7 @@ M: form clone
     [ value ] dip '[
         [
             begin-form
-            1+ "index" set-value
+            1 + "index" set-value
             from-object
             @
         ] with-scope
index ceb2e72478d964cf5f3444f0fb6e33ff44489889..a98a21f177c2ca6ebdbaa4daf3e89a201220bec3 100644 (file)
@@ -17,7 +17,7 @@ TUPLE: template-lexer < lexer ;
 M: template-lexer skip-word
     [
         {
-            { [ 2dup nth CHAR: " = ] [ drop 1+ ] }
+            { [ 2dup nth CHAR: " = ] [ drop 1 + ] }
             { [ 2dup swap tail-slice "%>" head? ] [ drop 2 + ] }
             [ f skip ]
         } cond
index c391b417a932eaab87c5f3d6bf94009928eb4cda..7a7fcffc741d5a838971d0a9a4e4018a8cbf0209 100644 (file)
@@ -1,5 +1,6 @@
 USING: http.client http.client.private http tools.test
 namespaces urls ;
+IN: http.client.tests
 
 [ "localhost" f ] [ "localhost" parse-host ] unit-test
 [ "localhost" 8888 ] [ "localhost:8888" parse-host ] unit-test
diff --git a/basis/http/client/post-data/post-data-tests.factor b/basis/http/client/post-data/post-data-tests.factor
deleted file mode 100644 (file)
index 2704ce1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test http.client.post-data ;
-IN: http.client.post-data.tests
index f87ed47f00811a6c647a1ddf2934bee03ee9b4b5..f8c3b836a6e7d0eb4f7590ab81c22eddc49d1253 100644 (file)
@@ -1,5 +1,5 @@
-IN: http.parsers.tests
 USING: http http.parsers tools.test ;
+IN: http.parsers.tests
 
 [ { } ] [ "" parse-cookie ] unit-test
 [ { } ] [ "" parse-set-cookie ] unit-test
@@ -13,4 +13,4 @@ unit-test
 
 [ { T{ cookie { name "__s" } { value "12345567" } } } ]
 [ "__s=12345567;" parse-cookie ]
-unit-test
\ No newline at end of file
+unit-test
index 72ff111db93ae2185987cee4270d1796cec90d78..d502de75b0e6d9779c9fee15d24af513cf0db190 100644 (file)
@@ -1,6 +1,6 @@
-IN: http.server.redirection.tests
 USING: http http.server.redirection urls accessors
 namespaces tools.test present kernel ;
+IN: http.server.redirection.tests
 
 [
     <request>
diff --git a/basis/http/server/rewrite/rewrite-docs.factor b/basis/http/server/rewrite/rewrite-docs.factor
new file mode 100644 (file)
index 0000000..9ded10b
--- /dev/null
@@ -0,0 +1,72 @@
+IN: http.server.rewrite
+USING: help.syntax help.markup http.server ;
+
+HELP: rewrite
+{ $class-description "The class of directory rewrite responders. The slots are as follows:"
+{ $list
+  { { $slot "default" } " - the responder to call if no file name is provided." }
+  { { $slot "child" } " - the responder to call if a file name is provided." }
+  { { $slot "param" } " - the name of a request parameter which will store the first path component of the file name passed to the responder." }
+} } ;
+
+HELP: <rewrite>
+{ $values { "rewrite" rewrite } }
+{ $description "Creates a new " { $link rewrite } " responder." }
+{ $examples
+  { $code
+    "<rewrite>"
+    "    <display-post-action> >>default"
+    "    <display-comment-action> >>child"
+    "    \"comment_id\" >>param"
+  }
+} ;
+
+HELP: vhost-rewrite
+{ $class-description "The class of virtual host rewrite responders. The slots are as follows:"
+{ $list
+  { { $slot "default" } " - the responder to call if no host name prefix is provided." }
+  { { $slot "child" } " - the responder to call if a host name prefix is provided." }
+  { { $slot "param" } " - the name of a request parameter which will store the first host name component of the host name passed to the responder." }
+  { { $slot "suffix" } " - the domain name suffix which will be chopped off the end of the request's host name in order to produce the parameter." }
+} } ;
+
+HELP: <vhost-rewrite>
+{ $values { "vhost-rewrite" vhost-rewrite } }
+{ $description "Creates a new " { $link vhost-rewrite } " responder." }
+{ $examples
+  { $code
+    "<vhost-rewrite>"
+    "    <show-blogs-action> >>default"
+    "    <display-blog-action> >>child"
+    "    \"blog_id\" >>param"
+    "    \"blogs.vegan.net\" >>suffix"
+  }
+} ;
+
+ARTICLE: "http.server.rewrite.overview" "Rewrite responder overview"
+"Rewrite responders take the file name and turn it into a request parameter named by the " { $slot "param" } " slot before delegating to a child responder. If a file name is provided, it calls the responder in the " { $slot "child" } " slot. If no file name is provided, they call the default responder in the " { $slot "default" } " slot."
+$nl
+"For example, suppose you want to have the following website schema:"
+{ $list
+{ { $snippet "/posts/" } " - show a list of posts" }
+{ { $snippet "/posts/factor_language" } " - show thread with ID " { $snippet "factor_language" } }
+{ { $snippet "/posts/factor_language/1" } " - show first comment in the thread with ID " { $snippet "factor_language" } }
+{ { $snippet "/animals" } ", ... - a bunch of other actions" } }
+"One way to achieve this would be to have a nesting of responders as follows:"
+{ $list
+{ "A dispatcher at the top level" }
+  { "A " { $link rewrite } " as a child of the dispatcher under the name " { $snippet "posts" } ". The rewrite has the " { $slot "param" } " slot set to, say, " { $snippet "post_id" } ". The " { $slot "default" } " slot is set to a Furnace action which displays a list of posts." }
+  { "The child slot is set to a second " { $link rewrite } " instance, with " { $snippet "param" } " set to " { $snippet "comment_id" } ", the " { $slot "default" } " slot set to an action which displays a post identified by the " { $snippet "post_id" } " parameter, and the " { $snippet "child" } " slot set to an action which displays the comment identified by the " { $snippet "comment_id" } " parameter." } }
+"Note that parameters can be extracted from the request using the " { $link param } " word, but most of the time you want to use " { $vocab-link "furnace.actions" } " instead." ;
+
+ARTICLE: "http.server.rewrite" "URL rewrite responders"
+"The " { $vocab-link "http.server.rewrite" } " vocabulary defines two responder types which can help make website URLs more human-friendly."
+{ $subsection "http.server.rewrite.overview" }
+"Directory rewrite responders:"
+{ $subsection rewrite }
+{ $subsection <rewrite> }
+"Virtual host rewrite responders -- these chop off the value in the " { $snippet "suffix" } " slot from the tail of the host name, and use the rest as the parameter value:"
+{ $subsection vhost-rewrite }
+{ $subsection <vhost-rewrite> } ;
+
+ABOUT: "http.server.rewrite"
\ No newline at end of file
diff --git a/basis/http/server/rewrite/rewrite-tests.factor b/basis/http/server/rewrite/rewrite-tests.factor
new file mode 100644 (file)
index 0000000..3a053c3
--- /dev/null
@@ -0,0 +1,48 @@
+USING: accessors arrays http.server http.server.rewrite kernel
+namespaces tools.test urls ;
+IN: http.server.rewrite.tests
+
+TUPLE: rewrite-test-default ;
+
+M: rewrite-test-default call-responder*
+    drop "DEFAULT!" 2array ;
+
+TUPLE: rewrite-test-child ;
+
+M: rewrite-test-child call-responder*
+    drop "rewritten-param" param 2array ;
+
+V{ } clone responder-nesting set
+H{ } clone params set
+
+<rewrite>
+    rewrite-test-child new >>child
+    rewrite-test-default new >>default
+    "rewritten-param" >>param
+"rewrite" set
+
+[ { { } "DEFAULT!" } ] [ { } "rewrite" get call-responder ] unit-test
+[ { { } "xxx" } ] [ { "xxx" } "rewrite" get call-responder ] unit-test
+[ { { "blah" } "xxx" } ] [ { "xxx" "blah" } "rewrite" get call-responder ] unit-test
+
+<vhost-rewrite>
+    rewrite-test-child new >>child
+    rewrite-test-default new >>default
+    "rewritten-param" >>param
+    "blogs.vegan.net" >>suffix
+"rewrite" set
+
+[ { { } "DEFAULT!" } ] [
+    URL" http://blogs.vegan.net" url set
+    { } "rewrite" get call-responder
+] unit-test
+
+[ { { } "DEFAULT!" } ] [
+    URL" http://www.blogs.vegan.net" url set
+    { } "rewrite" get call-responder
+] unit-test
+
+[ { { } "erg" } ] [
+    URL" http://erg.blogs.vegan.net" url set
+    { } "rewrite" get call-responder
+] unit-test
\ No newline at end of file
diff --git a/basis/http/server/rewrite/rewrite.factor b/basis/http/server/rewrite/rewrite.factor
new file mode 100644 (file)
index 0000000..86c6f83
--- /dev/null
@@ -0,0 +1,33 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors http.server http.server.dispatchers kernel
+namespaces sequences splitting urls ;
+IN: http.server.rewrite
+
+TUPLE: rewrite param child default ;
+
+: <rewrite> ( -- rewrite )
+    rewrite new ;
+
+M: rewrite call-responder*
+    over empty? [ default>> ] [
+        [ [ first ] [ param>> ] bi* set-param ]
+        [ [ rest ] [ child>> ] bi* ]
+        2bi
+    ] if
+    call-responder* ;
+
+TUPLE: vhost-rewrite suffix param child default ;
+
+: <vhost-rewrite> ( -- vhost-rewrite )
+    vhost-rewrite new ;
+
+: sub-domain? ( vhost-rewrite url -- subdomain ? )
+    swap suffix>> dup [
+        [ host>> canonical-host ] [ "." prepend ] bi* ?tail
+    ] [ 2drop f f ] if ;
+
+M: vhost-rewrite call-responder*
+    dup url get sub-domain?
+    [ over param>> set-param child>> ] [ drop default>> ] if
+    call-responder ;
index daf03059727b4498f6e559b0ce75fc5f5de54dc1..e6d5c63ac1f14b1f3e0f02a0d0baa650476d0e82 100644 (file)
@@ -1,4 +1,5 @@
-USING: help.markup help.syntax io.streams.string quotations strings urls http vocabs.refresh math io.servers.connection ;
+USING: help.markup help.syntax io.streams.string quotations strings urls
+http vocabs.refresh math io.servers.connection assocs ;
 IN: http.server
 
 HELP: trivial-responder
@@ -52,12 +53,33 @@ HELP: httpd
 HELP: http-insomniac
 { $description "Starts a thread which rotates the logs and e-mails a summary of HTTP requests every 24 hours. See " { $link "logging.insomniac" } "." } ;
 
+HELP: request-params
+{ $values { "request" request } { "assoc" assoc } }
+{ $description "Outputs the query parameters (if the current request is a GET or HEAD request) or the POST parameters (if the current request is a POST request)." } ;
+
+HELP: param
+{ $values
+     { "name" string }
+     { "value" string }
+}
+{ $description "Outputs the value of a query parameter (if the current request is a GET or HEAD request) or a POST parameter (if the current request is a POST request)." }
+{ $notes "Instead of using this word, it is better to use " { $vocab-link "furnace.actions" } " and the associated validation machinery, which allows you to access values using " { $link "html.forms.values" } " words." } ;
+
+HELP: params
+{ $var-description "A variable holding an assoc of query parameters (if the current request is a GET or HEAD request) or POST parameters (if the current request is a POST request)." }
+{ $notes "Instead of using this word, it is better to use " { $vocab-link "furnace.actions" } " and the associated validation machinery, which allows you to access values using " { $link "html.forms.values" } " words." } ;
+
 ARTICLE: "http.server.requests" "HTTP request variables"
 "The following variables are set by the HTTP server at the beginning of a request."
 { $subsection request }
 { $subsection url }
 { $subsection post-request? }
 { $subsection responder-nesting }
+{ $subsection params }
+"Utility words:"
+{ $subsection param }
+{ $subsection set-param }
+{ $subsection request-params }
 "Additional vocabularies may be set by vocabularies such as " { $vocab-link "html.forms" } " and " { $vocab-link "furnace.sessions" } "." ;
 
 ARTICLE: "http.server.responders" "HTTP server responders"
index 8682c97c731fdec9d15d8222698698d3cf812692..131fe3fe186e0d2ea7bf0ec835d566cffa07d990 100755 (executable)
@@ -3,7 +3,8 @@
 USING: kernel accessors sequences arrays namespaces splitting
 vocabs.loader destructors assocs debugger continuations
 combinators vocabs.refresh tools.time math math.parser present
-io vectors
+vectors hashtables
+io
 io.sockets
 io.sockets.secure
 io.encodings
@@ -212,8 +213,25 @@ LOG: httpd-header NOTICE
 : split-path ( string -- path )
     "/" split harvest ;
 
+: request-params ( request -- assoc )
+    dup method>> {
+        { "GET" [ url>> query>> ] }
+        { "HEAD" [ url>> query>> ] }
+        { "POST" [ post-data>> params>> ] }
+    } case ;
+
+SYMBOL: params
+
+: param ( name -- value )
+    params get at ;
+
+: set-param ( value name -- )
+    params get set-at ;
+
 : init-request ( request -- )
-    [ request set ] [ url>> url set ] bi
+    [ request set ]
+    [ url>> url set ]
+    [ request-params >hashtable params set ] tri
     V{ } clone responder-nesting set ;
 
 : dispatch-request ( request -- response )
index d54be036984af493cb4b6db4239cca7c5abf16ae..185b0eb36194c016d12646e51b064212f432ad8a 100644 (file)
@@ -1,4 +1,4 @@
-IN: http.server.static.tests
 USING: http.server.static tools.test xml.writer ;
+IN: http.server.static.tests
 
-[ ] [ "resource:basis" directory>html write-xml ] unit-test
\ No newline at end of file
+[ ] [ "resource:basis" directory>html write-xml ] unit-test
index ca3ea8d2b456ca28988641537f1a29309938cd60..ec7a70b656eac61db3567a8e1d06a65126780b64 100644 (file)
@@ -229,8 +229,8 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
     ] with each^2 ;
 
 : sign-extend ( bits v -- v' )
-    swap [ ] [ 1- 2^ < ] 2bi
-    [ -1 swap shift 1+ + ] [ drop ] if ;
+    swap [ ] [ 1 - 2^ < ] 2bi
+    [ -1 swap shift 1 + + ] [ drop ] if ;
 
 : read1-jpeg-dc ( decoder -- dc )
     [ read1-huff dup ] [ bs>> bs:read ] bi sign-extend ;
@@ -245,7 +245,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
     0 :> k!
     [
         color ac-huff-table>> read1-jpeg-ac
-        [ first 1+ k + k! ] [ second k coefs set-nth ] [ ] tri
+        [ first 1 + k + k! ] [ second k coefs set-nth ] [ ] tri
         { 0 0 } = not
         k 63 < and
     ] loop
index 22283deecb5971a7c0a9caa3c2ac89c076f7def0..e9130a3c40c6b82828c11fe52c6da85b82afe8d6 100644 (file)
@@ -46,7 +46,7 @@ PRIVATE>
     array>> [ value ] map ;\r
 \r
 : <interval-map> ( specification -- map )\r
-    all-intervals [ [ first second ] compare ] sort\r
+    all-intervals [ first second ] sort-with\r
     >intervals ensure-disjoint interval-map boa ;\r
 \r
 : <interval-set> ( specification -- map )\r
@@ -58,7 +58,7 @@ PRIVATE>
     [\r
         alist sort-keys unclip swap [ [ first dup ] [ second ] bi ] dip\r
         [| oldkey oldval key val | ! Underneath is start\r
-            oldkey 1+ key =\r
+            oldkey 1 + key =\r
             oldval val = and\r
             [ oldkey 2array oldval 2array , key ] unless\r
             key val\r
index 51ab6f27d9782e6b2eb04d28e285f25ff057fbfa..571957cf4c9d23465b243229526793cfd4d20ee0 100644 (file)
@@ -21,7 +21,7 @@ C: <foo> foo
 
 : something ( array -- num )
     {
-        { [ dup 1+ 2array ] [ 3 * ] }
+        { [ dup 1 + 2array ] [ 3 * ] }
         { [ 3array ] [ + + ] }
     } switch ;
 
@@ -92,5 +92,5 @@ TUPLE: funny-tuple ;
 
 [ ] [ [ <funny-tuple> ] [undo] drop ] unit-test
 
-[ 0 ] [ { 1 2 } [ [ 1+ 2 ] { } output>sequence ] undo ] unit-test
-[ { 0 1 } ] [ 1 2 [ [ [ 1+ ] bi@ ] input<sequence ] undo ] unit-test
+[ 0 ] [ { 1 2 } [ [ 1 + 2 ] { } output>sequence ] undo ] unit-test
+[ { 0 1 } ] [ 1 2 [ [ [ 1 + ] bi@ ] input<sequence ] undo ] unit-test
index 2183c95f080db60145007c7016d888ea7188d3a5..39a2d5f3dc96f0f0b01de3f8535cf95f1bd5b02a 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2009 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel words summary slots quotations
+USING: accessors kernel locals words summary slots quotations
 sequences assocs math arrays stack-checker effects
 continuations debugger classes.tuple namespaces make vectors
 bit-arrays byte-arrays strings sbufs math.functions macros
@@ -231,6 +231,18 @@ DEFER: __
 \ output>sequence 2 [ [undo] '[ dup _ assure-same-class _ input<sequence ] ] define-pop-inverse
 \ input<sequence 1 [ [undo] '[ _ { } output>sequence ] ] define-pop-inverse
 
+! conditionals
+
+:: undo-if-empty ( result a b -- seq )
+   a call( -- b ) result = [ { } ] [ result b [undo] call( a -- b ) ] if ;
+
+:: undo-if* ( result a b -- boolean )
+   b call( -- b ) result = [ f ] [ result a [undo] call( a -- b ) ] if ;
+
+\ if-empty 2 [ swap [ undo-if-empty ] 2curry ] define-pop-inverse
+
+\ if* 2 [ swap [ undo-if* ] 2curry ] define-pop-inverse
+
 ! Constructor inverse
 : deconstruct-pred ( class -- quot )
     "predicate" word-prop [ dupd call assure ] curry ;
@@ -283,4 +295,4 @@ M: no-match summary drop "Fall through in switch" ;
     reverse [ [ [undo] ] dip compose ] { } assoc>map
     recover-chain ;
 
-MACRO: switch ( quot-alist -- ) [switch] ;
+MACRO: switch ( quot-alist -- ) [switch] ;
\ No newline at end of file
index 7d0acb4140a3f8d0ceeaba0542febb14d22d3028..8022ed34e223f899cb302486d63efa795b3e2368 100644 (file)
@@ -40,7 +40,7 @@ TUPLE: select-mx < mx read-fdset write-fdset ;
     dup assoc-empty? [ drop 0 ] [ keys supremum ] if ;
 
 : num-fds ( mx -- n )
-    [ reads>> max-fd ] [ writes>> max-fd ] bi max 1+ ;
+    [ reads>> max-fd ] [ writes>> max-fd ] bi max 1 + ;
 
 : init-fdsets ( mx -- nfds read write except )
     [ num-fds ]
index 7237651b8003345be1f0049a554ab06a00f39bdd..a66b2aad7a00b50f288539863309356e0ac6d798 100755 (executable)
@@ -1,4 +1,4 @@
-IN: io.backend.windows.privileges.tests\r
 USING: io.backend.windows.privileges tools.test ;\r
+IN: io.backend.windows.privileges.tests\r
 \r
 [ [ ] with-privileges ] must-infer\r
index 1654cb8b833a17d39a9c206c0df59ba9f35fccb0..16132ca810d814299bcc184c12637776130d56cf 100644 (file)
@@ -5,7 +5,7 @@ IN: io.encodings.ascii
 
 <PRIVATE
 : encode-if< ( char stream encoding max -- )
-    nip 1- pick < [ encode-error ] [ stream-write1 ] if ; inline
+    nip 1 - pick < [ encode-error ] [ stream-write1 ] if ; inline
 
 : decode-if< ( stream encoding max -- character )
     nip swap stream-read1 dup
@@ -19,4 +19,4 @@ M: ascii encode-char
     128 encode-if< ;
 
 M: ascii decode-char
-    128 decode-if< ;
\ No newline at end of file
+    128 decode-if< ;
index 81e43f8dd9cd0dd5d2655b7a34f56e926c30e770..38165e4267819d36c9e61c546afa7dc2aa0a1601 100755 (executable)
@@ -9,11 +9,11 @@ calendar ascii combinators.short-circuit locals ;
 IN: io.files.info.windows
 
 :: round-up-to ( n multiple -- n' )
-    n multiple rem dup 0 = [
-        drop n
+    n multiple rem [
+        n
     ] [
         multiple swap - n +
-    ] if ;
+    ] if-zero ;
 
 TUPLE: windows-file-info < file-info attributes ;
 
@@ -109,11 +109,11 @@ M: windows link-info ( path -- info )
     file-info ;
 
 : volume-information ( normalized-path -- volume-name volume-serial max-component flags type )
-    MAX_PATH 1+ [ <byte-array> ] keep
+    MAX_PATH 1 + [ <byte-array> ] keep
     "DWORD" <c-object>
     "DWORD" <c-object>
     "DWORD" <c-object>
-    MAX_PATH 1+ [ <byte-array> ] keep
+    MAX_PATH 1 + [ <byte-array> ] keep
     [ GetVolumeInformation win32-error=0/f ] 7 nkeep
     drop 5 nrot drop
     [ utf16n alien>string ] 4 ndip
@@ -165,13 +165,13 @@ M: winnt file-system-info ( path -- file-system-info )
     ] if ;
 
 : find-first-volume ( -- string handle )
-    MAX_PATH 1+ [ <byte-array> ] keep
+    MAX_PATH 1 + [ <byte-array> ] keep
     dupd
     FindFirstVolume dup win32-error=0/f
     [ utf16n alien>string ] dip ;
 
 : find-next-volume ( handle -- string/f )
-    MAX_PATH 1+ [ <byte-array> tuck ] keep
+    MAX_PATH 1 + [ <byte-array> tuck ] keep
     FindNextVolume 0 = [
         GetLastError ERROR_NO_MORE_FILES =
         [ drop f ] [ win32-error-string throw ] if
index 7aec916c72086977809a0e4f6a8a6e97acdd62bf..38bcc86cc6b00fbb8a9cae6a46ddf075d9ea13e2 100644 (file)
@@ -28,7 +28,7 @@ ERROR: too-many-symlinks path n ;
 : (follow-links) ( n path -- path' )
     over 0 = [ symlink-depth get too-many-symlinks ] when
     dup link-info type>> +symbolic-link+ =
-    [ [ 1- ] [ follow-link ] bi* (follow-links) ]
+    [ [ 1 - ] [ follow-link ] bi* (follow-links) ]
     [ nip ] if ; inline recursive
 
 PRIVATE>
index dd5eb5c8d912872e97baaa47d0744147fe767133..ef7d778abe7ae439b2ce4c35e6a81bc66b92b15c 100644 (file)
@@ -4,7 +4,7 @@ io.pathnames namespaces ;
 IN: io.files.links.unix.tests
 
 : make-test-links ( n path -- )
-    [ '[ [ 1+ ] keep [ number>string _ prepend ] bi@ make-link ] each ]
+    [ '[ [ 1 + ] keep [ number>string _ prepend ] bi@ make-link ] each ]
     [ [ number>string ] dip prepend touch-file ] 2bi ; inline
 
 [ t ] [
index 7de6c25a135fb3b8de86994167ceb0817f59910c..d17cd1ff805965297df3a60c50185c9cc693ad3a 100755 (executable)
@@ -47,7 +47,7 @@ TUPLE: CreateProcess-args
 
 : count-trailing-backslashes ( str n -- str n )
     [ "\\" ?tail ] dip swap [
-        1+ count-trailing-backslashes
+        1 + count-trailing-backslashes
     ] when ;
 
 : fix-trailing-backslashes ( str -- str' )
index db8e02ae73881f739156f3ed6e9f612096dbc02a..7329e73a8007bfb9c14b1e4ac7f43134dae82909 100644 (file)
@@ -14,13 +14,13 @@ SYMBOL: dummy-monitor-disposed
 TUPLE: dummy-monitor < monitor ;
 
 M: dummy-monitor dispose
-    drop dummy-monitor-disposed get [ 1+ ] change-i drop ;
+    drop dummy-monitor-disposed get [ 1 + ] change-i drop ;
 
 M: mock-io-backend (monitor)
     nip
     over exists? [
         dummy-monitor new-monitor
-        dummy-monitor-created get [ 1+ ] change-i drop
+        dummy-monitor-created get [ 1 + ] change-i drop
     ] [
         "Does not exist" throw
     ] if ;
index c15663b0319c714e5ebaa09552b37d1f1a3a2f8c..8d747086a7b1a32f7367e0388f14c4ec4b856980 100644 (file)
@@ -47,7 +47,7 @@ M: callable run-pipeline-element
 PRIVATE>
 
 : run-pipeline ( seq -- results )
-    [ length dup zero? [ drop { } ] [ 1- <pipes> ] if ] keep
+    [ length dup zero? [ drop { } ] [ 1 - <pipes> ] if ] keep
     [
         [ [ first in>> ] [ second out>> ] bi ] dip
         run-pipeline-element
index e72b267c04849acfb2d0f2a90e6e6281dc7b54f4..07246354e3e98871ecb01acd14ecd76cc52240a9 100644 (file)
@@ -36,7 +36,7 @@ TUPLE: openssl-context < secure-context aliens sessions ;
         password [ B{ 0 } password! ] unless
 
         [let | len [ password strlen ] |
-            buf password len 1+ size min memcpy
+            buf password len 1 + size min memcpy
             len
         ]
     ] alien-callback ;
index fe136cd88732b63636a410f0d9ad228944d109fe..ec8b4206e3c1d2c82302e23701a0fc1013903e4c 100644 (file)
@@ -19,7 +19,7 @@ IN: io.sockets.unix
     [ handle-fd ] 2dip 1 <int> "int" heap-size setsockopt io-error ;
 
 M: unix addrinfo-error ( n -- )
-    dup zero? [ drop ] [ gai_strerror throw ] if ;
+    [ gai_strerror throw ] unless-zero ;
 
 ! Client sockets - TCP and Unix domain
 M: object (get-local-address) ( handle remote -- sockaddr )
index ab4fbd60bb9fdbdf2c7b2daa5ab7768f18b3a950..aabd4bbafcd6e84d55d4dbb7e008e197b30ecf0d 100644 (file)
@@ -5,18 +5,18 @@ IN: lcs
 \r
 <PRIVATE\r
 : levenshtein-step ( insert delete change same? -- next )\r
-    0 1 ? + [ [ 1+ ] bi@ ] dip min min ;\r
+    0 1 ? + [ [ 1 + ] bi@ ] dip min min ;\r
 \r
 : lcs-step ( insert delete change same? -- next )\r
     1 -1/0. ? + max max ; ! -1/0. is -inf (float)\r
 \r
 :: loop-step ( i j matrix old new step -- )\r
-    i j 1+ matrix nth nth ! insertion\r
-    i 1+ j matrix nth nth ! deletion\r
+    i j 1 + matrix nth nth ! insertion\r
+    i 1 + j matrix nth nth ! deletion\r
     i j matrix nth nth ! replace/retain\r
     i old nth j new nth = ! same?\r
     step call\r
-    i 1+ j 1+ matrix nth set-nth ; inline\r
+    i 1 + j 1 + matrix nth set-nth ; inline\r
 \r
 : lcs-initialize ( |str1| |str2| -- matrix )\r
     [ drop 0 <array> ] with map ;\r
@@ -25,7 +25,7 @@ IN: lcs
     [ [ + ] curry map ] with map ;\r
 \r
 :: run-lcs ( old new init step -- matrix )\r
-    [let | matrix [ old length 1+ new length 1+ init call ] |\r
+    [let | matrix [ old length 1 + new length 1 + init call ] |\r
         old length [| i |\r
             new length\r
             [| j | i j matrix old new step loop-step ] each\r
@@ -44,14 +44,14 @@ TUPLE: insert item ;
 TUPLE: trace-state old new table i j ;\r
 \r
 : old-nth ( state -- elt )\r
-    [ i>> 1- ] [ old>> ] bi nth ;\r
+    [ i>> 1 - ] [ old>> ] bi nth ;\r
 \r
 : new-nth ( state -- elt )\r
-    [ j>> 1- ] [ new>> ] bi nth ;\r
+    [ j>> 1 - ] [ new>> ] bi nth ;\r
 \r
 : top-beats-side? ( state -- ? )\r
-    [ [ i>> ] [ j>> 1- ] [ table>> ] tri nth nth ]\r
-    [ [ i>> 1- ] [ j>> ] [ table>> ] tri nth nth ] bi > ;\r
+    [ [ i>> ] [ j>> 1 - ] [ table>> ] tri nth nth ]\r
+    [ [ i>> 1 - ] [ j>> ] [ table>> ] tri nth nth ] bi > ;\r
 \r
 : retained? ( state -- ? )\r
     {\r
@@ -61,7 +61,7 @@ TUPLE: trace-state old new table i j ;
 \r
 : do-retain ( state -- state )\r
     dup old-nth retain boa ,\r
-    [ 1- ] change-i [ 1- ] change-j ;\r
+    [ 1 - ] change-i [ 1 - ] change-j ;\r
 \r
 : inserted? ( state -- ? )\r
     {\r
@@ -70,7 +70,7 @@ TUPLE: trace-state old new table i j ;
     } 1&& ;\r
 \r
 : do-insert ( state -- state )\r
-    dup new-nth insert boa , [ 1- ] change-j ;\r
+    dup new-nth insert boa , [ 1 - ] change-j ;\r
 \r
 : deleted? ( state -- ? )\r
     {\r
@@ -79,7 +79,7 @@ TUPLE: trace-state old new table i j ;
     } 1&& ;\r
 \r
 : do-delete ( state -- state )\r
-    dup old-nth delete boa , [ 1- ] change-i ;\r
+    dup old-nth delete boa , [ 1 - ] change-i ;\r
 \r
 : (trace-diff) ( state -- )\r
     {\r
@@ -90,7 +90,7 @@ TUPLE: trace-state old new table i j ;
     } cond ;\r
 \r
 : trace-diff ( old new table -- diff )\r
-    [ ] [ first length 1- ] [ length 1- ] tri trace-state boa\r
+    [ ] [ first length 1 - ] [ length 1 - ] tri trace-state boa\r
     [ (trace-diff) ] { } make reverse ;\r
 PRIVATE>\r
 \r
index 5030e93abc955492392a6f5b6e813ec4b2153257..603b04e895e0d6df74e15cb5180b86f3cc58dde8 100644 (file)
@@ -50,8 +50,8 @@ IN: linked-assocs.test
 
 { 9 } [
     <linked-hash>
-    { [ 3 * ] [ 1- ] }          "first"   pick set-at
-    { [ [ 1- ] bi@ ] [ 2 / ] }  "second"  pick set-at
+    { [ 3 * ] [ 1 - ] }          "first"   pick set-at
+    { [ [ 1 - ] bi@ ] [ 2 / ] }  "second"  pick set-at
     4 6 pick values [ first call ] each
     + swap values <reversed> [ second call ] each
 ] unit-test
@@ -62,4 +62,4 @@ IN: linked-assocs.test
     2 "by" pick set-at
     3 "cx" pick set-at
     >alist
-] unit-test
\ No newline at end of file
+] unit-test
index bde26e2fb9cff2fa06cf4b09f5a371bdb2b0d46d..7b386e9c819ea1acfc93988b97227fcfb8666355 100644 (file)
@@ -97,7 +97,7 @@ M: lazy-take car ( lazy-take -- car )
     cons>> car ;
 
 M: lazy-take cdr ( lazy-take -- cdr )
-    [ n>> 1- ] keep
+    [ n>> 1 - ] keep
     cons>> cdr ltake ;
 
 M: lazy-take nil? ( lazy-take -- ? )
@@ -191,7 +191,7 @@ TUPLE: lazy-from-by n quot ;
 C: lfrom-by lazy-from-by
 
 : lfrom ( n -- list )
-    [ 1+ ] lfrom-by ;
+    [ 1 + ] lfrom-by ;
 
 M: lazy-from-by car ( lazy-from-by -- car )
     n>> ;
@@ -235,7 +235,7 @@ M: sequence-cons car ( sequence-cons -- car )
     [ index>> ] [ seq>> nth ] bi ;
 
 M: sequence-cons cdr ( sequence-cons -- cdr )
-    [ index>> 1+ ] [ seq>> sequence-tail>list ] bi ;
+    [ index>> 1 + ] [ seq>> sequence-tail>list ] bi ;
 
 M: sequence-cons nil? ( sequence-cons -- ? )
     drop f ;
index e34a719c57835a25ebfd610bcd719cd59c53fe2c..d2f969cddc62236632ef8a848959d65f25b38517 100644 (file)
@@ -24,7 +24,7 @@ IN: lists.tests
 ] unit-test
     
 { T{ cons f 2 T{ cons f 3 T{ cons f 4 T{ cons f 5 +nil+ } } } } } [
-    { 1 2 3 4 } sequence>list [ 1+ ] lmap
+    { 1 2 3 4 } sequence>list [ 1 + ] lmap
 ] unit-test
     
 { 15 } [
index 0eedb808891605748f2857c2d0c1d4bb9d4dcad0..ddf1ab91098e2e7abab454a4424775fbc4af404b 100644 (file)
@@ -71,7 +71,7 @@ PRIVATE>
     ] if ; inline recursive
 
 : llength ( list -- n )
-    0 [ drop 1+ ] foldl ;
+    0 [ drop 1 + ] foldl ;
 
 : lreverse ( list -- newlist )    
     nil [ swap cons ] foldl ;
index 9ec8e30133f5df95d918eaabc0a965e2d59f2943..1caa4b746fa59947e0822cac7c88b0ee020a4bf9 100644 (file)
@@ -38,7 +38,7 @@ USING: kernel literals math prettyprint ;
 IN: scratchpad
 
 << CONSTANT: five 5 >>
-{ $[ five dup 1+ dup 2 + ] } .
+{ $[ five dup 1 + dup 2 + ] } .
     "> "{ 5 6 8 }" }
 
 } ;
@@ -69,7 +69,7 @@ USE: literals
 IN: scratchpad
 
 CONSTANT: five 5
-{ $ five $[ five dup 1+ dup 2 + ] } .
+{ $ five $[ five dup 1 + dup 2 + ] } .
     "> "{ 5 5 6 8 }" }
 { $subsection POSTPONE: $ }
 { $subsection POSTPONE: $[ }
index b1f0b6ca1732b3d59b6092d32b665c1d04d08ea2..0f94e0591a675fcf4448fbd6d1e762fc2d8ed7e2 100644 (file)
@@ -175,8 +175,8 @@ $nl
 { $code
     ":: counter ( -- )"
     "    [let | value! [ 0 ] |"
-    "        [ value 1+ dup value! ]"
-    "        [ value 1- dup value! ] ] ;"
+    "        [ value 1 + dup value! ]"
+    "        [ value 1 - dup value! ] ] ;"
 }
 "Mutable bindings are implemented in a manner similar to the ML language; each mutable binding is actually an immutable binding of a mutable cell (in Factor's case, a 1-element array); reading the binding automatically dereferences the array, and writing to the binding stores into the array."
 $nl
index 414b2da45c96cfb049bc3ce9ebb9ec8ff72bfb54..63b6d68feb3a4131eb5ed4415711ad754c67c48a 100644 (file)
@@ -199,23 +199,23 @@ DEFER: xyzzy
 [ 5 ] [ 10 xyzzy ] unit-test
 
 :: let*-test-1 ( a -- b )
-    [let* | b [ a 1+ ]
-            c [ b 1+ ] |
+    [let* | b [ a 1 + ]
+            c [ b 1 + ] |
         a b c 3array ] ;
 
 [ { 1 2 3 } ] [ 1 let*-test-1 ] unit-test
 
 :: let*-test-2 ( a -- b )
-    [let* | b [ a 1+ ]
-            c! [ b 1+ ] |
+    [let* | b [ a 1 + ]
+            c! [ b 1 + ] |
         a b c 3array ] ;
 
 [ { 1 2 3 } ] [ 1 let*-test-2 ] unit-test
 
 :: let*-test-3 ( a -- b )
-    [let* | b [ a 1+ ]
-            c! [ b 1+ ] |
-        c 1+ c!  a b c 3array ] ;
+    [let* | b [ a 1 + ]
+            c! [ b 1 + ] |
+        c 1 + c!  a b c 3array ] ;
 
 [ { 1 2 4 } ] [ 1 let*-test-3 ] unit-test
 
@@ -502,7 +502,7 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
 
 [ 3 ] [ 3 [| | :> a! a ] call ] unit-test
 
-[ 3 ] [ 2 [| | :> a! a 1+ a! a ] call ] unit-test
+[ 3 ] [ 2 [| | :> a! a 1 + a! a ] call ] unit-test
 
 :: wlet-&&-test ( a -- ? )
     [wlet | is-integer? [ a integer? ]
index 8374ab421bd214dfcd4ea71c0ee3b8815a923bd4..848ad5d40e8d160b8001d780c4ff3e7b189b5e74 100644 (file)
@@ -74,7 +74,7 @@ CONSTANT: keep-logs 10
     over exists? [ move-file ] [ 2drop ] if ;\r
 \r
 : advance-log ( path n -- )\r
-    [ 1- log# ] 2keep log# ?move-file ;\r
+    [ 1 - log# ] 2keep log# ?move-file ;\r
 \r
 : rotate-log ( service -- )\r
     dup close-log\r
index 0fbfdf0bd948df160a6db96cddbcc87081f26471..e469140ff423a0ea710eced35f54da536f74e684 100644 (file)
@@ -7,7 +7,7 @@ TUPLE: bits { number read-only } { length read-only } ;
 C: <bits> bits
 
 : make-bits ( number -- bits )
-    dup zero? [ drop T{ bits f 0 0 } ] [ dup abs log2 1 + <bits> ] if ; inline
+    [ T{ bits f 0 0 } ] [ dup abs log2 1 + <bits> ] if-zero ; inline
 
 M: bits length length>> ;
 
@@ -16,4 +16,4 @@ M: bits nth-unsafe number>> swap bit? ;
 INSTANCE: bits immutable-sequence
 
 : unbits ( seq -- number )
-    <reversed> 0 [ [ 1 shift ] dip [ 1+ ] when ] reduce ;
+    <reversed> 0 [ [ 1 shift ] dip [ 1 + ] when ] reduce ;
index 041539c9815c2aaa82611688731e7f0df1ae3239..0e0b7ae1677f007e24a1680502aed5fada88b3d1 100644 (file)
@@ -28,7 +28,7 @@ HELP: nCk
 HELP: permutation
 { $values { "n" "a non-negative integer" } { "seq" sequence } { "seq" sequence } }
 { $description "Outputs the " { $snippet "nth" } " lexicographical permutation of " { $snippet "seq" } "." }
-{ $notes "Permutations are 0-based and a bounds error will be thrown if " { $snippet "n" } " is larger than " { $snippet "seq length factorial 1-" } "." }
+{ $notes "Permutations are 0-based and a bounds error will be thrown if " { $snippet "n" } " is larger than " { $snippet "seq length factorial 1 -" } "." }
 { $examples
     { $example "USING: math.combinatorics prettyprint ;"
         "1 3 permutation ." "{ 0 2 1 }" }
index 41800e46dafdcf514afa4ff15d6f1a49cb0c6d5c..0fe77fa4aeba1fd0c35e24a83dccc32f7af1b7aa 100644 (file)
@@ -50,8 +50,10 @@ ARTICLE: "power-functions" "Powers and logarithms"
 { $subsection exp }
 { $subsection cis }
 { $subsection log }
+{ $subsection log10 }
 "Raising a number to a power:"
 { $subsection ^ }
+{ $subsection 10^ }
 "Converting between rectangular and polar form:"
 { $subsection abs }
 { $subsection absq }
@@ -122,6 +124,10 @@ HELP: log
 { $values { "x" number } { "y" number } }
 { $description "Natural logarithm function. Outputs negative infinity if " { $snippet "x" } " is 0." } ;
 
+HELP: log10
+{ $values { "x" number } { "y" number } }
+{ $description "Logarithm function base 10. Outputs negative infinity if " { $snippet "x" } " is 0." } ;
+
 HELP: sqrt
 { $values { "x" number } { "y" number } }
 { $description "Square root function." } ;
@@ -261,6 +267,10 @@ HELP: ^
 { $description "Raises " { $snippet "x" } " to the power of " { $snippet "y" } ". If " { $snippet "y" } " is an integer the answer is computed exactly, otherwise a floating point approximation is used." }
 { $errors "Throws an error if " { $snippet "x" } " and " { $snippet "y" } " are both integer 0." } ;
 
+HELP: 10^
+{ $values { "x" number } { "y" number } }
+{ $description "Raises " { $snippet "x" } " to the power of 10. If " { $snippet "x" } " is an integer the answer is computed exactly, otherwise a floating point approximation is used." } ;
+
 HELP: gcd
 { $values { "x" integer } { "y" integer } { "a" integer } { "d" integer } }
 { $description "Computes the positive greatest common divisor " { $snippet "d" } " of " { $snippet "x" } " and " { $snippet "y" } ", and another value " { $snippet "a" } " satisfying:" { $code "a*y = d mod x" } }
index 314062591d192cff360e643d1f7479393e937268..801522b37634a89dba9c31a3c0a7d94de5809082 100644 (file)
@@ -71,7 +71,7 @@ PRIVATE>
     2dup [ real? ] both? [ drop 0 >= ] [ 2drop f ] if ; inline
 
 : 0^ ( x -- z )
-    dup zero? [ drop 0/0. ] [ 0 < 1/0. 0 ? ] if ; inline
+    [ 0/0. ] [ 0 < 1/0. 0 ? ] if-zero ; inline
 
 : (^mod) ( n x y -- z )
     make-bits 1 [
@@ -104,10 +104,12 @@ PRIVATE>
 : divisor? ( m n -- ? )
     mod 0 = ;
 
+ERROR: non-trivial-divisor n ;
+
 : mod-inv ( x n -- y )
     [ nip ] [ gcd 1 = ] 2bi
     [ dup 0 < [ + ] [ nip ] if ]
-    [ "Non-trivial divisor found" throw ] if ; foldable
+    [ non-trivial-divisor ] if ; foldable
 
 : ^mod ( x y n -- z )
     over 0 < [
@@ -156,6 +158,10 @@ M: real log dup 0.0 >= [ flog ] [ 0.0 rect> log ] if ;
 
 M: complex log >polar swap flog swap rect> ;
 
+: 10^ ( x -- y ) 10 swap ^ ; inline
+
+: log10 ( x -- y ) log 10 log / ; inline
+
 GENERIC: cos ( x -- y ) foldable
 
 M: complex cos
@@ -259,13 +265,13 @@ M: real atan fatan ;
 : round ( x -- y ) dup sgn 2 / + truncate ; inline
 
 : floor ( x -- y )
-    dup 1 mod dup zero?
-    [ drop ] [ dup 0 < [ - 1 - ] [ - ] if ] if ; foldable
+    dup 1 mod
+    [ ] [ dup 0 < [ - 1 - ] [ - ] if ] if-zero ; foldable
 
 : ceiling ( x -- y ) neg floor neg ; foldable
 
 : floor-to ( x step -- y )
-    dup zero? [ drop ] [ [ / floor ] [ * ] bi ] if ;
+    [ [ / floor ] [ * ] bi ] unless-zero ;
 
 : lerp ( a b t -- a_t ) [ over - ] dip * + ; inline
 
index 2b8b3dff243d5980d53b049ec2d1661a61f85cac..de402b48b9256ddaa877c9e120dbedc8861ddaa9 100644 (file)
@@ -1,10 +1,12 @@
 USING: math.intervals kernel sequences words math math.order
 arrays prettyprint tools.test random vocabs combinators
-accessors math.constants ;
+accessors math.constants fry ;
 IN: math.intervals.tests
 
 [ empty-interval ] [ 2 2 (a,b) ] unit-test
 
+[ empty-interval ] [ 2 2.0 (a,b) ] unit-test
+
 [ empty-interval ] [ 2 2 [a,b) ] unit-test
 
 [ empty-interval ] [ 2 2 (a,b] ] unit-test
@@ -111,6 +113,22 @@ IN: math.intervals.tests
     0 1 (a,b) 0 1 [a,b] interval-subset?
 ] unit-test
 
+[ t ] [
+    full-interval -1/0. 1/0. [a,b] interval-subset?
+] unit-test
+
+[ t ] [
+    -1/0. 1/0. [a,b] full-interval interval-subset?
+] unit-test
+
+[ f ] [
+    full-interval 0 1/0. [a,b] interval-subset?
+] unit-test
+
+[ t ] [
+    0 1/0. [a,b] full-interval interval-subset?
+] unit-test
+
 [ f ] [
     0 0 1 (a,b) interval-contains?
 ] unit-test
@@ -189,6 +207,10 @@ IN: math.intervals.tests
 
 [ f ] [ 0 10 [a,b] 0 [a,a] interval< ] unit-test
 
+[ f ] [ 0 10 [a,b] 0.0 [a,a] interval< ] unit-test
+
+[ f ] [ 0.0 10 [a,b] 0 [a,a] interval< ] unit-test
+
 [ f ] [ 0 10 [a,b] 10 [a,a] interval> ] unit-test
 
 [ incomparable ] [ 0 [a,a] 0 10 [a,b] interval< ] unit-test
@@ -211,6 +233,10 @@ IN: math.intervals.tests
 
 [ t ] [ 1 100 [a,b] -1 1 [a,b] interval/i [-inf,inf] = ] unit-test
 
+! Accuracy of interval-mod
+[ t ] [ full-interval 40 40 [a,b] interval-mod -40 40 (a,b) interval-subset?
+] unit-test
+
 ! Interval random tester
 : random-element ( interval -- n )
     dup full-interval eq? [
@@ -236,7 +262,7 @@ IN: math.intervals.tests
         } case
     ] if ;
 
-: random-unary-op ( -- pair )
+: unary-ops ( -- alist )
     {
         { bitnot interval-bitnot }
         { abs interval-abs }
@@ -247,11 +273,10 @@ IN: math.intervals.tests
     }
     "math.ratios.private" vocab [
         { recip interval-recip } suffix
-    ] when
-    random ;
+    ] when ;
 
-: unary-test ( -- ? )
-    random-interval random-unary-op ! 2dup . .
+: unary-test ( op -- ? )
+    [ random-interval ] dip
     0 pick interval-contains? over first \ recip eq? and [
         2drop t
     ] [
@@ -259,9 +284,11 @@ IN: math.intervals.tests
         second execute( a -- b ) interval-contains?
     ] if ;
 
-[ t ] [ 80000 iota [ drop unary-test ] all? ] unit-test
+unary-ops [
+    [ [ t ] ] dip '[ 8000 iota [ drop _ unary-test ] all? ] unit-test
+] each
 
-: random-binary-op ( -- pair )
+: binary-ops ( -- alist )
     {
         { + interval+ }
         { - interval- }
@@ -272,17 +299,15 @@ IN: math.intervals.tests
         { bitand interval-bitand }
         { bitor interval-bitor }
         { bitxor interval-bitxor }
-        ! { shift interval-shift }
         { min interval-min }
         { max interval-max }
     }
     "math.ratios.private" vocab [
         { / interval/ } suffix
-    ] when
-    random ;
+    ] when ;
 
-: binary-test ( -- ? )
-    random-interval random-interval random-binary-op ! 3dup . . .
+: binary-test ( op -- ? )
+    [ random-interval random-interval ] dip
     0 pick interval-contains? over first { / /i mod rem } member? and [
         3drop t
     ] [
@@ -290,22 +315,26 @@ IN: math.intervals.tests
         second execute( a b -- c ) interval-contains?
     ] if ;
 
-[ t ] [ 80000 iota [ drop binary-test ] all? ] unit-test
+binary-ops [
+    [ [ t ] ] dip '[ 8000 iota [ drop _ binary-test ] all? ] unit-test
+] each
 
-: random-comparison ( -- pair )
+: comparison-ops ( -- alist )
     {
         { < interval< }
         { <= interval<= }
         { > interval> }
         { >= interval>= }
-    } random ;
+    } ;
 
-: comparison-test ( -- ? )
-    random-interval random-interval random-comparison
+: comparison-test ( op -- ? )
+    [ random-interval random-interval ] dip
     [ [ [ random-element ] bi@ ] dip first execute( a b -- ? ) ] 3keep
     second execute( a b -- ? ) dup incomparable eq? [ 2drop t ] [ = ] if ;
 
-[ t ] [ 40000 iota [ drop comparison-test ] all? ] unit-test
+comparison-ops [
+    [ [ t ] ] dip '[ 8000 iota [ drop _ comparison-test ] all? ] unit-test
+] each
 
 [ t ] [ -10 10 [a,b] 0 100 [a,b] assume> 0 10 (a,b] = ] unit-test
 
@@ -325,18 +354,19 @@ IN: math.intervals.tests
 : random-interval-or-empty ( -- obj )
     10 random 0 = [ empty-interval ] [ random-interval ] if ;
 
-: random-commutative-op ( -- op )
+: commutative-ops ( -- seq )
     {
         interval+ interval*
         interval-bitor interval-bitand interval-bitxor
         interval-max interval-min
-    } random ;
-
-[ t ] [
-    80000 iota [
-        drop
-        random-interval-or-empty random-interval-or-empty
-        random-commutative-op
-        [ execute ] [ swapd execute ] 3bi =
-    ] all?
-] unit-test
+    } ;
+
+commutative-ops [
+    [ [ t ] ] dip '[
+        8000 iota [
+            drop
+            random-interval-or-empty random-interval-or-empty _
+            [ execute ] [ swapd execute ] 3bi =
+        ] all?
+    ] unit-test
+] each
index 767197a975721c2f01df860426714ebe3a3f0618..8ea28b2235e122cca3cec530bc03c69e326b6bd9 100755 (executable)
@@ -1,8 +1,8 @@
-! Copyright (C) 2007, 2008 Slava Pestov, Doug Coleman.
+! Copyright (C) 2007, 2009 Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 ! Based on Slate's src/unfinished/interval.slate by Brian Rice.
 USING: accessors kernel sequences arrays math math.order
-combinators generic layouts ;
+combinators generic layouts memoize ;
 IN: math.intervals
 
 SYMBOL: empty-interval
@@ -11,14 +11,21 @@ SYMBOL: full-interval
 
 TUPLE: interval { from read-only } { to read-only } ;
 
+: closed-point? ( from to -- ? )
+    2dup [ first ] bi@ number=
+    [ [ second ] both? ] [ 2drop f ] if ;
+
 : <interval> ( from to -- interval )
-    2dup [ first ] bi@ {
-        { [ 2dup > ] [ 2drop 2drop empty-interval ] }
-        { [ 2dup = ] [
-            2drop 2dup [ second ] both?
+    {
+        { [ 2dup [ first ] bi@ > ] [ 2drop empty-interval ] }
+        { [ 2dup [ first ] bi@ number= ] [
+            2dup [ second ] both?
             [ interval boa ] [ 2drop empty-interval ] if
         ] }
-        [ 2drop interval boa ]
+        { [ 2dup [ { -1/0. t } = ] [ { 1/0. t } = ] bi* and ] [
+            2drop full-interval
+        ] }
+        [ interval boa ]
     } cond ;
 
 : open-point ( n -- endpoint ) f 2array ;
@@ -48,7 +55,13 @@ TUPLE: interval { from read-only } { to read-only } ;
 
 : (a,inf] ( a -- interval ) 1/0. (a,b] ; inline
 
-: [0,inf] ( -- interval ) 0 [a,inf] ; foldable
+MEMO: [0,inf] ( -- interval ) 0 [a,inf] ; foldable
+
+MEMO: fixnum-interval ( -- interval )
+    most-negative-fixnum most-positive-fixnum [a,b] ; inline
+
+MEMO: array-capacity-interval ( -- interval )
+    0 max-array-capacity [a,b] ; inline
 
 : [-inf,inf] ( -- interval ) full-interval ; inline
 
@@ -56,20 +69,23 @@ TUPLE: interval { from read-only } { to read-only } ;
     [ 2dup [ first ] bi@ ] dip call [
         2drop t
     ] [
-        2dup [ first ] bi@ = [
+        2dup [ first ] bi@ number= [
             [ second ] bi@ not or
         ] [
             2drop f
         ] if
     ] if ; inline
 
+: endpoint= ( p1 p2 -- ? )
+    [ [ first ] bi@ number= ] [ [ second ] bi@ eq? ] 2bi and ;
+
 : endpoint< ( p1 p2 -- ? ) [ < ] compare-endpoints ;
 
-: endpoint<= ( p1 p2 -- ? ) [ endpoint< ] 2keep = or ;
+: endpoint<= ( p1 p2 -- ? ) [ endpoint< ] [ endpoint= ] 2bi or ;
 
 : endpoint> ( p1 p2 -- ? ) [ > ] compare-endpoints ;
 
-: endpoint>= ( p1 p2 -- ? ) [ endpoint> ] 2keep = or ;
+: endpoint>= ( p1 p2 -- ? ) [ endpoint> ] [ endpoint= ] 2bi or ;
 
 : endpoint-min ( p1 p2 -- p3 ) [ endpoint< ] most ;
 
@@ -180,7 +196,7 @@ TUPLE: interval { from read-only } { to read-only } ;
     ] [
         interval>points
         2dup [ second ] both?
-        [ [ first ] bi@ = ]
+        [ [ first ] bi@ number= ]
         [ 2drop f ] if
     ] if ;
 
@@ -269,22 +285,6 @@ TUPLE: interval { from read-only } { to read-only } ;
         [ (interval-abs) points>interval ]
     } cond ;
 
-: interval-mod ( i1 i2 -- i3 )
-    #! Inaccurate.
-    [
-        [
-            nip interval-abs to>> first [ neg ] keep (a,b)
-        ] interval-division-op
-    ] do-empty-interval ;
-
-: interval-rem ( i1 i2 -- i3 )
-    #! Inaccurate.
-    [
-        [
-            nip interval-abs to>> first 0 swap [a,b)
-        ] interval-division-op
-    ] do-empty-interval ;
-
 : interval-recip ( i1 -- i2 ) 1 [a,a] swap interval/ ;
 
 : interval-2/ ( i1 -- i2 ) -1 [a,a] interval-shift ;
@@ -294,13 +294,13 @@ SYMBOL: incomparable
 : left-endpoint-< ( i1 i2 -- ? )
     [ swap interval-subset? ]
     [ nip interval-singleton? ]
-    [ [ from>> ] bi@ = ]
+    [ [ from>> ] bi@ endpoint= ]
     2tri and and ;
 
 : right-endpoint-< ( i1 i2 -- ? )
     [ interval-subset? ]
     [ drop interval-singleton? ]
-    [ [ to>> ] bi@ = ]
+    [ [ to>> ] bi@ endpoint= ]
     2tri and and ;
 
 : (interval<) ( i1 i2 -- i1 i2 ? )
@@ -316,10 +316,10 @@ SYMBOL: incomparable
     } cond 2nip ;
 
 : left-endpoint-<= ( i1 i2 -- ? )
-    [ from>> ] dip to>> = ;
+    [ from>> ] [ to>> ] bi* endpoint= ;
 
 : right-endpoint-<= ( i1 i2 -- ? )
-    [ to>> ] dip from>> = ;
+    [ to>> ] [ from>> ] bi* endpoint= ;
 
 : interval<= ( i1 i2 -- ? )
     {
@@ -335,6 +335,25 @@ SYMBOL: incomparable
 : interval>= ( i1 i2 -- ? )
     swap interval<= ;
 
+: interval-mod ( i1 i2 -- i3 )
+    {
+        { [ over empty-interval eq? ] [ swap ] }
+        { [ dup empty-interval eq? ] [ ] }
+        { [ dup full-interval eq? ] [ ] }
+        [ interval-abs to>> first [ neg ] keep (a,b) ]
+    } cond
+    swap 0 [a,a] interval>= t eq? [ [0,inf] interval-intersect ] when ;
+
+: (rem-range) ( i -- i' ) interval-abs to>> first 0 swap [a,b) ;
+
+: interval-rem ( i1 i2 -- i3 )
+    {
+        { [ over empty-interval eq? ] [ drop ] }
+        { [ dup empty-interval eq? ] [ nip ] }
+        { [ dup full-interval eq? ] [ 2drop [0,inf] ] }
+        [ nip (rem-range) ]
+    } cond ;
+
 : interval-bitand-pos ( i1 i2 -- ? )
     [ to>> first ] bi@ min 0 swap [a,b] ;
 
index 0368dd5286195caa96654af970d00a8ee14f78b3..8411447aac3a183e1ba7b99558b3770c32146a03 100755 (executable)
@@ -50,7 +50,7 @@ SYMBOL: matrix
 : do-row ( exchange-with row# -- )
     [ exchange-rows ] keep
     [ first-col ] keep
-    dup 1+ rows-from clear-col ;
+    dup 1 + rows-from clear-col ;
 
 : find-row ( row# quot -- i elt )
     [ rows-from ] dip find ; inline
@@ -60,8 +60,8 @@ SYMBOL: matrix
 
 : (echelon) ( col# row# -- )
     over cols < over rows < and [
-        2dup pivot-row [ over do-row 1+ ] when*
-        [ 1+ ] dip (echelon)
+        2dup pivot-row [ over do-row 1 + ] when*
+        [ 1 + ] dip (echelon)
     ] [
         2drop
     ] if ;
index 673f9c97cdbf3bd9e419aaefe5df4df6f120deed..fdc2f9fc3bef158c64f13dacbf19d5afea5d6e87 100644 (file)
@@ -9,7 +9,7 @@ IN: math.primes.erato
 CONSTANT: masks B{ 0 128 0 0 0 0 0 64 0 0 0 32 0 16 0 0 0 8 0 4 0 0 0 2 0 0 0 0 0 1 }
 
 : bit-pos ( n -- byte/f mask/f )
-    30 /mod masks nth-unsafe dup zero? [ 2drop f f ] when ;
+    30 /mod masks nth-unsafe [ drop f f ] when-zero ;
 
 : marked-unsafe? ( n arr -- ? )
     [ bit-pos ] dip swap [ [ nth-unsafe ] [ bitand zero? not ] bi* ] [ 2drop f ] if* ;
@@ -38,4 +38,4 @@ PRIVATE>
 
 : marked-prime? ( n arr -- ? )
     2dup upper-bound 2 swap between? [ bounds-error ] unless
-    over { 2 3 5 } member? [ 2drop t ] [ marked-unsafe? ] if ;
\ No newline at end of file
+    over { 2 3 5 } member? [ 2drop t ] [ marked-unsafe? ] if ;
index 439d55ee8d405a2e947eff19c3067d8fd151aa66..da1c36196bef0b2649c45961340ce77634c331c5 100644 (file)
@@ -8,7 +8,7 @@ IN: math.primes.factors
 
 : count-factor ( n d -- n' c )
     [ 1 ] 2dip [ /i ] keep
-    [ dupd /mod zero? ] curry [ nip [ 1+ ] dip ] while drop
+    [ dupd /mod zero? ] curry [ nip [ 1 + ] dip ] while drop
     swap ;
 
 : write-factor ( n d -- n' d' )
@@ -39,7 +39,7 @@ PRIVATE>
 : totient ( n -- t )
     {
         { [ dup 2 < ] [ drop 0 ] }
-        [ dup unique-factors [ 1 [ 1- * ] reduce ] [ product ] bi / * ]
+        [ dup unique-factors [ 1 [ 1 - * ] reduce ] [ product ] bi / * ]
     } cond ; foldable
 
 : divisors ( n -- seq )
index c01e7377b2fcc118109eda1af6df6affcf240f04..8124fcdd24610f39670c5af67cbe9d51ba753bb1 100644 (file)
@@ -78,8 +78,8 @@ unit-test
 [ 3 ] [ 10/3 truncate ] unit-test
 [ -3 ] [ -10/3 truncate ] unit-test
 
-[ -1/2 ] [ 1/2 1- ] unit-test
-[ 3/2 ] [ 1/2 1+ ] unit-test
+[ -1/2 ] [ 1/2 1 - ] unit-test
+[ 3/2 ] [ 1/2 1 + ] unit-test
 
 [ 1.0 ] [ 0.5 1/2 + ] unit-test
 [ 1.0 ] [ 1/2 0.5 + ] unit-test
index d4f457180edc393a26510cdec3c33c9b656f8821..7da92cd1545ee596c8cf68a2a56462cfbc403b1b 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel kernel.private math math.functions math.private ;
+USING: accessors kernel kernel.private math math.functions
+math.private sequences summary ;
 IN: math.ratios
 
 : 2>fraction ( a/b c/d -- a c b d )
@@ -19,13 +20,18 @@ IN: math.ratios
 
 PRIVATE>
 
+ERROR: division-by-zero x ;
+
+M: division-by-zero summary
+    drop "Division by zero" ;
+
 M: integer /
-    dup zero? [
-        "Division by zero" throw
+    [
+        division-by-zero
     ] [
         dup 0 < [ [ neg ] bi@ ] when
         2dup gcd nip [ /i ] curry bi@ fraction>
-    ] if ;
+    ] if-zero ;
 
 M: ratio hashcode*
     nip >fraction [ hashcode ] bi@ bitxor ;
diff --git a/basis/math/vectors/specialization/specialization-tests.factor b/basis/math/vectors/specialization/specialization-tests.factor
new file mode 100644 (file)
index 0000000..5b6f1ea
--- /dev/null
@@ -0,0 +1,21 @@
+IN: math.vectors.specialization.tests
+USING: compiler.tree.debugger math.vectors tools.test kernel
+kernel.private math specialized-arrays.double
+specialized-arrays.complex-float
+specialized-arrays.float ;
+
+[ V{ t } ] [
+    [ { double-array double-array } declare distance 0.0 < not ] final-literals
+] unit-test
+
+[ V{ float } ] [
+    [ { float-array float } declare v*n norm ] final-classes
+] unit-test
+
+[ V{ number } ] [
+    [ { complex-float-array complex-float-array } declare v. ] final-classes
+] unit-test
+
+[ V{ real } ] [
+    [ { complex-float-array complex } declare v*n norm ] final-classes
+] unit-test
\ No newline at end of file
diff --git a/basis/math/vectors/specialization/specialization.factor b/basis/math/vectors/specialization/specialization.factor
new file mode 100644 (file)
index 0000000..c9db3e0
--- /dev/null
@@ -0,0 +1,112 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: words kernel make sequences effects kernel.private accessors
+combinators math math.intervals math.vectors namespaces assocs fry
+splitting classes.algebra generalizations
+compiler.tree.propagation.info ;
+IN: math.vectors.specialization
+
+SYMBOLS: -> +vector+ +scalar+ +nonnegative+ ;
+
+: signature-for-schema ( array-type elt-type schema -- signature )
+    [
+        {
+            { +vector+ [ drop ] }
+            { +scalar+ [ nip ] }
+            { +nonnegative+ [ nip ] }
+        } case
+    ] with with map ;
+
+: (specialize-vector-word) ( word array-type elt-type schema -- word' )
+    signature-for-schema
+    [ [ name>> ] [ [ name>> ] map "," join ] bi* "=>" glue f <word> ]
+    [ [ , \ declare , def>> % ] [ ] make ]
+    [ drop stack-effect ]
+    2tri
+    [ define-declared ] [ 2drop ] 3bi ;
+
+: output-infos ( array-type elt-type schema -- value-infos )
+    [
+        {
+            { +vector+ [ drop <class-info> ] }
+            { +scalar+ [ nip <class-info> ] }
+            { +nonnegative+ [ nip real class-and [0,inf] <class/interval-info> ] }
+        } case
+    ] with with map ;
+
+: record-output-signature ( word array-type elt-type schema -- word )
+    output-infos
+    [ drop ]
+    [ drop ]
+    [ [ stack-effect in>> length '[ _ ndrop ] ] dip append ] 2tri
+    "outputs" set-word-prop ;
+
+CONSTANT: vector-words
+H{
+    { [v-] { +vector+ +vector+ -> +vector+ } }
+    { distance { +vector+ +vector+ -> +nonnegative+ } }
+    { n*v { +scalar+ +vector+ -> +vector+ } }
+    { n+v { +scalar+ +vector+ -> +vector+ } }
+    { n-v { +scalar+ +vector+ -> +vector+ } }
+    { n/v { +scalar+ +vector+ -> +vector+ } }
+    { norm { +vector+ -> +nonnegative+ } }
+    { norm-sq { +vector+ -> +nonnegative+ } }
+    { normalize { +vector+ -> +vector+ } }
+    { v* { +vector+ +vector+ -> +vector+ } }
+    { v*n { +vector+ +scalar+ -> +vector+ } }
+    { v+ { +vector+ +vector+ -> +vector+ } }
+    { v+n { +vector+ +scalar+ -> +vector+ } }
+    { v- { +vector+ +vector+ -> +vector+ } }
+    { v-n { +vector+ +scalar+ -> +vector+ } }
+    { v. { +vector+ +vector+ -> +scalar+ } }
+    { v/ { +vector+ +vector+ -> +vector+ } }
+    { v/n { +vector+ +scalar+ -> +vector+ } }
+    { vceiling { +vector+ -> +vector+ } }
+    { vfloor { +vector+ -> +vector+ } }
+    { vmax { +vector+ +vector+ -> +vector+ } }
+    { vmin { +vector+ +vector+ -> +vector+ } }
+    { vneg { +vector+ -> +vector+ } }
+    { vtruncate { +vector+ -> +vector+ } }
+}
+
+SYMBOL: specializations
+
+specializations [ vector-words keys [ V{ } clone ] H{ } map>assoc ] initialize
+
+: add-specialization ( new-word signature word -- )
+    specializations get at set-at ;
+
+: word-schema ( word -- schema ) vector-words at ;
+
+: inputs ( schema -- seq ) { -> } split first ;
+
+: outputs ( schema -- seq ) { -> } split second ;
+
+: specialize-vector-word ( word array-type elt-type -- word' )
+    pick word-schema
+    [ inputs (specialize-vector-word) ]
+    [ outputs record-output-signature ] 3bi ;
+
+: input-signature ( word -- signature ) def>> first ;
+
+: specialize-vector-words ( array-type elt-type -- )
+    [ vector-words keys ] 2dip
+    '[
+        [ _ _ specialize-vector-word ] keep
+        [ dup input-signature ] dip
+        add-specialization
+    ] each ;
+
+: find-specialization ( classes word -- word/f )
+    specializations get at
+    [ first [ class<= ] 2all? ] with find
+    swap [ second ] when ;
+
+: vector-word-custom-inlining ( #call -- word/f )
+    [ in-d>> [ value-info class>> ] map ] [ word>> ] bi
+    find-specialization ;
+
+vector-words keys [
+    [ vector-word-custom-inlining ]
+    "custom-inlining" set-word-prop
+] each
\ No newline at end of file
index 14a66b5c18ab8364d2fcc56444b63b177fa3eadd..dd48525b53a1fe271896469a708b0b5054d8b959 100644 (file)
@@ -41,9 +41,13 @@ IN: math.vectors
 : set-axis ( u v axis -- w )
     [ [ zero? 2over ? ] dip swap nth ] map-index 2nip ;
 
+<PRIVATE
+
 : 2tetra@ ( p q r s t u v w quot -- )
     dup [ [ 2bi@ ] curry 4dip ] dip 2bi@ ; inline
 
+PRIVATE>
+
 : trilerp ( aaa baa aba bba aab bab abb bbb {t,u,v} -- a_tuv )
     [ first lerp ] [ second lerp ] [ third lerp ] tri-curry
     [ 2tetra@ ] [ 2bi@ ] [ call ] tri* ;
index d82abe5b07aefbcd8b48e01ddea62b2c16b34ad7..771c11c1300f34105d88b81a596c024f8469a122 100644 (file)
@@ -9,7 +9,7 @@ MEMO: fib ( m -- n )
 
 [ 89 ] [ 10 fib ] unit-test
 
-[ "USING: kernel math memoize generalizations ; IN: memoize.tests MEMO: x ( a b c d e -- f g h i j ) [ 1+ ] 4 ndip ;" eval( -- ) ] must-fail
+[ "USING: kernel math memoize generalizations ; IN: memoize.tests MEMO: x ( a b c d e -- f g h i j ) [ 1 + ] 4 ndip ;" eval( -- ) ] must-fail
 
 MEMO: see-test ( a -- b ) reverse ;
 
index 0cf7556bcd01513f23472bd3f5082cca7bb969c8..1d56c59fc0ee28d74ecb897abccc0973b7e0abf1 100755 (executable)
@@ -46,7 +46,7 @@ ERROR: end-of-stream multipart ;
     dup bytes>> length 256 < [ fill-bytes ] when ;
 
 : split-bytes ( bytes separator -- leftover-bytes safe-to-dump )
-    dupd [ length ] bi@ 1- - short cut-slice swap ;
+    dupd [ length ] bi@ 1 - - short cut-slice swap ;
 
 : dump-until-separator ( multipart -- multipart )
     dup
index 6984e0e750a11658448cde4baedf07497f7f2fc4..d7900f1dbd5e32ab5b534b35ad9dfd8e73eda488 100644 (file)
@@ -4,7 +4,7 @@ IN: models.arrow.tests
 \r
 3 <model> "x" set\r
 "x" get [ 2 * ] <arrow> dup "z" set\r
-[ 1+ ] <arrow> "y" set\r
+[ 1 + ] <arrow> "y" set\r
 [ ] [ "y" get activate-model ] unit-test\r
 [ t ] [ "z" get "x" get connections>> memq? ] unit-test\r
 [ 7 ] [ "y" get value>> ] unit-test\r
diff --git a/basis/models/illusion/authors.txt b/basis/models/illusion/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/basis/models/illusion/illusion.factor b/basis/models/illusion/illusion.factor
new file mode 100644 (file)
index 0000000..0016979
--- /dev/null
@@ -0,0 +1,15 @@
+USING: accessors models models.arrow inverse kernel ;
+IN: models.illusion
+
+TUPLE: illusion < arrow ;
+
+: <illusion> ( model quot -- illusion )
+    illusion new V{ } clone >>connections V{ } clone >>dependencies 0 >>ref
+    swap >>quot over >>model [ add-dependency ] keep ;
+
+: <activated-illusion> ( model quot -- illusion ) <illusion> dup activate-model ;
+
+: backtalk ( value object -- )
+   [ quot>> [undo] call( a -- b ) ] [ model>> ] bi set-model ;
+
+M: illusion update-model ( model -- ) [ [ value>> ] keep backtalk ] with-locked-model ;
\ No newline at end of file
diff --git a/basis/models/illusion/summary.txt b/basis/models/illusion/summary.txt
new file mode 100644 (file)
index 0000000..8ea7cf1
--- /dev/null
@@ -0,0 +1 @@
+Two Way Arrows
\ No newline at end of file
index 19b478eaf9b696da29bbd6e4b0bb1cef2794c57a..27504bc0fa769d7e9b014aa6c9a424f286abbee2 100644 (file)
@@ -32,10 +32,10 @@ GENERIC: model-activated ( model -- )
 M: model model-activated drop ;
 
 : ref-model ( model -- n )
-    [ 1+ ] change-ref ref>> ;
+    [ 1 + ] change-ref ref>> ;
 
 : unref-model ( model -- n )
-    [ 1- ] change-ref ref>> ;
+    [ 1 - ] change-ref ref>> ;
 
 : activate-model ( model -- )
     dup ref-model 1 = [
index 84ac738126b973af1b9be33aba8b556d1a246af2..f52dc8a3b0a3c29f887936acf2cc9c4a121a694c 100644 (file)
@@ -24,7 +24,7 @@ IN: models.product.tests
 \r
 TUPLE: an-observer { i integer } ;\r
 \r
-M: an-observer model-changed nip [ 1+ ] change-i drop ;\r
+M: an-observer model-changed nip [ 1 + ] change-i drop ;\r
 \r
 [ 1 0 ] [\r
     [let* | m1 [ 1 <model> ]\r
@@ -42,4 +42,4 @@ M: an-observer model-changed nip [ 1+ ] change-i drop ;
         o1 i>>\r
         o2 i>>\r
     ]\r
-] unit-test
\ No newline at end of file
+] unit-test\r
index 2e8f8eb4c497d1fb9252ee15b1b554f2d6645a6f..c0d109e3c5a0e4286f0e018a1072f5c3f6b13913 100644 (file)
@@ -44,7 +44,7 @@ PRIVATE>
 : parse-multiline-string ( end-text -- str )
     [
         lexer get
-        [ 1+ swap (parse-multiline-string) ]
+        [ 1 + swap (parse-multiline-string) ]
         change-column drop
     ] "" make ;
 
index 9aa4ee429d869ab3882277ad943e3fb819e082fe..6292a683e3066d4e44d928cff397ceb2a27018c5 100644 (file)
@@ -25,7 +25,7 @@ reset-gl-function-number-counter
 
 : gl-function-number ( -- n )
     +gl-function-number-counter+ get-global
-    dup 1+ +gl-function-number-counter+ set-global ;
+    dup 1 + +gl-function-number-counter+ set-global ;
 
 : gl-function-pointer ( names n -- funptr )
     gl-function-context 2array dup +gl-function-pointers+ get-global at
index 93f407681e04f418c2ea02c979984cba7b482a28..850b585190646384904f7ec17f1785f7c593dc61 100644 (file)
@@ -51,7 +51,7 @@ PRIVATE>
   dup zero? [
     2drop epsilon
   ] [
-    [ exactly-n ] [ 1- at-most-n ] 2bi 2choice
+    [ exactly-n ] [ 1 - at-most-n ] 2bi 2choice
   ] if ;
 
 : at-least-n ( parser n -- parser' )
index 12e6d59fc01885484737f7ea572688b851df947d..42530151be51f01aa13303e5908f513c3ee5a4c9 100644 (file)
@@ -329,7 +329,7 @@ SYMBOL: id
 : next-id ( -- n )
   #! Return the next unique id for a parser
   id get-global [
-    dup 1+ id set-global
+    dup 1 + id set-global
   ] [
     1 id set-global 0
   ] if* ;
index a761e2d327707a67680c260094a8c7fc21221bc2..cb2abd801568773df3bcb066be453b4ef2d678dc 100644 (file)
@@ -4,5 +4,5 @@ USING: layouts kernel parser math ;
 IN: persistent.hashtables.config
 
 : radix-bits ( -- n ) << cell 4 = 4 5 ? parsed >> ; foldable
-: radix-mask ( -- n ) radix-bits 2^ 1- ; foldable
-: full-bitmap-mask ( -- n ) radix-bits 2^ 2^ 1- ; inline
+: radix-mask ( -- n ) radix-bits 2^ 1 - ; foldable
+: full-bitmap-mask ( -- n ) radix-bits 2^ 2^ 1 - ; inline
index 67886312c67379383fd7504e7e36178fc2ea5c7b..0179216e62a7acc1f0a474e613695316dac56150 100644 (file)
@@ -33,7 +33,7 @@ M: persistent-hash pluck-at
     {
         { [ 2dup root>> eq? ] [ nip ] }
         { [ over not ] [ 2drop T{ persistent-hash } ] }
-        [ count>> 1- persistent-hash boa ]
+        [ count>> 1 - persistent-hash boa ]
     } cond ;
 
 M: persistent-hash >alist [ root>> >alist% ] { } make ;
index f231043274839d171ee0bf6ed39bea0fc357a621..4c764eba9331d2bbdfeeb407e41758b054a51ccd 100644 (file)
@@ -7,7 +7,7 @@ persistent.hashtables.config
 persistent.hashtables.nodes ;
 IN: persistent.hashtables.nodes.bitmap
 
-: index ( bit bitmap -- n ) [ 1- ] dip bitand bit-count ; inline
+: index ( bit bitmap -- n ) [ 1 - ] dip bitand bit-count ; inline
 
 M:: bitmap-node (entry-at) ( key hashcode bitmap-node -- entry )
     [let* | shift [ bitmap-node shift>> ]
index 5927171aa3b3d13e54301d65bf104e8226f5bd39..2527959f325f0317cd6540a0c3ab2a625e45f2fe 100644 (file)
@@ -55,13 +55,13 @@ M: persistent-vector nth-unsafe
     [ 1array ] dip node boa ;
 
 : 2node ( first second -- node )
-    [ 2array ] [ drop level>> 1+ ] 2bi node boa ;
+    [ 2array ] [ drop level>> 1 + ] 2bi node boa ;
 
 : new-child ( new-child node -- node' expansion/f )
     dup full? [ tuck level>> 1node ] [ node-add f ] if ;
 
 : new-last ( val seq -- seq' )
-    [ length 1- ] keep new-nth ;
+    [ length 1 - ] keep new-nth ;
 
 : node-set-last ( child node -- node' )
     clone [ new-last ] change-children ;
@@ -86,7 +86,7 @@ M: persistent-vector ppush ( val pvec -- pvec' )
     clone
     dup tail>> full?
     [ ppush-new-tail ] [ ppush-tail ] if
-    [ 1+ ] change-count ;
+    [ 1 + ] change-count ;
 
 : node-set-nth ( val i node -- node' )
     clone [ new-nth ] change-children ;
@@ -166,7 +166,7 @@ M: persistent-vector ppop ( pvec -- pvec' )
                 clone
                 dup tail>> children>> length 1 >
                 [ ppop-tail ] [ ppop-new-tail ] if
-            ] dip 1- >>count
+            ] dip 1 - >>count
         ]
     } case ;
 
index 4765df10d74f9501407abacfcf89145353c8b38b..2e1a47b9512d50b75f68667c123483d1a3e84407 100644 (file)
@@ -7,7 +7,7 @@ IN: porter-stemmer
     ] [
         CHAR: y = [
             over zero?
-            [ 2drop t ] [ [ 1- ] dip consonant? not ] if
+            [ 2drop t ] [ [ 1 - ] dip consonant? not ] if
         ] [
             2drop t
         ] if
@@ -15,18 +15,18 @@ IN: porter-stemmer
 
 : skip-vowels ( i str -- i str )
     2dup bounds-check? [
-        2dup consonant? [ [ 1+ ] dip skip-vowels ] unless
+        2dup consonant? [ [ 1 + ] dip skip-vowels ] unless
     ] when ;
 
 : skip-consonants ( i str -- i str )
     2dup bounds-check? [
-        2dup consonant? [ [ 1+ ] dip skip-consonants ] when
+        2dup consonant? [ [ 1 + ] dip skip-consonants ] when
     ] when ;
 
 : (consonant-seq) ( n i str -- n )
     skip-vowels
     2dup bounds-check? [
-        [ 1+ ] [ 1+ ] [ ] tri* skip-consonants [ 1+ ] dip
+        [ 1 + ] [ 1 + ] [ ] tri* skip-consonants [ 1 + ] dip
         (consonant-seq)
     ] [
         2drop
@@ -42,7 +42,7 @@ IN: porter-stemmer
     over 1 < [
         2drop f
     ] [
-        2dup nth [ over 1- over nth ] dip = [
+        2dup nth [ over 1 - over nth ] dip = [
             consonant?
         ] [
             2drop f
@@ -92,7 +92,7 @@ IN: porter-stemmer
         { [ "bl" ?tail ] [ "ble" append ] }
         { [ "iz" ?tail ] [ "ize" append ] }
         {
-            [ dup length 1- over double-consonant? ]
+            [ dup length 1 - over double-consonant? ]
             [ dup "lsz" last-is? [ but-last-slice ] unless ]
         }
         {
@@ -206,7 +206,7 @@ IN: porter-stemmer
 : ll->l ( str -- newstr )
     {
         { [ dup last CHAR: l = not ] [ ] }
-        { [ dup length 1- over double-consonant? not ] [ ] }
+        { [ dup length 1 - over double-consonant? not ] [ ] }
         { [ dup consonant-seq 1 > ] [ but-last-slice ] }
         [ ]
     } cond ;
index 99913a803abaaa5788df469c15b6c38743759458..718de7e84c38174525ce4f0e5cf8bebf1607d798 100644 (file)
@@ -73,7 +73,7 @@ SYMBOL: ->
 
 : remove-breakpoints ( quot pos -- quot' )
     over quotation? [
-        1+ cut [ (remove-breakpoints) ] bi@
+        1 + cut [ (remove-breakpoints) ] bi@
         [ -> ] glue 
     ] [
         drop
@@ -109,4 +109,4 @@ SYMBOL: pprint-string-cells?
                 ] each
             ] with-row
         ] each
-    ] tabular-output nl ;
\ No newline at end of file
+    ] tabular-output nl ;
index 0e0c7afb82ad0041c9a4e370f665dfeabed0f2e0..040b6d8f7c23723f365e04e8bc002d56bb364cb7 100644 (file)
@@ -44,7 +44,7 @@ TUPLE: pprinter last-newline line-count indent ;
         line-limit? [
             "..." write pprinter get return
         ] when
-        pprinter get [ 1+ ] change-line-count drop
+        pprinter get [ 1 + ] change-line-count drop
         nl do-indent
     ] if ;
 
@@ -209,7 +209,7 @@ M: block short-section ( block -- )
 TUPLE: text < section string ;
 
 : <text> ( string style -- text )
-    over length 1+ \ text new-section
+    over length 1 + \ text new-section
         swap >>style
         swap >>string ;
 
@@ -310,8 +310,8 @@ SYMBOL: next
 : group-flow ( seq -- newseq )
     [
         dup length [
-            2dup 1- swap ?nth prev set
-            2dup 1+ swap ?nth next set
+            2dup 1 - swap ?nth prev set
+            2dup 1 + swap ?nth next set
             swap nth dup split-before dup , split-after
         ] with each
     ] { } make { t } split harvest ;
index e82789ccbf3602893a7dcafcd26b2d825e669323..53af3a5178ab5655cb47e6342a7ef453a4d40465 100644 (file)
@@ -29,7 +29,7 @@ IN: quoted-printable
 
 : take-some ( seqs -- seqs seq )
     0 over [ length + dup 76 >= ] find drop nip
-    [ 1- cut-slice swap ] [ f swap ] if* concat ;
+    [ 1 - cut-slice swap ] [ f swap ] if* concat ;
 
 : divide-lines ( strings -- strings )
     [ dup ] [ take-some ] produce nip ;
index dadf93fd439f09593663e2459c89f8352a0ce483..e6661dc07886eab2d5ff393f23712bc98908e8b7 100644 (file)
@@ -8,4 +8,4 @@ M: random-dummy seed-random ( seed obj -- )
     (>>i) ;
 
 M: random-dummy random-32* ( obj -- r )
-    [ dup 1+ ] change-i drop ;
+    [ dup 1 + ] change-i drop ;
index a02abbb8ac8262d03dd51e933070f0d724955cc0..966c5b2e608e7801fbd9598f6064a519d10bfd23 100644 (file)
@@ -17,7 +17,7 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
 
 : y ( n seq -- y )
     [ nth-unsafe 31 mask-bit ]
-    [ [ 1+ ] [ nth-unsafe ] bi* 31 bits ] 2bi bitor ; inline
+    [ [ 1 + ] [ nth-unsafe ] bi* 31 bits ] 2bi bitor ; inline
 
 : mt[k] ( offset n seq -- )
     [
@@ -30,16 +30,16 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
     [
         seq>>
         [ [ n m - ] dip '[ [ m ] dip _ mt[k] ] each ]
-        [ [ m 1- ] dip '[ [ m n - ] [ n m - + ] bi* _ mt[k] ] each ]
+        [ [ m 1 - ] dip '[ [ m n - ] [ n m - + ] bi* _ mt[k] ] each ]
         bi
     ] [ 0 >>i drop ] bi ; inline
 
 : init-mt-formula ( i seq -- f(seq[i]) )
-    dupd nth dup -30 shift bitxor 1812433253 * + 1+ 32 bits ; inline
+    dupd nth dup -30 shift bitxor 1812433253 * + 1 + 32 bits ; inline
 
 : init-mt-rest ( seq -- )
-    n 1- swap '[
-        _ [ init-mt-formula ] [ [ 1+ ] dip set-nth ] 2bi
+    n 1 - swap '[
+        _ [ init-mt-formula ] [ [ 1 + ] dip set-nth ] 2bi
     ] each ; inline
 
 : init-mt-seq ( seed -- seq )
@@ -67,7 +67,7 @@ M: mersenne-twister seed-random ( mt seed -- )
 M: mersenne-twister random-32* ( mt -- r )
     [ next-index ]
     [ seq>> nth-unsafe mt-temper ]
-    [ [ 1+ ] change-i drop ] tri ;
+    [ [ 1 + ] change-i drop ] tri ;
 
 [
     [ 32 random-bits ] with-system-random
index 1962857d573181a1da1b5a2a3291d2825a8ae8cb..4c94e87928cebe5acaa9efe2e959207c1f42d45f 100755 (executable)
@@ -39,7 +39,7 @@ M: f random-32* ( obj -- * ) no-random-number-generator ;
 <PRIVATE
 
 : random-integer ( n -- n' )
-    dup log2 7 + 8 /i 1+
+    dup log2 7 + 8 /i 1 +
     [ random-bytes >byte-array byte-array>bignum ]
     [ 3 shift 2^ ] bi / * >integer ;
 
@@ -57,7 +57,7 @@ PRIVATE>
 
 : randomize ( seq -- seq )
     dup length [ dup 1 > ]
-    [ [ iota random ] [ 1- ] bi [ pick exchange ] keep ]
+    [ [ iota random ] [ 1 - ] bi [ pick exchange ] keep ]
     while drop ;
 
 : delete-random ( seq -- elt )
index 2916ef7c32be08352ba6ed3836443e663e37b8a3..90ab3342f2ea0eda65f26eae9184f126ebefb4d8 100644 (file)
@@ -56,7 +56,7 @@ M: at-least <times>
 : to-times ( term n -- ast )
     dup zero?
     [ 2drop epsilon ]
-    [ dupd 1- to-times 2array <concatenation> <maybe> ]
+    [ dupd 1 - to-times 2array <concatenation> <maybe> ]
     if ;
 
 M: from-to <times>
index 548273486589cfbcbcc22a96a020be4c4542fd1b..d8940bb829a3afc70848194901b8a795d36d8999 100644 (file)
@@ -35,13 +35,13 @@ M: $ question>quot
     drop [ { [ length = ] [ ?nth "\r\n" member? ] } 2|| ] ;
 
 M: ^ question>quot
-    drop [ { [ drop zero? ] [ [ 1- ] dip ?nth "\r\n" member? ] } 2|| ] ;
+    drop [ { [ drop zero? ] [ [ 1 - ] dip ?nth "\r\n" member? ] } 2|| ] ;
 
 M: $unix question>quot
     drop [ { [ length = ] [ ?nth CHAR: \n = ] } 2|| ] ;
 
 M: ^unix question>quot
-    drop [ { [ drop zero? ] [ [ 1- ] dip ?nth CHAR: \n = ] } 2|| ] ;
+    drop [ { [ drop zero? ] [ [ 1 - ] dip ?nth CHAR: \n = ] } 2|| ] ;
 
 M: word-break question>quot
     drop [ word-break-at? ] ;
index 21439640fe18f6934606946006062c301265ab14..4318986813d5eeaf3b9eca90b163112e823ac0cd 100644 (file)
@@ -25,7 +25,7 @@ M: lookahead question>quot ! Returns ( index string -- ? )
 M: lookbehind question>quot ! Returns ( index string -- ? )
     term>> <reversed-option>
     ast>dfa dfa>reverse-shortest-word
-    '[ [ 1- ] dip f _ execute ] ;
+    '[ [ 1 - ] dip f _ execute ] ;
 
 : check-string ( string -- string )
     ! Make this configurable
@@ -53,12 +53,12 @@ PRIVATE>
 :: (next-match) ( i string regexp quot: ( i string regexp -- j ) reverse? -- i start end ? )
     i string regexp quot call dup [| j |
         j i j
-        reverse? [ swap [ 1+ ] bi@ ] when
+        reverse? [ swap [ 1 + ] bi@ ] when
         string
     ] [ drop f f f f ] if ; inline
 
 : search-range ( i string reverse? -- seq )
-    [ drop dup 1+ -1 ] [ length 1 ] if range boa ; inline
+    [ drop dup 1 + -1 ] [ length 1 ] if range boa ; inline
 
 :: next-match ( i string regexp quot: ( i string regexp -- j ) reverse? -- i start end ? )
     f f f f
@@ -93,7 +93,7 @@ PRIVATE>
     [ subseq ] map-matches ;
 
 : count-matches ( string regexp -- n )
-    [ 0 ] 2dip [ 3drop 1+ ] each-match ;
+    [ 0 ] 2dip [ 3drop 1 + ] each-match ;
 
 <PRIVATE
 
@@ -192,7 +192,7 @@ PRIVATE>
     dup skip-blank [
         [ index-from ] 2keep
         [ swapd subseq ]
-        [ 2drop 1+ ] 3bi
+        [ 2drop 1 + ] 3bi
     ] change-lexer-column ;
 
 : parse-noblank-token ( lexer -- str/f )
@@ -220,4 +220,4 @@ USING: vocabs vocabs.loader ;
 
 "prettyprint" vocab [
     "regexp.prettyprint" require
-] when
\ No newline at end of file
+] when
index 93f9727f75db1edc772a8d2c5b3e66029198dce8..730689eb4ff46f8de5e253b6c7c06a5893b4a520 100644 (file)
@@ -18,8 +18,8 @@ PRIVATE>
 M: complex-sequence length
     seq>> length -1 shift ;
 M: complex-sequence nth-unsafe
-    complex@ [ nth-unsafe ] [ [ 1+ ] dip nth-unsafe ] 2bi rect> ;
+    complex@ [ nth-unsafe ] [ [ 1 + ] dip nth-unsafe ] 2bi rect> ;
 M: complex-sequence set-nth-unsafe
     complex@
     [ [ real-part      ] [    ] [ ] tri* set-nth-unsafe ]
-    [ [ imaginary-part ] [ 1+ ] [ ] tri* set-nth-unsafe ] 3bi ;
+    [ [ imaginary-part ] [ 1 + ] [ ] tri* set-nth-unsafe ] 3bi ;
index b7e395fa359ebcc38ced50e47646de13135f6f4e..2b4294bda4ca9250643d255b26c24be28945bcc5 100644 (file)
@@ -47,11 +47,11 @@ M: id equal? over id? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
 ! The last case is needed because a very large number would
 ! otherwise be confused with a small number.
 : serialize-cell ( n -- )
-    dup zero? [ drop 0 write1 ] [
+    [ 0 write1 ] [
         dup HEX: 7e <= [
             HEX: 80 bitor write1
         ] [
-            dup log2 8 /i 1+ 
+            dup log2 8 /i 1 
             dup HEX: 7f >= [
                 HEX: ff write1
                 dup serialize-cell
@@ -60,7 +60,7 @@ M: id equal? over id? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
             ] if
             >be write
         ] if
-    ] if ;
+    ] if-zero ;
 
 : deserialize-cell ( -- n )
     read1 {
@@ -79,12 +79,12 @@ M: f (serialize) ( obj -- )
     drop CHAR: n write1 ;
 
 M: integer (serialize) ( obj -- )
-    dup zero? [
-        drop CHAR: z write1
+    [
+        CHAR: z write1
     ] [
         dup 0 < [ neg CHAR: m ] [ CHAR: p ] if write1
         serialize-cell
-    ] if ;
+    ] if-zero ;
 
 M: float (serialize) ( obj -- )
     CHAR: F write1
@@ -295,4 +295,4 @@ PRIVATE>
     binary [ deserialize ] with-byte-reader ;
 
 : object>bytes ( obj -- bytes )
-    binary [ serialize ] with-byte-writer ;
\ No newline at end of file
+    binary [ serialize ] with-byte-writer ;
index 8bc12e270441894929fa3300274244e8ca190181..78b1493920cca026cde6aa54b8e9085f3e5cb462 100644 (file)
@@ -4,9 +4,9 @@ IN: sorting.insertion
 <PRIVATE
 :: insert ( seq quot: ( elt -- elt' ) n -- )
     n zero? [
-        n n 1- [ seq nth quot call ] bi@ >= [
-            n n 1- seq exchange
-            seq quot n 1- insert
+        n n 1 - [ seq nth quot call ] bi@ >= [
+            n n 1 - seq exchange
+            seq quot n 1 - insert
         ] unless
     ] unless ; inline recursive
 PRIVATE>
index 02e47ca140c00da8bb4fbcd32a637b7487957f25..95324bd2d58294f2697c9884c5870c49f2f48bc5 100644 (file)
@@ -11,61 +11,14 @@ HINTS: <double-array> { 2 } { 3 } ;
 
 HINTS: (double-array) { 2 } { 3 } ;
 
-HINTS: vneg { array } { double-array } ;
-HINTS: v*n { array object } { double-array float } ;
-HINTS: n*v { array object } { float double-array } ;
-HINTS: v/n { array object } { double-array float } ;
-HINTS: n/v { object array } { float double-array } ;
-HINTS: v+ { array array } { double-array double-array } ;
-HINTS: v- { array array } { double-array double-array } ;
-HINTS: v* { array array } { double-array double-array } ;
-HINTS: v/ { array array } { double-array double-array } ;
-HINTS: vmax { array array } { double-array double-array } ;
-HINTS: vmin { array array } { double-array double-array } ;
-HINTS: v. { array array } { double-array double-array } ;
-HINTS: norm-sq { array } { double-array } ;
-HINTS: norm { array } { double-array } ;
-HINTS: normalize { array } { double-array } ;
-HINTS: distance { array array } { double-array double-array } ;
-
 ! Type functions
 USING: words classes.algebra compiler.tree.propagation.info
 math.intervals ;
 
-{ v+ v- v* v/ vmax vmin } [
-    [
-        [ class>> double-array class<= ] both?
-        double-array object ? <class-info>
-    ] "outputs" set-word-prop
-] each
-
-{ n*v n/v } [
-    [
-        nip class>> double-array class<= double-array object ? <class-info>
-    ] "outputs" set-word-prop
-] each
-
-{ v*n v/n } [
-    [
-        drop class>> double-array class<= double-array object ? <class-info>
-    ] "outputs" set-word-prop
-] each
-
-{ vneg normalize } [
-    [
-        class>> double-array class<= double-array object ? <class-info>
-    ] "outputs" set-word-prop
-] each
-
 \ norm-sq [
     class>> double-array class<= [ float 0. 1/0. [a,b] <class/interval-info> ] [ object-info ] if
 ] "outputs" set-word-prop
 
-\ v. [
-    [ class>> double-array class<= ] both?
-    float object ? <class-info>
-] "outputs" set-word-prop
-
 \ distance [
     [ class>> double-array class<= ] both?
     [ float 0. 1/0. [a,b] <class/interval-info> ] [ object-info ] if
index c6641463f90fabcf7fa7ee1211633c5d3587bf4a..1c855be1a485c84144538cdcc51eea63d683e04e 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: functors sequences sequences.private prettyprint.custom
-kernel words classes math parser alien.c-types byte-arrays
-accessors summary ;
+kernel words classes math math.vectors.specialization parser
+alien.c-types byte-arrays accessors summary ;
 IN: specialized-arrays.functor
 
 ERROR: bad-byte-array-length byte-array type ;
@@ -74,4 +74,6 @@ SYNTAX: A{ \ } [ >A ] parse-literal ;
 
 INSTANCE: A sequence
 
+A T c-type-boxed-class specialize-vector-words
+
 ;FUNCTOR
index 088de527665d0667adbae979b806174237314f01..3641345a3ebd2bd9179e1224d9e8df1dbf69d146 100644 (file)
@@ -29,10 +29,10 @@ PRIVATE>
             [ length ] [ ] [ <circular> 1 over change-circular-start ] tri
             [ @ not [ , ] [ drop ] if ] 3each
         ] { } make
-        dup empty? [ over length 1- prefix ] when -1 prefix 2 clump
+        dup empty? [ over length 1 - prefix ] when -1 prefix 2 clump
         swap
     ] dip
-    '[ first2 [ 1+ ] bi@ _ _ boa ] map ; inline
+    '[ first2 [ 1 + ] bi@ _ _ boa ] map ; inline
 
 PRIVATE>
 
@@ -64,6 +64,6 @@ TUPLE: upward-slice < slice ;
             drop
             [ downward-slices ]
             [ stable-slices ]
-            [ upward-slices ] tri 3append [ [ from>> ] compare ] sort
+            [ upward-slices ] tri 3append [ from>> ] sort-with
         ]
     } case ;
index 338b052316146c9fbd19d2b44fd8deb0fc2efd08..5411c885ad7165f0a7a44ea55e2c879df6658c79 100755 (executable)
@@ -5,7 +5,7 @@ parser sequences strings vectors words quotations effects classes
 continuations assocs combinators compiler.errors accessors math.order
 definitions sets hints macros stack-checker.state
 stack-checker.visitor stack-checker.errors stack-checker.values
-stack-checker.recursive-state ;
+stack-checker.recursive-state summary ;
 IN: stack-checker.backend
 
 : push-d ( obj -- ) meta-d push ;
@@ -98,8 +98,10 @@ M: object apply-object push-literal ;
 : time-bomb ( error -- )
     '[ _ throw ] infer-quot-here ;
 
-: bad-call ( -- )
-    "call must be given a callable" time-bomb ;
+ERROR: bad-call obj ;
+
+M: bad-call summary
+    drop "call must be given a callable" ;
 
 : infer-literal-quot ( literal -- )
     dup recursive-quotation? [
@@ -110,7 +112,7 @@ M: object apply-object push-literal ;
             [ [ recursion>> ] keep add-local-quotation ]
             bi infer-quot
         ] [
-            drop bad-call
+            value>> \ bad-call boa time-bomb
         ] if
     ] if ;
 
index 6959e3245224ce3ccc094c0572ff0b80a72e31bb..0edbe5e53dc87a5e0a22f6223cd1bd6051bd962c 100644 (file)
@@ -134,13 +134,17 @@ M: object infer-call*
 
 \ compose [ infer-compose ] "special" set-word-prop
 
+ERROR: bad-executable obj ;
+
+M: bad-executable summary
+    drop "execute must be given a word" ;
+
 : infer-execute ( -- )
     pop-literal nip
     dup word? [
         apply-object
     ] [
-        drop
-        "execute must be given a word" time-bomb
+        \ bad-executable boa time-bomb
     ] if ;
 
 \ execute [ infer-execute ] "special" set-word-prop
@@ -149,7 +153,7 @@ M: object infer-call*
 
 : infer-<tuple-boa> ( -- )
     \ <tuple-boa>
-    peek-d literal value>> second 1+ { tuple } <effect>
+    peek-d literal value>> second 1 + { tuple } <effect>
     apply-word/effect ;
 
 \ <tuple-boa> [ infer-<tuple-boa> ] "special" set-word-prop
diff --git a/basis/stuff.factor b/basis/stuff.factor
deleted file mode 100644 (file)
index 2e5fa2d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-
-: spill-integer-base ( -- n )
-    stack-frame get spill-counts>> double-float-regs swap at
-    double-float-regs reg-size * ;
-
-: spill-integer@ ( n -- offset )
-    cells spill-integer-base + param@ ;
-
-: spill-float@ ( n -- offset )
-    double-float-regs reg-size * param@ ;
-
-: (stack-frame-size) ( stack-frame -- n )
-    [
-        {
-            [ spill-counts>> [ swap reg-size * ] { } assoc>map sum ]
-            [ gc-roots>> cells ]
-            [ params>> ]
-            [ return>> ]
-        } cleave
-    ] sum-outputs ;
\ No newline at end of file
index f4bd56348130f88a8b2a3c74ca7d13ef9892075d..931cb36ea949b8c394164e3e85d9bbdaa34b09bb 100755 (executable)
@@ -17,7 +17,7 @@ IN: suffix-arrays
 
 : from-to ( index begin suffix-array -- from/f to/f )
     swap '[ _ head? not ]
-    [ find-last-from drop dup [ 1+ ] when ]
+    [ find-last-from drop dup [ 1 + ] when ]
     [ find-from drop ] 3bi ;
 
 : <funky-slice> ( from/f to/f seq -- slice )
index 79aef90bead4b36f435a93d3fa973337b245315e..c21e9e0c60ea9b90244de909042d0c0b79054af4 100644 (file)
@@ -10,7 +10,7 @@ IN: tools.annotations.tests
 ! erg's bug
 GENERIC: some-generic ( a -- b )
 
-M: integer some-generic 1+ ;
+M: integer some-generic 1 + ;
 
 [ 4 ] [ 3 some-generic ] unit-test
 
@@ -18,7 +18,7 @@ M: integer some-generic 1+ ;
 
 [ 4 ] [ 3 some-generic ] unit-test
 
-[ ] [ "IN: tools.annotations.tests USE: math M: integer some-generic 1- ;" eval( -- ) ] unit-test
+[ ] [ "IN: tools.annotations.tests USE: math M: integer some-generic 1 - ;" eval( -- ) ] unit-test
 
 [ 2 ] [ 3 some-generic ] unit-test
 
@@ -59,4 +59,4 @@ M: object my-generic ;
 : some-code ( -- )
     f my-generic drop ;
 
-[ ] [ some-code ] unit-test
\ No newline at end of file
+[ ] [ some-code ] unit-test
index fb664c495c35f5e5553b0d465d58e79c5eca4d32..7b9c8b43bc167bdcbc8a099934e12035d384ebd7 100644 (file)
@@ -9,7 +9,7 @@ IN: tools.completion
 :: (fuzzy) ( accum i full ch -- accum i full ? )
     ch i full index-from [
         :> i i accum push
-        accum i 1+ full t
+        accum i 1 + full t
     ] [
         f -1 full f
     ] if* ;
@@ -23,7 +23,7 @@ IN: tools.completion
         [
             2dup number=
             [ drop ] [ nip V{ } clone pick push ] if
-            1+
+            1 +
         ] keep pick last push
     ] each ;
 
@@ -33,9 +33,9 @@ IN: tools.completion
 : score-1 ( i full -- n )
     {
         { [ over zero? ] [ 2drop 10 ] }
-        { [ 2dup length 1- number= ] [ 2drop 4 ] }
-        { [ 2dup [ 1- ] dip nth Letter? not ] [ 2drop 10 ] }
-        { [ 2dup [ 1+ ] dip nth Letter? not ] [ 2drop 4 ] }
+        { [ 2dup length 1 - number= ] [ 2drop 4 ] }
+        { [ 2dup [ 1 - ] dip nth Letter? not ] [ 2drop 10 ] }
+        { [ 2dup [ 1 + ] dip nth Letter? not ] [ 2drop 4 ] }
         [ 2drop 1 ]
     } cond ;
 
index 270b55fda6a1f59754d8e5fc357e95c8aba9292e..35e58a0aa71588b70567a3fe2f44c356e20ba782 100755 (executable)
@@ -293,6 +293,8 @@ IN: tools.deploy.shaker
 
             { } { "math.partial-dispatch" } strip-vocab-globals %
 
+            { } { "math.vectors.specialization" } strip-vocab-globals %
+
             { } { "peg" } strip-vocab-globals %
         ] when
 
index b53d4ef7a2a6578caa20fe9ba4ef0562cded2449..963ea7592ccec5ddd5709f7ced0211f36e4c5cb0 100644 (file)
@@ -14,14 +14,16 @@ M: source-file-error error-help error>> error-help ;
 
 CONSTANT: +listener-input+ "<Listener input>"
 
-M: source-file-error summary
+: error-location ( error -- string )
     [
-        [ file>> [ % ": " % ] [ +listener-input+ % ] if* ]
-        [ line#>> [ # ] when* ] bi
+        [ file>> [ % ] [ +listener-input+ % ] if* ]
+        [ line#>> [ ": " % # ] when* ] bi
     ] "" make ;
 
+M: source-file-error summary error>> summary ;
+
 M: source-file-error error.
-    [ summary print nl ]
+    [ error-location print nl ]
     [ asset>> [ "Asset: " write short. nl ] when* ]
     [ error>> error. ]
     tri ;
index 7b07311ded119dc7923ef76212d7ef1339540132..42721bada1da85578bab3879088755eb35623eeb 100644 (file)
@@ -80,7 +80,7 @@ MACRO: <experiment> ( word -- )
     '[ _ ndup _ narray _ prefix ] ;
 
 : experiment. ( seq -- )
-    [ first write ": " write ] [ rest . ] bi ;
+    [ first write ": " write ] [ rest . flush ] bi ;
 
 :: experiment ( word: ( -- error ? ) line# -- )
     word <experiment> :> e
@@ -130,7 +130,7 @@ TEST: must-fail
 
 M: test-failure error. ( error -- )
     {
-        [ summary print nl ]
+        [ error-location print nl ]
         [ asset>> [ experiment. nl ] when* ]
         [ error>> error. ]
         [ traceback-button. ]
index 03a86fe25f6f46bedaf86484700b11f6dcd7f644..f23989a1e264876164e63cced6eaefc00cc4e7c5 100755 (executable)
@@ -202,7 +202,7 @@ PRIVATE>
     lf>crlf [
         utf16n string>alien
         EmptyClipboard win32-error=0/f
-        GMEM_MOVEABLE over length 1+ GlobalAlloc
+        GMEM_MOVEABLE over length 1 + GlobalAlloc
             dup win32-error=0/f
     
         dup GlobalLock dup win32-error=0/f
index aa2b9ca58c58a18541aea7fa2693e24950feaa9e..b1b82a054235513845001cbdbad6801ec7a28e8a 100755 (executable)
@@ -495,7 +495,7 @@ TUPLE: multiline-editor < editor ;
 
 <PRIVATE
 
-: page-elt ( editor -- editor element ) dup visible-lines 1- <page-elt> ;
+: page-elt ( editor -- editor element ) dup visible-lines 1 - <page-elt> ;
 
 PRIVATE>
 
@@ -526,7 +526,7 @@ PRIVATE>
 
 : this-line-and-next ( document line -- start end )
     [ nip 0 swap 2array ]
-    [ [ nip 1+ ] [ 1+ swap doc-line length ] 2bi 2array ]
+    [ [ nip 1 + ] [ 1 + swap doc-line length ] 2bi 2array ]
     2bi ;
 
 : last-line? ( document line -- ? )
index 34f46865187081aebe5bcfcbb54538174574da7f..168fb4bb114473387077718b3f9978ce70d1f821 100644 (file)
@@ -23,7 +23,7 @@ M: glue pref-dim* drop { 0 0 } ;
     [ '[ [ dim>> ] [ gap>> ] [ filled-cell>> ] tri _ tri@ ] dip ] dip call ; inline
 
 : available-space ( pref-dim gap dims -- avail )
-    length 1+ * [-] ; inline
+    length 1 + * [-] ; inline
 
 : -center) ( pref-dim gap filled-cell dims -- )
     [ nip available-space ] 2keep [ remove-nth sum [-] ] 2keep set-nth ; inline
@@ -46,4 +46,4 @@ M: frame layout*
     [ <frame-grid> ] dip new-grid ; inline
 
 : <frame> ( cols rows -- frame )
-    frame new-frame ;
\ No newline at end of file
+    frame new-frame ;
index ade5c8101ebae19ba6f2145adace76f9a15e72e7..d7f77d9e549301c9bd19ce58b763ac47165eda80 100644 (file)
@@ -78,10 +78,10 @@ TUPLE: mock-gadget < gadget graft-called ungraft-called ;
     mock-gadget new 0 >>graft-called 0 >>ungraft-called ;
 
 M: mock-gadget graft*
-    [ 1+ ] change-graft-called drop ;
+    [ 1 + ] change-graft-called drop ;
 
 M: mock-gadget ungraft*
-    [ 1+ ] change-ungraft-called drop ;
+    [ 1 + ] change-ungraft-called drop ;
 
 ! We can't print to output-stream here because that might be a pane
 ! stream, and our graft-queue rebinding here would be captured
@@ -122,7 +122,7 @@ M: mock-gadget ungraft*
         3 [
             <mock-gadget> over <model> >>model
             "g" get over add-gadget drop
-            swap 1+ number>string set
+            swap 1 + number>string set
         ] each ;
 
     : status-flags ( -- seq )
index 029501258421f9f2467e2dbdfa5c83951799826b..26d0fee2e30fee83b7d27f4c6205c1db25191e66 100644 (file)
@@ -395,4 +395,4 @@ M: f request-focus-on 2drop ;
 
 USING: vocabs vocabs.loader ;
 
-"prettyprint" vocab [ "ui.gadgets.prettyprint" require ] when
\ No newline at end of file
+"prettyprint" vocab [ "ui.gadgets.prettyprint" require ] when
index b9fe10c530b83e71ce1265a1f8edb8a255d57732..3292e3e6c5621292dda37ef5dd10d87f8c982286 100644 (file)
@@ -28,10 +28,10 @@ M: line-gadget line-height font>> font-metrics height>> ceiling ;
 : line>y ( n gadget -- y ) line-height * >integer ;
 
 : validate-line ( m gadget -- n )
-    control-value [ drop f ] [ length 1- min 0 max ] if-empty ;
+    control-value [ drop f ] [ length 1 - min 0 max ] if-empty ;
 
 : valid-line? ( n gadget -- ? )
-    control-value length 1- 0 swap between? ;
+    control-value length 1 - 0 swap between? ;
 
 : visible-line ( gadget quot -- n )
     '[
@@ -43,7 +43,7 @@ M: line-gadget line-height font>> font-metrics height>> ceiling ;
     [ loc>> ] visible-line ;
 
 : last-visible-line ( gadget -- n )
-    [ [ loc>> ] [ dim>> ] bi v+ ] visible-line 1+ ;
+    [ [ loc>> ] [ dim>> ] bi v+ ] visible-line 1 + ;
 
 : each-slice-index ( from to seq quot -- )
     [ [ <slice> ] [ drop [a,b) ] 3bi ] dip 2each ; inline
@@ -85,4 +85,4 @@ M: line-gadget pref-viewport-dim
     2bi 2array ;
 
 : visible-lines ( gadget -- n )
-    [ visible-dim second ] [ line-height ] bi /i ;
\ No newline at end of file
+    [ visible-dim second ] [ line-height ] bi /i ;
index 159da59be5a1e0013be2ad79898c7552fd7eaa9a..70818262c5542143fc8def2109cf3d223baca3d1 100644 (file)
@@ -65,7 +65,7 @@ M: ---- <menu-item>
 : <operations-menu> ( target hook -- menu )
     over object-operations
     [ primary-operation? ] partition
-    [ reverse ] [ [ [ command-name ] compare ] sort ] bi*
+    [ reverse ] [ [ command-name ] sort-with ] bi*
     { ---- } glue <commands-menu> ;
 
 : show-operations-menu ( gadget target hook -- )
index fc564b6ffe9eabd8c644ef2e236489e591cab550..9f55c7a67df0d11617777c32cf7a744633486cd2 100644 (file)
@@ -58,7 +58,7 @@ mouse-color
 column-line-color
 selection-required?
 single-click?
-selected-value
+selection
 min-rows
 min-cols
 max-rows
index c064a80ee4bb6649f8a60e287ac6725229801e73..81e5f0f77842a1782919c4981a07dff57dffa431 100644 (file)
@@ -16,17 +16,17 @@ $nl
 { $subsection column-titles } ;
 
 ARTICLE: "ui.gadgets.tables.selection" "Table row selection"
-"At any given time, a single row in the table may be selected."
-$nl
 "A few slots in the table gadget concern row selection:"
 { $table
-  { { $slot "selected-value" } { " - if set to a model, the currently selected row's value, as determined by a " { $link row-value } " call to the renderer, is stored in this model. See " { $link "models" } "." } }
-  { { $slot "selected-index" } " - the index of the currently selected row." }
+  { { $slot "selection" } { " - if set to a model, the values of the currently selected row or rows, as determined by a " { $link row-value } " call to the renderer, is stored in this model. See " { $link "models" } "." } }
+  { { $slot "selection-index" } { " - if set to a model, the indices of the currently selected rows." } }
   { { $slot "selection-required?" } { " - if set to a true value, the table ensures that some row is always selected, if the model is non-empty. If set to " { $link f } ", a state where nothing is selected is permitted to occur. The default is " { $link f } "." } }
+  { { $slot "multiple-selection?" } { " - if set to a true value, users are allowed to select more than one value." } }
 }
 "Some words for row selection:"
-{ $subsection selected-row }
-{ $subsection (selected-row) } ;
+{ $subsection selected-rows }
+{ $subsection (selected-rows) }
+{ $subsection selected } ;
 
 ARTICLE: "ui.gadgets.tables.actions" "Table row actions"
 "When the user double-clicks on a row, or presses " { $command table "row" row-action } " while a row is selected, optional action and hook quotations are invoked. The action receives the row value and the hook receives the table gadget itself. These quotations are stored in the " { $slot "action" } " and " { $snippet "hook" } " slots of a table, respectively."
index 3191753324dd6103025f44d628f1a32f0a266eee..b92f72a2dd97327709a933a4337b98bf1cfa18b0 100644 (file)
@@ -1,6 +1,6 @@
 IN: ui.gadgets.tables.tests
 USING: ui.gadgets.tables ui.gadgets.scrollers ui.gadgets.debug accessors
-models namespaces tools.test kernel combinators ;
+models namespaces tools.test kernel combinators prettyprint arrays ;
 
 SINGLETON: test-renderer
 
@@ -44,4 +44,19 @@ M: test-renderer column-titles drop { "First" "Last" } ;
             [ selected-row drop ]
         } cleave
     ] with-grafted-gadget
-] unit-test
\ No newline at end of file
+] unit-test
+
+SINGLETON: silly-renderer
+
+M: silly-renderer row-columns drop unparse 1array ;
+
+M: silly-renderer column-titles drop { "Foo" } ;
+
+: test-table-2 ( -- table )
+    { 1 2 f } <model> silly-renderer <table> ;
+
+[ f f ] [
+    test-table dup [
+        selected-row
+    ] with-grafted-gadget
+] unit-test
index 3beb0af79f946a75cbe630b046a982005c725a2a..ccc5550adb41132dafee9f53e3c2155cbc97142b 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays colors colors.constants fry kernel math
-math.functions math.rectangles math.order math.vectors namespaces
-opengl sequences ui.gadgets ui.gadgets.scrollers ui.gadgets.status-bar
-ui.gadgets.worlds ui.gestures ui.render ui.pens.solid ui.text
-ui.commands ui.images ui.gadgets.menus ui.gadgets.line-support
-models math.ranges combinators
-combinators.short-circuit fonts locals strings ;
+USING: accessors assocs hashtables arrays colors colors.constants fry
+kernel math math.functions math.ranges math.rectangles math.order
+math.vectors namespaces opengl sequences ui.gadgets
+ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.worlds
+ui.gestures ui.render ui.pens.solid ui.text ui.commands ui.images
+ui.gadgets.menus ui.gadgets.line-support models combinators
+combinators.short-circuit fonts locals strings sets sorting ;
 IN: ui.gadgets.tables
 
 ! Row rendererer protocol
@@ -41,19 +41,44 @@ focus-border-color
 { mouse-color initial: COLOR: black }
 column-line-color
 selection-required?
-selected-index selected-value
+selection
+selection-index
+selected-indices
 mouse-index
 { takes-focus? initial: t }
-focused? ;
+focused?
+multiple-selection? ;
+
+<PRIVATE
+
+: add-selected-index ( table n -- table )
+    over selected-indices>> conjoin ;
+
+: multiple>single ( values -- value/f ? )
+    dup assoc-empty? [ drop f f ] [ values first t ] if ;
+
+: selected-index ( table -- n )
+    selected-indices>> multiple>single drop ;
+
+: set-selected-index ( table n -- table )
+    dup associate >>selected-indices ;
+
+PRIVATE>
+
+: selected ( table -- index/indices )
+    [ selected-indices>> ] [ multiple-selection?>> ] bi
+    [ multiple>single drop ] unless ;
 
 : new-table ( rows renderer class -- table )
     new-line-gadget
         swap >>renderer
         swap >>model
-        f <model> >>selected-value
         sans-serif-font >>font
         focus-border-color >>focus-border-color
-        transparent >>column-line-color ; inline
+        transparent >>column-line-color
+        f <model> >>selection-index
+        f <model> >>selection
+        H{ } clone >>selected-indices ;
 
 : <table> ( rows renderer -- table ) table new-table ;
 
@@ -131,21 +156,21 @@ M: table layout*
 : row-bounds ( table row -- loc dim )
     row-rect rect-bounds ; inline
 
-: draw-selected-row ( table -- )
+: draw-selected-rows ( table -- )
     {
-        { [ dup selected-index>> not ] [ drop ] }
+        { [ dup selected-indices>> assoc-empty? ] [ drop ] }
         [
-            [ ] [ selected-index>> ] [ selection-color>> gl-color ] tri
-            row-bounds gl-fill-rect
+            [ selected-indices>> keys ] [ selection-color>> gl-color ] [ ] tri
+            [ swap row-bounds gl-fill-rect ] curry each
         ]
     } cond ;
 
 : draw-focused-row ( table -- )
     {
         { [ dup focused?>> not ] [ drop ] }
-        { [ dup selected-index>> not ] [ drop ] }
+        { [ dup selected-index not ] [ drop ] }
         [
-            [ ] [ selected-index>> ] [ focus-border-color>> gl-color ] tri
+            [ ] [ selected-index ] [ focus-border-color>> gl-color ] tri
             row-bounds gl-rect
         ]
     } cond ;
@@ -189,10 +214,11 @@ M: table layout*
     dup renderer>> column-alignment
     [ ] [ column-widths>> length 0 <repetition> ] ?if ;
 
-:: row-font ( row index table -- font )
+:: row-font ( row ind table -- font )
     table font>> clone
     row table renderer>> row-color [ >>foreground ] when*
-    index table selected-index>> = [ table selection-color>> >>background ] when ;
+    ind table selected-indices>> key?
+    [ table selection-color>> >>background ] when ;
 
 : draw-columns ( columns widths alignment font gap -- )
     '[ [ _ ] 3dip _ draw-column ] 3each ;
@@ -213,7 +239,7 @@ M: table draw-gadget*
     dup control-value empty? [ drop ] [
         dup line-height \ line-height [
             {
-                [ draw-selected-row ]
+                [ draw-selected-rows ]
                 [ draw-lines ]
                 [ draw-column-lines ]
                 [ draw-focused-row ]
@@ -236,17 +262,36 @@ M: table pref-dim*
 
 PRIVATE>
 
-: (selected-row) ( table -- value/f ? )
-    [ selected-index>> ] keep nth-row ;
+: (selected-rows) ( table -- assoc )
+    [ selected-indices>> ] keep
+    '[ _ nth-row drop ] assoc-map ;
+
+: selected-rows ( table -- assoc )
+    [ selected-indices>> ] [ ] [ renderer>> ] tri
+    '[ _ nth-row drop _ row-value ] assoc-map ;
+
+: (selected-row) ( table -- value/f ? ) (selected-rows) multiple>single ;
 
-: selected-row ( table -- value/f ? )
-    [ (selected-row) ] keep
-    swap [ renderer>> row-value t ] [ 2drop f f ] if ;
+: selected-row ( table -- value/f ? ) selected-rows multiple>single ;
 
 <PRIVATE
 
-: update-selected-value ( table -- )
-    [ selected-row drop ] [ selected-value>> ] bi set-model ;
+: set-table-model ( model value multiple? -- )
+    [ values ] [ multiple>single drop ] if swap set-model ;
+
+: update-selected ( table -- )
+    [
+        [ selection>> ]
+        [ selected-rows ]
+        [ multiple-selection?>> ] tri
+        set-table-model
+    ]
+    [
+        [ selection-index>> ]
+        [ selected-indices>> ]
+        [ multiple-selection?>> ] tri
+        set-table-model
+    ] bi ;
 
 : show-row-summary ( table n -- )
     over nth-row
@@ -258,51 +303,73 @@ PRIVATE>
     f >>mouse-index [ hide-status ] [ relayout-1 ] bi ;
 
 : find-row-index ( value table -- n/f )
-    [ model>> value>> ] [ renderer>> '[ _ row-value ] map index ] bi ;
+    [ model>> value>> ] [ renderer>> ] bi
+    '[ _ row-value eq? ] with find drop ;
 
-: initial-selected-index ( table -- n/f )
+: (update-selected-indices) ( table -- set )
+    [ selection>> value>> dup [ array? not ] [ ] bi and [ 1array ] when ] keep
+    '[ _ find-row-index ] map sift unique f assoc-like ;
+
+: initial-selected-indices ( table -- set )
     {
         [ model>> value>> empty? not ]
         [ selection-required?>> ]
-        [ drop 0 ]
+        [ drop { 0 } unique ]
     } 1&& ;
 
-: (update-selected-index) ( table -- n/f )
-    [ selected-value>> value>> ] keep over
-    [ find-row-index ] [ 2drop f ] if ;
-
-: update-selected-index ( table -- n/f )
+: update-selected-indices ( table -- set )
     {
-        [ (update-selected-index) ]
-        [ initial-selected-index ]
+        [ (update-selected-indices) ]
+        [ initial-selected-indices ]
     } 1|| ;
 
 M: table model-changed
-    nip dup update-selected-index {
-        [ >>selected-index f >>mouse-index drop ]
-        [ show-row-summary ]
-        [ drop update-selected-value ]
+    nip dup update-selected-indices {
+        [ >>selected-indices f >>mouse-index drop ]
+        [ multiple>single drop show-row-summary ]
+        [ drop update-selected ]
         [ drop relayout ]
     } 2cleave ;
 
 : thin-row-rect ( table row -- rect )
     row-rect [ { 0 1 } v* ] change-dim ;
 
+: scroll-to-row ( table n -- )
+    dup [ [ thin-row-rect ] [ drop ] 2bi scroll>rect ] [ 2drop ] if ;
+
+: add-selected-row ( table n -- )
+    [ scroll-to-row ]
+    [ add-selected-index relayout-1 ] 2bi ;
+
 : (select-row) ( table n -- )
-    [ dup [ [ thin-row-rect ] [ drop ] 2bi scroll>rect ] [ 2drop ] if ]
-    [ >>selected-index relayout-1 ]
+    [ scroll-to-row ]
+    [ set-selected-index relayout-1 ]
     2bi ;
 
 : mouse-row ( table -- n )
     [ hand-rel second ] keep y>line ;
 
-: if-mouse-row ( table true: ( table mouse-index -- ) false: ( table -- ) -- )
+: if-mouse-row ( table true: ( mouse-index table -- ) false: ( table -- ) -- )
     [ [ mouse-row ] keep 2dup valid-line? ]
     [ ] [ '[ nip @ ] ] tri* if ; inline
 
+: (table-button-down) ( quot table -- )
+    dup takes-focus?>> [ dup request-focus ] when swap
+   '[ swap [ >>mouse-index ] _ bi ] [ drop ] if-mouse-row ; inline
+
 : table-button-down ( table -- )
-    dup takes-focus?>> [ dup request-focus ] when
-    [ swap [ >>mouse-index ] [ (select-row) ] bi ] [ drop ] if-mouse-row ;
+    [ (select-row) ] swap (table-button-down) ;
+
+: continued-button-down ( table -- )
+    dup multiple-selection?>>
+    [ [ add-selected-row ] swap (table-button-down) ] [ table-button-down ] if ;
+
+: thru-button-down ( table -- )
+    dup multiple-selection?>> [
+      [ 2dup over selected-index (a,b) swap
+      [ swap add-selected-index drop ] curry each add-selected-row ]
+      swap (table-button-down)
+    ] [ table-button-down ] if ;
 
 PRIVATE>
 
@@ -319,7 +386,7 @@ PRIVATE>
 
 : table-button-up ( table -- )
     dup [ mouse-row ] keep valid-line? [
-        dup row-action? [ row-action ] [ update-selected-value ] if
+        dup row-action? [ row-action ] [ update-selected ] if
     ] [ drop ] if ;
 
 PRIVATE>
@@ -327,14 +394,14 @@ PRIVATE>
 : select-row ( table n -- )
     over validate-line
     [ (select-row) ]
-    [ drop update-selected-value ]
+    [ drop update-selected ]
     [ show-row-summary ]
     2tri ;
 
 <PRIVATE
 
 : prev/next-row ( table n -- )
-    [ dup selected-index>> ] dip '[ _ + ] [ 0 ] if* select-row ;
+    [ dup selected-index ] dip '[ _ + ] [ 0 ] if* select-row ;
     
 : previous-row ( table -- )
     -1 prev/next-row ;
@@ -346,10 +413,10 @@ PRIVATE>
     0 select-row ;
 
 : last-row ( table -- )
-    dup control-value length 1- select-row ;
+    dup control-value length 1 - select-row ;
 
 : prev/next-page ( table n -- )
-    over visible-lines 1- * prev/next-row ;
+    over visible-lines 1 - * prev/next-row ;
 
 : previous-page ( table -- )
     -1 prev/next-page ;
@@ -386,8 +453,11 @@ table "sundry" f {
     { mouse-enter show-mouse-help }
     { mouse-leave hide-mouse-help }
     { motion show-mouse-help }
-    { T{ button-down } table-button-down }
+    { T{ button-down f { S+ } 1 } thru-button-down }
+    { T{ button-down f { A+ } 1 } continued-button-down }
     { T{ button-up } table-button-up }
+    { T{ button-up f { S+ } } table-button-up }
+    { T{ button-down } table-button-down }
     { gain-focus focus-table }
     { lose-focus unfocus-table }
     { T{ drag } table-button-down }
@@ -433,4 +503,4 @@ M: table viewport-column-header
     dup renderer>> column-titles
     [ <column-headers> ] [ drop f ] if ;
 
-PRIVATE>
\ No newline at end of file
+PRIVATE>
index 485015b898fb35cfd5467bdace3ebead38f693f5..042e2d34466ca7310f36e65a50246991ebbcbb78 100644 (file)
@@ -14,7 +14,7 @@ TUPLE: gradient < caching-pen colors last-vertices last-colors ;
 
 :: gradient-vertices ( direction dim colors -- seq )
     direction dim v* dim over v- swap
-    colors length dup 1- v/n [ v*n ] with map
+    colors length dup 1 - v/n [ v*n ] with map
     swap [ over v+ 2array ] curry map
     concat concat >float-array ;
 
@@ -43,4 +43,4 @@ M: gradient draw-interior
         [ colors>> draw-gradient ]
     } cleave ;
 
-M: gradient pen-background 2drop transparent ;
\ No newline at end of file
+M: gradient pen-background 2drop transparent ;
index d56da86b866ff72d3632d5a0b1e4bfb58cdc271c..d5e836044bd4a48d30613d83d2964f5c81e99d01 100755 (executable)
@@ -25,7 +25,7 @@ M: uniscribe-renderer draw-string ( font string -- )
 \r
 M: uniscribe-renderer x>offset ( x font string -- n )\r
     [ 2drop 0 ] [\r
-        cached-script-string x>line-offset 0 = [ 1+ ] unless\r
+        cached-script-string x>line-offset 0 = [ 1 + ] unless\r
     ] if-empty ;\r
 \r
 M: uniscribe-renderer offset>x ( n font string -- x )\r
index 024442a2647ae2f1ccf874c54a95700cc2aa9d63..a4fda6600e6e6b8f8b70d48fc73c61e0d1afa6ae 100755 (executable)
@@ -79,7 +79,7 @@ debugger "gestures" f {
 
 : com-help ( debugger -- ) error>> error-help-window ;
 
-: com-edit ( debugger -- ) error>> (:edit) ;
+: com-edit ( debugger -- ) error>> edit-error ;
 
 \ com-edit H{ { +listener+ t } } define-command
 
index 5040a13be2c3d881112162d2974cddb9234f808a..ec96ac4078d67a6650f4d552ae20e9b27d6b9aaf 100644 (file)
@@ -12,8 +12,8 @@ $nl
     ! { { $image "vocab:ui/tools/error-list/icons/syntax-error.tiff" } "Syntax error" { $link "syntax" } }
     { { $image "vocab:ui/tools/error-list/icons/compiler-error.tiff" } "Compiler error" { $link "compiler-errors" } }
     { { $image "vocab:ui/tools/error-list/icons/linkage-error.tiff" } "Linkage error" { $link "loading-libs" } }
-    { { $image "vocab:ui/tools/error-list/icons/unit-test-error.tiff" } "Unit test failure" { $link "tools.test" } }
     { { $image "vocab:ui/tools/error-list/icons/help-lint-error.tiff" } "Help lint failure" { $link "help.lint" } }
+    { { $image "vocab:ui/tools/error-list/icons/unit-test-error.tiff" } "Unit test failure" { $link "tools.test" } }
 } ;
 
 ABOUT: "ui.tools.error-list"
index e9d4b50bac41edb385d4e2f811d51ef5726af35b..a1da59fe391bca006b3852dba15a31bc12a115e8 100644 (file)
@@ -71,7 +71,7 @@ M: source-file-renderer filled-column drop 1 ;
         60 >>min-cols
         60 >>max-cols
         t >>selection-required?
-        error-list source-file>> >>selected-value ;
+        error-list source-file>> >>selection ;
 
 SINGLETON: error-renderer
 
@@ -120,7 +120,7 @@ M: error-renderer column-alignment drop { 0 1 0 0 } ;
         60 >>min-cols
         60 >>max-cols
         t >>selection-required?
-        error-list error>> >>selected-value ;
+        error-list error>> >>selection ;
 
 TUPLE: error-display < track ;
 
@@ -165,8 +165,8 @@ error-display "toolbar" f {
         { 5 5 } >>gap
         error-list <error-list-toolbar> f track-add
         error-list source-file-table>> <scroller> "Source files" <labeled-gadget> 1/4 track-add
-        error-list error-table>> <scroller> "Errors" <labeled-gadget> 1/2 track-add
-        error-list error-display>> "Details" <labeled-gadget> 1/4 track-add
+        error-list error-table>> <scroller> "Errors" <labeled-gadget> 1/4 track-add
+        error-list error-display>> "Details" <labeled-gadget> 1/2 track-add
     { 5 5 } <filled-border> 1 track-add ;
 
 M: error-list-gadget focusable-child*
index 35fa5e3c172dccc983802f044cf7a4f5563499c7..b4a772dca56847465e4c78816caafd133b2a5449 100644 (file)
@@ -57,7 +57,7 @@ M: object make-slot-descriptions
     make-mirror [ <slot-description> ] { } assoc>map ;
 
 M: hashtable make-slot-descriptions
-    call-next-method [ [ key-string>> ] compare ] sort ;
+    call-next-method [ key-string>> ] sort-with ;
 
 : <inspector-table> ( model -- table )
     [ make-slot-descriptions ] <arrow> inspector-renderer <table>
index 5e03ab21ad1242cb545377df63ceb509172d0ed8..dae9e26dc8df7bdbfb2c28096721556a67d5b0c0 100644 (file)
@@ -10,7 +10,7 @@ TUPLE: history document elements index ;
     V{ } clone 0 history boa ;
 
 : history-add ( history -- input )
-    dup elements>> length 1+ >>index
+    dup elements>> length 1 + >>index
     [ document>> doc-string [ <input> ] [ empty? ] bi ] keep
     '[ [ _ elements>> push ] keep ] unless ;
 
@@ -32,7 +32,7 @@ TUPLE: history document elements index ;
     [ set-doc-string ] [ clear-undo drop ] 2bi ;
 
 : change-history-index ( history i -- )
-    over elements>> length 1-
+    over elements>> length 1 -
     '[ _ + _ min 0 max ] change-index drop ;
 
 : history-recall ( history i -- )
index e34e354a874f9851b8e12b3fc8dc59fd3c9d2584..4b9a4a1ef37644e511755bea9d4e4bdbf98755fd 100644 (file)
@@ -170,7 +170,7 @@ M: interactor stream-read1
 M: interactor dispose drop ;
 
 : go-to-error ( interactor error -- )
-    [ line>> 1- ] [ column>> ] bi 2array
+    [ line>> 1 - ] [ column>> ] bi 2array
     over set-caret
     mark>caret ;
 
@@ -444,4 +444,4 @@ M: listener-gadget graft*
     [ call-next-method ] [ restart-listener ] bi ;
 
 M: listener-gadget ungraft*
-    [ com-end ] [ call-next-method ] bi ;
\ No newline at end of file
+    [ com-end ] [ call-next-method ] bi ;
index 8be357b4093f46ebd49ccfa484f7c9ee83bacbb0..c3fbdb88cd0ce20b46562bc2d36da1c33a55b7e3 100644 (file)
@@ -147,7 +147,7 @@ M: method-renderer column-titles drop { "" "Method" "Count" } ;
     horizontal <track>
         { 3 3 } >>gap
         profiler vocabs>> vocab-renderer <profiler-table>
-            profiler vocab>> >>selected-value
+            profiler vocab>> >>selection
             10 >>min-rows
             10 >>max-rows
         "Vocabularies" <labeled-gadget>
@@ -164,11 +164,11 @@ M: method-renderer column-titles drop { "" "Method" "Count" } ;
         horizontal <track>
             { 3 3 } >>gap
             profiler <generic-model> word-renderer <profiler-table>
-                profiler generic>> >>selected-value
+                profiler generic>> >>selection
             "Generic words" <labeled-gadget>
         1/2 track-add
             profiler <class-model> word-renderer <profiler-table>
-                profiler class>> >>selected-value
+                profiler class>> >>selection
             "Classes" <labeled-gadget>
         1/2 track-add
     1/2 track-add
index 9df084210dfdacea63ab361169543653f64ac0d6..11c2a48a2a5408900b03b538f9390eae9f4a36bb 100644 (file)
@@ -35,7 +35,7 @@ TUPLE: node value children ;
         ] [
             [
                 [ traverse-step traverse-from-path ]
-                [ tuck children>> swap first 1+ tail-slice % ] 2bi
+                [ tuck children>> swap first 1 + tail-slice % ] 2bi
             ] make-node
         ] if
     ] if ;
@@ -44,7 +44,7 @@ TUPLE: node value children ;
     traverse-step traverse-from-path ;
 
 : (traverse-middle) ( frompath topath gadget -- )
-    [ first 1+ ] [ first ] [ children>> ] tri* <slice> % ;
+    [ first 1 + ] [ first ] [ children>> ] tri* <slice> % ;
 
 : traverse-post ( topath gadget -- )
     traverse-step traverse-to-path ;
@@ -94,4 +94,4 @@ M: array leaves* '[ _ leaves* ] each ;
 
 M: gadget leaves* conjoin ;
 
-: leaves ( tree -- assoc ) H{ } clone [ leaves* ] keep ;
\ No newline at end of file
+: leaves ( tree -- assoc ) H{ } clone [ leaves* ] keep ;
index 2486e701c0cec64c26cffb529785dc88575fdcfa..aa3c549cf0e2fdeb7c98a25592d8a31184809766 100644 (file)
@@ -26,7 +26,7 @@ SYMBOL: windows
     #! etc.
     swap 2array windows get-global push
     windows get-global dup length 1 >
-    [ [ length 1- dup 1- ] keep exchange ] [ drop ] if ;
+    [ [ length 1 - dup 1 - ] keep exchange ] [ drop ] if ;
 
 : unregister-window ( handle -- )
     windows [ [ first = not ] with filter ] change-global ;
index ed96842c41ad0f58d1c2e900c8b31ed451ff55c4..7c7b8a1f50771499672eb752680021570141ccd4 100644 (file)
@@ -93,7 +93,7 @@ PRIVATE>
 : first-grapheme ( str -- i )
     unclip-slice grapheme-class over
     [ grapheme-class [ nip ] [ grapheme-break? ] 2bi ] find drop
-    nip swap length or 1+ ;
+    nip swap length or 1 + ;
 
 : first-grapheme-from ( start str -- i )
     over tail-slice first-grapheme + ;
@@ -192,13 +192,13 @@ to: word-table
     swap [ format/extended? not ] find-from drop ;
 
 : walk-up ( str i -- j )
-    dupd 1+ (walk-up) [ 1+ (walk-up) ] [ drop f ] if* ;
+    dupd 1 + (walk-up) [ 1 + (walk-up) ] [ drop f ] if* ;
 
 : (walk-down) ( str i -- j )
     swap [ format/extended? not ] find-last-from drop ;
 
 : walk-down ( str i -- j )
-    dupd (walk-down) [ 1- (walk-down) ] [ drop f ] if* ;
+    dupd (walk-down) [ 1 - (walk-down) ] [ drop f ] if* ;
 
 : word-break? ( str i table-entry -- ? )
     {
@@ -226,7 +226,7 @@ PRIVATE>
 : first-word ( str -- i )
     [ unclip-slice word-break-prop over <enum> ] keep
     '[ swap _ word-break-next ] assoc-find 2drop
-    nip swap length or 1+ ;
+    nip swap length or 1 + ;
 
 : >words ( str -- words )
     [ first-word ] >pieces ;
@@ -234,7 +234,7 @@ PRIVATE>
 <PRIVATE
 
 : nth-next ( i str -- str[i-1] str[i] )
-    [ [ 1- ] keep ] dip '[ _ nth ] bi@ ;
+    [ [ 1 - ] keep ] dip '[ _ nth ] bi@ ;
 
 PRIVATE>
 
index cea880c0b08b5885e575da6475c3c017f4fe9f16..ff2c808fdef7e8bb24507c4798ff7e316a70474e 100644 (file)
@@ -27,7 +27,7 @@ IN: unicode.normalize.tests
 :: assert= ( test spec quot -- )
     spec [
         [
-            [ 1- test nth ] bi@
+            [ 1 - test nth ] bi@
             [ 1quotation ] [ quot curry ] bi* unit-test
         ] with each
     ] assoc-each ;
index aca96a56942c315303dc84afd4c52a9061883c7c..b1cba0751187d2787b8b91f98711dae0d6108364 100644 (file)
@@ -108,7 +108,7 @@ HINTS: string-append string string ;
 ! Normalization -- Composition
 
 : initial-medial? ( str i -- ? )
-    { [ swap nth initial? ] [ 1+ swap ?nth medial? ] } 2&& ;
+    { [ swap nth initial? ] [ 1 + swap ?nth medial? ] } 2&& ;
 
 : --final? ( str i -- ? )
     2 + swap ?nth final? ;
@@ -124,7 +124,7 @@ HINTS: string-append string string ;
 : compose-jamo ( str i -- str i )
     2dup initial-medial? [
         2dup --final? [ imf, ] [ im, ] if
-    ] [ 2dup swap nth , 1+ ] if ;
+    ] [ 2dup swap nth , 1 + ] if ;
 
 : pass-combining ( str -- str i )
     dup [ non-starter? not ] find drop
@@ -136,7 +136,7 @@ TUPLE: compose-state i str char after last-class ;
 : get-str ( state i -- ch )
     swap [ i>> + ] [ str>> ] bi ?nth ; inline
 : current ( state -- ch ) 0 get-str ; inline
-: to ( state -- state ) [ 1+ ] change-i ; inline
+: to ( state -- state ) [ 1 + ] change-i ; inline
 : push-after ( ch state -- state ) [ ?push ] change-after ; inline
 
 :: try-compose ( state new-char current-class -- state )
@@ -177,8 +177,8 @@ DEFER: compose-iter
 :: (compose) ( str i -- )
     i str ?nth [
         dup jamo? [ drop str i compose-jamo ] [
-            i 1+ str ?nth combining-class
-            [ str i 1+ compose-combining ] [ , str i 1+ ] if
+            i 1 + str ?nth combining-class
+            [ str i 1 + compose-combining ] [ , str i 1 + ] if
         ] if (compose)
     ] when* ; inline recursive
 
index 91feae6471cd624ed53efef94e066a62fb944802..eba0e4976f40e7927e61ae7c02e76e15752b48b4 100644 (file)
@@ -64,7 +64,7 @@ PRIVATE>
     #! first group is -1337, legacy unix code
     -1337 NGROUPS_MAX [ 4 * <byte-array> ] keep
     <int> [ getgrouplist io-error ] 2keep
-    [ 4 tail-slice ] [ *int 1- ] bi* >groups ;
+    [ 4 tail-slice ] [ *int 1 - ] bi* >groups ;
 
 PRIVATE>
     
index da8b1e63e3f11f7eafacc778486c0aed12238f05..131d8dda5dc681488a36296ed79400f63dcd6009 100644 (file)
@@ -80,7 +80,7 @@ CONSTANT: WNOWAIT    HEX: 1000000
     HEX: ff00 bitand -8 shift ; inline
 
 : WIFSIGNALED ( status -- ? )
-    HEX: 7f bitand 1+ -1 shift 0 > ; inline
+    HEX: 7f bitand 1 + -1 shift 0 > ; inline
 
 : WCOREFLAG ( -- value )
     HEX: 80 ; inline
index bd4a2c1114b01d759a335b7e002826a8d331fd81..9e2c9539c6ecfa2362efbbc7892a1aee165e2cd6 100644 (file)
@@ -45,7 +45,7 @@ M: unrolled-list clear-deque
 : <front-node> ( elt front -- node )
     [
         unroll-factor 0 <array>
-        [ unroll-factor 1- swap set-nth ] keep f
+        [ unroll-factor 1 - swap set-nth ] keep f
     ] dip [ node boa dup ] keep
     dup [ (>>prev) ] [ 2drop ] if ; inline
 
@@ -55,12 +55,12 @@ M: unrolled-list clear-deque
     ] [ dup front>> >>back ] if* drop ; inline
 
 : push-front/new ( elt list -- )
-    unroll-factor 1- >>front-pos
+    unroll-factor 1 - >>front-pos
     [ <front-node> ] change-front
     normalize-back ; inline
 
 : push-front/existing ( elt list front -- )
-    [ [ 1- ] change-front-pos ] dip
+    [ [ 1 - ] change-front-pos ] dip
     [ front-pos>> ] [ data>> ] bi* set-nth-unsafe ; inline
 
 M: unrolled-list push-front*
@@ -81,12 +81,12 @@ M: unrolled-list peek-front
 
 : pop-front/existing ( list front -- )
     [ dup front-pos>> ] [ data>> ] bi* [ 0 ] 2dip set-nth-unsafe
-    [ 1+ ] change-front-pos
+    [ 1 + ] change-front-pos
     drop ; inline
 
 M: unrolled-list pop-front*
     dup front>> [ empty-unrolled-list ] unless*
-    over front-pos>> unroll-factor 1- eq?
+    over front-pos>> unroll-factor 1 - eq?
     [ pop-front/new ] [ pop-front/existing ] if ;
 
 : <back-node> ( elt back -- node )
@@ -106,8 +106,8 @@ M: unrolled-list pop-front*
     normalize-front ; inline
 
 : push-back/existing ( elt list back -- )
-    [ [ 1+ ] change-back-pos ] dip
-    [ back-pos>> 1- ] [ data>> ] bi* set-nth-unsafe ; inline
+    [ [ 1 + ] change-back-pos ] dip
+    [ back-pos>> 1 - ] [ data>> ] bi* set-nth-unsafe ; inline
 
 M: unrolled-list push-back*
     dup [ back>> ] [ back-pos>> unroll-factor eq? not ] bi
@@ -116,7 +116,7 @@ M: unrolled-list push-back*
 
 M: unrolled-list peek-back
     dup back>>
-    [ [ back-pos>> 1- ] dip data>> nth-unsafe ]
+    [ [ back-pos>> 1 - ] dip data>> nth-unsafe ]
     [ empty-unrolled-list ]
     if* ;
 
@@ -126,7 +126,7 @@ M: unrolled-list peek-back
     dup back>> [ normalize-front ] [ f >>front drop ] if ; inline
 
 : pop-back/existing ( list back -- )
-    [ [ 1- ] change-back-pos ] dip
+    [ [ 1 - ] change-back-pos ] dip
     [ dup back-pos>> ] [ data>> ] bi* [ 0 ] 2dip set-nth-unsafe
     drop ; inline
 
index 8e11dec431fbd2688094d00f7b7c25344d08efb5..f87c21d2ffbdd9e6acb167388d2f6c833d7c1a37 100644 (file)
@@ -57,7 +57,7 @@ PRIVATE>
     2dup length 2 - >= [
         2drop
     ] [
-        [ 1+ dup 2 + ] dip subseq  hex> [ , ] when*
+        [ 1 + dup 2 + ] dip subseq  hex> [ , ] when*
     ] if ;
 
 : url-decode-% ( index str -- index str )
@@ -70,7 +70,7 @@ PRIVATE>
         2dup nth dup CHAR: % = [
             drop url-decode-% [ 3 + ] dip
         ] [
-            , [ 1+ ] dip
+            , [ 1 + ] dip
         ] if url-decode-iter
     ] if ;
 
index 6ad5e7dee61fc74310d750798da49404a154e375..74c63e3d8f23558608ca8386a1c1b3753d5fd486 100644 (file)
@@ -5,5 +5,5 @@ VALUE: foo
 [ f ] [ foo ] unit-test\r
 [ ] [ 3 to: foo ] unit-test\r
 [ 3 ] [ foo ] unit-test\r
-[ ] [ \ foo [ 1+ ] change-value ] unit-test\r
+[ ] [ \ foo [ 1 + ] change-value ] unit-test\r
 [ 4 ] [ foo ] unit-test\r
index ae106cbf93b9dfbb3ce2ada86972815320dfaac2..79870b483f35561109d46d7061123456f1920f3e 100644 (file)
@@ -28,13 +28,13 @@ PRIVATE>
 M: vlist ppush
     >vlist<
     2dup length = [ unshare ] unless
-    [ [ 1+ swap ] dip push ] keep vlist boa ;
+    [ [ 1 + swap ] dip push ] keep vlist boa ;
 
 ERROR: empty-vlist-error ;
 
 M: vlist ppop
     [ empty-vlist-error ]
-    [ [ length>> 1- ] [ vector>> ] bi vlist boa ] if-empty ;
+    [ [ length>> 1 - ] [ vector>> ] bi vlist boa ] if-empty ;
 
 M: vlist clone
     [ length>> ] [ vector>> >vector ] bi vlist boa ;
@@ -65,7 +65,7 @@ M: valist assoc-size vlist>> length 2/ ;
 : valist-at ( key i array -- value ? )
     over 0 >= [
         3dup nth-unsafe = [
-            [ 1+ ] dip nth-unsafe nip t
+            [ 1 + ] dip nth-unsafe nip t
         ] [
             [ 2 - ] dip valist-at
         ] if
index aa3e619660320d69eebf17928544b341acde7bba..b840b5ab9dfe96d83ff8dcb22a18fad77c8e5117 100644 (file)
@@ -107,7 +107,8 @@ MEMO: all-vocabs-recursive ( -- assoc )
 PRIVATE>\r
 \r
 : (load) ( prefix -- failures )\r
-    child-vocabs-recursive no-roots no-prefixes\r
+    [ child-vocabs-recursive no-roots no-prefixes ]\r
+    [ dup find-vocab-root [ >vocab-link prefix ] [ drop ] if ] bi\r
     filter-unportable\r
     require-all ;\r
 \r
index 0e150ef07a7d1e38949202bc5a60cf43ddb1fb81..66bc277ef7d3f1bc50e9e2fe2082e9080b17048f 100644 (file)
@@ -14,7 +14,7 @@ IN: vocabs.prettyprint
 <PRIVATE
 
 : sort-vocabs ( seq -- seq' )
-    [ [ vocab-name ] compare ] sort ;
+    [ vocab-name ] sort-with ;
 
 : pprint-using ( seq -- )
     [ "syntax" vocab = not ] filter
index 9d52378da912855bfbb39619b611fe53d83d7deb..beac4b6c27397c5a13b13c634946dd8a0a57f839 100755 (executable)
@@ -28,7 +28,7 @@ unless
 "windows.com.wrapper.callbacks" create-vocab drop
 
 : (next-vtbl-counter) ( -- n )
-    +vtbl-counter+ [ 1+ dup ] change ;
+    +vtbl-counter+ [ 1 + dup ] change ;
 
 : com-unwrap ( wrapped -- object )
     +wrapped-objects+ get-global at*
@@ -59,7 +59,7 @@ unless
 : (make-add-ref) ( interfaces -- quot )
     length "void*" heap-size * '[
         _
-        [ alien-unsigned-4 1+ dup ]
+        [ alien-unsigned-4 1 + dup ]
         [ set-alien-unsigned-4 ]
         2bi
     ] ;
@@ -68,7 +68,7 @@ unless
     length "void*" heap-size * '[
         _
         [ drop ]
-        [ alien-unsigned-4 1- dup ]
+        [ alien-unsigned-4 1 - dup ]
         [ set-alien-unsigned-4 ]
         2tri
         dup 0 = [ swap (free-wrapped-object) ] [ nip ] if
@@ -101,7 +101,7 @@ unless
     "windows.com.wrapper.callbacks" create ;
 
 : (finish-thunk) ( param-count thunk quot -- thunked-quot )
-    [ [ drop [ ] ] [ swap 1- '[ _ _ ndip ] ] if-empty ]
+    [ [ drop [ ] ] [ swap 1 - '[ _ _ ndip ] ] if-empty ]
     dip compose ;
 
 : (make-interface-callbacks) ( interface-name quots iunknown-methods n -- words )
index 4543aa703a0188db1a0bde7bdfb4ca19ffcb9656..e9c4930b6402d986189b7ac06b9d99c7f0d8e7f2 100644 (file)
@@ -7,7 +7,7 @@ IN: windows.dragdrop-listener
 : filenames-from-hdrop ( hdrop -- filenames )\r
     dup HEX: FFFFFFFF f 0 DragQueryFile ! get count of files\r
     [\r
-        2dup f 0 DragQueryFile 1+ ! get size of filename buffer\r
+        2dup f 0 DragQueryFile 1 + ! get size of filename buffer\r
         dup "WCHAR" <c-array>\r
         [ swap DragQueryFile drop ] keep\r
         alien>u16-string\r
index d180cb20e7b27b05b5f820d4b508650e8db5b445..8bdbb9f1e99838bbcd812d1afce3966d2f73ce03 100644 (file)
@@ -713,11 +713,7 @@ ERROR: error-message-failed id ;
     GetLastError n>win32-error-string ;
 
 : (win32-error) ( n -- )
-    dup zero? [
-        drop
-    ] [
-        win32-error-string throw
-    ] if ;
+    [ win32-error-string throw ] unless-zero ;
 
 : win32-error ( -- )
     GetLastError (win32-error) ;
index feb0bef7a8ab7dd06c204a058107992f93250fd2..7c5c26c2da82733a2be5afc9cc7232ebe5a5f999 100755 (executable)
@@ -12,7 +12,7 @@ TUPLE: script-string font string metrics ssa size image disposed ;
 : line-offset>x ( n script-string -- x )
     2dup string>> length = [
         ssa>> ! ssa
-        swap 1- ! icp
+        swap 1 - ! icp
         TRUE ! fTrailing
     ] [
         ssa>>
index 7561d674820f7ff7fe7918ef0522bac0e9eafa28..5b2a0bcfb4d3dc2223dd82117cda190c497a83a5 100644 (file)
@@ -140,7 +140,7 @@ MACRO: interpolate-xml ( xml -- quot )
 : number<-> ( doc -- dup )
     0 over [
         dup var>> [
-            over >>var [ 1+ ] dip
+            over >>var [ 1 + ] dip
         ] unless drop
     ] each-interpolated drop ;
 
index 052cab15c29beffd273859ecf2828b96f8e50659..b0dbdf22ac83036076b8271eb0dfc3322a9c2fee 100644 (file)
@@ -13,7 +13,7 @@ IN: xml.tokenize
         swap
         [ version-1.0?>> over text? not ]
         [ check>> ] bi and [
-            spot get [ 1+ ] change-column drop
+            spot get [ 1 + ] change-column drop
             disallowed-char
         ] [ drop ] if
     ] [ drop ] if* ;
@@ -23,7 +23,7 @@ HINTS: assure-good-char { spot fixnum } ;
 : record ( spot char -- spot )
     over char>> [
         CHAR: \n =
-        [ [ 1+ ] change-line -1 ] [ dup column>> 1+ ] if
+        [ [ 1 + ] change-line -1 ] [ dup column>> 1 + ] if
         >>column
     ] [ drop ] if ;
 
@@ -91,7 +91,7 @@ HINTS: next* { spot } ;
 : take-string ( match -- string )
     dup length <circular-string>
     spot get '[ 2dup _ string-matches? ] take-until nip
-    dup length rot length 1- - head
+    dup length rot length 1 - - head
     get-char [ missing-close ] unless next ;
 
 : expect ( string -- )
index 44d3a0285e41a040723c821896cdfb23e16d12c5..3e7e697baa80d3c36fe48be39121454a0b376589 100644 (file)
@@ -28,7 +28,7 @@ SYMBOLS: line last-offset position context
 
 : next-token, ( len id -- )
     [ position get 2dup + ] dip token,
-    position get + dup 1- position set last-offset set ;
+    position get + dup 1 - position set last-offset set ;
 
 : push-context ( rules -- )
     context [ <line-context> ] change ;
index 4a998a1ebb118d7e15a9bcb4f04681ff640d0471..dd70e45b6b15eb485dacb804bad7e5c88fb8ac65 100644 (file)
@@ -14,7 +14,7 @@ M: array resize resize-array ;
 
 M: object new-sequence drop 0 <array> ;
 
-M: f new-sequence drop dup zero? [ drop f ] [ 0 <array> ] if ;
+M: f new-sequence drop [ f ] [ 0 <array> ] if-zero ;
 
 M: array equal?
     over array? [ sequence= ] [ 2drop f ] if ;
index 3c5ac31d23e2d94c0a2f31b9202e0b8d10c0db59..9e36f9f00cc6cbbe2ff28de7bc8a818cc934313f 100644 (file)
@@ -1,7 +1,7 @@
-IN: assocs.tests
 USING: kernel math namespaces make tools.test vectors sequences
 sequences.private hashtables io prettyprint assocs
 continuations specialized-arrays.double ;
+IN: assocs.tests
 
 [ t ] [ H{ } dup assoc-subset? ] unit-test
 [ f ] [ H{ { 1 3 } } H{ } assoc-subset? ] unit-test
@@ -149,4 +149,4 @@ unit-test
         H{ { 1 3 } { 2 5 } }
         H{ { 1 7 } { 5 6 } }
     } assoc-refine
-] unit-test
\ No newline at end of file
+] unit-test
index d94cd45c3d0ae1185575ed7e9cc9abd507c7b7e7..13e17f90fd9805ec280a77a04b2fef46aa6d7534 100644 (file)
@@ -425,8 +425,8 @@ tuple
     { "set-retainstack" "kernel" (( rs -- )) }
     { "set-callstack" "kernel" (( cs -- )) }
     { "exit" "system" (( n -- )) }
-    { "data-room" "memory" (( -- cards generations )) }
-    { "code-room" "memory" (( -- code-free code-total )) }
+    { "data-room" "memory" (( -- cards decks generations )) }
+    { "code-room" "memory" (( -- code-total code-used code-free largest-free-block )) }
     { "micros" "system" (( -- us )) }
     { "modify-code-heap" "compiler.units" (( alist -- )) }
     { "(dlopen)" "alien.libraries" (( path -- dll )) }
diff --git a/core/bootstrap/syntax-docs.factor b/core/bootstrap/syntax-docs.factor
deleted file mode 100644 (file)
index e69de29..0000000
index 1c3e4d3bdfdc4ca3755f0b1402e66e04a0e19cd4..a23e4ecd745fc3222fb8f9e82258b34e8c10ba44 100644 (file)
@@ -1,5 +1,5 @@
-IN: byte-arrays.tests\r
 USING: tools.test byte-arrays sequences kernel ;\r
+IN: byte-arrays.tests\r
 \r
 [ 6 B{ 1 2 3 } ] [\r
     6 B{ 1 2 3 } resize-byte-array\r
@@ -10,4 +10,4 @@ USING: tools.test byte-arrays sequences kernel ;
 \r
 [ -10 B{ } resize-byte-array ] must-fail\r
 \r
-[ B{ 123 } ] [ 123 1byte-array ] unit-test
\ No newline at end of file
+[ B{ 123 } ] [ 123 1byte-array ] unit-test\r
index bd7510c95f632cb8b90e77702429dbc7626815a0..fdf4ab6aca99c6c4600a20d76ae80abbf36d5b14 100644 (file)
@@ -1,6 +1,6 @@
-IN: byte-vectors.tests\r
 USING: tools.test byte-vectors vectors sequences kernel\r
 prettyprint ;\r
+IN: byte-vectors.tests\r
 \r
 [ 0 ] [ 123 <byte-vector> length ] unit-test\r
 \r
diff --git a/core/checksums/checksums-tests.factor b/core/checksums/checksums-tests.factor
deleted file mode 100644 (file)
index 8ba09d8..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-IN: checksums.tests
-USING: checksums tools.test ;
-
index 0dd808c7227faf0d88c066b014ff58431b896f9b..5fe46b532f40f9cbe5b54dd08996028a2c65c4af 100644 (file)
@@ -56,7 +56,7 @@ M: checksum checksum-lines
     [ B{ CHAR: \n } join ] dip checksum-bytes ;
 
 : checksum-file ( path checksum -- value )
-    #! normalize-path (file-reader) is equivalen to
+    #! normalize-path (file-reader) is equivalent to
     #! binary <file-reader>. We use the lower-level form
     #! so that we can move io.encodings.binary to basis/.
     [ normalize-path (file-reader) ] dip checksum-stream ;
index 2730e4683bc06b8215270c9ac51bd6845854311a..cbf6acdeed3123d63b82afe9993f31bfff2c418b 100644 (file)
@@ -12,7 +12,6 @@ ARTICLE: "class-operations" "Class operations"
 { $subsection classes-intersect? }\r
 { $subsection min-class }\r
 "Low-level implementation detail:"\r
-{ $subsection class-types }\r
 { $subsection flatten-class }\r
 { $subsection flatten-builtin-class }\r
 { $subsection class-types }\r
index 6d221c138007c9d8f974d8d91143584f480444bc..df4f8f2563033899a221203021061625a98c4930 100755 (executable)
@@ -202,12 +202,14 @@ M: anonymous-complement (classes-intersect?)
 : class= ( first second -- ? )\r
     [ class<= ] [ swap class<= ] 2bi and ;\r
 \r
+ERROR: topological-sort-failed ;\r
+\r
 : largest-class ( seq -- n elt )\r
     dup [ [ class< ] with any? not ] curry find-last\r
-    [ "Topological sort failed" throw ] unless* ;\r
+    [ topological-sort-failed ] unless* ;\r
 \r
 : sort-classes ( seq -- newseq )\r
-    [ [ name>> ] compare ] sort >vector\r
+    [ name>> ] sort-with >vector\r
     [ dup empty? not ]\r
     [ dup largest-class [ over delete-nth ] dip ]\r
     produce nip ;\r
index 6f990d0d62d6dcdf4b8a76601fd38c0dc0e594df..c6ce302c269ed71556c9ea16bccdb642af7a1d74 100755 (executable)
@@ -1,5 +1,5 @@
-IN: classes.builtin.tests
 USING: tools.test words sequences kernel memory accessors ;
+IN: classes.builtin.tests
 
 [ f ] [
     [ word? ] instances
index 32f7af8113faaa900d749dcb98bb1625c374a1dd..c74c8f3b503ef83f108948f356e34c5b8659f9eb 100644 (file)
@@ -50,13 +50,6 @@ M: builtin-class (classes-intersect?)
         [ swap classes-intersect? ]
     } cond ;
 
-M: anonymous-intersection (flatten-class)
-    participants>> [ flatten-builtin-class ] map
-    [
-        builtins get sift [ (flatten-class) ] each
-    ] [
-        [ ] [ assoc-intersect ] map-reduce [ swap set ] assoc-each
-    ] if-empty ;
-
-M: anonymous-complement (flatten-class)
-    drop builtins get sift [ (flatten-class) ] each ;
+: full-cover ( -- ) builtins get sift [ (flatten-class) ] each ;
+
+M: anonymous-complement (flatten-class) drop full-cover ;
diff --git a/core/classes/intersection/intersection-tests.factor b/core/classes/intersection/intersection-tests.factor
new file mode 100644 (file)
index 0000000..57e716f
--- /dev/null
@@ -0,0 +1,38 @@
+USING: kernel tools.test generic generic.standard ;
+IN: classes.intersection.tests
+
+TUPLE: a ;
+TUPLE: a1 < a ; TUPLE: a2 < a ; TUPLE: a3 < a2 ;
+MIXIN: b
+INSTANCE: a3 b
+INSTANCE: a1 b
+INTERSECTION: c a2 b ;
+
+GENERIC: x ( a -- b )
+
+M: c x drop c ;
+M: a x drop a ;
+
+[ a ] [ T{ a } x ] unit-test
+[ a ] [ T{ a1 } x ] unit-test
+[ a ] [ T{ a2 } x ] unit-test
+
+[ t ] [ T{ a3 } c? ] unit-test
+[ t ] [ T{ a3 } \ x effective-method M\ c x eq? nip ] unit-test
+[ c ] [ T{ a3 } x ] unit-test
+
+! More complex case
+TUPLE: t1 ;
+TUPLE: t2 < t1 ; TUPLE: t3 < t1 ;
+TUPLE: t4 < t2 ; TUPLE: t5 < t2 ;
+
+UNION: m t4 t5 t3 ;
+INTERSECTION: i t2 m ;
+
+GENERIC: g ( a -- b )
+
+M: i g drop i ;
+M: t4 g drop t4 ;
+
+[ t4 ] [ T{ t4 } g ] unit-test
+[ i ] [ T{ t5 } g ] unit-test
\ No newline at end of file
index 43018f6358afc25549f606a74e146f7076b76ad2..a0481a62a730963f14d6ed06d0d9ba64db29ff0d 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: words sequences kernel assocs combinators classes
+USING: words accessors sequences kernel assocs combinators classes
 classes.algebra classes.builtin namespaces arrays math quotations ;
 IN: classes.intersection
 
@@ -34,3 +34,15 @@ M: intersection-class instance?
 
 M: intersection-class (flatten-class)
     participants <anonymous-intersection> (flatten-class) ;
+
+! Horribly inefficient and inaccurate
+: intersect-flattened-classes ( seq1 seq2 -- seq3 )
+    ! Only keep those in seq1 that intersect something in seq2.
+    [ [ classes-intersect? ] with any? ] curry filter ;
+
+M: anonymous-intersection (flatten-class)
+    participants>> [ full-cover ] [
+        [ flatten-class keys ]
+        [ intersect-flattened-classes ] map-reduce
+        [ dup set ] each
+    ] if-empty ;
index 951608931bd415f0d3776f95af4ac88ca1d381d5..dadfa5991734f4d7ce8e626cfc5f3811a4f0b4a5 100644 (file)
@@ -27,8 +27,18 @@ TUPLE: tuple-b < tuple-a ;
 
 PREDICATE: tuple-c < tuple-b slot>> ;
 
-GENERIC: ptest ( tuple -- )
-M: tuple-a ptest drop ;
-M: tuple-c ptest drop ;
+GENERIC: ptest ( tuple -- )
+M: tuple-a ptest drop tuple-a ;
+M: tuple-c ptest drop tuple-c ;
 
-[ ] [ tuple-b new ptest ] unit-test
+[ tuple-a ] [ tuple-b new ptest ] unit-test
+[ tuple-c ] [ tuple-b new t >>slot ptest ] unit-test
+
+PREDICATE: tuple-d < tuple-a slot>> ;
+
+GENERIC: ptest' ( tuple -- x )
+M: tuple-a ptest' drop tuple-a ;
+M: tuple-d ptest' drop tuple-d ;
+
+[ tuple-a ] [ tuple-b new ptest' ] unit-test
+[ tuple-d ] [ tuple-b new t >>slot ptest' ] unit-test
index 72457ff97431fcd9099d0867bc9e137dd9b3a0cb..4ee31936a99733fb72fd8dac0502d8dad0e78c8a 100644 (file)
@@ -1,7 +1,7 @@
-IN: classes.tuple.parser.tests
 USING: accessors classes.tuple.parser lexer words classes
 sequences math kernel slots tools.test parser compiler.units
 arrays classes.tuple eval multiline ;
+IN: classes.tuple.parser.tests
 
 TUPLE: test-1 ;
 
@@ -141,4 +141,4 @@ TUPLE: parsing-corner-case x ;
         "USE: classes.tuple.parser.tests T{ parsing-corner-case {"
         "    x 3 }"
     } "\n" join eval( -- tuple )
-] [ error>> unexpected-eof? ] must-fail-with
\ No newline at end of file
+] [ error>> unexpected-eof? ] must-fail-with
index 4c55001aa1ec36e9061c5c98c3d31b90f97e269b..e915ca50fbf96b7533799b654cb2487a66bcb10c 100644 (file)
@@ -291,8 +291,7 @@ $nl
 { $subsection POSTPONE: SLOT: }
 "Protocol slots are used where the implementation of a superclass needs to assume that each subclass defines certain slots, however the slots of each subclass are potentially declared with different class specializers, thus preventing the slots from being defined in the superclass."
 $nl
-"For example, the " { $link growable } " mixin provides an implementation of the sequence protocol which wraps an underlying sequence, resizing it as necessary when elements are added beyond the length of the sequence. It assumes that the concrete mixin instances define two slots, " { $snippet "length" } " and " { $snippet "underlying" } ". These slots are defined as protocol slots:"
-{ $snippet "SLOT: length" "SLOT: underlying" }
+"For example, the " { $link growable } " mixin provides an implementation of the sequence protocol which wraps an underlying sequence, resizing it as necessary when elements are added beyond the length of the sequence. It assumes that the concrete mixin instances define two slots, " { $snippet "length" } " and " { $snippet "underlying" } ". These slots are defined as protocol slots: " { $snippet "SLOT: length" } " and " { $snippet "SLOT: underlying" } ". "
 "An alternate approach would be to define " { $link growable } " as a tuple class with these two slots, and have other classes subclass it as required. However, this rules out subclasses defining these slots with custom type declarations."
 $nl
 "For example, compare the definitions of the " { $link sbuf } " class,"
@@ -348,7 +347,7 @@ $nl
 { $list
     { { $snippet "\"predicate\"" } " - a quotation which tests if the top of the stack is an instance of this tuple class" }
     { { $snippet "\"slots\"" } " - a sequence of " { $link slot-spec } " instances" }
-    { { $snippet "\"tuple-layout\"" } " - an array with the tuple size and superclasses encoded in a format amneable to fast method dispatch" }
+    { { $snippet "\"layout\"" } " - an array with the tuple size and superclasses encoded in a format amneable to fast method dispatch" }
 } } ;
 
 HELP: define-tuple-predicate
index 8893db392925f229d89de25d27032b6045097852..7395014bed0ec111179f57f81fe20c5781f9fbb2 100755 (executable)
@@ -434,7 +434,7 @@ HELP: cond>quot
 { $values { "assoc" "a sequence of pairs of quotations" } { "quot" quotation } }
 { $description  "Creates a quotation that when called, has the same effect as applying " { $link cond } " to " { $snippet "assoc" } "."
 $nl
-"the generated quotation is more efficient than the naive implementation of " { $link cond } ", though, since it expands into a series of conditionals, and no iteration through " { $snippet "assoc" } " has to be performed." }
+"The generated quotation is more efficient than the naive implementation of " { $link cond } ", though, since it expands into a series of conditionals, and no iteration through " { $snippet "assoc" } " has to be performed." }
 { $notes "This word is used behind the scenes to compile " { $link cond } " forms efficiently; it can also be called directly,  which is useful for meta-programming." } ;
 
 HELP: case>quot
index 54037b899e2b85587d0eb872ea9350a3f23d0da2..2bef1a568a1b3dd99d6b350aa56cb56e11a56963 100755 (executable)
@@ -113,7 +113,7 @@ ERROR: no-case object ;
     ] if ;
 
 : <buckets> ( initial length -- array )
-    next-power-of-2 swap [ nip clone ] curry map ;
+    next-power-of-2 iota swap [ nip clone ] curry map ;
 
 : distribute-buckets ( alist initial quot -- buckets )
     swapd [ [ dup first ] dip call 2array ] curry map
index 1abcba0720dcbe813420514888669f209576e154..ed7d4330264c1fb101fab1e793f1ecebad22b7f7 100644 (file)
@@ -26,7 +26,7 @@ HELP: with-disposal
 
 HELP: with-destructors
 { $values { "quot" "a quotation" } }
-{ $description "Calls a quotation within a new dynamic scope. This quotation may register destructors using " { $link &dispose } " or " { $link |dispose } ". The former registers a destructor that will always run whether or not the quotation threw an error, and the latter registers a destructor that only runs if the quotation throws an error only. Destructors are run in reverse order from the order in which they were registered." }
+{ $description "Calls a quotation within a new dynamic scope. This quotation may register destructors using " { $link &dispose } " or " { $link |dispose } ". The former registers a destructor that will always run whether or not the quotation threw an error, and the latter registers a destructor that only runs if the quotation throws an error. Destructors are run in reverse order from the order in which they were registered." }
 { $notes
     "Destructors generalize " { $link with-disposal } ". The following two lines are equivalent, except that the second line establishes a new dynamic scope:"
     { $code
index 3eb92738595188d03b661e890ee1829df316e6b8..37d4fd1195d0b72bf2992b0d04475268d33f86ea 100644 (file)
@@ -1,5 +1,5 @@
-IN: effects.tests
 USING: effects tools.test prettyprint accessors sequences ;
+IN: effects.tests
 
 [ t ] [ 1 1 <effect> 2 2 <effect> effect<= ] unit-test
 [ f ] [ 1 0 <effect> 2 2 <effect> effect<= ] unit-test
@@ -22,4 +22,4 @@ USING: effects tools.test prettyprint accessors sequences ;
 
 [ t ] [ (( -- )) (( -- )) compose-effects (( -- )) effect= ] unit-test
 [ t ] [ (( -- * )) (( -- )) compose-effects (( -- * )) effect= ] unit-test
-[ t ] [ (( -- )) (( -- * )) compose-effects (( -- * )) effect= ] unit-test
\ No newline at end of file
+[ t ] [ (( -- )) (( -- * )) compose-effects (( -- * )) effect= ] unit-test
index c8ed6da2aa3ce77cbcc906e255f1a7baec8e404c..66179c5e523f2109c713c50016315883f2e80624 100644 (file)
@@ -24,9 +24,11 @@ ERROR: bad-effect ;
 : parse-effect-tokens ( end -- tokens )
     [ parse-effect-token dup ] curry [ ] produce nip ;
 
+ERROR: stack-effect-omits-dashes effect ;
+
 : parse-effect ( end -- effect )
     parse-effect-tokens { "--" } split1 dup
-    [ <effect> ] [ "Stack effect declaration must contain --" throw ] if ;
+    [ <effect> ] [ drop stack-effect-omits-dashes ] if ;
 
 : complete-effect ( -- effect )
     "(" expect ")" parse-effect ;
index 73002a5d89b3acceabc06d0a278b3e9c48f0d400..99c9783075ab2a1abd8c6d830caa3d1001bee643 100644 (file)
@@ -9,7 +9,7 @@ ARTICLE: "method-order" "Method precedence"
 $nl
 "Here is an example:"
 { $code
-    "GENERIC: explain"
+    "GENERIC: explain ( object -- )"
     "M: object explain drop \"an object\" print ;"
     "M: number explain drop \"a number\" print ;"
     "M: sequence explain drop \"a sequence\" print ;"
@@ -17,7 +17,7 @@ $nl
 "The linear order is the following, from least-specific to most-specific:"
 { $code "{ object sequence number }" }
 "Neither " { $link number } " nor " { $link sequence } " are subclasses of each other, yet their intersection is the non-empty " { $link integer } " class. Calling " { $snippet "explain" } " with an integer on the stack will print " { $snippet "a number" } " because " { $link number } " precedes " { $link sequence } " in the class linearization order. If this was not the desired outcome, define a method on the intersection:"
-{ $code "M: integer explain drop \"a sequence\" print ;" }
+{ $code "M: integer explain drop \"an integer\" print ;" }
 "Now, the linear order is the following, from least-specific to most-specific:"
 { $code "{ object sequence number integer }" }
 "The " { $link order } " word can be useful to clarify method dispatch order:"
index 51e122431cfcffbc3b5b2bd5b775d421bbbb0778..2279fd019cf5c9d4680583ee9b1c6ef1d93b11ca 100644 (file)
@@ -1,5 +1,5 @@
-IN: generic.math.tests
 USING: generic.math math tools.test kernel ;
+IN: generic.math.tests
 
 ! Test math-combination
 [ [ [ >float ] dip ] ] [ \ real \ float math-upgrade ] unit-test
index 61ae4e1ba1090db669be21602f03af8ebc88ac22..f59268b770312caa7566d8bfe88a4d5adf969753 100644 (file)
@@ -1,10 +1,10 @@
-IN: generic.single.tests
 USING: tools.test math math.functions math.constants generic.standard
 generic.single strings sequences arrays kernel accessors words
 specialized-arrays.double byte-arrays bit-arrays parser namespaces
 make quotations stack-checker vectors growable hashtables sbufs
 prettyprint byte-vectors bit-vectors specialized-vectors.double
 definitions generic sets graphs assocs grouping see eval ;
+IN: generic.single.tests
 
 GENERIC: lo-tag-test ( obj -- obj' )
 
@@ -279,4 +279,4 @@ M: growable call-next-hooker call-next-method "growable " prepend ;
 ! Corner case
 [ "IN: generic.single.tests GENERIC# broken-generic# -1 ( a -- b )" eval( -- ) ]
 [ error>> bad-dispatch-position? ]
-must-fail-with
\ No newline at end of file
+must-fail-with
index 9a773f43a2b5c0f78fe38afb6896243cbd0ec365..8a53368062d285979c9505670b0765a797287654 100644 (file)
@@ -145,7 +145,7 @@ GENERIC: compile-engine ( engine -- obj )
     default get <array> [ <enum> swap update ] keep ;
 
 : lo-tag-number ( class -- n )
-    "type" word-prop dup num-tags get member?
+    "type" word-prop dup num-tags get iota member?
     [ drop object tag-number ] unless ;
 
 M: tag-dispatch-engine compile-engine
@@ -208,9 +208,11 @@ SYMBOL: predicate-engines
 : keep-going? ( assoc -- ? )
     assumed get swap second first class<= ;
 
+ERROR: unreachable ;
+
 : prune-redundant-predicates ( assoc -- default assoc' )
     {
-        { [ dup empty? ] [ drop [ "Unreachable" throw ] { } ] }
+        { [ dup empty? ] [ drop [ unreachable ] { } ] }
         { [ dup length 1 = ] [ first second { } ] }
         { [ dup keep-going? ] [ rest-slice prune-redundant-predicates ] }
         [ [ first second ] [ rest-slice ] bi ]
index 004b543c7f879936e1f255204e423ff10240fb0e..54e58c0282729653e990cf8052d7fab3c3bcd66f 100644 (file)
@@ -1,7 +1,7 @@
-IN: hashtables.tests
 USING: kernel math namespaces make tools.test vectors sequences
 sequences.private hashtables io prettyprint assocs
 continuations ;
+IN: hashtables.tests
 
 [ f ] [ "hi" V{ 1 2 3 } at ] unit-test
 
@@ -178,4 +178,4 @@ H{ } "x" set
 [ 1 ] [ 2 "h" get at ] unit-test
 
 ! Random test case
-[ "A" ] [ 100 [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
\ No newline at end of file
+[ "A" ] [ 100 [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
index c3d7e8e89bf3f7b55205d3c45507c640b9dbea6a..7d668eeab117578d28cdd06843fd9bbbd928a009 100644 (file)
@@ -1,4 +1,4 @@
-IN: io.backend.tests
 USING: tools.test io.backend kernel ;
+IN: io.backend.tests
 
 [ ] [ "a" normalize-path drop ] unit-test
index cf2781aac074c1022d45e99f79fb63f2d4760a14..f5467daea6bc1b053584319d1bdbd98ed88051bc 100644 (file)
@@ -10,7 +10,7 @@ IN: io.binary
 
 : nth-byte ( x n -- b ) -8 * shift mask-byte ; inline
 
-: >le ( x n -- byte-array ) [ nth-byte ] with B{ } map-as ;
+: >le ( x n -- byte-array ) iota [ nth-byte ] with B{ } map-as ;
 : >be ( x n -- byte-array ) >le dup reverse-here ;
 
 : d>w/w ( d -- w1 w2 )
index 4846b06f32d29023bbf2d257a24c2554d3852b61..a722655cad4a81dfcecf2e094bab0ae2a23392ad 100755 (executable)
@@ -73,14 +73,14 @@ M: utf8 encode-char
 PRIVATE>
 
 : code-point-length ( n -- x )
-    dup zero? [ drop 1 ] [
+    [ 1 ] [
         log2 {
             { [ dup 0 6 between? ] [ 1 ] }
             { [ dup 7 10 between? ] [ 2 ] }
             { [ dup 11 15 between? ] [ 3 ] }
             { [ dup 16 20 between? ] [ 4 ] }
         } cond nip
-    ] if ;
+    ] if-zero ;
 
 : code-point-offsets ( string -- indices )
     0 [ code-point-length + ] accumulate swap suffix ;
index ac74e6b11e68163667991b8a48fa862e47355b2d..70136f81eb87c092178a0d6f0ed828799503274c 100644 (file)
@@ -296,7 +296,7 @@ ARTICLE: "stdio-motivation" "Motivation for default streams"
     "    16 group"
     "] with-disposal"
 }
-"This code is robust however it is more complex than it needs to be since. This is where the default stream words come in; using them, the above can be rewritten as follows:"
+"This code is robust, however it is more complex than it needs to be. This is where the default stream words come in; using them, the above can be rewritten as follows:"
 { $code
     "USING: continuations kernel io io.files math.parser splitting ;"
     "\"data.txt\" utf8 <file-reader> ["
@@ -338,7 +338,6 @@ $nl
 { $subsection write1 }
 { $subsection write }
 "If the default output stream is a character stream (" { $link stream-element-type } " outputs " { $link +character+ } "), lines of text can be written:"
-{ $subsection readln }
 { $subsection print }
 { $subsection nl }
 { $subsection bl }
index ad5453af6174eae2dc7b41127d2f212c01574d8e..e7b4338388c49a1ab22ed3a634299697aa915080 100644 (file)
@@ -12,4 +12,4 @@ M: memory-stream stream-element-type drop +byte+ ;
 
 M: memory-stream stream-read1
     [ [ alien>> ] [ index>> ] bi alien-unsigned-1 ]
-    [ [ 1+ ] change-index drop ] bi ;
+    [ [ 1 + ] change-index drop ] bi ;
index b617544084c32516abaa295d1c7279f273dea7e6..4f4ad18837ceeb7bdaa03f7ad0057c216ce63e8e 100644 (file)
@@ -803,7 +803,7 @@ ARTICLE: "looping-combinators" "Looping combinators"
 { $subsection until }
 "To execute one iteration of a loop, use the following word:"
 { $subsection do }
-"This word is intended as a modifier. The normal " { $link while } " loop never executes the body if the predicate returns first on the first iteration. To ensure the body executes at least once, use " { $link do } ":"
+"This word is intended as a modifier. The normal " { $link while } " loop never executes the body if the predicate returns false on the first iteration. To ensure the body executes at least once, use " { $link do } ":"
 { $code
     "[ P ] [ Q ] do while"
 }
index b0c5d8cfda69a13d7582b0c50aa35fc4df0b2e09..5a39f2462742afb8e2e93f04dad2242032aa61a9 100644 (file)
@@ -1,5 +1,5 @@
-IN: system.tests\r
 USING: layouts math tools.test ;\r
+IN: system.tests\r
 \r
 [ t ] [ cell integer? ] unit-test\r
 [ t ] [ bootstrap-cell integer? ] unit-test\r
index 99e6f05c6c6df186cb947b43a2d297ebe1c139ad..036c7d9721bc48cf7575d2c942e33ea039b2d1d2 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences accessors namespaces math words strings
-io vectors arrays math.parser combinators continuations ;
+io vectors arrays math.parser combinators continuations
+source-files.errors ;
 IN: lexer
 
 TUPLE: lexer text line line-text line-length column ;
@@ -24,11 +25,8 @@ TUPLE: lexer text line line-text line-length column ;
 
 ERROR: unexpected want got ;
 
-PREDICATE: unexpected-tab < unexpected
-    got>> CHAR: \t = ;
-
 : forbid-tab ( c -- c )
-    [ CHAR: \t eq? [ "[space]" "[tab]" unexpected ] when ] keep ;
+    [ CHAR: \t eq? [ "[space]" "[tab]" unexpected ] when ] keep ; inline
 
 : skip ( i seq ? -- n )
     over length
@@ -96,6 +94,9 @@ PREDICATE: unexpected-eof < unexpected
 
 TUPLE: lexer-error line column line-text error ;
 
+M: lexer-error error-file error>> error-file ;
+M: lexer-error error-line [ error>> error-line ] [ line>> ] bi or ;
+
 : <lexer-error> ( msg -- error )
     \ lexer-error new
         lexer get
index 6a77ef65fca8c7dc5e5dcb3eb307c8b638a28352..1fc59fce62cf9cbd60a3216cfc10bbed82619471 100644 (file)
@@ -14,7 +14,7 @@ $nl
 $nl
 "On the other hand, using " { $link make } " instead of a single call to " { $link surround } " is overkill. The below headings summarize the most important cases where other idioms are more appropriate than " { $link make } "."
 { $heading "Make versus combinators" }
-"Sometimes, usages of " { $link make } " are better expressed with " { $link "sequences-combinators" } ". For example, instead of calling a combinator with a quotation which executes " { $link , } " exactly once on each iteration, oftena combinator encapsulating that specific idiom exists and can be used."
+"Sometimes, usages of " { $link make } " are better expressed with " { $link "sequences-combinators" } ". For example, instead of calling a combinator with a quotation which executes " { $link , } " exactly once on each iteration, often a combinator encapsulating that specific idiom exists and can be used."
 $nl
 "For example,"
 { $code "[ [ 42 * , ] each ] { } make" }
index bb7fc107b2aec2a255f1ba1f048dcd8ff79907b3..2b35ef76fd72a75edde2cb855a90b57f521f52a2 100644 (file)
@@ -121,14 +121,14 @@ M: bignum (log2) bignum-log2 ;
     over zero? [
         2drop 0.0
     ] [
-        dup zero? [
-            2drop 1/0.
+        [
+            drop 1/0.
         ] [
             pre-scale
             /f-loop over odd?
             [ zero? [ 1 + ] unless ] [ drop ] if
             post-scale
-        ] if
+        ] if-zero
     ] if ; inline
 
 M: bignum /f ( m n -- f )
index 55a50cd5d799f4575620315faf8c6ba2215d62bf..c4a1bb4f345af8a2df942edba4148896fccfe64e 100644 (file)
@@ -213,9 +213,9 @@ HELP: sgn
 { $description
     "Outputs one of the following:"
     { $list
-        "-1 if " { $snippet "x" } " is negative"
-        "0 if " { $snippet "x" } " is equal to 0"
-        "1 if " { $snippet "x" } " is positive"
+        { "-1 if " { $snippet "x" } " is negative" }
+        { "0 if " { $snippet "x" } " is equal to 0" }
+        { "1 if " { $snippet "x" } " is positive" }
     }
 } ;
 
index 28efbaa26e4a099b8c7502b2f6cef23f13573a54..8fa56e6e2496942287d2f0f9faf6781aaf81626d 100755 (executable)
@@ -48,9 +48,11 @@ GENERIC: (log2) ( x -- n ) foldable
 
 PRIVATE>
 
+ERROR: log2-expects-positive x ;
+
 : log2 ( x -- n )
     dup 0 <= [
-        "log2 expects positive inputs" throw
+        log2-expects-positive
     ] [
         (log2)
     ] if ; inline
index 368d060eb9239bcb06a20d70d7c088c5d4e0e3bf..b2c2eeb9737bb8cc9041637406f4f0c1af4199b4 100644 (file)
@@ -109,7 +109,6 @@ ARTICLE: "math.order" "Linear order protocol"
 { $subsection "order-specifiers" }
 "Utilities for comparing objects:"
 { $subsection after? }
-{ $subsection after? }
 { $subsection before? }
 { $subsection after=? }
 { $subsection before=? }
index cc01699bd4d2790ae1de5fb99660fd55de3915ed..21062baf4bbe985c8d007023720a2d28eb560846 100644 (file)
@@ -135,7 +135,7 @@ M: ratio >base
     [
         dup 0 < negative? set
         abs 1 /mod
-        [ dup zero? [ drop "" ] [ (>base) sign append ] if ]
+        [ [ "" ] [ (>base) sign append ] if-zero ]
         [
             [ numerator (>base) ]
             [ denominator (>base) ] bi
index eb2968ece7d9dc6bf6bad8632bf649557a9a929b..8ee2ca99c2586f626da5327463b98a1fbae779ba 100644 (file)
@@ -31,12 +31,12 @@ HELP: instances
 HELP: gc ( -- )
 { $description "Performs a full garbage collection." } ;
 
-HELP: data-room ( -- cards generations )
-{ $values { "cards" "number of bytes reserved for card marking" } { "generations" "array of free/total bytes pairs" } }
+HELP: data-room ( -- cards decks generations )
+{ $values { "cards" "number of kilobytes reserved for card marking" } { "decks" "number of kilobytes reserved for decks of cards" } { "generations" "array of free/total kilobytes pairs" } }
 { $description "Queries the runtime for memory usage information." } ;
 
-HELP: code-room ( -- code-free code-total )
-{ $values { "code-free" "bytes free in the code heap" } { "code-total" "total bytes in the code heap" } }
+HELP: code-room ( -- code-total code-used code-free largest-free-block )
+{ $values { "code-total" "total kilobytes in the code heap" } { "code-used" "kilobytes used in the code heap" } { "code-free" "kilobytes free in the code heap" } { "largest-free-block" "size of largest free block" } }
 { $description "Queries the runtime for memory usage information." } ;
 
 HELP: size ( obj -- n )
index ec0810509bf2df1ff171d93dfd7365ef74e8b4db..146b1afdfae93b7e06a7b3a2cdcd2c9dc3fcaaa9 100644 (file)
@@ -54,7 +54,7 @@ $nl
 ARTICLE: "parsing-words" "Parsing words"
 "The Factor parser follows a simple recursive-descent design. The parser reads successive tokens from the input; if the token identifies a number or an ordinary word, it is added to an accumulator vector. Otherwise if the token identifies a parsing word, the parsing word is executed immediately."
 $nl
-"Parsing words are defined using the defining word:"
+"Parsing words are defined using the defining word:"
 { $subsection POSTPONE: SYNTAX: }
 "Parsing words have uppercase names by convention. Here is the simplest possible parsing word; it prints a greeting at parse time:"
 { $code "SYNTAX: HELLO \"Hello world\" print ;" }
index 71d42705a2d71f0b98f149e95acc3bd5abd9fd3c..fbdd8268dac6048adcd67486318a82865972c346 100755 (executable)
@@ -123,7 +123,48 @@ HELP: unless-empty
     }
 } ;
 
-{ if-empty when-empty unless-empty } related-words
+HELP: if-zero
+{ $values { "n" number } { "quot1" quotation } { "quot2" quotation } }
+{ $description "Makes an implicit check if the number is zero. A zero is dropped and " { $snippet "quot1" } " is called. Otherwise, if the number is not zero, " { $snippet "quot2" } " is called on it." }
+{ $example
+    "USING: kernel math prettyprint sequences ;"
+    "3 [ \"zero\" ] [ sq ] if-zero ."
+    "9"
+} ;
+
+HELP: when-zero
+{ $values
+     { "n" number } { "quot" "the first quotation of an " { $link if-zero } } }
+{ $description "Makes an implicit check if the sequence is empty. A zero is dropped and the " { $snippet "quot" } " is called." }
+{ $examples "This word is equivalent to " { $link if-zero } " with an empty second quotation:"
+    { $example
+    "USING: sequences prettyprint ;"
+    "0 [ 4 ] [ ] if-zero ."
+    "4"
+    }
+    { $example
+    "USING: sequences prettyprint ;"
+    "0 [ 4 ] when-zero ."
+    "4"
+    }
+} ;
+
+HELP: unless-zero
+{ $values
+     { "n" number } { "quot" "the second quotation of an " { $link if-empty } } }
+{ $description "Makes an implicit check if the number is zero. A zero is dropped. Otherwise, the " { $snippet "quot" } " is called on the number." }
+{ $examples "This word is equivalent to " { $link if-zero } " with an empty first quotation:"
+    { $example
+    "USING: sequences math prettyprint ;"
+    "3 [ ] [ sq ] if-empty ."
+    "9"
+    }
+    { $example
+    "USING: sequences math prettyprint ;"
+    "3 [ sq ] unless-zero ."
+    "9"
+    }
+} ;
 
 HELP: delete-all
 { $values { "seq" "a resizable sequence" } }
@@ -1214,7 +1255,7 @@ HELP: follow
 { $examples "Get random numbers until zero is reached:"
     { $unchecked-example
     "USING: random sequences prettyprint math ;"
-    "100 [ random dup zero? [ drop f ] when ] follow ."
+    "100 [ random [ f ] when-zero ] follow ."
     "{ 100 86 34 32 24 11 7 2 }"
 } } ;
 
@@ -1393,6 +1434,18 @@ $nl
 $nl
 "More elaborate counted loops can be performed with " { $link "math.ranges" } "." ;
 
+ARTICLE: "sequences-if" "Control flow with sequences"
+"To reduce the boilerplate of checking if a sequence is empty or a number is zero, several combinators are provided."
+$nl
+"Checking if a sequence is empty:"
+{ $subsection if-empty }
+{ $subsection when-empty }
+{ $subsection unless-empty }
+"Checking if a number is zero:"
+{ $subsection if-zero }
+{ $subsection when-zero }
+{ $subsection unless-zero } ;
+
 ARTICLE: "sequences-access" "Accessing sequence elements"
 { $subsection ?nth }
 "Concise way of extracting one of the first four elements:"
@@ -1658,6 +1711,8 @@ $nl
 "Using sequences for looping:"
 { $subsection "sequences-integers" }
 { $subsection "math.ranges" }
+"Using sequences for control flow:"
+{ $subsection "sequences-if" }
 "For inner loops:"
 { $subsection "sequences-unsafe" } ;
 
index 17dbcf5c3cbb8b7a87e8df8d00cafe7de0801e07..aecc9e33d8fd9f0e771921d2d6cf2c25d5f9cb88 100755 (executable)
@@ -29,13 +29,27 @@ M: sequence shorten 2dup length < [ set-length ] [ 2drop ] if ;
 
 : empty? ( seq -- ? ) length 0 = ; inline
 
+<PRIVATE
+
+: (if-empty) ( seq quot1 quot2 quot3 -- )
+    [ [ drop ] prepose ] [ ] tri* if ; inline
+
+PRIVATE>
+
 : if-empty ( seq quot1 quot2 -- )
-    [ dup empty? ] [ [ drop ] prepose ] [ ] tri* if ; inline
+    [ dup empty? ] (if-empty) ; inline
 
 : when-empty ( seq quot -- ) [ ] if-empty ; inline
 
 : unless-empty ( seq quot -- ) [ ] swap if-empty ; inline
 
+: if-zero ( n quot1 quot2 -- )
+    [ dup zero? ] (if-empty) ; inline
+
+: when-zero ( n quot -- ) [ ] if-zero ; inline
+
+: unless-zero ( n quot -- ) [ ] swap if-zero ; inline
+
 : delete-all ( seq -- ) 0 swap set-length ;
 
 : first ( seq -- first ) 0 swap nth ; inline
@@ -267,9 +281,11 @@ INSTANCE: repetition immutable-sequence
 
 <PRIVATE
 
+ERROR: integer-length-expected obj ;
+
 : check-length ( n -- n )
     #! Ricing.
-    dup integer? [ "length not an integer" throw ] unless ; inline
+    dup integer? [ integer-length-expected ] unless ; inline
 
 : ((copy)) ( dst i src j n -- dst i src j n )
     dup -roll [
@@ -414,8 +430,11 @@ PRIVATE>
 : reduce ( seq identity quot -- result )
     swapd each ; inline
 
+: map-integers ( len quot exemplar -- newseq )
+    [ over ] dip [ [ collect ] keep ] new-like ; inline
+
 : map-as ( seq quot exemplar -- newseq )
-    [ over length ] dip [ [ map-into ] keep ] new-like ; inline
+    [ (each) ] dip map-integers ; inline
 
 : map ( seq quot -- newseq )
     over map-as ; inline
@@ -442,7 +461,7 @@ PRIVATE>
     [ -rot ] dip 2each ; inline
 
 : 2map-as ( seq1 seq2 quot exemplar -- newseq )
-    [ (2each) ] dip map-as ; inline
+    [ (2each) ] dip map-integers ; inline
 
 : 2map ( seq1 seq2 quot -- newseq )
     pick 2map-as ; inline
@@ -454,7 +473,7 @@ PRIVATE>
     (3each) each ; inline
 
 : 3map-as ( seq1 seq2 seq3 quot exemplar -- newseq )
-    [ (3each) ] dip map-as ; inline
+    [ (3each) ] dip map-integers ; inline
 
 : 3map ( seq1 seq2 seq3 quot -- newseq )
     [ pick ] dip swap 3map-as ; inline
@@ -701,7 +720,7 @@ PRIVATE>
     3tri ;
 
 : reverse-here ( seq -- )
-    [ length 2/ ] [ length ] [ ] tri
+    [ length 2/ iota ] [ length ] [ ] tri
     [ [ over - 1 - ] dip exchange-unsafe ] 2curry each ;
 
 : reverse ( seq -- newseq )
@@ -805,14 +824,14 @@ PRIVATE>
 <PRIVATE
 
 : (start) ( subseq seq n -- subseq seq ? )
-    pick length [
+    pick length iota [
         [ 3dup ] dip [ + swap nth-unsafe ] keep rot nth-unsafe =
     ] all? nip ; inline
 
 PRIVATE>
 
 : start* ( subseq seq n -- i )
-    pick length pick length swap - 1 +
+    pick length pick length swap - 1 + iota
     [ (start) ] find-from
     swap [ 3drop ] dip ;
 
index 1365e815242efa192f49d02f131fb66f8c9371ab..81251d728fd75b755461b811116641fb2a314b97 100644 (file)
@@ -1,6 +1,6 @@
-IN: slots.tests
 USING: math accessors slots strings generic.single kernel
 tools.test generic words parser eval math.functions ;
+IN: slots.tests
 
 TUPLE: r/w-test foo ;
 
index 290ca1470cc68f1a1f8bd38e75df59f68876f4e1..c30c06a989bd0c528f7c75bfa3e9c851929143bc 100644 (file)
@@ -12,6 +12,8 @@ $nl
 "Sorting a sequence with a custom comparator:"
 { $subsection sort }
 "Sorting a sequence with common comparators:"
+{ $subsection sort-with }
+{ $subsection inv-sort-with }
 { $subsection natural-sort }
 { $subsection sort-keys }
 { $subsection sort-values } ;
@@ -20,16 +22,24 @@ ABOUT: "sequences-sorting"
 
 HELP: sort
 { $values { "seq" "a sequence" } { "quot" { $quotation "( obj1 obj2 -- <=> )" } } { "sortedseq" "a new sorted sequence" } }
-{ $description "Sorts the elements into a new array using a stable sort." }
+{ $description "Sorts the elements of " { $snippet "seq" } " into a new array using a stable sort." }
 { $notes "The algorithm used is the merge sort." } ;
 
+HELP: sort-with
+{ $values { "seq" "a sequence" } { "quot" { $quotation "( object -- key )" } } { "sortedseq" "a new sorted sequence" } }
+{ $description "Sorts the elements of " { $snippet "seq" } " by applying " { $link compare } " with " { $snippet "quot" } " to each pair of elements in the sequence." } ;
+
+HELP: inv-sort-with
+{ $values { "seq" "a sequence" } { "quot" { $quotation "( object -- key )" } } { "sortedseq" "a new sorted sequence" } }
+{ $description "Sorts the elements of " { $snippet "seq" } " by applying " { $link compare } " with " { $snippet "quot" } " to each pair of elements in the sequence and inverting the results." } ;
+
 HELP: sort-keys
 { $values { "seq" "an alist" } { "sortedseq" "a new sorted sequence" } }
-{ $description "Sorts the elements comparing first elements of pairs using the " { $link <=> } " word." } ;
+{ $description "Sorts the elements of " { $snippet "seq" } " comparing first elements of pairs using the " { $link <=> } " word." } ;
 
 HELP: sort-values
 { $values { "seq" "an alist" } { "sortedseq" "a new sorted sequence" } }
-{ $description "Sorts the elements comparing second elements of pairs using the " { $link <=> } " word." } ;
+{ $description "Sorts the elements of " { $snippet "seq" } " comparing second elements of pairs using the " { $link <=> } " word." } ;
 
 HELP: natural-sort
 { $values { "seq" "a sequence of real numbers" } { "sortedseq" "a new sorted sequence" } }
@@ -43,4 +53,4 @@ HELP: midpoint@
 { $values { "seq" "a sequence" } { "n" integer } }
 { $description "Outputs the index of the midpoint of " { $snippet "seq" } "." } ;
 
-{ <=> compare natural-sort sort-keys sort-values } related-words
+{ <=> compare natural-sort sort-with inv-sort-with sort-keys sort-values } related-words
index 0c0951bbceb5d150ccd64fde3bad33762e3ab62e..b8258b239bfebd28e1d126d22541262de9374a2e 100644 (file)
@@ -155,8 +155,13 @@ PRIVATE>
 
 : natural-sort ( seq -- sortedseq ) [ <=> ] sort ;
 
-: sort-keys ( seq -- sortedseq ) [ [ first ] compare ] sort ;
+: sort-with ( seq quot -- sortedseq )
+    [ compare ] curry sort ; inline
+: inv-sort-with ( seq quot -- sortedseq )
+    [ compare invert-comparison ] curry sort ; inline
 
-: sort-values ( seq -- sortedseq ) [ [ second ] compare ] sort ;
+: sort-keys ( seq -- sortedseq ) [ first ] sort-with ;
+
+: sort-values ( seq -- sortedseq ) [ second ] sort-with ;
 
 : sort-pair ( a b -- c d ) 2dup after? [ swap ] when ;
index f6f4f4825aaf9b8da76ff17d9b01d402557f7267..93078c162b9d75aac21129c83df2ad4b1e3b379f 100644 (file)
@@ -1,13 +1,25 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs kernel math.order sorting sequences definitions
-namespaces arrays splitting io math.parser math init ;
+namespaces arrays splitting io math.parser math init continuations ;
 IN: source-files.errors
 
+GENERIC: error-file ( error -- file )
+GENERIC: error-line ( error -- line )
+
+M: object error-file drop f ;
+M: object error-line drop f ;
+
+M: condition error-file error>> error-file ;
+M: condition error-line error>> error-line ;
+
 TUPLE: source-file-error error asset file line# ;
 
+M: source-file-error error-file [ error>> error-file ] [ file>> ] bi or ;
+M: source-file-error error-line [ error>> error-line ] [ line#>> ] bi or ;
+
 : sort-errors ( errors -- alist )
-    [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ;
+    [ [ line#>> ] sort-with ] { } assoc-map-as sort-keys ;
 
 : group-by-source-file ( errors -- assoc )
     H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ;
index 5ec396e5ba6301376bc6f134f5c9581ad0ca8f3d..7aae30f20b356667fab9f1ef25ee456ff7ecc93d 100644 (file)
@@ -58,7 +58,7 @@ PRIVATE>
 : (split) ( separators n seq -- )
     3dup rot [ member? ] curry find-from drop
     [ [ swap subseq , ] 2keep 1 + swap (split) ]
-    [ swap dup zero? [ drop ] [ tail ] if , drop ] if* ; inline recursive
+    [ swap [ tail ] unless-zero , drop ] if* ; inline recursive
 
 : split, ( seq separators -- ) 0 rot (split) ;
 
old mode 100644 (file)
new mode 100755 (executable)
index 574f8afe8198152d48fc2eb19fbbeb87a116be29..806d09bf9ecc6e926eb2ddc1f683afb3076e43c9 100644 (file)
@@ -276,6 +276,7 @@ HELP: parsing-word?
 HELP: define-declared
 { $values { "word" word } { "def" quotation } { "effect" effect } }
 { $description "Defines a word and declares its stack effect." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
 { $side-effects "word" } ;
 
 HELP: define-temp
@@ -311,4 +312,5 @@ HELP: make-inline
 HELP: define-inline
 { $values { "word" word } { "def" quotation } { "effect" effect } }
 { $description "Defines a word and makes it " { $link POSTPONE: inline } "." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
 { $side-effects "word" } ;
index c659e109ce3715d9f99f2184d935b47c633a7999..cc09ad52813e4df2fbabc61f431e77f168549c54 100755 (executable)
@@ -57,7 +57,7 @@ t to: remove-hidden-solids?
 \r
 : with-pv ( i quot -- ) [ swap >pv call ] with-scope  ; inline\r
 \r
-: dimension ( array -- x )      length 1- ; inline \r
+: dimension ( array -- x )      length 1 - ; inline \r
 : change-last ( seq quot -- ) \r
     [ [ dimension ] keep ] dip change-nth  ; inline\r
 \r
@@ -99,7 +99,7 @@ TUPLE: light name { direction array } color ;
 : point-inside-or-on-halfspace? ( halfspace v -- ? ) \r
     position-point VERY-SMALL-NUM neg > ;\r
 : project-vector (  seq -- seq )     \r
-    pv> [ head ] [ 1+  tail ] 2bi append ; \r
+    pv> [ head ] [ 1 +  tail ] 2bi append ; \r
 : get-intersection ( matrice -- seq )     \r
     [ 1 tail* ] map     flip first ;\r
 \r
@@ -336,7 +336,7 @@ TUPLE: solid dimension silhouettes
 : compute-adjacencies ( solid -- solid )\r
     dup dimension>> [ >= ] curry \r
     [ keep swap ] curry MAX-FACE-PER-CORNER swap\r
-    [ [ test-faces-combinaisons ] 2keep 1- ] while drop ;\r
+    [ [ test-faces-combinaisons ] 2keep 1 - ] while drop ;\r
 \r
 : find-adjacencies ( solid -- solid ) \r
     erase-old-adjacencies   \r
@@ -435,7 +435,7 @@ TUPLE: space name dimension solids ambient-color lights ;
     [ [ non-empty-solid? ] filter ] change-solids ;\r
 \r
 : projected-space ( space solids -- space ) \r
-   swap dimension>> 1-  <space>    \r
+   swap dimension>> 1 -  <space>    \r
    swap >>dimension    swap  >>solids ;\r
 \r
 : get-silhouette ( solid -- silhouette )    \r
index 4e4bbff72d57d8d3135263d8951e9d4ec19d6e42..d00eebc9763497ba1bced13f7d38161774874bdc 100755 (executable)
@@ -13,7 +13,7 @@ IN: adsoda.combinators
 !        { [ dup 0 = ] [ 2drop { { } } ] }\r
 !        { [ over empty? ] [ 2drop { } ] }\r
 !        { [ t ] [ \r
-!            [ [ 1- (combinations) ] [ drop first ] 2bi prefix-each ]\r
+!            [ [ 1 - (combinations) ] [ drop first ] 2bi prefix-each ]\r
 !            [ (combinations) ] 2bi append\r
 !        ] }\r
 !    } cond ;\r
@@ -26,7 +26,7 @@ IN: adsoda.combinators
         { [ over 1 = ] [ 3drop columnize ] }\r
         { [ over 0 = ] [ 2drop 2drop { } ] }\r
         { [ 2dup < ] [ 2drop [ 1 cut ] dip  \r
-                         [ 1- among [ append ] with map  ] \r
+                         [ 1 - among [ append ] with map  ] \r
                          [ among append ] 2bi\r
                        ] }\r
         { [ 2dup = ] [ 3drop 1array ] }\r
index 3e0648128de9746937e1e4b4a87b6f33212693be..fa73120df364a11d1c3421971cc3768b85d0119a 100755 (executable)
@@ -66,7 +66,7 @@ SYMBOL: matrix
 : do-row ( exchange-with row# -- )\r
     [ exchange-rows ] keep\r
     [ first-col ] keep\r
-    dup 1+ rows-from clear-col ;\r
+    dup 1 + rows-from clear-col ;\r
 \r
 : find-row ( row# quot -- i elt )\r
     [ rows-from ] dip find ; inline\r
@@ -76,8 +76,8 @@ SYMBOL: matrix
 \r
 : (echelon) ( col# row# -- )\r
     over cols < over rows < and [\r
-        2dup pivot-row [ over do-row 1+ ] when*\r
-        [ 1+ ] dip (echelon)\r
+        2dup pivot-row [ over do-row 1 + ] when*\r
+        [ 1 + ] dip (echelon)\r
     ] [\r
         2drop\r
     ] if ;\r
index d5a13e48d8988756b4e11a36a11b13d53c2929ff..48fd281c6cdf8c37b670c1fd8be2d772f1ae794b 100644 (file)
@@ -10,7 +10,7 @@ IN: annotations.tests
 
 : four ( -- x )
     !BROKEN this code is broken
-    2 2 + 1+ ;
+    2 2 + 1 + ;
 
 : five ( -- x )
     !TODO return 5
index 6b3fd41575fbc58ef6d70da405ccfbc895016f1c..14ebcb1c5b4e50bfbda653b63b6928af992f14a5 100755 (executable)
@@ -15,7 +15,7 @@ IN: benchmark.beust2
                     remaining 1 <= [
                         listener call f
                     ] [
-                        remaining 1-
+                        remaining 1 -
                         0
                         value' 10 *
                         used mask bitor
@@ -29,12 +29,12 @@ IN: benchmark.beust2
     ] any? ; inline recursive
 
 :: count-numbers ( max listener -- )
-    10 iota [ 1+ 1 1 0 max listener (count-numbers) ] any? drop ;
+    10 iota [ 1 + 1 1 0 max listener (count-numbers) ] any? drop ;
     inline
 
 :: beust ( -- )
     [let | i! [ 0 ] |
-        5000000000 [ i 1+ i! ] count-numbers
+        5000000000 [ i 1 + i! ] count-numbers
         i number>string " unique numbers." append print
     ] ;
 
diff --git a/extra/benchmark/chameneos-redux/authors.txt b/extra/benchmark/chameneos-redux/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/extra/benchmark/chameneos-redux/chameneos-redux.factor b/extra/benchmark/chameneos-redux/chameneos-redux.factor
new file mode 100644 (file)
index 0000000..afd2f88
--- /dev/null
@@ -0,0 +1,106 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors arrays assocs combinators
+concurrency.mailboxes fry io kernel make math math.parser
+math.text.english sequences threads ;
+IN: benchmark.chameneos-redux
+
+SYMBOLS: red yellow blue ;
+
+ERROR: bad-color-pair pair ;
+
+TUPLE: creature n color count self-count mailbox ;
+
+TUPLE: meeting-place count mailbox ;
+
+: <meeting-place> ( count -- meeting-place )
+    meeting-place new
+        swap >>count
+        <mailbox> >>mailbox ;
+
+: <creature> ( n color -- creature )
+    creature new
+        swap >>color
+        swap >>n
+        0 >>count
+        0 >>self-count
+        <mailbox> >>mailbox ;
+
+: make-creatures ( colors -- seq )
+    [ length iota ] [ ] bi [ <creature> ] 2map ;
+
+: complement-color ( color1 color2 -- color3 )
+    2dup = [ drop ] [
+        2array {
+            { { red yellow } [ blue ] }
+            { { red blue } [ yellow ] }
+            { { yellow red } [ blue ] }
+            { { yellow blue } [ red ] }
+            { { blue red } [ yellow ] }
+            { { blue yellow } [ red ] }
+            [ bad-color-pair ]
+        } case
+    ] if ;
+
+: color-string ( color1 color2 -- string )
+    [
+        [ [ name>> ] bi@ " + " glue % " -> " % ]
+        [ complement-color name>> % ] 2bi
+    ] "" make ;
+
+: print-color-table ( -- )
+    { blue red yellow } dup
+    '[ _ '[ color-string print ] with each ] each ;
+
+: try-meet ( meeting-place creature -- )
+    over count>> 0 < [
+        2drop
+    ] [
+        [ swap mailbox>> mailbox-put ]
+        [ nip mailbox>> mailbox-get drop ]
+        [ try-meet ] 2tri
+    ] if ;
+
+: creature-meeting ( seq -- )
+    first2 {
+        [ [ [ 1 + ] change-count ] bi@ 2drop ]
+        [ 2dup = [ [ 1 + ] change-self-count ] when 2drop ]
+        [ [ [ color>> ] bi@ complement-color ] [ [ (>>color) ] bi-curry@ bi ] 2bi ]
+        [ [ mailbox>> f swap mailbox-put ] bi@ ]
+    } 2cleave ;
+
+: run-meeting-place ( meeting-place -- )
+    [ 1 - ] change-count
+    dup count>> 0 < [
+        mailbox>> mailbox-get-all
+        [ f swap mailbox>> mailbox-put ] each
+    ] [
+        [ mailbox>> 2 swap '[ _ mailbox-get ] replicate creature-meeting ]
+        [ run-meeting-place ] bi
+    ] if ;
+
+: number>chameneos-string ( n -- string )
+    number>string string>digits [ number>text ] { } map-as " " join ;
+
+: chameneos-redux ( n colors -- )
+    [ <meeting-place> ] [ make-creatures ] bi*
+    {
+        [ nip nl bl [ bl ] [ color>> name>> write ] interleave nl ]
+        [ [ '[ _ _ try-meet ] in-thread ] with each ]
+        [ drop run-meeting-place ]
+    
+        [ nip [ [ count>> number>string write bl ] [ self-count>> number>text write nl ] bi ] each ]
+        [ nip 0 [ count>> + ] reduce bl number>chameneos-string print ]
+    } 2cleave ;
+
+! 6000000 for shootout, too slow right now
+
+: chameneos-redux-main ( -- )
+    print-color-table
+    60000 [
+        { blue red yellow } chameneos-redux
+    ] [
+        { blue red yellow red yellow blue red yellow red blue } chameneos-redux
+    ] bi ;
+
+MAIN: chameneos-redux-main
index a69c53852deab7ad5e91b56d2e0d154940fb2abf..63e635f3de4ccbe8444d173203dcf8a2d403c356 100644 (file)
@@ -7,7 +7,7 @@ IN: benchmark.fannkuch
 : count ( quot: ( -- ? ) -- n )
     #! Call quot until it returns false, return number of times
     #! it was true
-    [ 0 ] dip '[ _ dip swap [ [ 1+ ] when ] keep ] loop ; inline
+    [ 0 ] dip '[ _ dip swap [ [ 1 + ] when ] keep ] loop ; inline
 
 : count-flips ( perm -- flip# )
     '[
@@ -19,12 +19,12 @@ IN: benchmark.fannkuch
     [ CHAR: 0 + write1 ] each nl ; inline
 
 : fannkuch-step ( counter max-flips perm -- counter max-flips )
-    pick 30 < [ [ 1+ ] [ ] [ dup write-permutation ] tri* ] when
+    pick 30 < [ [ 1 + ] [ ] [ dup write-permutation ] tri* ] when
     count-flips max ; inline
 
 : fannkuch ( n -- )
     [
-        [ 0 0 ] dip [ 1+ ] B{ } map-as
+        [ 0 0 ] dip [ 1 + ] B{ } map-as
         [ fannkuch-step ] each-permutation nip
     ] keep
     "Pfannkuchen(" write pprint ") = " write . ;
index f457b90c309fe7b1d12d517e94db7afd9e3359fb..c1d554a5a3919dc7ddd3631a7abbcee6a3250460 100755 (executable)
@@ -63,7 +63,7 @@ CONSTANT: homo-sapiens
 :: split-lines ( n quot -- )
     n line-length /mod
     [ [ line-length quot call ] times ] dip
-    dup zero? [ drop ] quot if ; inline
+    quot unless-zero ; inline
 
 : write-random-fasta ( seed n chars floats desc id -- seed )
     write-description
index c988e5722e6c693762f0e3bf648bf13c12fb5215..fa49503797be993608ee5981de72145f4dde6009 100644 (file)
@@ -9,10 +9,10 @@ C: <box> box
     dup i>> 1 <= [
         drop 1 <box>
     ] [
-        i>> 1- <box>
+        i>> 1 - <box>
         dup tuple-fib
         swap
-        i>> 1- <box>
+        i>> 1 - <box>
         tuple-fib
         swap i>> swap i>> + <box>
     ] if ; inline recursive
index f81b6a21a2f09a40b3cd6e6f197ad31afdcc1d7f..70ce97597467861d18a4ce93aace175e4ace965e 100755 (executable)
@@ -1,10 +1,10 @@
-IN: benchmark.fib6\r
 USING: math kernel alien ;\r
+IN: benchmark.fib6\r
 \r
 : fib ( x -- y )\r
     "int" { "int" } "cdecl" [\r
         dup 1 <= [ drop 1 ] [\r
-            1- dup fib swap 1- fib +\r
+            1 - dup fib swap 1- fib +\r
         ] if\r
     ] alien-callback\r
     "int" { "int" } "cdecl" alien-indirect ;\r
index d201a08ecf79d7e4ddab211871e5390191966220..8b0a3e6a432ee95b70e0b499867980b194bdde14 100644 (file)
@@ -3,6 +3,6 @@
 USING: math sequences kernel ;
 IN: benchmark.gc1
 
-: gc1 ( -- ) 6000000 [ >bignum 1+ ] map drop ;
+: gc1 ( -- ) 6000000 [ >bignum 1 + ] map drop ;
 
-MAIN: gc1
\ No newline at end of file
+MAIN: gc1
index 99b0ee15f4ea60ecc616e8f55210903469748ccb..fb4f17cca5c768615975aa03451108ebf4bea86a 100644 (file)
@@ -23,12 +23,12 @@ IN: benchmark.knucleotide
 : tally ( x exemplar -- b )
     clone tuck
     [
-      [ [ 1+ ] [ 1 ] if* ] change-at
+      [ [ 1 + ] [ 1 ] if* ] change-at
     ] curry each ;
 
 : small-groups ( x n -- b )
     swap
-    [ length swap - 1+ ] 2keep
+    [ length swap - 1 + ] 2keep
     [ [ over + ] dip subseq ] 2curry map ;
 
 : handle-table ( inputs n -- )
index 9e0f2472e27c4c8563cb51d95c0287ab20bf070b..0300538ce101d0f9d3b07df6039a1fc47ccc3345 100644 (file)
@@ -12,7 +12,7 @@ CONSTANT: val 0.85
 
 : <color-map> ( nb-cols -- map )
     dup [
-        360 * swap 1+ / sat val
+        360 * swap 1 + / sat val
         1 <hsva> >rgba scale-rgb
     ] with map ;
 
index f72ceb46297301bfe24e933a6d0f89e11b2491c6..983da8882176f1a7697d8fea8cdd6746c6599740 100644 (file)
@@ -59,7 +59,7 @@ TUPLE: nbody-system { bodies array read-only } ;
 :: each-pair ( bodies pair-quot: ( other-body body -- ) each-quot: ( body -- ) -- )
     bodies [| body i |
         body each-quot call
-        bodies i 1+ tail-slice [
+        bodies i 1 + tail-slice [
             body pair-quot call
         ] each
     ] each-index ; inline
index 246a962a55b554e00e8b4b1e239a4dbb222162c1..9ccc2d8616171bf851e298534d39dc7d7635b400 100644 (file)
@@ -1,6 +1,6 @@
-IN: benchmark.nsieve-bits
 USING: math math.parser sequences sequences.private kernel
 bit-arrays make io ;
+IN: benchmark.nsieve-bits
 
 : clear-flags ( step i seq -- )
     2dup length >= [
@@ -13,14 +13,14 @@ bit-arrays make io ;
     2dup length < [
         2dup nth-unsafe [
             over dup 2 * pick clear-flags
-            rot 1+ -rot ! increment count
-        ] when [ 1+ ] dip (nsieve-bits)
+            rot 1 + -rot ! increment count
+        ] when [ 1 + ] dip (nsieve-bits)
     ] [
         2drop
     ] if ; inline recursive
 
 : nsieve-bits ( m -- count )
-    0 2 rot 1+ <bit-array> dup set-bits (nsieve-bits) ;
+    0 2 rot 1 + <bit-array> dup set-bits (nsieve-bits) ;
 
 : nsieve-bits. ( m -- )
     [ "Primes up to " % dup # " " % nsieve-bits # ] "" make
@@ -28,7 +28,7 @@ bit-arrays make io ;
 
 : nsieve-bits-main ( n -- )
     dup 2^ 10000 * nsieve-bits.
-    dup 1- 2^ 10000 * nsieve-bits.
+    dup 1 - 2^ 10000 * nsieve-bits.
     2 - 2^ 10000 * nsieve-bits. ;
 
 : nsieve-bits-main* ( -- ) 11 nsieve-bits-main ;
index bbeccf750b3fca290c370e98b9901cb377752cd4..15c0f9ee0b1dc0670c933152d1a5274fcef9759b 100644 (file)
@@ -13,14 +13,14 @@ byte-arrays make io ;
     2dup length < [
         2dup nth-unsafe 0 > [
             over dup 2 * pick clear-flags
-            rot 1+ -rot ! increment count
-        ] when [ 1+ ] dip (nsieve)
+            rot 1 + -rot ! increment count
+        ] when [ 1 + ] dip (nsieve)
     ] [
         2drop
     ] if ; inline recursive
 
 : nsieve ( m -- count )
-    0 2 rot 1+ <byte-array> dup [ drop 1 ] change-each (nsieve) ;
+    0 2 rot 1 + <byte-array> dup [ drop 1 ] change-each (nsieve) ;
 
 : nsieve. ( m -- )
     [ "Primes up to " % dup # " " % nsieve # ] "" make print ;
index 6fbc144e8078ba76573de611446d0560cda9893e..646c98f3a4214f2da60b9e0b06fecb31676d0b7c 100644 (file)
@@ -1,6 +1,6 @@
-IN: benchmark.nsieve
 USING: math math.parser sequences sequences.private kernel
 arrays make io ;
+IN: benchmark.nsieve
 
 : clear-flags ( step i seq -- )
     2dup length >= [
@@ -13,14 +13,14 @@ arrays make io ;
     2dup length < [
         2dup nth-unsafe [
             over dup 2 * pick clear-flags
-            rot 1+ -rot ! increment count
-        ] when [ 1+ ] dip (nsieve)
+            rot 1 + -rot ! increment count
+        ] when [ 1 + ] dip (nsieve)
     ] [
         2drop
     ] if ; inline recursive
 
 : nsieve ( m -- count )
-    0 2 rot 1+ t <array> (nsieve) ;
+    0 2 rot 1 + t <array> (nsieve) ;
 
 : nsieve. ( m -- )
     [ "Primes up to " % dup # " " % nsieve # ] "" make print ;
index 7c7c68b12d741a7e87a48ca32bed0139cb26d918..023f5de5c24d8b21ba88629225294ef6fff92a38 100644 (file)
@@ -5,21 +5,21 @@ combinators hints fry namespaces sequences ;
 IN: benchmark.partial-sums
 
 ! Helper words
-: summing-integers ( n quot -- y ) [ 0.0 ] 2dip '[ 1+ @ + ] each ; inline
+: summing-integers ( n quot -- y ) [ 0.0 ] 2dip '[ 1 + @ + ] each ; inline
 : summing-floats ( n quot -- y ) '[ >float @ ] summing-integers ; inline
 : cube ( x -- y ) dup dup * * ; inline
-: -1^ ( n -- -1/1 ) 2 mod 2 * 1- ; inline
+: -1^ ( n -- -1/1 ) 2 mod 2 * 1 - ; inline
 
 ! The functions
-: 2/3^k ( n -- y ) [ 2.0 3.0 / swap 1- ^ ] summing-floats ; inline
+: 2/3^k ( n -- y ) [ 2.0 3.0 / swap 1 - ^ ] summing-floats ; inline
 : k^-0.5 ( n -- y ) [ -0.5 ^ ] summing-floats ; inline
-: 1/k(k+1) ( n -- y ) [ dup 1+ * recip ] summing-floats ; inline
+: 1/k(k+1) ( n -- y ) [ dup 1 + * recip ] summing-floats ; inline
 : flint-hills ( n -- y ) [ [ cube ] [ sin sq ] bi * recip ] summing-floats ; inline
 : cookson-hills ( n -- y ) [ [ cube ] [ cos sq ] bi * recip ] summing-floats ; inline
 : harmonic ( n -- y ) [ recip ] summing-floats ; inline
 : riemann-zeta ( n -- y ) [ sq recip ] summing-floats ; inline
 : alternating-harmonic ( n -- y ) [ [ -1^ ] keep /f ] summing-integers ; inline
-: gregory ( n -- y ) [ [ -1^ ] [ 2.0 * 1- ] bi / ] summing-integers ; inline
+: gregory ( n -- y ) [ [ -1^ ] [ 2.0 * 1 - ] bi / ] summing-integers ; inline
 
 : partial-sums ( n -- results )
     [
index 642b3dbb934cda14f88f578ce076b0eafe2898a6..25915404bef45bc081523663d4d2bdba778d4b8e 100755 (executable)
@@ -78,6 +78,8 @@ C: <sphere> sphere
 M: sphere intersect-scene ( hit ray sphere -- hit )
     [ [ sphere-n normalize ] keep <hit> nip ] if-ray-sphere ;
 
+HINTS: M\ sphere intersect-scene { hit ray sphere } ;
+
 TUPLE: group < sphere { objs array read-only } ;
 
 : <group> ( objs bound -- group )
@@ -89,6 +91,8 @@ TUPLE: group < sphere { objs array read-only } ;
 M: group intersect-scene ( hit ray group -- hit )
     [ drop objs>> [ intersect-scene ] with each ] if-ray-sphere ;
 
+HINTS: M\ group intersect-scene { hit ray group } ;
+
 CONSTANT: initial-hit T{ hit f double-array{ 0.0 0.0 0.0 } 1/0. }
 
 : initial-intersect ( ray scene -- hit )
index 128ec571f2293d7969554199a0de008947b15cd7..219c73ae0aa62a32ead0bf410b281e45cffe2be0 100755 (executable)
@@ -7,18 +7,18 @@ IN: benchmark.recursive
 
 : ack ( m n -- x )
     {
-        { [ over zero? ] [ nip 1+ ] }
-        { [ dup zero? ] [ drop 1- 1 ack ] }
-        [ [ drop 1- ] [ 1- ack ] 2bi ack ]
+        { [ over zero? ] [ nip 1 + ] }
+        { [ dup zero? ] [ drop 1 - 1 ack ] }
+        [ [ drop 1 - ] [ 1 - ack ] 2bi ack ]
     } cond ; inline recursive
 
 : tak ( x y z -- t )
     2over <= [
         2nip
     ] [
-        [  rot 1- -rot tak ]
-        [ -rot 1- -rot tak ]
-        [      1- -rot tak ]
+        [  rot 1 - -rot tak ]
+        [ -rot 1 - -rot tak ]
+        [      1 - -rot tak ]
         3tri
         tak
     ] if ; inline recursive
@@ -26,7 +26,7 @@ IN: benchmark.recursive
 : recursive ( n -- )
     [ 3 swap ack . flush ]
     [ 27.0 + fib . flush ]
-    [ 1- [ 3 * ] [ 2 * ] [ ] tri tak . flush ] tri
+    [ 1 - [ 3 * ] [ 2 * ] [ ] tri tak . flush ] tri
     3 fib . flush
     3.0 2.0 1.0 tak . flush ;
 
index 483311d4f4c9d7fed812fc892ef89c0213b33036..bd9a7139b3c3511214088df988538e4e61a6d289 100644 (file)
@@ -11,10 +11,10 @@ TUPLE-ARRAY: point
 : tuple-array-benchmark ( -- )
     100 [
         drop 5000 <point-array> [
-            [ 1+ ] change-x
-            [ 1- ] change-y
-            [ 1+ 2 / ] change-z
+            [ 1 + ] change-x
+            [ 1 - ] change-y
+            [ 1 + 2 / ] change-z
         ] map [ z>> ] sigma
     ] sigma . ;
 
-MAIN: tuple-array-benchmark
\ No newline at end of file
+MAIN: tuple-array-benchmark
diff --git a/extra/benchmark/yuv-to-rgb/yuv-to-rgb.factor b/extra/benchmark/yuv-to-rgb/yuv-to-rgb.factor
new file mode 100644 (file)
index 0000000..ca57de8
--- /dev/null
@@ -0,0 +1,95 @@
+! Copyright (C) Chris Double.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.accessors alien.c-types alien.syntax byte-arrays
+destructors generalizations hints kernel libc locals math math.order
+sequences sequences.private ;
+IN: benchmark.yuv-to-rgb
+
+C-STRUCT: yuv_buffer
+    { "int" "y_width" }
+    { "int" "y_height" }
+    { "int" "y_stride" }
+    { "int" "uv_width" }
+    { "int" "uv_height" }
+    { "int" "uv_stride" }
+    { "void*" "y" }
+    { "void*" "u" }
+    { "void*" "v" } ;
+
+:: fake-data ( -- rgb yuv )
+    [let* | w [ 1600 ]
+            h [ 1200 ]
+            buffer [ "yuv_buffer" <c-object> ]
+            rgb [ w h * 3 * <byte-array> ] |
+        w buffer set-yuv_buffer-y_width
+        h buffer set-yuv_buffer-y_height
+        h buffer set-yuv_buffer-uv_height
+        w buffer set-yuv_buffer-y_stride
+        w buffer set-yuv_buffer-uv_stride
+        w h * [ dup * ] B{ } map-as malloc-byte-array &free buffer set-yuv_buffer-y
+        w h * 2/ [ dup dup * * ] B{ } map-as malloc-byte-array &free buffer set-yuv_buffer-u
+        w h * 2/ [ dup * dup * ] B{ } map-as malloc-byte-array &free buffer set-yuv_buffer-v
+        rgb buffer
+    ] ;
+
+: clamp ( n -- n )
+    255 min 0 max ; inline
+
+: stride ( line yuv  -- uvy yy )
+    [ yuv_buffer-uv_stride swap 2/ * >fixnum ]
+    [ yuv_buffer-y_stride * >fixnum ] 2bi ; inline
+
+: compute-y ( yuv uvy yy x -- y )
+    + >fixnum nip swap yuv_buffer-y swap alien-unsigned-1 16 - ; inline
+
+: compute-v ( yuv uvy yy x -- v )
+    nip 2/ + >fixnum swap yuv_buffer-u swap alien-unsigned-1 128 - ; inline
+
+: compute-u ( yuv uvy yy x -- v )
+    nip 2/ + >fixnum swap yuv_buffer-v swap alien-unsigned-1 128 - ; inline
+
+:: compute-yuv ( yuv uvy yy x -- y u v )
+    yuv uvy yy x compute-y
+    yuv uvy yy x compute-u
+    yuv uvy yy x compute-v ; inline
+
+: compute-blue ( y u v -- b )
+    drop 516 * 128 + swap 298 * + -8 shift clamp ; inline
+
+: compute-green ( y u v -- g )
+    [ [ 298 * ] dip 100 * - ] dip 208 * - 128 + -8 shift clamp ;
+    inline
+
+: compute-red ( y u v -- g )
+    nip 409 * swap 298 * + 128 + -8 shift clamp ; inline
+
+: compute-rgb ( y u v -- b g r )
+    [ compute-blue ] [ compute-green ] [ compute-red ] 3tri ;
+    inline
+
+: store-rgb ( index rgb b g r -- index )
+    [ pick 0 + pick set-nth-unsafe ]
+    [ pick 1 + pick set-nth-unsafe ]
+    [ pick 2 + pick set-nth-unsafe ] tri*
+    drop ; inline
+
+: yuv>rgb-pixel ( index rgb yuv uvy yy x -- index )
+    compute-yuv compute-rgb store-rgb 3 + >fixnum ; inline
+
+: yuv>rgb-row ( index rgb yuv y -- index )
+    over stride
+    pick yuv_buffer-y_width >fixnum
+    [ yuv>rgb-pixel ] with with with with each ; inline
+
+: yuv>rgb ( rgb yuv -- )
+    [ 0 ] 2dip
+    dup yuv_buffer-y_height >fixnum
+    [ yuv>rgb-row ] with with each
+    drop ;
+
+HINTS: yuv>rgb byte-array byte-array ;
+
+: yuv>rgb-benchmark ( -- )
+    [ fake-data yuv>rgb ] with-destructors ;
+
+MAIN: yuv>rgb-benchmark
index 620f737fe3783ddff6ea7750f7542a84d9aacfbf..b7400c4acb53e054c7497d95dd2d451b8cc41848 100755 (executable)
@@ -11,7 +11,7 @@ TUPLE: bunny-world < demo-world model-triangles geom draw-seq draw-n ;
 
 : next-draw ( gadget -- )
     dup [ draw-seq>> ] [ draw-n>> ] bi
-    1+ swap length mod
+    1 + swap length mod
     >>draw-n relayout-1 ;
 
 : make-draws ( gadget -- draw-seq )
diff --git a/extra/c/lexer/authors.txt b/extra/c/lexer/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/extra/c/lexer/lexer-tests.factor b/extra/c/lexer/lexer-tests.factor
new file mode 100644 (file)
index 0000000..c972b88
--- /dev/null
@@ -0,0 +1,103 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors c.lexer kernel sequence-parser tools.test ;
+IN: c.lexer.tests
+
+[ 36 ]
+[
+    "    //jofiejoe\n    //eoieow\n/*asdf*/\n      "
+    <sequence-parser> skip-whitespace/comments n>>
+] unit-test
+
+[ f "33asdf" ]
+[ "33asdf" <sequence-parser> [ take-c-identifier ] [ take-rest ] bi ] unit-test
+
+[ "asdf" ]
+[ "asdf" <sequence-parser> take-c-identifier ] unit-test
+
+[ "_asdf" ]
+[ "_asdf" <sequence-parser> take-c-identifier ] unit-test
+
+[ "_asdf400" ]
+[ "_asdf400" <sequence-parser> take-c-identifier ] unit-test
+
+[ "asdfasdf" ] [
+    "/*asdfasdf*/" <sequence-parser> take-c-comment
+] unit-test
+
+[ "k" ] [
+    "/*asdfasdf*/k" <sequence-parser> [ take-c-comment drop ] [ take-rest ] bi
+] unit-test
+
+[ "omg" ] [
+    "//asdfasdf\nomg" <sequence-parser>
+    [ take-c++-comment drop ] [ take-rest ] bi
+] unit-test
+
+[ "omg" ] [
+    "omg" <sequence-parser>
+    [ take-c++-comment drop ] [ take-rest ] bi
+] unit-test
+
+[ "/*asdfasdf" ] [
+    "/*asdfasdf" <sequence-parser> [ take-c-comment drop ] [ take-rest ] bi
+] unit-test
+
+[ "asdf" "eoieoei" ] [
+    "//asdf\neoieoei" <sequence-parser>
+    [ take-c++-comment ] [ take-rest ] bi
+] unit-test
+
+[ f ]
+[
+    "\"abc\" asdf" <sequence-parser>
+    [ CHAR: \ CHAR: " take-quoted-string drop ] [ "asdf" take-sequence ] bi
+] unit-test
+
+[ "abc\\\"def" ]
+[
+    "\"abc\\\"def\" asdf" <sequence-parser>
+    CHAR: \ CHAR: " take-quoted-string
+] unit-test
+
+[ "asdf" ]
+[
+    "\"abc\" asdf" <sequence-parser>
+    [ CHAR: \ CHAR: " take-quoted-string drop ]
+    [ skip-whitespace "asdf" take-sequence ] bi
+] unit-test
+
+[ f ]
+[
+    "\"abc asdf" <sequence-parser>
+    CHAR: \ CHAR: " take-quoted-string
+] unit-test
+
+[ "\"abc" ]
+[
+    "\"abc asdf" <sequence-parser>
+    [ CHAR: \ CHAR: " take-quoted-string drop ]
+    [ "\"abc" take-sequence ] bi
+] unit-test
+
+[ "c" ]
+[ "c" <sequence-parser> take-token ] unit-test
+
+[ f ]
+[ "" <sequence-parser> take-token ] unit-test
+
+[ "abcd e \\\"f g" ]
+[ "\"abcd e \\\"f g\"" <sequence-parser> CHAR: \ CHAR: " take-token* ] unit-test
+
+[ "123" ]
+[ "123jjj" <sequence-parser> take-c-integer ] unit-test
+
+[ "123uLL" ]
+[ "123uLL" <sequence-parser> take-c-integer ] unit-test
+
+[ "123ull" ]
+[ "123ull" <sequence-parser> take-c-integer ] unit-test
+
+[ "123u" ]
+[ "123u" <sequence-parser> take-c-integer ] unit-test
+
diff --git a/extra/c/lexer/lexer.factor b/extra/c/lexer/lexer.factor
new file mode 100644 (file)
index 0000000..962407e
--- /dev/null
@@ -0,0 +1,123 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators combinators.short-circuit
+generalizations kernel locals math.order math.ranges
+sequence-parser sequences sorting.functor sorting.slots
+unicode.categories ;
+IN: c.lexer
+
+: take-c-comment ( sequence-parser -- seq/f )
+    [
+        dup "/*" take-sequence [
+            "*/" take-until-sequence*
+        ] [
+            drop f
+        ] if
+    ] with-sequence-parser ;
+
+: take-c++-comment ( sequence-parser -- seq/f )
+    [
+        dup "//" take-sequence [
+            [
+                [
+                    { [ current CHAR: \n = ] [ sequence-parse-end? ] } 1||
+                ] take-until
+            ] [
+                advance drop
+            ] bi
+        ] [
+            drop f
+        ] if
+    ] with-sequence-parser ;
+
+: skip-whitespace/comments ( sequence-parser -- sequence-parser )
+    skip-whitespace-eol
+    {
+        { [ dup take-c-comment ] [ skip-whitespace/comments ] }
+        { [ dup take-c++-comment ] [ skip-whitespace/comments ] }
+        [ ]
+    } cond ;
+
+: take-define-identifier ( sequence-parser -- string )
+    skip-whitespace/comments
+    [ current { [ blank? ] [ CHAR: ( = ] } 1|| ] take-until ;
+
+:: take-quoted-string ( sequence-parser escape-char quote-char -- string )
+    sequence-parser n>> :> start-n
+    sequence-parser advance
+    [
+        {
+            [ { [ previous escape-char = ] [ current quote-char = ] } 1&& ]
+            [ current quote-char = not ]
+        } 1||
+    ] take-while :> string
+    sequence-parser current quote-char = [
+        sequence-parser advance* string
+    ] [
+        start-n sequence-parser (>>n) f
+    ] if ;
+
+: (take-token) ( sequence-parser -- string )
+    skip-whitespace [ current { [ blank? ] [ f = ] } 1|| ] take-until ;
+
+:: take-token* ( sequence-parser escape-char quote-char -- string/f )
+    sequence-parser skip-whitespace
+    dup current {
+        { quote-char [ escape-char quote-char take-quoted-string ] }
+        { f [ drop f ] }
+        [ drop (take-token) ]
+    } case ;
+
+: take-token ( sequence-parser -- string/f )
+    CHAR: \ CHAR: " take-token* ;
+
+: c-identifier-begin? ( ch -- ? )
+    CHAR: a CHAR: z [a,b]
+    CHAR: A CHAR: Z [a,b]
+    { CHAR: _ } 3append member? ;
+
+: c-identifier-ch? ( ch -- ? )
+    CHAR: a CHAR: z [a,b]
+    CHAR: A CHAR: Z [a,b]
+    CHAR: 0 CHAR: 9 [a,b]
+    { CHAR: _ } 4 nappend member? ;
+
+: (take-c-identifier) ( sequence-parser -- string/f )
+    dup current c-identifier-begin? [
+        [ current c-identifier-ch? ] take-while
+    ] [
+        drop f
+    ] if ;
+
+: take-c-identifier ( sequence-parser -- string/f )
+    [ (take-c-identifier) ] with-sequence-parser ;
+
+<< "length" [ length ] define-sorting >>
+
+: sort-tokens ( seq -- seq' )
+    { length>=< <=> } sort-by ;
+
+: take-c-integer ( sequence-parser -- string/f )
+    [
+        dup take-integer [
+            swap
+            { "ull" "uLL" "Ull" "ULL" "ll" "LL" "l" "L" "u" "U" }
+            take-longest [ append ] when*
+        ] [
+            drop f
+        ] if*
+    ] with-sequence-parser ;
+
+CONSTANT: c-punctuators
+    {
+        "[" "]" "(" ")" "{" "}" "." "->"
+        "++" "--" "&" "*" "+" "-" "~" "!"
+        "/" "%" "<<" ">>" "<" ">" "<=" ">=" "==" "!=" "^" "|" "&&" "||"
+        "?" ":" ";" "..."
+        "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" "&=" "^=" "|="
+        "," "#" "##"
+        "<:" ":>" "<%" "%>" "%:" "%:%:"
+    }
+
+: take-c-punctuator ( sequence-parser -- string/f )
+    c-punctuators take-longest ;
index f787befc3116a1a0234eae644b401daac18c001d..3018fa7a2469d400d9ffd5930bea8b5fa646778f 100644 (file)
@@ -4,7 +4,7 @@ USING: sequence-parser io io.encodings.utf8 io.files
 io.streams.string kernel combinators accessors io.pathnames
 fry sequences arrays locals namespaces io.directories
 assocs math splitting make unicode.categories
-combinators.short-circuit ;
+combinators.short-circuit c.lexer ;
 IN: c.preprocessor
 
 : initial-library-paths ( -- seq )
index 3dbcbf32fcc76ce09f45a0f6fa1d910caad51ef5..17c5ee901f75620f4fedb45295d674af34ea7c97 100644 (file)
@@ -9,11 +9,11 @@ CENTRAL: test-central
 TUPLE: test-disp-cent value disposed ;
 
 ! A phony destructor that adds 1 to the value so we can make sure it got called.
-M: test-disp-cent dispose* dup value>> 1+ >>value drop ;
+M: test-disp-cent dispose* dup value>> 1 + >>value drop ;
 
 DISPOSABLE-CENTRAL: t-d-c
 
 : test-t-d-c ( -- n )
     test-disp-cent new 3 >>value [ t-d-c ] with-t-d-c value>> ;
 
-[ 4 ] [ test-t-d-c ] unit-test
\ No newline at end of file
+[ 4 ] [ test-t-d-c ] unit-test
diff --git a/extra/closures/closures.factor b/extra/closures/closures.factor
new file mode 100644 (file)
index 0000000..79fcf75
--- /dev/null
@@ -0,0 +1,13 @@
+USING: assocs io.pathnames fry namespaces namespaces.private kernel sequences parser hashtables ;
+IN: closures
+SYMBOL: |
+
+! Selective Binding
+: delayed-bind-with ( vars quot -- quot' ) '[ _ dup [ get ] map zip >hashtable [ _ bind ] curry ] ;
+SYNTAX: C[ | parse-until parse-quotation delayed-bind-with over push-all ;
+! Common ones
+SYNTAX: DIR[ parse-quotation { current-directory } swap delayed-bind-with over push-all ;
+
+! Namespace Binding
+: bind-to-namespace ( quot -- quot' ) '[ namespace [ _ bind ] curry ] ;
+SYNTAX: NS[ parse-quotation bind-to-namespace over push-all ;
\ No newline at end of file
diff --git a/extra/compiler/cfg/graphviz/graphviz.factor b/extra/compiler/cfg/graphviz/graphviz.factor
deleted file mode 100644 (file)
index 0aade13..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license
-USING: accessors compiler.cfg.rpo compiler.cfg.dominance
-compiler.cfg.dominance.private compiler.cfg.predecessors images.viewer
-io io.encodings.ascii io.files io.files.unique io.launcher kernel
-math.parser sequences assocs arrays make namespaces ;
-IN: compiler.cfg.graphviz
-
-: render-graph ( edges -- )
-    "cfg" "dot" make-unique-file
-    [
-        ascii [
-            "digraph CFG {" print
-            [ [ number>> number>string ] bi@ " -> " glue write ";" print ] assoc-each
-            "}" print
-        ] with-file-writer
-    ]
-    [ { "dot" "-Tpng" "-O" } swap suffix try-process ]
-    [ ".png" append { "open" } swap suffix try-process ]
-    tri ;
-
-: cfg-edges ( cfg -- edges )
-    [
-        [
-            dup successors>> [
-                2array ,
-            ] with each
-        ] each-basic-block
-    ] { } make ;
-
-: render-cfg ( cfg -- ) cfg-edges render-graph ;
-
-: dom-edges ( cfg -- edges )
-    [
-        compute-predecessors
-        compute-dominance
-        dom-childrens get [
-            [
-                2array ,
-            ] with each
-        ] assoc-each
-    ] { } make ;
-
-: render-dom ( cfg -- ) dom-edges render-graph ;
\ No newline at end of file
diff --git a/extra/compiler/graphviz/graphviz.factor b/extra/compiler/graphviz/graphviz.factor
new file mode 100644 (file)
index 0000000..9823f93
--- /dev/null
@@ -0,0 +1,138 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license
+USING: accessors compiler.tree.builder compiler.cfg compiler.cfg.rpo
+compiler.cfg.dominance compiler.cfg.dominance.private
+compiler.cfg.predecessors compiler.cfg.debugger compiler.cfg.optimizer
+compiler.cfg.utilities compiler.tree.recursive images.viewer
+images.png io io.encodings.ascii io.files io.files.unique io.launcher
+kernel math.parser sequences assocs arrays make math namespaces
+quotations combinators locals words ;
+IN: compiler.graphviz
+
+: quotes ( str -- str' ) "\"" "\"" surround ;
+
+: graph, ( quot title -- )
+    [
+        quotes "digraph " " {" surround ,
+        call
+        "}" ,
+    ] { } make , ; inline
+
+: render-graph ( quot -- )
+    { } make
+    "cfg" ".dot" make-unique-file
+    dup "Wrote " prepend print
+    [ [ concat ] dip ascii set-file-lines ]
+    [ { "dot" "-Tpng" "-O" } swap suffix try-process ]
+    [ ".png" append "open" swap 2array try-process ]
+    tri ; inline
+
+: attrs>string ( seq -- str )
+    [ "" ] [ "," join "[" "]" surround ] if-empty ;
+
+: edge,* ( from to attrs -- )
+    [
+        [ quotes % " -> " % ] [ quotes % " " % ] [ attrs>string % ] tri*
+        ";" %
+    ] "" make , ;
+
+: edge, ( from to -- )
+    { } edge,* ;
+
+: bb-edge, ( from to -- )
+    [ number>> number>string ] bi@ edge, ;
+
+: node-style, ( str attrs -- )
+    [ [ quotes % " " % ] [ attrs>string % ";" % ] bi* ] "" make , ;
+
+: cfg-title ( cfg/mr -- string )
+    [
+        "=== word: " %
+        [ word>> name>> % ", label: " % ]
+        [ label>> name>> % ]
+        bi
+    ] "" make ;
+
+: cfg-vertex, ( bb -- )
+    [ number>> number>string ]
+    [ kill-block? { "color=grey" "style=filled" } { } ? ]
+    bi node-style, ;
+
+: cfgs ( cfgs -- )
+    [
+        [
+            [ [ cfg-vertex, ] each-basic-block ]
+            [
+                [
+                    dup successors>> [
+                        bb-edge,
+                    ] with each
+                ] each-basic-block
+            ] bi
+        ] over cfg-title graph,
+    ] each ;
+
+: optimized-cfg ( quot -- cfgs )
+    {
+        { [ dup cfg? ] [ 1array ] }
+        { [ dup quotation? ] [ test-cfg [ optimize-cfg ] map ] }
+        { [ dup word? ] [ test-cfg [ optimize-cfg ] map ] }
+        [ ]
+    } cond ;
+
+: render-cfg ( cfg -- )
+    optimized-cfg [ cfgs ] render-graph ;
+
+: dom-trees ( cfgs -- )
+    [
+        [
+            needs-dominance drop
+            dom-childrens get [
+                [
+                    bb-edge,
+                ] with each
+            ] assoc-each
+        ] over cfg-title graph,
+    ] each ;
+
+: render-dom ( cfg -- )
+    optimized-cfg [ dom-trees ] render-graph ;
+
+SYMBOL: word-counts
+SYMBOL: vertex-names
+
+: vertex-name ( call-graph-node -- string )
+    label>> vertex-names get [
+        word>> name>>
+        dup word-counts get [ 0 or 1 + dup ] change-at number>string " #" glue
+    ] cache ;
+
+: vertex-attrs ( obj -- string )
+    tail?>> { "style=bold,label=\"tail\"" } { } ? ;
+
+: call-graph-edge, ( from to attrs -- )
+    [ [ vertex-name ] [ vertex-attrs ] bi ] dip append edge,* ;
+
+: (call-graph-back-edges) ( string calls -- )
+    [ { "color=red" } call-graph-edge, ] with each ;
+
+: (call-graph-edges) ( string children -- )
+    [
+        {
+            [ { } call-graph-edge, ]
+            [ [ vertex-name ] [ label>> loop?>> { "shape=box" } { } ? ] bi node-style, ]
+            [ [ vertex-name ] [ calls>> ] bi (call-graph-back-edges) ] 
+            [ [ vertex-name ] [ children>> ] bi (call-graph-edges) ]
+        } cleave
+    ] with each ;
+
+: call-graph-edges ( call-graph-node -- )
+    H{ } clone word-counts set
+    H{ } clone vertex-names set
+    [ "ROOT" ] dip (call-graph-edges) ;
+
+: render-call-graph ( tree -- )
+    dup quotation? [ build-tree ] when
+    analyze-recursive drop
+    [ [ call-graph get call-graph-edges ] "Call graph" graph, ]
+    render-graph ;
\ No newline at end of file
index f4ac97354dc65bfd8ece9054fbe43448094020db..90e88f64fb27e8cc33e6ab8a100aae535efc5002 100644 (file)
@@ -7,7 +7,7 @@ USING: coroutines kernel sequences prettyprint tools.test math ;
   [ drop 1 coyield* 2 coyield* 3 coterminate ] cocreate ;
 
 : test2 ( -- co )
-  [ 1+ coyield* ] cocreate ;
+  [ 1 + coyield* ] cocreate ;
 
 test1 dup *coresume . dup *coresume . dup *coresume . dup *coresume 2drop
 [ test2 42 over coresume . dup *coresume . drop ] must-fail
@@ -18,4 +18,4 @@ test1 dup *coresume . dup *coresume . dup *coresume . dup *coresume 2drop
 
 { "c" "b" "a" } [ test3 { "a" "b" "c" } over coresume [ dup *coresume [ *coresume ] dip ] dip ] unit-test
 
-{ 4+2/3 } [ [ 1+ coyield 2 * coyield 3 / coreset ] cocreate 1 5 [ over coresume ] times nip ] unit-test
\ No newline at end of file
+{ 4+2/3 } [ [ 1 + coyield 2 * coyield 3 / coreset ] cocreate 1 5 [ over coresume ] times nip ] unit-test
index 9d5c65aa94da179f01580122d64af8dadcccc793..10f99058b5e51140026e97b3b037f55824425ddd 100644 (file)
@@ -6,5 +6,5 @@ IN: crypto.barrett
 : barrett-mu ( n size -- mu )
     #! Calculates Barrett's reduction parameter mu
     #! size = word size in bits (8, 16, 32, 64, ...)
-    [ [ log2 1+ ] [ / 2 * ] bi* ]
+    [ [ log2 1 + ] [ / 2 * ] bi* ]
     [ 2^ rot ^ swap /i ] 2bi ;
index 286a313fda10376b80d77f717b572ab35beebe0f..30650c1e401daa806ef75eeb5e84cf6631359f9c 100644 (file)
@@ -11,7 +11,7 @@ IN: crypto.passwd-md5
     "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" nth ; inline
 
 : to64 ( v n -- string )
-    [ [ -6 shift ] [ 6 2^ 1- bitand lookup-table ] bi ]
+    [ [ -6 shift ] [ 6 2^ 1 - bitand lookup-table ] bi ]
     replicate nip ; inline
 
 PRIVATE>
index f4ef4687b5b98a2c1b60b9094be7540eb57116ce..917e98a6ee52cc7f251e7abf19a99ee737de90e4 100644 (file)
@@ -26,7 +26,7 @@ CONSTANT: public-key 65537
 : modulus-phi ( numbits -- n phi ) 
     #! Loop until phi is not divisible by the public key.
     dup rsa-primes [ * ] 2keep
-    [ 1- ] bi@ *
+    [ 1 - ] bi@ *
     dup public-key gcd nip 1 = [
         rot drop
     ] [
index 40c0b791cfd43ca4a72b200e2bac21c530b46115..615b38daf6d94ea1ca57f4349405707432e2f141 100644 (file)
@@ -29,7 +29,7 @@ IN: ctags.etags
   H{ } clone swap [ swap [ etag-add ] keep ] each ;
 
 : lines>bytes ( seq n -- bytes )
-  head 0 [ length 1+ + ] reduce ;
+  head 0 [ length 1 + + ] reduce ;
 
 : file>lines ( path -- lines )
   ascii file-lines ;
@@ -40,7 +40,7 @@ IN: ctags.etags
     1 HEX: 7f <string> %
     second dup number>string %
     1 CHAR: , <string> %
-    1- lines>bytes number>string %
+    1 - lines>bytes number>string %
   ] "" make ;
 
 : etag-length ( vector -- n )
@@ -72,4 +72,4 @@ IN: ctags.etags
   [ etag-strings ] dip ascii set-file-lines ; 
 
 : etags ( path -- )
-  [ (ctags) sort-values etag-hash >alist ] dip etags-write ;
\ No newline at end of file
+  [ (ctags) sort-values etag-hash >alist ] dip etags-write ;
index dc08656f7e578dae3b220cd93a005fb2c6b08962..77defb081d952a977e2a11f73ed1e183ed7ebb1f 100644 (file)
@@ -68,7 +68,7 @@ M: from-sequence cursor-get-unsafe
     >from-sequence< nth-unsafe ;
 
 M: from-sequence cursor-advance
-    [ 1+ ] change-n drop ;
+    [ 1 + ] change-n drop ;
 
 : >input ( seq -- cursor )
     0 from-sequence boa ; inline
diff --git a/extra/db/info/info.factor b/extra/db/info/info.factor
new file mode 100644 (file)
index 0000000..66409f2
--- /dev/null
@@ -0,0 +1,15 @@
+USING: accessors sequences generalizations io.encodings.utf8 db.postgresql parser combinators vocabs.parser db.sqlite
+io.files ;
+IN: db.info
+! having sensative (and likely to change) information directly in source code seems a bad idea
+: get-info ( -- lines ) current-vocab name>> "vocab:" "/dbinfo.txt" surround utf8 file-lines ;
+SYNTAX: get-psql-info <postgresql-db> get-info 5 firstn
+    {
+        [ >>host ]
+        [ >>port ]
+        [ >>username ]
+        [ [ f ] [ ] if-empty >>password ]
+        [ >>database ]
+    } spread parsed ;
+
+SYNTAX: get-sqlite-info get-info first <sqlite-db> parsed ;
\ No newline at end of file
index 755c57cedaee74534efdc1ceeb600fa2ee3b617d..6630d2addb9c81157f86fa46df70bc501ac1f6dc 100755 (executable)
@@ -1,16 +1,34 @@
-USING: descriptive kernel math tools.test continuations prettyprint io.streams.string see ;\r
+USING: descriptive kernel math tools.test continuations prettyprint io.streams.string see\r
+math.ratios ;\r
 IN: descriptive.tests\r
 \r
 DESCRIPTIVE: divide ( num denom -- fraction ) / ;\r
 \r
 [ 3 ] [ 9 3 divide ] unit-test\r
-[ T{ descriptive-error f { { "num" 3 } { "denom" 0 } } "Division by zero" divide } ] [ [ 3 0 divide ] [ ] recover ] unit-test\r
 \r
-[ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE: divide ( num denom -- fraction ) / ;\n" ] [ \ divide [ see ] with-string-writer ] unit-test\r
+[\r
+    T{ descriptive-error f\r
+        { { "num" 3 } { "denom" 0 } }\r
+        T{ division-by-zero f 3 }\r
+        divide\r
+    }\r
+] [\r
+    [ 3 0 divide ] [ ] recover\r
+] unit-test\r
+\r
+[ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE: divide ( num denom -- fraction ) / ;\n" ]\r
+[ \ divide [ see ] with-string-writer ] unit-test\r
 \r
 DESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;\r
 \r
 [ 3 ] [ 9 3 divide* ] unit-test\r
-[ T{ descriptive-error f { { "num" 3 } { "denom" 0 } } "Division by zero" divide* } ] [ [ 3 0 divide* ] [ ] recover ] unit-test\r
+\r
+[\r
+    T{ descriptive-error f\r
+        { { "num" 3 } { "denom" 0 } }\r
+        T{ division-by-zero f 3 }\r
+        divide*\r
+    }\r
+] [ [ 3 0 divide* ] [ ] recover ] unit-test\r
 \r
 [ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;\n" ] [ \ divide* [ see ] with-string-writer ] unit-test\r
index af080f61ebb25a60bdc76b8c07b24018820a16b7..72f553c0f773daecd69fd6705937977fc250075f 100644 (file)
@@ -16,7 +16,7 @@ IN: dns.misc
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: cdr-name ( name -- name ) dup CHAR: . index 1+ tail ;
+: cdr-name ( name -- name ) dup CHAR: . index 1 + tail ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
index 644533d3a235d75df09aeef4709bd593619a7f23..773fe31ea6a1c1ddc53ccf896aea12b1155afe52 100644 (file)
@@ -120,7 +120,7 @@ DEFER: query->rrs
 ! have-delegates?
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: cdr-name ( name -- name ) dup CHAR: . index 1+ tail ;
+: cdr-name ( name -- name ) dup CHAR: . index 1 + tail ;
 
 : is-soa? ( name -- ? ) SOA IN query boa matching-rrs empty? not ;
 
index f47eb7010c6dbbf0b4c16862f628d87edafcb065..6934d3bbd916f3dceb7d1a18ed1b2c71747b4d35 100644 (file)
@@ -10,7 +10,7 @@ MACRO: 1if ( test then else -- ) '[ dup @ _ _ if ] ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: sort-largest-first ( seq -- seq ) [ [ length ] compare ] sort reverse ;
+: sort-largest-first ( seq -- seq ) [ length ] sort-with reverse ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
index eaa0d3bb6949fce87143fa6ca32b8838bcec21bb..c1e93078f7f0533ae33b78cab90d75b48e74cfd6 100644 (file)
@@ -1,14 +1,14 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-unicode? f }
+    { deploy-name "drills" }
+    { deploy-c-types? t }
+    { "stop-after-last-window?" t }
+    { deploy-unicode? t }
     { deploy-threads? t }
+    { deploy-reflection 6 }
+    { deploy-word-defs? t }
     { deploy-math? t }
-    { deploy-name "drills" }
     { deploy-ui? t }
-    { "stop-after-last-window?" t }
-    { deploy-word-props? f }
-    { deploy-c-types? f }
-    { deploy-io 2 }
-    { deploy-word-defs? f }
-    { deploy-reflection 1 }
+    { deploy-word-props? t }
+    { deploy-io 3 }
 }
index 43873c99bb089b145d5a203406b0849987969979..5681c73438e2fc238a03f61f587f68b8e7f352cd 100644 (file)
@@ -1,11 +1,11 @@
-USING: accessors arrays cocoa.dialogs combinators continuations
+USING: arrays cocoa.dialogs combinators continuations
 fry grouping io.encodings.utf8 io.files io.styles kernel math
 math.parser models models.arrow models.history namespaces random
 sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
 ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
 ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
 wrap.strings system ;
-
+EXCLUDE: accessors => change-model ;
 IN: drills.deployed
 SYMBOLS: it startLength ;
 : big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
index 9ee4e9b6ebc23636c1c63cc6e5fa97efd920a42f..1da1fcaa1d963268338e267ef8d983316294b81e 100644 (file)
@@ -1,16 +1,17 @@
-USING: accessors arrays cocoa.dialogs combinators continuations
+USING: arrays cocoa.dialogs combinators continuations
 fry grouping io.encodings.utf8 io.files io.styles kernel math
 math.parser models models.arrow models.history namespaces random
 sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
 ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
 ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
 wrap.strings ;
+EXCLUDE: accessors => change-model ;
 
 IN: drills
 SYMBOLS: it startLength ;
 : big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
 : card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
-: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
+: op ( quot str -- gadget ) <label> big swap <book-border-btn> ;
 
 : show ( model -- gadget ) dup it set-global [ random ] <arrow>
    { [ [ first ] card ]
index d76b93a4d78af2a3dcf527a8b2101bdafc99d62a..1000bb9d71c9bcaac5401d1fbc6354e09ca032a0 100644 (file)
@@ -57,7 +57,7 @@ PRIVATE>
     KEY EC_KEY_get0_public_key dup 
     [| PUB |
         KEY EC_KEY_get0_group :> GROUP
-        GROUP EC_GROUP_get_degree bits>bytes 1+ :> LEN
+        GROUP EC_GROUP_get_degree bits>bytes 1 + :> LEN
         LEN <byte-array> :> BIN
         GROUP PUB POINT_CONVERSION_COMPRESSED BIN LEN f
         EC_POINT_point2oct ssl-error
@@ -72,4 +72,4 @@ PRIVATE>
     LEN *uint SIG resize ;
 
 : ecdsa-verify ( dgst sig -- ? )
-    ec-key-handle [ 0 -rot [ dup length ] bi@ ] dip ECDSA_verify 0 > ;
\ No newline at end of file
+    ec-key-handle [ 0 -rot [ dup length ] bi@ ] dip ECDSA_verify 0 > ;
diff --git a/extra/enter/authors.txt b/extra/enter/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/enter/enter.factor b/extra/enter/enter.factor
new file mode 100644 (file)
index 0000000..845182c
--- /dev/null
@@ -0,0 +1,8 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel parser vocabs.parser words ;
+IN: enter
+! main words are usually only used for entry, doing initialization, etc
+! it makes sense, then to define it all at once, rather than factoring it out into a seperate word
+! and then declaring it main
+SYNTAX: ENTER: gensym [ parse-definition (( -- )) define-declared ] keep current-vocab (>>main) ;
\ No newline at end of file
diff --git a/extra/file-trees/file-trees-tests.factor b/extra/file-trees/file-trees-tests.factor
deleted file mode 100644 (file)
index dbb8f9f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: kernel file-trees ;
-IN: file-trees.tests
-{ "/sample/1" "/sample/2" "/killer/1" "/killer/2/3"
-"/killer/2/4" "/killer/2/4/6" "/megakiller" } create-tree drop
\ No newline at end of file
diff --git a/extra/file-trees/file-trees.factor b/extra/file-trees/file-trees.factor
deleted file mode 100644 (file)
index eadfccd..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-USING: accessors arrays delegate delegate.protocols
-io.pathnames kernel locals namespaces prettyprint sequences
-ui.frp vectors ;
-IN: file-trees
-
-TUPLE: tree node children ;
-CONSULT: sequence-protocol tree children>> ;
-
-: <tree> ( start -- tree ) V{ } clone
-   [ tree boa dup children>> ] [ ".." swap tree boa ] bi swap push ;
-
-DEFER: (tree-insert)
-
-: tree-insert ( path tree -- ) [ unclip <tree> ] [ children>> ] bi* (tree-insert) ;
-:: (tree-insert) ( path-rest path-head tree-children -- )
-   tree-children [ node>> path-head node>> = ] find nip
-   [ path-rest swap tree-insert ]
-   [ 
-      path-head tree-children push
-      path-rest [ path-head tree-insert ] unless-empty
-   ] if* ;
-: create-tree ( file-list -- tree ) [ path-components ] map
-   t <tree> [ [ tree-insert ] curry each ] keep ;
-
-: <dir-table> ( tree-model -- table )
-   <frp-list*> [ node>> 1array ] >>quot
-   [ selected-value>> <switch> ]
-   [ swap >>model ] bi ;
\ No newline at end of file
diff --git a/extra/fonts/syntax/authors.txt b/extra/fonts/syntax/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/fonts/syntax/summary.txt b/extra/fonts/syntax/summary.txt
new file mode 100644 (file)
index 0000000..35dcf4e
--- /dev/null
@@ -0,0 +1 @@
+Syntax for modifying gadget fonts
\ No newline at end of file
diff --git a/extra/fonts/syntax/syntax-docs.factor b/extra/fonts/syntax/syntax-docs.factor
new file mode 100644 (file)
index 0000000..7edd6d7
--- /dev/null
@@ -0,0 +1,6 @@
+USING: help.syntax help.markup ;
+IN: fonts.syntax
+
+HELP: FONT:
+{ $syntax "\"testing\" <label> FONT: 18 serif bold ... ;" }
+{ $description "Used after a gadget to change font settings.  Attributes can be in any order: the first number is set as the size, the style attributes like bold and italic will set the bold? and italic? slots, and font-names like serif or monospace will set the name slot." } ;
\ No newline at end of file
diff --git a/extra/fonts/syntax/syntax.factor b/extra/fonts/syntax/syntax.factor
new file mode 100644 (file)
index 0000000..c296dfb
--- /dev/null
@@ -0,0 +1,16 @@
+USING: accessors arrays variants combinators io.styles
+kernel math parser sequences fry ;
+IN: fonts.syntax
+
+VARIANT: fontname serif monospace ;
+
+: install ( object quot -- quot/? ) over [ curry ] [ 2drop [ ] ] if ;
+
+: >>name* ( object fontname -- object ) name>> >>name ;
+
+SYNTAX: FONT: \ ; parse-until {
+    [ [ number? ] find nip [ >>size ] install ]
+    [ [ italic = ] find nip [ >>italic? ] install ]
+    [ [ bold = ] find nip [ >>bold? ] install ]
+    [ [ fontname? ] find nip [ >>name* ] install ]
+} cleave 4array concat '[ dup font>> @ drop ] over push-all ;
diff --git a/extra/fries/authors.txt b/extra/fries/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/fries/fries.factor b/extra/fries/fries.factor
new file mode 100644 (file)
index 0000000..f67d0d7
--- /dev/null
@@ -0,0 +1,13 @@
+USING: arrays vectors combinators effects kernel math sequences splitting
+strings.parser parser fry sequences.extras ;
+IN: fries
+: str-fry ( str on -- quot ) split
+    [ unclip-last [ [ spin glue ] reduce-r ] 2curry ]
+    [ length 1 - 1 <effect> [ call-effect ] 2curry ] bi ;
+: gen-fry ( str on -- quot ) split
+    [ unclip-last [ [ spin 1array glue ] reduce-r ] 2curry ]
+    [ length 1 - 1 <effect> [ call-effect ] 2curry ] bi ;
+
+SYNTAX: i" parse-string rest "_" str-fry over push-all ;
+SYNTAX: i{ \ } parse-until >array { _ } gen-fry over push-all ;
+SYNTAX: iV{ \ } parse-until >vector V{ _ } gen-fry over push-all ;
diff --git a/extra/fries/summary.txt b/extra/fries/summary.txt
new file mode 100644 (file)
index 0000000..44e9456
--- /dev/null
@@ -0,0 +1 @@
+Generalized Frying
\ No newline at end of file
index 86aa215e2104227803381e5cb2d54c3a8426bc0a..c228901afbefea40326aa38cc2e6e1c08b776f9b 100644 (file)
@@ -23,7 +23,7 @@ IN: fuel.xref
     dup dup >vocab-link where normalize-loc 4array ;
 
 : sort-xrefs ( seq -- seq' )
-    [ [ first ] dip first <=> ] sort ;
+    [ first ] sort-with ;
 
 : format-xrefs ( seq -- seq' )
     [ word? ] filter [ word>xref ] map ;
@@ -36,8 +36,8 @@ MEMO: (vocab-words) ( name -- seq )
 
 : current-words ( -- seq )
     manifest get
-    [ search-vocabs>> ] [ qualified-vocabs>> ] bi [ words>> ] bi@
-    assoc-union keys ;
+    [ search-vocabs>> ] [ qualified-vocabs>> ] bi [ [ words>> ] map ] bi@
+    append H{ } [ assoc-union ] reduce keys ;
 
 : vocabs-words ( names -- seq )
     prune [ (vocab-words) ] map concat ;
index 982319541b12c3c4b80b3a6c185103fb6d50ab62..5f78c6770cadcfbadc2dc70b4584377fb18eff52 100644 (file)
@@ -1,5 +1,6 @@
 USING: accessors calendar continuations destructors kernel math
-math.order namespaces system threads ui ui.gadgets.worlds ;
+math.order namespaces system threads ui ui.gadgets.worlds
+sequences ;
 IN: game-loop
 
 TUPLE: game-loop
@@ -40,23 +41,23 @@ TUPLE: game-loop-error game-loop error ;
 <PRIVATE
 
 : redraw ( loop -- )
-    [ 1+ ] change-frame-number
+    [ 1 + ] change-frame-number
     [ tick-slice ] [ delegate>> ] bi draw* ;
 
 : tick ( loop -- )
     delegate>> tick* ;
 
 : increment-tick ( loop -- )
-    [ 1+ ] change-tick-number
+    [ 1 + ] change-tick-number
     dup tick-length>> [ + ] curry change-last-tick
     drop ;
 
 : ?tick ( loop count -- )
-    dup zero? [ drop millis >>last-tick drop ] [
+    [ millis >>last-tick drop ] [
         over [ since-last-tick ] [ tick-length>> ] bi >=
-        [ [ drop increment-tick ] [ drop tick ] [ 1- ?tick ] 2tri ]
+        [ [ drop increment-tick ] [ drop tick ] [ 1 - ?tick ] 2tri ]
         [ 2drop ] if
-    ] if ;
+    ] if-zero ;
 
 : (run-loop) ( loop -- )
     dup running?>>
index 8f1679bfa8c61ca876aea372beb3a9ac9a4111c1..2f920645ed5a2213a4b5092613138ede0077552c 100644 (file)
@@ -73,7 +73,7 @@ TUPLE: multi-index-range
 C: <multi-index-range> multi-index-range
 
 TUPLE: index-elements
-    { ptr gpu-data-ptr read-only }
+    { ptr read-only }
     { count integer read-only }
     { index-type index-type read-only } ;
 
@@ -422,7 +422,7 @@ SYNTAX: UNIFORM-TUPLE:
     [ [ length ] [ >int-array ] bi glDrawBuffers ] if ;
 
 : bind-named-output-attachments ( program-instance framebuffer attachments -- )
-    rot '[ [ first _ swap output-index ] bi@ <=> ] sort [ second ] map
+    rot '[ first _ swap output-index ] sort-with [ second ] map
     bind-unnamed-output-attachments ;
 
 : bind-output-attachments ( program-instance framebuffer attachments -- )
index a77ebf2577071e2d6cd12ab9b43a131a12697175..2f94f3f2d695924bb3fb87e98546f0bdf6bbcadc 100755 (executable)
@@ -69,7 +69,7 @@ M: hashcash string>>
 
 : (mint) ( tuple counter -- tuple ) 
     2dup set-suffix checksummed-bits pick 
-    valid-guess? [ drop ] [ 1+ (mint) ] if ;
+    valid-guess? [ drop ] [ 1 + (mint) ] if ;
 
 PRIVATE>
 
index 02b45ee9396c57d407f49f052138ea69cefbeed1..d206ae5f45110a4901429b911f5ef8cc7aada0f8 100755 (executable)
@@ -16,7 +16,7 @@ TUPLE: link attributes clickable ;
 
 : find-nth ( seq quot n -- i elt )
     [ <enum> >alist ] 2dip -rot
-    '[ _ [ second @ ] find-from rot drop swap 1+ ]
+    '[ _ [ second @ ] find-from rot drop swap 1 + ]
     [ f 0 ] 2dip times drop first2 ; inline
 
 : find-first-name ( vector string -- i/f tag/f )
@@ -29,7 +29,7 @@ TUPLE: link attributes clickable ;
 : find-between* ( vector i/f tag/f -- vector )
     over integer? [
         [ tail-slice ] [ name>> ] bi*
-        dupd find-matching-close drop dup [ 1+ ] when
+        dupd find-matching-close drop dup [ 1 + ] when
         [ head ] [ first ] if*
     ] [
         3drop V{ } clone
index 6d9b778ee8d1f2ba08bc5f818149d233230dcab4..38aa291a3aff4afa9afdd7bfbabf70a65a4ac001 100644 (file)
@@ -104,7 +104,7 @@ CONSTANT: id3v1+-offset $[ 128 227 + ]
     0 [ [ 7 shift ] dip bitor ] reduce ;
 
 : synchsafe>seq ( n -- seq )
-    dup 1+ log2 1+ 7 / ceiling
+    dup 1 + log2 1 + 7 / ceiling
     [ [ -7 shift ] keep HEX: 7f bitand  ] replicate nip reverse ;
 
 : filter-text-data ( data -- filtered )
index b065dfe2f0b22168193b7f6014c50b90e0805853..6ce851e7dd0137a758e981bb637189db1d8b0e73 100644 (file)
@@ -10,7 +10,7 @@ IN: irc.client.internals
 : do-connect ( server port quot: ( host port -- stream ) attempts -- stream/f )
     dup 0 > [
         [ drop call( host port -- stream ) ]
-        [ drop 15 sleep 1- do-connect ]
+        [ drop 15 sleep 1 - do-connect ]
         recover
     ] [ 2drop 2drop f ] if ;
 
index 986574ee9148c847dc74fae2b047ed5136a3c0e9..ac5be9df2e18b8630ed65dd01e95e6397ad9c6a0 100644 (file)
@@ -13,7 +13,7 @@ TUPLE: segment < oint number color radius ;
 C: <segment> segment
 
 : segment-number++ ( segment -- )
-    [ number>> 1+ ] keep (>>number) ;
+    [ number>> 1 + ] keep (>>number) ;
 
 : clamp-length ( n seq -- n' )
     0 swap length clamp ;
@@ -31,7 +31,7 @@ CONSTANT: random-rotation-angle $[ pi 20 / ]
 
 : (random-segments) ( segments n -- segments )
     dup 0 > [
-        [ dup last random-segment over push ] dip 1- (random-segments)
+        [ dup last random-segment over push ] dip 1 - (random-segments)
     ] [ drop ] if ;
 
 CONSTANT: default-segment-radius 1
@@ -78,7 +78,7 @@ CONSTANT: default-segment-radius 1
     rot dup length swap <slice> find-nearest-segment ;
 
 : nearest-segment-backward ( segments oint start -- segment )
-    swapd 1+ 0 spin <slice> <reversed> find-nearest-segment ;
+    swapd 1 + 0 spin <slice> <reversed> find-nearest-segment ;
 
 : nearest-segment ( segments oint start-segment -- segment )
     #! find the segment nearest to 'oint', and return it.
@@ -91,10 +91,10 @@ CONSTANT: default-segment-radius 1
     over clamp-length swap nth ;
 
 : next-segment ( segments current-segment -- segment )
-    number>> 1+ get-segment ;
+    number>> 1 + get-segment ;
 
 : previous-segment ( segments current-segment -- segment )
-    number>> 1- get-segment ;
+    number>> 1 - get-segment ;
 
 : heading-segment ( segments current-segment heading -- segment )
     #! the next segment on the given heading
diff --git a/extra/key-handlers/authors.txt b/extra/key-handlers/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/key-handlers/key-handlers.factor b/extra/key-handlers/key-handlers.factor
new file mode 100644 (file)
index 0000000..b5171be
--- /dev/null
@@ -0,0 +1,10 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs kernel ui.gadgets.borders ui.gestures ;
+IN: key-handlers
+
+TUPLE: key-handler < border handlers ;
+: <keys> ( gadget -- key-handler ) key-handler new-border { 0 0 } >>size ;
+
+M: key-handler handle-gesture
+    tuck handlers>> at [ call( gadget -- ) f ] [ drop t ] if* ;
\ No newline at end of file
index 1ecd56d416d2df77e1fa02023eebe02cd7f304d9..59efec1c02302124c896aa0956fc71e538470e8b 100755 (executable)
@@ -75,7 +75,7 @@ SYMBOL: terms
 
 : inversions ( seq -- n )
     0 swap [ length ] keep [
-        [ nth ] 2keep swap 1+ tail-slice (inversions) +
+        [ nth ] 2keep swap 1 + tail-slice (inversions) +
     ] curry each ;
 
 : duplicates? ( seq -- ? )
@@ -141,7 +141,7 @@ DEFER: (d)
 
 ! Computing a basis
 : graded ( seq -- seq )
-    dup 0 [ length max ] reduce 1+ [ V{ } clone ] replicate
+    dup 0 [ length max ] reduce 1 + [ V{ } clone ] replicate
     [ dup length pick nth push ] reduce ;
 
 : nth-basis-elt ( generators n -- elt )
@@ -176,7 +176,7 @@ DEFER: (d)
 ! Graded by degree
 : (graded-ker/im-d) ( n seq -- null/rank )
     #! d: C(n) ---> C(n+1)
-    [ ?nth ] [ [ 1+ ] dip ?nth ] 2bi
+    [ ?nth ] [ [ 1 + ] dip ?nth ] 2bi
     dim-im/ker-d ;
 
 : graded-ker/im-d ( graded-basis -- seq )
@@ -240,7 +240,7 @@ DEFER: (d)
     ] if ;
 
 : graded-triple ( seq n -- triple )
-    3 [ 1- + ] with map swap [ ?nth ] curry map ;
+    3 [ 1 - + ] with map swap [ ?nth ] curry map ;
 
 : graded-triples ( seq -- triples )
     dup length [ graded-triple ] with map ;
index a1fc0bd07b904c0301e533bfa74e6e993fa0e652..39d6450ba0cffc20d317b4e4608f473964bf746c 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman, Slava Pestov, Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.short-circuit kernel math math.constants math.functions
-    math.vectors sequences ;
+USING: combinators.short-circuit kernel math math.constants
+math.functions math.vectors sequences ;
 IN: math.analysis
 
 <PRIVATE
@@ -117,5 +117,5 @@ PRIVATE>
 : stirling-fact ( n -- fact )
     [ pi 2 * * sqrt ]
     [ [ e / ] keep ^ ]
-    [ 12 * recip 1+ ] tri * * ;
+    [ 12 * recip 1 + ] tri * * ;
 
index 3e0e5437b4bff5491f635499f7db2ce05d865b19..55789778af26ad7f1dc7eaecf978f44c1bf6a95e 100644 (file)
@@ -45,7 +45,7 @@ MACRO: duals>nweave ( n -- )
 MACRO: chain-rule ( word -- e )
     [ input-length '[ _ duals>nweave ] ]
     [ "derivative" word-prop ]
-    [ input-length 1+ '[ _ nspread ] ]
+    [ input-length 1 + '[ _ nspread ] ]
     tri
     '[ [ @ _ @ ] sum-outputs ] ;
 
@@ -80,4 +80,4 @@ MACRO: dual-op ( word -- )
 
 ! Specialize math functions to operate on dual numbers.
 [ all-words [ "derivative" word-prop ] filter
-    [ define-dual ] each ] with-compilation-unit
\ No newline at end of file
+    [ define-dual ] each ] with-compilation-unit
index 4823e358b007137783752f7258d3998eb9727daa..5954b08c9b3649331aafe2c0d666dc73c6defd7b 100644 (file)
@@ -7,10 +7,10 @@ IN: math.finance
 <PRIVATE
 
 : weighted ( x y a -- z )
-    tuck [ * ] [ 1- neg * ] 2bi* + ;
+    tuck [ * ] [ 1 - neg * ] 2bi* + ;
 
 : a ( n -- a )
-    1+ 2 swap / ;
+    1 + 2 swap / ;
 
 PRIVATE>
 
index 13f314f6bae8778bff5a470cbea7a099b5f3f7c7..c2733058b3c4ed6cbcf1aa8368fdbafb0aca5a65 100644 (file)
@@ -6,4 +6,4 @@ IN: math.primes.lists
 : lprimes ( -- list ) 2 [ next-prime ] lfrom-by ;
 
 : lprimes-from ( n -- list )
-    dup 3 < [ drop lprimes ] [ 1- next-prime [ next-prime ] lfrom-by ] if ;
+    dup 3 < [ drop lprimes ] [ 1 - next-prime [ next-prime ] lfrom-by ] if ;
index a7fdc421aa4c7d089abb59978644e7eb677fc3d0..5bd24c3e98e40fdf102f419faa2eeb30092825e5 100644 (file)
@@ -4,4 +4,4 @@ IN: math.text.english
 HELP: number>text
 { $values { "n" integer } { "str" string } }
 { $description "Converts an integer to a text string representation in English, including appropriate punctuation and conjunctions." }
-{ $examples { $example "USING: math.text.english prettyprint ;" "12345 number>text ." "\"Twelve Thousand, Three Hundred and Forty-Five\"" } } ;
+{ $examples { $example "USING: math.text.english prettyprint ;" "12345 number>text ." "\"twelve thousand, three hundred and forty-five\"" } } ;
index 8f8932c97d9c870addbdf6b8f696a9683cf325e5..81a94687a7c46463a391537a5bd1114577c79199 100644 (file)
@@ -1,15 +1,15 @@
 USING: math.functions math.text.english tools.test ;
 IN: math.text.english.tests
 
-[ "Zero" ] [ 0 number>text ] unit-test
-[ "Twenty-One" ] [ 21 number>text ] unit-test
-[ "One Hundred" ] [ 100 number>text ] unit-test
-[ "One Hundred and One" ] [ 101 number>text ] unit-test
-[ "One Thousand and One" ] [ 1001 number>text ] unit-test
-[ "One Thousand, One Hundred and One" ] [ 1101 number>text ] unit-test
-[ "One Million, One Thousand and One" ] [ 1001001 number>text ] unit-test
-[ "One Million, One Thousand, One Hundred and One" ] [ 1001101 number>text ] unit-test
-[ "One Million, One Hundred and Eleven Thousand, One Hundred and Eleven" ] [ 1111111 number>text ] unit-test
-[ "One Duotrigintillion" ] [ 10 99 ^ number>text ] unit-test
+[ "zero" ] [ 0 number>text ] unit-test
+[ "twenty-one" ] [ 21 number>text ] unit-test
+[ "one hundred" ] [ 100 number>text ] unit-test
+[ "one hundred and one" ] [ 101 number>text ] unit-test
+[ "one thousand and one" ] [ 1001 number>text ] unit-test
+[ "one thousand, one hundred and one" ] [ 1101 number>text ] unit-test
+[ "one million, one thousand and one" ] [ 1001001 number>text ] unit-test
+[ "one million, one thousand, one hundred and one" ] [ 1001101 number>text ] unit-test
+[ "one million, one hundred and eleven thousand, one hundred and eleven" ] [ 1111111 number>text ] unit-test
+[ "one duotrigintillion" ] [ 10 99 ^ number>text ] unit-test
 
-[ "Negative One Hundred and Twenty-Three" ] [ -123 number>text ] unit-test
+[ "negative one hundred and twenty-three" ] [ -123 number>text ] unit-test
index 5a10e7af37009b412edecb9adb2b4d773aba2e1d..422036d5cc39ae6c44c819f5632c926439653c17 100755 (executable)
@@ -7,35 +7,44 @@ IN: math.text.english
 <PRIVATE
 
 : small-numbers ( n -- str )
-    { "Zero" "One" "Two" "Three" "Four" "Five" "Six" "Seven" "Eight" "Nine"
-    "Ten" "Eleven" "Twelve" "Thirteen" "Fourteen" "Fifteen" "Sixteen"
-    "Seventeen" "Eighteen" "Nineteen" } nth ;
+    {
+        "zero" "one" "two" "three" "four" "five" "six"
+        "seven" "eight" "nine" "ten" "eleven" "twelve"
+        "thirteen" "fourteen" "fifteen" "sixteen" "seventeen"
+        "eighteen" "nineteen"
+    } nth ;
 
 : tens ( n -- str )
-    { f f "Twenty" "Thirty" "Forty" "Fifty" "Sixty" "Seventy" "Eighty" "Ninety" } nth ;
-
+    {
+        f f "twenty" "thirty" "forty" "fifty" "sixty"
+        "seventy" "eighty" "ninety"
+    } nth ;
+    
 : scale-numbers ( n -- str )  ! up to 10^99
-    { f "Thousand" "Million" "Billion" "Trillion" "Quadrillion" "Quintillion"
-    "Sextillion" "Septillion" "Octillion" "Nonillion" "Decillion" "Undecillion"
-    "Duodecillion" "Tredecillion" "Quattuordecillion" "Quindecillion"
-    "Sexdecillion" "Septendecillion" "Octodecillion" "Novemdecillion"
-    "Vigintillion" "Unvigintillion" "Duovigintillion" "Trevigintillion"
-    "Quattuorvigintillion" "Quinvigintillion" "Sexvigintillion"
-    "Septvigintillion" "Octovigintillion" "Novemvigintillion" "Trigintillion"
-    "Untrigintillion" "Duotrigintillion" } nth ;
+    {
+        f "thousand" "million" "billion" "trillion" "quadrillion"
+        "quintillion" "sextillion" "septillion" "octillion"
+        "nonillion" "decillion" "undecillion" "duodecillion"
+        "tredecillion" "quattuordecillion" "quindecillion"
+        "sexdecillion" "septendecillion" "octodecillion" "novemdecillion"
+        "vigintillion" "unvigintillion" "duovigintillion" "trevigintillion"
+        "quattuorvigintillion" "quinvigintillion" "sexvigintillion"
+        "septvigintillion" "octovigintillion" "novemvigintillion"
+        "trigintillion" "untrigintillion" "duotrigintillion"
+    } nth ;
 
 SYMBOL: and-needed?
 : set-conjunction ( seq -- )
     first { [ 100 < ] [ 0 > ] } 1&& and-needed? set ;
 
 : negative-text ( n -- str )
-    0 < "Negative " "" ? ;
+    0 < "negative " "" ? ;
 
 : hundreds-place ( n -- str )
     100 /mod over 0 = [
         2drop ""
     ] [
-        [ small-numbers " Hundred" append ] dip
+        [ small-numbers " hundred" append ] dip
         0 = [ " and " append ] unless
     ] if ;
 
@@ -78,7 +87,7 @@ SYMBOL: and-needed?
     ] if ;
 
 : (number>text) ( n -- str )
-    [ negative-text ] [ abs 3digit-groups recombine ] bi append ;
+    [ negative-text ] [ abs 3 digit-groups recombine ] bi append ;
 
 PRIVATE>
 
index f8b97103eb30183f635a95160c49a360e505851e..8d313b91970f4fcc3dfe4eba2fa4417e7bf8879f 100644 (file)
@@ -73,7 +73,7 @@ MEMO: units ( -- seq ) ! up to 10^99
     } cond ;
 
 : over-1000000 ( n -- str )
-    3digit-groups [ 1+ units nth n-units ] map-index sift
+    3 digit-groups [ 1 + units nth n-units ] map-index sift
     reverse " " join ;
 
 : decompose ( n -- str ) 1000000 /mod [ over-1000000 ] dip complete ;
old mode 100644 (file)
new mode 100755 (executable)
index e1d1a00..2352ab9
@@ -1,6 +1,6 @@
 USING: help.markup help.syntax ;
 IN: math.text.utils
 
-HELP: 3digit-groups
-{ $values { "n" "a positive integer" } { "seq" "a sequence" } }
-{ $description "Decompose a number into 3 digits groups and return them in a sequence, starting with the units, then the tenths, etc." } ;
+HELP: digit-groups
+{ $values { "n" "a positive integer" } { "k" "a positive integer" } { "seq" "a sequence" } }
+{ $description "Decompose a number into groups of " { $snippet "k" } " digits and return them in a sequence starting with the least significant grouped digits first." } ;
old mode 100644 (file)
new mode 100755 (executable)
index d14bb06..04fbcdc
@@ -1,3 +1,3 @@
 USING: math.text.utils tools.test ;
 
-[ { 1 999 2 } ] [ 2999001 3digit-groups ] unit-test
+[ { 1 999 2 } ] [ 2999001 3 digit-groups ] unit-test
old mode 100644 (file)
new mode 100755 (executable)
index 422a79a..13551f1
@@ -1,7 +1,7 @@
 ! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math sequences ;
+USING: kernel fry math.functions math sequences ;
 IN: math.text.utils
 
-: 3digit-groups ( n -- seq )
-    [ dup 0 > ] [ 1000 /mod ] produce nip ;
+: digit-groups ( n k -- seq )
+    [ dup 0 > ] swap '[ _ 10^ /mod ] produce nip ;
index adaab737c3dc00696a0c0656356fdb86302c84de..39a73eab82399b3ac83784c40b1b784de52179fa 100644 (file)
@@ -1,14 +1,14 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-math? t }
-    { deploy-io 2 }
-    { deploy-unicode? t }
+    { deploy-name "Merger" }
     { deploy-c-types? f }
     { "stop-after-last-window?" t }
-    { deploy-ui? t }
-    { deploy-reflection 1 }
-    { deploy-name "Merger" }
-    { deploy-word-props? f }
+    { deploy-unicode? f }
     { deploy-threads? t }
+    { deploy-reflection 1 }
     { deploy-word-defs? f }
+    { deploy-math? t }
+    { deploy-ui? t }
+    { deploy-word-props? f }
+    { deploy-io 2 }
 }
index c4986bf47fb47bf436176f8cf0197d84d9e41bbf..ee9207e4caff4121d83fe92e08798862116cc801 100644 (file)
@@ -1,4 +1,5 @@
-USING: accessors arrays fry io.directories kernel models sequences sets ui
+USING: accessors arrays fry io.directories kernel
+models sequences sets ui
 ui.gadgets ui.gadgets.buttons ui.gadgets.labeled
 ui.gadgets.tracks ui.gadgets.labels ui.gadgets.glass
 math.rectangles cocoa.dialogs ;
diff --git a/extra/models/combinators/authors.txt b/extra/models/combinators/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/models/combinators/combinators-docs.factor b/extra/models/combinators/combinators-docs.factor
new file mode 100644 (file)
index 0000000..5ccfe1f
--- /dev/null
@@ -0,0 +1,41 @@
+USING: help.markup help.syntax models models.arrow sequences monads ;
+IN: models.combinators
+
+HELP: merge
+{ $values { "models" "a list of models" } { "model" basic-model } }
+{ $description "Creates a model that merges the updates of others" } ;
+
+HELP: filter-model
+{ $values { "model" model } { "quot" "quotation with stack effect ( a b -- c )" } { "filter-model" filter-model } }
+{ $description "Creates a model that uses the updates of another model only when they satisfy a given predicate" } ;
+
+HELP: fold
+{ $values { "oldval" "starting value" } { "quot" "applied to update and previous values" } { "model" model } { "model" model } }
+{ $description "Similar to " { $link reduce } " but works on models, applying a quotation to the previous and new values at each update" } ;
+
+HELP: switch-models
+{ $values { "model1" model } { "model2" model } { "model'" model } }
+{ $description "Creates a model that starts with the behavior of model2 and switches to the behavior of model1 on its update" } ;
+
+HELP: <mapped>
+{ $values { "model" model } { "quot" "applied to model's value on updates" } { "model" model } }
+{ $description "An expanded version of " { $link <arrow> } ". Use " { $link fmap } " instead." } ;
+
+HELP: when-model
+{ $values { "model" model } { "quot" "called on the model if the quot yields true" } { "cond" "a quotation called on the model's value, yielding a boolean value"  } }
+{ $description "Calls quot when model updates if its value meets the condition set in cond" } ;
+
+HELP: with-self
+{ $values { "quot" "quotation that recieves its own return value" } { "model" model } }
+{ $description "Fixed points for models: the quot reacts to the same model to gives" } ;
+
+HELP: #1
+{ $values { "model" model } { "model'" model } }
+{ $description "Moves a model to the top of its dependencies' connections, thus being notified before the others" } ;
+
+ARTICLE: "models.combinators" "Extending models"
+"The " { $vocab-link "models.combinators" } " library expands models to have discrete start and end times. "
+"Also, it provides methods of manipulating and combining models, expecially useful when programming user interfaces: "
+"The output models of some gadgets (see " { $vocab-link "ui.gadgets.controls" } " ) can be manipulated and used as the input models of others. " ;
+
+ABOUT: "models.combinators"
\ No newline at end of file
diff --git a/extra/models/combinators/combinators.factor b/extra/models/combinators/combinators.factor
new file mode 100644 (file)
index 0000000..c7b864d
--- /dev/null
@@ -0,0 +1,105 @@
+USING: accessors arrays kernel models models.product monads
+sequences sequences.extras ;
+FROM: syntax => >> ;
+IN: models.combinators
+
+TUPLE: multi-model < model important? ;
+GENERIC: (model-changed) ( model observer -- )
+: <multi-model> ( models kind -- model ) f swap new-model [ [ add-dependency ] curry each ] keep ;
+M: multi-model model-changed over value>> [ (model-changed) ] [ 2drop ] if ;
+M: multi-model model-activated dup dependencies>> [ value>> ] find nip
+   [ swap model-changed ] [ drop ] if* ;
+
+: #1 ( model -- model' ) t >>important? ;
+
+IN: models
+: notify-connections ( model -- )
+    dup connections>> dup [ dup multi-model? [ important?>> ] [ drop f ] if ] find-all
+    [ second tuck [ remove ] dip prefix ] each
+    [ model-changed ] with each ;
+IN: models.combinators
+
+TUPLE: basic-model < multi-model ;
+M: basic-model (model-changed) [ value>> ] dip set-model ;
+: merge ( models -- model ) basic-model <multi-model> ;
+: 2merge ( model1 model2 -- model ) 2array merge ;
+: <basic> ( value -- model ) basic-model new-model ;
+
+TUPLE: filter-model < multi-model quot ;
+M: filter-model (model-changed) [ value>> ] dip 2dup quot>> call( a -- ? )
+   [ set-model ] [ 2drop ] if ;
+: filter-model ( model quot -- filter-model ) [ 1array \ filter-model <multi-model> ] dip >>quot ;
+
+TUPLE: fold-model < multi-model quot base values ;
+M: fold-model (model-changed) 2dup base>> =
+    [ [ [ value>> ] [ [ values>> ] [ quot>> ] bi ] bi* swapd reduce* ] keep set-model ]
+    [ [ [ value>> ] [ values>> ] bi* push ]
+      [ [ [ value>> ] [ [ value>> ] [ quot>> ] bi ] bi* call( val oldval -- newval ) ] keep set-model ] 2bi
+    ] if ;
+M: fold-model model-activated drop ;
+: new-fold-model ( deps -- model ) fold-model <multi-model> V{ } clone >>values ;
+: fold ( model oldval quot -- model ) rot 1array new-fold-model swap >>quot
+   swap >>value ;
+: fold* ( model oldmodel quot -- model ) over [ [ 2array new-fold-model ] dip >>quot ]
+    dip [ >>base ] [ value>> >>value ] bi ;
+
+TUPLE: updater-model < multi-model values updates ;
+M: updater-model (model-changed) [ tuck updates>> =
+   [ [ values>> value>> ] keep set-model ]
+   [ drop ] if ] keep f swap (>>value) ;
+: updates ( values updates -- model ) [ 2array updater-model <multi-model> ] 2keep
+   [ >>values ] [ >>updates ] bi* ;
+
+SYMBOL: switch
+TUPLE: switch-model < multi-model original switcher on ;
+M: switch-model (model-changed) 2dup switcher>> =
+   [ [ value>> ] dip over switch = [ nip [ original>> ] keep f >>on model-changed ] [ t >>on set-model ] if ]
+   [ dup on>> [ 2drop ] [ [ value>> ] dip over [ set-model ] [ 2drop ] if ] if ] if ;
+: switch-models ( model1 model2 -- model' ) swap [ 2array switch-model <multi-model> ] 2keep
+   [ [ value>> >>value ] [ >>original ] bi ] [ >>switcher ] bi* ;
+M: switch-model model-activated [ original>> ] keep model-changed ;
+: >behavior ( event -- behavior ) t >>value ;
+
+TUPLE: mapped-model < multi-model model quot ;
+: new-mapped-model ( model quot class -- mapped-model ) [ over 1array ] dip
+   <multi-model> swap >>quot swap >>model ;
+: <mapped> ( model quot -- model ) mapped-model new-mapped-model ;
+M: mapped-model (model-changed)
+    [ [ value>> ] [ quot>> ] bi* call( old -- new ) ] [ nip ] 2bi
+    set-model ;
+
+TUPLE: side-effect-model < mapped-model ;
+M: side-effect-model (model-changed) [ value>> ] dip [ quot>> call( old -- ) ] 2keep set-model ;
+
+TUPLE: quot-model < mapped-model ;
+M: quot-model (model-changed) nip [ quot>> call( -- b ) ] keep set-model ;
+
+TUPLE: action-value < basic-model parent ;
+: <action-value> ( parent value -- model ) action-value new-model swap >>parent ;
+M: action-value model-activated dup parent>> dup activate-model model-changed ; ! a fake dependency of sorts
+
+TUPLE: action < multi-model quot ;
+M: action (model-changed) [ [ value>> ] [ quot>> ] bi* call( a -- b ) ] keep value>>
+   [ swap add-connection ] 2keep model-changed ;
+: <action> ( model quot -- action-model ) [ 1array action <multi-model> ] dip >>quot dup f <action-value> >>value value>> ;
+
+TUPLE: collection < multi-model ;
+: <collection> ( models -- product ) collection <multi-model> ;
+M: collection (model-changed)
+    nip
+    dup dependencies>> [ value>> ] all?
+    [ dup [ value>> ] product-value swap set-model ]
+    [ drop ] if ;
+M: collection model-activated dup (model-changed) ;
+
+! for side effects
+TUPLE: (when-model) < multi-model quot cond ;
+: when-model ( model quot cond -- model ) rot 1array (when-model) <multi-model> swap >>cond swap >>quot ;
+M: (when-model) (model-changed) [ quot>> ] 2keep
+    [ value>> ] [ cond>> ] bi* call( a -- ? ) [ call( model -- ) ] [ 2drop ] if ;
+
+! only used in construction
+: with-self ( quot: ( model -- model ) -- model ) [ f <basic> dup ] dip call swap [ add-dependency ] keep ; inline
+
+USE: models.combinators.templates
+<< { "$>" "<$" "fmap" } [ fmaps ] each >>
\ No newline at end of file
diff --git a/extra/models/combinators/summary.txt b/extra/models/combinators/summary.txt
new file mode 100644 (file)
index 0000000..1e5347e
--- /dev/null
@@ -0,0 +1 @@
+Model combination and manipulation
\ No newline at end of file
diff --git a/extra/models/combinators/templates/templates.factor b/extra/models/combinators/templates/templates.factor
new file mode 100644 (file)
index 0000000..685ad93
--- /dev/null
@@ -0,0 +1,23 @@
+USING: kernel sequences functors fry macros generalizations ;
+IN: models.combinators.templates
+FROM: models.combinators => <collection> #1 ;
+FUNCTOR: fmaps ( W -- )
+W        IS ${W}
+w-n      DEFINES ${W}-n
+w-2      DEFINES 2${W}
+w-3      DEFINES 3${W}
+w-4      DEFINES 4${W}
+w-n*     DEFINES ${W}-n*
+w-2*     DEFINES 2${W}*
+w-3*     DEFINES 3${W}*
+w-4*     DEFINES 4${W}*
+WHERE
+MACRO: w-n ( int -- quot ) dup '[ [ _ narray <collection> ] dip [ _ firstn ] prepend W ] ;
+: w-2 ( a b quot -- mapped ) 2 w-n ; inline
+: w-3 ( a b c quot -- mapped ) 3 w-n ; inline
+: w-4 ( a b c d quot -- mapped ) 4 w-n ; inline
+MACRO: w-n* ( int -- quot ) dup '[ [ _ narray <collection> #1 ] dip [ _ firstn ] prepend W ] ;
+: w-2* ( a b quot -- mapped ) 2 w-n* ; inline
+: w-3* ( a b c quot -- mapped ) 3 w-n* ; inline
+: w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline
+;FUNCTOR
\ No newline at end of file
diff --git a/extra/models/conditional/authors.txt b/extra/models/conditional/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/models/conditional/conditional.factor b/extra/models/conditional/conditional.factor
new file mode 100644 (file)
index 0000000..37cf3d1
--- /dev/null
@@ -0,0 +1,21 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays accessors kernel models threads calendar ;
+IN: models.conditional
+
+TUPLE: conditional < model condition thread ;
+
+M: conditional model-changed
+    [
+        [ dup
+            [ condition>> call( -- ? ) ]
+            [ thread>> self = not ] bi or
+            [ [ value>> ] dip set-model f ]
+            [ 2drop t ] if 100 milliseconds sleep 
+        ] 2curry "models.conditional" spawn-server
+    ] keep (>>thread) ;
+
+: <conditional> ( condition -- model )
+    f conditional new-model swap >>condition ;
+
+M: conditional model-activated [ model>> ] keep model-changed ;
\ No newline at end of file
diff --git a/extra/modules/rpc-server/authors.txt b/extra/modules/rpc-server/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/modules/rpc-server/rpc-server-docs.factor b/extra/modules/rpc-server/rpc-server-docs.factor
new file mode 100644 (file)
index 0000000..fc2c234
--- /dev/null
@@ -0,0 +1,5 @@
+USING: help.syntax help.markup modules.rpc-server modules.using ;
+IN: modules.rpc-server
+HELP: service
+{ $syntax "IN: my-vocab service" }
+{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } } ;
\ No newline at end of file
diff --git a/extra/modules/rpc-server/rpc-server.factor b/extra/modules/rpc-server/rpc-server.factor
new file mode 100644 (file)
index 0000000..d82f13f
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs combinators continuations effects
+io.encodings.binary io.servers.connection kernel namespaces
+sequences serialize sets threads vocabs vocabs.parser init io ;
+IN: modules.rpc-server
+
+<PRIVATE
+TUPLE: rpc-request args vocabspec wordname ;
+SYMBOL: serving-vocabs serving-vocabs [ V{ } clone ] initialize
+
+: getter ( -- ) deserialize dup serving-vocabs get-global index
+        [ vocab-words [ stack-effect ] { } assoc-map-as ]
+        [ \ no-vocab boa ] if serialize flush ;
+
+: doer ( -- ) deserialize dup vocabspec>> serving-vocabs get-global index
+        [ [ args>> ] [ wordname>> ] [ vocabspec>> vocab-words ] tri at [ execute ] curry with-datastack ]
+        [ vocabspec>> \ no-vocab boa ] if serialize flush ;
+
+PRIVATE>
+SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
+
+: start-rpc-server ( -- )
+    binary <threaded-server>
+    "rpcs" >>name 9012 >>insecure
+    [ deserialize {
+      { "getter" [ getter ] }
+      {  "doer" [ doer ] }
+      { "loader" [ deserialize vocab serialize flush ] } 
+    } case ] >>handler
+    start-server ;
diff --git a/extra/modules/rpc-server/summary.txt b/extra/modules/rpc-server/summary.txt
new file mode 100644 (file)
index 0000000..3688644
--- /dev/null
@@ -0,0 +1 @@
+Serve factor words as rpcs
\ No newline at end of file
diff --git a/extra/modules/rpc/authors.txt b/extra/modules/rpc/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/modules/rpc/rpc-docs.factor b/extra/modules/rpc/rpc-docs.factor
new file mode 100644 (file)
index 0000000..af99d21
--- /dev/null
@@ -0,0 +1,9 @@
+USING: help.syntax help.markup ;
+IN: modules.rpc
+ARTICLE: { "modules" "protocol" } "RPC Protocol"
+{ $list
+   "Send vocab as string"
+   "Send arglist"
+   "Send word as string"
+   "Receive result list"
+} ;
\ No newline at end of file
diff --git a/extra/modules/rpc/rpc.factor b/extra/modules/rpc/rpc.factor
new file mode 100644 (file)
index 0000000..b394090
--- /dev/null
@@ -0,0 +1,27 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs fry generalizations io.encodings.binary
+io.sockets kernel locals namespaces parser sequences serialize
+vocabs vocabs.parser words io ;
+IN: modules.rpc
+
+TUPLE: rpc-request args vocabspec wordname ;
+
+: send-with-check ( message -- reply/* )
+    serialize flush deserialize dup no-vocab? [ throw ] when ;
+
+:: define-remote ( str effect addrspec vocabspec -- )
+    str create-in effect [ in>> length ] [ out>> length ] bi
+    '[ _ narray vocabspec str rpc-request boa addrspec 9012 <inet> binary
+    [ "doer" serialize send-with-check ] with-client _ firstn ]
+    effect define-declared ;
+
+:: remote-vocab ( addrspec vocabspec -- vocab )
+   vocabspec "-remote" append dup vocab [ dup set-current-vocab
+     vocabspec addrspec 9012 <inet> binary [ "getter" serialize send-with-check ] with-client
+     [ first2 addrspec vocabspec define-remote ] each
+   ] unless ;
+
+: remote-load ( addr vocabspec -- voabspec ) [ swap
+    9012 <inet> binary [ "loader" serialize serialize flush deserialize ] with-client ] keep
+    [ dictionary get-global set-at ] keep ;
\ No newline at end of file
diff --git a/extra/modules/rpc/summary.txt b/extra/modules/rpc/summary.txt
new file mode 100644 (file)
index 0000000..cc1501f
--- /dev/null
@@ -0,0 +1 @@
+remote procedure call client
\ No newline at end of file
diff --git a/extra/modules/using/authors.txt b/extra/modules/using/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/modules/using/summary.txt b/extra/modules/using/summary.txt
new file mode 100644 (file)
index 0000000..62fdb05
--- /dev/null
@@ -0,0 +1 @@
+Improved module import syntax with network transparency
\ No newline at end of file
diff --git a/extra/modules/using/using-docs.factor b/extra/modules/using/using-docs.factor
new file mode 100644 (file)
index 0000000..0f67f2b
--- /dev/null
@@ -0,0 +1,11 @@
+USING: help.syntax help.markup strings modules.using ;
+IN: modules.using
+ARTICLE: { "modules.using" "use" } "Using the modules.using vocab"
+"This vocabulary defines " { $link POSTPONE: USING*: } " as an alternative to " { $link POSTPONE: USING: } " which makes qualified imports easier. "
+"Secondly, it allows loading vocabularies from remote servers, as long as the remote vocabulary can be accessed at compile time. "
+"Finally, the word can treat words in remote vocabularies as remote procedure calls. Any inputs are passed to the imported words as normal, and the result will appear on the stack- the only difference is that the word isn't called locally." ;
+ABOUT: { "modules.using" "use" }
+
+HELP: USING*:
+{ $syntax "USING: rpc-server::module fetch-sever:module { module qualified-name } { module => word ... } { qualified-module } { module EXCEPT word ... } { module word => importname } ;" }
+{ $description "Adds vocabularies to the search path. Vocabularies can be loaded off a server or called as an rpc if preceded by a valid hostname. Bracketed pairs facilitate all types of qualified imports on both remote and local modules." } ;
\ No newline at end of file
diff --git a/extra/modules/using/using.factor b/extra/modules/using/using.factor
new file mode 100644 (file)
index 0000000..5691caa
--- /dev/null
@@ -0,0 +1,28 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel modules.rpc peg peg-lexer peg.ebnf sequences
+strings vocabs.parser ;
+IN: modules.using
+
+EBNF: modulize
+tokenpart = (!(':').)+ => [[ >string ]]
+s = ':' => [[ drop ignore ]]
+rpc = tokenpart s s tokenpart => [[ first2 remote-vocab ]]
+remote = tokenpart s tokenpart => [[ first2 remote-load ]]
+module = rpc | remote | tokenpart
+;EBNF
+
+ON-BNF: USING*:
+tokenizer = <foreign factor>
+sym = !(";"|"}"|"=>"|"EXCEPT").
+modspec = sym => [[ modulize ]]
+qualified-with = modspec sym => [[ first2 add-qualified ignore ]]
+qualified = modspec => [[ dup add-qualified ignore ]]
+from = modspec "=>" sym+ => [[ first3 nip add-words-from ignore ]]
+exclude = modspec "EXCEPT" sym+ => [[ first3 nip add-words-excluding ignore ]]
+rename = modspec sym "=>" sym => [[ first4 nip swapd add-renamed-word ignore ]]
+long = "{" ( from | exclude | rename | qualified-with | qualified ) "}" => [[ drop ignore ]]
+short = modspec => [[ use-vocab ignore ]]
+wordSpec = long | short
+using = wordSpec+ ";" => [[ drop ignore ]]
+;ON-BNF
\ No newline at end of file
index 0f1eb8edda53fcf203689f1d7640ecf212b4e903..5504633bb636fdac67bc5007f3c930467c142776 100644 (file)
@@ -78,7 +78,7 @@ IN: monads.tests
 ] unit-test
 
 LAZY: nats-from ( n -- list )
-    dup 1+ nats-from cons ;
+    dup 1 + nats-from cons ;
 
 : nats ( -- list ) 0 nats-from ;
 
index 6b35772596f92e59e06c18b8ff6055e19ab6720d..a859c36f2e22661c7c8b2dee311d7de787e43c00 100644 (file)
@@ -7,6 +7,8 @@ IN: monads
 
 ! Functors
 GENERIC# fmap 1 ( functor quot -- functor' )
+GENERIC# <$ 1 ( functor quot -- functor' )
+GENERIC# $> 1 ( functor quot -- functor' )
 
 ! Monads
 
@@ -22,6 +24,7 @@ M: monad return monad-of return ;
 M: monad fail   monad-of fail   ;
 
 : bind ( mvalue quot -- mvalue' ) swap >>= call( quot -- mvalue ) ;
+: bind* ( mvalue quot -- mvalue' ) '[ drop @ ] bind ;
 : >>   ( mvalue k -- mvalue' ) '[ drop _ ] bind ;
 
 :: lift-m2 ( m1 m2 f monad -- m3 )
index 994d2143355c5925e2c583b855625ac325215d14..36dedb2a653b92e2f661317f227a2a1256ce23f0 100644 (file)
@@ -28,6 +28,6 @@ ERROR: not-an-integer x ;
     [
         [ dup string>number [ nip ] [ not-an-integer ] if* ] bi@
     ] keep length
-    10 swap ^ / + swap [ neg ] when ;
+    10^ / + swap [ neg ] when ;
 
 SYNTAX: DECIMAL: scan parse-decimal parsed ;
index e627a745cdc5fa13f5fc4abb1b8f89e9edac5398..2c7258bb68e1b7aca591eae5ba6b259a2a081763 100755 (executable)
@@ -3,7 +3,7 @@ namespaces opengl opengl.gl sequences ui ui.gadgets ui.gestures
 ui.gadgets.worlds ui.render accessors combinators literals ;
 IN: opengl.demo-support
 
-CONSTANT: FOV $[ 2.0 sqrt 1+ ]
+CONSTANT: FOV $[ 2.0 sqrt 1 + ]
 CONSTANT: MOUSE-MOTION-SCALE 0.5
 CONSTANT: KEY-ROTATE-STEP 10.0
 
index d44d5bce78e6974bc94cbca66e3a6d18baab9143..131f9f5465107c2b597850589203143e1bed36cd 100644 (file)
@@ -21,7 +21,7 @@ ERROR: no-pair-method a b generic ;
 
 : sorted-pair-methods ( word -- alist )
     "pair-generic-methods" word-prop >alist
-    [ [ first method-sort-key ] bi@ >=< ] sort ;
+    [ first method-sort-key ] inv-sort-with ;
 
 : pair-generic-definition ( word -- def )
     [ sorted-pair-methods [ first2 pair-method-cond ] map ]
index 814821fba963888825ea4cf53ed9b1d38539ea4d..7a73561e56fbbdfaf2c1f436ef95ce570d0c2110 100755 (executable)
@@ -339,7 +339,7 @@ LAZY: surrounded-by ( parser start end -- parser' )
         2drop epsilon
     ] [
         2dup exactly-n
-        -rot 1- at-most-n <|>
+        -rot 1 - at-most-n <|>
     ] if ;
 
 : at-least-n ( parser n -- parser' )
index eff0043ac373a9adcffc51ec78dd9aceb21ffc9e..dcde55c91ada82f2a6c696b928ebb2d58549a219 100644 (file)
@@ -11,8 +11,8 @@ CONSULT: assoc-protocol lex-hash hash>> ;
 
 :: prepare-pos ( v i -- c l )
     [let | n [ i v head-slice ] |
-           v CHAR: \n n last-index -1 or 1+ -
-           n [ CHAR: \n = ] count 1+
+           v CHAR: \n n last-index -1 or 1 + -
+           n [ CHAR: \n = ] count 1 +
     ] ;
       
 : store-pos ( v a -- )
@@ -25,12 +25,12 @@ M: lex-hash set-at
         [ swap hash>> set-at ]
     } case ;
 
-:: at-pos ( t l c -- p ) t l head-slice [ length ] map sum l 1- + c + ;
+:: at-pos ( t l c -- p ) t l head-slice [ length ] map sum l 1 - + c + ;
 
 M: lex-hash at*
     swap {
       { input [ drop lexer get text>> "\n" join t ] }
-      { pos [ drop lexer get [ text>> ] [ line>> 1- ] [ column>> 1+ ] tri at-pos t ] }
+      { pos [ drop lexer get [ text>> ] [ line>> 1 - ] [ column>> 1 + ] tri at-pos t ] }
       [ swap hash>> at* ]
     } case ;
 
@@ -61,4 +61,4 @@ space = " " | "\n" | "\t"
 spaces = space* => [[ drop ignore ]]
 chunk = (!(space) .)+ => [[ >string ]]
 expr = spaces chunk
-;EBNF
\ No newline at end of file
+;EBNF
diff --git a/extra/persistency/authors.txt b/extra/persistency/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/persistency/persistency.factor b/extra/persistency/persistency.factor
new file mode 100644 (file)
index 0000000..f459eca
--- /dev/null
@@ -0,0 +1,30 @@
+USING: accessors arrays byte-arrays calendar classes
+classes.tuple classes.tuple.parser combinators db db.queries
+db.tuples db.types kernel math nmake parser sequences strings
+strings.parser unicode.case urls words ;
+IN: persistency
+
+TUPLE: persistent id ;
+
+: add-types ( table -- table' ) [ dup array? [ [ first dup >upper ] [ second ] bi 3array ]
+        [ dup >upper FACTOR-BLOB 3array ] if
+    ] map { "id" "ID" +db-assigned-id+ } prefix ;
+
+: remove-types ( table -- table' ) [ dup array? [ first ] when ] map ;
+
+SYNTAX: STORED-TUPLE: parse-tuple-definition [ drop persistent ] dip [ remove-types define-tuple-class ]
+   [ nip [ dup name>> >upper ] [ add-types ] bi* define-persistent ] 3bi ;
+
+: define-db ( database class -- ) swap [ [ ensure-table ] with-db ] [ "database" set-word-prop ] 2bi ;
+
+: query>tuple ( tuple/query -- tuple ) dup query? [ tuple>> ] when ;
+: w/db ( query quot -- ) [ dup query>tuple class "database" word-prop ] dip with-db ; inline
+: get-tuples ( query -- tuples ) [ select-tuples ] w/db ;
+: get-tuple ( query -- tuple ) [ select-tuple ] w/db ;
+: store-tuple ( tuple -- ) [ insert-tuple ] w/db ;
+: modify-tuple ( tuple -- ) [ update-tuple ] w/db ;
+: remove-tuples ( tuple -- ) [ delete-tuples ] w/db ;
+    
+TUPLE: pattern value ; C: <pattern> pattern
+SYNTAX: %" parse-string <pattern> parsed ;
+M: pattern where value>> over column-name>> 0% " LIKE " 0% bind# ;
index 204527418b2828de68ede1571adb1a49cdaf6111..d59b9103449c5832c57fc9770bc35693764afa3e 100644 (file)
@@ -23,7 +23,7 @@ IN: project-euler.001
 <PRIVATE
 
 : sum-divisible-by ( target n -- m )
-    [ /i dup 1+ * ] keep * 2 /i ;
+    [ /i dup 1 + * ] keep * 2 /i ;
 
 PRIVATE>
 
index d2679f6309eade32c9880dc7bbb410cf5f388a07..223404b9d6888579994421db040eb36aa40aba1c 100644 (file)
@@ -34,7 +34,7 @@ IN: project-euler.012
 ! --------
 
 : euler012 ( -- answer )
-    8 [ dup nth-triangle tau* 500 < ] [ 1+ ] while nth-triangle ;
+    8 [ dup nth-triangle tau* 500 < ] [ 1 + ] while nth-triangle ;
 
 ! [ euler012 ] 10 ave-time
 ! 6573 ms ave run time - 346.27 SD (10 trials)
index b0305d5c3941daeb3154244dc6677e7e34068e90..49680177d525fb57bb69218141e32e270b1ab91c 100644 (file)
@@ -36,7 +36,7 @@ IN: project-euler.014
 <PRIVATE
 
 : next-collatz ( n -- n )
-    dup even? [ 2 / ] [ 3 * 1+ ] if ;
+    dup even? [ 2 / ] [ 3 * 1 + ] if ;
 
 : longest ( seq seq -- seq )
     2dup [ length ] bi@ > [ drop ] [ nip ] if ;
@@ -59,7 +59,7 @@ PRIVATE>
 <PRIVATE
 
 : worth-calculating? ( n -- ? )
-    1- 3 { [ divisor? ] [ / even? ] } 2&& ;
+    1 - 3 { [ divisor? ] [ / even? ] } 2&& ;
 
 PRIVATE>
 
index 1b675d41c47333ff9171c85a652ae12ca873b70a..b548591b5e3ba6eff89a05315a6afd883169bfc0 100644 (file)
@@ -32,7 +32,7 @@ IN: project-euler.022
     ascii file-contents [ quotable? ] filter "," split ;
 
 : name-scores ( seq -- seq )
-    [ 1+ swap alpha-value * ] map-index ;
+    [ 1 + swap alpha-value * ] map-index ;
 
 PRIVATE>
 
index 5dfe7b9f56343ea334886858a2fe2a6d42f1d826..e381e323d15f3fa61b586d675d2c06585a585f98 100644 (file)
@@ -44,7 +44,7 @@ MEMO: fib ( m -- n )
 <PRIVATE
 
 : (digit-fib) ( n term -- term )
-    2dup fib number>string length > [ 1+ (digit-fib) ] [ nip ] if ;
+    2dup fib number>string length > [ 1 + (digit-fib) ] [ nip ] if ;
 
 : digit-fib ( n -- term )
     1 (digit-fib) ;
@@ -68,7 +68,7 @@ PRIVATE>
 <PRIVATE
 
 : digit-fib* ( n -- term )
-    1- 5 log10 2 / + phi log10 / ceiling >integer ;
+    1 - 5 log10 2 / + phi log10 / ceiling >integer ;
 
 PRIVATE>
 
index 8e0cf37fa2724b6ad466989052747d93c0d6812e..4f4466c3952a73523430f43b12542f05898f5736 100644 (file)
@@ -37,7 +37,7 @@ IN: project-euler.026
     1 1000 (a,b) [ prime? ] filter [ 1 swap / ] map ;
 
 : (mult-order) ( n a m -- k )
-    3dup ^ swap mod 1 = [ 2nip ] [ 1+ (mult-order) ] if ;
+    3dup ^ swap mod 1 = [ 2nip ] [ 1 + (mult-order) ] if ;
 
 PRIVATE>
 
index f7bffbf66587d55452c1015796e34c44d7953c46..f97d8e9e0ddd700dc6b2b339a817d980c0d36908 100644 (file)
@@ -53,7 +53,7 @@ IN: project-euler.027
     dup sq -rot * + + ;
 
 : (consecutive-primes) ( b a n -- m )
-    3dup quadratic prime? [ 1+ (consecutive-primes) ] [ 2nip ] if ;
+    3dup quadratic prime? [ 1 + (consecutive-primes) ] [ 2nip ] if ;
 
 : consecutive-primes ( a b -- m )
     swap 0 (consecutive-primes) ;
index 2a75336a0d4c3c9e9ac8b45cea2d2f53a9217648..b689df50bbd9e2d1c2979c3bd534885fcb9e867f 100644 (file)
@@ -38,7 +38,7 @@ IN: project-euler.030
 PRIVATE>
 
 : euler030 ( -- answer )
-    325537 [0,b) [ dup sum-fifth-powers = ] filter sum 1- ;
+    325537 [0,b) [ dup sum-fifth-powers = ] filter sum 1 - ;
 
 ! [ euler030 ] 100 ave-time
 ! 1700 ms ave run time - 64.84 SD (100 trials)
index 378461842312e15d9f4815690281e5abc03e6c8a..7d98de62b1bb26a7825e75ff71a91d79cae19f29 100755 (executable)
@@ -39,13 +39,13 @@ IN: project-euler.035
 : (circular?) ( seq n -- ? )
     dup 0 > [
         2dup rotate 10 digits>integer
-        prime? [ 1- (circular?) ] [ 2drop f ] if
+        prime? [ 1 - (circular?) ] [ 2drop f ] if
     ] [
         2drop t
     ] if ;
 
 : circular? ( seq -- ? )
-    dup length 1- (circular?) ;
+    dup length 1 - (circular?) ;
 
 PRIVATE>
 
index 3c6e2eac0275d365a452b4b816344c4f2b841984..dd700510824ab3afd782d663a73accaf6e116a10 100755 (executable)
@@ -39,7 +39,7 @@ IN: project-euler.038
     pick length 8 > [
         2drop 10 digits>integer
     ] [
-        [ * number>digits over push-all ] 2keep 1+ (concat-product)
+        [ * number>digits over push-all ] 2keep 1 + (concat-product)
     ] if ;
 
 : concat-product ( n -- m )
index dee3f9804c15dde9c4ebd4d579c82e513297b71d..1ad163d5070293ac853692077250587c14eac831 100755 (executable)
@@ -37,8 +37,8 @@ SYMBOL: p-count
     p-count get length ;
 
 : adjust-p-count ( n -- )
-    max-p 1- over <range> p-count get
-    [ [ 1+ ] change-nth ] curry each ;
+    max-p 1 - over <range> p-count get
+    [ [ 1 + ] change-nth ] curry each ;
 
 : (count-perimeters) ( seq -- )
     dup sum max-p < [
index 86fb34629e03ba974b1ff85eb7eb975638d86306..a60714357ea2578dc36f4b460ebfda2cfcfb9b3a 100755 (executable)
@@ -28,7 +28,7 @@ IN: project-euler.040
 
 : (concat-upto) ( n limit str -- str )
     2dup length > [
-        pick number>string over push-all rot 1+ -rot (concat-upto)
+        pick number>string over push-all rot 1 + -rot (concat-upto)
     ] [
         2nip
     ] if ;
@@ -37,7 +37,7 @@ IN: project-euler.040
     SBUF" " clone 1 -rot (concat-upto) ;
 
 : nth-integer ( n str -- m )
-    [ 1- ] dip nth 1string string>number ;
+    [ 1 - ] dip nth 1string string>number ;
 
 PRIVATE>
 
index 8c74cc9b312a0ee67e23d2714f0e59b7cb850a34..e531ba848f303b5b66cfbea2ed09f7e549d380c6 100644 (file)
@@ -35,7 +35,7 @@ IN: project-euler.042
 
 : (triangle-upto) ( limit n -- )
     2dup nth-triangle > [
-        dup nth-triangle , 1+ (triangle-upto)
+        dup nth-triangle , 1 + (triangle-upto)
     ] [
         2drop
     ] if ;
@@ -61,7 +61,7 @@ PRIVATE>
 <PRIVATE
 
 : triangle? ( n -- ? )
-    8 * 1+ sqrt 1- 2 / 1 mod zero? ;
+    8 * 1 + sqrt 1 - 2 / 1 mod zero? ;
 
 PRIVATE>
 
index 75241499e11fc90387fd3944d4ec2c3b68f33fd4..bea7313abd214ede4d5c55c6761f8d97464620f6 100644 (file)
@@ -36,7 +36,7 @@ IN: project-euler.043
 <PRIVATE
 
 : subseq-divisible? ( n index seq -- ? )
-    [ 1- dup 3 + ] dip subseq 10 digits>integer swap divisor? ;
+    [ 1 - dup 3 + ] dip subseq 10 digits>integer swap divisor? ;
 
 : interesting? ( seq -- ? )
     {
index 8fc979e8bcf3257627b4d07723c69be91aa24afd..4c2306c480cf1e59958d26aaf03818d8af077103 100644 (file)
@@ -29,7 +29,7 @@ IN: project-euler.044
 <PRIVATE
 
 : nth-pentagonal ( n -- seq )
-    dup 3 * 1- * 2 / ;
+    dup 3 * 1 - * 2 / ;
 
 : sum-and-diff? ( m n -- ? )
     [ + ] [ - ] 2bi [ pentagonal? ] bi@ and ;
index 939b8416bb3b9083f0c7e5509d82aba37c02fb0e..8b0db1a32e4584c2b045ddc2505a0622e79a85fa 100644 (file)
@@ -28,7 +28,7 @@ IN: project-euler.045
 <PRIVATE
 
 : nth-hexagonal ( n -- m )
-    dup 2 * 1- * ;
+    dup 2 * 1 - * ;
 
 DEFER: next-solution
 
@@ -36,7 +36,7 @@ DEFER: next-solution
     dup pentagonal? [ nip ] [ drop next-solution ] if ;
 
 : next-solution ( n -- m )
-    1+ dup nth-hexagonal (next-solution) ;
+    1 + dup nth-hexagonal (next-solution) ;
 
 PRIVATE>
 
index 0aa9eafe58017297ca159ffff4a694490c7ec8db..13e39c815cecce611d3583f73864d79a65ee1d2f 100755 (executable)
@@ -37,7 +37,7 @@ IN: project-euler.046
     dup perfect-squares [ 2 * - ] with map [ prime? ] any? ;
 
 : next-odd-composite ( n -- m )
-    dup odd? [ 2 + ] [ 1+ ] if dup prime? [ next-odd-composite ] when ;
+    dup odd? [ 2 + ] [ 1 + ] if dup prime? [ next-odd-composite ] when ;
 
 : disprove-conjecture ( n -- m )
     dup fits-conjecture? [ next-odd-composite disprove-conjecture ] when ;
index e251045cd4d324970f692564e36237ba4cd031e4..e7b585bf0d5b030edf1216c6c9fd49fc66178e5c 100644 (file)
@@ -36,8 +36,8 @@ IN: project-euler.047
         swap - nip
     ] [
         dup prime? [ [ drop 0 ] 2dip ] [
-            2dup unique-factors length = [ [ 1+ ] 2dip ] [ [ drop 0 ] 2dip ] if
-        ] if 1+ (consecutive)
+            2dup unique-factors length = [ [ 1 + ] 2dip ] [ [ drop 0 ] 2dip ] if
+        ] if 1 + (consecutive)
     ] if ;
 
 : consecutive ( goal test -- n )
@@ -69,10 +69,10 @@ SYMBOL: sieve
     sieve get nth 0 = ;
 
 : multiples ( n -- seq )
-    sieve get length 1- over <range> ;
+    sieve get length 1 - over <range> ;
 
 : increment-counts ( n -- )
-     multiples [ sieve get [ 1+ ] change-nth ] each ;
+     multiples [ sieve get [ 1 + ] change-nth ] each ;
 
 : prime-tau-upto ( limit -- seq )
     dup initialize-sieve 2 swap [a,b) [
index 640a3a68f69efe0549e752388b9dc10bf259e493..fde3fa6026af4a0adbfad6d9e50c53025d9b69e0 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions math.ranges project-euler.common sequences ;
+USING: kernel math math.functions math.ranges
+project-euler.common sequences ;
 IN: project-euler.048
 
 ! http://projecteuler.net/index.php?section=problems&id=48
@@ -17,7 +18,7 @@ IN: project-euler.048
 ! --------
 
 : euler048 ( -- answer )
-    1000 [1,b] [ dup ^ ] sigma 10 10 ^ mod ;
+    1000 [1,b] [ dup ^ ] sigma 10 10^ mod ;
 
 ! [ euler048 ] 100 ave-time
 ! 276 ms run / 1 ms GC ave time - 100 trials
index 9ecf942ef669a88ee1a0b073cbf0f24e121edd85..8b6f635ee4bb5c932c65ae2a4fde0b7a70b47390 100644 (file)
@@ -27,7 +27,7 @@ IN: project-euler.049
 
 : count-digits ( n -- byte-array )
     10 <byte-array> [
-        '[ 10 /mod _ [ 1+ ] change-nth dup 0 > ] loop drop
+        '[ 10 /mod _ [ 1 + ] change-nth dup 0 > ] loop drop
     ] keep ;
 
 HINTS: count-digits fixnum ;
index 0c5b288b658c0424304553755b1d68b9a5b2fce1..6176ac81d2f3765db1376916b1eb5478e8324737 100644 (file)
@@ -66,7 +66,7 @@ IN: project-euler.050
     2dup [ first ] bi@ > [ drop ] [ nip ] if ;
 
 : continue? ( pair seq -- ? )
-    [ first ] [ length 1- ] bi* < ;
+    [ first ] [ length 1 - ] bi* < ;
 
 : (find-longest) ( best seq limit -- best )
     [ longest-prime longest ] 2keep 2over continue? [
index c25b1adcc073c3c7e2cdbd100af456307bc58bc9..037cc87288420e13ab0823aaaef63ba22287663d 100644 (file)
@@ -24,7 +24,7 @@ IN: project-euler.052
 <PRIVATE
 
 : map-nx ( n x -- seq )
-    [ 1+ * ] with map ; inline
+    [ 1 + * ] with map ; inline
 
 : all-same-digits? ( seq -- ? )
     [ number>digits natural-sort ] map all-equal? ;
@@ -35,9 +35,9 @@ IN: project-euler.052
 : next-all-same ( x n -- n )
     dup candidate? [
         2dup swap map-nx all-same-digits?
-        [ nip ] [ 1+ next-all-same ] if
+        [ nip ] [ 1 + next-all-same ] if
     ] [
-        1+ next-all-same
+        1 + next-all-same
     ] if ;
 
 PRIVATE>
index 133175f2a87d9328891787e2c3509d901c848f15..6edf2ad22a47ea80169fa4ca7108acd430247b2c 100644 (file)
@@ -43,13 +43,13 @@ CONSTANT: PERCENT_PRIME 0.1
 !    (n-2)² + 4(n-1) = odd squares, no need to calculate
 
 : prime-corners ( n -- m )
-    3 [1,b] swap '[ _ [ 1- * ] keep 2 - sq + prime? ] count ;
+    3 [1,b] swap '[ _ [ 1 - * ] keep 2 - sq + prime? ] count ;
 
 : total-corners ( n -- m )
-    1- 2 * ; foldable
+    1 - 2 * ; foldable
 
 : ratio-below? ( count length -- ? )
-    total-corners 1+ / PERCENT_PRIME < ;
+    total-corners 1 + / PERCENT_PRIME < ;
 
 : next-layer ( count length -- count' length' )
     2 + [ prime-corners + ] keep ;
index 3a59d665224ba24c13d67a1a6f9169bd6f01b68c..5094dcd674df0fd1f2544c6a59f95a38b9f508be 100644 (file)
@@ -70,7 +70,7 @@ PRIVATE>
     } cond product ;
 
 : primorial-upto ( limit -- m )
-    1 swap '[ dup primorial _ <= ] [ 1+ dup primorial ] produce
+    1 swap '[ dup primorial _ <= ] [ 1 + dup primorial ] produce
     nip penultimate ;
 
 PRIVATE>
index 5f54d8508e89683d64e352b1fdab0b8034877c8f..7285078bcf0cb19c481e1f92eeeaca978479526e 100755 (executable)
@@ -50,8 +50,8 @@ SYMBOL: p-count
     p-count get length ;
 
 : adjust-p-count ( n -- )
-    max-p 1- over <range> p-count get
-    [ [ 1+ ] change-nth ] curry each ;
+    max-p 1 - over <range> p-count get
+    [ [ 1 + ] change-nth ] curry each ;
 
 : (count-perimeters) ( seq -- )
     dup sum max-p < [
index e6ed9035d2b72e1fd702003551d77b247ff7718d..8615a272ae1cfd7e3bd042d8ea95aeb15a711675 100644 (file)
@@ -35,7 +35,7 @@ IN: project-euler.076
     over zero? [
         3drop
     ] [
-        [ [ 1-  2array ] dip at     ]
+        [ [ 1 -  2array ] dip at     ]
         [ [ use 2array ] dip at +   ]
         [ [     2array ] dip set-at ] 3tri
     ] if ;
@@ -46,7 +46,7 @@ IN: project-euler.076
 : (euler076) ( n -- m )
     dup init
     [ [ ways ] curry each-subproblem ]
-    [ [ dup 2array ] dip at 1- ] 2bi ;
+    [ [ dup 2array ] dip at 1 - ] 2bi ;
 
 PRIVATE>
 
index 4901eae3428af4eb4f058a563b862d90a2d4a1b5..9f22460b3cb69cf34eb392e53490f9e2a033ece9 100644 (file)
@@ -38,7 +38,7 @@ IN: project-euler.092
     567 [1,b] [ chain-ending ] map ;
 
 : fast-chain-ending ( seq n -- m )
-    dup 567 > [ next-link ] when 1- swap nth ;
+    dup 567 > [ next-link ] when 1 - swap nth ;
 
 PRIVATE>
 
index a8895c215a0113e8c700825ba0ca7363fc6e5fcb..35c3629035d1593753f6edf349d63f9bf284d733 100644 (file)
@@ -23,7 +23,7 @@ IN: project-euler.097
 ! --------
 
 : euler097 ( -- answer )
-     2 7830457 10 10 ^ ^mod 28433 * 10 10 ^ mod 1+ ;
+     2 7830457 10 10 ^ ^mod 28433 * 10 10 ^ mod 1 + ;
 
 ! [ euler097 ] 100 ave-time
 ! 0 ms ave run timen - 0.22 SD (100 trials)
index 30bf52bebbf56867f719417d4965e4bdbbc99baf..36fe7783fe398384853c4c7d5183929eb89c3484 100644 (file)
@@ -39,7 +39,7 @@ IN: project-euler.099
     flip first2 swap [ log ] map v* ;
 
 : solve ( seq -- index )
-    simplify [ supremum ] keep index 1+ ;
+    simplify [ supremum ] keep index 1 + ;
 
 PRIVATE>
 
index 6f05eb7120846adb2a05fdcb1ad2ab95aa018bf5..72584d833ec842bc4eca1d5e7ea344ba224e2981 100644 (file)
@@ -25,7 +25,7 @@ IN: project-euler.100
 
 : euler100 ( -- answer )
     1 1
-    [ dup dup 1- * 2 * 10 24 ^ <= ]
+    [ dup dup 1 - * 2 * 10 24 ^ <= ]
     [ tuck 6 * swap - 2 - ] while nip ;
 
 ! TODO: solution needs generalization
index 2766322323c6e8573f9698436371515a3baf9675..43eb30c9f691490721c17c3bf37004d4c69b1c29 100644 (file)
@@ -38,13 +38,13 @@ IN: project-euler.116
 <PRIVATE
 
 : nth* ( n seq -- elt/0 )
-    [ length swap - 1- ] keep ?nth 0 or ;
+    [ length swap - 1 - ] keep ?nth 0 or ;
 
 : next ( colortile seq -- )
      [ nth* ] [ last + ] [ push ] tri ;
 
 : ways ( length colortile -- permutations )
-    V{ 1 } clone [ [ next ] 2curry times ] keep last 1- ;
+    V{ 1 } clone [ [ next ] 2curry times ] keep last 1 - ;
 
 : (euler116) ( length -- permutations )
     3 [1,b] [ ways ] with sigma ;
index 582e103e56538a67579b1e680b6cef9ea2b0ec28..a75e65218350af7a051c881d383ea9bbfbb66dc7 100644 (file)
@@ -32,13 +32,13 @@ IN: project-euler.148
 <PRIVATE
 
 : sum-1toN ( n -- sum )
-    dup 1+ * 2/ ; inline
+    dup 1 + * 2/ ; inline
 
 : >base7 ( x -- y )
     [ dup 0 > ] [ 7 /mod ] produce nip ;
 
 : (use-digit) ( prev x index -- next )
-    [ [ 1+ * ] [ sum-1toN 7 sum-1toN ] bi ] dip ^ * + ;
+    [ [ 1 + * ] [ sum-1toN 7 sum-1toN ] bi ] dip ^ * + ;
 
 : (euler148) ( x -- y )
     >base7 0 [ (use-digit) ] reduce-index ;
index eeb4b0c315eb82420b8db813dd3c1d1ddacf650b..a54b7d1db0faa147fd98c6b2a82ba21efaa163b8 100644 (file)
@@ -56,10 +56,10 @@ IN: project-euler.150
 :: (euler150) ( m -- n )
     [let | table [ sums-triangle ] |
         m [| x |
-            x 1+ [| y |
+            x 1 + [| y |
                 m x - [0,b) [| z |
                     x z + table nth-unsafe
-                    [ y z + 1+ swap nth-unsafe ]
+                    [ y z + 1 + swap nth-unsafe ]
                     [ y        swap nth-unsafe ] bi -
                 ] map partial-sum-infimum
             ] map-infimum
diff --git a/extra/project-euler/151/151-tests.factor b/extra/project-euler/151/151-tests.factor
new file mode 100644 (file)
index 0000000..beea8e3
--- /dev/null
@@ -0,0 +1,4 @@
+USING: project-euler.151 tools.test ;
+IN: project-euler.151.tests
+
+[ 12138569781349/26138246400000 ] [ euler151 ] unit-test
index 66c5a6301edad0832b9f3e56a77db20bbc73d1e1..ccdb76d80e05ca679f5b464c27b6adf5bb9fd396 100644 (file)
@@ -39,11 +39,11 @@ SYMBOL: table
 
 : (pick-sheet) ( seq i -- newseq )
     [
-        <=> sgn
+        <=>
         {
-            { -1 [ ] }
-            {  0 [ 1- ] }
-            {  1 [ 1+ ] }
+            { +lt+ [ ] }
+            { +eq+ [ 1 - ] }
+            { +gt+ [ 1 + ] }
         } case
     ] curry map-index ;
 
@@ -59,9 +59,9 @@ DEFER: (euler151)
 : (euler151) ( x -- y )
     table get [ {
         { { 0 0 0 1 } [ 0 ] }
-        { { 0 0 1 0 } [ { 0 0 0 1 } (euler151) 1+ ] }
-        { { 0 1 0 0 } [ { 0 0 1 1 } (euler151) 1+ ] }
-        { { 1 0 0 0 } [ { 0 1 1 1 } (euler151) 1+ ] }
+        { { 0 0 1 0 } [ { 0 0 0 1 } (euler151) 1 + ] }
+        { { 0 1 0 0 } [ { 0 0 1 1 } (euler151) 1 + ] }
+        { { 1 0 0 0 } [ { 0 1 1 1 } (euler151) 1 + ] }
         [ [ dup length [ pick-sheet ] with map sum ] [ sum ] bi / ]
      } case ] cache ;
 
@@ -71,8 +71,6 @@ DEFER: (euler151)
         { 1 1 1 1 } (euler151)
     ] with-scope ;
 
-! TODO: doesn't work currently, problem in area of 'with map' in (euler151)
-
 ! [ euler151 ] 100 ave-time
 ! ? ms run time - 100 trials
 
index 5f0b853f0db998207cbe1d9787bdd85fc4cc7bef..efd1c8ee60494ccb678dd5e03ddbc2b82853d38a 100644 (file)
@@ -30,7 +30,7 @@ MEMO: fn ( n -- x )
     {
         { [ dup 2 < ]  [ drop 1 ] }
         { [ dup odd? ] [ 2/ fn ] }
-        [ 2/ [ fn ] [ 1- fn ] bi + ]
+        [ 2/ [ fn ] [ 1 - fn ] bi + ]
     } cond ;
 
 : euler169 ( -- result )
index c99d670808a905f51d6b908a755dd440859b85fd..3473d9327c8dfd4180506326f72ced70ad69f2de 100644 (file)
@@ -42,7 +42,7 @@ IN: project-euler.175
 
 : compute ( vec ratio -- )
     {
-        { [ dup integer? ] [ 1- 0 add-bits ] }
+        { [ dup integer? ] [ 1 - 0 add-bits ] }
         { [ dup 1 < ] [ 1 over - / dupd compute 1 1 add-bits ] }
         [ [ 1 mod compute ] 2keep >integer 0 add-bits ]
     } cond ;
index a9e62ec3a90033659b83aff90487b0b1afc466a0..ed4f03dda1aabc8a3a13e5004234bc20260b1b77 100644 (file)
@@ -58,7 +58,7 @@ IN: project-euler.186
         pick [ next ] [ next ] bi
         [ = ] [
             pick equate
-            [ 1+ ] dip
+            [ 1 + ] dip
         ] 2unless? (p186)
     ] [
         drop nip
index ec52af041524405c6a4c95eaff8b9a1b021d9185..19ff2c253ca6f5520454d3c523507d116a981950 100644 (file)
@@ -43,7 +43,7 @@ IN: project-euler.190
 PRIVATE>
 
 :: P_m ( m -- P_m )
-    m [1,b] [| i | 2 i * m 1+ / i ^ ] PI ;
+    m [1,b] [| i | 2 i * m 1 + / i ^ ] PI ;
 
 : euler190 ( -- answer )
     2 15 [a,b] [ P_m truncate ] sigma ;
index 2f165f654889b1106d473334feddb20098738a75..806098b865ebea4754e88b3c9be2226377870306 100644 (file)
@@ -45,7 +45,7 @@ IN: project-euler.203
     [ 0 prefix ] [ 0 suffix ] bi [ + ] 2map ;
 
 : generate ( n -- seq )
-    1- { 1 } [ (generate) ] iterate concat prune ;
+    1 - { 1 } [ (generate) ] iterate concat prune ;
 
 : squarefree ( n -- ? )
     factors all-unique? ;
index 30c42cc4be2b5855a56d90556b903f1497db8d58..1006b7a4cf25de71ce0ca2d96a8af19b4fbd32e1 100644 (file)
@@ -72,14 +72,14 @@ M: end h2 dup failure? [ <failure> <block> ] unless ;
 
 : first-row ( n -- t )
     [ <failure> <success> <failure> ] dip
-    1- [| a b c | b c <block> a b ] times 2drop ;
+    1 - [| a b c | b c <block> a b ] times 2drop ;
 
 GENERIC: total ( t -- n )
 M: block total [ total ] dup choice + ;
 M: end   total ways>> ;
 
 : solve ( width height -- ways )
-    [ first-row ] dip 1- [ next-row ] times total ;
+    [ first-row ] dip 1 - [ next-row ] times total ;
 
 PRIVATE>
 
index a7762836f19bbe23b00d1e53607d70d2bac89b44..dc521d4d70f0bd2520877b2f3c684439ace125f0 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: continuations fry io kernel make math math.functions math.parser
-    math.statistics memory tools.time ;
+USING: continuations fry io kernel make math math.functions
+math.parser math.statistics memory tools.time ;
 IN: project-euler.ave-time
 
 : nth-place ( x n -- y )
-    10 swap ^ [ * round >integer ] keep /f ;
+    10^ [ * round >integer ] keep /f ;
 
 : collect-benchmarks ( quot n -- seq )
     [
@@ -14,7 +14,7 @@ IN: project-euler.ave-time
             '[ _ gc benchmark 1000 / , ] tuck
             '[ _ _ with-datastack drop ]
         ]
-        [ 1- ] tri* swap times call
+        [ 1 - ] tri* swap times call
     ] { } make ; inline
 
 : ave-time ( quot n -- )
index 497fc31de7fc41cd89725daee7ff720c28147f6c..4119f8205cc2adf4e736abdd7dd4d7ab42be6615 100644 (file)
@@ -39,7 +39,7 @@ IN: project-euler.common
 <PRIVATE
 
 : max-children ( seq -- seq )
-    [ dup length 1- [ nth-pair max , ] with each ] { } make ;
+    [ dup length 1 - [ nth-pair max , ] with each ] { } make ;
 
 ! Propagate one row into the upper one
 : propagate ( bottom top -- newtop )
@@ -57,14 +57,11 @@ IN: project-euler.common
 PRIVATE>
 
 : alpha-value ( str -- n )
-    >lower [ CHAR: a - 1+ ] sigma ;
+    >lower [ CHAR: a - 1 + ] sigma ;
 
 : cartesian-product ( seq1 seq2 -- seq1xseq2 )
     [ [ 2array ] with map ] curry map concat ;
 
-: log10 ( m -- n )
-    log 10 log / ;
-
 : mediant ( a/c b/d -- (a+b)/(c+d) )
     2>fraction [ + ] 2bi@ / ;
 
@@ -79,13 +76,13 @@ PRIVATE>
     [ dup 0 = not ] [ 10 /mod ] produce reverse nip ;
 
 : number-length ( n -- m )
-    log10 floor 1+ >integer ;
+    log10 floor 1 + >integer ;
 
 : nth-prime ( n -- n )
-    1- lprimes lnth ;
+    1 - lprimes lnth ;
 
 : nth-triangle ( n -- n )
-    dup 1+ * 2 / ;
+    dup 1 + * 2 / ;
 
 : palindrome? ( n -- ? )
     number>string dup reverse = ;
@@ -94,7 +91,7 @@ PRIVATE>
     number>string natural-sort >string "123456789" = ;
 
 : pentagonal? ( n -- ? )
-    dup 0 > [ 24 * 1+ sqrt 1+ 6 / 1 mod zero? ] [ drop f ] if ;
+    dup 0 > [ 24 * 1 + sqrt 1 + 6 / 1 mod zero? ] [ drop f ] if ;
 
 : penultimate ( seq -- elt )
     dup length 2 - swap nth ;
@@ -122,11 +119,11 @@ PRIVATE>
 
 ! The divisor function, counts the number of divisors
 : tau ( m -- n )
-    group-factors flip second 1 [ 1+ * ] reduce ;
+    group-factors flip second 1 [ 1 + * ] reduce ;
 
 ! Optimized brute-force, is often faster than prime factorization
 : tau* ( m -- n )
-    factor-2s dup [ 1+ ]
+    factor-2s dup [ 1 + ]
     [ perfect-square? -1 0 ? ]
     [ dup sqrt >fixnum [1,b] ] tri* [
         dupd divisor? [ [ 2 + ] dip ] when
diff --git a/extra/recipes/authors.txt b/extra/recipes/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/recipes/icons/back.tiff b/extra/recipes/icons/back.tiff
new file mode 100644 (file)
index 0000000..27b8112
Binary files /dev/null and b/extra/recipes/icons/back.tiff differ
diff --git a/extra/recipes/icons/hate.tiff b/extra/recipes/icons/hate.tiff
new file mode 100644 (file)
index 0000000..d7d5f8e
Binary files /dev/null and b/extra/recipes/icons/hate.tiff differ
diff --git a/extra/recipes/icons/love.tiff b/extra/recipes/icons/love.tiff
new file mode 100644 (file)
index 0000000..ae2fa7b
Binary files /dev/null and b/extra/recipes/icons/love.tiff differ
diff --git a/extra/recipes/icons/more.tiff b/extra/recipes/icons/more.tiff
new file mode 100644 (file)
index 0000000..b4ec27b
Binary files /dev/null and b/extra/recipes/icons/more.tiff differ
diff --git a/extra/recipes/icons/submit.tiff b/extra/recipes/icons/submit.tiff
new file mode 100644 (file)
index 0000000..7c98267
Binary files /dev/null and b/extra/recipes/icons/submit.tiff differ
diff --git a/extra/recipes/recipes.factor b/extra/recipes/recipes.factor
new file mode 100644 (file)
index 0000000..d546859
--- /dev/null
@@ -0,0 +1,61 @@
+USING: accessors arrays colors.constants combinators
+db.sqlite db.tuples db.types kernel locals math
+monads persistency sequences sequences.extras ui ui.gadgets.controls
+ui.gadgets.layout models.combinators ui.gadgets.labels
+ui.gadgets.scrollers ui.pens.solid io.files.temp ;
+FROM: sets => prune ;
+IN: recipes
+
+STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ;
+: <recipe> ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
+"recipes.db" temp-file <sqlite-db> recipe define-db
+: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
+    "votes" >>order 30 >>limit swap >>offset get-tuples ;
+: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 short head-slice ;
+
+: interface ( -- book ) [ 
+     [
+        [ $ TOOLBAR $ ] <hbox> COLOR: AliceBlue <solid> >>interior ,
+        [ "Genres:" <label> , <spacer> $ ALL $ $ GENRES $ ] <hbox>
+            { 5 0 } >>gap COLOR: gray <solid> >>interior ,
+        $ RECIPES $
+     ] <vbox> ,
+     [
+        [ "Title:" <label> , $ TITLE $ "Genre:" <label> , $ GENRE $ ] <hbox> ,
+        $ BODY $
+        $ BUTTON $
+     ] <vbox> ,
+  ] <book*> { 350 245 } >>pref-dim ;
+  
+:: recipe-browser ( -- ) [ [
+    interface
+      <table*> :> tbl
+      "okay" <model-border-btn> BUTTON -> :> ok
+      IMG-MODEL-BTN: submit [ store-tuple ] >>value TOOLBAR -> :> submit
+      IMG-MODEL-BTN: love 1 >>value TOOLBAR ->
+      IMG-MODEL-BTN: hate -1 >>value -> 2array merge :> votes
+      IMG-MODEL-BTN: back -> [ -30 ] <$
+      IMG-MODEL-BTN: more -> [ 30 ] <$ 2array merge :> viewed
+      <spacer> <model-field*> ->% 1 :> search
+      submit ok [ [ drop ] ] <$ 2array merge [ drop ] >>value :> quot
+      viewed 0 [ + ] fold search ok t <basic> "all" <model-btn> ALL ->
+      tbl selection>> votes [ [ + ] curry change-votes modify-tuple ] 2$>
+        4array merge
+        [ drop [ f ] [ "%" dup surround <pattern> ] if-empty top-recipes ] 3fmap :> ups
+      ups [ top-genres [ <model-btn> GENRES -> ] map merge ] bind*
+        [ text>> T{ recipe } swap >>genre get-tuples ] fmap
+      tbl swap ups 2merge >>model
+        [ [ title>> ] [ genre>> ] bi 2array ] >>quot
+        { "Title" "Genre" } >>column-titles dup <scroller> RECIPES ,% 1 actions>>
+      submit [ "" dup dup <recipe> ] <$ 2array merge
+        { [ [ title>> ] fmap <model-field> TITLE ->% .5 ]
+          [ [ genre>> ] fmap <model-field> GENRE ->% .5 ]
+          [ [ txt>> ] fmap <model-editor> BODY ->% 1 ]
+        } cleave
+        [ <recipe> ] 3fmap
+      [ [ 1 ] <$ ]
+      [ quot ok updates #1 [ call( recipe -- ) 0 ] 2fmap ] bi
+      2merge 0 <basic> switch-models >>model
+   ] with-interface "recipes" open-window ] with-ui ;
+
+MAIN: recipe-browser
\ No newline at end of file
diff --git a/extra/recipes/summary.txt b/extra/recipes/summary.txt
new file mode 100644 (file)
index 0000000..98b1ece
--- /dev/null
@@ -0,0 +1 @@
+Database backed recipe sharing
\ No newline at end of file
diff --git a/extra/run-desc/run-desc.factor b/extra/run-desc/run-desc.factor
new file mode 100644 (file)
index 0000000..6acf66d
--- /dev/null
@@ -0,0 +1,3 @@
+USING: io io.encodings.utf8 io.launcher kernel sequences ;
+IN: run-desc
+: run-desc ( desc -- result ) utf8 [ contents [ but-last ] [ f ] if* ] with-process-reader ;
index 259fb9f259a10acd306774787839d7b793d315a1..af13e5b86e757c481693c419e827babeb9caf8ed 100644 (file)
@@ -77,47 +77,6 @@ IN: sequence-parser.tests
 [ "cd" ]
 [ "abcd" <sequence-parser> [ "ab" take-sequence drop ] [ "cd" take-sequence ] bi ] unit-test
 
-[ f ]
-[
-    "\"abc\" asdf" <sequence-parser>
-    [ CHAR: \ CHAR: " take-quoted-string drop ] [ "asdf" take-sequence ] bi
-] unit-test
-
-[ "abc\\\"def" ]
-[
-    "\"abc\\\"def\" asdf" <sequence-parser>
-    CHAR: \ CHAR: " take-quoted-string
-] unit-test
-
-[ "asdf" ]
-[
-    "\"abc\" asdf" <sequence-parser>
-    [ CHAR: \ CHAR: " take-quoted-string drop ]
-    [ skip-whitespace "asdf" take-sequence ] bi
-] unit-test
-
-[ f ]
-[
-    "\"abc asdf" <sequence-parser>
-    CHAR: \ CHAR: " take-quoted-string
-] unit-test
-
-[ "\"abc" ]
-[
-    "\"abc asdf" <sequence-parser>
-    [ CHAR: \ CHAR: " take-quoted-string drop ]
-    [ "\"abc" take-sequence ] bi
-] unit-test
-
-[ "c" ]
-[ "c" <sequence-parser> take-token ] unit-test
-
-[ f ]
-[ "" <sequence-parser> take-token ] unit-test
-
-[ "abcd e \\\"f g" ]
-[ "\"abcd e \\\"f g\"" <sequence-parser> CHAR: \ CHAR: " take-token* ] unit-test
-
 [ f ]
 [ "" <sequence-parser> take-rest ] unit-test
 
@@ -140,63 +99,6 @@ IN: sequence-parser.tests
 [ "abcd" ] [ "abcd" <sequence-parser> 4 take-n ] unit-test
 [ "abcd" "efg" ] [ "abcdefg" <sequence-parser> [ 4 take-n ] [ take-rest ] bi ] unit-test
 
-[ "asdfasdf" ] [
-    "/*asdfasdf*/" <sequence-parser> take-c-comment 
-] unit-test
-
-[ "k" ] [
-    "/*asdfasdf*/k" <sequence-parser> [ take-c-comment drop ] [ take-rest ] bi
-] unit-test
-
-[ "omg" ] [
-    "//asdfasdf\nomg" <sequence-parser>
-    [ take-c++-comment drop ] [ take-rest ] bi
-] unit-test
-
-[ "omg" ] [
-    "omg" <sequence-parser>
-    [ take-c++-comment drop ] [ take-rest ] bi
-] unit-test
-
-[ "/*asdfasdf" ] [
-    "/*asdfasdf" <sequence-parser> [ take-c-comment drop ] [ take-rest ] bi
-] unit-test
-
-[ "asdf" "eoieoei" ] [
-    "//asdf\neoieoei" <sequence-parser>
-    [ take-c++-comment ] [ take-rest ] bi
-] unit-test
-
-[ f "33asdf" ]
-[ "33asdf" <sequence-parser> [ take-c-identifier ] [ take-rest ] bi ] unit-test
-
-[ "asdf" ]
-[ "asdf" <sequence-parser> take-c-identifier ] unit-test
-
-[ "_asdf" ]
-[ "_asdf" <sequence-parser> take-c-identifier ] unit-test
-
-[ "_asdf400" ]
-[ "_asdf400" <sequence-parser> take-c-identifier ] unit-test
-
-[ "123" ]
-[ "123jjj" <sequence-parser> take-c-integer ] unit-test
-
-[ "123uLL" ]
-[ "123uLL" <sequence-parser> take-c-integer ] unit-test
-
-[ "123ull" ]
-[ "123ull" <sequence-parser> take-c-integer ] unit-test
-
-[ "123u" ]
-[ "123u" <sequence-parser> take-c-integer ] unit-test
-
-[ 36 ]
-[
-    "    //jofiejoe\n    //eoieow\n/*asdf*/\n      "
-    <sequence-parser> skip-whitespace/comments n>>
-] unit-test
-
 [ f ]
 [ "\n" <sequence-parser> take-integer ] unit-test
 
index e46abe809050a1ad73a3db05c3a81b22d351094e..d14a77057f9bdb75988168b98aff8906da5b6314 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2005, 2009 Daniel Ehrenberg, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces math kernel sequences accessors fry circular
-unicode.case unicode.categories locals combinators.short-circuit
-make combinators io splitting math.parser math.ranges
-generalizations sorting.functor math.order sorting.slots ;
+USING: accessors circular combinators.short-circuit fry io
+kernel locals math math.order sequences sorting.functor
+sorting.slots unicode.categories ;
 IN: sequence-parser
 
 TUPLE: sequence-parser sequence n ;
@@ -89,7 +88,7 @@ TUPLE: sequence-parser sequence n ;
     ] take-until :> found
     growing sequence sequence= [
         found dup length
-        growing length 1- - head
+        growing length 1 - - head
         sequence-parser [ growing length - 1 + ] change-n drop
         ! sequence-parser advance drop
     ] [
@@ -109,42 +108,6 @@ TUPLE: sequence-parser sequence n ;
 : skip-whitespace-eol ( sequence-parser -- sequence-parser )
     [ [ current " \t\r" member? not ] take-until drop ] keep ;
 
-: take-c-comment ( sequence-parser -- seq/f )
-    [
-        dup "/*" take-sequence [
-            "*/" take-until-sequence*
-        ] [
-            drop f
-        ] if
-    ] with-sequence-parser ;
-
-: take-c++-comment ( sequence-parser -- seq/f )
-    [
-        dup "//" take-sequence [
-            [
-                [
-                    { [ current CHAR: \n = ] [ sequence-parse-end? ] } 1||
-                ] take-until
-            ] [
-                advance drop
-            ] bi
-        ] [
-            drop f
-        ] if
-    ] with-sequence-parser ;
-
-: skip-whitespace/comments ( sequence-parser -- sequence-parser )
-    skip-whitespace-eol
-    {
-        { [ dup take-c-comment ] [ skip-whitespace/comments ] }
-        { [ dup take-c++-comment ] [ skip-whitespace/comments ] }
-        [ ]
-    } cond ;
-
-: take-define-identifier ( sequence-parser -- string )
-    skip-whitespace/comments
-    [ current { [ blank? ] [ CHAR: ( = ] } 1|| ] take-until ;
-
 : take-rest-slice ( sequence-parser -- sequence/f )
     [ sequence>> ] [ n>> ] bi
     2dup [ length ] dip < [ 2drop f ] [ tail-slice ] if ; inline
@@ -158,35 +121,6 @@ TUPLE: sequence-parser sequence n ;
 : parse-sequence ( sequence quot -- )
     [ <sequence-parser> ] dip call ; inline
 
-:: take-quoted-string ( sequence-parser escape-char quote-char -- string )
-    sequence-parser n>> :> start-n
-    sequence-parser advance
-    [
-        {
-            [ { [ previous escape-char = ] [ current quote-char = ] } 1&& ]
-            [ current quote-char = not ]
-        } 1||
-    ] take-while :> string
-    sequence-parser current quote-char = [
-        sequence-parser advance* string
-    ] [
-        start-n sequence-parser (>>n) f
-    ] if ;
-
-: (take-token) ( sequence-parser -- string )
-    skip-whitespace [ current { [ blank? ] [ f = ] } 1|| ] take-until ;
-
-:: take-token* ( sequence-parser escape-char quote-char -- string/f )
-    sequence-parser skip-whitespace
-    dup current {
-        { quote-char [ escape-char quote-char take-quoted-string ] }
-        { f [ drop f ] }
-        [ drop (take-token) ]
-    } case ;
-
-: take-token ( sequence-parser -- string/f )
-    CHAR: \ CHAR: " take-token* ;
-
 : take-integer ( sequence-parser -- n/f )
     [ current digit? ] take-while ;
 
@@ -198,27 +132,6 @@ TUPLE: sequence-parser sequence n ;
         sequence-parser [ n + ] change-n drop
     ] if ;
 
-: c-identifier-begin? ( ch -- ? )
-    CHAR: a CHAR: z [a,b]
-    CHAR: A CHAR: Z [a,b]
-    { CHAR: _ } 3append member? ;
-
-: c-identifier-ch? ( ch -- ? )
-    CHAR: a CHAR: z [a,b]
-    CHAR: A CHAR: Z [a,b]
-    CHAR: 0 CHAR: 9 [a,b]
-    { CHAR: _ } 4 nappend member? ;
-
-: (take-c-identifier) ( sequence-parser -- string/f )
-    dup current c-identifier-begin? [
-        [ current c-identifier-ch? ] take-while
-    ] [
-        drop f
-    ] if ;
-
-: take-c-identifier ( sequence-parser -- string/f )
-    [ (take-c-identifier) ] with-sequence-parser ;
-
 << "length" [ length ] define-sorting >>
 
 : sort-tokens ( seq -- seq' )
@@ -228,34 +141,8 @@ TUPLE: sequence-parser sequence n ;
     swap
     '[ _ [ swap take-sequence ] with-sequence-parser ] find nip ;
 
-
 : take-longest ( sequence-parser seq -- seq )
     sort-tokens take-first-matching ;
 
-: take-c-integer ( sequence-parser -- string/f )
-    [
-        dup take-integer [
-            swap
-            { "ull" "uLL" "Ull" "ULL" "ll" "LL" "l" "L" "u" "U" }
-            take-longest [ append ] when*
-        ] [
-            drop f
-        ] if*
-    ] with-sequence-parser ;
-
-CONSTANT: c-punctuators
-    {
-        "[" "]" "(" ")" "{" "}" "." "->"
-        "++" "--" "&" "*" "+" "-" "~" "!"
-        "/" "%" "<<" ">>" "<" ">" "<=" ">=" "==" "!=" "^" "|" "&&" "||"
-        "?" ":" ";" "..."
-        "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" "&=" "^=" "|="
-        "," "#" "##"
-        "<:" ":>" "<%" "%>" "%:" "%:%:"
-    }
-
-: take-c-punctuator ( sequence-parser -- string/f )
-    c-punctuators take-longest ;
-
 : write-full ( sequence-parser -- ) sequence>> write ;
 : write-rest ( sequence-parser -- ) take-rest write ;
diff --git a/extra/sequences/extras/extras.factor b/extra/sequences/extras/extras.factor
new file mode 100644 (file)
index 0000000..5256bea
--- /dev/null
@@ -0,0 +1,21 @@
+USING: arrays kernel locals math sequences ;
+IN: sequences.extras
+: reduce1 ( seq quot -- result ) [ unclip ] dip reduce ; inline
+
+:: reduce-r
+    ( list identity quot: ( obj1 obj2 -- obj ) -- result )
+    list empty?
+    [ identity ]
+    [ list rest identity quot reduce-r list first quot call ] if ;
+    inline recursive
+
+! Quot must have static stack effect, unlike "reduce"
+:: reduce* ( seq id quot -- result ) seq
+    [ id ]
+    [ unclip id swap quot call( prev elt -- next ) quot reduce* ] if-empty ; inline recursive
+
+:: combos ( list1 list2 -- result ) list2 [ [ 2array ] curry list1 swap map ] map concat ;
+: find-all ( seq quot -- elts ) [ [ length iota ] keep ] dip
+    [ dupd call( a -- ? ) [ 2array ] [ 2drop f ] if ] curry 2map [ ] filter ; inline
+
+: insert-sorted ( elt seq -- seq ) 2dup [ < ] with find drop over length or swap insert-nth ;
\ No newline at end of file
index 665d43f0cd00ed646f236778158ec6bf41dbfbcd..9291fad3c080d3cfea1d41dda1273503d3729ecb 100644 (file)
@@ -23,11 +23,11 @@ M: product-sequence length lengths>> product ;
     [ lengths>> ns ] [ nip sequences>> ] 2bi ;
 
 :: (carry-n) ( ns lengths i -- )
-    ns length i 1+ = [
+    ns length i 1 + = [
         i ns nth i lengths nth = [
             0 i ns set-nth
-            i 1+ ns [ 1+ ] change-nth
-            ns lengths i 1+ (carry-n)
+            i 1 + ns [ 1 + ] change-nth
+            ns lengths i 1 + (carry-n)
         ] when
     ] unless ;
 
@@ -35,7 +35,7 @@ M: product-sequence length lengths>> product ;
     0 (carry-n) ;
     
 : product-iter ( ns lengths -- )
-    [ 0 over [ 1+ ] change-nth ] dip carry-ns ;
+    [ 0 over [ 1 + ] change-nth ] dip carry-ns ;
 
 : start-product-iter ( sequence-product -- ns lengths )
     [ [ drop 0 ] map ] [ [ length ] map ] bi ;
@@ -57,7 +57,7 @@ M: product-sequence nth
     0 :> i!
     sequences [ length ] [ * ] map-reduce sequences
     [| result |
-        sequences [ quot call i result set-nth i 1+ i! ] product-each
+        sequences [ quot call i result set-nth i 1 + i! ] product-each
         result
     ] new-like ; inline
 
diff --git a/extra/set-n/set-n.factor b/extra/set-n/set-n.factor
new file mode 100644 (file)
index 0000000..04731b0
--- /dev/null
@@ -0,0 +1,9 @@
+USING: accessors assocs fry generalizations kernel math
+namespaces parser sequences words ;
+IN: set-n
+: get* ( var n -- val ) namestack dup length rot - head assoc-stack ;
+
+: set* ( val var n -- ) 1 + namestack [ length swap - ] keep nth set-at ;
+
+! dynamic lambda
+SYNTAX: :| (:) dup in>> dup length [ spin '[ _ narray _ swap zip _ bind ] ] 2curry dip define-declared ;
\ No newline at end of file
index 29367a2b2bfd8a9382196da075073c38a8fcb571..32ceb3b677cce28f676438adbd24756bc00630c3 100755 (executable)
@@ -90,7 +90,7 @@ TUPLE: slides < book ;
     [ first3 ] dip head 3array ;
 
 : strip-tease ( data -- seq )
-    dup third length 1- [
+    dup third length 1 - [
         2 + (strip-tease)
     ] with map ;
 
index 2eeee306925bb4db811a6466b71ea0b07a9f735a..0c1a5c07d17d21e0073ddfb824ea2a84b309966b 100644 (file)
@@ -123,7 +123,7 @@ M: ast-block compile-ast
     [ lexenv self>> suffix ] dip <lambda> ;
 
 : compile-method-body ( lexenv block -- quot )
-    [ [ (compile-method-body) ] [ arguments>> length 1+ ] bi ] 2keep
+    [ [ (compile-method-body) ] [ arguments>> length 1 + ] bi ] 2keep
     make-return ;
 
 : compile-method ( lexenv ast-method -- )
@@ -154,4 +154,4 @@ M: ast-foreign compile-ast
 
 : compile-smalltalk ( statement -- quot )
     [ empty-lexenv ] dip [ compile-sequence nip 0 ]
-    2keep make-return ;
\ No newline at end of file
+    2keep make-return ;
index 17e91473c3795df9be7dfd2f75f0705b1a1873b4..9d3aa6c65127d81da8138263dfac7d04770777b4 100644 (file)
@@ -52,10 +52,10 @@ fetched-in parsed-html links processed-in fetched-at ;
     [ host>> = ] with partition ;
 
 : add-spidered ( spider spider-result -- )
-    [ [ 1+ ] change-count ] dip
+    [ [ 1 + ] change-count ] dip
     2dup [ spidered>> ] [ dup url>> ] bi* rot set-at
     [ filter-base-links ] 2keep
-    depth>> 1+ swap
+    depth>> 1 + swap
     [ add-nonmatching ]
     [ tuck [ apply-filters ] 2dip add-todo ] 2bi ;
 
diff --git a/extra/str-fry/authors.txt b/extra/str-fry/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/str-fry/str-fry.factor b/extra/str-fry/str-fry.factor
deleted file mode 100644 (file)
index bfe74f3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-USING: combinators effects kernel math sequences splitting
-strings.parser ;
-IN: str-fry
-: str-fry ( str -- quot ) "_" split
-    [ unclip [ [ rot glue ] reduce ] 2curry ]
-    [ length 1 - 1 <effect> [ call-effect ] 2curry ] bi ;
-SYNTAX: I" parse-string rest str-fry over push-all ;
\ No newline at end of file
diff --git a/extra/str-fry/summary.txt b/extra/str-fry/summary.txt
deleted file mode 100644 (file)
index 7755f5a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-String Frying
\ No newline at end of file
index 1554d3df209431765d47ca2f3abbae2e700e3e6d..555f1e632a580b489131907d0b7d5259a597074f 100755 (executable)
@@ -25,7 +25,7 @@ SYMBOL: board
 DEFER: search
 
 : assume ( n x y -- )
-    [ >board ] 2keep [ [ 1+ ] dip search ] 2keep f>board ;
+    [ >board ] 2keep [ [ 1 + ] dip search ] 2keep f>board ;
 
 : attempt ( n x y -- )
     {
@@ -35,7 +35,7 @@ DEFER: search
         [ assume ]
     } cond ;
 
-: solve ( x y -- ) 9 [ 1+ 2over attempt ] each 2drop ;
+: solve ( x y -- ) 9 [ 1 + 2over attempt ] each 2drop ;
 
 : board. ( board -- )
     standard-table-style [
@@ -59,9 +59,9 @@ DEFER: search
 
 : search ( x y -- )
     {
-        { [ over 9 = ] [ [ drop 0 ] dip 1+ search ] }
+        { [ over 9 = ] [ [ drop 0 ] dip 1 + search ] }
         { [ over 0 = over 9 = and ] [ 2drop solution. ] }
-        { [ 2dup board> ] [ [ 1+ ] dip search ] }
+        { [ 2dup board> ] [ [ 1 + ] dip search ] }
         [ solve ]
     } cond ;
 
diff --git a/extra/sudokus/authors.txt b/extra/sudokus/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/sudokus/sudokus.factor b/extra/sudokus/sudokus.factor
new file mode 100644 (file)
index 0000000..9de9a6f
--- /dev/null
@@ -0,0 +1,40 @@
+USING: accessors arrays combinators.short-circuit grouping kernel lists
+lists.lazy locals math math.functions math.parser math.ranges
+models.product monads random sequences sets ui ui.gadgets.controls
+ui.gadgets.layout models.combinators ui.gadgets.alerts vectors fry
+ui.gadgets.labels ;
+IN: sudokus
+
+: row ( index -- row ) 1 + 9 / ceiling ;
+: col ( index -- col ) 9 mod 1 + ;
+: sq ( index -- square ) [ row ] [ col ] bi [ 3 / ceiling ] bi@ 2array ;
+: near ( a pos -- ? ) { [ [ row ] bi@ = ] [ [ col ] bi@ = ] [ [ sq ] bi@ = ] } 2|| ;
+: nth-or-lower ( n seq -- elt ) [ length 1 - 2dup > [ nip ] [ drop ] if ] keep nth ;
+
+:: solutions ( puzzle random? -- solutions )
+    f puzzle random? [ indices [ f ] [ random? swap nth-or-lower ] if-empty ] [ index ] if
+    [ :> pos
+      1 9 [a,b] 80 iota [ pos near ] filter [ puzzle nth ] map prune diff
+      [ 1array puzzle pos cut-slice rest surround ] map >list [ random? solutions ] bind
+    ] [ puzzle list-monad return ] if* ;
+
+: solution ( puzzle random? -- solution ) dupd solutions dup +nil+ = [ drop "Unsolvable" alert* ] [ nip car ] if ;
+: hint ( puzzle -- puzzle' ) [ [ f swap indices random dup ] [ f solution ] bi nth ] keep swapd >vector [ set-nth ] keep ;
+: create ( difficulty -- puzzle ) 81 [ f ] replicate
+    40 random solution [ [ dup length random f spin set-nth ] curry times ] keep ;
+
+: do-sudoku ( -- ) [ [
+        [
+            81 [ "" ] replicate <basic> switch-models [ [ <basic> ] map 9 group [ 3 group ] map 3 group
+               [ [ [ <spacer> [ [ <model-field> ->% 2 [ string>number ] fmap ]
+                    map <spacer> ] map concat ] <hbox> , ] map concat <spacer> ] map concat <product>
+               [ "Difficulty:" <label> , "1" <basic> <model-field> -> [ string>number 1 or 1 + 10 * ] fmap
+               "Generate" <model-border-btn> -> updates [ create ] fmap <spacer>
+               "Hint" <model-border-btn> -> "Solve" <model-border-btn> -> ] <hbox> ,
+               roll [ swap updates ] curry bi@
+               [ [ hint ] fmap ] [ [ f solution ] fmap ] bi* 3array merge [ [ [ number>string ] [ "" ] if* ] map ] fmap
+           ] bind
+        ] with-self , ] <vbox> { 280 220 } >>pref-dim
+    "Sudoku Sleuth" open-window ] with-ui ;
+
+MAIN: do-sudoku
\ No newline at end of file
diff --git a/extra/sudokus/summary.txt b/extra/sudokus/summary.txt
new file mode 100644 (file)
index 0000000..d66e7be
--- /dev/null
@@ -0,0 +1 @@
+graphical sudoku solver
\ No newline at end of file
index 2ed5d21707a84c0f1ec3aadaed21216686e38d06..2d2d38314ab6e2f2ac119dba67a753c9c24f2a93 100644 (file)
@@ -11,7 +11,7 @@ XML-NS: inkscape-name http://www.inkscape.org/namespaces/inkscape
 
 : svg-string>number ( string -- number )
     { { CHAR: E CHAR: e } } substitute "e" split1
-    [ string>number ] [ [ string>number 10 swap ^ ] [ 1 ] if* ] bi* *
+    [ string>number ] [ [ string>number 10^ ] [ 1 ] if* ] bi* *
     >float ;
 
 : degrees ( deg -- rad ) pi * 180.0 / ;
index 5be2dc89e2fbbc96f120901d512f5c58e0c9abaa..3e0cffe71db55aeccd965b842c65547e54e60313 100755 (executable)
@@ -36,7 +36,7 @@ M: winnt available-virtual-mem ( -- n )
     memory-status MEMORYSTATUSEX-ullAvailVirtual ;
 
 : computer-name ( -- string )
-    MAX_COMPUTERNAME_LENGTH 1+
+    MAX_COMPUTERNAME_LENGTH 1 +
     [ <byte-array> dup ] keep <uint>
     GetComputerName win32-error=0/f alien>native-string ;
  
index 42aa7e903a00b27c89761e27d54c32e415181237..4304ba343206ac53c048eba985549e189e79e0c6 100644 (file)
@@ -11,7 +11,7 @@ math.affine-transforms noise ui.gestures combinators.short-circuit
 destructors grid-meshes ;
 IN: terrain
 
-CONSTANT: FOV $[ 2.0 sqrt 1+ ]
+CONSTANT: FOV $[ 2.0 sqrt 1 + ]
 CONSTANT: NEAR-PLANE $[ 1.0 1024.0 / ]
 CONSTANT: FAR-PLANE 2.0
 CONSTANT: PLAYER-START-LOCATION { 0.5 0.51 0.5 }
index 00b5bb6c410a8d16d59f19eb47da80b56154b1de..e1b5867f64ed684ae5095036171bd144b60da824 100644 (file)
@@ -32,10 +32,10 @@ CONSTANT: default-height 20
     [ not ] change-paused? drop ;
 
 : level>> ( tetris -- level )
-    rows>> 1+ 10 / ceiling ;
+    rows>> 1 + 10 / ceiling ;
 
 : update-interval ( tetris -- interval )
-    level>> 1- 60 * 1000 swap - ;
+    level>> 1 - 60 * 1000 swap - ;
 
 : add-block ( tetris block -- )
     over board>> spin current-piece tetromino>> colour>> set-block ;
@@ -57,7 +57,7 @@ CONSTANT: default-height 20
         { 2 [ 100 ] }
         { 3 [ 300 ] }
         { 4 [ 1200 ] }
-    } case swap 1+ * ;
+    } case swap 1 + * ;
 
 : add-score ( tetris n-rows -- tetris )
     over level>> swap rows-score swap [ + ] change-score ;
index 68f8e85a4a19f1c2771d623633234b21c18da3b2..510daaec41085c5a6dde36b96cbcf11f5535b38d 100644 (file)
@@ -104,7 +104,7 @@ SYMBOL: tetrominoes
     tetrominoes get random ;
 
 : blocks-max ( blocks quot -- max )
-    map [ 1+ ] [ max ] map-reduce ; inline
+    map [ 1 + ] [ max ] map-reduce ; inline
 
 : blocks-width ( blocks -- width )
     [ first ] blocks-max ;
index 4efea6ae427944efe9b40b90a9236ee549ec3e84..62f4d8fce4ba9367bd7af9c1018e8e0a7be9ed37 100755 (executable)
@@ -41,9 +41,9 @@ CONSTANT: right 1
 
 : go-left? ( -- ? ) current-side get left eq? ;
 
-: inc-count ( tree -- ) [ 1+ ] change-count drop ;
+: inc-count ( tree -- ) [ 1 + ] change-count drop ;
 
-: dec-count ( tree -- ) [ 1- ] change-count drop ;
+: dec-count ( tree -- ) [ 1 - ] change-count drop ;
 
 : node-link@ ( node ? -- node )
     go-left? xor [ left>> ] [ right>> ] if ;
diff --git a/extra/ui/frp/authors.txt b/extra/ui/frp/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/ui/frp/frp-docs.factor b/extra/ui/frp/frp-docs.factor
deleted file mode 100644 (file)
index 479a56e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-USING: help.markup help.syntax models monads sequences
-ui.gadgets.buttons ui.gadgets.tracks ;
-IN: ui.frp
-
-! Layout utilities
-
-HELP: ,
-{ $values { "uiitem" "a gadget or model" } }
-{ $description "Used in a series of gadgets created by a box, accumulating the gadget" } ;
-HELP: ->
-{ $values { "uiitem" "a gadget or model" } { "model" model } }
-{ $description "Like " { $link , } "but passes its model on for further use." } ;
-HELP: <hbox>
-{ $values { "gadgets" "a list of gadgets" } { "track" track } }
-{ $syntax "[ gadget , gadget , ... ] <hbox>" }
-{ $description "Creates an horizontal track containing the gadgets listed in the quotation" } ;
-HELP: <vbox>
-{ $values { "gadgets" "a list of gadgets" } { "track" track } }
-{ $syntax "[ gadget , gadget , ... ] <hbox>" }
-{ $description "Creates an vertical track containing the gadgets listed in the quotation" } ;
-
-! Gadgets
-HELP: <frp-button>
-{ $values { "text" "the button's label" } { "button" button } }
-{ $description "Creates an button whose model updates on clicks" } ;
-
-HELP: <merge>
-{ $values { "models" "a list of models" } { "model" merge-model } }
-{ $description "Creates a model that merges the updates of others" } ;
-
-HELP: <filter>
-{ $values { "model" model } { "quot" "quotation with stack effect ( a b -- c )" } { "filter-model" filter-model } }
-{ $description "Creates a model that uses the updates of another model when they satisfy a given predicate" } ;
-
-HELP: <fold>
-{ $values { "oldval" "starting value" } { "quot" "applied to update and previous values" } { "model" model } { "model'" model } }
-{ $description "Similar to " { $link reduce } " but works on models, applying a quotation to the previous and new values at each update" } ;
-
-HELP: <switch>
-{ $values { "signal1" model } { "signal2" model } { "signal'" model } }
-{ $description "Creates a model that starts with the behavior of model1 and switches to the behavior of model2 on its update" } ;
-
-ARTICLE: { "frp" "instances" } "FRP Instances"
-"Models are all functors, as " { $link fmap } " corresponds directly to the " { $link "models.arrow" } " vocabulary. "
-"Also, a gadget is a monad. Binding recieves a model and creates a new gadget." ;
-
diff --git a/extra/ui/frp/frp.factor b/extra/ui/frp/frp.factor
deleted file mode 100644 (file)
index 699d034..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-USING: accessors arrays colors fonts kernel models
-models.product monads sequences ui.gadgets ui.gadgets.buttons
-ui.gadgets.editors ui.gadgets.line-support ui.gadgets.tables
-ui.gadgets.tracks ui.render ui.gadgets.scrollers ;
-QUALIFIED: make
-IN: ui.frp
-
-! Gadgets
-: <frp-button> ( text -- button ) [ t swap set-control-value ] <border-button> f <model> >>model ;
-TUPLE: frp-table < table quot val-quot color-quot column-titles column-alignment ;
-M: frp-table column-titles column-titles>> ;
-M: frp-table column-alignment column-alignment>> ;
-M: frp-table row-columns quot>> [ call( a -- b ) ] [ drop f ] if* ;
-M: frp-table row-value val-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
-M: frp-table row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
-
-: <frp-table> ( model -- table )
-    frp-table new-line-gadget dup >>renderer [ ] >>quot swap >>model
-    f <model> >>selected-value sans-serif-font >>font
-    focus-border-color >>focus-border-color
-    transparent >>column-line-color [ ] >>val-quot ;
-: <frp-table*> ( -- table ) f <model> <frp-table> ;
-: <frp-list> ( model -- table ) <frp-table> [ 1array ] >>quot ;
-: <frp-list*> ( -- table ) f <model> <frp-list> ;
-
-: <frp-field> ( -- field ) f <model> <model-field> ;
-
-! Layout utilities
-
-GENERIC: output-model ( gadget -- model )
-M: gadget output-model model>> ;
-M: frp-table output-model selected-value>> ;
-M: model-field output-model field-model>> ;
-M: scroller output-model children>> first model>> ;
-
-GENERIC: , ( uiitem -- )
-M: gadget , make:, ;
-M: model , activate-model ;
-
-GENERIC: -> ( uiitem -- model )
-M: gadget -> dup make:, output-model ;
-M: model -> dup , ;
-M: table -> dup , selected-value>> ;
-
-: <box> ( gadgets type -- track )
-   [ { } make:make ] dip <track> swap [ f track-add ] each ; inline
-: <box*> ( gadgets type -- track ) [ <box> ] [ [ model>> ] map <product> ] bi >>model ; inline
-: <hbox> ( gadgets -- track ) horizontal <box> ; inline
-: <hbox*> ( gadgets -- track ) horizontal <box*> ; inline
-: <vbox> ( gadgets -- track ) vertical <box> ; inline
-: <vbox*> ( gadgets -- track ) vertical <box*> ; inline
-
-! !!! Model utilities
-TUPLE: multi-model < model ;
-: <multi-model> ( models kind -- model ) f swap new-model [ [ add-dependency ] curry each ] keep ;
-
-! Events- discrete model utilities
-
-TUPLE: merge-model < multi-model ;
-M: merge-model model-changed [ value>> ] dip set-model ;
-: <merge> ( models -- model ) merge-model <multi-model> ;
-
-TUPLE: filter-model < multi-model quot ;
-M: filter-model model-changed [ value>> ] dip [ quot>> call( val -- bool ) ] 2keep
-   [ set-model ] [ 2drop ] if ;
-: <filter> ( model quot -- filter-model ) [ 1array filter-model <multi-model> ] dip >>quot ;
-
-! Behaviors - continuous model utilities
-
-TUPLE: fold-model < multi-model oldval quot ;
-M: fold-model model-changed [ [ value>> ] [ [ oldval>> ] [ quot>> ] bi ] bi*
-   call( val oldval -- newval ) ] keep set-model ;
-: <fold> ( oldval quot model -- model' ) 1array fold-model <multi-model> swap >>quot
-   swap [ >>oldval ] [ >>value ] bi ;
-
-TUPLE: switch-model < multi-model original switcher on ;
-M: switch-model model-changed 2dup switcher>> =
-   [ over value>> [ [ value>> ] [ t >>on ] bi* set-model ] [ 2drop ] if ]
-   [ dup on>> [ 2drop ] [ [ value>> ] dip set-model ] if ] if ;
-M: switch-model model-activated [ original>> ] keep model-changed ;
-: <switch> ( signal1 signal2 -- signal' ) [ 2array switch-model <multi-model> ] 2keep
-   [ >>original ] [ >>switcher ] bi* ;
-
-TUPLE: mapped < model model quot ;
-
-: <mapped> ( model quot -- arrow )
-    f mapped new-model
-        swap >>quot
-        over >>model
-        [ add-dependency ] keep ;
-
-M: mapped model-changed
-    [ [ value>> ] [ quot>> ] bi* call( old -- new ) ] [ nip ] 2bi
-    set-model ;
-
-! Instances
-M: model fmap <mapped> ;
-
-SINGLETON: gadget-monad
-INSTANCE: gadget-monad monad
-INSTANCE: gadget monad
-M: gadget monad-of drop gadget-monad ;
-M: gadget-monad return drop <gadget> swap >>model ;
-M: gadget >>= output-model [ swap call( x -- y ) ] curry ; 
\ No newline at end of file
diff --git a/extra/ui/frp/summary.txt b/extra/ui/frp/summary.txt
deleted file mode 100644 (file)
index 3b49d34..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Utilities for functional reactive programming in user interfaces
index 03d60957fa19a16e7221d9701d522ea550334c73..254e2821395fe1b16c9470cefceddf0f867ccbb1 100644 (file)
@@ -1,4 +1,28 @@
-USING: accessors ui ui.gadgets ui.gadgets.labels ui.gadgets.buttons ui.gadgets.packs locals sequences fonts io.styles ;
+USING: accessors models monads macros generalizations kernel
+ui ui.gadgets.controls models.combinators ui.gadgets.layout ui.gadgets
+ui.gadgets.labels ui.gadgets.editors ui.gadgets.buttons
+ui.gadgets.packs locals sequences fonts io.styles
+wrap.strings ;
+
 IN: ui.gadgets.alerts
-:: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align string <label> T{ font { name "sans-serif" } { size 18 } } >>font { 200 100 } >>pref-dim add-gadget 
-   "okay" [ close-window ] quot append <border-button> add-gadget "" open-window ;
\ No newline at end of file
+:: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align
+   string 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font { 200 100 } >>pref-dim add-gadget 
+   "okay" [ close-window ] quot append <border-button> add-gadget "" open-window ;
+
+: alert* ( str -- ) [ ] swap alert ;
+
+:: ask-user ( string -- model' )
+   [ [let | lbl  [ string <label>  T{ font { name "sans-serif" } { size 14 } } >>font dup , ]
+            fldm [ <model-field*> ->% 1 ]
+            btn  [ "okay" <model-border-btn> ] |
+         btn -> [ fldm swap updates ]
+                [ [ drop lbl close-window ] $> , ] bi
+   ] ] <vbox> { 161 86 } >>pref-dim "" open-window ;
+
+MACRO: ask-buttons ( buttons -- quot ) dup length [
+      [ swap
+         [ 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font ,
+         [ [ <model-border-btn> [ close-window ] >>hook -> ] map ] <hbox> , ] <vbox>
+         "" open-window
+      ] dip firstn
+   ] 2curry ;
\ No newline at end of file
index 9e9474791986899c17f54ec8eece1bc666a97655..41e16e0f9f050a477669652cd86bbed5ff58fa8a 100644 (file)
@@ -5,8 +5,13 @@ IN: ui.gadgets.book-extras
 : |<< ( book -- ) 0 swap set-control-value ;
 : next ( book -- ) model>> [ 1 + ] change-model ;
 : prev ( book -- ) model>> [ 1 - ] change-model ;
-: (book-t) ( quot -- quot ) '[ : owner ( gadget -- book ) parent>> dup book? [ owner ] unless ; owner @ ] ;
+: owner ( gadget -- book ) parent>> dup book? [ owner ] unless ;
+: (book-t) ( quot -- quot ) '[ owner @ ] ;
 : <book-btn> ( label quot -- button ) (book-t) <button> ;
-: <book-bevel-btn> ( label quot -- button ) (book-t) <border-button> ;
-: >>> ( label -- button ) [ next ] <book-btn> ;
-: <<< ( label -- button ) [ prev ] <book-btn> ;
\ No newline at end of file
+: <book-border-btn> ( label quot -- button ) (book-t) <border-button> ;
+: >>> ( gadget -- ) owner next ;
+: <<< ( gadget -- ) owner prev ;
+: go-to ( gadget number -- ) swap owner model>> set-model ;
+
+: <forward-btn> ( label -- button ) [ >>> ] <button> ;
+: <backward-btn> ( label -- button ) [ <<< ] <button> ;
index b0dbe34d1665381a6cbf0c10cad9007b2ceb233d..3eb118050e839a645d4e17c4e41e5deb1a27bea5 100644 (file)
@@ -1,22 +1,22 @@
-USING: accessors arrays kernel math.rectangles models sequences
-ui.frp ui.gadgets ui.gadgets.glass ui.gadgets.labels
-ui.gadgets.tables ui.gestures ;
+USING: accessors arrays kernel math.rectangles sequences
+ui.gadgets.controls models.combinators ui.gadgets ui.gadgets.glass
+ui.gadgets.labels ui.gestures ;
+QUALIFIED-WITH: ui.gadgets.tables tbl
 IN: ui.gadgets.comboboxes
 
 TUPLE: combo-table < table spawner ;
 
-M: combo-table handle-gesture [ call-next-method ] 2keep swap
+M: combo-table handle-gesture [ call-next-method drop ] 2keep swap
    T{ button-up } = [
       [ spawner>> ]
-      [ selected-value>> value>> [ swap set-control-value ] [ drop ] if* ]
-      [ hide-glass ] tri drop t
-   ] [ drop ] if ;
+      [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
+      [ hide-glass ] tri
+   ] [ drop ] if ;
 
 TUPLE: combobox < label-control table ;
 combobox H{
    { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
 } set-gestures
 
-: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <model> >>model ] keep
-   [ 1array ] map <model> trivial-renderer combo-table new-table
-   >>table ;
\ No newline at end of file
+: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
+    <basic> combo-table new-table [ 1array ] >>quot >>table ;
\ No newline at end of file
diff --git a/extra/ui/gadgets/controls/authors.txt b/extra/ui/gadgets/controls/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/ui/gadgets/controls/controls-docs.factor b/extra/ui/gadgets/controls/controls-docs.factor
new file mode 100644 (file)
index 0000000..1df6005
--- /dev/null
@@ -0,0 +1,71 @@
+USING: accessors help.markup help.syntax ui.gadgets.buttons
+ui.gadgets.editors models ui.gadgets ;
+IN: ui.gadgets.controls
+
+HELP: <model-btn>
+{ $values { "gadget" "the button's label" } { "button" button } }
+{ $description "Creates an button whose signal updates on clicks.  " } ;
+
+HELP: <model-border-btn>
+{ $values { "text" "the button's label" } { "button" button } }
+{ $description "Creates an button whose signal updates on clicks.  " } ;
+
+HELP: <table>
+{ $values { "model" "values the table is to display" } { "table" table } }
+{ $description "Creates an " { $link table } } ;
+
+HELP: <table*>
+{ $values { "table" table } }
+{ $description "Creates an " { $link table } " with no initial values to display" } ;
+
+HELP: <list>
+{ $values { "column-model" "values the table is to display" } { "table" table } }
+{ $description "Creates an " { $link table } " with a val-quot that renders each element as its own row" } ;
+
+HELP: <list*>
+{ $values { "table" table } }
+{ $description "Creates an model-list with no initial values to display" } ;
+
+HELP: indexed
+{ $values { "table" table } }
+{ $description "Sets the output model of an table to the selected-index, rather than the selected-value" } ;
+
+HELP: <model-field>
+{ $values { "model" model } { "gadget" model-field } }
+{ $description "Creates a field with an initial value" } ;
+
+HELP: <model-field*>
+{ $values { "field" model-field } }
+{ $description "Creates a field with an empty initial value" } ;
+
+HELP: <empty-field>
+{ $values { "model" model } { "field" model-field } }
+{ $description "Creates a field with an empty initial value that switches to another signal on its update" } ;
+
+HELP: <model-editor>
+{ $values { "model" model } { "gadget" model-field } }
+{ $description "Creates an editor with an initial value" } ;
+
+HELP: <model-editor*>
+{ $values { "editor" "an editor" } }
+{ $description "Creates a editor with an empty initial value" } ;
+
+HELP: <empty-editor>
+{ $values { "model" model } { "editor" "an editor" } }
+{ $description "Creates a field with an empty initial value that switches to another signal on its update" } ;
+
+HELP: <model-action-field>
+{ $values { "field" action-field } }
+{ $description "Field that updates its model with its contents when the user hits the return key" } ;
+
+HELP: IMG-MODEL-BTN:
+{ $syntax "IMAGE-MODEL-BTN: filename" }
+{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path" } ;
+
+HELP: IMG-BTN:
+{ $syntax "[ do-something ] IMAGE-BTN: filename" }
+{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path, calling the specified quotation on click" } ;
+
+HELP: output-model
+{ $values { "gadget" gadget } { "model" model } }
+{ $description "Returns the model a gadget uses for output. Often the same as " { $link model>> } } ;
\ No newline at end of file
diff --git a/extra/ui/gadgets/controls/controls.factor b/extra/ui/gadgets/controls/controls.factor
new file mode 100644 (file)
index 0000000..649c905
--- /dev/null
@@ -0,0 +1,83 @@
+USING: accessors assocs arrays kernel models monads sequences
+models.combinators ui.gadgets ui.gadgets.borders ui.gadgets.buttons
+ui.gadgets.buttons.private ui.gadgets.editors words images.loader
+ui.gadgets.scrollers ui.images vocabs.parser lexer
+models.range ui.gadgets.sliders ;
+QUALIFIED-WITH: ui.gadgets.sliders slider
+QUALIFIED-WITH: ui.gadgets.tables tbl
+EXCLUDE: ui.gadgets.editors => model-field ;
+IN: ui.gadgets.controls
+
+TUPLE: model-btn < button hook value ;
+: <model-btn> ( gadget -- button ) [
+      [ dup hook>> [ call( button -- ) ] [ drop ] if* ]
+      [ [ [ value>> ] [ ] bi or ] keep set-control-value ]
+      [ model>> f swap (>>value) ] tri
+   ] model-btn new-button f <basic> >>model ;
+: <model-border-btn> ( text -- button ) <model-btn> border-button-theme ;
+
+TUPLE: table < tbl:table { quot initial: [ ] } { val-quot initial: [ ] } color-quot column-titles column-alignment actions ;
+M: table tbl:column-titles column-titles>> ;
+M: table tbl:column-alignment column-alignment>> ;
+M: table tbl:row-columns quot>> [ call( a -- b ) ] [ drop f ] if* ;
+M: table tbl:row-value val-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
+M: table tbl:row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
+
+: new-table ( model class -- table ) f swap tbl:new-table dup >>renderer
+   f <basic> >>actions dup actions>> [ set-model ] curry >>action ;
+: <table> ( model -- table ) table new-table ;
+: <table*> ( -- table ) V{ } clone <model> <table> ;
+: <list> ( column-model -- table ) <table> [ 1array ] >>quot ;
+: <list*> ( -- table ) V{ } clone <model> <list> ;
+: indexed ( table -- table ) f >>val-quot ;
+
+TUPLE: model-field < field model* ;
+: init-field ( model -- model' ) [ [ ] [ "" ] if* ] change-value ;
+: <model-field> ( model -- gadget ) model-field new-field swap init-field >>model* ;
+M: model-field graft*
+    [ [ model*>> value>> ] [ editor>> ] bi set-editor-string ]
+    [ dup editor>> model>> add-connection ]
+    [ dup model*>> add-connection ] tri ;
+M: model-field ungraft*
+   [ dup editor>> model>> remove-connection ]
+   [ dup model*>> remove-connection ] bi ;
+M: model-field model-changed 2dup model*>> =
+    [ [ value>> ] [ editor>> ] bi* set-editor-string ]
+    [ nip [ editor>> editor-string ] [ model*>> ] bi set-model ] if ;
+: (new-field) ( editor field -- gadget ) [ new-editor ] dip new-border dup gadget-child >>editor
+    field-theme { 1 0 } >>align ; inline
+: <model-field*> ( -- field ) "" <model> <model-field> ;
+: <empty-field> ( model -- field ) "" <model> switch-models <model-field> ;
+: <model-editor> ( model -- gadget ) multiline-editor model-field (new-field) swap init-field >>model* ;
+: <model-editor*> ( -- editor ) "" <model> <model-editor> ;
+: <empty-editor> ( model -- editor ) "" <model> switch-models <model-editor> ;
+
+: <model-action-field> ( -- field ) f <action-field> dup [ set-control-value ] curry >>quot
+    f <model> >>model ;
+
+: <slider> ( init page min max step -- slider ) <range> horizontal slider:<slider> ;
+
+: image-prep ( -- image ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround <image-name> dup cached-image drop ;
+SYNTAX: IMG-MODEL-BTN: image-prep [ <model-btn> ] curry over push-all ;
+
+SYNTAX: IMG-BTN: image-prep [ swap <button> ] curry over push-all ;
+
+GENERIC: output-model ( gadget -- model )
+M: gadget output-model model>> ;
+M: table output-model dup val-quot>> [ selection>> ] [ selection-index>> ] if ;
+M: model-field output-model model*>> ;
+M: scroller output-model viewport>> children>> first output-model ;
+M: slider output-model model>> range-model ;
+
+IN: accessors
+M: model-btn text>> children>> first text>> ;
+
+IN: ui.gadgets.controls
+
+SINGLETON: gadget-monad
+INSTANCE: gadget-monad monad
+INSTANCE: gadget monad
+M: gadget monad-of drop gadget-monad ;
+M: gadget-monad return drop <gadget> swap >>model ;
+M: gadget >>= output-model [ swap call( x -- y ) ] curry ; 
\ No newline at end of file
diff --git a/extra/ui/gadgets/controls/summary.txt b/extra/ui/gadgets/controls/summary.txt
new file mode 100644 (file)
index 0000000..eeef94d
--- /dev/null
@@ -0,0 +1 @@
+Gadgets with expanded model usage
\ No newline at end of file
diff --git a/extra/ui/gadgets/layout/authors.txt b/extra/ui/gadgets/layout/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/ui/gadgets/layout/layout-docs.factor b/extra/ui/gadgets/layout/layout-docs.factor
new file mode 100644 (file)
index 0000000..cd8f62b
--- /dev/null
@@ -0,0 +1,53 @@
+USING: help.markup help.syntax models ui.gadgets.tracks ;
+IN: ui.gadgets.layout
+
+HELP: ,
+{ $values { "item" "a gadget or model" } }
+{ $description "Used in a series of gadgets created by a box, accumulating the gadget" } ;
+
+HELP: ,%
+{ $syntax "gadget ,% width" }
+{ $description "Like ',' but stretches the gadget to always fill a percent of the parent" } ;
+
+HELP: ->
+{ $values { "uiitem" "a gadget or model" } { "model" model } }
+{ $description "Like ',' but passes its model on for further use." } ;
+
+HELP: ->%
+{ $syntax "gadget ,% width" }
+{ $description "Like '->' but stretches the gadget to always fill a percent of the parent" } ;
+
+HELP: <spacer>
+{ $description "Grows to fill any empty space in a box" } ;
+
+HELP: <hbox>
+{ $values { "gadgets" "a list of gadgets" } { "track" track } }
+{ $syntax "[ gadget , gadget , ... ] <hbox>" }
+{ $description "Creates an horizontal track containing the gadgets listed in the quotation" } ;
+
+HELP: <vbox>
+{ $values { "gadgets" "a list of gadgets" } { "track" track } }
+{ $syntax "[ gadget , gadget , ... ] <hbox>" }
+{ $description "Creates an vertical track containing the gadgets listed in the quotation" } ;
+
+HELP: $
+{ $syntax "$ PLACEHOLDER-NAME $" }
+{ $description "Defines an insertion point in a template named PLACEHOLDER-NAME which can be used by calling its name" } ;
+
+HELP: with-interface
+{ $values { "quot" "quotation that builds a template and inserts into it" } }
+{ $description "Create templates, used with " { $link POSTPONE: $ } } ;
+
+ARTICLE: "ui.gadgets.layout" "GUI Layout"
+"Laying out GUIs works the same way as building lists with " { $vocab-link "make" }
+". Gadgets are layed out using " { $vocab-link "ui.gadgets.tracks" } " through " { $link <hbox> } " and " { $link <vbox> } ", which allow both fixed and percentage widths. "
+{ $link , } " and " { $link -> }  " add a model or gadget to the gadget you're building. "
+"Also, books can be made with " { $link <book> } ". "
+{ $link <spacer> } "s add flexable space between items. " $nl
+"Using " { $link with-interface } ", one can pre-build templates to add items to later: "
+"Like in the StringTemplate framework for java, placeholders are defined using $ PLACERHOLDER-NAME $ "
+"Using PLACEHOLDER-NAME again sets it as the current insertion point. "
+"For examples using normal layout, see the " { $vocab-link "sudokus" } " demo. "
+"For examples of templating, see the " { $vocab-link "recipes" } " demo. " ;
+
+ABOUT: "ui.gadgets.layout"
\ No newline at end of file
diff --git a/extra/ui/gadgets/layout/layout.factor b/extra/ui/gadgets/layout/layout.factor
new file mode 100644 (file)
index 0000000..bd3ab1d
--- /dev/null
@@ -0,0 +1,89 @@
+USING: accessors assocs arrays fry kernel lexer make math.parser
+models monads namespaces parser sequences
+sequences.extras models.combinators ui.gadgets
+ui.gadgets.tracks words ui.gadgets.controls ;
+QUALIFIED: make
+QUALIFIED-WITH: ui.gadgets.books book
+IN: ui.gadgets.layout
+
+SYMBOL: templates
+TUPLE: layout gadget size ; C: <layout> layout
+TUPLE: placeholder < gadget members ;
+: <placeholder> ( -- placeholder ) placeholder new V{ } clone >>members ;
+
+: (remove-members) ( placeholder members -- ) [ [ model? ] filter swap parent>> model>> [ remove-connection ] curry each ]
+    [ nip [ gadget? ] filter [ unparent ] each ] 2bi ;
+
+: remove-members ( placeholder -- ) dup members>> [ drop ] [ [ (remove-members) ] keep delete-all ] if-empty ;
+: add-member ( obj placeholder -- ) over layout? [ [ gadget>> ] dip ] when members>> push ;
+
+: , ( item -- ) make:, ;
+: make* ( quot -- list ) { } make ; inline
+
+! Just take the previous mentioned placeholder and use it
+! If there is no previously mentioned placeholder, we're probably making a box, and will create the placeholder ourselves
+DEFER: with-interface
+: insertion-quot ( quot -- quot' ) make:building get [ [ placeholder? ] find-last nip [ <placeholder> dup , ] unless*
+    templates get spin '[ [ _ templates set _ , @ ] with-interface ] ] when* ;
+
+SYNTAX: ,% scan string>number [ <layout> , ] curry over push-all ;
+SYNTAX: ->% scan string>number '[ [ _ <layout> , ] [ output-model ] bi ] over push-all ;
+
+GENERIC: -> ( uiitem -- model )
+M: gadget -> dup , output-model ;
+M: model -> dup , ;
+
+: <spacer> ( -- ) <gadget> 1 <layout> , ;
+
+: add-layout ( track layout -- track ) [ gadget>> ] [ size>> ] bi track-add ;
+: layouts ( sized? gadgets -- layouts ) [ [ gadget? ] [ layout? ] bi or ] filter swap
+   [ [ dup layout? [ f <layout> ] unless ] map ]
+   [ [ dup gadget? [ gadget>> ] unless ] map ] if ;
+: make-layout ( building sized? -- models layouts ) [ swap layouts ] curry
+   [ make* [ [ model? ] filter ] ] dip bi ; inline
+: <box> ( gadgets type -- track )
+   [ t make-layout ] dip <track>
+   swap [ add-layout ] each
+   swap [ <collection> >>model ] unless-empty ; inline
+: <hbox> ( gadgets -- track ) horizontal <box> ; inline
+: <vbox> ( gadgets -- track ) vertical <box> ; inline
+
+: make-book ( models gadgets model -- book ) book:<book> swap [ "No models in books" throw ] unless-empty ;
+: <book> ( quot: ( -- model ) -- book ) f make-layout rot 0 >>value make-book ; inline
+: <book*> ( quot -- book ) f make-layout f make-book ; inline
+
+ERROR: not-in-template word ;
+SYNTAX: $ CREATE-WORD dup
+    [ [ dup templates get at [ nip , ] [ not-in-template ] if* ] curry (( -- )) define-declared "$" expect ]
+    [ [ <placeholder> [ swap templates get set-at ] keep , ] curry ] bi over push-all ;
+
+: insert-gadget ( number parent gadget -- ) -rot [ but-last insert-nth ] change-children drop ;
+: insert-size ( number parent size -- ) -rot [ but-last insert-nth ] change-sizes drop ;
+: insertion-point ( placeholder -- number parent ) dup parent>> [ children>> index ] keep ;
+
+GENERIC: >layout ( gadget -- layout )
+M: gadget >layout f <layout> ;
+M: layout >layout ;
+
+GENERIC# (add-gadget-at) 2 ( parent item n -- )
+M: gadget (add-gadget-at) -rot [ add-gadget ] keep insert-gadget ;
+M: track (add-gadget-at) -rot >layout [ add-layout ] keep [ gadget>> insert-gadget ] [ size>> insert-size ] 3bi ;
+
+GENERIC# add-gadget-at 1 ( item location -- )
+M: object add-gadget-at insertion-point -rot (add-gadget-at) ;
+M: model add-gadget-at parent>> dup book:book? [ "No models in books" throw ]
+   [ dup model>> dup collection? [ nip swap add-connection ] [ drop [ 1array <collection> ] dip (>>model) ] if ] if ;
+: track-add-at ( item location size -- ) swap [ <layout> ] dip add-gadget-at ;
+: (track-add-at) ( parent item n size -- ) swap [ <layout> ] dip (add-gadget-at) ;
+
+: insert-item ( item location -- ) [ dup get [ drop ] [ remove-members ] if ] [ on ] [ ] tri
+    [ add-member ] 2keep add-gadget-at ;
+
+: insert-items ( makelist -- ) t swap [ dup placeholder? [ nip ] [ over insert-item ] if ] each drop ;
+
+: with-interface ( quot -- ) [ make* ] curry H{ } clone templates rot with-variable [ insert-items ] with-scope ; inline
+
+M: model >>= [ swap insertion-quot <action> ] curry ;
+M: model fmap insertion-quot <mapped> ;
+M: model $> insertion-quot side-effect-model new-mapped-model ;
+M: model <$ insertion-quot quot-model new-mapped-model ;
\ No newline at end of file
diff --git a/extra/ui/gadgets/layout/summary.txt b/extra/ui/gadgets/layout/summary.txt
new file mode 100644 (file)
index 0000000..30b5ef5
--- /dev/null
@@ -0,0 +1 @@
+Syntax for easily building GUIs and using templates
\ No newline at end of file
index 5ff5bb38791e46072eb91a8969bc9aa3428899c3..8730c0acc48330bd553edc4d7a93b3f2125c7dd1 100644 (file)
@@ -23,7 +23,7 @@ TUPLE: list < pack index presenter color hook ;
         list-theme ;
 
 : calc-bounded-index ( n list -- m )
-    control-value length 1- min 0 max ;
+    control-value length 1 - min 0 max ;
 
 : bound-index ( list -- )
     dup index>> over calc-bounded-index >>index drop ;
@@ -83,10 +83,10 @@ M: list focusable-child* drop t ;
     ] if ;
 
 : select-previous ( list -- )
-    [ index>> 1- ] keep select-index ;
+    [ index>> 1 - ] keep select-index ;
 
 : select-next ( list -- )
-    [ index>> 1+ ] keep select-index ;
+    [ index>> 1 + ] keep select-index ;
 
 : invoke-value-action ( list -- )
     dup list-empty? [
diff --git a/extra/ui/gadgets/poppers/authors.txt b/extra/ui/gadgets/poppers/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/ui/gadgets/poppers/poppers.factor b/extra/ui/gadgets/poppers/poppers.factor
new file mode 100644 (file)
index 0000000..1c815d5
--- /dev/null
@@ -0,0 +1,50 @@
+! Copyright (C) 2009 Sam Anklesaria
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays accessors combinators kernel math
+models models.combinators namespaces sequences
+ui.gadgets ui.gadgets.controls ui.gadgets.layout
+ui.gadgets.tracks ui.gestures ui.gadgets.line-support ;
+EXCLUDE: ui.gadgets.editors => model-field ;
+IN: ui.gadgets.poppers
+
+TUPLE: popped < model-field { fatal? initial: t } ;
+TUPLE: popped-editor < multiline-editor ;
+: <popped> ( text -- gadget ) <basic> init-field popped-editor popped (new-field) swap >>model* ;
+
+: set-expansion ( popped size -- ) over dup parent>> [ children>> index ] [ sizes>> ] bi set-nth relayout ;
+: new-popped ( popped -- ) insertion-point "" <popped>
+    [ rot 1 + f (track-add-at) ] keep [ relayout ] [ request-focus ] bi ;
+: focus-prev ( popped -- ) dup parent>> children>> length 1 =
+    [ drop ] [
+        insertion-point [ 1 - dup -1 = [ drop 1 ] when ] [ children>> ] bi* nth
+        [ request-focus ] [ editor>> end-of-document ] bi
+    ] if ;
+: initial-popped ( popper -- ) "" <popped> [ f track-add drop ] keep request-focus ;
+
+TUPLE: popper < track { unfocus-hook initial: [ drop ] } ;
+! list of strings is model (make shown objects implement sequence protocol)
+: <popper> ( model -- popper ) vertical popper new-track swap >>model ;
+
+M: popped handle-gesture swap {
+    { gain-focus [ 1 set-expansion f ] }
+    { lose-focus [ dup parent>>
+        [ [ unfocus-hook>> call( a -- ) ] curry [ f set-expansion ] bi ]
+        [ drop ] if* f
+    ] }
+    { T{ key-up f f "RET" } [ dup editor>> delete-previous-character new-popped f ] }
+    { T{ key-up f f "BACKSPACE" } [ dup editor>> editor-string "" =
+        [ dup fatal?>> [ [ focus-prev ] [ unparent ] bi ] [ t >>fatal? drop ] if ]
+        [ f >>fatal? drop ] if f
+    ] }
+    [ swap call-next-method ]
+} case ;
+
+M: popper handle-gesture swap T{ button-down f f 1 } =
+    [ hand-click# get 2 = [ initial-popped ] [ drop ] if ] [ drop ] if f ;
+
+M: popper model-changed
+    [ children>> [ unparent ] each ]
+    [ [ value>> [ <popped> ] map ] dip [ f track-add ] reduce request-focus ] bi ;
+
+M: popped pref-dim* editor>> [ pref-dim* first ] [ line-height ] bi 2array ;
+M: popper focusable-child* children>> [ t ] [ first ] if-empty ;
\ No newline at end of file
index c16450bb251e79083b3e46fbf2d70f7549e934ff..f098bb9f09d4c674aab312709c9612b82415cbe7 100644 (file)
@@ -83,7 +83,7 @@ M: comment entity-url
     >>comments ;
 
 : reverse-chronological-order ( seq -- sorted )
-    [ [ date>> ] compare invert-comparison ] sort ;
+    [ date>> ] inv-sort-with ;
 
 : validate-author ( -- )
     { { "author" [ v-username ] } } validate-params ;
index 6a52d02009df3b1b562b44d3dccfda232370f63e..2c51d41aa016de58e9e54480e7ab2b35d14698c9 100644 (file)
@@ -59,7 +59,7 @@ TUPLE: paste < entity annotations ;
 
 : pastes ( -- pastes )
     f <paste> select-tuples
-    [ [ date>> ] compare ] sort
+    [ date>> ] sort-with
     reverse ;
 
 TUPLE: annotation < entity parent ;
index 12b7ccda24827815952edcb45cdce948d377b9a8..eb51acbe1a698e3dcaf8ce9972f5b4a335437209 100755 (executable)
@@ -56,11 +56,11 @@ posting "POSTINGS"
 
 : blogroll ( -- seq )
     f <blog> select-tuples
-    [ [ name>> ] compare ] sort ;
+    [ name>> ] sort-with ;
 
 : postings ( -- seq )
     posting new select-tuples
-    [ [ date>> ] compare invert-comparison ] sort ;
+    [ date>> ] inv-sort-with ;
 
 : <edit-blogroll-action> ( -- action )
     <page-action>
@@ -99,7 +99,7 @@ posting "POSTINGS"
     [ '[ _ <posting> ] map ] 2map concat ;
 
 : sort-entries ( entries -- entries' )
-    [ [ date>> ] compare invert-comparison ] sort ;
+    [ date>> ] inv-sort-with ;
 
 : update-cached-postings ( -- )
     blogroll fetch-blogroll sort-entries 8 short head [
index 5689f23d4ea6cfd60f3e30e1ac2f5e8f574316c9..f3a3784465d254d80882184e872913fed901e8a3 100644 (file)
@@ -66,7 +66,7 @@ M: revision feed-entry-date date>> ;
 M: revision feed-entry-url id>> revision-url ;
 
 : reverse-chronological-order ( seq -- sorted )
-    [ [ date>> ] compare invert-comparison ] sort ;
+    [ date>> ] inv-sort-with ;
 
 : <revision> ( id -- revision )
     revision new swap >>id ;
@@ -307,7 +307,7 @@ M: revision feed-entry-url id>> revision-url ;
 
         [
             f <article> select-tuples
-            [ [ title>> ] compare ] sort
+            [ title>> ] sort-with
             "articles" set-value
         ] >>init
 
index e02701b6909674772ca6b92b514c929f25f18ffb..abf6a536578fb4372d21e6a7a529a98f7141ce97 100644 (file)
@@ -14,7 +14,7 @@ SYMBOL: *calling*
   *wordtimes* get-global [ drop { 0 0 } ] cache first2 ;
 
 : update-times ( utime current-utime current-numinvokes -- utime' invokes' )
-  rot [ + ] curry [ 1+ ] bi* ;
+  rot [ + ] curry [ 1 + ] bi* ;
 
 : register-time ( utime word -- )
   name>>
diff --git a/misc/Factor.tmbundle/Commands/Cycle Vocabs-Docs-Tests.tmCommand b/misc/Factor.tmbundle/Commands/Cycle Vocabs-Docs-Tests.tmCommand
new file mode 100644 (file)
index 0000000..e21ad95
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+x = ENV["TM_FILEPATH"][/\/([^\/]+\.factor)/,1]
+y = x.sub("-tests","").sub("docs", "tests")
+if x == y then
+  z = x.sub(".factor","")
+  factor_eval(%Q(USING: tools.scaffold #{z} ;\n"#{z}" scaffold-help))
+  y = x.sub(".factor", "-docs.factor")
+end
+exec "mate #{ENV["TM_FILEPATH"][/(.*\/)[^\/]+\.factor/,1] &lt;&lt; y}"</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>none</string>
+       <key>keyEquivalent</key>
+       <string>^@`</string>
+       <key>name</key>
+       <string>Cycle Vocabs/Docs/Tests</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>D348BE40-6F51-4471-B300-DDDA70ED8C8C</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Edit Vocab.tmCommand b/misc/Factor.tmbundle/Commands/Edit Vocab.tmCommand
new file mode 100644 (file)
index 0000000..1ed5787
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: editors\n "#{word}" edit-vocab))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>@V</string>
+       <key>name</key>
+       <string>Edit Vocab</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>0034EC1C-DAD1-498F-82FD-BEF7015F84EE</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Edit Word Docs.tmCommand b/misc/Factor.tmbundle/Commands/Edit Word Docs.tmCommand
new file mode 100644 (file)
index 0000000..bc447ee
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USING: help.topics editors ;\n \\ #{word} &gt;link edit))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>@D</string>
+       <key>name</key>
+       <string>Edit Word Docs</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>D95A617C-E1C6-44DA-9126-04171CB21299</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Edit Word.tmCommand b/misc/Factor.tmbundle/Commands/Edit Word.tmCommand
new file mode 100644 (file)
index 0000000..ab4fa2a
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: editors\n \\ #{word} edit))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>@E</string>
+       <key>name</key>
+       <string>Edit Word</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>C573487C-DD7D-497F-A728-52D7962D95E2</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Expand Selection.tmCommand b/misc/Factor.tmbundle/Commands/Expand Selection.tmCommand
new file mode 100644 (file)
index 0000000..d2b69dc
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: ui.tools.operations\n [ #{ENV["TM_SELECTED_TEXT"} ] com-expand-macros))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>name</key>
+       <string>Expand Selection</string>
+       <key>output</key>
+       <string>showAsTooltip</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>8465B33D-7CA0-4337-945C-4078346D64BC</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Fix Word.tmCommand b/misc/Factor.tmbundle/Commands/Fix Word.tmCommand
new file mode 100644 (file)
index 0000000..25a852c
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_run(%Q(#{doc_using_statements(doc)} USE: editors\n \\ #{word} fix))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>@F</string>
+       <key>name</key>
+       <string>Fix Word</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>D02D9D74-E073-48AE-A78E-B40FFFA519D5</string>
+</dict>
+</plist>
index 0ff133c891705991c40ba14f370c397f03260c0f..350c01d3442c0a9a2aebcb61d8877a5691d6bf19 100644 (file)
@@ -11,7 +11,7 @@ require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
 
 doc = STDIN.read
 word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
-factor_run(%Q(#{doc_using_statements(doc)} USE: ui.tools.workspace\n \\ #{word} help-window))</string>
+factor_run(%Q(#{doc_using_statements(doc)} USE: help\n \\ #{word} help))</string>
        <key>fallbackInput</key>
        <string>word</string>
        <key>input</key>
diff --git a/misc/Factor.tmbundle/Commands/Infer Effect of Selection.tmCommand b/misc/Factor.tmbundle/Commands/Infer Effect of Selection.tmCommand
deleted file mode 100644 (file)
index 378294e..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>beforeRunningCommand</key>
-       <string>nop</string>
-       <key>command</key>
-       <string>#!/usr/bin/env ruby
-
-require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
-
-doc = STDIN.read
-puts factor_eval(%Q(#{doc_using_statements(doc)} USE: inference\n [ #{ENV["TM_SELECTED_TEXT"]} ] infer.))</string>
-       <key>fallbackInput</key>
-       <string>word</string>
-       <key>input</key>
-       <string>document</string>
-       <key>name</key>
-       <string>Infer Effect of Selection</string>
-       <key>output</key>
-       <string>showAsTooltip</string>
-       <key>scope</key>
-       <string>source.factor</string>
-       <key>uuid</key>
-       <string>B619FCC0-2DF2-4657-82A8-0E5676A10254</string>
-</dict>
-</plist>
diff --git a/misc/Factor.tmbundle/Commands/Infer Selection.tmCommand b/misc/Factor.tmbundle/Commands/Infer Selection.tmCommand
new file mode 100644 (file)
index 0000000..c7b6ec8
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: stack-checker\n [ #{ENV["TM_SELECTED_TEXT"]} ] infer.))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^i</string>
+       <key>name</key>
+       <string>Infer Selection</string>
+       <key>output</key>
+       <string>showAsTooltip</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>B619FCC0-2DF2-4657-82A8-0E5676A10254</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Insert Inferrence.tmCommand b/misc/Factor.tmbundle/Commands/Insert Inferrence.tmCommand
new file mode 100644 (file)
index 0000000..366cdfc
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: stack-checker\n [ #{ENV["TM_SELECTED_TEXT"]} ] infer.))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>name</key>
+       <string>Insert Inferrence</string>
+       <key>output</key>
+       <string>afterSelectedText</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>DBC0A0CA-5368-43A7-864B-7B9C4034AD08</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Profile.tmCommand b/misc/Factor.tmbundle/Commands/Profile.tmCommand
new file mode 100644 (file)
index 0000000..108ad7b
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_run(%Q(#{doc_using_statements(doc)} USE: tools.profiler\n [ #{word} ] profile))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^p</string>
+       <key>name</key>
+       <string>Profile</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>7FF52332-CA5B-4D46-99EF-DAE0659DB478</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Reload in Listener.tmCommand b/misc/Factor.tmbundle/Commands/Reload in Listener.tmCommand
new file mode 100644 (file)
index 0000000..cec58f2
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+doc = STDIN.read
+factor_run(%Q(USE: vocabs.loader\n "#{doc[/\bIN:\s(\S+)/, 1]}" reload))</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^r</string>
+       <key>name</key>
+       <string>Reload in Listener</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>8088D204-FFD7-4384-8FDD-A01536FFD0E7</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Reset Word.tmCommand b/misc/Factor.tmbundle/Commands/Reset Word.tmCommand
new file mode 100644 (file)
index 0000000..0a9808a
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: tools.annotations\n \\ #{word} reset))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^~r</string>
+       <key>name</key>
+       <string>Reset Word</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>71F08D9B-3D24-4E78-84C9-82CA736554D1</string>
+</dict>
+</plist>
index 4502e235be0b2eaf6a9c30bf9173181025ac69dc..ca1cf4232044f926cbf461a6d51cd87a5c8ad1a0 100644 (file)
@@ -11,7 +11,7 @@ require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
 
 doc = STDIN.read
 word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
-puts factor_eval(%Q(#{doc_using_statements(doc)} USE: prettyprint\n \\ #{word} see))</string>
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: see\n \\ #{word} see))</string>
        <key>fallbackInput</key>
        <string>word</string>
        <key>input</key>
diff --git a/misc/Factor.tmbundle/Commands/Set Breakpoint.tmCommand b/misc/Factor.tmbundle/Commands/Set Breakpoint.tmCommand
new file mode 100644 (file)
index 0000000..1066c78
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: tools.annotations\n \\ #{word} breakpoint))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^b</string>
+       <key>name</key>
+       <string>Set Breakpoint</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>E4614756-DF2E-433A-8935-197159C67AB8</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Show Using.tmCommand b/misc/Factor.tmbundle/Commands/Show Using.tmCommand
new file mode 100644 (file)
index 0000000..b710e64
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+factor_run(%Q(USING: namespaces parser ;
+auto-use? t set "#{ENV["TM_FILEPATH"]}" run-file auto-use? f set))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>none</string>
+       <key>keyEquivalent</key>
+       <string>^u</string>
+       <key>name</key>
+       <string>Show Using</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>93AF1721-C14D-428A-B5A0-34CEFAA3B3C5</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Usage.tmCommand b/misc/Factor.tmbundle/Commands/Usage.tmCommand
new file mode 100644 (file)
index 0000000..459a7fe
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: tools.crossref\n \\ #{word} usage.))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>name</key>
+       <string>Usage</string>
+       <key>output</key>
+       <string>showAsTooltip</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>3043A033-A113-4283-BCBB-3DE2CCC8F63E</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Vocab Usage.tmCommand b/misc/Factor.tmbundle/Commands/Vocab Usage.tmCommand
new file mode 100644 (file)
index 0000000..70687d9
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(USE: tools.crossref\n "#{word}" vocab-usage.))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>none</string>
+       <key>name</key>
+       <string>Vocab Usage</string>
+       <key>output</key>
+       <string>showAsTooltip</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>B1F81321-B760-474F-875D-78FB52752E1B</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Vocab Uses.tmCommand b/misc/Factor.tmbundle/Commands/Vocab Uses.tmCommand
new file mode 100644 (file)
index 0000000..e8acb98
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(USE: tools.crossref\n "#{word}" vocab-uses.))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>none</string>
+       <key>name</key>
+       <string>Vocab Uses</string>
+       <key>output</key>
+       <string>showAsTooltip</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>BC3E2E39-3B79-460C-B05E-BD00BAACB90E</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Walk Selection.tmCommand b/misc/Factor.tmbundle/Commands/Walk Selection.tmCommand
new file mode 100644 (file)
index 0000000..641e6db
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+puts factor_run(%Q(#{doc_using_statements(doc)} USE: tools.walker\n [ #{ENV["TM_SELECTED_TEXT"]} ] walk))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^w</string>
+       <key>name</key>
+       <string>Walk Selection</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>57C2BAAC-0474-404F-AA91-DFD02EC2A3ED</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Commands/Watch Word.tmCommand b/misc/Factor.tmbundle/Commands/Watch Word.tmCommand
new file mode 100644 (file)
index 0000000..3a4612e
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>beforeRunningCommand</key>
+       <string>nop</string>
+       <key>bundleUUID</key>
+       <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: tools.annotations\n \\ #{word} watch))</string>
+       <key>fallbackInput</key>
+       <string>word</string>
+       <key>input</key>
+       <string>document</string>
+       <key>keyEquivalent</key>
+       <string>^~w</string>
+       <key>name</key>
+       <string>Watch Word</string>
+       <key>output</key>
+       <string>discard</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>1C86869F-1030-4F74-B242-6357A080E127</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Macros/Extract as New Word.tmMacro b/misc/Factor.tmbundle/Macros/Extract as New Word.tmMacro
new file mode 100644 (file)
index 0000000..e1bd296
--- /dev/null
@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>commands</key>
+       <array>
+               <dict>
+                       <key>command</key>
+                       <string>cut:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>m</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>y</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>-</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>w</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>o</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>r</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>d</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <dict>
+                               <key>action</key>
+                               <string>findPrevious</string>
+                               <key>findInProjectIgnoreCase</key>
+                               <true/>
+                               <key>findString</key>
+                               <string>: </string>
+                               <key>ignoreCase</key>
+                               <true/>
+                               <key>replaceAllScope</key>
+                               <string>document</string>
+                               <key>replaceString</key>
+                               <string>table</string>
+                               <key>wrapAround</key>
+                               <true/>
+                       </dict>
+                       <key>command</key>
+                       <string>findWithOptions:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>moveToBeginningOfLine:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>paste:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>moveToBeginningOfLineAndModifySelection:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <dict>
+                               <key>beforeRunningCommand</key>
+                               <string>nop</string>
+                               <key>command</key>
+                               <string>#!/usr/bin/env ruby
+
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+
+doc = STDIN.read
+puts factor_eval(%Q(#{doc_using_statements(doc)} USE: stack-checker\n [ #{ENV["TM_SELECTED_TEXT"]} ] infer.))</string>
+                               <key>fallbackInput</key>
+                               <string>word</string>
+                               <key>input</key>
+                               <string>document</string>
+                               <key>name</key>
+                               <string>Insert Inferrence</string>
+                               <key>output</key>
+                               <string>afterSelectedText</string>
+                               <key>scope</key>
+                               <string>source.factor</string>
+                               <key>uuid</key>
+                               <string>DBC0A0CA-5368-43A7-864B-7B9C4034AD08</string>
+                       </dict>
+                       <key>command</key>
+                       <string>executeCommandWithOptions:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>insertNewline:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <dict>
+                               <key>action</key>
+                               <string>findPrevious</string>
+                               <key>findInProjectIgnoreCase</key>
+                               <true/>
+                               <key>findString</key>
+                               <string>(</string>
+                               <key>ignoreCase</key>
+                               <true/>
+                               <key>replaceAllScope</key>
+                               <string>document</string>
+                               <key>replaceString</key>
+                               <string>table</string>
+                               <key>wrapAround</key>
+                               <true/>
+                       </dict>
+                       <key>command</key>
+                       <string>findWithOptions:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>moveToEndOfLineAndModifySelection:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>cut:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string> </string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>;</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>moveToBeginningOfLine:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>:</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string> </string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>m</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>y</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>-</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>w</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>o</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>r</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string>d</string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string> </string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+               <dict>
+                       <key>command</key>
+                       <string>paste:</string>
+               </dict>
+               <dict>
+                       <key>argument</key>
+                       <string> </string>
+                       <key>command</key>
+                       <string>insertText:</string>
+               </dict>
+       </array>
+       <key>keyEquivalent</key>
+       <string>@W</string>
+       <key>name</key>
+       <string>Extract as New Word</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>82E740D1-8D20-48AF-8470-C85C251D4870</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Preferences/Miscellaneous.tmPreferences b/misc/Factor.tmbundle/Preferences/Miscellaneous.tmPreferences
new file mode 100644 (file)
index 0000000..fa19e50
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>name</key>
+       <string>Miscellaneous</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>settings</key>
+       <dict>
+               <key>increaseIndentPattern</key>
+               <string>^:</string>
+               <key>shellVariables</key>
+               <array>
+                       <dict>
+                               <key>name</key>
+                               <string>TM_COMMENT_START</string>
+                               <key>value</key>
+                               <string>! </string>
+                       </dict>
+               </array>
+       </dict>
+       <key>uuid</key>
+       <string>D60675B0-9BF4-4CCF-9066-CA14FE836981</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/[ expanded.tmSnippet b/misc/Factor.tmbundle/Snippets/[ expanded.tmSnippet
new file mode 100644 (file)
index 0000000..19035a1
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>[
+   $TM_SELECTED_TEXT$0
+]</string>
+       <key>keyEquivalent</key>
+       <string>~[</string>
+       <key>name</key>
+       <string>[ expanded</string>
+       <key>scope</key>
+       <string>source.factor
+</string>
+       <key>tabTrigger</key>
+       <string>“</string>
+       <key>uuid</key>
+       <string>F771F82B-6B2B-4DAE-9A2A-E1042D3B08AD</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/[.tmSnippet b/misc/Factor.tmbundle/Snippets/[.tmSnippet
new file mode 100644 (file)
index 0000000..94cd7f7
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>[ $TM_SELECTED_TEXT$0 ]</string>
+       <key>keyEquivalent</key>
+       <string>[</string>
+       <key>name</key>
+       <string>[</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>[</string>
+       <key>uuid</key>
+       <string>3F17AF0F-4DE0-4A86-A649-CB65907F0DA5</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/bi.tmSnippet b/misc/Factor.tmbundle/Snippets/bi.tmSnippet
new file mode 100644 (file)
index 0000000..401ba70
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>
+   [ $1 ]
+   [ $2 ] bi</string>
+       <key>name</key>
+       <string>bi</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>bi</string>
+       <key>uuid</key>
+       <string>8D69F968-D322-4008-A540-209B32A97F5D</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/cleave.tmSnippet b/misc/Factor.tmbundle/Snippets/cleave.tmSnippet
new file mode 100644 (file)
index 0000000..ab77ff0
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>{
+   [ $1 ]
+   [ $2 ]
+   [ $3 ]
+   [ $4 ]
+} cleave</string>
+       <key>name</key>
+       <string>cleave</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>cleave</string>
+       <key>uuid</key>
+       <string>E51383D9-1C82-4ACE-AE45-633E6CE35245</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/cond.tmSnippet b/misc/Factor.tmbundle/Snippets/cond.tmSnippet
new file mode 100644 (file)
index 0000000..1b2f326
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>{
+  { [ $1 ] [ $2 ] }
+  { [ $3 ] [ $4 ] }
+$5} cond </string>
+       <key>name</key>
+       <string>cond</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>cond</string>
+       <key>uuid</key>
+       <string>C8E068DE-A117-43AE-9916-99AF2C21BD24</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/functor.tmSnippet b/misc/Factor.tmbundle/Snippets/functor.tmSnippet
new file mode 100644 (file)
index 0000000..39c1a85
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>
+FUNCTOR: $1 ( $2 -- $3 )
+$4
+WHERE
+$0
+;FUNCTOR
+</string>
+       <key>name</key>
+       <string>functor</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>functor</string>
+       <key>uuid</key>
+       <string>B9DA0999-D710-4693-8056-9E4B8BDAC7E9</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/if.tmSnippet b/misc/Factor.tmbundle/Snippets/if.tmSnippet
new file mode 100644 (file)
index 0000000..83bb519
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>
+   [ $1 ]
+   [ $2 ] if</string>
+       <key>name</key>
+       <string>if</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>if</string>
+       <key>uuid</key>
+       <string>AD9D0A71-2371-4756-86D7-A084B4A3FE2F</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/lambda word def.tmSnippet b/misc/Factor.tmbundle/Snippets/lambda word def.tmSnippet
new file mode 100644 (file)
index 0000000..83c394d
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>:: $1 ( $2 -- $3 ) $0 ;</string>
+       <key>name</key>
+       <string>::</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>::</string>
+       <key>uuid</key>
+       <string>9A96D386-F7B9-47DC-9CAE-E4BAD1F81748</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/let.tmSnippet b/misc/Factor.tmbundle/Snippets/let.tmSnippet
new file mode 100644 (file)
index 0000000..f1e8a38
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>
+   [let | $1 [ $2 ] $3|
+      $0
+   ]</string>
+       <key>name</key>
+       <string>let</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>let</string>
+       <key>uuid</key>
+       <string>1B3CF04D-B23D-4D9A-A648-7191315CDF96</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/spread.tmSnippet b/misc/Factor.tmbundle/Snippets/spread.tmSnippet
new file mode 100644 (file)
index 0000000..8193a7d
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>{
+   [ $1 ]
+   [ $2 ]
+   [ $3 ]
+   [ $4 ]
+} spread</string>
+       <key>name</key>
+       <string>spread</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>spread</string>
+       <key>uuid</key>
+       <string>3DE1C097-6F69-4562-9C49-C897FF5AB909</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/tri.tmSnippet b/misc/Factor.tmbundle/Snippets/tri.tmSnippet
new file mode 100644 (file)
index 0000000..5dcb037
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>
+   [ $1 ]
+   [ $2 ]
+   [ $3 ] tri</string>
+       <key>name</key>
+       <string>tri</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>tri</string>
+       <key>uuid</key>
+       <string>B8B7B5ED-C75C-4BD1-906A-220C9956F91F</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/word def.tmSnippet b/misc/Factor.tmbundle/Snippets/word def.tmSnippet
new file mode 100644 (file)
index 0000000..48bf5b2
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>: $1 ( $2 -- $3 ) $0 ;</string>
+       <key>name</key>
+       <string>:</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>:</string>
+       <key>uuid</key>
+       <string>7903894E-CB75-43ED-8635-C0E65F94DEBB</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/{ expanded.tmSnippet b/misc/Factor.tmbundle/Snippets/{ expanded.tmSnippet
new file mode 100644 (file)
index 0000000..e6e3ffe
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>{
+   $TM_SELECTED_TEXT$0
+}</string>
+       <key>keyEquivalent</key>
+       <string>~{</string>
+       <key>name</key>
+       <string>{ expanded</string>
+       <key>scope</key>
+       <string>source.factor
+</string>
+       <key>uuid</key>
+       <string>275EA395-6026-481A-81C5-1F71D8026972</string>
+</dict>
+</plist>
diff --git a/misc/Factor.tmbundle/Snippets/{.tmSnippet b/misc/Factor.tmbundle/Snippets/{.tmSnippet
new file mode 100644 (file)
index 0000000..ff5141b
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>content</key>
+       <string>{ $TM_SELECTED_TEXT$0 }</string>
+       <key>keyEquivalent</key>
+       <string>{</string>
+       <key>name</key>
+       <string>{</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>tabTrigger</key>
+       <string>[</string>
+       <key>uuid</key>
+       <string>B4448FB0-B7F9-4FFD-AB4B-EAD31A5920CB</string>
+</dict>
+</plist>
index 2775a12ae9f621af1272a8a5bad41c186c4b1bbb..48f318651a4508fc4bddc7d6557b032408e539c2 100644 (file)
@@ -32,6 +32,10 @@ def doc_using_statements(document)
     document.scan(/\b(USING:\s[^;]*\s;|USE:\s+\S+|IN:\s\S+)/).join("\n") << "\n"
 end
 
+def doc_vocab(document) 
+  document.sub(/\bIN:\s(\S+)/, %Q("\\1"))
+end
+
 def line_current_word(line, point)
     left = line.rindex(/\s/, point - 1) || 0; right = line.index(/\s/, point) || line.length
     line[left..right]
diff --git a/misc/Factor.tmbundle/Templates/Vocabulary.tmTemplate/info.plist b/misc/Factor.tmbundle/Templates/Vocabulary.tmTemplate/info.plist
new file mode 100644 (file)
index 0000000..1ee1c3a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>command</key>
+       <string>#!/usr/bin/env ruby
+require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
+require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
+
+a = TextMate::UI.request_string(:title =&gt; "Scaffold Setup", :prompt =&gt;
+"Vocab Name:")
+b = ENV["TM_FILEPATH"]
+if b then c = b[/\/factor\/([^\/]+)\//,1]
+else c = "work"
+end
+factor_eval(%Q(USING: kernel editors tools.scaffold ; "#{a}" dup #{"scaffold-" &lt;&lt; c} edit-vocab))</string>
+       <key>extension</key>
+       <string>factor</string>
+       <key>keyEquivalent</key>
+       <string>@N</string>
+       <key>name</key>
+       <string>Vocabulary</string>
+       <key>scope</key>
+       <string>source.factor</string>
+       <key>uuid</key>
+       <string>B6D1D91E-3EF3-4112-97DF-BFCABEBAA1C9</string>
+</dict>
+</plist>
index 1ea756a1a5855affdbcfe6355d4ab3625955cb3a..15362802e4dc5ed3b2d691ec5d5e88db002b1cfa 100644 (file)
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+       <key>deleted</key>
+       <array/>
+       <key>mainMenu</key>
+       <dict>
+               <key>excludedItems</key>
+               <array>
+                       <string>DBC0A0CA-5368-43A7-864B-7B9C4034AD08</string>
+                       <string>1B3CF04D-B23D-4D9A-A648-7191315CDF96</string>
+                       <string>3F17AF0F-4DE0-4A86-A649-CB65907F0DA5</string>
+                       <string>B4448FB0-B7F9-4FFD-AB4B-EAD31A5920CB</string>
+                       <string>C8E068DE-A117-43AE-9916-99AF2C21BD24</string>
+                       <string>AD9D0A71-2371-4756-86D7-A084B4A3FE2F</string>
+                       <string>8D69F968-D322-4008-A540-209B32A97F5D</string>
+                       <string>B8B7B5ED-C75C-4BD1-906A-220C9956F91F</string>
+                       <string>E51383D9-1C82-4ACE-AE45-633E6CE35245</string>
+                       <string>3DE1C097-6F69-4562-9C49-C897FF5AB909</string>
+                       <string>B9DA0999-D710-4693-8056-9E4B8BDAC7E9</string>
+                       <string>7903894E-CB75-43ED-8635-C0E65F94DEBB</string>
+                       <string>9A96D386-F7B9-47DC-9CAE-E4BAD1F81748</string>
+                       <string>F771F82B-6B2B-4DAE-9A2A-E1042D3B08AD</string>
+                       <string>275EA395-6026-481A-81C5-1F71D8026972</string>
+               </array>
+               <key>items</key>
+               <array>
+                       <string>8088D204-FFD7-4384-8FDD-A01536FFD0E7</string>
+                       <string>CAD3BB10-C480-4C0E-9518-94D61F7A0C0B</string>
+                       <string>82E740D1-8D20-48AF-8470-C85C251D4870</string>
+                       <string>D348BE40-6F51-4471-B300-DDDA70ED8C8C</string>
+                       <string>9D99C141-EC9D-4C9E-9C08-0CA4EAEA2F3E</string>
+                       <string>1C72489C-15A1-4B44-BCDF-438962D4F3EB</string>
+                       <string>9E5EC5B6-AABD-4657-A663-D3C558051216</string>
+                       <string>219C4AB2-742E-48FE-92E1-CB2EC19C8A24</string>
+                       <string>D25BF2AE-0595-44AE-B97A-9F20D4E28173</string>
+                       <string>93AF1721-C14D-428A-B5A0-34CEFAA3B3C5</string>
+               </array>
+               <key>submenus</key>
+               <dict>
+                       <key>1C72489C-15A1-4B44-BCDF-438962D4F3EB</key>
+                       <dict>
+                               <key>items</key>
+                               <array>
+                                       <string>3043A033-A113-4283-BCBB-3DE2CCC8F63E</string>
+                                       <string>B1F81321-B760-474F-875D-78FB52752E1B</string>
+                                       <string>BC3E2E39-3B79-460C-B05E-BD00BAACB90E</string>
+                               </array>
+                               <key>name</key>
+                               <string>Cross Ref</string>
+                       </dict>
+                       <key>219C4AB2-742E-48FE-92E1-CB2EC19C8A24</key>
+                       <dict>
+                               <key>items</key>
+                               <array>
+                                       <string>57C2BAAC-0474-404F-AA91-DFD02EC2A3ED</string>
+                                       <string>E4614756-DF2E-433A-8935-197159C67AB8</string>
+                                       <string>1C86869F-1030-4F74-B242-6357A080E127</string>
+                                       <string>71F08D9B-3D24-4E78-84C9-82CA736554D1</string>
+                               </array>
+                               <key>name</key>
+                               <string>Debugging</string>
+                       </dict>
+                       <key>9D99C141-EC9D-4C9E-9C08-0CA4EAEA2F3E</key>
+                       <dict>
+                               <key>items</key>
+                               <array>
+                                       <string>D02D9D74-E073-48AE-A78E-B40FFFA519D5</string>
+                                       <string>C573487C-DD7D-497F-A728-52D7962D95E2</string>
+                                       <string>D95A617C-E1C6-44DA-9126-04171CB21299</string>
+                                       <string>0034EC1C-DAD1-498F-82FD-BEF7015F84EE</string>
+                               </array>
+                               <key>name</key>
+                               <string>Edit</string>
+                       </dict>
+                       <key>9E5EC5B6-AABD-4657-A663-D3C558051216</key>
+                       <dict>
+                               <key>items</key>
+                               <array>
+                                       <string>7FF52332-CA5B-4D46-99EF-DAE0659DB478</string>
+                                       <string>15A984BD-BC65-43E8-878A-267788C8DA70</string>
+                                       <string>8E01DDAF-959B-4237-ADB9-C133A4ACCE90</string>
+                                       <string>B619FCC0-2DF2-4657-82A8-0E5676A10254</string>
+                                       <string>8465B33D-7CA0-4337-945C-4078346D64BC</string>
+                               </array>
+                               <key>name</key>
+                               <string>Tools</string>
+                       </dict>
+                       <key>D25BF2AE-0595-44AE-B97A-9F20D4E28173</key>
+                       <dict>
+                               <key>items</key>
+                               <array>
+                                       <string>35484754-DBF9-4381-BB25-00CAB64DF4A1</string>
+                                       <string>BC5BE120-734B-40DF-8B6B-5D3243614B27</string>
+                               </array>
+                               <key>name</key>
+                               <string>Help</string>
+                       </dict>
+               </dict>
+       </dict>
        <key>name</key>
        <string>Factor</string>
        <key>ordering</key>
        <array>
                <string>3C9C9C2A-314A-475B-A4E4-A68BAAF3F36E</string>
+               <string>D60675B0-9BF4-4CCF-9066-CA14FE836981</string>
                <string>141517D7-73E0-4475-A481-71102575A175</string>
+               <string>B6D1D91E-3EF3-4112-97DF-BFCABEBAA1C9</string>
                <string>CAD3BB10-C480-4C0E-9518-94D61F7A0C0B</string>
+               <string>8088D204-FFD7-4384-8FDD-A01536FFD0E7</string>
                <string>15A984BD-BC65-43E8-878A-267788C8DA70</string>
                <string>8E01DDAF-959B-4237-ADB9-C133A4ACCE90</string>
                <string>35484754-DBF9-4381-BB25-00CAB64DF4A1</string>
                <string>BC5BE120-734B-40DF-8B6B-5D3243614B27</string>
                <string>B619FCC0-2DF2-4657-82A8-0E5676A10254</string>
+               <string>DBC0A0CA-5368-43A7-864B-7B9C4034AD08</string>
+               <string>93AF1721-C14D-428A-B5A0-34CEFAA3B3C5</string>
+               <string>3043A033-A113-4283-BCBB-3DE2CCC8F63E</string>
+               <string>B1F81321-B760-474F-875D-78FB52752E1B</string>
+               <string>BC3E2E39-3B79-460C-B05E-BD00BAACB90E</string>
+               <string>8465B33D-7CA0-4337-945C-4078346D64BC</string>
+               <string>57C2BAAC-0474-404F-AA91-DFD02EC2A3ED</string>
+               <string>1C86869F-1030-4F74-B242-6357A080E127</string>
+               <string>E4614756-DF2E-433A-8935-197159C67AB8</string>
+               <string>D02D9D74-E073-48AE-A78E-B40FFFA519D5</string>
+               <string>C573487C-DD7D-497F-A728-52D7962D95E2</string>
+               <string>0034EC1C-DAD1-498F-82FD-BEF7015F84EE</string>
+               <string>D95A617C-E1C6-44DA-9126-04171CB21299</string>
+               <string>71F08D9B-3D24-4E78-84C9-82CA736554D1</string>
+               <string>7FF52332-CA5B-4D46-99EF-DAE0659DB478</string>
+               <string>D348BE40-6F51-4471-B300-DDDA70ED8C8C</string>
+               <string>1B3CF04D-B23D-4D9A-A648-7191315CDF96</string>
+               <string>3F17AF0F-4DE0-4A86-A649-CB65907F0DA5</string>
+               <string>F771F82B-6B2B-4DAE-9A2A-E1042D3B08AD</string>
+               <string>B4448FB0-B7F9-4FFD-AB4B-EAD31A5920CB</string>
+               <string>275EA395-6026-481A-81C5-1F71D8026972</string>
+               <string>C8E068DE-A117-43AE-9916-99AF2C21BD24</string>
+               <string>AD9D0A71-2371-4756-86D7-A084B4A3FE2F</string>
+               <string>8D69F968-D322-4008-A540-209B32A97F5D</string>
+               <string>B8B7B5ED-C75C-4BD1-906A-220C9956F91F</string>
+               <string>E51383D9-1C82-4ACE-AE45-633E6CE35245</string>
+               <string>3DE1C097-6F69-4562-9C49-C897FF5AB909</string>
+               <string>B9DA0999-D710-4693-8056-9E4B8BDAC7E9</string>
+               <string>7903894E-CB75-43ED-8635-C0E65F94DEBB</string>
+               <string>9A96D386-F7B9-47DC-9CAE-E4BAD1F81748</string>
+               <string>82E740D1-8D20-48AF-8470-C85C251D4870</string>
        </array>
        <key>uuid</key>
        <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
index 1659d1897ee9916c99ff2be209f340fece605de4..d094919c74f2ebf49a2b934d4a5eabdc2def660e 100644 (file)
@@ -39,15 +39,15 @@ syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
 syn match factorComment /\<#! .*/ contains=factorTodo
 syn match factorComment /\<! .*/ contains=factorTodo
 
-syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorArray0,factorQuotation0
+syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorLiteralStackEffect,factorArray0,factorQuotation0
 
-syn region factorDefn matchgroup=factorDefnDelims start=/\<\(MACRO\|MACRO::\|MEMO:\|MEMO::\|:\|::\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
-syn region factorMethod matchgroup=factorMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
+syn region factorDefn matchgroup=factorDefnDelims start=/\<\(SYNTAX\|\(MACRO\|MEMO\)\?:\?\):\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
+syn region factorMethod matchgroup=factorMethodDelims start=/\<M::\?\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
 syn region factorGeneric matchgroup=factorGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect
 syn region factorGenericN matchgroup=factorGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
 
-syn region factorPrivateDefn matchgroup=factorPrivateDefnDelims start=/\<\(MACRO\|MACRO::\|MEMO:\|MEMO::\|:\|::\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
-syn region factorPrivateMethod matchgroup=factorPrivateMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
+syn region factorPrivateDefn matchgroup=factorPrivateDefnDelims start=/\<\(SYNTAX\|\(MACRO\|MEMO\)\?:\?\):\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
+syn region factorPrivateMethod matchgroup=factorPrivateMethodDelims start=/\<M::\?\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
 syn region factorPGeneric matchgroup=factorPGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect contained
 syn region factorPGenericN matchgroup=factorPGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
 
@@ -55,7 +55,7 @@ syn region None matchgroup=factorPrivate start=/\<<PRIVATE\>/ end=/\<PRIVATE>\>/
 
 
 syn keyword factorBoolean boolean f general-t t
-syn keyword factorCompileDirective inline foldable parsing
+syn keyword factorCompileDirective inline foldable recursive
 
 <%
 
@@ -149,37 +149,39 @@ syn match factorMultiStringContents /.*/ contained
 
 "syn match factorStackEffectErr /\<)\>/
 "syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
-syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
+"syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
+syn match factorStackEffect /\<( .*--.* )\>/ contained
+syn match factorLiteralStackEffect /\<(( .*--.* ))\>/
 
 "adapted from lisp.vim
 if exists("g:factor_norainbow") 
-    syn region factorQuotation matchgroup=factorDelimiter start=/\<\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
+    syn region factorQuotation matchgroup=factorDelimiter start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
 else
-    syn region factorQuotation0           matchgroup=hlLevel0 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
-    syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
-    syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
-    syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
-    syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
-    syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
-    syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
-    syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
-    syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
-    syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
+    syn region factorQuotation0           matchgroup=hlLevel0 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
+    syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
+    syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
+    syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
+    syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
+    syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
+    syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
+    syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
+    syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
+    syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
 endif
 
 if exists("g:factor_norainbow") 
-    syn region factorArray    matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/  matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
+    syn region factorArray    matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/  matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
 else
-    syn region factorArray0           matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
-    syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
-    syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
-    syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
-    syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
-    syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
-    syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
-    syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
-    syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
-    syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
+    syn region factorArray0           matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
+    syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
+    syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
+    syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
+    syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
+    syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
+    syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
+    syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
+    syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
+    syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
 endif
 
 syn match factorBracketErr /\<\]\>/
@@ -197,6 +199,7 @@ if version >= 508 || !exists("did_factor_syn_inits")
 
     HiLink factorComment                Comment
     HiLink factorStackEffect            Typedef
+    HiLink factorLiteralStackEffect     Typedef
     HiLink factorTodo                   Todo
     HiLink factorInclude                Include
     HiLink factorRepeat                 Repeat
@@ -283,7 +286,7 @@ endif
 let b:current_syntax = "factor"
 
 set sw=4
-set ts=4
+set sts=4
 set expandtab
 set autoindent " annoying?
 
index fee762d09a05921da0266b201ecd918db7f4bcae..ab8b636a6a61370ccd8fe5acb1f0f905340aec70 100644 (file)
@@ -1,6 +1,6 @@
 ;;; fuel-log.el -- logging utilities
 
-;; Copyright (C) 2008 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz
 ;; See http://factorcode.org/license.txt for BSD license.
 
 ;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
@@ -34,6 +34,9 @@
 (defvar fuel-log--inhibit-p nil
   "Set this to t to inhibit all log messages")
 
+(defvar fuel-log--debug-p nil
+  "If t, all messages are logged no matter what")
+
 (define-derived-mode factor-messages-mode fundamental-mode "FUEL Messages"
   "Simple mode to log interactions with the factor listener"
   (kill-all-local-variables)
@@ -55,7 +58,7 @@
         (current-buffer))))
 
 (defun fuel-log--msg (type &rest args)
-  (unless fuel-log--inhibit-p
+  (when (or fuel-log--debug-p (not fuel-log--inhibit-p))
     (with-current-buffer (fuel-log--buffer)
       (let ((inhibit-read-only t))
         (insert
index bede15145851aa207bc704ebd8884903fd047308..431427120aa7f7c6e988f65284a7e4b31f611b6a 100644 (file)
@@ -20,9 +20,7 @@ Note: The syntax-highlighting file is automatically generated to include the
 names of all the vocabularies Factor knows about. To regenerate it manually,
 run the following code in the listener:
 
-    USE: editors.vim.generate-syntax
-
-    generate-vim-syntax
+    "editors.vim.generate-syntax" run
 
 ...or run it from the command-line:
 
old mode 100755 (executable)
new mode 100644 (file)
index 8da5001..1d89c1c
@@ -1,3 +1,4 @@
+
 " Vim syntax file
 " Language: factor
 " Maintainer: Alex Chapman <chapman.alex@gmail.com>
@@ -28,15 +29,15 @@ syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
 syn match factorComment /\<#! .*/ contains=factorTodo
 syn match factorComment /\<! .*/ contains=factorTodo
 
-syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorArray0,factorQuotation0
+syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorLiteralStackEffect,factorArray0,factorQuotation0
 
-syn region factorDefn matchgroup=factorDefnDelims start=/\<\(MACRO\|MEMO\|:\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
-syn region factorMethod matchgroup=factorMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
+syn region factorDefn matchgroup=factorDefnDelims start=/\<\(SYNTAX\|\(MACRO\|MEMO\)\?:\?\):\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
+syn region factorMethod matchgroup=factorMethodDelims start=/\<M::\?\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
 syn region factorGeneric matchgroup=factorGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect
 syn region factorGenericN matchgroup=factorGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
 
-syn region factorPrivateDefn matchgroup=factorPrivateDefnDelims start=/\<\(MACRO\|MEMO\|:\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
-syn region factorPrivateMethod matchgroup=factorPrivateMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
+syn region factorPrivateDefn matchgroup=factorPrivateDefnDelims start=/\<\(SYNTAX\|\(MACRO\|MEMO\)\?:\?\):\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
+syn region factorPrivateMethod matchgroup=factorPrivateMethodDelims start=/\<M::\?\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
 syn region factorPGeneric matchgroup=factorPGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect contained
 syn region factorPGenericN matchgroup=factorPGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
 
@@ -44,13 +45,13 @@ syn region None matchgroup=factorPrivate start=/\<<PRIVATE\>/ end=/\<PRIVATE>\>/
 
 
 syn keyword factorBoolean boolean f general-t t
-syn keyword factorCompileDirective inline foldable parsing
+syn keyword factorCompileDirective inline foldable recursive
 
 syn keyword factorKeyword or tuck 2bi 2tri while wrapper nip 4dip wrapper? bi* callstack>array both? hashcode die dupd callstack callstack? 3dup tri@ pick curry build ?execute 3bi prepose >boolean ?if clone eq? tri* ? = swapd call-clear 2over 2keep 3keep clear 2dup when not tuple? dup 2bi* 2tri* call tri-curry object bi@ do unless* if* loop bi-curry* drop when* assert= retainstack assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi curry? datastack until 3dip over 3curry roll tri-curry* swap tri-curry@ 2nip and throw set-retainstack bi-curry (clone) hashcode* compose spin 2dip if 3tri unless compose? tuple keep 2curry equal? set-datastack assert tri 2drop most <wrapper> boolean? identity-tuple? null new set-callstack dip bi-curry@ rot -roll xor identity-tuple boolean
-syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map <enum> assoc assoc-map enum value-at* remove-all assoc-map-as >alist assoc-filter-as substitute-here clear-assoc assoc-stack substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? unzip
-syn keyword factorKeyword case execute-effect dispatch-case-quot <buckets> no-cond no-case? 3cleave>quot contiguous-range? 2cleave cond>quot wrong-values? no-cond? cleave>quot no-case hash-dispatch-quot case>quot 3cleave wrong-values alist>quot hash-case-table hash-case-quot case-find (distribute-buckets) cond cleave distribute-buckets call-effect 2cleave>quot recursive-hashcode linear-case-quot spread spread>quot
+syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect assoc-refine update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map <enum> assoc assoc-map enum value-at* remove-all assoc-map-as >alist assoc-filter-as substitute-here clear-assoc assoc-stack maybe-set-at substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? unzip
+syn keyword factorKeyword case execute-effect no-cond no-case? 3cleave>quot 2cleave cond>quot wrong-values? no-cond? cleave>quot no-case case>quot 3cleave wrong-values to-fixed-point alist>quot case-find cond cleave call-effect 2cleave>quot recursive-hashcode linear-case-quot spread spread>quot
 syn keyword factorKeyword byte-array>bignum sgn >bignum next-float number= each-integer next-power-of-2 ?1+ fp-special? imaginary-part mod recip float>bits rational >float number? 2^ bignum? integer fixnum? neg fixnum sq bignum fp-snan? fp-infinity? denominator (all-integers?) times find-last-integer (each-integer) bit? * + fp-bitwise= - fp-qnan? / power-of-2? >= bitand find-integer complex <fp-nan> < log2 > integer? real number bits>double double>bits bitor 2/ zero? rem fp-nan-payload all-integers? (find-integer) real-part prev-float align bits>float float? shift float 1+ 1- fp-nan? abs bitxor ratio? even? <= /mod odd? >integer ratio rational? bitnot real? >fixnum complex? /i numerator /f
-syn keyword factorKeyword append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter-here last-index-from prepare-index reversed index-from cut* pad-tail (indices) concat-as remq but-last snip trim-tail nths nth 2pusher sequence slice? <slice> partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length delq drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift delete sigma new-sequence follow like delete-nth first4 1sequence reverse slice unless-empty padding virtual@ repetition? index 4sequence max-length set-second immutable-sequence first2 first3 replicate-as reduce-index unclip-slice supremum insert-nth trim-tail-slice tail 3append short count suffix concat flip filter sum immutable? 2sequence delete-all start* indices snip-slice check-slice sequence? head map-find reduce append-as reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check harvest immutable find produce remove pad-head replicate set-fourth peek shorten reversed? map-find-last 3map-as 2unclip-slice shorter? 3map find-last head-slice pop* 2map-as tail-slice* but-last-slice 2map-reduce iota? accumulate each pusher cut-slice new-resizable each-index head-slice* 2reverse-each sequence-hashcode memq? pop set-nth ?nth <flat-slice> second change-each join when-empty accumulator immutable-sequence? <reversed> all? 3append-as virtual-sequence subseq? push-either new-like length last-index push-if 2all? lengthen assert-sequence copy map-reduce move third first 3each tail? set-first prefix bounds-error any? <repetition> trim-slice exchange surround 2reduce cut change-nth min-length set-third produce-as push-all head? delete-slice rest sum-lengths 2each head* infimum glue slice-error subseq replace-slice push repetition map-index trim-head unclip-last mismatch trim
+syn keyword factorKeyword append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter-here last-index-from reversed index-from cut* pad-tail (indices) concat-as remq but-last snip trim-tail nths nth 2pusher sequence slice? <slice> partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length delq drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift delete sigma new-sequence follow like delete-nth first4 1sequence reverse slice unless-empty padding virtual@ repetition? set-last index 4sequence max-length set-second immutable-sequence first2 first3 replicate-as reduce-index unclip-slice supremum insert-nth trim-tail-slice tail 3append short count suffix concat flip filter sum immutable? 2sequence map-integers delete-all start* indices snip-slice check-slice sequence? head map-find reduce append-as reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check harvest immutable find produce remove pad-head last replicate set-fourth shorten reversed? map-find-last 3map-as 2unclip-slice shorter? 3map find-last head-slice pop* 2map-as tail-slice* but-last-slice 2map-reduce iota? accumulate each pusher cut-slice new-resizable each-index head-slice* 2reverse-each sequence-hashcode memq? pop set-nth ?nth <flat-slice> second change-each join when-empty accumulator immutable-sequence? <reversed> all? 3append-as virtual-sequence subseq? push-either new-like length last-index push-if 2all? lengthen assert-sequence copy map-reduce move third first 3each tail? set-first prefix bounds-error any? <repetition> trim-slice exchange surround 2reduce cut change-nth min-length set-third produce-as push-all head? delete-slice rest sum-lengths 2each head* infimum glue slice-error subseq replace-slice push repetition map-index trim-head unclip-last mismatch trim
 syn keyword factorKeyword global +@ change set-namestack change-global init-namespaces on off set-global namespace set with-scope bind with-variable inc dec counter initialize namestack get get-global make-assoc
 syn keyword factorKeyword <array> 2array 3array pair >array 1array 4array pair? array resize-array array?
 syn keyword factorKeyword +character+ bad-seek-type? readln stream-seek read print with-output-stream contents write1 stream-write1 stream-copy stream-element-type with-input-stream stream-print stream-read stream-contents bl seek-output bad-seek-type nl stream-nl write flush stream-lines +byte+ stream-flush read1 seek-absolute? stream-read1 lines stream-readln stream-read-until each-line seek-end with-output-stream* seek-absolute with-streams seek-input seek-relative? input-stream stream-write read-partial seek-end? seek-relative error-stream read-until with-input-stream* with-streams* each-block output-stream stream-read-partial
@@ -136,37 +137,39 @@ syn match factorMultiStringContents /.*/ contained
 
 "syn match factorStackEffectErr /\<)\>/
 "syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
-syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
+"syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
+syn match factorStackEffect /\<( .*--.* )\>/ contained
+syn match factorLiteralStackEffect /\<(( .*--.* ))\>/
 
 "adapted from lisp.vim
 if exists("g:factor_norainbow") 
-    syn region factorQuotation matchgroup=factorDelimiter start=/\<\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
+    syn region factorQuotation matchgroup=factorDelimiter start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
 else
-    syn region factorQuotation0           matchgroup=hlLevel0 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
-    syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
-    syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
-    syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
-    syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
-    syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
-    syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
-    syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
-    syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
-    syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
+    syn region factorQuotation0           matchgroup=hlLevel0 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
+    syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
+    syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
+    syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
+    syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
+    syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
+    syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
+    syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
+    syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
+    syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\(\('\|\$\|\)\[\)\|\[\(let\||\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
 endif
 
 if exists("g:factor_norainbow") 
-    syn region factorArray    matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/  matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
+    syn region factorArray    matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/  matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
 else
-    syn region factorArray0           matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
-    syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
-    syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
-    syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
-    syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
-    syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
-    syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
-    syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
-    syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
-    syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
+    syn region factorArray0           matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
+    syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
+    syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
+    syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
+    syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
+    syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
+    syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
+    syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
+    syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
+    syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\|F\|B\|\$\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
 endif
 
 syn match factorBracketErr /\<\]\>/
@@ -184,6 +187,7 @@ if version >= 508 || !exists("did_factor_syn_inits")
 
     HiLink factorComment                Comment
     HiLink factorStackEffect            Typedef
+    HiLink factorLiteralStackEffect     Typedef
     HiLink factorTodo                   Todo
     HiLink factorInclude                Include
     HiLink factorRepeat                 Repeat
@@ -270,8 +274,9 @@ endif
 let b:current_syntax = "factor"
 
 set sw=4
-set ts=4
+set sts=4
 set expandtab
 set autoindent " annoying?
 
 " vim: syntax=vim
+
diff --git a/unmaintained/modules/remote-loading/authors.txt b/unmaintained/modules/remote-loading/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/unmaintained/modules/remote-loading/remote-loading.factor b/unmaintained/modules/remote-loading/remote-loading.factor
deleted file mode 100644 (file)
index 7a51f24..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: modules.rpc-server vocabs ;
-IN: modules.remote-loading mem-service
-
-: get-vocab ( vocabstr -- vocab ) vocab ;
\ No newline at end of file
diff --git a/unmaintained/modules/remote-loading/summary.txt b/unmaintained/modules/remote-loading/summary.txt
deleted file mode 100644 (file)
index 304f855..0000000
+++ /dev/null
@@ -1 +0,0 @@
-required for listeners allowing remote loading of modules
\ No newline at end of file
diff --git a/unmaintained/modules/rpc-server/authors.txt b/unmaintained/modules/rpc-server/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/unmaintained/modules/rpc-server/rpc-server.factor b/unmaintained/modules/rpc-server/rpc-server.factor
deleted file mode 100644 (file)
index 0c881ad..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-USING: accessors assocs continuations effects io
-io.encodings.binary io.servers.connection kernel
-memoize namespaces parser sets sequences serialize
-threads vocabs vocabs.parser words ;
-IN: modules.rpc-server
-
-SYMBOL: serving-vocabs V{ } clone serving-vocabs set-global
-
-: do-rpc ( args word -- bytes )
-    [ execute ] curry with-datastack object>bytes ; inline
-
-MEMO: mem-do-rpc ( args word -- bytes ) do-rpc ; inline
-
-: process ( vocabspec -- )
-    vocab-words [ deserialize ] dip deserialize
-    swap at "executer" get execute( args word -- bytes ) write flush ;
-
-: (serve) ( -- )
-    deserialize dup serving-vocabs get-global index
-    [ process ] [ drop ] if ;
-
-: start-serving-vocabs ( -- )
-    [
-        binary <threaded-server>
-        5000 >>insecure
-        [ (serve) ] >>handler
-        start-server
-    ] in-thread ;
-
-: (service) ( -- )
-    serving-vocabs get-global empty? [ start-serving-vocabs ] when
-    current-vocab serving-vocabs get-global adjoin
-    "get-words" create-in
-    in get [ vocab vocab-words [ stack-effect ] { } assoc-map-as ] curry
-    (( -- words )) define-inline ;
-
-SYNTAX: service \ do-rpc  "executer" set (service) ;
-SYNTAX: mem-service \ mem-do-rpc "executer" set (service) ;
-
-load-vocab-hook [
-    [
-        dup words>> values
-        \ mem-do-rpc "memoize" word-prop [ delete-at ] curry each
-    ] append
-] change-global
diff --git a/unmaintained/modules/rpc-server/summary.txt b/unmaintained/modules/rpc-server/summary.txt
deleted file mode 100644 (file)
index 396a1c8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-remote procedure call server
\ No newline at end of file
diff --git a/unmaintained/modules/rpc/authors.txt b/unmaintained/modules/rpc/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/unmaintained/modules/rpc/rpc-docs.factor b/unmaintained/modules/rpc/rpc-docs.factor
deleted file mode 100644 (file)
index af99d21..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-USING: help.syntax help.markup ;
-IN: modules.rpc
-ARTICLE: { "modules" "protocol" } "RPC Protocol"
-{ $list
-   "Send vocab as string"
-   "Send arglist"
-   "Send word as string"
-   "Receive result list"
-} ;
\ No newline at end of file
diff --git a/unmaintained/modules/rpc/rpc.factor b/unmaintained/modules/rpc/rpc.factor
deleted file mode 100644 (file)
index 1c1217a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-USING: accessors compiler.units combinators fry generalizations io
-io.encodings.binary io.sockets kernel namespaces
-parser sequences serialize vocabs vocabs.parser words ;
-IN: modules.rpc
-
-DEFER: get-words
-
-: remote-quot ( addrspec vocabspec effect str -- quot )
-   '[ _ 5000 <inet> binary
-      [
-         _ serialize _ in>> length narray serialize _ serialize flush deserialize dup length firstn
-      ] with-client
-    ] ;
-
-: define-remote ( addrspec vocabspec effect str -- ) [
-      [ remote-quot ] 2keep create-in -rot define-declared word make-inline
-   ] with-compilation-unit ;
-
-: with-in ( vocab quot -- vocab ) over
-   [ '[ _ set-in @ ] in get swap dip set-in ] dip vocab ; inline
-
-: remote-vocab ( addrspec vocabspec -- vocab )
-   dup "-remote" append [ 
-      [ (( -- words )) [ "get-words" remote-quot ] keep call-effect ] 2keep
-      [ rot first2 swap define-remote ] 2curry each
-   ] with-in ;
\ No newline at end of file
diff --git a/unmaintained/modules/rpc/summary.txt b/unmaintained/modules/rpc/summary.txt
deleted file mode 100644 (file)
index cc1501f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-remote procedure call client
\ No newline at end of file
diff --git a/unmaintained/modules/uploads/authors.txt b/unmaintained/modules/uploads/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/unmaintained/modules/uploads/summary.txt b/unmaintained/modules/uploads/summary.txt
deleted file mode 100644 (file)
index 1ba8ffe..0000000
+++ /dev/null
@@ -1 +0,0 @@
-module pushing in remote-loading listeners
\ No newline at end of file
diff --git a/unmaintained/modules/uploads/uploads.factor b/unmaintained/modules/uploads/uploads.factor
deleted file mode 100644 (file)
index 137a2c9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: assocs modules.rpc-server vocabs
-modules.remote-loading words ;
-IN: modules.uploads service
-
-: upload-vocab ( word binary -- ) \ get-vocab "memoize" word-prop set-at ;
\ No newline at end of file
diff --git a/unmaintained/modules/using/authors.txt b/unmaintained/modules/using/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/unmaintained/modules/using/summary.txt b/unmaintained/modules/using/summary.txt
deleted file mode 100644 (file)
index 6bafda7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-improved module import syntax
\ No newline at end of file
diff --git a/unmaintained/modules/using/tests/tags.txt b/unmaintained/modules/using/tests/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/unmaintained/modules/using/tests/test-server.factor b/unmaintained/modules/using/tests/test-server.factor
deleted file mode 100644 (file)
index 3e6b736..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-USING: modules.rpc-server io.servers.connection ;
-IN: modules.test-server service
-: rpc-hello ( -- str ) "hello world" stop-this-server ;
\ No newline at end of file
diff --git a/unmaintained/modules/using/tests/tests.factor b/unmaintained/modules/using/tests/tests.factor
deleted file mode 100644 (file)
index 894075a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: modules.using ;
-IN: modules.using.tests
-USING: tools.test localhost::modules.test-server ;
-[ "hello world" ] [ rpc-hello ] unit-test
\ No newline at end of file
diff --git a/unmaintained/modules/using/using-docs.factor b/unmaintained/modules/using/using-docs.factor
deleted file mode 100644 (file)
index c78e546..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-USING: modules.using modules.rpc-server help.syntax help.markup strings ;
-IN: modules
-
-HELP: service
-{ $syntax "IN: module service" }
-{ $description "Starts a server for requests for remote procedure calls." } ;
-
-ARTICLE: { "modules" "remote-loading" } "Using the remote-loading vocabulary"
-"If loaded, starts serving vocabularies, accessable through a " { $link POSTPONE: USING: } " form" ;
-
-HELP: USING:
-{ $syntax "USING: rpc-server::module fetch-sever::module { module qualified-name } { module => word ... } ... ;" }
-{ $description "Adds vocabularies to the front of the search path.  Vocabularies can be fetched remotely, if preceded by a valid hostname.  Name pairs facilitate imports like in the "
-{ $link POSTPONE: QUALIFIED: } " or " { $link POSTPONE: FROM: } " forms." } ;
\ No newline at end of file
diff --git a/unmaintained/modules/using/using.factor b/unmaintained/modules/using/using.factor
deleted file mode 100644 (file)
index b0891aa..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-USING: assocs kernel modules.remote-loading modules.rpc
-namespaces peg peg.ebnf peg-lexer sequences vocabs vocabs.parser
-strings ;
-IN: modules.using
-
-: >qualified ( vocab prefix -- assoc )
-    [ vocab-words ] [ 58 suffix ] bi* [ swap [ prepend ] dip ] curry assoc-map ;
-
-: >partial-vocab ( words assoc -- assoc )
-    [ dupd at [ no-word-error ] unless* ] curry { } map>assoc ;
-
-: remote-load ( addr vocabspec -- voab ) [ "modules.remote-loading" remote-vocab (use+) ] dip get-vocab ;
-
-: load'em ( vocab words/? -- ) [ swap >partial-vocab ] when* use get push ;
-
-EBNF: modulize
-tokenpart = (!(':').)+ => [[ >string ]]
-s = ':' => [[ drop ignore ]]
-rpc = tokenpart s s tokenpart => [[ first2 remote-vocab ]]
-remote = tokenpart s tokenpart => [[ first2 remote-load ]]
-plain = tokenpart => [[ load-vocab ]]
-module = rpc | remote | plain
-;EBNF
-
-ON-BNF: USING:
-tokenizer = <foreign factor>
-sym = !(";"|"}"|"=>").
-modspec = sym => [[ modulize ]]
-qualified = modspec sym => [[ first2 >qualified ]]
-unqualified = modspec => [[ vocab-words ]]
-words = ("=>" sym+ )? => [[ [ f ] [ second ] if-empty ]]
-long = "{" ( qualified | unqualified ) words "}" => [[ rest first2 load'em ignore ]]
-short = modspec => [[ use+ ignore ]]
-wordSpec = long | short
-using = wordSpec+ ";" => [[ drop ignore ]]
-;ON-BNF
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6631a04..a075cd0
@@ -9,7 +9,7 @@ bool performing_gc;
 bool performing_compaction;
 cell collecting_gen;
 
-/* if true, we collecting aging space for the second time, so if it is still
+/* if true, we are collecting aging space for the second time, so if it is still
 full, we go on to collect tenured */
 bool collecting_aging_again;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)