]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' into startup
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 15 Nov 2009 08:52:50 +0000 (02:52 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 15 Nov 2009 08:52:50 +0000 (02:52 -0600)
Conflicts:
core/bootstrap/primitives.factor
vm/run.hpp

1557 files changed:
Makefile
basis/alarms/alarms-docs.factor
basis/alien/arrays/arrays.factor
basis/alien/c-types/c-types.factor
basis/alien/data/data.factor
basis/alien/fortran/fortran.factor
basis/alien/parser/parser.factor
basis/alien/syntax/syntax.factor
basis/binary-search/binary-search-docs.factor
basis/binary-search/binary-search.factor
basis/bit-arrays/bit-arrays-docs.factor
basis/bit-arrays/bit-arrays-tests.factor
basis/bitstreams/bitstreams.factor
basis/bootstrap/compiler/compiler.factor
basis/bootstrap/image/image.factor
basis/bootstrap/stage2.factor
basis/bootstrap/tools/tools.factor
basis/byte-arrays/hex/hex.factor
basis/calendar/calendar-docs.factor
basis/calendar/calendar-tests.factor
basis/calendar/calendar.factor
basis/calendar/unix/unix.factor
basis/channels/examples/examples.factor
basis/channels/remote/remote-docs.factor
basis/channels/remote/remote.factor
basis/checksums/hmac/hmac.factor
basis/circular/circular.factor
basis/classes/struct/bit-accessors/bit-accessors.factor
basis/classes/struct/struct-tests.factor
basis/classes/struct/struct.factor
basis/cocoa/callbacks/callbacks.factor
basis/cocoa/cocoa-tests.factor
basis/cocoa/cocoa.factor
basis/cocoa/messages/messages-docs.factor
basis/cocoa/messages/messages.factor
basis/cocoa/subclassing/subclassing-docs.factor
basis/colors/constants/constants.factor
basis/columns/columns-tests.factor
basis/columns/columns.factor
basis/combinators/smart/smart-tests.factor
basis/combinators/smart/smart.factor
basis/compiler/cfg/alias-analysis/alias-analysis.factor
basis/compiler/cfg/builder/builder-tests.factor
basis/compiler/cfg/builder/builder.factor
basis/compiler/cfg/cfg.factor
basis/compiler/cfg/checker/checker.factor
basis/compiler/cfg/comparisons/comparisons.factor
basis/compiler/cfg/copy-prop/copy-prop.factor
basis/compiler/cfg/dce/dce.factor
basis/compiler/cfg/def-use/def-use.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/fixnum/fixnum.factor
basis/compiler/cfg/intrinsics/intrinsics.factor
basis/compiler/cfg/intrinsics/misc/misc.factor
basis/compiler/cfg/intrinsics/simd/simd.factor
basis/compiler/cfg/intrinsics/slots/slots.factor
basis/compiler/cfg/linear-scan/allocation/allocation.factor
basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor
basis/compiler/cfg/linear-scan/allocation/state/state.factor
basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor
basis/compiler/cfg/predecessors/predecessors.factor
basis/compiler/cfg/registers/registers.factor
basis/compiler/cfg/renaming/functor/functor.factor
basis/compiler/cfg/representations/preferred/preferred.factor
basis/compiler/cfg/representations/representations.factor
basis/compiler/cfg/ssa/destruction/destruction.factor
basis/compiler/cfg/ssa/liveness/liveness.factor
basis/compiler/cfg/useless-conditionals/useless-conditionals.factor
basis/compiler/cfg/utilities/utilities.factor
basis/compiler/cfg/value-numbering/expressions/expressions.factor
basis/compiler/cfg/value-numbering/rewrite/rewrite.factor
basis/compiler/cfg/value-numbering/value-numbering-tests.factor
basis/compiler/cfg/write-barrier/write-barrier.factor
basis/compiler/codegen/codegen.factor
basis/compiler/compiler.factor
basis/compiler/constants/constants.factor
basis/compiler/crossref/authors.txt [new file with mode: 0644]
basis/compiler/crossref/crossref.factor [new file with mode: 0644]
basis/compiler/tests/alien.factor
basis/compiler/tests/codegen.factor
basis/compiler/tests/intrinsics.factor [changed mode: 0644->0755]
basis/compiler/tests/low-level-ir.factor
basis/compiler/tests/optimizer.factor
basis/compiler/tests/redefine3.factor
basis/compiler/tests/simple.factor
basis/compiler/tests/stack-trace.factor
basis/compiler/tree/builder/builder.factor
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/dead-code/dead-code-tests.factor
basis/compiler/tree/dead-code/recursive/recursive.factor
basis/compiler/tree/dead-code/simple/simple.factor
basis/compiler/tree/debugger/debugger.factor
basis/compiler/tree/modular-arithmetic/modular-arithmetic.factor
basis/compiler/tree/propagation/branches/branches.factor
basis/compiler/tree/propagation/call-effect/call-effect-tests.factor
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/compiler/tree/propagation/constraints/constraints.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/simple/simple.factor
basis/compiler/tree/propagation/slots/slots.factor
basis/compiler/tree/propagation/transforms/transforms.factor
basis/compiler/tree/tree.factor
basis/compiler/utilities/utilities.factor
basis/compression/run-length/run-length.factor
basis/concurrency/combinators/combinators.factor
basis/concurrency/distributed/distributed-docs.factor
basis/concurrency/distributed/distributed-tests.factor
basis/concurrency/distributed/distributed.factor
basis/concurrency/exchangers/exchangers-tests.factor
basis/concurrency/flags/flags-tests.factor
basis/concurrency/locks/locks-tests.factor
basis/concurrency/mailboxes/mailboxes-docs.factor
basis/concurrency/messaging/messaging-docs.factor
basis/concurrency/messaging/messaging.factor
basis/cords/cords.factor
basis/core-foundation/fsevents/fsevents.factor
basis/core-foundation/run-loop/run-loop.factor
basis/core-text/core-text-tests.factor
basis/core-text/core-text.factor
basis/cpu/architecture/architecture.factor
basis/cpu/ppc/bootstrap.factor
basis/cpu/ppc/linux/bootstrap.factor
basis/cpu/ppc/macosx/bootstrap.factor
basis/cpu/ppc/macosx/macosx.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/32/32.factor
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/bootstrap.factor
basis/cpu/x86/64/unix/bootstrap.factor
basis/cpu/x86/64/winnt/bootstrap.factor
basis/cpu/x86/64/winnt/winnt.factor
basis/cpu/x86/assembler/operands/operands.factor
basis/cpu/x86/bootstrap.factor
basis/cpu/x86/x86.factor
basis/csv/csv-tests.factor
basis/db/sqlite/ffi/ffi.factor
basis/db/sqlite/sqlite.factor
basis/debugger/debugger-docs.factor
basis/debugger/debugger.factor
basis/debugger/windows/windows.factor [changed mode: 0644->0755]
basis/delegate/delegate-docs.factor
basis/documents/documents-docs.factor
basis/documents/documents.factor
basis/editors/editors.factor
basis/farkup/farkup.factor
basis/fry/fry-docs.factor
basis/fry/fry-tests.factor
basis/fry/fry.factor
basis/ftp/server/server-tests.factor
basis/ftp/server/server.factor
basis/functors/functors.factor
basis/furnace/auth/auth-docs.factor
basis/furnace/auth/providers/providers.factor
basis/game/input/dinput/keys-array/keys-array.factor
basis/game/input/input.factor
basis/generalizations/generalizations-docs.factor
basis/generalizations/generalizations-tests.factor
basis/generalizations/generalizations.factor
basis/grouping/grouping-docs.factor
basis/grouping/grouping-tests.factor
basis/grouping/grouping.factor
basis/half-floats/authors.txt [new file with mode: 0644]
basis/half-floats/half-floats-tests.factor [new file with mode: 0644]
basis/half-floats/half-floats.factor [new file with mode: 0755]
basis/half-floats/summary.txt [new file with mode: 0644]
basis/heaps/heaps-docs.factor
basis/help/apropos/apropos.factor
basis/help/crossref/crossref-tests.factor
basis/help/handbook/handbook.factor
basis/help/help.factor
basis/help/home/home-docs.factor
basis/help/lint/checks/checks.factor
basis/help/markup/markup.factor
basis/help/tips/tips.factor
basis/help/vocabs/vocabs-tests.factor
basis/hints/hints-docs.factor
basis/hints/hints.factor
basis/html/templates/fhtml/fhtml.factor
basis/http/client/client-docs.factor
basis/http/client/client.factor
basis/http/http-tests.factor
basis/http/http.factor
basis/images/bitmap/loading/loading.factor
basis/images/jpeg/jpeg.factor
basis/images/normalization/authors.txt [new file with mode: 0644]
basis/images/normalization/normalization-docs.factor [new file with mode: 0644]
basis/images/normalization/normalization-tests.factor [new file with mode: 0644]
basis/images/normalization/normalization.factor [new file with mode: 0755]
basis/images/png/png.factor
basis/images/testing/bmp/1bit.bmp [deleted file]
basis/images/testing/bmp/42red_24bit.bmp [deleted file]
basis/images/testing/bmp/42red_24bit.fig [deleted file]
basis/images/testing/bmp/rgb_4bit.bmp [deleted file]
basis/images/testing/bmp/rgb_8bit.bmp [deleted file]
basis/images/testing/bmp/rgb_8bit.fig [deleted file]
basis/images/testing/gif/alpha.fig [deleted file]
basis/images/testing/gif/alpha.gif [deleted file]
basis/images/testing/gif/astronaut_animation.fig [deleted file]
basis/images/testing/gif/astronaut_animation.gif [deleted file]
basis/images/testing/gif/checkmark.fig [deleted file]
basis/images/testing/gif/checkmark.gif [deleted file]
basis/images/testing/gif/circle.fig [deleted file]
basis/images/testing/gif/circle.gif [deleted file]
basis/images/testing/gif/monochrome.fig [deleted file]
basis/images/testing/gif/monochrome.gif [deleted file]
basis/images/testing/gif/noise.fig [deleted file]
basis/images/testing/gif/noise.gif [deleted file]
basis/images/testing/png/basn2c08.fig [deleted file]
basis/images/testing/png/basn2c08.png [deleted file]
basis/images/testing/png/basn6a08.fig [deleted file]
basis/images/testing/png/basn6a08.png [deleted file]
basis/images/testing/png/f00n2c08.fig [deleted file]
basis/images/testing/png/f00n2c08.png [deleted file]
basis/images/testing/png/f01n2c08.fig [deleted file]
basis/images/testing/png/f01n2c08.png [deleted file]
basis/images/testing/png/f02n2c08.fig [deleted file]
basis/images/testing/png/f02n2c08.png [deleted file]
basis/images/testing/png/f03n2c08.fig [deleted file]
basis/images/testing/png/f03n2c08.png [deleted file]
basis/images/testing/png/f04n2c08.fig [deleted file]
basis/images/testing/png/f04n2c08.png [deleted file]
basis/images/testing/png/suite/basi0g01.png [deleted file]
basis/images/testing/png/suite/basi0g02.png [deleted file]
basis/images/testing/png/suite/basi0g04.png [deleted file]
basis/images/testing/png/suite/basi0g08.png [deleted file]
basis/images/testing/png/suite/basi0g16.png [deleted file]
basis/images/testing/png/suite/basi2c08.png [deleted file]
basis/images/testing/png/suite/basi2c16.png [deleted file]
basis/images/testing/png/suite/basi3p01.png [deleted file]
basis/images/testing/png/suite/basi3p02.png [deleted file]
basis/images/testing/png/suite/basi3p04.png [deleted file]
basis/images/testing/png/suite/basi3p08.png [deleted file]
basis/images/testing/png/suite/basi4a08.png [deleted file]
basis/images/testing/png/suite/basi4a16.png [deleted file]
basis/images/testing/png/suite/basi6a08.png [deleted file]
basis/images/testing/png/suite/basi6a16.png [deleted file]
basis/images/testing/png/suite/basn0g01.png [deleted file]
basis/images/testing/png/suite/basn0g02.png [deleted file]
basis/images/testing/png/suite/basn0g04.png [deleted file]
basis/images/testing/png/suite/basn0g08.png [deleted file]
basis/images/testing/png/suite/basn0g16.png [deleted file]
basis/images/testing/png/suite/basn2c08.png [deleted file]
basis/images/testing/png/suite/basn2c16.png [deleted file]
basis/images/testing/png/suite/basn3p01.png [deleted file]
basis/images/testing/png/suite/basn3p02.png [deleted file]
basis/images/testing/png/suite/basn3p04.png [deleted file]
basis/images/testing/png/suite/basn3p08.png [deleted file]
basis/images/testing/png/suite/basn4a08.png [deleted file]
basis/images/testing/png/suite/basn4a16.png [deleted file]
basis/images/testing/png/suite/basn6a08.png [deleted file]
basis/images/testing/png/suite/basn6a16.png [deleted file]
basis/images/testing/png/suite/bgai4a08.png [deleted file]
basis/images/testing/png/suite/bgai4a16.png [deleted file]
basis/images/testing/png/suite/bgan6a08.png [deleted file]
basis/images/testing/png/suite/bgan6a16.png [deleted file]
basis/images/testing/png/suite/bgbn4a08.png [deleted file]
basis/images/testing/png/suite/bggn4a16.png [deleted file]
basis/images/testing/png/suite/bgwn6a08.png [deleted file]
basis/images/testing/png/suite/bgyn6a16.png [deleted file]
basis/images/testing/png/suite/ccwn2c08.png [deleted file]
basis/images/testing/png/suite/ccwn3p08.png [deleted file]
basis/images/testing/png/suite/cdfn2c08.png [deleted file]
basis/images/testing/png/suite/cdhn2c08.png [deleted file]
basis/images/testing/png/suite/cdsn2c08.png [deleted file]
basis/images/testing/png/suite/cdun2c08.png [deleted file]
basis/images/testing/png/suite/ch1n3p04.png [deleted file]
basis/images/testing/png/suite/ch2n3p08.png [deleted file]
basis/images/testing/png/suite/cm0n0g04.png [deleted file]
basis/images/testing/png/suite/cm7n0g04.png [deleted file]
basis/images/testing/png/suite/cm9n0g04.png [deleted file]
basis/images/testing/png/suite/cs3n2c16.png [deleted file]
basis/images/testing/png/suite/cs3n3p08.png [deleted file]
basis/images/testing/png/suite/cs5n2c08.png [deleted file]
basis/images/testing/png/suite/cs5n3p08.png [deleted file]
basis/images/testing/png/suite/cs8n2c08.png [deleted file]
basis/images/testing/png/suite/cs8n3p08.png [deleted file]
basis/images/testing/png/suite/ct0n0g04.png [deleted file]
basis/images/testing/png/suite/ct1n0g04.png [deleted file]
basis/images/testing/png/suite/ctzn0g04.png [deleted file]
basis/images/testing/png/suite/f00n0g08.png [deleted file]
basis/images/testing/png/suite/f00n2c08.png [deleted file]
basis/images/testing/png/suite/f01n0g08.png [deleted file]
basis/images/testing/png/suite/f01n2c08.png [deleted file]
basis/images/testing/png/suite/f02n0g08.png [deleted file]
basis/images/testing/png/suite/f02n2c08.png [deleted file]
basis/images/testing/png/suite/f03n0g08.png [deleted file]
basis/images/testing/png/suite/f03n2c08.png [deleted file]
basis/images/testing/png/suite/f04n0g08.png [deleted file]
basis/images/testing/png/suite/f04n2c08.png [deleted file]
basis/images/testing/png/suite/g03n0g16.png [deleted file]
basis/images/testing/png/suite/g03n2c08.png [deleted file]
basis/images/testing/png/suite/g03n3p04.png [deleted file]
basis/images/testing/png/suite/g04n0g16.png [deleted file]
basis/images/testing/png/suite/g04n2c08.png [deleted file]
basis/images/testing/png/suite/g04n3p04.png [deleted file]
basis/images/testing/png/suite/g05n0g16.png [deleted file]
basis/images/testing/png/suite/g05n2c08.png [deleted file]
basis/images/testing/png/suite/g05n3p04.png [deleted file]
basis/images/testing/png/suite/g07n0g16.png [deleted file]
basis/images/testing/png/suite/g07n2c08.png [deleted file]
basis/images/testing/png/suite/g07n3p04.png [deleted file]
basis/images/testing/png/suite/g10n0g16.png [deleted file]
basis/images/testing/png/suite/g10n2c08.png [deleted file]
basis/images/testing/png/suite/g10n3p04.png [deleted file]
basis/images/testing/png/suite/g25n0g16.png [deleted file]
basis/images/testing/png/suite/g25n2c08.png [deleted file]
basis/images/testing/png/suite/g25n3p04.png [deleted file]
basis/images/testing/png/suite/oi1n0g16.png [deleted file]
basis/images/testing/png/suite/oi1n2c16.png [deleted file]
basis/images/testing/png/suite/oi2n0g16.png [deleted file]
basis/images/testing/png/suite/oi2n2c16.png [deleted file]
basis/images/testing/png/suite/oi4n0g16.png [deleted file]
basis/images/testing/png/suite/oi4n2c16.png [deleted file]
basis/images/testing/png/suite/oi9n0g16.png [deleted file]
basis/images/testing/png/suite/oi9n2c16.png [deleted file]
basis/images/testing/png/suite/pngsuite.doc [deleted file]
basis/images/testing/png/suite/pngsuite_logo.png [deleted file]
basis/images/testing/png/suite/pp0n2c16.png [deleted file]
basis/images/testing/png/suite/pp0n6a08.png [deleted file]
basis/images/testing/png/suite/ps1n0g08.png [deleted file]
basis/images/testing/png/suite/ps1n2c16.png [deleted file]
basis/images/testing/png/suite/ps2n0g08.png [deleted file]
basis/images/testing/png/suite/ps2n2c16.png [deleted file]
basis/images/testing/png/suite/s01i3p01.png [deleted file]
basis/images/testing/png/suite/s01n3p01.png [deleted file]
basis/images/testing/png/suite/s02i3p01.png [deleted file]
basis/images/testing/png/suite/s02n3p01.png [deleted file]
basis/images/testing/png/suite/s03i3p01.png [deleted file]
basis/images/testing/png/suite/s03n3p01.png [deleted file]
basis/images/testing/png/suite/s04i3p01.png [deleted file]
basis/images/testing/png/suite/s04n3p01.png [deleted file]
basis/images/testing/png/suite/s05i3p02.png [deleted file]
basis/images/testing/png/suite/s05n3p02.png [deleted file]
basis/images/testing/png/suite/s06i3p02.png [deleted file]
basis/images/testing/png/suite/s06n3p02.png [deleted file]
basis/images/testing/png/suite/s07i3p02.png [deleted file]
basis/images/testing/png/suite/s07n3p02.png [deleted file]
basis/images/testing/png/suite/s08i3p02.png [deleted file]
basis/images/testing/png/suite/s08n3p02.png [deleted file]
basis/images/testing/png/suite/s09i3p02.png [deleted file]
basis/images/testing/png/suite/s09n3p02.png [deleted file]
basis/images/testing/png/suite/s32i3p04.png [deleted file]
basis/images/testing/png/suite/s32n3p04.png [deleted file]
basis/images/testing/png/suite/s33i3p04.png [deleted file]
basis/images/testing/png/suite/s33n3p04.png [deleted file]
basis/images/testing/png/suite/s34i3p04.png [deleted file]
basis/images/testing/png/suite/s34n3p04.png [deleted file]
basis/images/testing/png/suite/s35i3p04.png [deleted file]
basis/images/testing/png/suite/s35n3p04.png [deleted file]
basis/images/testing/png/suite/s36i3p04.png [deleted file]
basis/images/testing/png/suite/s36n3p04.png [deleted file]
basis/images/testing/png/suite/s37i3p04.png [deleted file]
basis/images/testing/png/suite/s37n3p04.png [deleted file]
basis/images/testing/png/suite/s38i3p04.png [deleted file]
basis/images/testing/png/suite/s38n3p04.png [deleted file]
basis/images/testing/png/suite/s39i3p04.png [deleted file]
basis/images/testing/png/suite/s39n3p04.png [deleted file]
basis/images/testing/png/suite/s40i3p04.png [deleted file]
basis/images/testing/png/suite/s40n3p04.png [deleted file]
basis/images/testing/png/suite/tbbn1g04.png [deleted file]
basis/images/testing/png/suite/tbbn2c16.png [deleted file]
basis/images/testing/png/suite/tbbn3p08.png [deleted file]
basis/images/testing/png/suite/tbgn2c16.png [deleted file]
basis/images/testing/png/suite/tbgn3p08.png [deleted file]
basis/images/testing/png/suite/tbrn2c08.png [deleted file]
basis/images/testing/png/suite/tbwn1g16.png [deleted file]
basis/images/testing/png/suite/tbwn3p08.png [deleted file]
basis/images/testing/png/suite/tbyn3p08.png [deleted file]
basis/images/testing/png/suite/tp0n1g08.png [deleted file]
basis/images/testing/png/suite/tp0n2c08.png [deleted file]
basis/images/testing/png/suite/tp0n3p08.png [deleted file]
basis/images/testing/png/suite/tp1n3p08.png [deleted file]
basis/images/testing/png/suite/x00n0g01.png [deleted file]
basis/images/testing/png/suite/xcrn0g04.png [deleted file]
basis/images/testing/png/suite/xlfn0g04.png [deleted file]
basis/images/testing/png/suite/z00n2c08.png [deleted file]
basis/images/testing/png/suite/z03n2c08.png [deleted file]
basis/images/testing/png/suite/z06n2c08.png [deleted file]
basis/images/testing/png/suite/z09n2c08.png [deleted file]
basis/images/testing/png/z00n2c08.fig [deleted file]
basis/images/testing/png/z00n2c08.png [deleted file]
basis/images/testing/png/z03n2c08.fig [deleted file]
basis/images/testing/png/z03n2c08.png [deleted file]
basis/images/testing/png/z06n2c08.fig [deleted file]
basis/images/testing/png/z06n2c08.png [deleted file]
basis/images/testing/png/z09n2c08.fig [deleted file]
basis/images/testing/png/z09n2c08.png [deleted file]
basis/images/testing/testing-docs.factor [deleted file]
basis/images/testing/testing.factor [deleted file]
basis/images/testing/tiff/alpha.fig [deleted file]
basis/images/testing/tiff/alpha.tiff [deleted file]
basis/images/testing/tiff/color_spectrum.fig [deleted file]
basis/images/testing/tiff/color_spectrum.tiff [deleted file]
basis/images/testing/tiff/elephants.tiff [deleted file]
basis/images/testing/tiff/noise.fig [deleted file]
basis/images/testing/tiff/noise.tiff [deleted file]
basis/images/testing/tiff/octagon.fig [deleted file]
basis/images/testing/tiff/octagon.tiff [deleted file]
basis/images/testing/tiff/rgb.fig [deleted file]
basis/images/testing/tiff/rgb.tiff [deleted file]
basis/interpolate/interpolate-tests.factor
basis/interpolate/interpolate.factor
basis/inverse/inverse.factor
basis/io/backend/unix/multiplexers/run-loop/run-loop.factor
basis/io/backend/windows/nt/nt.factor
basis/io/buffers/buffers-tests.factor
basis/io/buffers/buffers.factor
basis/io/directories/directories-docs.factor
basis/io/directories/directories.factor
basis/io/directories/search/search.factor
basis/io/encodings/8-bit/8-bit-docs.factor
basis/io/encodings/8-bit/8-bit-tests.factor
basis/io/encodings/8-bit/8-bit.factor
basis/io/encodings/8-bit/CP1250.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1251.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1253.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1254.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1255.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1256.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1257.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1258.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/arabic/arabic-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/arabic/arabic.factor [new file with mode: 0644]
basis/io/encodings/8-bit/arabic/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/cyrillic/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/cyrillic/cyrillic-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/cyrillic/cyrillic.factor [new file with mode: 0644]
basis/io/encodings/8-bit/ebcdic/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/ebcdic/ebcdic-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/ebcdic/ebcdic.factor [new file with mode: 0644]
basis/io/encodings/8-bit/greek/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/greek/greek-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/greek/greek.factor [new file with mode: 0644]
basis/io/encodings/8-bit/hebrew/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/hebrew/hebrew-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/hebrew/hebrew.factor [new file with mode: 0644]
basis/io/encodings/8-bit/koi8-r/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/koi8-r/koi8-r-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/koi8-r/koi8-r.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin1/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin1/latin1-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin1/latin1.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin10/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin10/latin10-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin10/latin10.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin2/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin2/latin2-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin2/latin2.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin3/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin3/latin3-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin3/latin3.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin4/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin4/latin4-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin4/latin4.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin5/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin5/latin5-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin5/latin5.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin6/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin6/latin6-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin6/latin6.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin7/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin7/latin7-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin7/latin7.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin8/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin8/latin8-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin8/latin8.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin9/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin9/latin9-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin9/latin9.factor [new file with mode: 0644]
basis/io/encodings/8-bit/mac-roman/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/mac-roman/mac-roman-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/mac-roman/mac-roman.factor [new file with mode: 0644]
basis/io/encodings/8-bit/thai/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/thai/thai-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/thai/thai.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1250/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1250/windows-1250.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1251/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1251/windows-1251.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1252/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1252/windows-1252-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1252/windows-1252.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1253/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1253/windows-1253.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1254/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1254/windows-1254.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1255/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1255/windows-1255.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1256/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1256/windows-1256.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1257/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1257/windows-1257.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1258/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1258/windows-1258.factor [new file with mode: 0644]
basis/io/encodings/gb18030/gb18030.factor
basis/io/encodings/iana/iana.factor
basis/io/encodings/iso2022/iso2022.factor
basis/io/files/info/unix/linux/linux.factor
basis/io/files/info/windows/windows.factor
basis/io/files/links/unix/unix.factor
basis/io/files/windows/nt/nt.factor
basis/io/launcher/launcher.factor
basis/io/launcher/unix/unix-tests.factor
basis/io/launcher/unix/unix.factor
basis/io/launcher/windows/windows.factor
basis/io/mmap/mmap-docs.factor
basis/io/mmap/windows/windows.factor
basis/io/monitors/linux/linux.factor
basis/io/monitors/macosx/macosx.factor
basis/io/monitors/recursive/recursive.factor
basis/io/ports/ports.factor
basis/io/servers/packet/authors.txt [deleted file]
basis/io/servers/packet/packet.factor [deleted file]
basis/io/servers/packet/summary.txt [deleted file]
basis/io/servers/packet/tags.txt [deleted file]
basis/io/sockets/secure/openssl/openssl.factor
basis/io/sockets/sockets.factor
basis/io/sockets/unix/unix.factor
basis/io/sockets/windows/windows.factor
basis/io/streams/limited/limited-tests.factor
basis/io/streams/limited/limited.factor
basis/iokit/iokit.factor
basis/lcs/lcs.factor
basis/listener/listener-docs.factor
basis/listener/listener.factor
basis/lists/lazy/lazy-tests.factor
basis/lists/lazy/lazy.factor
basis/lists/lists-docs.factor
basis/lists/lists.factor
basis/locals/errors/errors.factor
basis/locals/fry/fry.factor
basis/locals/locals-docs.factor
basis/locals/locals-tests.factor
basis/locals/locals.factor
basis/locals/macros/macros.factor
basis/locals/parser/parser.factor
basis/locals/prettyprint/prettyprint.factor
basis/locals/rewrite/sugar/sugar.factor
basis/locals/types/types.factor
basis/logging/analysis/analysis.factor
basis/logging/logging-docs.factor
basis/macros/macros.factor
basis/math/blas/vectors/vectors.factor
basis/math/combinatorics/combinatorics.factor
basis/math/functions/functions-docs.factor
basis/math/functions/functions-tests.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/matrices/matrices.factor
basis/math/partial-dispatch/partial-dispatch-tests.factor
basis/math/primes/erato/erato-tests.factor
basis/math/primes/miller-rabin/miller-rabin.factor
basis/math/primes/primes-docs.factor
basis/math/ranges/ranges-docs.factor
basis/math/ratios/ratios-tests.factor
basis/math/rectangles/rectangles.factor
basis/math/statistics/statistics-docs.factor
basis/math/statistics/statistics-tests.factor
basis/math/statistics/statistics.factor
basis/math/vectors/conversion/conversion.factor
basis/math/vectors/simd/functor/functor.factor
basis/math/vectors/simd/intrinsics/intrinsics.factor
basis/math/vectors/simd/simd-tests.factor
basis/math/vectors/simd/simd.factor
basis/math/vectors/specialization/specialization.factor
basis/math/vectors/vectors-docs.factor
basis/math/vectors/vectors.factor
basis/mirrors/mirrors.factor
basis/models/arrow/arrow-tests.factor
basis/models/illusion/authors.txt [deleted file]
basis/models/illusion/illusion.factor [deleted file]
basis/models/illusion/summary.txt [deleted file]
basis/models/models.factor
basis/models/product/product-tests.factor
basis/multiline/multiline.factor
basis/opengl/debug/debug.factor
basis/opengl/opengl-tests.factor [new file with mode: 0644]
basis/opengl/opengl.factor
basis/opengl/textures/textures.factor
basis/pack/pack.factor
basis/peg/ebnf/ebnf.factor
basis/peg/parsers/parsers.factor
basis/peg/peg.factor
basis/persistent/hashtables/config/config.factor
basis/persistent/hashtables/hashtables-tests.factor
basis/persistent/hashtables/hashtables.factor
basis/persistent/hashtables/nodes/bitmap/bitmap.factor
basis/persistent/hashtables/nodes/collision/collision.factor
basis/persistent/hashtables/nodes/full/full.factor
basis/persistent/hashtables/nodes/leaf/leaf.factor
basis/persistent/heaps/heaps-docs.factor
basis/persistent/vectors/vectors.factor
basis/prettyprint/backend/backend.factor
basis/prettyprint/prettyprint-docs.factor
basis/prettyprint/prettyprint-tests.factor
basis/prettyprint/prettyprint.factor
basis/quoted-printable/quoted-printable-tests.factor
basis/random/random-docs.factor
basis/random/random.factor
basis/regexp/dfa/dfa.factor
basis/regexp/disambiguate/disambiguate.factor
basis/regexp/minimize/minimize.factor
basis/regexp/nfa/nfa.factor
basis/regexp/regexp.factor
basis/roman/roman-tests.factor
basis/roman/roman.factor
basis/sequences/deep/deep-docs.factor
basis/sequences/deep/deep-tests.factor
basis/sequences/deep/deep.factor
basis/sequences/generalizations/generalizations-docs.factor [new file with mode: 0644]
basis/sequences/generalizations/generalizations-tests.factor [new file with mode: 0644]
basis/sequences/generalizations/generalizations.factor [new file with mode: 0644]
basis/sequences/merged/authors.txt [new file with mode: 0644]
basis/sequences/merged/merged-docs.factor [new file with mode: 0644]
basis/sequences/merged/merged-tests.factor [new file with mode: 0644]
basis/sequences/merged/merged.factor [new file with mode: 0644]
basis/sequences/merged/summary.txt [new file with mode: 0644]
basis/sequences/merged/tags.txt [new file with mode: 0644]
basis/sequences/parser/authors.txt [new file with mode: 0644]
basis/sequences/parser/parser-tests.factor [new file with mode: 0644]
basis/sequences/parser/parser.factor [new file with mode: 0644]
basis/sequences/product/authors.txt [new file with mode: 0644]
basis/sequences/product/product-docs.factor [new file with mode: 0644]
basis/sequences/product/product-tests.factor [new file with mode: 0644]
basis/sequences/product/product.factor [new file with mode: 0644]
basis/sequences/product/summary.txt [new file with mode: 0644]
basis/serialize/serialize-tests.factor
basis/serialize/serialize.factor
basis/shuffle/shuffle-docs.factor [new file with mode: 0644]
basis/shuffle/shuffle-tests.factor
basis/shuffle/shuffle.factor
basis/specialized-arrays/mirrors/mirrors.factor [new file with mode: 0644]
basis/specialized-arrays/specialized-arrays-tests.factor
basis/specialized-arrays/specialized-arrays.factor
basis/stack-checker/alien/alien.factor
basis/stack-checker/backend/backend-tests.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/branches/branches.factor
basis/stack-checker/dependencies/authors.txt [new file with mode: 0644]
basis/stack-checker/dependencies/dependencies-tests.factor [new file with mode: 0644]
basis/stack-checker/dependencies/dependencies.factor [new file with mode: 0644]
basis/stack-checker/errors/errors-docs.factor
basis/stack-checker/errors/errors.factor
basis/stack-checker/errors/prettyprint/prettyprint.factor
basis/stack-checker/inlining/inlining.factor
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/stack-checker-docs.factor
basis/stack-checker/stack-checker-tests.factor
basis/stack-checker/state/state-tests.factor [deleted file]
basis/stack-checker/state/state.factor
basis/stack-checker/transforms/transforms-tests.factor
basis/stack-checker/transforms/transforms.factor
basis/stack-checker/values/values.factor
basis/suffix-arrays/suffix-arrays.factor
basis/system-info/linux/linux.factor
basis/threads/threads-tests.factor
basis/tools/crossref/crossref.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/test/14/14.factor
basis/tools/deploy/test/4/4.factor
basis/tools/deploy/test/9/9.factor
basis/tools/deploy/test/test.factor
basis/tools/deprecation/deprecation-docs.factor
basis/tools/dispatch/authors.txt [new file with mode: 0644]
basis/tools/dispatch/dispatch-docs.factor [new file with mode: 0644]
basis/tools/dispatch/dispatch.factor [new file with mode: 0644]
basis/tools/errors/errors.factor
basis/tools/memory/memory-docs.factor
basis/tools/memory/memory-tests.factor
basis/tools/memory/memory.factor
basis/tools/profiler/profiler-docs.factor
basis/tools/profiler/profiler-tests.factor
basis/tools/profiler/profiler.factor
basis/tools/scaffold/scaffold.factor
basis/tools/test/test.factor
basis/tools/time/time-docs.factor
basis/tools/time/time-tests.factor [new file with mode: 0644]
basis/tools/time/time.factor
basis/tools/walker/debug/debug.factor
basis/tools/walker/walker-docs.factor
basis/tools/walker/walker.factor
basis/tr/tr.factor
basis/typed/typed-tests.factor
basis/typed/typed.factor
basis/ui/backend/cocoa/cocoa.factor
basis/ui/backend/cocoa/tools/tools.factor
basis/ui/backend/cocoa/views/views.factor
basis/ui/backend/windows/windows.factor
basis/ui/gadgets/editors/editors.factor
basis/ui/gadgets/gadgets.factor
basis/ui/gadgets/labels/labels.factor
basis/ui/gadgets/menus/menus-docs.factor
basis/ui/gadgets/paragraphs/paragraphs.factor
basis/ui/gadgets/scrollers/scrollers-docs.factor
basis/ui/gadgets/tracks/tracks-docs.factor
basis/ui/gadgets/tracks/tracks.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/gestures/gestures.factor
basis/ui/pens/pens-docs.factor
basis/ui/tools/browser/browser.factor
basis/ui/tools/listener/completion/completion.factor
basis/ui/tools/listener/listener-docs.factor
basis/ui/tools/listener/listener.factor
basis/ui/tools/profiler/profiler.factor
basis/ui/traverse/traverse.factor
basis/ui/ui.factor
basis/unicode/collation/collation.factor
basis/unix/groups/groups.factor
basis/unix/types/macosx/macosx.factor
basis/unix/types/types.factor
basis/unix/unix.factor
basis/urls/urls.factor
basis/validators/validators.factor
basis/values/values.factor
basis/vectors/functor/functor.factor
basis/vm/vm.factor
basis/windows/com/com-tests.factor
basis/windows/com/syntax/syntax.factor
basis/windows/com/wrapper/wrapper-docs.factor
basis/windows/com/wrapper/wrapper.factor
basis/windows/dinput/constants/constants.factor
basis/windows/kernel32/kernel32.factor
basis/windows/shell32/shell32.factor
basis/xml/data/data.factor
basis/xml/entities/html/html.factor
basis/xml/syntax/syntax-docs.factor
basis/xml/syntax/syntax-tests.factor
basis/xml/syntax/syntax.factor
basis/xml/tests/encodings.factor
basis/xmode/catalog/catalog.factor
basis/xmode/marker/marker.factor
basis/xmode/rules/rules.factor
core/alien/alien-docs.factor
core/alien/alien.factor
core/alien/strings/strings-tests.factor
core/alien/strings/strings.factor
core/assocs/assocs-docs.factor
core/assocs/assocs-tests.factor
core/assocs/assocs.factor
core/bootstrap/layouts/layouts.factor
core/bootstrap/primitives.factor
core/bootstrap/stage1.factor
core/bootstrap/syntax.factor
core/byte-vectors/byte-vectors.factor
core/classes/algebra/algebra-docs.factor
core/classes/algebra/algebra-tests.factor
core/classes/algebra/algebra.factor
core/classes/builtin/builtin-docs.factor
core/classes/builtin/builtin.factor
core/classes/classes-tests.factor
core/classes/intersection/intersection.factor
core/classes/mixin/mixin.factor
core/classes/predicate/predicate.factor
core/classes/singleton/singleton.factor
core/classes/tuple/tuple-tests.factor
core/classes/tuple/tuple.factor
core/classes/union/union.factor
core/combinators/combinators-docs.factor
core/compiler/units/units-tests.factor
core/compiler/units/units.factor
core/continuations/continuations-docs.factor
core/definitions/definitions-docs.factor
core/definitions/definitions.factor
core/destructors/destructors.factor
core/effects/parser/parser.factor
core/generic/generic-docs.factor
core/generic/generic-tests.factor
core/generic/single/single.factor
core/growable/growable.factor
core/hashtables/hashtables-docs.factor
core/hashtables/hashtables-tests.factor
core/hashtables/hashtables.factor
core/io/binary/binary.factor
core/io/files/files-tests.factor
core/io/io.factor
core/io/pathnames/pathnames-docs.factor
core/io/pathnames/pathnames-tests.factor
core/io/pathnames/pathnames.factor
core/io/streams/byte-array/byte-array-docs.factor
core/io/streams/c/c.factor
core/io/streams/sequence/sequence.factor
core/kernel/kernel-docs.factor
core/kernel/kernel-tests.factor
core/kernel/kernel.factor
core/layouts/layouts-docs.factor
core/layouts/layouts.factor
core/math/integers/integers-docs.factor
core/math/integers/integers-tests.factor
core/math/integers/integers.factor
core/math/math.factor
core/math/parser/parser.factor
core/memory/memory-docs.factor
core/memory/memory-tests.factor
core/memory/memory.factor
core/namespaces/namespaces-docs.factor
core/parser/parser-docs.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/quotations/quotations-docs.factor
core/quotations/quotations.factor
core/sbufs/sbufs.factor
core/sequences/sequences-docs.factor
core/sequences/sequences-tests.factor
core/sequences/sequences.factor
core/sets/sets-docs.factor
core/sets/sets.factor
core/slots/slots-docs.factor
core/slots/slots.factor
core/source-files/errors/errors.factor
core/source-files/source-files-docs.factor
core/source-files/source-files.factor
core/splitting/splitting-docs.factor
core/splitting/splitting-tests.factor
core/splitting/splitting.factor
core/strings/strings-tests.factor
core/syntax/syntax-docs.factor
core/syntax/syntax.factor
core/vocabs/loader/loader-docs.factor
core/vocabs/parser/parser.factor
core/vocabs/vocabs-docs.factor
core/vocabs/vocabs.factor
core/words/words-docs.factor
core/words/words-tests.factor
core/words/words.factor
extra/4DNav/4DNav-docs.factor [deleted file]
extra/4DNav/4DNav.factor [deleted file]
extra/4DNav/authors.txt [deleted file]
extra/4DNav/camera/authors.txt [deleted file]
extra/4DNav/camera/camera-docs.factor [deleted file]
extra/4DNav/camera/camera.factor [deleted file]
extra/4DNav/deep/deep-docs.factor [deleted file]
extra/4DNav/deep/deep.factor [deleted file]
extra/4DNav/deploy.factor [deleted file]
extra/4DNav/file-chooser/authors.txt [deleted file]
extra/4DNav/file-chooser/file-chooser.factor [deleted file]
extra/4DNav/hypercube.xml [deleted file]
extra/4DNav/light_test.xml [deleted file]
extra/4DNav/multi solids.xml [deleted file]
extra/4DNav/prismetriagone.xml [deleted file]
extra/4DNav/space-file-decoder/authors.txt [deleted file]
extra/4DNav/space-file-decoder/space-file-decoder-docs.factor [deleted file]
extra/4DNav/space-file-decoder/space-file-decoder.factor [deleted file]
extra/4DNav/summary.txt [deleted file]
extra/4DNav/tags.txt [deleted file]
extra/4DNav/triancube.xml [deleted file]
extra/4DNav/turtle/authors.txt [deleted file]
extra/4DNav/turtle/turtle-docs.factor [deleted file]
extra/4DNav/turtle/turtle.factor [deleted file]
extra/4DNav/window3D/authors.txt [deleted file]
extra/4DNav/window3D/window3D-docs.factor [deleted file]
extra/4DNav/window3D/window3D.factor [deleted file]
extra/adsoda/adsoda-docs.factor [deleted file]
extra/adsoda/adsoda-tests.factor [deleted file]
extra/adsoda/adsoda.factor [deleted file]
extra/adsoda/adsoda.tests [deleted file]
extra/adsoda/authors.txt [deleted file]
extra/adsoda/combinators/authors.txt [deleted file]
extra/adsoda/combinators/combinators-docs.factor [deleted file]
extra/adsoda/combinators/combinators-tests.factor [deleted file]
extra/adsoda/combinators/combinators.factor [deleted file]
extra/adsoda/solution2/solution2.factor [deleted file]
extra/adsoda/solution2/summary.txt [deleted file]
extra/adsoda/summary.txt [deleted file]
extra/adsoda/tags.txt [deleted file]
extra/adsoda/tools/authors.txt [deleted file]
extra/adsoda/tools/tools-docs.factor [deleted file]
extra/adsoda/tools/tools-tests.factor [deleted file]
extra/adsoda/tools/tools.factor [deleted file]
extra/alien/data/map/map.factor
extra/annotations/annotations-tests.factor
extra/annotations/annotations.factor
extra/bank/bank.factor
extra/benchmark/backtrack/backtrack.factor
extra/benchmark/beust2/beust2.factor
extra/benchmark/e-ratios/e-ratios.factor
extra/benchmark/fannkuch/fannkuch.factor
extra/benchmark/fasta/fasta.factor
extra/benchmark/fib6/fib6.factor
extra/benchmark/knucleotide/knucleotide.factor
extra/benchmark/nsieve-bytes/nsieve-bytes.factor
extra/benchmark/reverse-complement/reverse-complement.factor
extra/benchmark/simd-1/simd-1.factor
extra/benchmark/tuple-arrays/tuple-arrays.factor
extra/benchmark/yuv-to-rgb/yuv-to-rgb.factor
extra/bunny/model/model.factor
extra/c/lexer/lexer-tests.factor
extra/c/lexer/lexer.factor
extra/c/preprocessor/preprocessor.factor
extra/calendar/holidays/authors.txt [new file with mode: 0644]
extra/calendar/holidays/canada/authors.txt [new file with mode: 0644]
extra/calendar/holidays/canada/canada-tests.factor [new file with mode: 0644]
extra/calendar/holidays/canada/canada.factor [new file with mode: 0644]
extra/calendar/holidays/holidays.factor [new file with mode: 0644]
extra/calendar/holidays/us/authors.txt [new file with mode: 0644]
extra/calendar/holidays/us/us-tests.factor [new file with mode: 0644]
extra/calendar/holidays/us/us.factor [new file with mode: 0644]
extra/closures/closures.factor
extra/couchdb/couchdb.factor
extra/crypto/aes/aes.factor
extra/crypto/passwd-md5/passwd-md5.factor
extra/curses/curses.factor
extra/db/info/info.factor
extra/decimals/decimals-tests.factor
extra/decimals/decimals.factor
extra/digraphs/digraphs.factor
extra/dns/cache/nx/nx.factor [deleted file]
extra/dns/cache/rr/rr.factor [deleted file]
extra/dns/dns.factor [deleted file]
extra/dns/forwarding/forwarding.factor [deleted file]
extra/dns/misc/misc.factor [deleted file]
extra/dns/resolver/resolver.factor [deleted file]
extra/dns/server/server.factor [deleted file]
extra/dns/stub/stub.factor [deleted file]
extra/dns/util/util.factor [deleted file]
extra/drills/deployed/deploy.factor [deleted file]
extra/drills/deployed/deployed.factor [deleted file]
extra/drills/deployed/tags.txt [deleted file]
extra/drills/drills.factor [deleted file]
extra/drills/tags.txt [deleted file]
extra/ecdsa/ecdsa.factor
extra/fonts/syntax/syntax.factor
extra/fries/fries.factor
extra/fuel/fuel.factor
extra/fuel/xref/xref.factor
extra/galois-talk/galois-talk.factor
extra/geo-ip/geo-ip.factor
extra/geobytes/geobytes.factor
extra/google-tech-talk/google-tech-talk.factor
extra/gpu/buffers/buffers.factor
extra/gpu/demos/bunny/bunny.factor
extra/gpu/framebuffers/framebuffers.factor
extra/gpu/render/render.factor
extra/gpu/shaders/shaders.factor
extra/gpu/util/wasd/wasd.factor
extra/half-floats/authors.txt [deleted file]
extra/half-floats/half-floats-tests.factor [deleted file]
extra/half-floats/half-floats.factor [deleted file]
extra/half-floats/summary.txt [deleted file]
extra/histogram/histogram-docs.factor [deleted file]
extra/histogram/histogram-tests.factor [deleted file]
extra/histogram/histogram.factor [deleted file]
extra/html/parser/parser.factor
extra/images/normalization/authors.txt [deleted file]
extra/images/normalization/normalization-docs.factor [deleted file]
extra/images/normalization/normalization-tests.factor [deleted file]
extra/images/normalization/normalization.factor [deleted file]
extra/images/testing/bmp/1bit.bmp [new file with mode: 0644]
extra/images/testing/bmp/42red_24bit.bmp [new file with mode: 0644]
extra/images/testing/bmp/42red_24bit.fig [new file with mode: 0644]
extra/images/testing/bmp/rgb_4bit.bmp [new file with mode: 0644]
extra/images/testing/bmp/rgb_8bit.bmp [new file with mode: 0644]
extra/images/testing/bmp/rgb_8bit.fig [new file with mode: 0644]
extra/images/testing/gif/alpha.fig [new file with mode: 0644]
extra/images/testing/gif/alpha.gif [new file with mode: 0644]
extra/images/testing/gif/astronaut_animation.fig [new file with mode: 0644]
extra/images/testing/gif/astronaut_animation.gif [new file with mode: 0644]
extra/images/testing/gif/checkmark.fig [new file with mode: 0644]
extra/images/testing/gif/checkmark.gif [new file with mode: 0644]
extra/images/testing/gif/circle.fig [new file with mode: 0644]
extra/images/testing/gif/circle.gif [new file with mode: 0644]
extra/images/testing/gif/monochrome.fig [new file with mode: 0644]
extra/images/testing/gif/monochrome.gif [new file with mode: 0644]
extra/images/testing/gif/noise.fig [new file with mode: 0644]
extra/images/testing/gif/noise.gif [new file with mode: 0644]
extra/images/testing/png/basn2c08.fig [new file with mode: 0644]
extra/images/testing/png/basn2c08.png [new file with mode: 0644]
extra/images/testing/png/basn6a08.fig [new file with mode: 0644]
extra/images/testing/png/basn6a08.png [new file with mode: 0644]
extra/images/testing/png/f00n2c08.fig [new file with mode: 0644]
extra/images/testing/png/f00n2c08.png [new file with mode: 0644]
extra/images/testing/png/f01n2c08.fig [new file with mode: 0644]
extra/images/testing/png/f01n2c08.png [new file with mode: 0644]
extra/images/testing/png/f02n2c08.fig [new file with mode: 0644]
extra/images/testing/png/f02n2c08.png [new file with mode: 0644]
extra/images/testing/png/f03n2c08.fig [new file with mode: 0644]
extra/images/testing/png/f03n2c08.png [new file with mode: 0644]
extra/images/testing/png/f04n2c08.fig [new file with mode: 0644]
extra/images/testing/png/f04n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/basi0g01.png [new file with mode: 0644]
extra/images/testing/png/suite/basi0g02.png [new file with mode: 0644]
extra/images/testing/png/suite/basi0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/basi0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/basi0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/basi2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/basi2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/basi3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/basi3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/basi3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/basi3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/basi4a08.png [new file with mode: 0644]
extra/images/testing/png/suite/basi4a16.png [new file with mode: 0644]
extra/images/testing/png/suite/basi6a08.png [new file with mode: 0644]
extra/images/testing/png/suite/basi6a16.png [new file with mode: 0644]
extra/images/testing/png/suite/basn0g01.png [new file with mode: 0644]
extra/images/testing/png/suite/basn0g02.png [new file with mode: 0644]
extra/images/testing/png/suite/basn0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/basn0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/basn0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/basn2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/basn2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/basn3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/basn3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/basn3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/basn3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/basn4a08.png [new file with mode: 0644]
extra/images/testing/png/suite/basn4a16.png [new file with mode: 0644]
extra/images/testing/png/suite/basn6a08.png [new file with mode: 0644]
extra/images/testing/png/suite/basn6a16.png [new file with mode: 0644]
extra/images/testing/png/suite/bgai4a08.png [new file with mode: 0644]
extra/images/testing/png/suite/bgai4a16.png [new file with mode: 0644]
extra/images/testing/png/suite/bgan6a08.png [new file with mode: 0644]
extra/images/testing/png/suite/bgan6a16.png [new file with mode: 0644]
extra/images/testing/png/suite/bgbn4a08.png [new file with mode: 0644]
extra/images/testing/png/suite/bggn4a16.png [new file with mode: 0644]
extra/images/testing/png/suite/bgwn6a08.png [new file with mode: 0644]
extra/images/testing/png/suite/bgyn6a16.png [new file with mode: 0644]
extra/images/testing/png/suite/ccwn2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/ccwn3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/cdfn2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/cdhn2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/cdsn2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/cdun2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/ch1n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/ch2n3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/cm0n0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/cm7n0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/cm9n0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/cs3n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/cs3n3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/cs5n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/cs5n3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/cs8n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/cs8n3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/ct0n0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/ct1n0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/ctzn0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/f00n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/f00n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/f01n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/f01n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/f02n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/f02n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/f03n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/f03n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/f04n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/f04n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g03n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/g03n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g03n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/g04n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/g04n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g04n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/g05n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/g05n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g05n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/g07n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/g07n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g07n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/g10n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/g10n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g10n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/g25n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/g25n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/g25n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/oi1n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi1n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi2n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi2n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi4n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi4n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi9n0g16.png [new file with mode: 0644]
extra/images/testing/png/suite/oi9n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/pngsuite.doc [new file with mode: 0644]
extra/images/testing/png/suite/pngsuite_logo.png [new file with mode: 0644]
extra/images/testing/png/suite/pp0n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/pp0n6a08.png [new file with mode: 0644]
extra/images/testing/png/suite/ps1n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/ps1n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/ps2n0g08.png [new file with mode: 0644]
extra/images/testing/png/suite/ps2n2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/s01i3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s01n3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s02i3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s02n3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s03i3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s03n3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s04i3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s04n3p01.png [new file with mode: 0644]
extra/images/testing/png/suite/s05i3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s05n3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s06i3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s06n3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s07i3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s07n3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s08i3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s08n3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s09i3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s09n3p02.png [new file with mode: 0644]
extra/images/testing/png/suite/s32i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s32n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s33i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s33n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s34i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s34n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s35i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s35n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s36i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s36n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s37i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s37n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s38i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s38n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s39i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s39n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s40i3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/s40n3p04.png [new file with mode: 0644]
extra/images/testing/png/suite/tbbn1g04.png [new file with mode: 0644]
extra/images/testing/png/suite/tbbn2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/tbbn3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/tbgn2c16.png [new file with mode: 0644]
extra/images/testing/png/suite/tbgn3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/tbrn2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/tbwn1g16.png [new file with mode: 0644]
extra/images/testing/png/suite/tbwn3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/tbyn3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/tp0n1g08.png [new file with mode: 0644]
extra/images/testing/png/suite/tp0n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/tp0n3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/tp1n3p08.png [new file with mode: 0644]
extra/images/testing/png/suite/x00n0g01.png [new file with mode: 0644]
extra/images/testing/png/suite/xcrn0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/xlfn0g04.png [new file with mode: 0644]
extra/images/testing/png/suite/z00n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/z03n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/z06n2c08.png [new file with mode: 0644]
extra/images/testing/png/suite/z09n2c08.png [new file with mode: 0644]
extra/images/testing/png/z00n2c08.fig [new file with mode: 0644]
extra/images/testing/png/z00n2c08.png [new file with mode: 0644]
extra/images/testing/png/z03n2c08.fig [new file with mode: 0644]
extra/images/testing/png/z03n2c08.png [new file with mode: 0644]
extra/images/testing/png/z06n2c08.fig [new file with mode: 0644]
extra/images/testing/png/z06n2c08.png [new file with mode: 0644]
extra/images/testing/png/z09n2c08.fig [new file with mode: 0644]
extra/images/testing/png/z09n2c08.png [new file with mode: 0644]
extra/images/testing/testing-docs.factor [new file with mode: 0644]
extra/images/testing/testing.factor [new file with mode: 0644]
extra/images/testing/tiff/alpha.fig [new file with mode: 0644]
extra/images/testing/tiff/alpha.tiff [new file with mode: 0644]
extra/images/testing/tiff/color_spectrum.fig [new file with mode: 0644]
extra/images/testing/tiff/color_spectrum.tiff [new file with mode: 0644]
extra/images/testing/tiff/elephants.tiff [new file with mode: 0644]
extra/images/testing/tiff/noise.fig [new file with mode: 0644]
extra/images/testing/tiff/noise.tiff [new file with mode: 0644]
extra/images/testing/tiff/octagon.fig [new file with mode: 0644]
extra/images/testing/tiff/octagon.tiff [new file with mode: 0644]
extra/images/testing/tiff/rgb.fig [new file with mode: 0644]
extra/images/testing/tiff/rgb.tiff [new file with mode: 0755]
extra/infix/infix-docs.factor
extra/infix/infix-tests.factor
extra/infix/infix.factor
extra/io/serial/windows/windows.factor
extra/irc/client/chats/chats.factor
extra/irc/client/internals/internals.factor
extra/irc/gitbot/gitbot.factor
extra/irc/logbot/logbot.factor
extra/jamshred/gl/gl.factor
extra/jamshred/oint/oint.factor
extra/jamshred/player/player.factor
extra/jamshred/tunnel/tunnel-tests.factor
extra/jamshred/tunnel/tunnel.factor
extra/joystick-demo/joystick-demo.factor
extra/key-handlers/key-handlers.factor
extra/koszul/koszul.factor
extra/llvm/types/types.factor
extra/mason/common/common.factor
extra/mason/platform/platform.factor
extra/math/affine-transforms/affine-transforms.factor
extra/math/analysis/analysis-docs.factor
extra/math/analysis/analysis.factor
extra/math/binpack/binpack.factor
extra/math/finance/finance.factor
extra/math/matrices/simd/simd.factor
extra/math/quadratic/quadratic.factor
extra/models/combinators/authors.txt [deleted file]
extra/models/combinators/combinators-docs.factor [deleted file]
extra/models/combinators/combinators.factor [deleted file]
extra/models/combinators/summary.txt [deleted file]
extra/models/combinators/templates/templates.factor [deleted file]
extra/models/illusion/authors.txt [new file with mode: 0644]
extra/models/illusion/illusion.factor [new file with mode: 0644]
extra/models/illusion/summary.txt [new file with mode: 0644]
extra/money/money.factor
extra/mongodb/connection/connection.factor
extra/mongodb/driver/driver.factor
extra/mongodb/msg/msg.factor
extra/mongodb/operations/operations.factor
extra/mongodb/tuple/collection/collection.factor
extra/mongodb/tuple/persistent/persistent.factor
extra/mongodb/tuple/state/state.factor
extra/monotonic-clock/authors.txt [new file with mode: 0644]
extra/monotonic-clock/monotonic-clock.factor [new file with mode: 0755]
extra/monotonic-clock/unix/authors.txt [new file with mode: 0644]
extra/monotonic-clock/unix/macosx/authors.txt [new file with mode: 0644]
extra/monotonic-clock/unix/macosx/macosx.factor [new file with mode: 0755]
extra/monotonic-clock/unix/macosx/tags.txt [new file with mode: 0644]
extra/monotonic-clock/unix/unix.factor [new file with mode: 0644]
extra/monotonic-clock/windows/authors.txt [new file with mode: 0644]
extra/monotonic-clock/windows/tags.txt [new file with mode: 0644]
extra/monotonic-clock/windows/windows.factor [new file with mode: 0755]
extra/morse/morse.factor
extra/multi-methods/multi-methods.factor
extra/multi-methods/tests/definitions.factor
extra/noise/noise.factor
extra/nurbs/nurbs.factor
extra/pair-rocket/pair-rocket.factor
extra/parser-combinators/parser-combinators.factor
extra/partial-continuations/partial-continuations-tests.factor
extra/persistency/persistency.factor
extra/pop3/authors.txt [new file with mode: 0644]
extra/pop3/pop3-docs.factor [new file with mode: 0644]
extra/pop3/pop3-tests.factor [new file with mode: 0644]
extra/pop3/pop3.factor [new file with mode: 0644]
extra/pop3/server/server.factor [new file with mode: 0644]
extra/pop3/server/summary.txt [new file with mode: 0644]
extra/pop3/summary.txt [new file with mode: 0644]
extra/pop3/tags.txt [new file with mode: 0644]
extra/project-euler/002/002.factor
extra/project-euler/017/017.factor
extra/project-euler/021/021.factor
extra/project-euler/028/028.factor
extra/project-euler/030/030.factor
extra/project-euler/034/034.factor
extra/project-euler/038/038.factor
extra/project-euler/040/040.factor
extra/project-euler/043/043.factor
extra/project-euler/048/048.factor
extra/project-euler/053/053.factor
extra/project-euler/062/062-tests.factor [new file with mode: 0644]
extra/project-euler/062/062.factor [new file with mode: 0644]
extra/project-euler/062/authors.txt [new file with mode: 0644]
extra/project-euler/063/063.factor
extra/project-euler/072/072.factor
extra/project-euler/073/073.factor
extra/project-euler/074/074.factor
extra/project-euler/089/089-tests.factor [new file with mode: 0644]
extra/project-euler/089/089.factor [new file with mode: 0644]
extra/project-euler/089/authors.txt [new file with mode: 0644]
extra/project-euler/089/roman.txt [new file with mode: 0644]
extra/project-euler/092/092.factor
extra/project-euler/100/100.factor
extra/project-euler/116/116.factor
extra/project-euler/117/117.factor
extra/project-euler/150/150.factor
extra/project-euler/190/190.factor
extra/project-euler/ave-time/ave-time-docs.factor
extra/project-euler/ave-time/ave-time-tests.factor [new file with mode: 0644]
extra/project-euler/ave-time/ave-time.factor
extra/project-euler/common/common.factor
extra/project-euler/project-euler.factor
extra/quadtrees/quadtrees.factor
extra/qw/qw.factor
extra/random/blum-blum-shub/blum-blum-shub-tests.factor
extra/random/lagged-fibonacci/lagged-fibonacci.factor
extra/recipes/authors.txt [deleted file]
extra/recipes/icons/back.tiff [deleted file]
extra/recipes/icons/hate.tiff [deleted file]
extra/recipes/icons/love.tiff [deleted file]
extra/recipes/icons/more.tiff [deleted file]
extra/recipes/icons/submit.tiff [deleted file]
extra/recipes/recipes.factor [deleted file]
extra/recipes/summary.txt [deleted file]
extra/redis/redis.factor
extra/reports/noise/noise.factor
extra/rot13/rot13.factor
extra/sequence-parser/sequence-parser-tests.factor [deleted file]
extra/sequence-parser/sequence-parser.factor [deleted file]
extra/sequences/abbrev/abbrev.factor
extra/sequences/merged/authors.txt [deleted file]
extra/sequences/merged/merged-docs.factor [deleted file]
extra/sequences/merged/merged-tests.factor [deleted file]
extra/sequences/merged/merged.factor [deleted file]
extra/sequences/merged/summary.txt [deleted file]
extra/sequences/merged/tags.txt [deleted file]
extra/sequences/modified/modified.factor
extra/sequences/product/authors.txt [deleted file]
extra/sequences/product/product-docs.factor [deleted file]
extra/sequences/product/product-tests.factor [deleted file]
extra/sequences/product/product.factor [deleted file]
extra/sequences/product/summary.txt [deleted file]
extra/sequences/repeating/repeating.factor
extra/set-n/set-n.factor
extra/slides/slides.factor
extra/space-invaders/space-invaders.factor
extra/spider/spider.factor
extra/spider/unique-deque/unique-deque.factor
extra/sudokus/authors.txt [deleted file]
extra/sudokus/sudokus.factor [deleted file]
extra/sudokus/summary.txt [deleted file]
extra/synth/synth.factor
extra/tetris/game/game.factor
extra/tetris/piece/piece.factor
extra/tokyo/assoc-functor/assoc-functor.factor
extra/trees/avl/avl.factor
extra/trees/splay/splay.factor
extra/trees/trees.factor
extra/ui/gadgets/alerts/alerts.factor [deleted file]
extra/ui/gadgets/alerts/authors.txt [deleted file]
extra/ui/gadgets/alerts/summary.txt [deleted file]
extra/ui/gadgets/comboboxes/authors.txt [deleted file]
extra/ui/gadgets/comboboxes/comboboxes.factor [deleted file]
extra/ui/gadgets/comboboxes/summary.txt [deleted file]
extra/ui/gadgets/controls/authors.txt [deleted file]
extra/ui/gadgets/controls/controls-docs.factor [deleted file]
extra/ui/gadgets/controls/controls.factor [deleted file]
extra/ui/gadgets/controls/summary.txt [deleted file]
extra/ui/gadgets/layout/authors.txt [deleted file]
extra/ui/gadgets/layout/layout-docs.factor [deleted file]
extra/ui/gadgets/layout/layout.factor [deleted file]
extra/ui/gadgets/layout/summary.txt [deleted file]
extra/ui/gadgets/lists/lists.factor
extra/ui/gadgets/poppers/authors.txt [deleted file]
extra/ui/gadgets/poppers/poppers.factor [deleted file]
extra/units/units-tests.factor
extra/units/units.factor
extra/usa-cities/usa-cities.factor
extra/vocabs/git/authors.txt [new file with mode: 0644]
extra/vocabs/git/git.factor [new file with mode: 0644]
extra/vpri-talk/vpri-talk.factor
misc/Factor.tmbundle/Snippets/let.tmSnippet
misc/bash/cdfactor.sh
misc/fuel/fuel-syntax.el
misc/vim/syntax/factor.vim
readme.html
unmaintained/4DNav/4DNav-docs.factor [new file with mode: 0755]
unmaintained/4DNav/4DNav.factor [new file with mode: 0755]
unmaintained/4DNav/authors.txt [new file with mode: 0755]
unmaintained/4DNav/camera/authors.txt [new file with mode: 0755]
unmaintained/4DNav/camera/camera-docs.factor [new file with mode: 0755]
unmaintained/4DNav/camera/camera.factor [new file with mode: 0755]
unmaintained/4DNav/deep/deep-docs.factor [new file with mode: 0755]
unmaintained/4DNav/deep/deep.factor [new file with mode: 0755]
unmaintained/4DNav/deploy.factor [new file with mode: 0755]
unmaintained/4DNav/file-chooser/authors.txt [new file with mode: 0755]
unmaintained/4DNav/file-chooser/file-chooser.factor [new file with mode: 0755]
unmaintained/4DNav/hypercube.xml [new file with mode: 0755]
unmaintained/4DNav/light_test.xml [new file with mode: 0755]
unmaintained/4DNav/multi solids.xml [new file with mode: 0755]
unmaintained/4DNav/prismetriagone.xml [new file with mode: 0755]
unmaintained/4DNav/space-file-decoder/authors.txt [new file with mode: 0755]
unmaintained/4DNav/space-file-decoder/space-file-decoder-docs.factor [new file with mode: 0755]
unmaintained/4DNav/space-file-decoder/space-file-decoder.factor [new file with mode: 0755]
unmaintained/4DNav/summary.txt [new file with mode: 0755]
unmaintained/4DNav/tags.txt [new file with mode: 0755]
unmaintained/4DNav/triancube.xml [new file with mode: 0755]
unmaintained/4DNav/turtle/authors.txt [new file with mode: 0755]
unmaintained/4DNav/turtle/turtle-docs.factor [new file with mode: 0755]
unmaintained/4DNav/turtle/turtle.factor [new file with mode: 0755]
unmaintained/4DNav/window3D/authors.txt [new file with mode: 0755]
unmaintained/4DNav/window3D/window3D-docs.factor [new file with mode: 0755]
unmaintained/4DNav/window3D/window3D.factor [new file with mode: 0755]
unmaintained/adsoda/adsoda-docs.factor [new file with mode: 0755]
unmaintained/adsoda/adsoda-tests.factor [new file with mode: 0755]
unmaintained/adsoda/adsoda.factor [new file with mode: 0755]
unmaintained/adsoda/adsoda.tests [new file with mode: 0755]
unmaintained/adsoda/authors.txt [new file with mode: 0755]
unmaintained/adsoda/combinators/authors.txt [new file with mode: 0755]
unmaintained/adsoda/combinators/combinators-docs.factor [new file with mode: 0755]
unmaintained/adsoda/combinators/combinators-tests.factor [new file with mode: 0755]
unmaintained/adsoda/combinators/combinators.factor [new file with mode: 0755]
unmaintained/adsoda/solution2/solution2.factor [new file with mode: 0755]
unmaintained/adsoda/solution2/summary.txt [new file with mode: 0755]
unmaintained/adsoda/summary.txt [new file with mode: 0755]
unmaintained/adsoda/tags.txt [new file with mode: 0755]
unmaintained/adsoda/tools/authors.txt [new file with mode: 0755]
unmaintained/adsoda/tools/tools-docs.factor [new file with mode: 0755]
unmaintained/adsoda/tools/tools-tests.factor [new file with mode: 0755]
unmaintained/adsoda/tools/tools.factor [new file with mode: 0755]
unmaintained/advice/advice.factor
unmaintained/combinators/cleave/authors.txt [deleted file]
unmaintained/combinators/cleave/cleave-tests.factor [deleted file]
unmaintained/combinators/cleave/cleave.factor [deleted file]
unmaintained/combinators/cleave/enhanced/enhanced.factor [deleted file]
unmaintained/combinators/conditional/conditional.factor [deleted file]
unmaintained/dns/cache/nx/nx.factor [new file with mode: 0644]
unmaintained/dns/cache/rr/rr.factor [new file with mode: 0644]
unmaintained/dns/dns.factor [new file with mode: 0644]
unmaintained/dns/forwarding/forwarding.factor [new file with mode: 0644]
unmaintained/dns/misc/misc.factor [new file with mode: 0644]
unmaintained/dns/resolver/resolver.factor [new file with mode: 0644]
unmaintained/dns/server/server.factor [new file with mode: 0644]
unmaintained/dns/stub/stub.factor [new file with mode: 0644]
unmaintained/dns/util/util.factor [new file with mode: 0644]
unmaintained/drills/deployed/deploy.factor [new file with mode: 0644]
unmaintained/drills/deployed/deployed.factor [new file with mode: 0644]
unmaintained/drills/deployed/tags.txt [new file with mode: 0644]
unmaintained/drills/drills.factor [new file with mode: 0644]
unmaintained/drills/tags.txt [new file with mode: 0644]
unmaintained/graph-theory/graph-theory.factor
unmaintained/models/combinators/authors.txt [new file with mode: 0644]
unmaintained/models/combinators/combinators-docs.factor [new file with mode: 0644]
unmaintained/models/combinators/combinators.factor [new file with mode: 0644]
unmaintained/models/combinators/summary.txt [new file with mode: 0644]
unmaintained/models/combinators/templates/templates.factor [new file with mode: 0644]
unmaintained/newfx/newfx.factor [deleted file]
unmaintained/recipes/authors.txt [new file with mode: 0644]
unmaintained/recipes/icons/back.tiff [new file with mode: 0644]
unmaintained/recipes/icons/hate.tiff [new file with mode: 0644]
unmaintained/recipes/icons/love.tiff [new file with mode: 0644]
unmaintained/recipes/icons/more.tiff [new file with mode: 0644]
unmaintained/recipes/icons/submit.tiff [new file with mode: 0644]
unmaintained/recipes/recipes.factor [new file with mode: 0644]
unmaintained/recipes/summary.txt [new file with mode: 0644]
unmaintained/sudokus/authors.txt [new file with mode: 0644]
unmaintained/sudokus/sudokus.factor [new file with mode: 0644]
unmaintained/sudokus/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/alerts/alerts.factor [new file with mode: 0644]
unmaintained/ui/gadgets/alerts/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/alerts/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/comboboxes/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/comboboxes/comboboxes.factor [new file with mode: 0644]
unmaintained/ui/gadgets/comboboxes/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/controls/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/controls/controls-docs.factor [new file with mode: 0644]
unmaintained/ui/gadgets/controls/controls.factor [new file with mode: 0644]
unmaintained/ui/gadgets/controls/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/layout/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/layout/layout-docs.factor [new file with mode: 0644]
unmaintained/ui/gadgets/layout/layout.factor [new file with mode: 0644]
unmaintained/ui/gadgets/layout/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/poppers/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/poppers/poppers.factor [new file with mode: 0644]
vm/aging_collector.cpp
vm/aging_collector.hpp
vm/aging_space.hpp
vm/alien.cpp
vm/allot.hpp [new file with mode: 0644]
vm/arrays.cpp
vm/arrays.hpp
vm/bignum.cpp
vm/bitwise_hacks.hpp [new file with mode: 0644]
vm/bump_allocator.hpp [new file with mode: 0644]
vm/byte_arrays.cpp
vm/byte_arrays.hpp
vm/callbacks.cpp
vm/callstack.cpp
vm/callstack.hpp
vm/code_block.cpp
vm/code_block_visitor.hpp [new file with mode: 0644]
vm/code_heap.cpp
vm/code_heap.hpp
vm/code_roots.hpp [new file with mode: 0644]
vm/collector.hpp
vm/compaction.cpp [new file with mode: 0644]
vm/compaction.hpp [new file with mode: 0644]
vm/contexts.cpp
vm/contexts.hpp
vm/copying_collector.hpp
vm/cpu-ppc.S
vm/cpu-x86.32.S
vm/cpu-x86.64.S
vm/cpu-x86.S
vm/data_heap.cpp
vm/data_heap.hpp
vm/data_heap_checker.cpp [new file with mode: 0644]
vm/data_roots.hpp [new file with mode: 0644]
vm/debug.cpp
vm/dispatch.cpp
vm/dispatch.hpp
vm/errors.cpp
vm/errors.hpp
vm/factor.cpp
vm/free_list.cpp [new file with mode: 0644]
vm/free_list.hpp [new file with mode: 0644]
vm/free_list_allocator.hpp [new file with mode: 0644]
vm/full_collector.cpp
vm/full_collector.hpp
vm/gc.cpp
vm/gc.hpp
vm/generic_arrays.hpp
vm/heap.cpp [deleted file]
vm/heap.hpp [deleted file]
vm/image.cpp
vm/image.hpp
vm/inline_cache.cpp
vm/io.cpp
vm/jit.cpp
vm/jit.hpp
vm/layouts.hpp
vm/local_roots.hpp [deleted file]
vm/mach_signal.cpp
vm/mark_bits.hpp
vm/master.hpp
vm/math.cpp
vm/math.hpp
vm/nursery_collector.cpp
vm/nursery_collector.hpp
vm/nursery_space.hpp [new file with mode: 0644]
vm/object_start_map.cpp [new file with mode: 0644]
vm/object_start_map.hpp [new file with mode: 0644]
vm/objects.cpp [new file with mode: 0644]
vm/objects.hpp [new file with mode: 0644]
vm/old_space.cpp [deleted file]
vm/old_space.hpp [deleted file]
vm/os-freebsd-x86.32.hpp
vm/os-freebsd-x86.64.hpp
vm/os-genunix.hpp
vm/os-linux-arm.hpp
vm/os-linux-ppc.hpp
vm/os-linux-x86.32.hpp
vm/os-linux-x86.64.hpp
vm/os-macosx-ppc.hpp
vm/os-macosx-x86.32.hpp
vm/os-macosx-x86.64.hpp
vm/os-macosx.hpp
vm/os-macosx.mm
vm/os-netbsd-x86.32.hpp
vm/os-netbsd-x86.64.hpp
vm/os-openbsd-x86.32.hpp
vm/os-openbsd-x86.64.hpp
vm/os-solaris-x86.32.hpp
vm/os-solaris-x86.64.hpp
vm/os-unix.cpp
vm/os-windows.hpp
vm/primitives.cpp
vm/profiler.cpp
vm/quotations.cpp
vm/quotations.hpp
vm/run.cpp
vm/run.hpp
vm/slot_visitor.hpp [new file with mode: 0644]
vm/strings.cpp
vm/strings.hpp
vm/tagged.hpp
vm/tenured_space.hpp
vm/to_tenured_collector.cpp
vm/to_tenured_collector.hpp
vm/tuples.cpp
vm/tuples.hpp
vm/utilities.cpp
vm/utilities.hpp
vm/vm.cpp
vm/vm.hpp
vm/words.cpp
vm/words.hpp
vm/zone.hpp [deleted file]

index 35cf7a05c4293a94fc18c6e340eff43b8dc9dbcc..6aee3e329df38352f8084559496d16260c086863 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -41,22 +41,25 @@ DLL_OBJS = $(PLAF_DLL_OBJS) \
        vm/callstack.o \
        vm/code_block.o \
        vm/code_heap.o \
+       vm/compaction.o \
        vm/contexts.o \
        vm/data_heap.o \
+       vm/data_heap_checker.o \
        vm/debug.o \
        vm/dispatch.o \
        vm/errors.o \
        vm/factor.o \
+       vm/free_list.o \
        vm/full_collector.o \
        vm/gc.o \
-       vm/heap.o \
        vm/image.o \
        vm/inline_cache.o \
        vm/io.o \
        vm/jit.o \
        vm/math.o \
        vm/nursery_collector.o \
-       vm/old_space.o \
+       vm/object_start_map.o \
+       vm/objects.o \
        vm/primitives.o \
        vm/profiler.o \
        vm/quotations.o \
index 82134e825ea1320da202a2069d254212904bbdd5..df88f497016bf9b841c67732f7900663ced17111 100644 (file)
@@ -1,16 +1,23 @@
-IN: alarms\r
 USING: help.markup help.syntax calendar quotations ;\r
+IN: alarms\r
 \r
 HELP: alarm\r
 { $class-description "An alarm. Can be passed to " { $link cancel-alarm } "." } ;\r
 \r
 HELP: add-alarm\r
 { $values { "quot" quotation } { "time" timestamp } { "frequency" { $maybe duration } } { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm. If " { $snippet "frequency" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency. The quotation will be called from the alarm thread." } ;\r
+{ $description "Creates and registers an alarm to start at " { $snippet "time" } ". If " { $snippet "frequency" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency. The quotation will be called from the alarm thread." } ;\r
 \r
 HELP: later\r
 { $values { "quot" quotation } { "duration" duration } { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } " from now." } ;\r
+{ $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } " from now." }\r
+{ $examples\r
+    { $unchecked-example\r
+        "USING: alarms io calendar ;"\r
+        """[ "GET BACK TO WORK, Guy." print flush ] 10 minutes later drop"""\r
+        ""\r
+    }\r
+} ;\r
 \r
 HELP: cancel-alarm\r
 { $values { "alarm" alarm } }\r
@@ -20,16 +27,29 @@ HELP: every
 { $values\r
      { "quot" quotation } { "duration" duration }\r
      { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency." } ;\r
+{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency." }\r
+{ $examples\r
+    { $unchecked-example\r
+        "USING: alarms io calendar ;"\r
+        """[ "Hi Buddy." print flush ] 10 seconds every drop"""\r
+        ""\r
+    }\r
+} ;\r
 \r
 ARTICLE: "alarms" "Alarms"\r
-"The " { $vocab-link "alarms" } " vocabulary provides a lightweight way to schedule one-time and recurring tasks without spawning a new thread."\r
+"The " { $vocab-link "alarms" } " vocabulary provides a lightweight way to schedule one-time and recurring tasks without spawning a new thread." $nl\r
+"The alarm class:"\r
 { $subsections\r
     alarm\r
-    add-alarm\r
-    later\r
-    cancel-alarm\r
 }\r
+"Register a recurring alarm:"\r
+{ $subsections every }\r
+"Register a one-time alarm:"\r
+{ $subsections later }\r
+"Low-level interface to add alarms:"\r
+{ $subsections add-alarm }\r
+"Cancelling an alarm:"\r
+{ $subsections cancel-alarm }\r
 "Alarms do not persist across image saves. Saving and restoring an image has the effect of calling " { $link cancel-alarm } " on all " { $link alarm } " instances." ;\r
 \r
 ABOUT: "alarms"\r
index ee75d22c2c74618c0775fc5337551dd063210c1d..7eed1a0664505f7a68bf026753a9bad612fa6c7c 100755 (executable)
@@ -20,6 +20,8 @@ M: array heap-size unclip [ array-length ] [ heap-size ] bi* * ;
 
 M: array c-type-align first c-type-align ;
 
+M: array c-type-align-first first c-type-align-first ;
+
 M: array c-type-stack-align? drop f ;
 
 M: array unbox-parameter drop void* unbox-parameter ;
@@ -55,6 +57,9 @@ M: string-type heap-size
 M: string-type c-type-align
     drop void* c-type-align ;
 
+M: string-type c-type-align-first
+    drop void* c-type-align-first ;
+
 M: string-type c-type-stack-align?
     drop void* c-type-stack-align? ;
 
@@ -97,5 +102,5 @@ M: string-type c-type-setter
 { char* utf8 } char* typedef
 char* uchar* typedef
 
-char  char*  "pointer-c-type" set-word-prop
+char char* "pointer-c-type" set-word-prop
 uchar uchar* "pointer-c-type" set-word-prop
index d622a42c9dc9ab56bc7eaf5c86edff8118354917..027fe046b62aa9d82b05c0104f481b09d737dcf7 100755 (executable)
@@ -30,8 +30,9 @@ TUPLE: abstract-c-type
 { unboxer-quot callable }
 { getter callable }
 { setter callable }
-size
-align ;
+{ size integer }
+{ align integer }
+{ align-first integer } ;
 
 TUPLE: c-type < abstract-c-type
 boxer
@@ -104,10 +105,9 @@ M: word c-type
 
 GENERIC: c-struct? ( c-type -- ? )
 
-M: object c-struct?
-    drop f ;
-M: c-type-name c-struct?
-    dup void? [ drop f ] [ c-type c-struct? ] if ;
+M: object c-struct? drop f ;
+
+M: c-type-name c-struct? dup void? [ drop f ] [ c-type c-struct? ] if ;
 
 ! These words being foldable means that words need to be
 ! recompiled if a C type is redefined. Even so, folding the
@@ -172,6 +172,12 @@ M: abstract-c-type c-type-align align>> ;
 
 M: c-type-name c-type-align c-type c-type-align ;
 
+GENERIC: c-type-align-first ( name -- n )
+
+M: c-type-name c-type-align-first c-type c-type-align-first ;
+
+M: abstract-c-type c-type-align-first align-first>> ;
+
 GENERIC: c-type-stack-align? ( name -- ? )
 
 M: c-type c-type-stack-align? stack-align?>> ;
@@ -230,6 +236,10 @@ M: byte-array byte-length length ; inline
 
 M: f byte-length drop 0 ; inline
 
+: >c-bool ( ? -- int ) 1 0 ? ; inline
+
+: c-bool> ( int -- ? ) 0 = not ; inline
+
 MIXIN: value-type
 
 : c-getter ( name -- quot )
@@ -256,6 +266,7 @@ PREDICATE: typedef-word < c-type-word
     "c-type" word-prop c-type-name? ;
 
 M: string typedef ( old new -- ) c-types get set-at ;
+
 M: word typedef ( old new -- )
     {
         [ nip define-symbol ]
@@ -292,7 +303,7 @@ M: long-long-type box-return ( c-type -- )
 
 : define-out ( name -- )
     [ "alien.c-types" constructor-word ]
-    [ dup c-setter '[ _ heap-size <byte-array> [ 0 @ ] keep ] ] bi
+    [ dup c-setter '[ _ heap-size (byte-array) [ 0 @ ] keep ] ] bi
     (( value -- c-ptr )) define-inline ;
 
 : define-primitive-type ( c-type name -- )
@@ -319,6 +330,13 @@ SYMBOLS:
     ptrdiff_t intptr_t uintptr_t size_t
     char* uchar* ;
 
+: 8-byte-alignment ( c-type -- c-type )
+    {
+        { [ cpu ppc? os macosx? and ] [ 4 >>align 8 >>align-first ] }
+        { [ cpu x86.32? os windows? not and ] [ 4 >>align 4 >>align-first ] }
+        [ 8 >>align 8 >>align-first ]
+    } cond ;
+
 [
     <c-type>
         c-ptr >>class
@@ -327,6 +345,7 @@ SYMBOLS:
         [ [ >c-ptr ] 2dip set-alien-cell ] >>setter
         bootstrap-cell >>size
         bootstrap-cell >>align
+        bootstrap-cell >>align-first
         [ >c-ptr ] >>unboxer-quot
         "box_alien" >>boxer
         "alien_offset" >>unboxer
@@ -338,7 +357,7 @@ SYMBOLS:
         [ alien-signed-8 ] >>getter
         [ set-alien-signed-8 ] >>setter
         8 >>size
-        8 >>align
+        8-byte-alignment
         "box_signed_8" >>boxer
         "to_signed_8" >>unboxer
     \ longlong define-primitive-type
@@ -349,7 +368,7 @@ SYMBOLS:
         [ alien-unsigned-8 ] >>getter
         [ set-alien-unsigned-8 ] >>setter
         8 >>size
-        8 >>align
+        8-byte-alignment
         "box_unsigned_8" >>boxer
         "to_unsigned_8" >>unboxer
     \ ulonglong define-primitive-type
@@ -361,6 +380,7 @@ SYMBOLS:
         [ set-alien-signed-cell ] >>setter
         bootstrap-cell >>size
         bootstrap-cell >>align
+        bootstrap-cell >>align-first
         "box_signed_cell" >>boxer
         "to_fixnum" >>unboxer
     \ long define-primitive-type
@@ -372,6 +392,7 @@ SYMBOLS:
         [ set-alien-unsigned-cell ] >>setter
         bootstrap-cell >>size
         bootstrap-cell >>align
+        bootstrap-cell >>align-first
         "box_unsigned_cell" >>boxer
         "to_cell" >>unboxer
     \ ulong define-primitive-type
@@ -383,6 +404,7 @@ SYMBOLS:
         [ set-alien-signed-4 ] >>setter
         4 >>size
         4 >>align
+        4 >>align-first
         "box_signed_4" >>boxer
         "to_fixnum" >>unboxer
     \ int define-primitive-type
@@ -394,6 +416,7 @@ SYMBOLS:
         [ set-alien-unsigned-4 ] >>setter
         4 >>size
         4 >>align
+        4 >>align-first
         "box_unsigned_4" >>boxer
         "to_cell" >>unboxer
     \ uint define-primitive-type
@@ -405,6 +428,7 @@ SYMBOLS:
         [ set-alien-signed-2 ] >>setter
         2 >>size
         2 >>align
+        2 >>align-first
         "box_signed_2" >>boxer
         "to_fixnum" >>unboxer
     \ short define-primitive-type
@@ -416,6 +440,7 @@ SYMBOLS:
         [ set-alien-unsigned-2 ] >>setter
         2 >>size
         2 >>align
+        2 >>align-first
         "box_unsigned_2" >>boxer
         "to_cell" >>unboxer
     \ ushort define-primitive-type
@@ -427,6 +452,7 @@ SYMBOLS:
         [ set-alien-signed-1 ] >>setter
         1 >>size
         1 >>align
+        1 >>align-first
         "box_signed_1" >>boxer
         "to_fixnum" >>unboxer
     \ char define-primitive-type
@@ -438,17 +464,30 @@ SYMBOLS:
         [ set-alien-unsigned-1 ] >>setter
         1 >>size
         1 >>align
+        1 >>align-first
         "box_unsigned_1" >>boxer
         "to_cell" >>unboxer
     \ uchar define-primitive-type
 
-    <c-type>
-        [ alien-unsigned-1 0 = not ] >>getter
-        [ [ 1 0 ? ] 2dip set-alien-unsigned-1 ] >>setter
-        1 >>size
-        1 >>align
-        "box_boolean" >>boxer
-        "to_boolean" >>unboxer
+    cpu ppc? [
+        <c-type>
+            [ alien-unsigned-4 c-bool> ] >>getter
+            [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
+            4 >>size
+            4 >>align
+            4 >>align-first
+            "box_boolean" >>boxer
+            "to_boolean" >>unboxer
+    ] [
+        <c-type>
+            [ alien-unsigned-1 c-bool> ] >>getter
+            [ [ >c-bool ] 2dip set-alien-unsigned-1 ] >>setter
+            1 >>size
+            1 >>align
+            1 >>align-first
+            "box_boolean" >>boxer
+            "to_boolean" >>unboxer
+    ] if
     \ bool define-primitive-type
 
     <c-type>
@@ -458,6 +497,7 @@ SYMBOLS:
         [ [ >float ] 2dip set-alien-float ] >>setter
         4 >>size
         4 >>align
+        4 >>align-first
         "box_float" >>boxer
         "to_float" >>unboxer
         float-rep >>rep
@@ -470,17 +510,24 @@ SYMBOLS:
         [ alien-double ] >>getter
         [ [ >float ] 2dip set-alien-double ] >>setter
         8 >>size
-        8 >>align
+        8-byte-alignment
         "box_double" >>boxer
         "to_double" >>unboxer
         double-rep >>rep
         [ >float ] >>unboxer-quot
     \ double define-primitive-type
 
-    \ long c-type \ ptrdiff_t typedef
-    \ long c-type \ intptr_t typedef
-    \ ulong c-type \ uintptr_t typedef
-    \ ulong c-type \ size_t typedef
+    cpu x86.64? os windows? and [
+        \ longlong c-type \ ptrdiff_t typedef
+        \ longlong c-type \ intptr_t typedef
+        \ ulonglong c-type \ uintptr_t typedef
+        \ ulonglong c-type \ size_t typedef
+    ] [
+        \ long c-type \ ptrdiff_t typedef
+        \ long c-type \ intptr_t typedef
+        \ ulong c-type \ uintptr_t typedef
+        \ ulong c-type \ size_t typedef
+    ] if
 ] with-compilation-unit
 
 M: char-16-rep rep-component-type drop char ;
@@ -501,9 +548,9 @@ M: double-2-rep rep-component-type drop double ;
 
 : c-type-interval ( c-type -- from to )
     {
-        { [ dup { float double } memq? ] [ drop -1/0. 1/0. ] }
-        { [ dup { char short int long longlong } memq? ] [ signed-interval ] }
-        { [ dup { uchar ushort uint ulong ulonglong } memq? ] [ unsigned-interval ] }
+        { [ dup { float double } member-eq? ] [ drop -1/0. 1/0. ] }
+        { [ dup { char short int long longlong } member-eq? ] [ signed-interval ] }
+        { [ dup { uchar ushort uint ulong ulonglong } member-eq? ] [ unsigned-interval ] }
     } cond ; foldable
 
 : c-type-clamp ( value c-type -- value' ) c-type-interval clamp ; inline
index fc18921ef121f6e9510f4f8ea45f450d326bb583..93b1afd436cfd878129d4339c920f914d27830a2 100644 (file)
@@ -65,10 +65,6 @@ M: memory-stream stream-read
 : byte-array>memory ( byte-array base -- )
     swap dup byte-length memcpy ; inline
 
-: >c-bool ( ? -- int ) 1 0 ? ; inline
-
-: c-bool> ( int -- ? ) 0 = not ; inline
-
 M: value-type c-type-rep drop int-rep ;
 
 M: value-type c-type-getter
@@ -77,5 +73,3 @@ M: value-type c-type-getter
 M: value-type c-type-setter ( type -- quot )
     [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri
     '[ @ swap @ _ memcpy ] ;
-
-
index bf8721b549497b43eee9b977724f1979ce9aba43..d7659d8400f90e110a691dd98ebcfbb3bccb865e 100644 (file)
@@ -205,9 +205,6 @@ M: fortran-type (fortran-ret-type>c-type) (fortran-type>c-type) ;
 M: real-type (fortran-ret-type>c-type)
     drop real-functions-return-double? [ "double" ] [ "float" ] if ;
 
-: suffix! ( seq   elt   -- seq   ) over push     ; inline
-: append! ( seq-a seq-b -- seq-a ) over push-all ; inline
-
 GENERIC: (fortran-arg>c-args) ( type -- main-quot added-quot )
 
 : args?dims ( type quot -- main-quot added-quot )
@@ -333,7 +330,7 @@ M: character-type (<fortran-result>)
     ] if-empty ;
 
 :: [fortran-invoke] ( [args>args] return library function parameters -- [args>args] quot ) 
-    return parameters fortran-sig>c-sig :> c-parameters :> c-return
+    return parameters fortran-sig>c-sig :> ( c-return c-parameters )
     function fortran-name>symbol-name :> c-function
     [args>args] 
     c-return library c-function c-parameters \ alien-invoke
index 4b83739efe07cc1782ea389d8d971cf0002eee61..0cf495fd25d4cd53592be9fdf989d50ad16f6995 100644 (file)
@@ -98,7 +98,7 @@ IN: alien.parser
     type-name current-vocab create :> type-word 
     type-word [ reset-generic ] [ reset-c-type ] bi
     void* type-word typedef
-    parameters return parse-arglist :> callback-effect :> types
+    parameters return parse-arglist :> ( types callback-effect )
     type-word callback-effect "callback-effect" set-word-prop
     type-word lib "callback-library" set-word-prop
     type-word return types lib library-abi callback-quot (( quot -- alien )) ;
index 7adf837841675d02a141ccc1e6386a5a36115a4a..609ed2826d9d526c2ee40487e18442b82b9feb94 100644 (file)
@@ -7,11 +7,11 @@ effects assocs combinators lexer strings.parser alien.parser
 fry vocabs.parser words.constant alien.libraries ;
 IN: alien.syntax
 
-SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
+SYNTAX: DLL" lexer get skip-blank parse-string dlopen suffix! ;
 
-SYNTAX: ALIEN: 16 scan-base <alien> parsed ;
+SYNTAX: ALIEN: 16 scan-base <alien> suffix! ;
 
-SYNTAX: BAD-ALIEN <bad-alien> parsed ;
+SYNTAX: BAD-ALIEN <bad-alien> suffix! ;
 
 SYNTAX: LIBRARY: scan "c-library" set ;
 
@@ -37,7 +37,7 @@ ERROR: no-such-symbol name library ;
     2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
 
 SYNTAX: &:
-    scan "c-library" get '[ _ _ address-of ] over push-all ;
+    scan "c-library" get '[ _ _ address-of ] append! ;
 
 : global-quot ( type word -- quot )
     name>> "c-library" get '[ _ _ address-of 0 ]
index 728ac41e94672018bc7800a27ccad31ccb57978c..aa015c55022f515c1d37d092c0f1bcd265068eba 100644 (file)
@@ -25,11 +25,11 @@ HELP: sorted-member?
 
 { member? sorted-member? } related-words
 
-HELP: sorted-memq?
+HELP: sorted-member-eq?
 { $values { "obj" object } { "seq" "a sorted sequence" } { "?" "a boolean" } }
 { $description "Tests if the sorted sequence contains " { $snippet "elt" } ". Equality is tested with " { $link eq? } "." } ;
 
-{ memq? sorted-memq? } related-words
+{ member-eq? sorted-member-eq? } related-words
 
 ARTICLE: "binary-search" "Binary search"
 "The " { $emphasis "binary search" } " algorithm allows elements to be located in sorted sequence in " { $snippet "O(log n)" } " time."
@@ -38,7 +38,7 @@ ARTICLE: "binary-search" "Binary search"
 { $subsections
     sorted-index
     sorted-member?
-    sorted-memq?
+    sorted-member-eq?
 }
 { $see-also "order-specifiers" "sequences-sorting" } ;
 
index aba3cfbfe5c8b9a0643ffb3fae2771befc4d678f..89a300202aacf9eab56e106452c58219143bbc63 100644 (file)
@@ -49,5 +49,5 @@ HINTS: natural-search array ;
 : sorted-member? ( obj seq -- ? )
     dupd natural-search nip = ;
 
-: sorted-memq? ( obj seq -- ? )
+: sorted-member-eq? ( obj seq -- ? )
     dupd natural-search nip eq? ;
index e9c9e1dc5127f06212c78d2e62847786ada7cd46..76b636c3f3908c66cd8d09ac3125a5dee0f056c5 100644 (file)
@@ -55,7 +55,7 @@ HELP: clear-bits
 { $values { "bit-array" bit-array } }
 { $description "Sets all elements of the bit array to " { $link f } "." }
 { $notes "Calling this word is more efficient than the following:"
-    { $code "[ drop f ] change-each" }
+    { $code "[ drop f ] map! drop" }
 }
 { $side-effects "bit-array" } ;
 
@@ -63,7 +63,7 @@ HELP: set-bits
 { $values { "bit-array" bit-array } }
 { $description "Sets all elements of the bit array to " { $link t } "." }
 { $notes "Calling this word is more efficient than the following:"
-    { $code "[ drop t ] change-each" }
+    { $code "[ drop t ] map! drop" }
 }
 { $side-effects "bit-array" } ;
 
index 1de49d353d7684fb3a306b36ebaf1fc89c06cc3b..7397791ab5b1b05058058d87fade66942c1ccb6d 100644 (file)
@@ -20,7 +20,7 @@ IN: bit-arrays.tests
 [
     { t f t } { f t f }
 ] [
-    { t f t } >bit-array dup clone dup [ not ] change-each
+    { t f t } >bit-array dup clone [ not ] map!
     [ >array ] bi@
 ] unit-test
 
index 0eef54dc66c6ae2f6738d992c38da26d080216a1..c4e1ec42b2fca6943629f7495f735f5191141e03 100644 (file)
@@ -113,7 +113,7 @@ PRIVATE>
 M:: lsb0-bit-writer poke ( value n bs -- )
     value n <widthed> :> widthed
     widthed
-    bs widthed>> #bits>> 8 swap - split-widthed :> remainder :> byte
+    bs widthed>> #bits>> 8 swap - split-widthed :> ( byte remainder )
     byte bs widthed>> |widthed :> new-byte
     new-byte #bits>> 8 = [
         new-byte bits>> bs bytes>> push
@@ -143,7 +143,7 @@ ERROR: not-enough-bits n bit-reader ;
     neg shift n bits ;
 
 :: adjust-bits ( n bs -- )
-    n 8 /mod :> #bits :> #bytes
+    n 8 /mod :> ( #bytes #bits )
     bs [ #bytes + ] change-byte-pos
     bit-pos>> #bits + dup 8 >= [
         8 - bs (>>bit-pos)
index e9187cc3b1e6d1d4ee4a7cd6e77fdf0677b83213..3b7848251bbfec4f70c7f9dcb303e5c4c0944404 100755 (executable)
@@ -49,7 +49,7 @@ gc
     {
         not ?
 
-        2over roll -roll
+        2over
 
         array? hashtable? vector?
         tuple? sbuf? tombstone?
@@ -94,7 +94,7 @@ gc
     "." write flush
 
     {
-        memq? split harvest sift cut cut-slice start index clone
+        member-eq? split harvest sift cut cut-slice start index clone
         set-at reverse push-all class number>string string>number
         like clone-like
     } compile-unoptimized
@@ -118,4 +118,4 @@ gc
 
     " done" print flush
 
-] unless
\ No newline at end of file
+] unless
index e086215e910b9cb4141b7f2a67c98b38a4041e75..b2c7f37013f2ba45f85e8c6afca305325413f434 100644 (file)
@@ -1,14 +1,16 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays byte-arrays generic hashtables hashtables.private
-io io.binary io.files io.encodings.binary io.pathnames kernel
-kernel.private math namespaces make parser prettyprint sequences
-strings sbufs vectors words quotations assocs system layouts splitting
-grouping growable classes classes.builtin classes.tuple
-classes.tuple.private vocabs vocabs.loader source-files definitions
-debugger quotations.private combinators math.order math.private
-accessors slots.private generic.single.private compiler.units
-compiler.constants fry bootstrap.image.syntax ;
+USING: alien arrays byte-arrays generic hashtables
+hashtables.private io io.binary io.files io.encodings.binary
+io.pathnames kernel kernel.private math namespaces make parser
+prettyprint sequences strings sbufs vectors words quotations
+assocs system layouts splitting grouping growable classes
+classes.builtin classes.tuple classes.tuple.private vocabs
+vocabs.loader source-files definitions debugger
+quotations.private combinators combinators.short-circuit
+math.order math.private accessors slots.private
+generic.single.private compiler.units compiler.constants fry
+bootstrap.image.syntax ;
 IN: bootstrap.image
 
 : arch ( os cpu -- arch )
@@ -38,7 +40,7 @@ IN: bootstrap.image
 
 ! Object cache; we only consider numbers equal if they have the
 ! same type
-TUPLE: eql-wrapper obj ;
+TUPLE: eql-wrapper { obj read-only } ;
 
 C: <eql-wrapper> eql-wrapper
 
@@ -47,31 +49,31 @@ M: eql-wrapper hashcode* obj>> hashcode* ;
 GENERIC: (eql?) ( obj1 obj2 -- ? )
 
 : eql? ( obj1 obj2 -- ? )
-    [ (eql?) ] [ [ class ] bi@ = ] 2bi and ;
+    { [ [ class ] bi@ = ] [ (eql?) ] } 2&& ;
 
-M: integer (eql?) = ;
+M: fixnum (eql?) eq? ;
 
-M: float (eql?)
-    over float? [ fp-bitwise= ] [ 2drop f ] if ;
+M: bignum (eql?) = ;
 
-M: sequence (eql?)
-    over sequence? [
-        2dup [ length ] bi@ =
-        [ [ eql? ] 2all? ] [ 2drop f ] if
-    ] [ 2drop f ] if ;
+M: float (eql?) fp-bitwise= ;
+
+M: sequence (eql?) 2dup [ length ] bi@ = [ [ eql? ] 2all? ] [ 2drop f ] if ;
 
 M: object (eql?) = ;
 
 M: eql-wrapper equal?
     over eql-wrapper? [ [ obj>> ] bi@ eql? ] [ 2drop f ] if ;
 
-TUPLE: eq-wrapper obj ;
+TUPLE: eq-wrapper { obj read-only } ;
 
 C: <eq-wrapper> eq-wrapper
 
 M: eq-wrapper equal?
     over eq-wrapper? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
 
+M: eq-wrapper hashcode*
+    nip obj>> identity-hashcode ;
+
 SYMBOL: objects
 
 : cache-eql-object ( obj quot -- value )
@@ -177,14 +179,12 @@ USERENV: callback-stub 45
 ! PIC stubs
 USERENV: pic-load 47
 USERENV: pic-tag 48
-USERENV: pic-hi-tag 49
-USERENV: pic-tuple 50
-USERENV: pic-hi-tag-tuple 51
-USERENV: pic-check-tag 52
-USERENV: pic-check 53
-USERENV: pic-hit 54
-USERENV: pic-miss-word 55
-USERENV: pic-miss-tail-word 56
+USERENV: pic-tuple 49
+USERENV: pic-check-tag 50
+USERENV: pic-check-tuple 51
+USERENV: pic-hit 52
+USERENV: pic-miss-word 53
+USERENV: pic-miss-tail-word 54
 
 ! Megamorphic dispatch
 USERENV: mega-lookup 57
@@ -218,13 +218,20 @@ USERENV: undefined-quot 60
 
 : here-as ( tag -- pointer ) here bitor ;
 
+: (align-here) ( alignment -- )
+    [ here neg ] dip rem
+    [ bootstrap-cell /i [ 0 emit ] times ] unless-zero ;
+
 : align-here ( -- )
-    here 8 mod 4 = [ 0 emit ] when ;
+    data-alignment get (align-here) ;
 
 : emit-fixnum ( n -- ) tag-fixnum emit ;
 
+: emit-header ( n -- ) tag-header emit ;
+
 : emit-object ( class quot -- addr )
-    over tag-number here-as [ swap type-number tag-fixnum emit call align-here ] dip ;
+    [ type-number ] dip over here-as
+    [ swap emit-header call align-here ] dip ;
     inline
 
 ! Write an object to the image.
@@ -232,7 +239,7 @@ GENERIC: ' ( obj -- ptr )
 
 ! Image header
 
-: emit-header ( -- )
+: emit-image-header ( -- )
     image-magic emit
     image-version emit
     data-base emit ! relocation base at end of header
@@ -293,7 +300,7 @@ M: fake-bignum ' n>> tag-fixnum ;
 M: float '
     [
         float [
-            align-here double>bits emit-64
+            8 (align-here) double>bits emit-64
         ] emit-object
     ] cache-eql-object ;
 
@@ -305,7 +312,7 @@ M: float '
 
 M: f '
     #! f is #define F RETAG(0,F_TYPE)
-    drop \ f tag-number ;
+    drop \ f type-number ;
 
 :  0, ( -- )  0 >bignum '  0-offset fixup ;
 :  1, ( -- )  1 >bignum '  1-offset fixup ;
@@ -351,7 +358,7 @@ M: f '
     [ ] [ "Not in image: " word-error ] ?if ;
 
 : fixup-words ( -- )
-    image get [ dup word? [ fixup-word ] when ] change-each ;
+    image get [ dup word? [ fixup-word ] when ] map! drop ;
 
 M: word ' ;
 
@@ -411,6 +418,7 @@ M: byte-array '
     [
         byte-array [
             dup length emit-fixnum
+            bootstrap-cell 4 = [ 0 emit 0 emit ] when
             pad-bytes emit-bytes
         ] emit-object
     ] cache-eq-object ;
@@ -515,7 +523,7 @@ M: quotation '
 : build-image ( -- image )
     800000 <vector> image set
     20000 <hashtable> objects set
-    emit-header t, 0, 1, -1,
+    emit-image-header t, 0, 1, -1,
     "Building generic words..." print flush
     remake-generics
     "Serializing words..." print flush
index b8531abd90c10e7fd6234bf9ff3b73ecaa59dcf3..b011b41c4b8735fe50bacadb68fa3041de903b48 100644 (file)
@@ -78,8 +78,6 @@ SYMBOL: bootstrap-time
         "stage2: deployment mode" print
     ] [
         "debugger" require
-        "inspector" require
-        "tools.errors" require
         "listener" require
         "none" require
     ] if
index 6bdfd6241c0b619925e6d420f0e38af00d28bf47..51f44025c9c7fe42d0826d7d6fcec1a06d5ec043 100644 (file)
@@ -2,14 +2,17 @@ USING: vocabs.loader sequences ;
 IN: bootstrap.tools
 
 {
+    "editors"
     "inspector"
     "bootstrap.image"
+    "see"
     "tools.annotations"
     "tools.crossref"
     "tools.errors"
     "tools.deploy"
     "tools.destructors"
     "tools.disassembler"
+    "tools.dispatch"
     "tools.memory"
     "tools.profiler"
     "tools.test"
@@ -19,5 +22,4 @@ IN: bootstrap.tools
     "vocabs.hierarchy"
     "vocabs.refresh"
     "vocabs.refresh.monitor"
-    "editors"
 } [ require ] each
index 5c381b7db0a07253de2d4d5367d102d5fcfb945e..ae9b9c8ba21f11ee60bc9ebfe2266dce25b6c444 100644 (file)
@@ -7,4 +7,4 @@ SYNTAX: HEX{
     "}" parse-tokens "" join
     [ blank? not ] filter
     2 group [ hex> ] B{ } map-as
-    parsed ;
+    suffix! ;
index 8cb1e751b26fde2202ad6c3967f847cfd6a77e8d..b774e79b8bbbba1528574b5a7026b67c2b88cf6a 100644 (file)
@@ -32,7 +32,7 @@ HELP: month-names
 { $warning "Do not use this array for looking up a month name directly. Use month-name instead." } ;
 
 HELP: month-name
-{ $values { "n" integer } { "string" string } }
+{ $values { "obj" { $or integer timestamp } } { "string" string } }
 { $description "Looks up the month name and returns it as a string.  January has an index of 1 instead of zero." } ;
 
 HELP: month-abbreviations
@@ -46,11 +46,11 @@ HELP: month-abbreviation
 
 
 HELP: day-names
-{ $values { "array" array } }
+{ $values { "value" array } }
 { $description "Returns an array with the English names of the days of the week." } ;
 
 HELP: day-name
-{ $values { "n" integer } { "string" string } }
+{ $values { "obj" { $or integer timestamp } } { "string" string } }
 { $description "Looks up the day name and returns it as a string." } ;
 
 HELP: day-abbreviations2
index 8d1071122d98f5c58bb214097f785a460311a6cf..44ba777c4517b9c49d24da22286020a8557d015c 100644 (file)
@@ -170,3 +170,8 @@ IN: calendar.tests
 [ f ] [ now dup midnight eq? ] unit-test
 [ f ] [ now dup easter eq? ] unit-test
 [ f ] [ now dup beginning-of-year eq? ] unit-test
+
+[ t ] [ 1325376000 unix-time>timestamp 2012 <year-gmt> = ] unit-test
+[ t ] [ 1356998399 unix-time>timestamp 2013 <year-gmt> 1 seconds time- = ] unit-test
+
+[ t ] [ 1500000000 random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test
index a8bb60cbf36396f4098e37c23baf3b0b52a67d80..ef22a98c80a0dfbda684695b2015ba6caf203f0c 100644 (file)
@@ -17,6 +17,8 @@ TUPLE: duration
 
 C: <duration> duration
 
+: instant ( -- duration ) 0 0 0 0 0 0 <duration> ;
+
 TUPLE: timestamp
     { year integer }
     { month integer }
@@ -34,6 +36,15 @@ C: <timestamp> timestamp
 : <date> ( year month day -- timestamp )
     0 0 0 gmt-offset-duration <timestamp> ;
 
+: <date-gmt> ( year month day -- timestamp )
+    0 0 0 instant <timestamp> ;
+
+: <year> ( year -- timestamp )
+    1 1 <date> ;
+
+: <year-gmt> ( year -- timestamp )
+    1 1 <date-gmt> ;
+
 ERROR: not-a-month ;
 M: not-a-month summary
     drop "Months are indexed starting at 1" ;
@@ -51,8 +62,16 @@ CONSTANT: month-names
         "July" "August" "September" "October" "November" "December"
     }
 
-: month-name ( n -- string )
-    check-month 1 - month-names nth ;
+<PRIVATE
+
+: (month-name) ( n -- string ) 1 - month-names nth ;
+
+PRIVATE>
+
+GENERIC: month-name ( obj -- string )
+
+M: integer month-name check-month 1 - month-names nth ;
+M: timestamp month-name month>> 1 - month-names nth ;
 
 CONSTANT: month-abbreviations
     {
@@ -65,12 +84,8 @@ CONSTANT: month-abbreviations
 
 CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 }
 
-: day-names ( -- array )
-    {
-        "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"
-    } ;
-
-: day-name ( n -- string ) day-names nth ;
+CONSTANT: day-names
+    { "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" }
 
 CONSTANT: day-abbreviations2
     { "Su" "Mo" "Tu" "We" "Th" "Fr" "Sa" }
@@ -119,16 +134,16 @@ GENERIC: easter ( obj -- obj' )
 
 :: easter-month-day ( year -- month day )
     year 19 mod :> a
-    year 100 /mod :> c :> b
-    b 4 /mod :> e :> d
+    year 100 /mod :> ( b c )
+    b 4 /mod :> ( d e )
     b 8 + 25 /i :> f
     b f - 1 + 3 /i :> g
     19 a * b + d - g - 15 + 30 mod :> h
-    c 4 /mod :> k :> i
+    c 4 /mod :> ( i k )
     32 2 e * + 2 i * + h - k - 7 mod :> l
     a 11 h * + 22 l * + 451 /i :> m
 
-    h l + 7 m * - 114 + 31 /mod 1 + :> day :> month
+    h l + 7 m * - 114 + 31 /mod 1 + :> ( month day )
     month day ;
 
 M: integer easter ( year -- timestamp )
@@ -145,7 +160,6 @@ M: timestamp easter ( timestamp -- timestamp )
 : >time< ( timestamp -- hour minute second )
     [ hour>> ] [ minute>> ] [ second>> ] tri ;
 
-: instant ( -- duration ) 0 0 0 0 0 0 <duration> ;
 : years ( x -- duration ) instant clone swap >>year ;
 : months ( x -- duration ) instant clone swap >>month ;
 : days ( x -- duration ) instant clone swap >>day ;
@@ -157,6 +171,18 @@ M: timestamp easter ( timestamp -- timestamp )
 : microseconds ( x -- duration ) 1000000 / seconds ;
 : nanoseconds ( x -- duration ) 1000000000 / seconds ;
 
+GENERIC: year ( obj -- n )
+M: integer year ;
+M: timestamp year year>> ;
+
+GENERIC: month ( obj -- n )
+M: integer month ;
+M: timestamp month month>> ;
+
+GENERIC: day ( obj -- n )
+M: integer day ;
+M: timestamp day day>> ;
+
 GENERIC: leap-year? ( obj -- ? )
 
 M: integer leap-year? ( year -- ? )
@@ -305,6 +331,9 @@ GENERIC: time- ( time1 time2 -- time3 )
 M: timestamp <=> ( ts1 ts2 -- n )
     [ >gmt tuple-slots ] compare ;
 
+: same-day? ( ts1 ts2 -- ? )
+    [ >gmt >date< <date> ] bi@ = ;
+
 : (time-) ( timestamp timestamp -- n )
     [ >gmt ] bi@
     [ [ >date< julian-day-number ] bi@ - 86400 * ] 2keep
@@ -387,6 +416,10 @@ M: timestamp days-in-year ( timestamp -- n ) year>> days-in-year ;
 : day-of-week ( timestamp -- n )
     >date< zeller-congruence ;
 
+GENERIC: day-name ( obj -- string )
+M: integer day-name day-names nth ;
+M: timestamp day-name day-of-week day-names nth ;
+
 :: (day-of-year) ( year month day -- n )
     day-counts month head-slice sum day +
     year leap-year? [
@@ -398,14 +431,75 @@ M: timestamp days-in-year ( timestamp -- n ) year>> days-in-year ;
 : day-of-year ( timestamp -- n )
     >date< (day-of-year) ;
 
+: midnight ( timestamp -- new-timestamp )
+    clone 0 >>hour 0 >>minute 0 >>second ; inline
+
+: noon ( timestamp -- new-timestamp )
+    midnight 12 >>hour ; inline
+
+: beginning-of-month ( timestamp -- new-timestamp )
+    midnight 1 >>day ;
+
+: end-of-month ( timestamp -- new-timestamp )
+    [ midnight ] [ days-in-month ] bi >>day ;
+
 <PRIVATE
-: day-offset ( timestamp m -- timestamp n )
+
+: day-offset ( timestamp m -- new-timestamp n )
     over day-of-week - ; inline
 
-: day-this-week ( timestamp n -- timestamp )
+: day-this-week ( timestamp n -- new-timestamp )
     day-offset days time+ ;
+
+:: nth-day-this-month ( timestamp n day -- new-timestamp )
+    timestamp beginning-of-month day day-this-week
+    dup timestamp [ month>> ] bi@ = [ 1 weeks time+ ] unless
+    n 1 - [ weeks time+ ] unless-zero ;
+
+: last-day-this-month ( timestamp day -- new-timestamp )
+    [ 1 months time+ 1 ] dip nth-day-this-month 1 weeks time- ;
+
 PRIVATE>
 
+GENERIC: january ( obj -- timestamp )
+GENERIC: february ( obj -- timestamp )
+GENERIC: march ( obj -- timestamp )
+GENERIC: april ( obj -- timestamp )
+GENERIC: may ( obj -- timestamp )
+GENERIC: june ( obj -- timestamp )
+GENERIC: july ( obj -- timestamp )
+GENERIC: august ( obj -- timestamp )
+GENERIC: september ( obj -- timestamp )
+GENERIC: october ( obj -- timestamp )
+GENERIC: november ( obj -- timestamp )
+GENERIC: december ( obj -- timestamp )
+
+M: integer january 1 1 <date> ;
+M: integer february 2 1 <date> ;
+M: integer march 3 1 <date> ;
+M: integer april 4 1 <date> ;
+M: integer may 5 1 <date> ;
+M: integer june 6 1 <date> ;
+M: integer july 7 1 <date> ;
+M: integer august 8 1 <date> ;
+M: integer september 9 1 <date> ;
+M: integer october 10 1 <date> ;
+M: integer november 11 1 <date> ;
+M: integer december 12 1 <date> ;
+
+M: timestamp january clone 1 >>month ;
+M: timestamp february clone 2 >>month ;
+M: timestamp march clone 3 >>month ;
+M: timestamp april clone 4 >>month ;
+M: timestamp may clone 5 >>month ;
+M: timestamp june clone 6 >>month ;
+M: timestamp july clone 7 >>month ;
+M: timestamp august clone 8 >>month ;
+M: timestamp september clone 9 >>month ;
+M: timestamp october clone 10 >>month ;
+M: timestamp november clone 11 >>month ;
+M: timestamp december clone 12 >>month ;
+
 : sunday ( timestamp -- new-timestamp ) 0 day-this-week ;
 : monday ( timestamp -- new-timestamp ) 1 day-this-week ;
 : tuesday ( timestamp -- new-timestamp ) 2 day-this-week ;
@@ -414,20 +508,40 @@ PRIVATE>
 : friday ( timestamp -- new-timestamp ) 5 day-this-week ;
 : saturday ( timestamp -- new-timestamp ) 6 day-this-week ;
 
-: midnight ( timestamp -- new-timestamp )
-    clone 0 >>hour 0 >>minute 0 >>second ; inline
-
-: noon ( timestamp -- new-timestamp )
-    midnight 12 >>hour ; inline
-
-: beginning-of-month ( timestamp -- new-timestamp )
-    midnight 1 >>day ;
+: sunday? ( timestamp -- ? ) day-of-week 0 = ;
+: monday? ( timestamp -- ? ) day-of-week 1 = ;
+: tuesday? ( timestamp -- ? ) day-of-week 2 = ;
+: wednesday? ( timestamp -- ? ) day-of-week 3 = ;
+: thursday? ( timestamp -- ? ) day-of-week 4 = ;
+: friday? ( timestamp -- ? ) day-of-week 5 = ;
+: saturday? ( timestamp -- ? ) day-of-week 6 = ;
+
+: sunday-of-month ( timestamp n -- new-timestamp ) 0 nth-day-this-month ;
+: monday-of-month ( timestamp n -- new-timestamp ) 1 nth-day-this-month ;
+: tuesday-of-month ( timestamp n -- new-timestamp ) 2 nth-day-this-month ;
+: wednesday-of-month ( timestamp n -- new-timestamp ) 3 nth-day-this-month ;
+: thursday-of-month ( timestamp n -- new-timestamp ) 4 nth-day-this-month ;
+: friday-of-month ( timestamp n -- new-timestamp ) 5 nth-day-this-month ;
+: saturday-of-month ( timestamp n -- new-timestamp ) 6 nth-day-this-month ;
+
+: last-sunday-of-month ( timestamp -- new-timestamp ) 0 last-day-this-month ;
+: last-monday-of-month ( timestamp -- new-timestamp ) 1 last-day-this-month ;
+: last-tuesday-of-month ( timestamp -- new-timestamp ) 2 last-day-this-month ;
+: last-wednesday-of-month ( timestamp -- new-timestamp ) 3 last-day-this-month ;
+: last-thursday-of-month ( timestamp -- new-timestamp ) 4 last-day-this-month ;
+: last-friday-of-month ( timestamp -- new-timestamp ) 5 last-day-this-month ;
+: last-saturday-of-month ( timestamp -- new-timestamp ) 6 last-day-this-month ;
 
 : beginning-of-week ( timestamp -- new-timestamp )
     midnight sunday ;
 
-: beginning-of-year ( timestamp -- new-timestamp )
-    beginning-of-month 1 >>month ;
+GENERIC: beginning-of-year ( object -- new-timestamp )
+M: timestamp beginning-of-year beginning-of-month 1 >>month ;
+M: integer beginning-of-year <year> ;
+
+GENERIC: end-of-year ( object -- new-timestamp )
+M: timestamp end-of-year 12 >>month 31 >>day ;
+M: integer end-of-year 12 31 <date> ;
 
 : time-since-midnight ( timestamp -- duration )
     dup midnight time- ;
@@ -435,6 +549,12 @@ PRIVATE>
 : since-1970 ( duration -- timestamp )
     unix-1970 time+ >local-time ;
 
+: timestamp>unix-time ( timestamp -- seconds )
+    unix-1970 time- second>> ;
+
+: unix-time>timestamp ( seconds -- timestamp )
+    seconds unix-1970 time+ ;
+
 M: timestamp sleep-until timestamp>micros sleep-until ;
 
 M: duration sleep hence sleep-until ;
index 28e54b89fb5d95fa01d1119d3a9fbdb2ab9cf28d..ac72385d8c75a33d8ce55270a7cfcaf4b17eaa40 100644 (file)
@@ -14,6 +14,9 @@ IN: calendar.unix
 : timespec>seconds ( timespec -- seconds )
     [ sec>> seconds ] [ nsec>> nanoseconds ] bi time+ ;
 
+: timespec>nanoseconds ( timespec -- seconds )
+    [ sec>> 1000000000 * ] [ nsec>> ] bi + ;
+
 : timespec>unix-time ( timespec -- timestamp )
     timespec>seconds since-1970 ;
 
index 99fa41cd400e7788dc76a2046ca124f7b3d05760..4b48d7923c6ebbc7d784aac64bc2f6ca55fc9abb 100644 (file)
@@ -25,12 +25,11 @@ IN: channels.examples
     ] 3keep filter ;
 
 :: (sieve) ( prime c -- )
-    [let | p [ c from ] 
-           newc [ <channel> ] |
-        p prime to
-        [ newc p c filter ] "Filter" spawn drop
-        prime newc (sieve)
-    ] ;
+    c from :> p
+    <channel> :> newc
+    p prime to
+    [ newc p c filter ] "Filter" spawn drop
+    prime newc (sieve) ;
 
 : sieve ( prime -- ) 
     #! Send prime numbers to 'prime' channel
index 309f764d2da6f1e6a3deb4baef1901fc0932b2ac..c612b4256ac549039451351a7995d7d836dcaa9f 100644 (file)
@@ -53,11 +53,11 @@ $nl
 " to be accessed remotely. " { $link publish } " returns an id which a remote node "
 "needs to know to access the channel."
 $nl
-{ $snippet "channel [ from . ] spawn drop dup publish" }
+{ $snippet "<channel> dup [ from . flush ] curry \"test\" spawn drop publish" }
 $nl
-"Given the id from the snippet above, a remote node can put items in the channel."
+"Given the id from the snippet above, a remote node can put items in the channel (where 123456 is the id):"
 $nl
-{ $snippet "\"myhost.com\" 9001 <node> \"ID123456\" <remote-channel>\n\"hello\" over to" } 
+{ $snippet "\"myhost.com\" 9001 <node> 123456 <remote-channel>\n\"hello\" over to" } 
 ;
 
 ABOUT: { "remote-channels" "remote-channels" }
index bf2438ac19517dccc49134a0d5bbaeca48c9377b..4eab29fd81f15322cf6f5283c9663dfb5d4cb6ef 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 ! Remote Channels
-USING: kernel init namespaces make assocs arrays random
+USING: kernel init namespaces assocs arrays random
 sequences channels match concurrency.messaging
 concurrency.distributed threads accessors ;
 IN: channels.remote
@@ -27,39 +27,44 @@ PRIVATE>
 MATCH-VARS: ?from ?tag ?id ?value ;
 
 SYMBOL: no-channel
+TUPLE: to-message id value ;
+TUPLE: from-message id ;
 
-: channel-process ( -- )
+: channel-thread ( -- )
     [
         {
-            { { to ?id ?value  }
+            { T{ to-message f ?id ?value  }
             [ ?value ?id get-channel dup [ to f ] [ 2drop no-channel ] if ] }
-            { { from ?id }
+            { T{ from-message f ?id }
             [ ?id get-channel [ from ] [ no-channel ] if* ] }
         } match-cond
     ] handle-synchronous ;
 
-PRIVATE>
-
 : start-channel-node ( -- )
-    "remote-channels" get-process [
-        "remote-channels" 
-        [ channel-process t ] "Remote channels" spawn-server
-        register-process 
+    "remote-channels" get-remote-thread [
+        [ channel-thread t ] "Remote channels" spawn-server
+        "remote-channels" register-remote-thread 
     ] unless ;
 
+PRIVATE>
+
 TUPLE: remote-channel node id ;
 
 C: <remote-channel> remote-channel 
 
+<PRIVATE
+
+: send-message ( message remote-channel -- value )
+    node>> "remote-channels" <remote-thread> 
+    send-synchronous dup no-channel = [ no-channel throw ] when* ;
+    
+PRIVATE>
+
 M: remote-channel to ( value remote-channel -- )
-    [ [ \ to , id>> , , ] { } make ] keep
-    node>> "remote-channels" <remote-process> 
-    send-synchronous no-channel = [ no-channel throw ] when ;
+    [ id>> swap to-message boa ] keep send-message drop ;
 
 M: remote-channel from ( remote-channel -- value )
-    [ [ \ from , id>> , ] { } make ] keep
-    node>> "remote-channels" <remote-process> 
-    send-synchronous dup no-channel = [ no-channel throw ] when* ;
+    [ id>> from-message boa ] keep send-message ;
 
 [
     H{ } clone \ remote-channels set-global
index 9ec78248a1c5f2064eab91413a91ca36b924c73f..cb536cd75ed6bbb2a1f09866bcaba197c743196c 100755 (executable)
@@ -24,7 +24,7 @@ PRIVATE>
 
 :: hmac-stream ( stream key checksum -- value )
     checksum initialize-checksum-state :> checksum-state
-    checksum key checksum-state init-key :> Ki :> Ko
+    checksum key checksum-state init-key :> ( Ko Ki )
     checksum-state Ki add-checksum-bytes
     stream add-checksum-stream get-checksum
     checksum initialize-checksum-state
index b3be4651cd627799269edbefa72ac168f97718ba..1c0efb1c36c15c104ba8a200e39f8028a3cd3a8d 100644 (file)
@@ -21,7 +21,7 @@ M: circular length seq>> length ;
 
 M: circular virtual@ circular-wrap seq>> ;
 
-M: circular virtual-seq seq>> ;
+M: circular virtual-exemplar seq>> ;
 
 : change-circular-start ( n circular -- )
     #! change start to (start + n) mod length
index c535e52c0a2cce1cf19354efb39cd91e0288efba..c5959ab7acde83e447cbb749a0d9613ddcea2f05 100644 (file)
@@ -10,7 +10,7 @@ IN: classes.struct.bit-accessors
     [ 2^ 1 - ] bi@ swap bitnot bitand ;
 
 :: manipulate-bits ( offset bits step-quot -- quot shift-amount offset' bits' )
-    offset 8 /mod :> start-bit :> i
+    offset 8 /mod :> ( i start-bit )
     start-bit bits + 8 min :> end-bit
     start-bit end-bit ones-between :> mask
     end-bit start-bit - :> used-bits
index 58ab2df80b533480c80c07d98954c082bac64a81..2c0db93522b8e411695cd9fe034ab1c5183eced2 100755 (executable)
@@ -365,3 +365,18 @@ STRUCT: bit-field-test
 [ -2 ] [ bit-field-test <struct> 2 >>b b>> ] unit-test
 [ 1 ] [ bit-field-test <struct> 257 >>c c>> ] unit-test
 [ 3 ] [ bit-field-test heap-size ] unit-test
+
+cpu ppc? [
+    STRUCT: ppc-align-test-1
+        { x longlong }
+        { y int } ;
+
+    [ 16 ] [ ppc-align-test-1 heap-size ] unit-test
+
+    STRUCT: ppc-align-test-2
+        { y int }
+        { x longlong } ;
+
+    [ 12 ] [ ppc-align-test-2 heap-size ] unit-test
+    [ 4 ] [ "x" ppc-align-test-2 offset-of ] unit-test
+] when
index af23834383ea7f02d200163943f51835059d1125..c7dd3fb50516d455e45ec255e155cf596592365f 100755 (executable)
@@ -211,27 +211,32 @@ M: struct-c-type c-struct? drop t ;
         slots >>fields
         size >>size
         align >>align
+        align >>align-first
         class (unboxer-quot) >>unboxer-quot
-        class (boxer-quot)   >>boxer-quot ;
-    
-GENERIC: align-offset ( offset class -- offset' )
+        class (boxer-quot) >>boxer-quot ;
+
+GENERIC: compute-slot-offset ( offset class -- offset' )
 
-M: struct-slot-spec align-offset
-    [ type>> c-type-align 8 * align ] keep
+: c-type-align-at ( class offset -- n )
+    0 = [ c-type-align-first ] [ c-type-align ] if ;
+
+M: struct-slot-spec compute-slot-offset
+    [ type>> over c-type-align-at 8 * align ] keep
     [ [ 8 /i ] dip (>>offset) ] [ type>> heap-size 8 * + ] 2bi ;
 
-M: struct-bit-slot-spec align-offset
+M: struct-bit-slot-spec compute-slot-offset
     [ (>>offset) ] [ bits>> + ] 2bi ;
 
-: struct-offsets ( slots -- size )
-    0 [ align-offset ] reduce 8 align 8 /i ;
+: compute-struct-offsets ( slots -- size )
+    0 [ compute-slot-offset ] reduce 8 align 8 /i ;
 
-: union-struct-offsets ( slots -- size )
+: compute-union-offsets ( slots -- size )
     1 [ 0 >>offset type>> heap-size max ] reduce ;
 
-: struct-align ( slots -- align )
+: struct-alignment ( slots -- align )
     [ struct-bit-slot-spec? not ] filter
-    1 [ type>> c-type-align max ] reduce ;
+    1 [ [ type>> ] [ offset>> ] bi c-type-align-at max ] reduce ;
+
 PRIVATE>
 
 M: struct byte-length class "struct-size" word-prop ; foldable
@@ -243,10 +248,8 @@ GENERIC: binary-zero? ( value -- ? )
 
 M: object binary-zero? drop f ;
 M: f binary-zero? drop t ;
-M: number binary-zero? zero? ;
-M: struct binary-zero?
-    [ byte-length iota ] [ >c-ptr ] bi
-    [ <displaced-alien> *uchar zero? ] curry all? ;
+M: number binary-zero? 0 = ;
+M: struct binary-zero? >c-ptr [ 0 = ] all? ;
 
 : struct-needs-prototype? ( class -- ? )
     struct-slots [ initial>> binary-zero? ] all? not ;
@@ -278,7 +281,7 @@ M: struct binary-zero?
     slots empty? [ struct-must-have-slots ] when
     class redefine-struct-tuple-class
     slots make-slots dup check-struct-slots :> slot-specs
-    slot-specs struct-align :> alignment
+    slot-specs struct-alignment :> alignment
     slot-specs offsets-quot call alignment align :> size
 
     class  slot-specs  size  alignment  c-type-for-class :> c-type
@@ -291,10 +294,10 @@ M: struct binary-zero?
 PRIVATE>
 
 : define-struct-class ( class slots -- )
-    [ struct-offsets ] (define-struct-class) ;
+    [ compute-struct-offsets ] (define-struct-class) ;
 
 : define-union-struct-class ( class slots -- )
-    [ union-struct-offsets ] (define-struct-class) ;
+    [ compute-union-offsets ] (define-struct-class) ;
 
 M: struct-class reset-class
     [ call-next-method ] [ name>> c-types get delete-at ] bi ;
@@ -350,7 +353,7 @@ PRIVATE>
 : parse-struct-slots ( slots -- slots' more? )
     scan {
         { ";" [ f ] }
-        { "{" [ parse-struct-slot over push t ] }
+        { "{" [ parse-struct-slot suffix! t ] }
         { f [ unexpected-eof ] }
         [ invalid-struct-slot ]
     } case ;
@@ -365,10 +368,10 @@ SYNTAX: UNION-STRUCT:
     parse-struct-definition define-union-struct-class ;
 
 SYNTAX: S{
-    scan-word dup struct-slots parse-tuple-literal-slots parsed ;
+    scan-word dup struct-slots parse-tuple-literal-slots suffix! ;
 
 SYNTAX: S@
-    scan-word scan-object swap memory>struct parsed ;
+    scan-word scan-object swap memory>struct suffix! ;
 
 ! functor support
 
@@ -378,7 +381,7 @@ SYNTAX: S@
 
 : parse-struct-slot` ( accum -- accum )
     scan-string-param scan-c-type` \ } parse-until
-    [ <struct-slot-spec> over push ] 3curry over push-all ;
+    [ <struct-slot-spec> suffix! ] 3curry append! ;
 
 : parse-struct-slots` ( accum -- accum more? )
     scan {
@@ -389,10 +392,10 @@ SYNTAX: S@
 PRIVATE>
 
 FUNCTOR-SYNTAX: STRUCT:
-    scan-param parsed
-    [ 8 <vector> ] over push-all
+    scan-param suffix!
+    [ 8 <vector> ] append!
     [ parse-struct-slots` ] [ ] while
-    [ >array define-struct-class ] over push-all ;
+    [ >array define-struct-class ] append! ;
 
 USING: vocabs vocabs.loader ;
 
index a798eb15ba0cee9e917d744f1ad87a8aacec9ca5..e1ec43f1dc7c4416b117ccae60a8aedde3c1a2d6 100644 (file)
@@ -16,11 +16,11 @@ CLASS: {
     { +superclass+ "NSObject" }
 }
 
-{ "perform:" "void" { "id" "SEL" "id" }
+{ "perform:" void { id SEL id }
     [ 2drop callbacks get at try ]
 }
 
-{ "dealloc" "void" { "id" "SEL" }
+{ "dealloc" void { id SEL }
     [
         drop
         dup callbacks get delete-at
index c657a5e6e896c82cc63cb5ffa0428e97c56b2c3c..892d5ea38d2be1a0bd80f7c310bbc5ed2690baca 100644 (file)
@@ -1,6 +1,7 @@
 USING: cocoa cocoa.messages cocoa.subclassing cocoa.types
-compiler kernel namespaces cocoa.classes tools.test memory
-compiler.units math core-graphics.types ;
+compiler kernel namespaces cocoa.classes cocoa.runtime
+tools.test memory compiler.units math core-graphics.types ;
+FROM: alien.c-types => int void ;
 IN: cocoa.tests
 
 CLASS: {
@@ -8,8 +9,8 @@ CLASS: {
     { +name+ "Foo" }
 } {
     "foo:"
-    "void"
-    { "id" "SEL" "NSRect" }
+    void
+    { id SEL NSRect }
     [ gc "x" set 2drop ]
 } ;
 
@@ -30,8 +31,8 @@ CLASS: {
     { +name+ "Bar" }
 } {
     "bar"
-    "NSRect"
-    { "id" "SEL" }
+    NSRect
+    { id SEL }
     [ 2drop test-foo "x" get ]
 } ;
 
@@ -52,13 +53,13 @@ CLASS: {
     { +name+ "Bar" }
 } {
     "bar"
-    "NSRect"
-    { "id" "SEL" }
+    NSRect
+    { id SEL }
     [ 2drop test-foo "x" get ]
 } {
     "babb"
-    "int"
-    { "id" "SEL" "int" }
+    int
+    { id SEL int }
     [ 2nip sq ]
 } ;
 
index 7f9d3f6814ac8ba48f7a9c70139d9afb8d4b2c15..34bac0a5055229e13b7a738190f577359fd3ab7e 100644 (file)
@@ -14,14 +14,14 @@ SYMBOL: sent-messages
 : remember-send ( selector -- )
     sent-messages (remember-send) ;
 
-SYNTAX: -> scan dup remember-send parsed \ send parsed ;
+SYNTAX: -> scan dup remember-send suffix! \ send suffix! ;
 
 SYMBOL: super-sent-messages
 
 : remember-super-send ( selector -- )
     super-sent-messages (remember-send) ;
 
-SYNTAX: SUPER-> scan dup remember-super-send parsed \ super-send parsed ;
+SYNTAX: SUPER-> scan dup remember-super-send suffix! \ super-send suffix! ;
 
 SYMBOL: frameworks
 
index 400599383fba5347bfd2615a30e57d7aa732adc0..7dee15d2e2192fd4c03894a729e801441a378bf1 100644 (file)
@@ -2,13 +2,13 @@ USING: help.markup help.syntax strings alien ;
 IN: cocoa.messages
 
 HELP: send
-{ $values { "args..." "method arguments" } { "receiver" alien } { "selector" string } { "return..." "value returned by method, if any" } }
+{ $values { "receiver" alien } { "args..." "method arguments" } { "selector" string } { "return..." "value returned by method, if any" } }
 { $description "Sends an Objective C message named by " { $snippet "selector" } " to " { $snippet "receiver" } ". The arguments must be on the stack in left-to-right order." }
 { $errors "Throws an error if the receiver does not recognize the message, or if the arguments have inappropriate types." }
 { $notes "This word uses a special fast code path if " { $snippet "selector" } " is a literal and the word containing the call to " { $link send } " is compiled." } ;
 
 HELP: super-send
-{ $values { "args..." "method arguments" } { "receiver" alien } { "selector" string } { "return..." "value returned by method, if any" } }
+{ $values { "receiver" alien } { "args..." "method arguments" } { "selector" string } { "return..." "value returned by method, if any" } }
 { $description "Sends an Objective C message named by " { $snippet "selector" } " to the super class of " { $snippet "receiver" } ". Otherwise behaves identically to " { $link send } "." } ;
 
 HELP: objc-class
index 85cff72749652512259c73420b6786f4fb4fef90..4cc9554d3c4be5b84d1be3a1f09b7ceabd02fded 100755 (executable)
@@ -2,10 +2,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.strings arrays assocs
 classes.struct continuations combinators compiler compiler.alien
-stack-checker kernel math namespaces make quotations sequences
-strings words cocoa.runtime io macros memoize io.encodings.utf8
-effects libc libc.private lexer init core-foundation fry
-generalizations specialized-arrays ;
+core-graphics.types stack-checker kernel math namespaces make
+quotations sequences strings words cocoa.runtime cocoa.types io
+macros memoize io.encodings.utf8 effects layouts libc
+libc.private lexer init core-foundation fry generalizations
+specialized-arrays ;
+QUALIFIED-WITH: alien.c-types c
 IN: cocoa.messages
 
 SPECIALIZED-ARRAY: void*
@@ -98,75 +100,84 @@ class-startup-hooks [ H{ } clone ] initialize
 SYMBOL: objc>alien-types
 
 H{
-    { "c" "char" }
-    { "i" "int" }
-    { "s" "short" }
-    { "C" "uchar" }
-    { "I" "uint" }
-    { "S" "ushort" }
-    { "f" "float" }
-    { "d" "double" }
-    { "B" "bool" }
-    { "v" "void" }
-    { "*" "char*" }
-    { "?" "unknown_type" }
-    { "@" "id" }
-    { "#" "Class" }
-    { ":" "SEL" }
+    { "c" c:char }
+    { "i" c:int }
+    { "s" c:short }
+    { "C" c:uchar }
+    { "I" c:uint }
+    { "S" c:ushort }
+    { "f" c:float }
+    { "d" c:double }
+    { "B" c:bool }
+    { "v" c:void }
+    { "*" c:char* }
+    { "?" unknown_type }
+    { "@" id }
+    { "#" Class }
+    { ":" SEL }
 }
-"ptrdiff_t" heap-size {
+cell {
     { 4 [ H{
-        { "l" "long" }
-        { "q" "longlong" }
-        { "L" "ulong" }
-        { "Q" "ulonglong" }
+        { "l" c:long }
+        { "q" c:longlong }
+        { "L" c:ulong }
+        { "Q" c:ulonglong }
     } ] }
     { 8 [ H{
-        { "l" "long32" }
-        { "q" "long" }
-        { "L" "ulong32" }
-        { "Q" "ulong" }
+        { "l" long32 }
+        { "q" long }
+        { "L" ulong32 }
+        { "Q" ulong }
     } ] }
 } case
 assoc-union objc>alien-types set-global
 
+SYMBOL: objc>struct-types
+
+H{
+    { "_NSPoint" NSPoint }
+    { "NSPoint"  NSPoint }
+    { "CGPoint"  NSPoint }
+    { "_NSRect"  NSRect  }
+    { "NSRect"   NSRect  }
+    { "CGRect"   NSRect  }
+    { "_NSSize"  NSSize  }
+    { "NSSize"   NSSize  }
+    { "CGSize"   NSSize  }
+    { "_NSRange" NSRange }
+    { "NSRange"  NSRange }
+} objc>struct-types set-global
+
 ! The transpose of the above map
 SYMBOL: alien>objc-types
 
 objc>alien-types get [ swap ] assoc-map
 ! A hack...
-"ptrdiff_t" heap-size {
+cell {
     { 4 [ H{
-        { "NSPoint"    "{_NSPoint=ff}" }
-        { "NSRect"     "{_NSRect={_NSPoint=ff}{_NSSize=ff}}" }
-        { "NSSize"     "{_NSSize=ff}" }
-        { "NSRange"    "{_NSRange=II}" }
-        { "NSInteger"  "i" }
-        { "NSUInteger" "I" }
-        { "CGFloat"    "f" }
+        { NSPoint    "{_NSPoint=ff}" }
+        { NSRect     "{_NSRect={_NSPoint=ff}{_NSSize=ff}}" }
+        { NSSize     "{_NSSize=ff}" }
+        { NSRange    "{_NSRange=II}" }
+        { NSInteger  "i" }
+        { NSUInteger "I" }
+        { CGFloat    "f" }
     } ] }
     { 8 [ H{
-        { "NSPoint"    "{CGPoint=dd}" }
-        { "NSRect"     "{CGRect={CGPoint=dd}{CGSize=dd}}" }
-        { "NSSize"     "{CGSize=dd}" }
-        { "NSRange"    "{_NSRange=QQ}" }
-        { "NSInteger"  "q" }
-        { "NSUInteger" "Q" }
-        { "CGFloat"    "d" }
+        { NSPoint    "{CGPoint=dd}" }
+        { NSRect     "{CGRect={CGPoint=dd}{CGSize=dd}}" }
+        { NSSize     "{CGSize=dd}" }
+        { NSRange    "{_NSRange=QQ}" }
+        { NSInteger  "q" }
+        { NSUInteger "Q" }
+        { CGFloat    "d" }
     } ] }
 } case
 assoc-union alien>objc-types set-global
 
-: internal-cocoa-type? ( c-type -- ? )
-    [ "?" = ] [ first CHAR: _ = ] bi or ;
-
-: warn-c-type ( c-type -- )
-    dup internal-cocoa-type?
-    [ drop ] [ "Warning: no such C type: " write print ] if ;
-
 : objc-struct-type ( i string -- ctype )
     [ CHAR: = ] 2keep index-from swap subseq
-    dup c-types get key? [ warn-c-type "void*" ] unless ;
+    objc>struct-types get at* [ drop void* ] unless ;
 
 ERROR: no-objc-type name ;
 
@@ -177,9 +188,9 @@ ERROR: no-objc-type name ;
 : (parse-objc-type) ( i string -- ctype )
     [ [ 1 + ] dip ] [ nth ] 2bi {
         { [ dup "rnNoORV" member? ] [ drop (parse-objc-type) ] }
-        { [ dup CHAR: ^ = ] [ 3drop "void*" ] }
+        { [ dup CHAR: ^ = ] [ 3drop void* ] }
         { [ dup CHAR: { = ] [ drop objc-struct-type ] }
-        { [ dup CHAR: [ = ] [ 3drop "void*" ] }
+        { [ dup CHAR: [ = ] [ 3drop void* ] }
         [ 2nip decode-type ]
     } cond ;
 
index 181912b0f049d26893c5a3ee0ce2c36e6d49eccc..0944727e4614d720ac3afdf89afb98e722768cc5 100644 (file)
@@ -2,7 +2,7 @@ USING: help.markup help.syntax strings alien hashtables ;
 IN: cocoa.subclassing
 
 HELP: define-objc-class
-{ $values { "hash" hashtable } { "imeth" "a sequence of instance method definitions" } }
+{ $values { "imeth" "a sequence of instance method definitions" } { "hash" hashtable } }
 { $description "Defines a new Objective C class. The hashtable can contain the following keys:"
     { $list
         { { $link +name+ } " - a string naming the new class. Required." }
index 8598fc06636c04c24b325bb24096e7b3c685f2e3..c17d1069b27533263a456e06c4d69c47d27781df 100644 (file)
@@ -30,4 +30,4 @@ ERROR: no-such-color name ;
 : named-color ( name -- color )
     dup colors at [ ] [ no-such-color ] ?if ;
 
-SYNTAX: COLOR: scan named-color parsed ;
\ No newline at end of file
+SYNTAX: COLOR: scan named-color suffix! ;
index a53f5c11853fa3c9d0fdf7c22b6bfffcfee455d3..434c2339368a24b1970dcd1a20e938f5df79e010 100644 (file)
@@ -5,5 +5,5 @@ IN: columns.tests
 { { 1 2 3 } { 4 5 6 } { 7 8 9 } } [ clone ] map "seq" set
 
 [ { 1 4 7 } ] [ "seq" get 0 <column> >array ] unit-test
-[ ] [ "seq" get 1 <column> [ sq ] change-each ] unit-test
+[ ] [ "seq" get 1 <column> [ sq ] map! drop ] unit-test
 [ { 4 25 64 } ] [ "seq" get 1 <column> >array ] unit-test
index 8f45dab8728c4e7ef153f94692dea47d0b2c36a1..8674217655c572e0bf977279d2fd3c9dc251882d 100644 (file)
@@ -8,7 +8,7 @@ TUPLE: column seq col ;
 
 C: <column> column
 
-M: column virtual-seq seq>> ;
+M: column virtual-exemplar seq>> ;
 M: column virtual@ [ col>> swap ] [ seq>> ] bi nth bounds-check ;
 M: column length seq>> length ;
 
index 399b4dc36fe35feaf226288c2944ea555094265c..bd224919f9e00c524e2a59f355f6797df286fde9 100644 (file)
@@ -47,3 +47,9 @@ IN: combinators.smart.tests
 [ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test
 
 [ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test
+
+{ 2 3 } [ [ + ] preserving ] must-infer-as
+
+{ 2 0 } [ [ + ] nullary ] must-infer-as
+
+{ 2 2 } [ [ [ + ] nullary ] preserving ] must-infer-as
index a00967742f716a28c58afbb54b2fd49edc95c614..91987e0dfa6577f05a1d3b492ab56a6279ce33dd 100644 (file)
@@ -46,5 +46,8 @@ MACRO: append-outputs ( quot -- seq )
 MACRO: preserving ( quot -- )
     [ infer in>> length ] keep '[ _ ndup @ ] ;
 
+MACRO: nullary ( quot -- quot' )
+    dup infer out>> length '[ @ _ ndrop ] ;
+
 MACRO: smart-if ( pred true false -- )
     '[ _ preserving _ _ if ] ; inline
index 2303b98aed766b4c66ec7375a730983c0dd3611d..9fffa0eed247093ad1c4e023d4a36a349fa5326c 100644 (file)
@@ -284,7 +284,7 @@ M: ##copy analyze-aliases*
 M: ##compare analyze-aliases*
     call-next-method
     dup useless-compare? [
-        dst>> \ f tag-number \ ##load-immediate new-insn
+        dst>> \ f type-number \ ##load-immediate new-insn
         analyze-aliases*
     ] when ;
 
index d303cc597fdde54627a9d574340fdda33d6140be..7f1b6aa6f28fa742777184c1718e1f4484d7136f 100644 (file)
@@ -6,6 +6,7 @@ compiler.cfg arrays locals byte-arrays kernel.private math
 slots.private vectors sbufs strings math.partial-dispatch
 hashtables assocs combinators.short-circuit
 strings.private accessors compiler.cfg.instructions ;
+FROM: alien.c-types => int ;
 IN: compiler.cfg.builder.tests
 
 ! Just ensure that various CFGs build correctly.
@@ -66,9 +67,9 @@ IN: compiler.cfg.builder.tests
     [ [ t ] loop ]
     [ [ dup ] loop ]
     [ [ 2 ] [ 3 throw ] if 4 ]
-    [ "int" f "malloc" { "int" } alien-invoke ]
-    [ "int" { "int" } "cdecl" alien-indirect ]
-    [ "int" { "int" } "cdecl" [ ] alien-callback ]
+    [ int f "malloc" { int } alien-invoke ]
+    [ int { int } "cdecl" alien-indirect ]
+    [ int { int } "cdecl" [ ] alien-callback ]
     [ swap - + * ]
     [ swap slot ]
     [ blahblah ]
@@ -118,7 +119,6 @@ IN: compiler.cfg.builder.tests
 
 {
     byte-array
-    simple-alien
     alien
     POSTPONE: f
 } [| class |
@@ -161,7 +161,7 @@ IN: compiler.cfg.builder.tests
 
 : count-insns ( quot insn-check -- ? )
     [ test-mr [ instructions>> ] map ] dip
-    '[ _ count ] sigma ; inline
+    '[ _ count ] map-sum ; inline
 
 : contains-insn? ( quot insn-check -- ? )
     count-insns 0 > ; inline
@@ -191,7 +191,7 @@ IN: compiler.cfg.builder.tests
 ] unit-test
 
 [ f t ] [
-    [ { fixnum simple-alien } declare <displaced-alien> 0 alien-cell ]
+    [ { fixnum alien } declare <displaced-alien> 0 alien-cell ]
     [ [ ##unbox-any-c-ptr? ] contains-insn? ]
     [ [ ##unbox-alien? ] contains-insn? ] bi
 ] unit-test
@@ -204,7 +204,7 @@ IN: compiler.cfg.builder.tests
     ] unit-test
 
     [ f t ] [
-        [ { byte-array fixnum } declare alien-cell { simple-alien } declare 4 alien-float ]
+        [ { byte-array fixnum } declare alien-cell { alien } declare 4 alien-float ]
         [ [ ##box-alien? ] contains-insn? ]
         [ [ ##allot? ] contains-insn? ] bi
     ] unit-test
@@ -213,4 +213,4 @@ IN: compiler.cfg.builder.tests
 ] when
 
 ! Regression. Make sure everything is inlined correctly
-[ f ] [ M\ hashtable set-at [ { [ ##call? ] [ word>> \ set-slot eq? ] } 1&& ] contains-insn? ] unit-test
\ No newline at end of file
+[ f ] [ M\ hashtable set-at [ { [ ##call? ] [ word>> \ set-slot eq? ] } 1&& ] contains-insn? ] unit-test
index 11aae28bf3295a00b42d8a2b0efa51f2fe8842ce..cf6215c5cde14b77708e56f963d58cf7552d5460 100755 (executable)
@@ -117,7 +117,7 @@ M: #recursive emit-node
     and ;
 
 : emit-trivial-if ( -- )
-    ds-pop \ f tag-number cc/= ^^compare-imm ds-push ;
+    ds-pop \ f type-number cc/= ^^compare-imm ds-push ;
 
 : trivial-not-if? ( #if -- ? )
     children>> first2
@@ -126,12 +126,12 @@ M: #recursive emit-node
     and ;
 
 : emit-trivial-not-if ( -- )
-    ds-pop \ f tag-number cc= ^^compare-imm ds-push ;
+    ds-pop \ f type-number cc= ^^compare-imm ds-push ;
 
 : emit-actual-if ( #if -- )
     ! Inputs to the final instruction need to be copied because of
     ! loc>vreg sync
-    ds-pop any-rep ^^copy \ f tag-number cc/= ##compare-imm-branch emit-if ;
+    ds-pop any-rep ^^copy \ f type-number cc/= ##compare-imm-branch emit-if ;
 
 M: #if emit-node
     {
index 369e6ebc32631f8177b338225cc12f8e79da93cb..035cc63b1e3977a9ca643bea222d969d269a0408 100644 (file)
@@ -4,20 +4,20 @@ USING: kernel math vectors arrays accessors namespaces ;
 IN: compiler.cfg
 
 TUPLE: basic-block < identity-tuple
-{ id integer }
+id
 number
 { instructions vector }
 { successors vector }
 { predecessors vector } ;
 
-M: basic-block hashcode* nip id>> ;
-
 : <basic-block> ( -- bb )
     basic-block new
+        \ basic-block counter >>id
         V{ } clone >>instructions
         V{ } clone >>successors
-        V{ } clone >>predecessors
-        \ basic-block counter >>id ;
+        V{ } clone >>predecessors ;
+
+M: basic-block hashcode* nip id>> ;
 
 TUPLE: cfg { entry basic-block } word label
 spill-area-size reps
index 510d7c45cbf5f036321859632347139acef53b7e..051b0e3e1f2c3064607c9c9ed82b554e26dfe561 100644 (file)
@@ -49,7 +49,7 @@ ERROR: bad-kill-insn bb ;
 ERROR: bad-successors ;
 
 : check-successors ( bb -- )
-    dup successors>> [ predecessors>> memq? ] with all?
+    dup successors>> [ predecessors>> member-eq? ] with all?
     [ bad-successors ] unless ;
 
 : check-basic-block ( bb -- )
index 0b4a6f2f02e561c1d3d6e87efa5279964f6121f6..35f25c2d40417ee2ebff7b76b7106414f6a5c3ac 100644 (file)
@@ -90,5 +90,5 @@ SYMBOLS:
         { cc/>   { +lt+ +eq+      +unordered+ } }
         { cc/<>  {      +eq+      +unordered+ } }
         { cc/<>= {                +unordered+ } }
-    } at memq? ;
+    } at member-eq? ;
 
index 6919ba8b9b06eb7d1b9fa4d81fa24f7690bfe42d..23382c3dbecd22c762bac9395cc73280b1d2d574 100644 (file)
@@ -63,7 +63,7 @@ M: insn update-insn rename-insn-uses t ;
     copies get dup assoc-empty? [ 2drop ] [
         renamings set
         [
-            instructions>> [ update-insn ] filter-here
+            instructions>> [ update-insn ] filter! drop
         ] each-basic-block
     ] if ;
 
index b8735e224c3e6f8dd92485173a3418a4215aeb35..03a43d0ab7860f641d633e583719946a530bc055 100644 (file)
@@ -117,5 +117,5 @@ M: insn live-insn? defs-vreg [ live-vreg? ] [ t ] if* ;
     dup
     [ [ instructions>> [ build-liveness-graph ] each ] each-basic-block ]
     [ [ instructions>> [ compute-live-vregs ] each ] each-basic-block ]
-    [ [ instructions>> [ live-insn? ] filter-here ] each-basic-block ]
+    [ [ instructions>> [ live-insn? ] filter! drop ] each-basic-block ]
     tri ;
index 825ff71b9be76aff6c7aa397a7e2bf62ff44f2ea..54cff2ccaa7aeb3bcac9c5321b223c3e57f601f8 100644 (file)
@@ -11,6 +11,10 @@ GENERIC: defs-vreg ( insn -- vreg/f )
 GENERIC: temp-vregs ( insn -- seq )
 GENERIC: uses-vregs ( insn -- seq )
 
+M: insn defs-vreg drop f ;
+M: insn temp-vregs drop { } ;
+M: insn uses-vregs drop { } ;
+
 M: ##phi uses-vregs inputs>> values ;
 
 <PRIVATE
@@ -24,19 +28,25 @@ M: ##phi uses-vregs inputs>> values ;
     } case ;
 
 : define-defs-vreg-method ( insn -- )
-    [ \ defs-vreg create-method ]
-    [ insn-def-slot [ name>> reader-word 1quotation ] [ [ drop f ] ] if* ] bi
-    define ;
+    dup insn-def-slot dup [
+        [ \ defs-vreg create-method ]
+        [ name>> reader-word 1quotation ] bi*
+        define
+    ] [ 2drop ] if ;
 
 : define-uses-vregs-method ( insn -- )
-    [ \ uses-vregs create-method ]
-    [ insn-use-slots [ name>> ] map slot-array-quot ] bi
-    define ;
+    dup insn-use-slots [ drop ] [
+        [ \ uses-vregs create-method ]
+        [ [ name>> ] map slot-array-quot ] bi*
+        define
+    ] if-empty ;
 
 : define-temp-vregs-method ( insn -- )
-    [ \ temp-vregs create-method ]
-    [ insn-temp-slots [ name>> ] map slot-array-quot ] bi
-    define ;
+    dup insn-temp-slots [ drop ] [
+        [ \ temp-vregs create-method ]
+        [ [ name>> ] map slot-array-quot ] bi*
+        define
+    ] if-empty ;
 
 PRIVATE>
 
index 5d3c79e40f60e22c0dd4a3f3517d0eb13385aca9..6d192ec54a627d6bf44d8320a317fef9d95fb452 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel sequences assocs fry
-cpu.architecture layouts
+USING: accessors kernel sequences assocs fry math
+cpu.architecture layouts namespaces
 compiler.cfg.rpo
 compiler.cfg.registers
 compiler.cfg.instructions
@@ -21,12 +21,14 @@ GENERIC: allocation-size* ( insn -- n )
 
 M: ##allot allocation-size* size>> ;
 
-M: ##box-alien allocation-size* drop 4 cells ;
+M: ##box-alien allocation-size* drop 5 cells ;
 
-M: ##box-displaced-alien allocation-size* drop 4 cells ;
+M: ##box-displaced-alien allocation-size* drop 5 cells ;
 
 : allocation-size ( bb -- n )
-    instructions>> [ ##allocation? ] filter [ allocation-size* ] sigma ;
+    instructions>>
+    [ ##allocation? ] filter
+    [ allocation-size* data-alignment get align ] map-sum ;
 
 : insert-gc-check ( bb -- )
     dup dup '[
@@ -44,4 +46,4 @@ M: ##box-displaced-alien allocation-size* drop 4 cells ;
     dup blocks-with-gc [
         over compute-uninitialized-sets
         [ insert-gc-check ] each
-    ] unless-empty ;
\ No newline at end of file
+    ] unless-empty ;
index 42aa5512bc1aa60321b1e0afe9813a690c7827f8..9d1945c525440d28dd4d0d4f9ca1a4597bc39c05 100644 (file)
@@ -26,7 +26,7 @@ IN: compiler.cfg.hats
 
 : hat-effect ( insn -- effect )
     "insn-slots" word-prop
-    [ type>> { def temp } memq? not ] filter [ name>> ] map
+    [ type>> { def temp } member-eq? not ] filter [ name>> ] map
     { "vreg" } <effect> ;
 
 : define-hat ( insn -- )
@@ -43,14 +43,14 @@ insn-classes get [
 
 : ^^load-literal ( obj -- dst )
     [ next-vreg dup ] dip {
-        { [ dup not ] [ drop \ f tag-number ##load-immediate ] }
+        { [ dup not ] [ drop \ f type-number ##load-immediate ] }
         { [ dup fixnum? ] [ tag-fixnum ##load-immediate ] }
         { [ dup float? ] [ ##load-constant ] }
         [ ##load-reference ]
     } cond ;
 
 : ^^offset>slot ( slot -- vreg' )
-    cell 4 = [ 1 ^^shr-imm ] [ any-rep ^^copy ] if ;
+    cell 4 = 2 1 ? ^^shr-imm ;
 
 : ^^tag-fixnum ( src -- dst )
     tag-bits get ^^shl-imm ;
index bffa0e59d054eda3c20d2bc0636bc1b653d5fa13..91ac92327339bf3780acd01d6de2a43997422559 100644 (file)
@@ -417,12 +417,12 @@ def: dst/scalar-rep
 use: src
 literal: rep ;
 
-PURE-INSN: ##horizontal-shl-vector
+PURE-INSN: ##horizontal-shl-vector-imm
 def: dst
 use: src1
 literal: src2 rep ;
 
-PURE-INSN: ##horizontal-shr-vector
+PURE-INSN: ##horizontal-shr-vector-imm
 def: dst
 use: src1
 literal: src2 rep ;
@@ -462,6 +462,16 @@ def: dst
 use: src
 literal: rep ;
 
+PURE-INSN: ##shl-vector-imm
+def: dst
+use: src1
+literal: src2 rep ;
+
+PURE-INSN: ##shr-vector-imm
+def: dst
+use: src1
+literal: src2 rep ;
+
 PURE-INSN: ##shl-vector
 def: dst
 use: src1 src2/int-scalar-rep
@@ -502,13 +512,12 @@ temp: temp/int-rep ;
 PURE-INSN: ##box-displaced-alien
 def: dst/int-rep
 use: displacement/int-rep base/int-rep
-temp: temp1/int-rep temp2/int-rep
+temp: temp/int-rep
 literal: base-class ;
 
 PURE-INSN: ##unbox-any-c-ptr
 def: dst/int-rep
-use: src/int-rep
-temp: temp/int-rep ;
+use: src/int-rep ;
 
 : ##unbox-f ( dst src -- ) drop 0 ##load-immediate ;
 : ##unbox-byte-array ( dst src -- ) byte-array-offset ##add-imm ;
@@ -517,12 +526,12 @@ PURE-INSN: ##unbox-alien
 def: dst/int-rep
 use: src/int-rep ;
 
-: ##unbox-c-ptr ( dst src class temp -- )
+: ##unbox-c-ptr ( dst src class -- )
     {
-        { [ over \ f class<= ] [ 2drop ##unbox-f ] }
-        { [ over simple-alien class<= ] [ 2drop ##unbox-alien ] }
-        { [ over byte-array class<= ] [ 2drop ##unbox-byte-array ] }
-        [ nip ##unbox-any-c-ptr ]
+        { [ dup \ f class<= ] [ drop ##unbox-f ] }
+        { [ dup alien class<= ] [ drop ##unbox-alien ] }
+        { [ dup byte-array class<= ] [ drop ##unbox-byte-array ] }
+        [ drop ##unbox-any-c-ptr ]
     } cond ;
 
 ! Alien accessors
@@ -833,7 +842,7 @@ SYMBOL: vreg-insn
 [
     vreg-insn
     insn-classes get [
-        "insn-slots" word-prop [ type>> { def use temp } memq? ] any?
+        "insn-slots" word-prop [ type>> { def use temp } member-eq? ] any?
     ] filter
     define-union-class
 ] with-compilation-unit
index a37e100c3e5c823afb8be082e2c2c2d2a6843c89..320a0a08f7c89982fd0445a305ddd8b48af086b9 100644 (file)
@@ -22,12 +22,10 @@ IN: compiler.cfg.intrinsics.alien
     ] [ emit-primitive ] if ;
 
 :: inline-alien ( node quot test -- )
-    [let | infos [ node node-input-infos ] |
-        infos test call
-        [ infos quot call ]
-        [ node emit-primitive ]
-        if
-    ] ; inline
+    node node-input-infos :> infos
+    infos test call
+    [ infos quot call ]
+    [ node emit-primitive ] if ; inline
 
 : inline-alien-getter? ( infos -- ? )
     [ first class>> c-ptr class<= ]
@@ -35,7 +33,7 @@ IN: compiler.cfg.intrinsics.alien
     bi and ;
 
 : ^^unbox-c-ptr ( src class -- dst )
-    [ next-vreg dup ] 2dip next-vreg ##unbox-c-ptr ;
+    [ next-vreg dup ] 2dip ##unbox-c-ptr ;
 
 : prepare-alien-accessor ( info -- ptr-vreg offset )
     class>> [ 2inputs ^^untag-fixnum swap ] dip ^^unbox-c-ptr ^^add 0 ;
index 8283299ea8afd140cbb2bc6f10657d1524570cb2..9804244ecb939da2a2d7d5996b808f9b4b61019c 100644 (file)
@@ -8,7 +8,7 @@ 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 + _ type-number ##set-slot-imm ] each-index ;
 
 : emit-simple-allot ( node -- )
     [ in-d>> length ] [ node-output-infos first class>> ] bi
@@ -31,10 +31,10 @@ IN: compiler.cfg.intrinsics.allot
     ] [ drop emit-primitive ] if ;
 
 : store-length ( len reg class -- )
-    [ [ ^^load-literal ] dip 1 ] dip tag-number ##set-slot-imm ;
+    [ [ ^^load-literal ] dip 1 ] dip type-number ##set-slot-imm ;
 
 :: store-initial-element ( len reg elt class -- )
-    len [ [ elt reg ] dip 2 + class tag-number ##set-slot-imm ] each ;
+    len [ [ elt reg ] dip 2 + class type-number ##set-slot-imm ] each ;
 
 : expand-<array>? ( obj -- ? )
     dup integer? [ 0 8 between? ] [ drop f ] if ;
@@ -43,17 +43,15 @@ IN: compiler.cfg.intrinsics.allot
     2 + cells array ^^allot ;
 
 :: emit-<array> ( node -- )
-    [let | len [ node node-input-infos first literal>> ] |
-        len expand-<array>? [
-            [let | elt [ ds-pop ]
-                   reg [ len ^^allot-array ] |
-                ds-drop
-                len reg array store-length
-                len reg elt array store-initial-element
-                reg ds-push
-            ]
-        ] [ node emit-primitive ] if
-    ] ;
+    node node-input-infos first literal>> :> len
+    len expand-<array>? [
+        ds-pop :> elt
+        len ^^allot-array :> reg
+        ds-drop
+        len reg array store-length
+        len reg elt array store-initial-element
+        reg ds-push
+    ] [ node emit-primitive ] if ;
 
 : expand-(byte-array)? ( obj -- ? )
     dup integer? [ 0 1024 between? ] [ drop f ] if ;
@@ -64,7 +62,7 @@ IN: compiler.cfg.intrinsics.allot
 : bytes>cells ( m -- n ) cell align cell /i ;
 
 : ^^allot-byte-array ( n -- dst )
-    2 cells + byte-array ^^allot ;
+    16 + byte-array ^^allot ;
 
 : emit-allot-byte-array ( len -- dst )
     ds-drop
index 8ead484cf1ac26e9dac7861723c7213f4bfcfcf7..e4d1735eae6b19cedc4b33854f1709a13c564b82 100644 (file)
@@ -21,7 +21,7 @@ IN: compiler.cfg.intrinsics.fixnum
     ds-push ;
 
 : tag-literal ( n -- tagged )
-    literal>> [ tag-fixnum ] [ \ f tag-number ] if* ;
+    literal>> [ tag-fixnum ] [ \ f type-number ] if* ;
 
 : emit-fixnum-op ( insn -- )
     [ 2inputs ] dip call ds-push ; inline
index 3b6674efee96fee69d5831ddd3e5611ac5c85721..f40b838b97214f6cac38672e0a646eaed3d243d3 100644 (file)
@@ -33,6 +33,7 @@ IN: compiler.cfg.intrinsics
 {
     { kernel.private:tag [ drop emit-tag ] }
     { kernel.private:getenv [ emit-getenv ] }
+    { kernel.private:(identity-hashcode) [ drop emit-identity-hashcode ] }
     { math.private:both-fixnums? [ drop emit-both-fixnums? ] }
     { math.private:fixnum+ [ drop emit-fixnum+ ] }
     { math.private:fixnum- [ drop emit-fixnum- ] }
@@ -163,8 +164,8 @@ IN: compiler.cfg.intrinsics
         { math.vectors.simd.intrinsics:(simd-v*) [ [ ^^mul-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vs*) [ [ ^^saturated-mul-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-v/) [ [ ^^div-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vmin) [ [ ^^min-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vmax) [ [ ^^max-vector ] emit-binary-vector-op ] }
+        { math.vectors.simd.intrinsics:(simd-vmin) [ [ generate-min-vector ] emit-binary-vector-op ] }
+        { math.vectors.simd.intrinsics:(simd-vmax) [ [ generate-max-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-v.) [ [ ^^dot-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vabs) [ [ generate-abs-vector ] emit-unary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vsqrt) [ [ ^^sqrt-vector ] emit-unary-vector-op ] }
@@ -187,10 +188,10 @@ IN: compiler.cfg.intrinsics
         { math.vectors.simd.intrinsics:(simd-vany?) [ [ vcc-any ^^test-vector ] emit-unary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vall?) [ [ vcc-all ^^test-vector ] emit-unary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vnone?) [ [ vcc-none ^^test-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vlshift) [ [ ^^shl-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vrshift) [ [ ^^shr-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-hlshift) [ [ ^^horizontal-shl-vector ] emit-horizontal-shift ] }
-        { math.vectors.simd.intrinsics:(simd-hrshift) [ [ ^^horizontal-shr-vector ] emit-horizontal-shift ] }
+        { math.vectors.simd.intrinsics:(simd-vlshift) [ [ ^^shl-vector-imm ] [ ^^shl-vector ] emit-shift-vector-op ] }
+        { math.vectors.simd.intrinsics:(simd-vrshift) [ [ ^^shr-vector-imm ] [ ^^shr-vector ] emit-shift-vector-op ] }
+        { math.vectors.simd.intrinsics:(simd-hlshift) [ [ ^^horizontal-shl-vector-imm ] emit-shift-vector-imm-op ] }
+        { math.vectors.simd.intrinsics:(simd-hrshift) [ [ ^^horizontal-shr-vector-imm ] emit-shift-vector-imm-op ] }
         { math.vectors.simd.intrinsics:(simd-with) [ [ ^^with-vector ] emit-unary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-gather-2) [ emit-gather-vector-2 ] }
         { math.vectors.simd.intrinsics:(simd-gather-4) [ emit-gather-vector-4 ] }
index ce005e8353650e5f6461b4d4188b8fef7be11f8c..a477ef4b950b1d0b9b6a6dcbf58d99edc1a6a6c6 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces layouts sequences kernel
-accessors compiler.tree.propagation.info
-compiler.cfg.stacks compiler.cfg.hats
-compiler.cfg.instructions compiler.cfg.utilities ;
+USING: namespaces layouts sequences kernel math accessors
+compiler.tree.propagation.info compiler.cfg.stacks
+compiler.cfg.hats compiler.cfg.instructions
+compiler.cfg.utilities ;
 IN: compiler.cfg.intrinsics.misc
 
 : emit-tag ( -- )
@@ -14,3 +14,9 @@ IN: compiler.cfg.intrinsics.misc
     swap node-input-infos first literal>>
     [ ds-drop 0 ^^slot-imm ] [ ds-pop ^^offset>slot ^^slot ] if*
     ds-push ;
+
+: emit-identity-hashcode ( -- )
+    ds-pop tag-mask get bitnot ^^load-immediate ^^and 0 0 ^^slot-imm
+    hashcode-shift ^^shr-imm
+    ^^tag-fixnum
+    ds-push ;
index 73f880a102e8d17bc77658440e413304c85d4726..a8dfaab2ddffbd2295175ed04f77633872784bdb 100644 (file)
@@ -10,8 +10,8 @@ compiler.cfg.stacks compiler.cfg.stacks.local compiler.cfg.hats
 compiler.cfg.instructions compiler.cfg.registers
 compiler.cfg.intrinsics.alien
 specialized-arrays ;
-FROM: alien.c-types => heap-size char uchar float double ;
-SPECIALIZED-ARRAYS: float double ;
+FROM: alien.c-types => heap-size uchar ushort uint ulonglong float double ;
+SPECIALIZED-ARRAYS: uchar ushort uint ulonglong float double ;
 IN: compiler.cfg.intrinsics.simd
 
 MACRO: check-elements ( quots -- )
@@ -55,10 +55,15 @@ MACRO: if-literals-match ( quots -- )
 : [unary/param] ( quot -- quot' )
     '[ [ -2 inc-d ds-pop ] 2dip @ ds-push ] ; inline
 
-: emit-horizontal-shift ( node quot -- )
+: emit-shift-vector-imm-op ( node quot -- )
     [unary/param]
     { [ integer? ] [ representation? ] } if-literals-match ; inline
 
+:: emit-shift-vector-op ( node imm-quot var-quot -- )
+    node node-input-infos 2 tail-slice* first literal>> integer?
+    [ node imm-quot emit-shift-vector-imm-op ]
+    [ node var-quot emit-binary-vector-op ] if ; inline
+
 : emit-gather-vector-2 ( node -- )
     [ ^^gather-vector-2 ] emit-binary-vector-op ;
 
@@ -155,28 +160,79 @@ MACRO: if-literals-match ( quots -- )
     [ ^^not-vector ]
     [ [ ^^fill-vector ] [ ^^xor-vector ] bi ] if ;
 
-:: (generate-compare-vector) ( src1 src2 rep {cc,swap} -- dst )
-    {cc,swap} first2 :> swap? :> cc
+:: ((generate-compare-vector)) ( src1 src2 rep {cc,swap} -- dst )
+    {cc,swap} first2 :> ( cc swap? )
     swap?
     [ src2 src1 rep cc ^^compare-vector ]
     [ src1 src2 rep cc ^^compare-vector ] if ;
 
-:: generate-compare-vector ( src1 src2 rep orig-cc -- dst )
-    rep orig-cc %compare-vector-ccs :> not? :> ccs
+:: (generate-compare-vector) ( src1 src2 rep orig-cc -- dst )
+    rep orig-cc %compare-vector-ccs :> ( ccs not? )
 
     ccs empty?
     [ rep not? [ ^^fill-vector ] [ ^^zero-vector ] if ]
     [
-        ccs unclip :> first-cc :> rest-ccs
-        src1 src2 rep first-cc (generate-compare-vector) :> first-dst
+        ccs unclip :> ( rest-ccs first-cc )
+        src1 src2 rep first-cc ((generate-compare-vector)) :> first-dst
 
         rest-ccs first-dst
-        [ [ src1 src2 rep ] dip (generate-compare-vector) rep ^^or-vector ]
+        [ [ src1 src2 rep ] dip ((generate-compare-vector)) rep ^^or-vector ]
         reduce
 
         not? [ rep generate-not-vector ] when
     ] if ;
 
+: sign-bit-mask ( rep -- byte-array )
+    unsign-rep {
+        { char-16-rep [ uchar-array{
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+        } underlying>> ] }
+        { short-8-rep [ ushort-array{
+            HEX: 8000 HEX: 8000 HEX: 8000 HEX: 8000
+            HEX: 8000 HEX: 8000 HEX: 8000 HEX: 8000
+        } underlying>> ] }
+        { int-4-rep [ uint-array{
+            HEX: 8000,0000 HEX: 8000,0000
+            HEX: 8000,0000 HEX: 8000,0000
+        } underlying>> ] }
+        { longlong-2-rep [ ulonglong-array{
+            HEX: 8000,0000,0000,0000
+            HEX: 8000,0000,0000,0000
+        } underlying>> ] }
+    } case ;
+
+:: (generate-minmax-compare-vector) ( src1 src2 rep orig-cc -- dst )
+    orig-cc order-cc {
+        { cc<  [ src1 src2 rep ^^max-vector src1 rep cc/= (generate-compare-vector) ] }
+        { cc<= [ src1 src2 rep ^^min-vector src1 rep cc=  (generate-compare-vector) ] }
+        { cc>  [ src1 src2 rep ^^min-vector src1 rep cc/= (generate-compare-vector) ] }
+        { cc>= [ src1 src2 rep ^^max-vector src1 rep cc=  (generate-compare-vector) ] }
+    } case ;
+
+:: generate-compare-vector ( src1 src2 rep orig-cc -- dst )
+    {
+        {
+            [ rep orig-cc %compare-vector-reps member? ]
+            [ src1 src2 rep orig-cc (generate-compare-vector) ]
+        }
+        {
+            [ rep %min-vector-reps member? ]
+            [ src1 src2 rep orig-cc (generate-minmax-compare-vector) ]
+        }
+        {
+            [ rep unsign-rep orig-cc %compare-vector-reps member? ]
+            [ 
+                rep sign-bit-mask ^^load-constant :> sign-bits
+                src1 sign-bits rep ^^xor-vector
+                src2 sign-bits rep ^^xor-vector
+                rep unsign-rep orig-cc (generate-compare-vector)
+            ]
+        }
+    } cond ;
+
 :: generate-unpack-vector-head ( src rep -- dst )
     {
         {
@@ -190,6 +246,14 @@ MACRO: if-literals-match ( quots -- )
                 src zero rep ^^merge-vector-head
             ]
         }
+        {
+            [ rep widen-vector-rep %shr-vector-imm-reps member? ]
+            [
+                src src rep ^^merge-vector-head
+                rep rep-component-type
+                heap-size 8 * rep widen-vector-rep ^^shr-vector-imm
+            ]
+        }
         [
             rep ^^zero-vector :> zero
             zero src rep cc> ^^compare-vector :> sign
@@ -217,6 +281,14 @@ MACRO: if-literals-match ( quots -- )
                 src zero rep ^^merge-vector-tail
             ]
         }
+        {
+            [ rep widen-vector-rep %shr-vector-imm-reps member? ]
+            [
+                src src rep ^^merge-vector-tail
+                rep rep-component-type
+                heap-size 8 * rep widen-vector-rep ^^shr-vector-imm
+            ]
+        }
         [
             rep ^^zero-vector :> zero
             zero src rep cc> ^^compare-vector :> sign
@@ -265,3 +337,17 @@ MACRO: if-literals-match ( quots -- )
         ]
     } cond ;
 
+: generate-min-vector ( src1 src2 rep -- dst )
+    dup %min-vector-reps member?
+    [ ^^min-vector ] [
+        [ cc< generate-compare-vector ]
+        [ generate-blend-vector ] 3bi
+    ] if ;
+
+: generate-max-vector ( src1 src2 rep -- dst )
+    dup %max-vector-reps member?
+    [ ^^max-vector ] [
+        [ cc> generate-compare-vector ]
+        [ generate-blend-vector ] 3bi
+    ] if ;
+
index e1088a80ef980c9cc1cd7598ecfe1b9c808413b5..1ceac4990ace32a93fdea8342e6af3bf07474b3c 100644 (file)
@@ -1,14 +1,17 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: layouts namespaces kernel accessors sequences math
-classes.algebra locals combinators cpu.architecture
-compiler.tree.propagation.info compiler.cfg.stacks
-compiler.cfg.hats compiler.cfg.registers
+classes.algebra classes.builtin locals combinators
+cpu.architecture compiler.tree.propagation.info
+compiler.cfg.stacks compiler.cfg.hats compiler.cfg.registers
 compiler.cfg.instructions compiler.cfg.utilities
 compiler.cfg.builder.blocks compiler.constants ;
 IN: compiler.cfg.intrinsics.slots
 
-: value-tag ( info -- n ) class>> class-tag ; inline
+: class-tag ( class -- tag/f )
+    builtins get [ class<= ] with find drop ;
+
+: value-tag ( info -- n ) class>> class-tag ;
 
 : ^^tag-offset>slot ( slot tag -- vreg' )
     [ ^^offset>slot ] dip ^^sub-imm ;
@@ -42,7 +45,7 @@ IN: compiler.cfg.intrinsics.slots
     first class>> immediate class<= not ;
 
 :: (emit-set-slot) ( infos -- )
-    3inputs :> slot :> obj :> src
+    3inputs :> ( src obj slot )
 
     slot infos second value-tag ^^tag-offset>slot :> slot
 
@@ -54,7 +57,7 @@ IN: compiler.cfg.intrinsics.slots
 :: (emit-set-slot-imm) ( infos -- )
     ds-drop
 
-    2inputs :> obj :> src
+    2inputs :> ( src obj )
 
     infos third literal>> :> slot
     infos second value-tag :> tag
index ac32265e654723e0f339a36324f4320ea754d1fb..8951d7a1f1e15b9e34bfc2535485755d1a13f8a2 100644 (file)
@@ -42,7 +42,7 @@ IN: compiler.cfg.linear-scan.allocation
 
 : handle-sync-point ( n -- )
     [ active-intervals get values ] dip
-    '[ [ _ spill-at-sync-point ] filter-here ] each ;
+    '[ [ _ spill-at-sync-point ] filter! drop ] each ;
 
 :: handle-progress ( n sync? -- )
     n {
index 8b4dde59daa9714241e14a650a89ebb37657d863..845cb14d5c8738f5fb3985e5fa25979f8be3dd47 100644 (file)
@@ -18,13 +18,13 @@ ERROR: bad-live-ranges interval ;
 
 : trim-before-ranges ( live-interval -- )
     [ ranges>> ] [ uses>> last 1 + ] bi
-    [ '[ from>> _ <= ] filter-here ]
+    [ '[ from>> _ <= ] filter! drop ]
     [ swap last (>>to) ]
     2bi ;
 
 : trim-after-ranges ( live-interval -- )
     [ ranges>> ] [ uses>> first ] bi
-    [ '[ to>> _ >= ] filter-here ]
+    [ '[ to>> _ >= ] filter! drop ]
     [ swap first (>>from) ]
     2bi ;
 
@@ -103,7 +103,7 @@ ERROR: bad-live-ranges interval ;
     ! most one) are split and spilled and removed from the inactive
     ! set.
     new vreg>> active-intervals-for [ [ reg>> reg = ] find swap dup ] keep
-    '[ _ delete-nth new start>> spill ] [ 2drop ] if ;
+    '[ _ remove-nth! drop  new start>> spill ] [ 2drop ] if ;
 
 :: spill-intersecting-inactive ( new reg -- )
     ! Any inactive intervals using 'reg' are split and spilled
@@ -114,7 +114,7 @@ ERROR: bad-live-ranges interval ;
                 new start>> spill f
             ] [ drop t ] if
         ] [ drop t ] if
-    ] filter-here ;
+    ] filter! drop ;
 
 : spill-intersecting ( new reg -- )
     ! Split and spill all active and inactive intervals
@@ -141,4 +141,4 @@ ERROR: bad-live-ranges interval ;
         { [ 2dup spill-new? ] [ spill-new ] }
         { [ 2dup register-available? ] [ spill-available ] }
         [ spill-partially-available ]
-    } cond ;
\ No newline at end of file
+    } cond ;
index aeebe31dcc00ec0a46bbdb536c09ddb9e45f11c7..4c825c9d7ce62c9c6eab8be06c3e9186a67096f3 100644 (file)
@@ -33,7 +33,7 @@ SYMBOL: active-intervals
     dup vreg>> active-intervals-for push ;
 
 : delete-active ( live-interval -- )
-    dup vreg>> active-intervals-for delq ;
+    dup vreg>> active-intervals-for remove-eq! drop ;
 
 : assign-free-register ( new registers -- )
     pop >>reg add-active ;
@@ -48,7 +48,7 @@ SYMBOL: inactive-intervals
     dup vreg>> inactive-intervals-for push ;
 
 : delete-inactive ( live-interval -- )
-    dup vreg>> inactive-intervals-for delq ;
+    dup vreg>> inactive-intervals-for remove-eq! drop ;
 
 ! Vector of handled live intervals
 SYMBOL: handled-intervals
@@ -83,7 +83,7 @@ ERROR: register-already-used live-interval ;
 ! Moving intervals between active and inactive sets
 : process-intervals ( n symbol quots -- )
     ! symbol stores an alist mapping register classes to vectors
-    [ get values ] dip '[ [ _ cond ] with filter-here ] with each ; inline
+    [ get values ] dip '[ [ _ cond ] with filter! drop ] with each ; inline
 
 : deactivate-intervals ( n -- )
     ! Any active intervals which have ended are moved to handled
index 75dda9b47534c77869641b7ea610c8f54e9c91e1..00d6f73517ec3dd8949dd5fd0549dfd8547d141b 100644 (file)
@@ -152,8 +152,8 @@ ERROR: bad-live-interval live-interval ;
     ! to reverse some sequences, and compute the start and end.
     values dup [
         {
-            [ ranges>> reverse-here ]
-            [ uses>> reverse-here ]
+            [ ranges>> reverse! drop ]
+            [ uses>> reverse! drop ]
             [ compute-start/end ]
             [ check-start ]
         } cleave
@@ -187,4 +187,4 @@ ERROR: bad-live-interval live-interval ;
     } cond ;
 
 : intervals-intersect? ( interval1 interval2 -- ? )
-    relevant-ranges intersect-live-ranges >boolean ; inline
\ No newline at end of file
+    relevant-ranges intersect-live-ranges >boolean ; inline
index 8ab9f316a726c357945f2a59da4f3a679d778911..506d4aa46cdc465f90afbdce7d92ec01ab49588e 100644 (file)
@@ -12,7 +12,7 @@ IN: compiler.cfg.predecessors
 : update-phi ( bb ##phi -- )
     [
         swap predecessors>>
-        '[ drop _ memq? ] assoc-filter
+        '[ drop _ member-eq? ] assoc-filter
     ] change-inputs drop ;
 
 : update-phis ( bb -- )
@@ -30,4 +30,4 @@ PRIVATE>
 
 : needs-predecessors ( cfg -- cfg' )
     dup predecessors-valid?>>
-    [ compute-predecessors t >>predecessors-valid? ] unless ;
\ No newline at end of file
+    [ compute-predecessors t >>predecessors-valid? ] unless ;
index 0d518735afb337dcd004acca4a297ebc9b5e4f79..2f4f2a99e69be5735c423c0b1b048fd672b48e5a 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors namespaces kernel parser assocs ;
+USING: accessors namespaces kernel parser assocs sequences ;
 IN: compiler.cfg.registers
 
 ! Virtual registers, used by CFG and machine IRs, are just integers
@@ -42,5 +42,5 @@ C: <ds-loc> ds-loc
 TUPLE: rs-loc < loc ;
 C: <rs-loc> rs-loc
 
-SYNTAX: D scan-word <ds-loc> parsed ;
-SYNTAX: R scan-word <rs-loc> parsed ;
+SYNTAX: D scan-word <ds-loc> suffix! ;
+SYNTAX: R scan-word <rs-loc> suffix! ;
index 2af68e9175214ca03218cc6ea599a917f2c30b5d..261aab6c54ee996e67ad9dd8aa07b661370aff02 100644 (file)
@@ -20,15 +20,19 @@ WHERE
 
 GENERIC: rename-insn-defs ( insn -- )
 
-insn-classes get [
+M: insn rename-insn-defs drop ;
+
+insn-classes get [ insn-def-slot ] filter [
     [ \ rename-insn-defs create-method-in ]
-    [ insn-def-slot dup [ name>> 1array ] when DEF-QUOT slot-change-quot ] bi
+    [ insn-def-slot name>> 1array DEF-QUOT slot-change-quot ] bi
     define
 ] each
 
 GENERIC: rename-insn-uses ( insn -- )
 
-insn-classes get { ##phi } diff [
+M: insn rename-insn-uses drop ;
+
+insn-classes get { ##phi } diff [ insn-use-slots empty? not ] filter [
     [ \ rename-insn-uses create-method-in ]
     [ insn-use-slots [ name>> ] map USE-QUOT slot-change-quot ] bi
     define
@@ -39,7 +43,9 @@ M: ##phi rename-insn-uses
 
 GENERIC: rename-insn-temps ( insn -- )
 
-insn-classes get [
+M: insn rename-insn-temps drop ;
+
+insn-classes get [ insn-temp-slots empty? not ] filter [
     [ \ rename-insn-temps create-method-in ]
     [ insn-temp-slots [ name>> ] map TEMP-QUOT slot-change-quot ] bi
     define
index 4444290f057ece86c2a2c0a43ee2899c209e2b8e..726521cfe1922b4fbfda67de04f296f05f8b319e 100644 (file)
@@ -11,6 +11,10 @@ GENERIC: defs-vreg-rep ( insn -- rep/f )
 GENERIC: temp-vreg-reps ( insn -- reps )
 GENERIC: uses-vreg-reps ( insn -- reps )
 
+M: insn defs-vreg-rep drop f ;
+M: insn temp-vreg-reps drop { } ;
+M: insn uses-vreg-reps drop { } ;
+
 <PRIVATE
 
 : rep-getter-quot ( rep -- quot )
@@ -21,12 +25,14 @@ GENERIC: uses-vreg-reps ( insn -- reps )
     } case ;
 
 : define-defs-vreg-rep-method ( insn -- )
-    [ \ defs-vreg-rep create-method ]
-    [ insn-def-slot [ rep>> rep-getter-quot ] [ [ drop f ] ] if* ]
-    bi define ;
+    dup insn-def-slot dup [
+        [ \ defs-vreg-rep create-method ]
+        [ rep>> rep-getter-quot ]
+        bi* define
+    ] [ 2drop ] if ;
 
 : reps-getter-quot ( reps -- quot )
-    dup [ rep>> { f scalar-rep } memq? not ] all? [
+    dup [ rep>> { f scalar-rep } member-eq? not ] all? [
         [ rep>> ] map [ drop ] swap suffix
     ] [
         [ rep>> rep-getter-quot ] map dup length {
@@ -38,14 +44,18 @@ GENERIC: uses-vreg-reps ( insn -- reps )
     ] if ;
 
 : define-uses-vreg-reps-method ( insn -- )
-    [ \ uses-vreg-reps create-method ]
-    [ insn-use-slots reps-getter-quot ]
-    bi define ;
+    dup insn-use-slots [ drop ] [
+        [ \ uses-vreg-reps create-method ]
+        [ reps-getter-quot ]
+        bi* define
+    ] if-empty ;
 
 : define-temp-vreg-reps-method ( insn -- )
-    [ \ temp-vreg-reps create-method ]
-    [ insn-temp-slots reps-getter-quot ]
-    bi define ;
+    dup insn-temp-slots [ drop ] [
+        [ \ temp-vreg-reps create-method ]
+        [ reps-getter-quot ]
+        bi* define
+    ] if-empty ;
 
 PRIVATE>
 
index 42059f4152f1a18b4379425f3969f98d3e019a42..005fe8c90b3b1a887f102766860862dbfc734d56 100644 (file)
@@ -47,7 +47,7 @@ M:: vector-rep emit-box ( dst src rep -- )
     int-rep next-vreg-rep :> temp
     dst 16 2 cells + byte-array int-rep next-vreg-rep ##allot
     temp 16 tag-fixnum ##load-immediate
-    temp dst 1 byte-array tag-number ##set-slot-imm
+    temp dst 1 byte-array type-number ##set-slot-imm
     dst byte-array-offset src rep ##set-alien-vector ;
 
 M: vector-rep emit-unbox
@@ -209,7 +209,7 @@ RENAMING: convert [ converted-value ] [ converted-value ] [ ]
 
 : perform-renaming ( insn -- )
     needs-renaming? get [
-        renaming-set get reverse-here
+        renaming-set get reverse! drop
         [ convert-insn-uses ] [ convert-insn-defs ] bi
         renaming-set get length 0 assert=
     ] [ drop ] if ;
index 071b5d4b2040bcfad4f6129cff00ddda9878d308..d93045da550acb9dbc496a7e7fc81ccddd391ed7 100644 (file)
@@ -102,7 +102,7 @@ M: ##phi prepare-insn
             [ rename-insn-defs ]
             [ rename-insn-uses ]
             [ [ useless-copy? ] [ ##phi? ] bi or not ] tri
-        ] filter-here
+        ] filter! drop
     ] each-basic-block ;
 
 : destruct-ssa ( cfg -- cfg' )
@@ -114,4 +114,4 @@ M: ##phi prepare-insn
     dup compute-live-ranges
     dup prepare-coalescing
     process-copies
-    dup perform-renaming ;
\ No newline at end of file
+    dup perform-renaming ;
index 1ed6010dbe894bf16fff9362a5d47d51d7f31c81..7847de28fcae16c39680206df8fbf6440731d28a 100644 (file)
@@ -121,10 +121,9 @@ PRIVATE>
 PRIVATE>
 
 :: live-out? ( vreg node -- ? )
-    [let | def [ vreg def-of ] |
-        {
-            { [ node def eq? ] [ vreg uses-of def only? not ] }
-            { [ def node strictly-dominates? ] [ vreg node (live-out?) ] }
-            [ f ]
-        } cond
-    ] ;
+    vreg def-of :> def
+    {
+        { [ node def eq? ] [ vreg uses-of def only? not ] }
+        { [ def node strictly-dominates? ] [ vreg node (live-out?) ] }
+        [ f ]
+    } cond ;
index cd4978c585ffe3bb194a7e2118e2f93c6c60afae..a2885ae26e775ed6b1a6e3a426e5aa1672397cfe 100644 (file)
@@ -13,7 +13,7 @@ IN: compiler.cfg.useless-conditionals
                 ##compare-imm-branch
                 ##compare-float-ordered-branch
                 ##compare-float-unordered-branch
-            } memq?
+            } member-eq?
         ]
         [ successors>> first2 [ skip-empty-blocks ] bi@ eq? ]
     } 1&& ;
index 19c73eebd470397c2ec4a5de1069216edb59e691..3710f4974bf81fd2ea428232eed1a48193873c38 100644 (file)
@@ -40,8 +40,8 @@ SYMBOL: visited
 :: insert-basic-block ( froms to bb -- )
     bb froms V{ } like >>predecessors drop
     bb to 1vector >>successors drop
-    to predecessors>> [ dup froms memq? [ drop bb ] when ] change-each
-    froms [ successors>> [ dup to eq? [ drop bb ] when ] change-each ] each ;
+    to predecessors>> [ dup froms member-eq? [ drop bb ] when ] map! drop
+    froms [ successors>> [ dup to eq? [ drop bb ] when ] map! drop ] each ;
 
 : add-instructions ( bb quot -- )
     [ instructions>> building ] dip '[
index 0ac973a20650a4b46163eadeb8dbce323039de2c..d2e7c2ac864fd48a0ff07e0ffb3265ead010cdd1 100644 (file)
@@ -27,6 +27,9 @@ C: <reference> reference-expr
 M: reference-expr equal?
     over reference-expr? [ [ value>> ] bi@ eq? ] [ 2drop f ] if ;
 
+M: reference-expr hashcode*
+    nip value>> identity-hashcode ;
+
 : constant>vn ( constant -- vn ) <constant> expr>vn ; inline
 
 GENERIC: >expr ( insn -- expr )
@@ -42,7 +45,7 @@ M: ##load-constant >expr obj>> <constant> ;
 <<
 
 : input-values ( slot-specs -- slot-specs' )
-    [ type>> { use literal constant } memq? ] filter ;
+    [ type>> { use literal constant } member-eq? ] filter ;
 
 : expr-class ( insn -- expr )
     name>> "##" ?head drop "-expr" append create-class-in ;
index bc228cb3b45a96ff95f19f5f34837bbdab190539..4864a8bfb7c28f57379ac9931a8dc757b9a3f34e 100755 (executable)
@@ -37,7 +37,7 @@ M: insn rewrite drop f ;
     dup ##compare-imm-branch? [
         {
             [ cc>> cc/= eq? ]
-            [ src2>> \ f tag-number eq? ]
+            [ src2>> \ f type-number eq? ]
         } 1&&
     ] [ drop f ] if ; inline
 
@@ -110,8 +110,8 @@ M: ##compare-imm rewrite-tagged-comparison
 : rewrite-redundant-comparison? ( insn -- ? )
     {
         [ src1>> vreg>expr general-compare-expr? ]
-        [ src2>> \ f tag-number = ]
-        [ cc>> { cc= cc/= } memq? ]
+        [ src2>> \ f type-number = ]
+        [ cc>> { cc= cc/= } member-eq? ]
     } 1&& ; inline
 
 : rewrite-redundant-comparison ( insn -- insn' )
@@ -174,7 +174,7 @@ M: ##compare-imm-branch rewrite
     [ src1>> ] [ src2>> ] bi [ vreg>vn ] bi@ = ; inline
 
 : (rewrite-self-compare) ( insn -- ? )
-    cc>> { cc= cc<= cc>= } memq? ;
+    cc>> { cc= cc<= cc>= } member-eq? ;
 
 : rewrite-self-compare-branch ( insn -- insn' )
     (rewrite-self-compare) fold-branch ;
@@ -204,7 +204,7 @@ M: ##compare-branch rewrite
     [ dst>> ] dip
     {
         { t [ t \ ##load-constant new-insn ] }
-        { f [ \ f tag-number \ ##load-immediate new-insn ] }
+        { f [ \ f type-number \ ##load-immediate new-insn ] }
     } case ;
 
 : rewrite-self-compare ( insn -- insn' )
@@ -279,7 +279,7 @@ M: ##not rewrite
         ##sub-imm
         ##mul
         ##mul-imm
-    } memq? ;
+    } member-eq? ;
 
 : immediate? ( value op -- ? )
     arithmetic-op? [ immediate-arithmetic? ] [ immediate-bitwise? ] if ;
@@ -440,7 +440,7 @@ M: ##sar rewrite \ ##sar-imm rewrite-arithmetic ;
 :: rewrite-unbox-displaced-alien ( insn expr -- insns )
     [
         next-vreg :> temp
-        temp expr base>> vn>vreg expr base-class>> insn temp>> ##unbox-c-ptr
+        temp expr base>> vn>vreg expr base-class>> ##unbox-c-ptr
         insn dst>> temp expr displacement>> vn>vreg ##add
     ] { } make ;
 
@@ -515,3 +515,48 @@ M: ##scalar>vector rewrite
 M: ##xor-vector rewrite
     dup [ src1>> vreg>vn ] [ src2>> vreg>vn ] bi eq?
     [ [ dst>> ] [ rep>> ] bi \ ##zero-vector new-insn ] [ drop f ] if ;
+
+: vector-not? ( expr -- ? )
+    {
+        [ not-vector-expr? ]
+        [ {
+            [ xor-vector-expr? ]
+            [ [ src1>> ] [ src2>> ] bi [ vn>expr fill-vector-expr? ] either? ]
+        } 1&& ]
+    } 1|| ;
+
+GENERIC: vector-not-src ( expr -- vreg )
+M: not-vector-expr vector-not-src src>> vn>vreg ;
+M: xor-vector-expr vector-not-src
+    dup src1>> vn>expr fill-vector-expr? [ src2>> ] [ src1>> ] if vn>vreg ;
+
+M: ##and-vector rewrite 
+    {
+        { [ dup src1>> vreg>expr vector-not? ] [
+            {
+                [ dst>> ]
+                [ src1>> vreg>expr vector-not-src ]
+                [ src2>> ]
+                [ rep>> ]
+            } cleave \ ##andn-vector new-insn
+        ] }
+        { [ dup src2>> vreg>expr vector-not? ] [
+            {
+                [ dst>> ]
+                [ src2>> vreg>expr vector-not-src ]
+                [ src1>> ]
+                [ rep>> ]
+            } cleave \ ##andn-vector new-insn
+        ] }
+        [ drop f ]
+    } cond ;
+
+M: ##andn-vector rewrite
+    dup src1>> vreg>expr vector-not? [
+        {
+            [ dst>> ]
+            [ src1>> vreg>expr vector-not-src ]
+            [ src2>> ]
+            [ rep>> ]
+        } cleave \ ##and-vector new-insn
+    ] [ drop f ] if ;
index 733b8cc22a469df9b5bedd33501f2cc9076d8626..b404c4d4a42e1eed1de7e24b77dac07a67377a59 100644 (file)
@@ -82,7 +82,7 @@ IN: compiler.cfg.value-numbering.tests
         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{ ##compare-imm f 6 4 $[ \ f type-number ] cc/= }
         T{ ##replace f 6 D 0 }
     } value-numbering-step trim-temps
 ] unit-test
@@ -100,7 +100,7 @@ IN: compiler.cfg.value-numbering.tests
         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{ ##compare-imm f 6 4 $[ \ f type-number ] cc= }
         T{ ##replace f 6 D 0 }
     } value-numbering-step trim-temps
 ] unit-test
@@ -118,7 +118,7 @@ IN: compiler.cfg.value-numbering.tests
         T{ ##peek f 8 D 0 }
         T{ ##peek f 9 D -1 }
         T{ ##compare-float-unordered f 12 8 9 cc< }
-        T{ ##compare-imm f 14 12 5 cc= }
+        T{ ##compare-imm f 14 12 $[ \ f type-number ] cc= }
         T{ ##replace f 14 D 0 }
     } value-numbering-step trim-temps
 ] unit-test
@@ -135,7 +135,7 @@ IN: compiler.cfg.value-numbering.tests
         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/= }
+        T{ ##compare-imm-branch f 33 $[ \ f type-number ] cc/= }
     } value-numbering-step trim-temps
 ] unit-test
 
@@ -149,7 +149,7 @@ IN: compiler.cfg.value-numbering.tests
     {
         T{ ##peek f 1 D -1 }
         T{ ##test-vector f 2 1 f float-4-rep vcc-any }
-        T{ ##compare-imm-branch f 2 5 cc/= }
+        T{ ##compare-imm-branch f 2 $[ \ f type-number ] cc/= }
     } value-numbering-step trim-temps
 ] unit-test
 
@@ -1071,14 +1071,14 @@ cell 8 = [
 ! Branch folding
 [
     {
-        T{ ##load-immediate f 1 1 }
-        T{ ##load-immediate f 2 2 }
-        T{ ##load-immediate f 3 5 }
+        T{ ##load-immediate f 1 10 }
+        T{ ##load-immediate f 2 20 }
+        T{ ##load-immediate f 3 $[ \ f type-number ] }
     }
 ] [
     {
-        T{ ##load-immediate f 1 1 }
-        T{ ##load-immediate f 2 2 }
+        T{ ##load-immediate f 1 10 }
+        T{ ##load-immediate f 2 20 }
         T{ ##compare f 3 1 2 cc= }
     } value-numbering-step
 ] unit-test
@@ -1113,14 +1113,14 @@ cell 8 = [
 
 [
     {
-        T{ ##load-immediate f 1 1 }
-        T{ ##load-immediate f 2 2 }
-        T{ ##load-immediate f 3 5 }
+        T{ ##load-immediate f 1 10 }
+        T{ ##load-immediate f 2 20 }
+        T{ ##load-immediate f 3 $[ \ f type-number ] }
     }
 ] [
     {
-        T{ ##load-immediate f 1 1 }
-        T{ ##load-immediate f 2 2 }
+        T{ ##load-immediate f 1 10 }
+        T{ ##load-immediate f 2 20 }
         T{ ##compare f 3 2 1 cc< }
     } value-numbering-step
 ] unit-test
@@ -1128,7 +1128,7 @@ cell 8 = [
 [
     {
         T{ ##peek f 0 D 0 }
-        T{ ##load-immediate f 1 5 }
+        T{ ##load-immediate f 1 $[ \ f type-number ] }
     }
 ] [
     {
@@ -1152,7 +1152,7 @@ cell 8 = [
 [
     {
         T{ ##peek f 0 D 0 }
-        T{ ##load-immediate f 1 5 }
+        T{ ##load-immediate f 1 $[ \ f type-number ] }
     }
 ] [
     {
@@ -1176,7 +1176,7 @@ cell 8 = [
 [
     {
         T{ ##peek f 0 D 0 }
-        T{ ##load-immediate f 1 5 }
+        T{ ##load-immediate f 1 $[ \ f type-number ] }
     }
 ] [
     {
@@ -1281,6 +1281,128 @@ cell 8 = [
     } value-numbering-step
 ] unit-test
 
+! NOT x AND y => x ANDN y
+
+[
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##andn-vector f 5 0 1 float-4-rep }
+    }
+] [
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##and-vector  f 5 4 1 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+[
+    {
+        T{ ##not-vector  f 4 0 float-4-rep }
+        T{ ##andn-vector f 5 0 1 float-4-rep }
+    }
+] [
+    {
+        T{ ##not-vector  f 4 0 float-4-rep }
+        T{ ##and-vector  f 5 4 1 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+! x AND NOT y => y ANDN x
+
+[
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##andn-vector f 5 0 1 float-4-rep }
+    }
+] [
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##and-vector  f 5 1 4 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+[
+    {
+        T{ ##not-vector  f 4 0 float-4-rep }
+        T{ ##andn-vector f 5 0 1 float-4-rep }
+    }
+] [
+    {
+        T{ ##not-vector  f 4 0 float-4-rep }
+        T{ ##and-vector  f 5 1 4 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+! NOT x ANDN y => x AND y
+
+[
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##and-vector  f 5 0 1 float-4-rep }
+    }
+] [
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##andn-vector f 5 4 1 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+[
+    {
+        T{ ##not-vector  f 4 0 float-4-rep }
+        T{ ##and-vector  f 5 0 1 float-4-rep }
+    }
+] [
+    {
+        T{ ##not-vector  f 4 0 float-4-rep }
+        T{ ##andn-vector f 5 4 1 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+! AND <=> ANDN
+
+[
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##andn-vector f 5 0 1 float-4-rep }
+        T{ ##and-vector  f 6 0 2 float-4-rep }
+        T{ ##or-vector   f 7 5 6 float-4-rep }
+    }
+] [
+    {
+        T{ ##fill-vector f 3 float-4-rep }
+        T{ ##xor-vector  f 4 0 3 float-4-rep }
+        T{ ##and-vector  f 5 4 1 float-4-rep }
+        T{ ##andn-vector f 6 4 2 float-4-rep }
+        T{ ##or-vector   f 7 5 6 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+[
+    {
+        T{ ##not-vector  f 4 0   float-4-rep }
+        T{ ##andn-vector f 5 0 1 float-4-rep }
+        T{ ##and-vector  f 6 0 2 float-4-rep }
+        T{ ##or-vector   f 7 5 6 float-4-rep }
+    }
+] [
+    {
+        T{ ##not-vector  f 4 0   float-4-rep }
+        T{ ##and-vector  f 5 4 1 float-4-rep }
+        T{ ##andn-vector f 6 4 2 float-4-rep }
+        T{ ##or-vector   f 7 5 6 float-4-rep }
+    } value-numbering-step
+] unit-test
+
+! branch folding
+
 : test-branch-folding ( insns -- insns' n )
     <basic-block>
     [ V{ 0 1 } clone >>successors basic-block set value-numbering-step ] keep
@@ -1435,7 +1557,7 @@ cell 8 = [
     {
         T{ ##peek f 0 D 0 }
         T{ ##compare f 1 0 0 cc<= }
-        T{ ##compare-imm-branch f 1 5 cc/= }
+        T{ ##compare-imm-branch f 1 $[ \ f type-number ] cc/= }
     } test-branch-folding
 ] unit-test
 
@@ -1537,7 +1659,7 @@ V{
     T{ ##copy { dst 21 } { src 20 } { rep any-rep } }
     T{ ##compare-imm-branch
         { src1 21 }
-        { src2 5 }
+        { src2 $[ \ f type-number ] }
         { cc cc/= }
     }
 } 1 test-bb
index 0217055923d025ef2d4821cd5c3b802ba6193c60..523f7c6d1ced65c45e05869eb5f166e049af2fd2 100644 (file)
@@ -37,7 +37,7 @@ M: insn eliminate-write-barrier drop t ;
 : write-barriers-step ( bb -- )
     H{ } clone fresh-allocations set
     H{ } clone mutated-objects set
-    instructions>> [ eliminate-write-barrier ] filter-here ;
+    instructions>> [ eliminate-write-barrier ] filter! drop ;
 
 : eliminate-write-barriers ( cfg -- cfg' )
     dup [ write-barriers-step ] each-basic-block ;
index e8f3ca7d64e76047f52ec388f2c222fda1c9968b..15c4e14ac1a8e43168c995c288d4e657243bc1a0 100755 (executable)
@@ -181,14 +181,16 @@ CODEGEN: ##dot-vector %dot-vector
 CODEGEN: ##sqrt-vector %sqrt-vector
 CODEGEN: ##horizontal-add-vector %horizontal-add-vector
 CODEGEN: ##horizontal-sub-vector %horizontal-sub-vector
-CODEGEN: ##horizontal-shl-vector %horizontal-shl-vector
-CODEGEN: ##horizontal-shr-vector %horizontal-shr-vector
+CODEGEN: ##horizontal-shl-vector-imm %horizontal-shl-vector-imm
+CODEGEN: ##horizontal-shr-vector-imm %horizontal-shr-vector-imm
 CODEGEN: ##abs-vector %abs-vector
 CODEGEN: ##and-vector %and-vector
 CODEGEN: ##andn-vector %andn-vector
 CODEGEN: ##or-vector %or-vector
 CODEGEN: ##xor-vector %xor-vector
 CODEGEN: ##not-vector %not-vector
+CODEGEN: ##shl-vector-imm %shl-vector-imm
+CODEGEN: ##shr-vector-imm %shr-vector-imm
 CODEGEN: ##shl-vector %shl-vector
 CODEGEN: ##shr-vector %shr-vector
 CODEGEN: ##integer>scalar %integer>scalar
index 626ab678c0659cd95bcdbd8fbad682ae8d67448f..a772855ab6c843eb84209cec4f0a58d1ea13a3c3 100755 (executable)
@@ -5,13 +5,16 @@ continuations vocabs assocs dlists definitions math graphs generic
 generic.single combinators deques search-deques macros
 source-files.errors combinators.short-circuit
 
-stack-checker stack-checker.state stack-checker.inlining stack-checker.errors
+stack-checker stack-checker.dependencies stack-checker.inlining
+stack-checker.errors
 
 compiler.errors compiler.units compiler.utilities
 
 compiler.tree.builder
 compiler.tree.optimizer
 
+compiler.crossref
+
 compiler.cfg
 compiler.cfg.builder
 compiler.cfg.optimizer
@@ -55,28 +58,28 @@ SYMBOL: compiled
 
 GENERIC: no-compile? ( word -- ? )
 
-M: word no-compile? "no-compile" word-prop ;
-
 M: method-body no-compile? "method-generic" word-prop no-compile? ;
 
 M: predicate-engine-word no-compile? "owner-generic" word-prop no-compile? ;
 
+M: word no-compile?
+    { [ macro? ] [ "special" word-prop ] [ "no-compile" word-prop ] } 1|| ;
+
+GENERIC: combinator? ( word -- ? )
+
+M: method-body combinator? "method-generic" word-prop combinator? ;
+
+M: predicate-engine-word combinator? "owner-generic" word-prop combinator? ;
+
+M: word combinator? inline? ;
+
 : ignore-error? ( word error -- ? )
     #! Ignore some errors on inline combinators, macros, and special
     #! words such as 'call'.
-    [
-        {
-            [ macro? ]
-            [ inline? ]
-            [ no-compile? ]
-            [ "special" word-prop ]
-        } 1||
-    ] [
-        {
-            [ do-not-compile? ]
-            [ literal-expected? ]
-        } 1||
-    ] bi* and ;
+    {
+        [ drop no-compile? ]
+        [ [ combinator? ] [ unknown-macro-input? ] bi* and ]
+    } 2|| ;
 
 : finish ( word -- )
     #! Recompile callers if the word's stack effect changed, then
@@ -199,6 +202,14 @@ M: optimizing-compiler recompile ( words -- alist )
     ] with-scope
     "--- compile done" compiler-message ;
 
+M: optimizing-compiler to-recompile ( -- words )
+    changed-definitions get compiled-usages
+    changed-generics get compiled-generic-usages
+    append assoc-combine keys ;
+
+M: optimizing-compiler process-forgotten-words
+    [ delete-compiled-xref ] each ;
+
 : with-optimizer ( quot -- )
     [ optimizing-compiler compiler-impl ] dip with-variable ; inline
 
index a22d522809d0816dbf89c0611c27e4a680de01a0..19cdb6eebdb033b76fdf1686f12abb239f844e1d 100644 (file)
@@ -12,19 +12,18 @@ CONSTANT: deck-bits 18
 ! These constants must match vm/layouts.h
 : slot-offset ( slot tag -- n ) [ bootstrap-cells ] dip - ; inline
 
-: header-offset ( -- n ) 0 object tag-number slot-offset ; inline
-: float-offset ( -- n ) 8 float tag-number - ; inline
-: string-offset ( -- n ) 4 string tag-number slot-offset ; inline
-: string-aux-offset ( -- n ) 2 string tag-number slot-offset ; inline
-: profile-count-offset ( -- n ) 8 \ word tag-number slot-offset ; inline
-: byte-array-offset ( -- n ) 2 byte-array tag-number slot-offset ; inline
-: alien-offset ( -- n ) 3 alien tag-number slot-offset ; inline
-: underlying-alien-offset ( -- n ) 1 alien tag-number slot-offset ; inline
-: tuple-class-offset ( -- n ) 1 tuple tag-number slot-offset ; inline
-: word-xt-offset ( -- n ) 10 \ word tag-number slot-offset ; inline
-: quot-xt-offset ( -- n ) 4 quotation tag-number slot-offset ; inline
-: word-code-offset ( -- n ) 11 \ word tag-number slot-offset ; inline
-: array-start-offset ( -- n ) 2 array tag-number slot-offset ; inline
+: float-offset ( -- n ) 8 float type-number - ; inline
+: string-offset ( -- n ) 4 string type-number slot-offset ; inline
+: string-aux-offset ( -- n ) 2 string type-number slot-offset ; inline
+: profile-count-offset ( -- n ) 8 \ word type-number slot-offset ; inline
+: byte-array-offset ( -- n ) 16 byte-array type-number - ; inline
+: alien-offset ( -- n ) 4 alien type-number slot-offset ; inline
+: underlying-alien-offset ( -- n ) 1 alien type-number slot-offset ; inline
+: tuple-class-offset ( -- n ) 1 tuple type-number slot-offset ; inline
+: word-xt-offset ( -- n ) 10 \ word type-number slot-offset ; inline
+: quot-xt-offset ( -- n ) 4 quotation type-number slot-offset ; inline
+: word-code-offset ( -- n ) 11 \ word type-number slot-offset ; inline
+: array-start-offset ( -- n ) 2 array type-number slot-offset ; inline
 : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
 
 ! Relocation classes
diff --git a/basis/compiler/crossref/authors.txt b/basis/compiler/crossref/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/compiler/crossref/crossref.factor b/basis/compiler/crossref/crossref.factor
new file mode 100644 (file)
index 0000000..e6ef5cf
--- /dev/null
@@ -0,0 +1,68 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs classes.algebra compiler.units definitions graphs
+grouping kernel namespaces sequences words
+stack-checker.dependencies ;
+IN: compiler.crossref
+
+SYMBOL: compiled-crossref
+
+compiled-crossref [ H{ } clone ] initialize
+
+SYMBOL: compiled-generic-crossref
+
+compiled-generic-crossref [ H{ } clone ] initialize
+
+: compiled-usage ( word -- assoc )
+    compiled-crossref get at ;
+
+: (compiled-usages) ( word -- assoc )
+    #! If the word is not flushable anymore, we have to recompile
+    #! all words which flushable away a call (presumably when the
+    #! word was still flushable). If the word is flushable, we
+    #! don't have to recompile words that folded this away.
+    [ compiled-usage ]
+    [ "flushable" word-prop inlined-dependency flushed-dependency ? ] bi
+    [ dependency>= nip ] curry assoc-filter ;
+
+: compiled-usages ( seq -- assocs )
+    [ drop word? ] assoc-filter
+    [ [ drop (compiled-usages) ] { } assoc>map ] keep suffix ;
+
+: compiled-generic-usage ( word -- assoc )
+    compiled-generic-crossref get at ;
+
+: (compiled-generic-usages) ( generic class -- assoc )
+    [ compiled-generic-usage ] dip
+    [
+        2dup [ valid-class? ] both?
+        [ classes-intersect? ] [ 2drop f ] if nip
+    ] curry assoc-filter ;
+
+: compiled-generic-usages ( assoc -- assocs )
+    [ (compiled-generic-usages) ] { } assoc>map ;
+
+: (compiled-xref) ( word dependencies word-prop variable -- )
+    [ [ concat ] dip set-word-prop ] [ get add-vertex* ] bi-curry* 2bi ;
+
+: compiled-xref ( word dependencies generic-dependencies -- )
+    [ [ drop crossref? ] { } assoc-filter-as ] bi@
+    [ "compiled-uses" compiled-crossref (compiled-xref) ]
+    [ "compiled-generic-uses" compiled-generic-crossref (compiled-xref) ]
+    bi-curry* bi ;
+
+: (compiled-unxref) ( word word-prop variable -- )
+    [ [ [ dupd word-prop 2 <groups> ] dip get remove-vertex* ] 2curry ]
+    [ drop [ remove-word-prop ] curry ]
+    2bi bi ;
+
+: compiled-unxref ( word -- )
+    [ "compiled-uses" compiled-crossref (compiled-unxref) ]
+    [ "compiled-generic-uses" compiled-generic-crossref (compiled-unxref) ]
+    bi ;
+
+: delete-compiled-xref ( word -- )
+    [ compiled-unxref ]
+    [ compiled-crossref get delete-at ]
+    [ compiled-generic-crossref get delete-at ]
+    tri ;
index 1bf7a00c752b56fcdd9805a3330e2c8b263483b8..a2ce533afdaa195718c65ebe8402d20ee97cefd7 100755 (executable)
@@ -12,7 +12,7 @@ IN: compiler.tests.alien
 
 <<
 : libfactor-ffi-tests-path ( -- string )
-    "resource:" (normalize-path)
+    "resource:" absolute-path
     {
         { [ os winnt? ]  [ "libfactor-ffi-test.dll" ] }
         { [ os macosx? ] [ "libfactor-ffi-test.dylib" ] }
@@ -90,14 +90,14 @@ FUNCTION: TINY ffi_test_17 int x ;
 [ [ alien-indirect ] infer ] [ inference-error? ] must-fail-with
 
 : indirect-test-1 ( ptr -- result )
-    "int" { } "cdecl" alien-indirect ;
+    int { } "cdecl" alien-indirect ;
 
 { 1 1 } [ indirect-test-1 ] must-infer-as
 
 [ 3 ] [ &: ffi_test_1 indirect-test-1 ] unit-test
 
 : indirect-test-1' ( ptr -- )
-    "int" { } "cdecl" alien-indirect drop ;
+    int { } "cdecl" alien-indirect drop ;
 
 { 1 0 } [ indirect-test-1' ] must-infer-as
 
@@ -106,7 +106,7 @@ FUNCTION: TINY ffi_test_17 int x ;
 [ -1 indirect-test-1 ] must-fail
 
 : indirect-test-2 ( x y ptr -- result )
-    "int" { "int" "int" } "cdecl" alien-indirect gc ;
+    int { int int } "cdecl" alien-indirect gc ;
 
 { 3 1 } [ indirect-test-2 ] must-infer-as
 
@@ -115,20 +115,20 @@ FUNCTION: TINY ffi_test_17 int x ;
 unit-test
 
 : indirect-test-3 ( a b c d ptr -- result )
-    "int" { "int" "int" "int" "int" } "stdcall" alien-indirect
+    int { int int int int } "stdcall" alien-indirect
     gc ;
 
 [ f ] [ "f-stdcall" load-library f = ] unit-test
 [ "stdcall" ] [ "f-stdcall" library abi>> ] unit-test
 
 : ffi_test_18 ( w x y z -- int )
-    "int" "f-stdcall" "ffi_test_18" { "int" "int" "int" "int" }
+    int "f-stdcall" "ffi_test_18" { int int int int }
     alien-invoke gc ;
 
 [ 25 ] [ 2 3 4 5 ffi_test_18 ] unit-test
 
 : ffi_test_19 ( x y z -- BAR )
-    "BAR" "f-stdcall" "ffi_test_19" { "long" "long" "long" }
+    BAR "f-stdcall" "ffi_test_19" { long long long }
     alien-invoke gc ;
 
 [ 11 6 -7 ] [
@@ -157,17 +157,17 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
 ! Make sure XT doesn't get clobbered in stack frame
 
 : ffi_test_31 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result y )
-    "int"
+    int
     "f-cdecl" "ffi_test_31"
-    { "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" }
+    { int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int }
     alien-invoke gc 3 ;
 
 [ 861 3 ] [ 42 [ ] each ffi_test_31 ] unit-test
 
 : ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result )
-    "float"
+    float
     "f-cdecl" "ffi_test_31_point_5"
-    { "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" }
+    { float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float }
     alien-invoke ;
 
 [ 861.0 ] [ 42 [ >float ] each ffi_test_31_point_5 ] unit-test
@@ -312,21 +312,21 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 
 ! Test callbacks
 
-: callback-1 ( -- callback ) "void" { } "cdecl" [ ] alien-callback ;
+: callback-1 ( -- callback ) void { } "cdecl" [ ] alien-callback ;
 
 [ 0 1 ] [ [ callback-1 ] infer [ in>> ] [ out>> ] bi ] unit-test
 
 [ t ] [ callback-1 alien? ] unit-test
 
-: callback_test_1 ( ptr -- ) "void" { } "cdecl" alien-indirect ;
+: callback_test_1 ( ptr -- ) void { } "cdecl" alien-indirect ;
 
 [ ] [ callback-1 callback_test_1 ] unit-test
 
-: callback-2 ( -- callback ) "void" { } "cdecl" [ [ 5 throw ] ignore-errors ] alien-callback ;
+: callback-2 ( -- callback ) void { } "cdecl" [ [ 5 throw ] ignore-errors ] alien-callback ;
 
 [ ] [ callback-2 callback_test_1 ] unit-test
 
-: callback-3 ( -- callback ) "void" { } "cdecl" [ 5 "x" set ] alien-callback ;
+: callback-3 ( -- callback ) void { } "cdecl" [ 5 "x" set ] alien-callback ;
 
 [ t ] [
     namestack*
@@ -341,7 +341,7 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 ] unit-test
 
 : callback-4 ( -- callback )
-    "void" { } "cdecl" [ "Hello world" write ] alien-callback
+    void { } "cdecl" [ "Hello world" write ] alien-callback
     gc ;
 
 [ "Hello world" ] [
@@ -349,40 +349,40 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 ] unit-test
 
 : callback-5 ( -- callback )
-    "void" { } "cdecl" [ gc ] alien-callback ;
+    void { } "cdecl" [ gc ] alien-callback ;
 
 [ "testing" ] [
     "testing" callback-5 callback_test_1
 ] unit-test
 
 : callback-5b ( -- callback )
-    "void" { } "cdecl" [ compact-gc ] alien-callback ;
+    void { } "cdecl" [ compact-gc ] alien-callback ;
 
 [ "testing" ] [
     "testing" callback-5b callback_test_1
 ] unit-test
 
 : callback-6 ( -- callback )
-    "void" { } "cdecl" [ [ continue ] callcc0 ] alien-callback ;
+    void { } "cdecl" [ [ continue ] callcc0 ] alien-callback ;
 
 [ 1 2 3 ] [ callback-6 callback_test_1 1 2 3 ] unit-test
 
 : callback-7 ( -- callback )
-    "void" { } "cdecl" [ 1000000 sleep ] alien-callback ;
+    void { } "cdecl" [ 1000000 sleep ] alien-callback ;
 
 [ 1 2 3 ] [ callback-7 callback_test_1 1 2 3 ] unit-test
 
 [ f ] [ namespace global eq? ] unit-test
 
 : callback-8 ( -- callback )
-    "void" { } "cdecl" [
+    void { } "cdecl" [
         [ continue ] callcc0
     ] alien-callback ;
 
 [ ] [ callback-8 callback_test_1 ] unit-test
 
 : callback-9 ( -- callback )
-    "int" { "int" "int" "int" } "cdecl" [
+    int { int int int } "cdecl" [
         + + 1 +
     ] alien-callback ;
 
@@ -440,13 +440,13 @@ STRUCT: double-rect
     } cleave ;
 
 : double-rect-callback ( -- alien )
-    "void" { "void*" "void*" "double-rect" } "cdecl"
+    void { void* void* double-rect } "cdecl"
     [ "example" set-global 2drop ] alien-callback ;
 
 : double-rect-test ( arg -- arg' )
     f f rot
     double-rect-callback
-    "void" { "void*" "void*" "double-rect" } "cdecl" alien-indirect
+    void { void* void* double-rect } "cdecl" alien-indirect
     "example" get-global ;
 
 [ 1.0 2.0 3.0 4.0 ]
@@ -463,7 +463,7 @@ FUNCTION: test_struct_14 ffi_test_40 ( double x1, double x2 ) ;
 ] unit-test
 
 : callback-10 ( -- callback )
-    "test_struct_14" { "double" "double" } "cdecl"
+    test_struct_14 { double double } "cdecl"
     [
         test_struct_14 <struct>
             swap >>x2
@@ -471,7 +471,7 @@ FUNCTION: test_struct_14 ffi_test_40 ( double x1, double x2 ) ;
     ] alien-callback ;
 
 : callback-10-test ( x1 x2 callback -- result )
-    "test_struct_14" { "double" "double" } "cdecl" alien-indirect ;
+    test_struct_14 { double double } "cdecl" alien-indirect ;
 
 [ 1.0 2.0 ] [
     1.0 2.0 callback-10 callback-10-test
@@ -486,7 +486,7 @@ FUNCTION: test-struct-12 ffi_test_41 ( int a, double x ) ;
 ] unit-test
 
 : callback-11 ( -- callback )
-    "test-struct-12" { "int" "double" } "cdecl"
+    test-struct-12 { int double } "cdecl"
     [
         test-struct-12 <struct>
             swap >>x
@@ -494,7 +494,7 @@ FUNCTION: test-struct-12 ffi_test_41 ( int a, double x ) ;
     ] alien-callback ;
 
 : callback-11-test ( x1 x2 callback -- result )
-    "test-struct-12" { "int" "double" } "cdecl" alien-indirect ;
+    test-struct-12 { int double } "cdecl" alien-indirect ;
 
 [ 1 2.0 ] [
     1 2.0 callback-11 callback-11-test
@@ -510,7 +510,7 @@ FUNCTION: test_struct_15 ffi_test_42 ( float x, float y ) ;
 [ 1.0 2.0 ] [ 1.0 2.0 ffi_test_42 [ x>> ] [ y>> ] bi ] unit-test
 
 : callback-12 ( -- callback )
-    "test_struct_15" { "float" "float" } "cdecl"
+    test_struct_15 { float float } "cdecl"
     [
         test_struct_15 <struct>
             swap >>y
@@ -518,7 +518,7 @@ FUNCTION: test_struct_15 ffi_test_42 ( float x, float y ) ;
     ] alien-callback ;
 
 : callback-12-test ( x1 x2 callback -- result )
-    "test_struct_15" { "float" "float" } "cdecl" alien-indirect ;
+    test_struct_15 { float float } "cdecl" alien-indirect ;
 
 [ 1.0 2.0 ] [
     1.0 2.0 callback-12 callback-12-test [ x>> ] [ y>> ] bi
@@ -533,7 +533,7 @@ FUNCTION: test_struct_16 ffi_test_43 ( float x, int a ) ;
 [ 1.0 2 ] [ 1.0 2 ffi_test_43 [ x>> ] [ a>> ] bi ] unit-test
 
 : callback-13 ( -- callback )
-    "test_struct_16" { "float" "int" } "cdecl"
+    test_struct_16 { float int } "cdecl"
     [
         test_struct_16 <struct>
             swap >>a
@@ -541,7 +541,7 @@ FUNCTION: test_struct_16 ffi_test_43 ( float x, int a ) ;
     ] alien-callback ;
 
 : callback-13-test ( x1 x2 callback -- result )
-    "test_struct_16" { "float" "int" } "cdecl" alien-indirect ;
+    test_struct_16 { float int } "cdecl" alien-indirect ;
 
 [ 1.0 2 ] [
     1.0 2 callback-13 callback-13-test
@@ -588,5 +588,4 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ;
 ! Regression: calling an undefined function would raise a protection fault
 FUNCTION: void this_does_not_exist ( ) ;
 
-[ this_does_not_exist ] [ { "kernel-error" 10 f f } = ] must-fail-with
-
+[ this_does_not_exist ] [ { "kernel-error" 9 f f } = ] must-fail-with
index 141fc24309c5f25170b9f1ac26066a172fbf3770..eba65805746b39c2b1466639b1935ff4013f8c4a 100644 (file)
@@ -175,20 +175,6 @@ TUPLE: my-tuple ;
     ] compile-call
 ] unit-test
 
-[ 1 t ] [
-    B{ 1 2 3 4 } [
-        { c-ptr } declare
-        [ 0 alien-unsigned-1 ] keep hi-tag
-    ] compile-call byte-array type-number =
-] unit-test
-
-[ t ] [
-    B{ 1 2 3 4 } [
-        { c-ptr } declare
-        0 alien-cell hi-tag
-    ] compile-call alien type-number =
-] unit-test
-
 [ 2 1 ] [
     2 1
     [ 2dup fixnum< [ [ die ] dip ] when ] compile-call
@@ -270,8 +256,8 @@ TUPLE: id obj ;
     { float } declare dup 0 =
     [ drop 1 ] [
         dup 0 >=
-        [ 2 "double" "libm" "pow" { "double" "double" } alien-invoke ]
-        [ -0.5 "double" "libm" "pow" { "double" "double" } alien-invoke ]
+        [ 2 double "libm" "pow" { double double } alien-invoke ]
+        [ -0.5 double "libm" "pow" { double double } alien-invoke ]
         if
     ] if ;
 
@@ -475,4 +461,4 @@ TUPLE: myseq { underlying1 byte-array read-only } { underlying2 byte-array read-
 [ 2 0 ] [
     1 1
     [ [ HEX: f bitand ] bi@ [ shift ] [ drop -3 shift ] 2bi ] compile-call
-] unit-test
\ No newline at end of file
+] unit-test
old mode 100644 (file)
new mode 100755 (executable)
index 75cfc1d..7fe5e2b
@@ -21,7 +21,6 @@ IN: compiler.tests.intrinsics
 [ 2 1 3 ] [ 1 2 3 [ swapd ] compile-call ] unit-test
 [ 2 ] [ 1 2 [ nip ] compile-call ] unit-test
 [ 3 ] [ 1 2 3 [ 2nip ] compile-call ] unit-test
-[ 2 1 2 ] [ 1 2 [ tuck ] compile-call ] unit-test
 [ 1 2 1 ] [ 1 2 [ over ] compile-call ] unit-test
 [ 1 2 3 1 ] [ 1 2 3 [ pick ] compile-call ] unit-test
 [ 2 1 ] [ 1 2 [ swap ] compile-call ] unit-test
@@ -244,20 +243,20 @@ IN: compiler.tests.intrinsics
 [ -4294967296 ] [ -1 [ 16 fixnum-shift 16 fixnum-shift ] compile-call ] unit-test
 
 [ HEX: 10000000 ] [ HEX: 1000000 HEX: 10 [ fixnum* ] compile-call ] unit-test
-[ HEX: 10000000 ] [ HEX: -10000000 >fixnum [ 0 swap fixnum- ] compile-call ] unit-test
-[ HEX: 10000000 ] [ HEX: -fffffff >fixnum [ 1 swap fixnum- ] compile-call ] unit-test
+[ HEX: 8000000 ] [ HEX: -8000000 >fixnum [ 0 swap fixnum- ] compile-call ] unit-test
+[ HEX: 8000000 ] [ HEX: -7ffffff >fixnum [ 1 swap fixnum- ] compile-call ] unit-test
 
-[ t ] [ 1 27 fixnum-shift dup [ fixnum+ ] compile-call 1 28 fixnum-shift = ] unit-test
-[ -268435457 ] [ 1 28 shift neg >fixnum [ -1 fixnum+ ] compile-call ] unit-test
+[ t ] [ 1 26 fixnum-shift dup [ fixnum+ ] compile-call 1 27 fixnum-shift = ] unit-test
+[ -134217729 ] [ 1 27 shift neg >fixnum [ -1 fixnum+ ] compile-call ] unit-test
 
 [ t ] [ 1 20 shift 1 20 shift [ fixnum* ] compile-call 1 40 shift = ] unit-test
 [ t ] [ 1 20 shift neg 1 20 shift [ fixnum* ] compile-call 1 40 shift neg = ] unit-test
 [ t ] [ 1 20 shift neg 1 20 shift neg [ fixnum* ] compile-call 1 40 shift = ] unit-test
 [ -351382792 ] [ -43922849 [ 3 fixnum-shift ] compile-call ] unit-test
 
-[ 268435456 ] [ -268435456 >fixnum -1 [ fixnum/i ] compile-call ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 [ fixnum/i ] compile-call ] unit-test
 
-[ 268435456 0 ] [ -268435456 >fixnum -1 [ fixnum/mod ] compile-call ] unit-test
+[ 134217728 0 ] [ -134217728 >fixnum -1 [ fixnum/mod ] compile-call ] unit-test
 
 [ t ] [ f [ f eq? ] compile-call ] unit-test
 
@@ -285,8 +284,8 @@ cell 8 = [
 
 ! 64-bit overflow
 cell 8 = [
-    [ t ] [ 1 59 fixnum-shift dup [ fixnum+ ] compile-call 1 60 fixnum-shift = ] unit-test
-    [ -1152921504606846977 ] [ 1 60 shift neg >fixnum [ -1 fixnum+ ] compile-call ] unit-test
+    [ t ] [ 1 58 fixnum-shift dup [ fixnum+ ] compile-call 1 59 fixnum-shift = ] unit-test
+    [ -576460752303423489 ] [ 1 59 shift neg >fixnum [ -1 fixnum+ ] compile-call ] unit-test
     
     [ t ] [ 1 40 shift 1 40 shift [ fixnum* ] compile-call 1 80 shift = ] unit-test
     [ t ] [ 1 40 shift neg 1 40 shift [ fixnum* ] compile-call 1 80 shift neg = ] unit-test
@@ -301,9 +300,9 @@ cell 8 = [
     [ -18446744073709551616 ] [ -1 [ 64 fixnum-shift ] compile-call ] unit-test
     [ -18446744073709551616 ] [ -1 [ 32 fixnum-shift 32 fixnum-shift ] compile-call ] unit-test
     
-    [ 1152921504606846976 ] [ -1152921504606846976 >fixnum -1 [ fixnum/i ] compile-call ] unit-test
+    [ 576460752303423488 ] [ -576460752303423488 >fixnum -1 [ fixnum/i ] compile-call ] unit-test
 
-    [ 1152921504606846976 0 ] [ -1152921504606846976 >fixnum -1 [ fixnum/mod ] compile-call ] unit-test
+    [ 576460752303423488 0 ] [ -576460752303423488 >fixnum -1 [ fixnum/mod ] compile-call ] unit-test
 
     [ -268435457 ] [ 28 2^ [ fixnum-bitnot ] compile-call ] unit-test
 ] when
@@ -311,12 +310,14 @@ cell 8 = [
 ! Some randomized tests
 : compiled-fixnum* ( a b -- c ) fixnum* ;
 
+ERROR: bug-in-fixnum* x y a b ;
+
 [ ] [
     10000 [ 
-        32 random-bits >fixnum 32 random-bits >fixnum
-        2dup
-        [ fixnum* ] 2keep compiled-fixnum* =
-        [ 2drop ] [ "Oops" throw ] if
+        32 random-bits >fixnum
+        32 random-bits >fixnum
+        2dup [ fixnum* ] [ compiled-fixnum* ] 2bi 2dup =
+        [ 2drop 2drop ] [ bug-in-fixnum* ] if
     ] times
 ] unit-test
 
@@ -419,7 +420,7 @@ cell 8 = [
 "b" get [
     [ 3 ] [ "b" get 2 [ alien-unsigned-1 ] compile-call ] unit-test
     [ 3 ] [ "b" get [ { alien } declare 2 alien-unsigned-1 ] compile-call ] unit-test
-    [ 3 ] [ "b" get 2 [ { simple-alien fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
+    [ 3 ] [ "b" get 2 [ { alien fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
     [ 3 ] [ "b" get 2 [ { c-ptr fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
 
     [ ] [ "b" get free ] unit-test
@@ -584,16 +585,16 @@ TUPLE: alien-accessor-regression { b byte-array } { i fixnum } ;
     swap [
         { tuple } declare 1 slot
     ] [
-        0 slot
+        1 slot
     ] if ;
 
-[ t ] [ f B{ } mutable-value-bug-1 byte-array type-number = ] unit-test
+[ 0 ] [ f { } mutable-value-bug-1 ] unit-test
 
 : mutable-value-bug-2 ( a b -- c )
     swap [
-        0 slot
+        1 slot
     ] [
         { tuple } declare 1 slot
     ] if ;
 
-[ t ] [ t B{ } mutable-value-bug-2 byte-array type-number = ] unit-test
+[ 0 ] [ t { } mutable-value-bug-2 ] unit-test
index 14c470d63f9029479cc9b5b167556042a994a6ea..b6b8e1c0313b66c630d4d25bba727af22f90af8c 100644 (file)
@@ -36,7 +36,7 @@ IN: compiler.tests.low-level-ir
 ! loading immediates
 [ f ] [
     V{
-        T{ ##load-immediate f 0 5 }
+        T{ ##load-immediate f 0 $[ \ f type-number ] }
     } compile-test-bb
 ] unit-test
 
@@ -50,7 +50,7 @@ IN: compiler.tests.low-level-ir
 ! one of the sources
 [ t ] [
     V{
-        T{ ##load-immediate f 1 $[ 2 cell log2 shift array tag-number - ] }
+        T{ ##load-immediate f 1 $[ 2 cell log2 shift array type-number - ] }
         T{ ##load-reference f 0 { t f t } }
         T{ ##slot f 0 0 1 }
     } compile-test-bb
@@ -59,13 +59,13 @@ IN: compiler.tests.low-level-ir
 [ t ] [
     V{
         T{ ##load-reference f 0 { t f t } }
-        T{ ##slot-imm f 0 0 2 $[ array tag-number ] }
+        T{ ##slot-imm f 0 0 2 $[ array type-number ] }
     } compile-test-bb
 ] unit-test
 
 [ t ] [
     V{
-        T{ ##load-immediate f 1 $[ 2 cell log2 shift array tag-number - ] }
+        T{ ##load-immediate f 1 $[ 2 cell log2 shift array type-number - ] }
         T{ ##load-reference f 0 { t f t } }
         T{ ##set-slot f 0 0 1 }
     } compile-test-bb
@@ -75,12 +75,12 @@ IN: compiler.tests.low-level-ir
 [ t ] [
     V{
         T{ ##load-reference f 0 { t f t } }
-        T{ ##set-slot-imm f 0 0 2 $[ array tag-number ] }
+        T{ ##set-slot-imm f 0 0 2 $[ array type-number ] }
     } compile-test-bb
     dup first eq?
 ] unit-test
 
-[ 8 ] [
+[ 4 ] [
     V{
         T{ ##load-immediate f 0 4 }
         T{ ##shl f 0 0 0 }
@@ -90,16 +90,16 @@ IN: compiler.tests.low-level-ir
 [ 4 ] [
     V{
         T{ ##load-immediate f 0 4 }
-        T{ ##shl-imm f 0 0 3 }
+        T{ ##shl-imm f 0 0 4 }
     } compile-test-bb
 ] unit-test
 
 [ 31 ] [
     V{
         T{ ##load-reference f 1 B{ 31 67 52 } }
-        T{ ##unbox-any-c-ptr f 0 1 }
+        T{ ##unbox-any-c-ptr f 0 1 }
         T{ ##alien-unsigned-1 f 0 0 0 }
-        T{ ##shl-imm f 0 0 3 }
+        T{ ##shl-imm f 0 0 4 }
     } compile-test-bb
 ] unit-test
 
@@ -108,13 +108,13 @@ IN: compiler.tests.low-level-ir
         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 }
+        T{ ##shl-imm f 0 0 4 }
     } compile-test-bb
 ] unit-test
 
 [ 1 ] [
     V{
-        T{ ##load-immediate f 0 16 }
-        T{ ##add-imm f 0 0 -8 }
+        T{ ##load-immediate f 0 32 }
+        T{ ##add-imm f 0 0 -16 }
     } compile-test-bb
 ] unit-test
index 0c9b1817c8cfc1c80458507aacb3e65f27fe4eb8..0831d6e8ddc91b7aeb2d7c768b514237123cf5af 100644 (file)
@@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private
 quotations classes classes.algebra classes.tuple.private
 continuations growable namespaces hints alien.accessors
 compiler.tree.builder compiler.tree.optimizer sequences.deep
-compiler definitions generic.single ;
+compiler definitions generic.single shuffle ;
 IN: compiler.tests.optimizer
 
 GENERIC: xyz ( obj -- obj )
@@ -202,7 +202,7 @@ USE: binary-search.private
     dup length 1 <= [
         from>>
     ] [
-        [ midpoint swap call ] 3keep roll dup zero?
+        [ midpoint swap call ] 3keep [ rot ] dip swap dup zero?
         [ drop dup from>> swap midpoint@ + ]
         [ drop dup midpoint@ head-slice old-binsearch ] if
     ] if ; inline recursive
@@ -443,5 +443,7 @@ M: object bad-dispatch-position-test* ;
 [ -1 ] [ 3 4 0 dispatch-branch-problem ] unit-test
 [ 12 ] [ 3 4 1 dispatch-branch-problem ] unit-test
 
+[ 1024 bignum ] [ 10 [ 1 >bignum swap >fixnum shift ] compile-call dup class ] unit-test
+
 ! Not sure if I want to fix this...
-! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with
\ No newline at end of file
+! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with
index 67added49d9b53647545b01332539ebf65a8bf3f..913111b8ea34586a677bbe908770eb23e0826608 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors compiler compiler.units tools.test math parser
 kernel sequences sequences.private classes.mixin generic
-definitions arrays words assocs eval ;
+definitions arrays words assocs eval grouping ;
 IN: compiler.tests.redefine3
 
 GENERIC: sheeple ( obj -- x )
@@ -13,20 +13,23 @@ M: empty-mixin sheeple drop "wake up" ; inline
 
 : sheeple-test ( -- string ) { } sheeple ;
 
+: compiled-use? ( key word -- ? )
+    "compiled-uses" word-prop 2 <groups> key? ;
+
 [ "sheeple" ] [ sheeple-test ] unit-test
 [ t ] [ \ sheeple-test optimized? ] unit-test
-[ t ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
-[ f ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
+[ t ] [ object \ sheeple method \ sheeple-test compiled-use? ] unit-test
+[ f ] [ empty-mixin \ sheeple method \ sheeple-test compiled-use? ] unit-test
 
 [ ] [ "IN: compiler.tests.redefine3 USE: arrays INSTANCE: array empty-mixin" eval( -- ) ] unit-test
 
 [ "wake up" ] [ sheeple-test ] unit-test
-[ f ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
-[ t ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
+[ f ] [ object \ sheeple method \ sheeple-test compiled-use? ] unit-test
+[ t ] [ empty-mixin \ sheeple method \ sheeple-test compiled-use? ] unit-test
 
 [ ] [ [ array empty-mixin remove-mixin-instance ] with-compilation-unit ] unit-test
 
 [ "sheeple" ] [ sheeple-test ] unit-test
 [ t ] [ \ sheeple-test optimized? ] unit-test
-[ t ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
-[ f ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
+[ t ] [ object \ sheeple method \ sheeple-test compiled-use? ] unit-test
+[ f ] [ empty-mixin \ sheeple method \ sheeple-test compiled-use? ] unit-test
index da021412fe8e0f8b78750985aa43c1e820a403e6..a86d5b8c520d98977b31f5f44d4a26288001011a 100644 (file)
@@ -1,6 +1,7 @@
 USING: compiler compiler.units tools.test kernel kernel.private
 sequences.private math.private math combinators strings alien
-arrays memory vocabs parser eval ;
+arrays memory vocabs parser eval quotations compiler.errors
+definitions ;
 IN: compiler.tests.simple
 
 ! Test empty word
@@ -238,3 +239,13 @@ M: f single-combination-test-2 single-combination-test-4 ;
         "USING: prettyprint words accessors ; IN: compiler.tests.foo : (recursive) ( -- ) (recursive) (recursive) ; inline recursive : recursive ( -- ) (recursive) ; \\ (recursive) optimized?" eval( -- obj )
     ] unit-test
 ] times
+
+! This should not compile
+GENERIC: bad-effect-test ( a -- )
+M: quotation bad-effect-test call ; inline
+: bad-effect-test* ( -- ) [ 1 2 3 ] bad-effect-test ;
+
+[ bad-effect-test* ] [ not-compiled? ] must-fail-with
+
+! Don't want compiler error to stick around
+[ ] [ [ M\ quotation bad-effect-test forget ] with-compilation-unit ] unit-test
index 20a5cc867c8bbde4f77a13d6ad28c3b05e6ef73b..40aa1bb336ad3d462c451b2013fe8b458aea68fd 100755 (executable)
@@ -19,7 +19,7 @@ IN: compiler.tests.stack-trace
 
 : bleh ( seq -- seq' ) [ 3 + ] map [ 0 > ] filter ;
 
-: stack-trace-any? ( word -- ? ) symbolic-stack-trace memq? ;
+: stack-trace-any? ( word -- ? ) symbolic-stack-trace member-eq? ;
 
 [ t ] [
     [ { 1 "hi" } bleh ] ignore-errors \ + stack-trace-any?
index e4523deb9ff7515575f0223e8e4afdac85f87582..8eb66fde1f82c9ed5b2bbf67e795e169df0d2be1 100644 (file)
@@ -39,7 +39,7 @@ M: word (build-tree)
     [
         <recursive-state> recursive-state set
         V{ } clone stack-visitor set
-        [ [ >vector \ meta-d set ] [ length d-in set ] bi ]
+        [ [ >vector \ meta-d set ] [ length input-count set ] bi ]
         [ (build-tree) ]
         bi*
     ] with-infer nip ;
index 02e7409c24aa3fd02da25f84977dd8910ed73ba8..db960863717aa28fffa3234d874ec2860f3da710 100755 (executable)
@@ -491,7 +491,7 @@ cell-bits 32 = [
 ] unit-test
 
 [ t ] [
-    [ { array } declare 2 <groups> [ . . ] assoc-each ]
+    [ { array } declare 2 <sliced-groups> [ . . ] assoc-each ]
     \ nth-unsafe inlined?
 ] unit-test
 
index 1cd9589065334bd27e5701829a9d545a7a1ffbee..ec819d0eacaee737d47cb5243b5947d3f95508d0 100644 (file)
@@ -3,7 +3,7 @@
 USING: kernel accessors sequences combinators fry
 classes.algebra namespaces assocs words math math.private
 math.partial-dispatch math.intervals classes classes.tuple
-classes.tuple.private layouts definitions stack-checker.state
+classes.tuple.private layouts definitions stack-checker.dependencies
 stack-checker.branches
 compiler.utilities
 compiler.tree
@@ -20,7 +20,7 @@ IN: compiler.tree.cleanup
 GENERIC: delete-node ( node -- )
 
 M: #call-recursive delete-node
-    dup label>> calls>> [ node>> eq? not ] with filter-here ;
+    dup label>> calls>> [ node>> eq? not ] with filter! drop ;
 
 M: #return-recursive delete-node
     label>> f >>return drop ;
index ed4df91eec0fd4304b51985f6afd22d72eaffebe..d859096e1db7c90793c4930e63cbc454b7769377 100644 (file)
@@ -6,7 +6,7 @@ compiler.tree.tuple-unboxing compiler.tree.debugger
 compiler.tree.recursive compiler.tree.normalization
 compiler.tree.checker tools.test kernel math stack-checker.state
 accessors combinators io prettyprint words sequences.deep
-sequences.private arrays classes kernel.private ;
+sequences.private arrays classes kernel.private shuffle ;
 IN: compiler.tree.dead-code.tests
 
 : count-live-values ( quot -- n )
index b0ab864c80f2cb2bf3ac34c7e672c319ee7634a7..482d370947bb626a601c217fc42689edd9ee5f8b 100644 (file)
@@ -39,14 +39,13 @@ M: #enter-recursive remove-dead-code*
     2bi ;
 
 :: (drop-call-recursive-outputs) ( inputs outputs -- #shuffle )
-    [let* | new-live-outputs [ inputs outputs filter-corresponding make-values ]
-            live-outputs [ outputs filter-live ] |
-        new-live-outputs
-        live-outputs
-        live-outputs
-        new-live-outputs
-        drop-values
-    ] ;
+    inputs outputs filter-corresponding make-values :> new-live-outputs
+    outputs filter-live :> live-outputs
+    new-live-outputs
+    live-outputs
+    live-outputs
+    new-live-outputs
+    drop-values ;
 
 : drop-call-recursive-outputs ( node -- #shuffle )
     dup [ label>> return>> in-d>> ] [ out-d>> ] bi
@@ -60,22 +59,20 @@ M: #call-recursive remove-dead-code*
     tri 3array ;
 
 :: drop-recursive-inputs ( node -- shuffle )
-    [let* | shuffle [ node [ in-d>> ] [ label>> enter-out>> ] bi drop-dead-inputs ]
-            new-outputs [ shuffle out-d>> ] |
-        node new-outputs
-        [ [ label>> enter-recursive>> ] dip >>in-d drop ] [ >>in-d drop ] 2bi
-        shuffle
-    ] ;
+    node [ in-d>> ] [ label>> enter-out>> ] bi drop-dead-inputs :> shuffle
+    shuffle out-d>> :> new-outputs
+    node new-outputs
+    [ [ label>> enter-recursive>> ] dip >>in-d drop ] [ >>in-d drop ] 2bi
+    shuffle ;
 
 :: drop-recursive-outputs ( node -- shuffle )
-    [let* | return [ node label>> return>> ]
-            new-inputs [ return in-d>> filter-live ]
-            new-outputs [ return [ in-d>> ] [ out-d>> ] bi filter-corresponding ] |
-        return
-        [ new-inputs >>in-d new-outputs >>out-d drop ]
-        [ drop-dead-outputs ]
-        bi
-    ] ;
+    node label>> return>> :> return
+    return in-d>> filter-live :> new-inputs
+    return [ in-d>> ] [ out-d>> ] bi filter-corresponding :> new-outputs
+    return
+    [ new-inputs >>in-d new-outputs >>out-d drop ]
+    [ drop-dead-outputs ]
+    bi ;
 
 M: #recursive remove-dead-code* ( node -- nodes )
     [ drop-recursive-inputs ]
index 5134a67a5bb53edf0cce2f3d010ee1a7fa6cf9cf..67c5cfdc78a55352390da3826bfa41345f29b0ce 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors words assocs sequences arrays namespaces
 fry locals definitions classes classes.algebra generic
-stack-checker.state
+stack-checker.dependencies
 stack-checker.backend
 compiler.tree
 compiler.tree.propagation.info
@@ -71,14 +71,13 @@ M: #alien-indirect compute-live-values* nip look-at-inputs ;
     filter-corresponding zip #data-shuffle ; inline
 
 :: drop-dead-values ( outputs -- #shuffle )
-    [let* | new-outputs [ outputs make-values ]
-            live-outputs [ outputs filter-live ] |
-        new-outputs
-        live-outputs
-        outputs
-        new-outputs
-        drop-values
-    ] ;
+    outputs make-values :> new-outputs
+    outputs filter-live :> live-outputs
+    new-outputs
+    live-outputs
+    outputs
+    new-outputs
+    drop-values ;
 
 : drop-dead-outputs ( node -- #shuffle )
     dup out-d>> drop-dead-values [ in-d>> >>out-d drop ] keep ;
index 4bf4cf88f02bb4efb92c0cd341d9977c12dff984..63f145d752a24aaf53474647f9de6e7c22a2e4f4 100644 (file)
@@ -51,7 +51,6 @@ MATCH-VARS: ?a ?b ?c ;
         { { { ?b ?a } { ?a ?b } } [ swap ] }
         { { { ?b ?a ?c } { ?a ?b ?c } } [ swapd ] }
         { { { ?a ?b } { ?a ?a ?b } } [ dupd ] }
-        { { { ?a ?b } { ?b ?a ?b } } [ tuck ] }
         { { { ?a ?b ?c } { ?a ?b ?c ?a } } [ pick ] }
         { { { ?a ?b ?c } { ?c ?a ?b } } [ -rot ] }
         { { { ?a ?b ?c } { ?b ?c ?a } } [ rot ] }
index 8ca80ccbae1ed74a44a607181dcce98a9ff7417a..ece2ed80f3d4af7c1622f04d0803e28d2e243482 100644 (file)
@@ -75,7 +75,7 @@ M: #push compute-modular-candidates*
     0 cell-bits tag-bits get - 1 - [a,b] interval-subset? ;
 
 : modular-word? ( #call -- ? )
-    dup word>> { shift fixnum-shift bignum-shift } memq?
+    dup word>> { shift fixnum-shift bignum-shift } member-eq?
     [ node-input-infos second interval>> small-shift? ]
     [ word>> "modular-arithmetic" word-prop ]
     if ;
@@ -178,10 +178,10 @@ MEMO: fixnum-coercion ( flags -- nodes )
     ] when ;
 
 : like->fixnum? ( #call -- ? )
-    word>> { >fixnum bignum>fixnum float>fixnum } memq? ;
+    word>> { >fixnum bignum>fixnum float>fixnum } member-eq? ;
 
 : like->integer? ( #call -- ? )
-    word>> { >integer >bignum fixnum>bignum } memq? ;
+    word>> { >integer >bignum fixnum>bignum } member-eq? ;
 
 M: #call optimize-modular-arithmetic*
     {
index 0d837d82aed598f386b8e8a49f299afea0c791fa..28f34cb425c5ccc9118832b01a7a984900876b0b 100755 (executable)
@@ -97,7 +97,7 @@ M: #phi propagate-before ( #phi -- )
     constraints get last update-constraints ;
 
 : branch-phi-constraints ( output values booleans -- )
-     {
+    {
         {
             { { t } { f } }
             [
@@ -130,6 +130,22 @@ M: #phi propagate-before ( #phi -- )
                 swap t-->
             ]
         }
+        {
+            { { t f } { t } }
+            [
+                first =f
+                condition-value get =t /\
+                swap f-->
+            ]
+        }
+        {
+            { { t } { t f } }
+            [
+                second =f
+                condition-value get =f /\
+                swap f-->
+            ]
+        }
         {
             { { t f } { } }
             [
index 79a9f69de5c2a1566f87f4811c8699db77975263..4a543fb87a1e427bffbdff157faffea8e8831a28 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: compiler.tree.propagation.call-effect tools.test fry math effects kernel
-compiler.tree.builder compiler.tree.optimizer compiler.tree.debugger sequences ;
+compiler.tree.builder compiler.tree.optimizer compiler.tree.debugger sequences
+eval combinators ;
 IN: compiler.tree.propagation.call-effect.tests
 
 [ t ] [ \ + (( a b -- c )) execute-effect-unsafe? ] unit-test
@@ -58,4 +59,23 @@ IN: compiler.tree.propagation.call-effect.tests
 ! [ boa ] by itself doesn't infer
 TUPLE: a-tuple x ;
 
-[ V{ a-tuple } ] [ [ a-tuple '[ _ boa ] call( x -- tuple ) ] final-classes ] unit-test
\ No newline at end of file
+[ V{ a-tuple } ] [ [ a-tuple '[ _ boa ] call( x -- tuple ) ] final-classes ] unit-test
+
+! See if redefinitions are handled correctly
+: call(-redefine-test ( a -- b ) 1 + ;
+
+: test-quotatation ( -- quot ) [ call(-redefine-test ] ;
+
+[ t ] [ test-quotatation cached-effect (( a -- b )) effect<= ] unit-test
+
+[ ] [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a b -- c ) + ;" eval( -- ) ] unit-test
+
+[ t ] [ test-quotatation cached-effect (( a b -- c )) effect<= ] unit-test
+
+: inline-cache-invalidation-test ( a b c -- c ) call( a b -- c ) ;
+
+[ 4 ] [ 1 3 test-quotatation inline-cache-invalidation-test ] unit-test
+
+[ ] [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a -- c ) 1 + ;" eval( -- ) ] unit-test
+
+[ 1 3 test-quotatation inline-cache-invalidation-test ] [ T{ wrong-values f (( a b -- c )) } = ] must-fail-with
index 614ceeb59770bf5eb74c0f8b75f41a74b68312da..ff4886d1c795ad0ecc2fb7d7dbe0d246f9474871 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators combinators.private effects fry
 kernel kernel.private make sequences continuations quotations
-words math stack-checker stack-checker.transforms
-compiler.tree.propagation.info
-compiler.tree.propagation.inlining ;
+words math stack-checker combinators.short-circuit
+stack-checker.transforms compiler.tree.propagation.info
+compiler.tree.propagation.inlining compiler.units ;
 IN: compiler.tree.propagation.call-effect
 
 ! call( and execute( have complex expansions.
@@ -15,13 +15,20 @@ IN: compiler.tree.propagation.call-effect
 !   and compare it with declaration. If matches, call it unsafely.
 ! - Fallback. If the above doesn't work, call it and compare the datastack before
 !   and after to make sure it didn't mess anything up.
+! - Inline caches and cached effects are invalidated whenever a macro is redefined, or
+!   a word's effect changes, by comparing a global counter against the counter value
+!   last observed. The counter is incremented by compiler.units.
 
 ! execute( uses a similar strategy.
 
-TUPLE: inline-cache value ;
+TUPLE: inline-cache value counter ;
 
-: cache-hit? ( word/quot ic -- ? )
-    [ value>> eq? ] [ value>> ] bi and ; inline
+: inline-cache-hit? ( word/quot ic -- ? )
+    { [ value>> eq? ] [ nip counter>> effect-counter eq? ] } 2&& ; inline
+
+: update-inline-cache ( word/quot ic -- )
+    [ effect-counter ] dip
+    [ (>>value) ] [ (>>counter) ] bi-curry bi* ; inline
 
 SINGLETON: +unknown+
 
@@ -53,9 +60,16 @@ M: compose cached-effect
 : safe-infer ( quot -- effect )
     [ infer ] [ 2drop +unknown+ ] recover ;
 
+: cached-effect-valid? ( quot -- ? )
+    cache-counter>> effect-counter eq? ; inline
+
+: save-effect ( effect quot -- )
+    [ effect-counter ] dip
+    [ (>>cached-effect) ] [ (>>cache-counter) ] bi-curry bi* ;
+
 M: quotation cached-effect
-    dup cached-effect>>
-    [ ] [ [ safe-infer dup ] keep (>>cached-effect) ] ?if ;
+    dup cached-effect-valid?
+    [ cached-effect>> ] [ [ safe-infer dup ] keep save-effect ] if ;
 
 : call-effect-unsafe? ( quot effect -- ? )
     [ cached-effect ] dip
@@ -82,12 +96,12 @@ M: quotation cached-effect
 
 : call-effect-fast ( quot effect inline-cache -- )
     2over call-effect-unsafe?
-    [ [ nip (>>value) ] [ drop call-effect-unsafe ] 3bi ]
+    [ [ nip update-inline-cache ] [ drop call-effect-unsafe ] 3bi ]
     [ drop call-effect-slow ]
     if ; inline
 
 : call-effect-ic ( quot effect inline-cache -- )
-    3dup nip cache-hit?
+    3dup nip inline-cache-hit?
     [ drop call-effect-unsafe ]
     [ call-effect-fast ]
     if ; inline
@@ -103,12 +117,12 @@ M: quotation cached-effect
 
 : execute-effect-fast ( word effect inline-cache -- )
     2over execute-effect-unsafe?
-    [ [ nip (>>value) ] [ drop execute-effect-unsafe ] 3bi ]
+    [ [ nip update-inline-cache ] [ drop execute-effect-unsafe ] 3bi ]
     [ drop execute-effect-slow ]
     if ; inline
 
 : execute-effect-ic ( word effect inline-cache -- )
-    3dup nip cache-hit?
+    3dup nip inline-cache-hit?
     [ drop execute-effect-unsafe ]
     [ execute-effect-fast ]
     if ; inline
index 59c9912e47539f3a519a200f207b97d7c3b19f7a..617352d6998fcc8fbd7e627725e7451ec166f052 100644 (file)
@@ -39,8 +39,8 @@ M: true-constraint assume*
     bi ;
 
 M: true-constraint satisfied?
-    value>> value-info class>>
-    { [ true-class? ] [ null-class? not ] } 1&& ;
+    value>> value-info*
+    [ class>> true-class? ] [ drop f ] if ;
 
 TUPLE: false-constraint value ;
 
@@ -52,8 +52,8 @@ M: false-constraint assume*
     bi ;
 
 M: false-constraint satisfied?
-    value>> value-info class>>
-    { [ false-class? ] [ null-class? not ] } 1&& ;
+    value>> value-info*
+    [ class>> false-class? ] [ drop f ] if ;
 
 ! Class constraints
 TUPLE: class-constraint value class ;
index 9030914e340a657faf0c46393ac0b8c32560b1c3..6dcf6f7317e2353d10a57bcb2e5f80240f9e8198 100644 (file)
@@ -294,8 +294,11 @@ DEFER: (value-info-union)
 ! Assoc stack of current value --> info mapping
 SYMBOL: value-infos
 
+: value-info* ( value -- info ? )
+    resolve-copy value-infos get assoc-stack [ null-info or ] [ >boolean ] bi ; inline
+
 : value-info ( value -- info )
-    resolve-copy value-infos get assoc-stack null-info or ;
+    value-info* drop ;
 
 : set-value-info ( info value -- )
     resolve-copy value-infos get last set-at ;
index 367427c7168aa0659c07366630e79062af3e8de0..634fade609b93643348aab904d475318f0997fcc 100755 (executable)
@@ -90,7 +90,7 @@ M: callable splicing-nodes splicing-body ;
 ! Method body inlining
 SYMBOL: history
 
-: already-inlined? ( obj -- ? ) history get memq? ;
+: already-inlined? ( obj -- ? ) history get member-eq? ;
 
 : add-to-history ( obj -- ) history [ swap suffix ] change ;
 
@@ -104,7 +104,7 @@ SYMBOL: history
     ] if ;
 
 : always-inline-word? ( word -- ? )
-    { curry compose } memq? ;
+    { curry compose } member-eq? ;
 
 : never-inline-word? ( word -- ? )
     { [ deferred? ] [ "default" word-prop ] [ \ call eq? ] } 1|| ;
index d4780b335bc6348b16e5ec703f578643654f8152..1453bebf9aa30f78ae48667619da8fa8d369aa07 100644 (file)
@@ -8,7 +8,7 @@ classes.algebra combinators generic.math splitting fry locals
 classes.tuple alien.accessors classes.tuple.private
 slots.private definitions strings.private vectors hashtables
 generic quotations alien
-stack-checker.state
+stack-checker.dependencies
 compiler.tree.comparisons
 compiler.tree.propagation.info
 compiler.tree.propagation.nodes
@@ -140,20 +140,30 @@ IN: compiler.tree.propagation.known-words
     '[ _ _ 2bi ] "outputs" set-word-prop
 ] each
 
-\ shift [ [ interval-shift-safe ] [ may-overflow integer-valued ] binary-op ] each-derived-op
-\ shift [ [ interval-shift-safe ] [ integer-valued ] binary-op ] each-fast-derived-op
+: shift-op-class ( info1 info2 -- newclass )
+    [ class>> ] bi@
+    2dup [ null-class? ] either? [ 2drop null ] [ drop math-closure ] if ;
+
+: shift-op ( word interval-quot post-proc-quot -- )
+    '[
+        [ shift-op-class ] [ _ binary-op-interval ] 2bi
+        @
+        <class/interval-info>
+    ] "outputs" set-word-prop ;
+
+\ shift [ [ interval-shift-safe ] [ may-overflow integer-valued ] shift-op ] each-derived-op
+\ shift [ [ interval-shift-safe ] [ integer-valued ] shift-op ] each-fast-derived-op
 
 \ bitand [ [ interval-bitand ] [ integer-valued ] binary-op ] each-derived-op
 \ bitor [ [ interval-bitor ] [ integer-valued ] binary-op ] each-derived-op
 \ bitxor [ [ interval-bitxor ] [ integer-valued ] binary-op ] each-derived-op
 
 :: (comparison-constraints) ( in1 in2 op -- constraint )
-    [let | i1 [ in1 value-info interval>> ]
-           i2 [ in2 value-info interval>> ] |
-       in1 i1 i2 op assumption is-in-interval
-       in2 i2 i1 op swap-comparison assumption is-in-interval
-       /\
-    ] ;
+    in1 value-info interval>> :> i1
+    in2 value-info interval>> :> i2
+    in1 i1 i2 op assumption is-in-interval
+    in2 i2 i1 op swap-comparison assumption is-in-interval
+    /\ ;
 
 :: comparison-constraints ( in1 in2 out op -- constraint )
     in1 in2 op (comparison-constraints) out t-->
@@ -269,7 +279,7 @@ generic-comparison-ops [
 ] each
 
 \ alien-cell [
-    2drop simple-alien \ f class-or <class-info>
+    2drop alien \ f class-or <class-info>
 ] "outputs" set-word-prop
 
 { <tuple> <tuple-boa> } [
index 0a8cb61a9f8d63c9ec895ceddb74ec10e8172a12..c7e02aef4c59fa99a6151ce368bf490e23086f9a 100644 (file)
@@ -224,6 +224,14 @@ IN: compiler.tree.propagation.tests
 
 [ t ] [ [ over [ drop f ] when [ "A" throw ] unless ] final-classes first false-class? ] unit-test
 
+[ V{ fixnum } ] [
+    [
+        [ { fixnum } declare ] [ drop f ] if
+        dup [ dup 13 eq? [ t ] [ f ] if ] [ t ] if
+        [ "Oops" throw ] when
+    ] final-classes
+] unit-test
+
 [ V{ fixnum } ] [
     [
         >fixnum
@@ -231,6 +239,14 @@ IN: compiler.tree.propagation.tests
     ] final-classes
 ] unit-test
 
+[ ] [
+    [
+        dup dup dup [ 100 < ] [ drop f ] if dup
+        [ 2drop f ] [ 2drop f ] if
+        [ ] [ dup [ ] [ ] if ] if
+    ] final-info drop
+] unit-test
+
 [ V{ fixnum } ] [
     [ { fixnum } declare (clone) ] final-classes
 ] unit-test
@@ -407,10 +423,18 @@ IN: compiler.tree.propagation.tests
     [ { fixnum fixnum } declare 7 bitand neg shift ] final-classes
 ] unit-test
 
+[ V{ fixnum } ] [
+    [ { fixnum fixnum } declare 7 bitand neg >bignum shift ] final-classes
+] unit-test
+
 [ V{ fixnum } ] [
     [ { fixnum } declare 1 swap 7 bitand shift ] final-classes
 ] unit-test
 
+[ V{ fixnum } ] [
+    [ { fixnum } declare 1 swap 7 bitand >bignum shift ] final-classes
+] unit-test
+
 cell-bits 32 = [
     [ V{ integer } ] [
         [ { fixnum } declare 1 swap 31 bitand shift ]
@@ -859,8 +883,8 @@ SYMBOL: not-an-assoc
 [ t ] [ [ { 1 2 3 } member? ] { member? } inlined? ] unit-test
 [ f ] [ [ { 1 2 3 } swap member? ] { member? } inlined? ] unit-test
 
-[ t ] [ [ { 1 2 3 } memq? ] { memq? } inlined? ] unit-test
-[ f ] [ [ { 1 2 3 } swap memq? ] { memq? } inlined? ] unit-test
+[ t ] [ [ { 1 2 3 } member-eq? ] { member-eq? } inlined? ] unit-test
+[ f ] [ [ { 1 2 3 } swap member-eq? ] { member-eq? } inlined? ] unit-test
 
 [ t ] [ [ V{ } clone ] { clone (clone) } inlined? ] unit-test
 [ f ] [ [ { } clone ] { clone (clone) } inlined? ] unit-test
@@ -882,10 +906,10 @@ M: tuple-with-read-only-slot clone
     [ { 1 2 3 } dup tuple-with-read-only-slot boa clone x>> eq? ] final-classes
 ] unit-test
 
-! alien-cell outputs a simple-alien or f
+! alien-cell outputs a alien or f
 [ t ] [
     [ { byte-array fixnum } declare alien-cell dup [ "OOPS" throw ] unless ] final-classes
-    first simple-alien class=
+    first alien class=
 ] unit-test
 
 ! Don't crash if bad literal inputs are passed to unsafe words
@@ -900,9 +924,21 @@ M: tuple-with-read-only-slot clone
 [ t ] [ [ void* <c-direct-array> ] { <c-direct-array> } inlined? ] unit-test
 [ V{ void*-array } ] [ [ void* <c-direct-array> ] final-classes ] unit-test
 
+! bitand identities
 [ t ] [ [ alien-unsigned-1 255 bitand ] { bitand fixnum-bitand } inlined? ] unit-test
 [ t ] [ [ alien-unsigned-1 255 swap bitand ] { bitand fixnum-bitand } inlined? ] unit-test
 
 [ t ] [ [ { fixnum } declare 256 rem -256 bitand ] { fixnum-bitand } inlined? ] unit-test
 [ t ] [ [ { fixnum } declare 250 rem -256 bitand ] { fixnum-bitand } inlined? ] unit-test
 [ f ] [ [ { fixnum } declare 257 rem -256 bitand ] { fixnum-bitand } inlined? ] unit-test
+
+[ V{ fixnum } ] [ [ >bignum 10 mod 2^ ] final-classes ] unit-test
+[ V{ bignum } ] [ [ >bignum 10 bitand ] final-classes ] unit-test
+[ V{ bignum } ] [ [ >bignum 10 >bignum bitand ] final-classes ] unit-test
+[ V{ bignum } ] [ [ >bignum 10 mod ] final-classes ] unit-test
+[ V{ bignum } ] [ [ { fixnum } declare -1 >bignum bitand ] final-classes ] unit-test
+[ V{ bignum } ] [ [ { fixnum } declare -1 >bignum swap bitand ] final-classes ] unit-test
+
+! Could be bignum not integer but who cares
+[ V{ integer } ] [ [ 10 >bignum bitand ] final-classes ] unit-test
+
index 974bb584eba38b70b82bb59611e59a34908626ae..42325d97ca8ee132d59f2c86a2630a9aa19210a5 100644 (file)
@@ -27,14 +27,16 @@ IN: compiler.tree.propagation.recursive.tests
 ] unit-test
 
 [ t ] [
+    T{ interval f { -268435456 t } { 268435455 t } }
     T{ interval f { 1 t } { 268435455 t } }
-    T{ interval f { -268435456 t } { 268435455 t } } tuck
+    over
     integer generalize-counter-interval =
 ] unit-test
 
 [ t ] [
+    T{ interval f { -268435456 t } { 268435455 t } }
     T{ interval f { 1 t } { 268435455 t } }
-    T{ interval f { -268435456 t } { 268435455 t } } tuck
+    over
     fixnum generalize-counter-interval =
 ] unit-test
 
index 5de5e26a304e4f8d8025157cf06364f5b21259ca..b4d8b95247b4e7c1966f2323e685b09b0e3ce5ea 100644 (file)
@@ -4,7 +4,7 @@ USING: fry accessors kernel sequences sequences.private assocs
 words namespaces classes.algebra combinators
 combinators.short-circuit classes classes.tuple
 classes.tuple.private continuations arrays alien.c-types math
-math.private slots generic definitions stack-checker.state
+math.private slots generic definitions stack-checker.dependencies
 compiler.tree
 compiler.tree.propagation.info
 compiler.tree.propagation.nodes
index 4996729ded72a235de05968f5931dd8f8fbf8674..11a4cdc4c6be9b41ec56b0e9a3be106284fde11d 100644 (file)
@@ -11,7 +11,7 @@ IN: compiler.tree.propagation.slots
 UNION: fixed-length-sequence array byte-array string ;
 
 : sequence-constructor? ( word -- ? )
-    { <array> <byte-array> (byte-array) <string> } memq? ;
+    { <array> <byte-array> (byte-array) <string> } member-eq? ;
 
 : constructor-output-class ( word -- class )
     {
index b8ff96f8331d593e3a95996da10fbca945440b81..5aa490bfd3c26a9219ec41d751fb3dba1098a7d0 100644 (file)
@@ -2,11 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences words fry generic accessors
 classes.tuple classes classes.algebra definitions
-stack-checker.state quotations classes.tuple.private math
-math.partial-dispatch math.private math.intervals
+stack-checker.dependencies quotations classes.tuple.private math
+math.partial-dispatch math.private math.intervals sets.private
 math.floats.private math.integers.private layouts math.order
 vectors hashtables combinators effects generalizations assocs
-sets combinators.short-circuit sequences.private locals
+sets combinators.short-circuit sequences.private locals growable
 stack-checker namespaces compiler.tree.propagation.info ;
 IN: compiler.tree.propagation.transforms
 
@@ -42,30 +42,27 @@ IN: compiler.tree.propagation.transforms
 : positive-fixnum? ( obj -- ? )
     { [ fixnum? ] [ 0 >= ] } 1&& ;
 
-: simplify-bitand? ( value -- ? )
-    value-info literal>> positive-fixnum? ;
+: simplify-bitand? ( value1 value2 -- ? )
+    [ literal>> positive-fixnum? ]
+    [ class>> fixnum swap class<= ]
+    bi* and ;
 
-: all-ones? ( int -- ? )
-    dup 1 + bitand zero? ; inline
+: all-ones? ( n -- ? ) dup 1 + bitand zero? ; inline
 
-: redundant-bitand? ( var 111... -- ? )
-    [ value-info ] bi@ [ interval>> ] [ literal>> ] bi* {
+: redundant-bitand? ( value1 value2 -- ? )
+    [ interval>> ] [ literal>> ] bi* {
         [ nip integer? ]
         [ nip all-ones? ]
         [ 0 swap [a,b] interval-subset? ]
     } 2&& ;
 
-: (zero-bitand?) ( value-info value-info' -- ? )
+: zero-bitand? ( value1 value2 -- ? )
     [ interval>> ] [ literal>> ] bi* {
         [ nip integer? ]
         [ nip bitnot all-ones? ]
         [ 0 swap bitnot [a,b] interval-subset? ]
     } 2&& ;
 
-: zero-bitand? ( var1 var2 -- ? )
-    [ value-info ] bi@
-    { [ (zero-bitand?) ] [ swap (zero-bitand?) ] } 2|| ;
-
 {
     bitand-integer-integer
     bitand-integer-fixnum
@@ -73,35 +70,45 @@ IN: compiler.tree.propagation.transforms
     bitand
 } [
     [
-        {
+        in-d>> first2 [ value-info ] bi@ {
             {
-                [ dup in-d>> first2 zero-bitand? ]
-                [ drop [ 2drop 0 ] ]
+                [ 2dup zero-bitand? ]
+                [ 2drop [ 2drop 0 ] ]
             }
             {
-                [ dup in-d>> first2 redundant-bitand? ]
-                [ drop [ drop ] ]
+                [ 2dup swap zero-bitand? ]
+                [ 2drop [ 2drop 0 ] ]
             }
             {
-                [ dup in-d>> first2 swap redundant-bitand? ]
-                [ drop [ nip ] ]
+                [ 2dup redundant-bitand? ]
+                [ 2drop [ drop ] ]
             }
             {
-                [ dup in-d>> first simplify-bitand? ]
-                [ drop [ >fixnum fixnum-bitand ] ]
+                [ 2dup swap redundant-bitand? ]
+                [ 2drop [ nip ] ]
             }
             {
-                [ dup in-d>> second simplify-bitand? ]
-                [ drop [ [ >fixnum ] dip fixnum-bitand ] ]
+                [ 2dup simplify-bitand? ]
+                [ 2drop [ >fixnum fixnum-bitand ] ]
             }
-            [ drop f ]
+            {
+                [ 2dup swap simplify-bitand? ]
+                [ 2drop [ [ >fixnum ] dip fixnum-bitand ] ]
+            }
+            [ 2drop f ]
         } cond
     ] "custom-inlining" set-word-prop
 ] each
 
 ! Speeds up 2^
+: 2^? ( #call -- ? )
+    in-d>> first2 [ value-info ] bi@
+    [ { [ literal>> 1 = ] [ class>> fixnum class<= ] } 1&& ]
+    [ class>> fixnum class<= ]
+    bi* and ;
+
 \ shift [
-    in-d>> first value-info literal>> 1 = [
+     2^? [
         cell-bits tag-bits get - 1 -
         '[
             >fixnum dup 0 < [ 2drop 0 ] [
@@ -206,12 +213,12 @@ ERROR: bad-partial-eval quot word ;
     ] [ drop f ] if
 ] 1 define-partial-eval
 
-: memq-quot ( seq -- newquot )
+: member-eq-quot ( seq -- newquot )
     [ [ dupd eq? ] curry [ drop t ] ] { } map>assoc
     [ drop f ] suffix [ cond ] curry ;
 
-\ memq? [
-    dup sequence? [ memq-quot ] [ drop f ] if
+\ member-eq? [
+    dup sequence? [ member-eq-quot ] [ drop f ] if
 ] 1 define-partial-eval
 
 ! Membership testing
@@ -283,3 +290,20 @@ CONSTANT: lookup-table-at-max 256
     ] [ drop f ] if ;
 
 \ at* [ at-quot ] 1 define-partial-eval
+
+: diff-quot ( seq -- quot: ( seq' -- seq'' ) )
+    tester '[ [ @ not ] filter ] ;
+
+\ diff [ diff-quot ] 1 define-partial-eval
+
+: intersect-quot ( seq -- quot: ( seq' -- seq'' ) )
+    tester '[ _ filter ] ;
+
+\ intersect [ intersect-quot ] 1 define-partial-eval
+
+! Speeds up sum-file, sort and reverse-complement benchmarks by
+! compiling decoder-readln better
+\ push [
+    in-d>> second value-info class>> growable class<=
+    [ \ push def>> ] [ f ] if
+] "custom-inlining" set-word-prop
index 7fa096b62392f828aef97bee34568b97cf5c93dd..82b8fbb8434f7ceae30119b96a3675a42bf83eab 100644 (file)
@@ -10,8 +10,6 @@ IN: compiler.tree
 
 TUPLE: node < identity-tuple ;
 
-M: node hashcode* drop node hashcode* ;
-
 TUPLE: #introduce < node out-d ;
 
 : #introduce ( out-d -- node )
index b6c6910e34538aed940ecd5da7dd93b44982ad9d..84080a73d7ce2399a2e9aa6f8415a17c916f3ee3 100644 (file)
@@ -36,13 +36,11 @@ yield-hook [ [ ] ] initialize
 : penultimate ( seq -- elt ) [ length 2 - ] keep nth ;
 
 :: compress-path ( source assoc -- destination )
-    [let | destination [ source assoc at ] |
-        source destination = [ source ] [
-            [let | destination' [ destination assoc compress-path ] |
-                destination' destination = [
-                    destination' source assoc set-at
-                ] unless
-                destination'
-            ]
-        ] if
-    ] ;
+    source assoc at :> destination
+    source destination = [ source ] [
+        destination assoc compress-path :> destination'
+        destination' destination = [
+            destination' source assoc set-at
+        ] unless
+        destination'
+    ] if ;
index cde2a7e1134c537cb7b00a93b9434b17c60ecb75..ce25cd6a63ad2c215bd69ce867c420ac0d0c306d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays combinators grouping kernel locals math
-math.matrices math.order multiline sequence-parser sequences
+math.matrices math.order multiline sequences.parser sequences
 tools.continuations ;
 IN: compression.run-length
 
index 3d18b9e029c26ff5f4c299c7a2da68179d922735..918b3c5ba0000e42ffa4fc2b3f70435632173331 100755 (executable)
@@ -29,7 +29,7 @@ PRIVATE>
 : [future] ( quot -- quot' ) '[ _ curry future ] ; inline\r
 \r
 : future-values ( futures -- futures )\r
-    dup [ ?future ] change-each ; inline\r
+    [ ?future ] map! ; inline\r
 \r
 PRIVATE>\r
 \r
index 76c9918ccacd1cca064655b61d33f72ebca7e17e..8ea7153b0bcebc66e1e7095b1ff9b9e4bf86d309 100644 (file)
@@ -8,11 +8,54 @@ HELP: start-node
 { $values { "port" "a port number between 0 and 65535" } }
 { $description "Starts a node server for receiving messages from remote Factor instances." } ;
 
+ARTICLE: "concurrency.distributed.example" "Distributed Concurrency Example"
+"For a Factor instance to be able to send and receive distributed "
+"concurrency messages it must first have " { $link start-node } " called."
+$nl
+"In one factor instance call " { $link start-node } " with the port 9000, "
+"and in another with the port 9001."
+$nl
+"In this example the Factor instance associated with port 9000 will run "
+"a thread that sits receiving messages and printing the received message "
+"in the listener. The code to start the thread is: "
+{ $examples
+    { $unchecked-example
+        ": log-message ( -- ) receive . flush log-message ;"
+        "[ log-message ] \"logger\" spawn dup name>> register-remote-thread"
+    }
+}
+"This spawns a thread waits for the messages. It registers that thread as a "
+"able to be accessed remotely using " { $link register-remote-thread } "."
+$nl
+"The second Factor instance, the one associated with port 9001, can send "
+"messages to the 'logger' thread by name:"
+{ $examples
+    { $unchecked-example
+        "USING: io.sockets concurrency.messaging concurrency.distributed ;"
+        "\"hello\" \"127.0.0.1\" 9000 <inet4> \"logger\" <remote-thread> send"
+    }
+}
+"The " { $link send } " word is used to send messages to other threads. If an "
+"instance of " { $link remote-thread } " is provided instead of a thread then "
+"the message is marshalled to the named thread on the given machine using the "
+{ $vocab-link "serialize" } " vocabulary."
+$nl
+"Running this code should show the message \"hello\" in the first Factor "
+"instance."
+$nl
+"It is also possible to use " { $link send-synchronous } " to receive a "
+"response to a distributed message. When an instance of " { $link thread } " "
+"is marshalled it is converted into an instance of " { $link remote-thread }
+". The receiver of this can use it as the target of a " { $link send }
+" or " { $link reply } " call." ;
+
 ARTICLE: "concurrency.distributed" "Distributed message passing"
 "The " { $vocab-link "concurrency.distributed" } " implements transparent distributed message passing, inspired by Erlang and Termite."
 { $subsections start-node }
-"Instances of " { $link thread } " can be sent to remote processes, at which point they are converted to objects holding the thread ID and the current node's host name:"
-{ $subsections remote-process }
-"The " { $vocab-link "serialize" } " vocabulary is used to convert Factor objects to byte arrays for transfer over a socket." ;
+"Instances of " { $link thread } " can be sent to remote threads, at which point they are converted to objects holding the thread ID and the current node's host name:"
+{ $subsections remote-thread }
+"The " { $vocab-link "serialize" } " vocabulary is used to convert Factor objects to byte arrays for transfer over a socket." 
+{ $subsections "concurrency.distributed.example" } ;
+
 
 ABOUT: "concurrency.distributed"
index b2a28519260ee4ed1ec7b98e39fadfc5605f7bae..1a46d0e38fac3080a47b4e3737414b036c8a2726 100644 (file)
@@ -18,14 +18,14 @@ IN: concurrency.distributed.tests
 [ ] [
     [
         receive first2 [ 3 + ] dip send
-        "thread-a" unregister-process
+        "thread-a" unregister-remote-thread
     ] "Thread A" spawn
-    "thread-a" swap register-process
+    "thread-a" register-remote-thread
 ] unit-test
 
 [ 8 ] [
     5 self 2array
-    "thread-a" test-node <remote-process> send
+    test-node "thread-a" <remote-thread> send
 
     receive
 ] unit-test
index 52627f2ed9ed1e6fabd8b9185d7bae0acb0b7ab7..244f1d95a34c082ddda82ad597e24d066aedb952 100644 (file)
@@ -1,16 +1,32 @@
 ! Copyright (C) 2005 Chris Double. All Rights Reserved.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: serialize sequences concurrency.messaging threads io
-io.servers.connection io.encodings.binary
+io.servers.connection io.encodings.binary assocs init
 arrays namespaces kernel accessors ;
 FROM: io.sockets => host-name <inet> with-client ;
 IN: concurrency.distributed
 
+<PRIVATE
+
+: registered-remote-threads ( -- hash )
+   \ registered-remote-threads get-global ;
+
+PRIVATE>
+
+: register-remote-thread ( thread name -- )
+    registered-remote-threads set-at ;
+
+: unregister-remote-thread ( name -- )
+    registered-remote-threads delete-at ;
+
+: get-remote-thread ( name -- thread )
+    dup registered-remote-threads at [ ] [ thread ] ?if ;
+
 SYMBOL: local-node
 
 : handle-node-client ( -- )
     deserialize
-    [ first2 get-process send ] [ stop-this-server ] if* ;
+    [ first2 get-remote-thread send ] [ stop-this-server ] if* ;
 
 : <node-server> ( addrspec -- threaded-server )
     binary <threaded-server>
@@ -24,20 +40,26 @@ SYMBOL: local-node
 : start-node ( port -- )
     host-name over <inet> (start-node) ;
 
-TUPLE: remote-process id node ;
+TUPLE: remote-thread node id ;
 
-C: <remote-process> remote-process
+C: <remote-thread> remote-thread
 
 : send-remote-message ( message node -- )
     binary [ serialize ] with-client ;
 
-M: remote-process send ( message thread -- )
+M: remote-thread send ( message thread -- )
     [ id>> 2array ] [ node>> ] bi
     send-remote-message ;
 
 M: thread (serialize) ( obj -- )
-    id>> local-node get-global <remote-process>
+    id>> [ local-node get-global ] dip <remote-thread>
     (serialize) ;
 
 : stop-node ( node -- )
     f swap send-remote-message ;
+
+[
+    H{ } clone \ registered-remote-threads set-global
+] "remote-thread-registry" add-init-hook
+
+
index a8214cf42f2301a5712a034df555f20053c3bbf3..c411aaea92254edf4974a1fcbf5f18e3f60e052a 100644 (file)
@@ -5,27 +5,25 @@ FROM: sequences => 3append ;
 IN: concurrency.exchangers.tests\r
 \r
 :: exchanger-test ( -- string )\r
-    [let |\r
-        ex [ <exchanger> ]\r
-        c [ 2 <count-down> ]\r
-        v1! [ f ]\r
-        v2! [ f ]\r
-        pr [ <promise> ] |\r
+    <exchanger> :> ex\r
+    2 <count-down> :> c\r
+    f :> v1!\r
+    f :> v2!\r
+    <promise> :> pr\r
 \r
-        [\r
-            c await\r
-            v1 ", " v2 3append pr fulfill\r
-        ] "Awaiter" spawn drop\r
+    [\r
+        c await\r
+        v1 ", " v2 3append pr fulfill\r
+    ] "Awaiter" spawn drop\r
 \r
-        [\r
-            "Goodbye world" ex exchange v1! c count-down\r
-        ] "Exchanger 1" spawn drop\r
+    [\r
+        "Goodbye world" ex exchange v1! c count-down\r
+    ] "Exchanger 1" spawn drop\r
 \r
-        [\r
-            "Hello world" ex exchange v2! c count-down\r
-        ] "Exchanger 2" spawn drop\r
+    [\r
+        "Hello world" ex exchange v2! c count-down\r
+    ] "Exchanger 2" spawn drop\r
 \r
-        pr ?promise\r
-    ] ;\r
+    pr ?promise ;\r
 \r
 [ "Hello world, Goodbye world" ] [ exchanger-test ] unit-test\r
index 4fc00b71dd74df1c5c604b7d0703bc6c38b384a1..8402a5663164a5215f39deb5117b5b2b36962517 100644 (file)
@@ -3,46 +3,41 @@ kernel threads locals accessors calendar ;
 IN: concurrency.flags.tests\r
 \r
 :: flag-test-1 ( -- val )\r
-    [let | f [ <flag> ] |\r
-        [ f raise-flag ] "Flag test" spawn drop\r
-        f lower-flag\r
-        f value>>\r
-    ] ;\r
+    <flag> :> f\r
+    [ f raise-flag ] "Flag test" spawn drop\r
+    f lower-flag\r
+    f value>> ;\r
 \r
 [ f ] [ flag-test-1 ] unit-test\r
 \r
 :: flag-test-2 ( -- ? )\r
-    [let | f [ <flag> ] |\r
-        [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop\r
-        f lower-flag\r
-        f value>>\r
-    ] ;\r
+    <flag> :> f\r
+    [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop\r
+    f lower-flag\r
+    f value>> ;\r
 \r
 [ f ] [ flag-test-2 ] unit-test\r
 \r
 :: flag-test-3 ( -- val )\r
-    [let | f [ <flag> ] |\r
-        f raise-flag\r
-        f value>>\r
-    ] ;\r
+    <flag> :> f\r
+    f raise-flag\r
+    f value>> ;\r
 \r
 [ t ] [ flag-test-3 ] unit-test\r
 \r
 :: flag-test-4 ( -- val )\r
-    [let | f [ <flag> ] |\r
-        [ f raise-flag ] "Flag test" spawn drop\r
-        f wait-for-flag\r
-        f value>>\r
-    ] ;\r
+    <flag> :> f\r
+    [ f raise-flag ] "Flag test" spawn drop\r
+    f wait-for-flag\r
+    f value>> ;\r
 \r
 [ t ] [ flag-test-4 ] unit-test\r
 \r
 :: flag-test-5 ( -- val )\r
-    [let | f [ <flag> ] |\r
-        [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop\r
-        f wait-for-flag\r
-        f value>>\r
-    ] ;\r
+    <flag> :> f\r
+    [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop\r
+    f wait-for-flag\r
+    f value>> ;\r
 \r
 [ t ] [ flag-test-5 ] unit-test\r
 \r
index f199876fd0c5d360c564debc1439724130f1ec08..c58d012b3fa74dac8123e2de407f342997f40ed8 100644 (file)
@@ -4,57 +4,55 @@ threads sequences calendar accessors ;
 IN: concurrency.locks.tests\r
 \r
 :: lock-test-0 ( -- v )\r
-    [let | v [ V{ } clone ]\r
-           c [ 2 <count-down> ] |\r
-\r
-           [\r
-               yield\r
-               1 v push\r
-               yield\r
-               2 v push\r
-               c count-down\r
-           ] "Lock test 1" spawn drop\r
-\r
-           [\r
-               yield\r
-               3 v push\r
-               yield\r
-               4 v push\r
-               c count-down\r
-           ] "Lock test 2" spawn drop\r
-\r
-           c await\r
-           v\r
-    ] ;\r
+    V{ } clone :> v\r
+    2 <count-down> :> c\r
+\r
+    [\r
+        yield\r
+        1 v push\r
+        yield\r
+        2 v push\r
+        c count-down\r
+    ] "Lock test 1" spawn drop\r
+\r
+    [\r
+        yield\r
+        3 v push\r
+        yield\r
+        4 v push\r
+        c count-down\r
+    ] "Lock test 2" spawn drop\r
+\r
+    c await\r
+    v ;\r
 \r
 :: lock-test-1 ( -- v )\r
-    [let | v [ V{ } clone ]\r
-           l [ <lock> ]\r
-           c [ 2 <count-down> ] |\r
-\r
-           [\r
-               l [\r
-                   yield\r
-                   1 v push\r
-                   yield\r
-                   2 v push\r
-               ] with-lock\r
-               c count-down\r
-           ] "Lock test 1" spawn drop\r
-\r
-           [\r
-               l [\r
-                   yield\r
-                   3 v push\r
-                   yield\r
-                   4 v push\r
-               ] with-lock\r
-               c count-down\r
-           ] "Lock test 2" spawn drop\r
-\r
-           c await\r
-           v\r
-    ] ;\r
+    V{ } clone :> v\r
+    <lock> :> l\r
+    2 <count-down> :> c\r
+\r
+    [\r
+        l [\r
+            yield\r
+            1 v push\r
+            yield\r
+            2 v push\r
+        ] with-lock\r
+        c count-down\r
+    ] "Lock test 1" spawn drop\r
+\r
+    [\r
+        l [\r
+            yield\r
+            3 v push\r
+            yield\r
+            4 v push\r
+        ] with-lock\r
+        c count-down\r
+    ] "Lock test 2" spawn drop\r
+\r
+    c await\r
+    v ;\r
 \r
 [ V{ 1 3 2 4 } ] [ lock-test-0 ] unit-test\r
 [ V{ 1 2 3 4 } ] [ lock-test-1 ] unit-test\r
@@ -80,98 +78,96 @@ IN: concurrency.locks.tests
 [ ] [ <rw-lock> dup [ [ ] with-read-lock ] with-write-lock ] unit-test\r
 \r
 :: rw-lock-test-1 ( -- v )\r
-    [let | l [ <rw-lock> ]\r
-           c [ 1 <count-down> ]\r
-           c' [ 1 <count-down> ]\r
-           c'' [ 4 <count-down> ]\r
-           v [ V{ } clone ] |\r
-\r
-           [\r
-               l [\r
-                   1 v push\r
-                   c count-down\r
-                   yield\r
-                   3 v push\r
-               ] with-read-lock\r
-               c'' count-down\r
-           ] "R/W lock test 1" spawn drop\r
-\r
-           [\r
-               c await\r
-               l [\r
-                   4 v push\r
-                   1 seconds sleep\r
-                   5 v push\r
-               ] with-write-lock\r
-               c'' count-down\r
-           ] "R/W lock test 2" spawn drop\r
-\r
-           [\r
-               c await\r
-               l [\r
-                   2 v push\r
-                   c' count-down\r
-               ] with-read-lock\r
-               c'' count-down\r
-           ] "R/W lock test 4" spawn drop\r
-\r
-           [\r
-               c' await\r
-               l [\r
-                   6 v push\r
-               ] with-write-lock\r
-               c'' count-down\r
-           ] "R/W lock test 5" spawn drop\r
-\r
-           c'' await\r
-           v\r
-    ] ;\r
+    <rw-lock> :> l\r
+    1 <count-down> :> c\r
+    1 <count-down> :> c'\r
+    4 <count-down> :> c''\r
+    V{ } clone :> v\r
+\r
+    [\r
+        l [\r
+            1 v push\r
+            c count-down\r
+            yield\r
+            3 v push\r
+        ] with-read-lock\r
+        c'' count-down\r
+    ] "R/W lock test 1" spawn drop\r
+\r
+    [\r
+        c await\r
+        l [\r
+            4 v push\r
+            1 seconds sleep\r
+            5 v push\r
+        ] with-write-lock\r
+        c'' count-down\r
+    ] "R/W lock test 2" spawn drop\r
+\r
+    [\r
+        c await\r
+        l [\r
+            2 v push\r
+            c' count-down\r
+        ] with-read-lock\r
+        c'' count-down\r
+    ] "R/W lock test 4" spawn drop\r
+\r
+    [\r
+        c' await\r
+        l [\r
+            6 v push\r
+        ] with-write-lock\r
+        c'' count-down\r
+    ] "R/W lock test 5" spawn drop\r
+\r
+    c'' await\r
+    v ;\r
 \r
 [ V{ 1 2 3 4 5 6 } ] [ rw-lock-test-1 ] unit-test\r
 \r
 :: rw-lock-test-2 ( -- v )\r
-    [let | l [ <rw-lock> ]\r
-           c [ 1 <count-down> ]\r
-           c' [ 2 <count-down> ]\r
-           v [ V{ } clone ] |\r
-\r
-           [\r
-               l [\r
-                   1 v push\r
-                   c count-down\r
-                   1 seconds sleep\r
-                   2 v push\r
-               ] with-write-lock\r
-               c' count-down\r
-           ] "R/W lock test 1" spawn drop\r
-\r
-           [\r
-               c await\r
-               l [\r
-                   3 v push\r
-               ] with-read-lock\r
-               c' count-down\r
-           ] "R/W lock test 2" spawn drop\r
-\r
-           c' await\r
-           v\r
-    ] ;\r
+    <rw-lock> :> l\r
+    1 <count-down> :> c\r
+    2 <count-down> :> c'\r
+    V{ } clone :> v\r
+\r
+    [\r
+        l [\r
+            1 v push\r
+            c count-down\r
+            1 seconds sleep\r
+            2 v push\r
+        ] with-write-lock\r
+        c' count-down\r
+    ] "R/W lock test 1" spawn drop\r
+\r
+    [\r
+        c await\r
+        l [\r
+            3 v push\r
+        ] with-read-lock\r
+        c' count-down\r
+    ] "R/W lock test 2" spawn drop\r
+\r
+    c' await\r
+    v ;\r
 \r
 [ V{ 1 2 3 } ] [ rw-lock-test-2 ] unit-test\r
 \r
 ! Test lock timeouts\r
 :: lock-timeout-test ( -- v )\r
-    [let | l [ <lock> ] |\r
-        [\r
-            l [ 1 seconds sleep ] with-lock\r
-        ] "Lock holder" spawn drop\r
+    <lock> :> l\r
 \r
-        [\r
-            l 1/10 seconds [ ] with-lock-timeout\r
-        ] "Lock timeout-er" spawn-linked drop\r
+    [\r
+        l [ 1 seconds sleep ] with-lock\r
+    ] "Lock holder" spawn drop\r
+\r
+    [\r
+        l 1/10 seconds [ ] with-lock-timeout\r
+    ] "Lock timeout-er" spawn-linked drop\r
 \r
-        receive\r
-    ] ;\r
+    receive ;\r
 \r
 [ lock-timeout-test ] [\r
     thread>> name>> "Lock timeout-er" =\r
index a58a1a4cc65c866f300ece82d4ba9524825318b9..727efd45d0e6df8dce387419b09c0b8d3a0d5eaa 100644 (file)
@@ -18,9 +18,10 @@ HELP: mailbox-put
 { $description "Put the object into the mailbox. Any threads that have a blocking get on the mailbox are resumed. Only one of those threads will successfully get the object, the rest will immediately block waiting for the next item in the mailbox." } ;\r
 \r
 HELP: block-unless-pred\r
-{ $values { "pred" { $quotation "( obj -- ? )" } } \r
+{ $values\r
     { "mailbox" mailbox }\r
     { "timeout" "a " { $link duration } " or " { $link f } }\r
+    { "pred" { $quotation "( obj -- ? )" } } \r
 }\r
 { $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack." } ;\r
 \r
index 17f05e20fb19bc1d07ad8bf74a3bd55fb4dc4af8..85870db4df8925bbc1c25ec26a7e419c615d2ab5 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.syntax help.markup concurrency.messaging.private
+USING: help.syntax help.markup 
 threads kernel arrays quotations strings ;
 IN: concurrency.messaging
 
index ce7f7d611083f8333469f4649d02c825f59a9f5a..37965309e8b4f1a41fbf966bea242eb81ae4a2db 100644 (file)
@@ -68,21 +68,3 @@ M: cannot-send-synchronous-to-self summary
     receive [\r
         data>> swap call\r
     ] keep reply-synchronous ; inline\r
-\r
-<PRIVATE\r
-\r
-: registered-processes ( -- hash )\r
-   \ registered-processes get-global ;\r
-\r
-PRIVATE>\r
-\r
-: register-process ( name process -- )\r
-    swap registered-processes set-at ;\r
-\r
-: unregister-process ( name -- )\r
-    registered-processes delete-at ;\r
-\r
-: get-process ( name -- process )\r
-    dup registered-processes at [ ] [ thread ] ?if ;\r
-\r
-\ registered-processes [ H{ } clone ] initialize\r
index a50de60c45c4505fe4be2e81ff15fa486e053a23..ad17da96524718d87a599b9d535ad7c464b60e8f 100644 (file)
@@ -12,7 +12,7 @@ TUPLE: simple-cord
 M: simple-cord length
     [ first>> length ] [ second>> length ] bi + ; inline
 
-M: simple-cord virtual-seq first>> ; inline
+M: simple-cord virtual-exemplar first>> ; inline
 
 M: simple-cord virtual@
     2dup first>> length <
@@ -28,7 +28,7 @@ M: multi-cord virtual@
     seqs>> [ first <=> ] with search nip
     [ first - ] [ second ] bi ; inline
 
-M: multi-cord virtual-seq
+M: multi-cord virtual-exemplar
     seqs>> [ f ] [ first second ] if-empty ; inline
 
 : <cord> ( seqs -- cord )
index e7a7962e6e72ac84a7604514c0f37ba75c3a425b..37dbcd1e4feb4c925177c904dc760ffe6269fd52 100755 (executable)
@@ -36,8 +36,8 @@ STRUCT: FSEventStreamContext
     { release void* }
     { copyDescription void* } ;
 
-! callback(FSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]);
-TYPEDEF: void* FSEventStreamCallback
+! callback(
+CALLBACK: void FSEventStreamCallback ( FSEventStreamRef streamRef, void* clientCallBackInfo, size_t numEvents, void* eventPaths, FSEventStreamEventFlags* eventFlags, FSEventStreamEventId* eventIds ) ;
 
 CONSTANT: FSEventStreamEventIdSinceNow HEX: FFFFFFFFFFFFFFFF
 
index 7b454266f26bdcbc8276e8cdd6b88c5786254d38..0b61274b22fc6debce7bf44ea8b416de8f565a89 100644 (file)
@@ -115,7 +115,7 @@ PRIVATE>
     [ fds>> [ enable-all-callbacks ] each ] bi ;
 
 : timer-callback ( -- callback )
-    "void" { "CFRunLoopTimerRef" "void*" } "cdecl"
+    void { CFRunLoopTimerRef void* } "cdecl"
     [ 2drop reset-run-loop yield ] alien-callback ;
 
 : init-thread-timer ( -- )
index a5cf69fdee3e23b7fa5db1aec4b59ddd8db3fffa..b6b54df7c3b567865a3926ce0c6d2a7a0967adfa 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.test core-text core-text.fonts core-foundation
 core-foundation.dictionaries destructors arrays kernel generalizations
-math accessors core-foundation.utilities combinators hashtables colors
+locals math accessors core-foundation.utilities combinators hashtables colors
 colors.constants ;
 IN: core-text.tests
 
@@ -18,10 +18,11 @@ IN: core-text.tests
     ] with-destructors
 ] unit-test
 
-: test-typographic-bounds ( string font -- ? )
+:: test-typographic-bounds ( string font -- ? )
     [
-        test-font &CFRelease tuck COLOR: white <CTLine> &CFRelease
-        compute-line-metrics {
+        font test-font &CFRelease :> ctfont
+        string ctfont COLOR: white <CTLine> &CFRelease :> ctline
+        ctfont ctline compute-line-metrics {
             [ width>> float? ]
             [ ascent>> float? ]
             [ descent>> float? ]
@@ -33,4 +34,4 @@ IN: core-text.tests
 
 [ t ] [ "Hello world" "Chicago" test-typographic-bounds ] unit-test
 
-[ t ] [ "日本語" "Helvetica" test-typographic-bounds ] unit-test
\ No newline at end of file
+[ t ] [ "日本語" "Helvetica" test-typographic-bounds ] unit-test
index d672815cbeae049bb64b8964a59ba7211ffdd3bb..7af6792e79845d8d14517139ba4d86f0b66513b7 100644 (file)
@@ -112,35 +112,34 @@ TUPLE: line < disposable line metrics image loc dim ;
     [
         line new-disposable
 
-        [let* | open-font [ font cache-font ]
-                line [ string open-font font foreground>> <CTLine> |CFRelease ]
-
-                rect [ line line-rect ]
-                (loc) [ rect origin>> CGPoint>loc ]
-                (dim) [ rect size>> CGSize>dim ]
-                (ext) [ (loc) (dim) v+ ]
-                loc [ (loc) [ floor ] map ]
-                ext [ (loc) (dim) [ + ceiling ] 2map ]
-                dim [ ext loc [ - >integer 1 max ] 2map ]
-                metrics [ open-font line compute-line-metrics ] |
-
-            line >>line
-
-            metrics >>metrics
-
-            dim [
-                {
-                    [ font dim fill-background ]
-                    [ loc dim line string fill-selection-background ]
-                    [ loc set-text-position ]
-                    [ [ line ] dip CTLineDraw ]
-                } cleave
-            ] make-bitmap-image >>image
-
-            metrics loc dim line-loc >>loc
-
-            metrics metrics>dim >>dim
-        ]
+        font cache-font :> open-font
+        string open-font font foreground>> <CTLine> |CFRelease :> line
+
+        line line-rect :> rect
+        rect origin>> CGPoint>loc :> (loc)
+        rect size>> CGSize>dim :> (dim)
+        (loc) (dim) v+ :> (ext)
+        (loc) [ floor ] map :> loc
+        (loc) (dim) [ + ceiling ] 2map :> ext
+        ext loc [ - >integer 1 max ] 2map :> dim
+        open-font line compute-line-metrics :> metrics
+
+        line >>line
+
+        metrics >>metrics
+
+        dim [
+            {
+                [ font dim fill-background ]
+                [ loc dim line string fill-selection-background ]
+                [ loc set-text-position ]
+                [ [ line ] dip CTLineDraw ]
+            } cleave
+        ] make-bitmap-image >>image
+
+        metrics loc dim line-loc >>loc
+
+        metrics metrics>dim >>dim
     ] with-destructors ;
 
 M: line dispose* line>> CFRelease ;
index c411d97558fb5bfd3434d96700239eaaf8a9aea1..6723956780733aae7150cfd7b85bd43e2b96cb70 100644 (file)
@@ -107,6 +107,16 @@ scalar-rep ;
         { ulonglong-scalar-rep longlong-scalar-rep }
     } ?at drop ;
 
+: widen-vector-rep ( rep -- rep' )
+    {
+        { char-16-rep     short-8-rep     }
+        { short-8-rep     int-4-rep       }
+        { int-4-rep       longlong-2-rep  }
+        { uchar-16-rep    ushort-8-rep    }
+        { ushort-8-rep    uint-4-rep      }
+        { uint-4-rep      ulonglong-2-rep }
+    } at ;
+
 ! Register classes
 SINGLETONS: int-regs float-regs ;
 
@@ -277,8 +287,10 @@ HOOK: %xor-vector cpu ( dst src1 src2 rep -- )
 HOOK: %not-vector cpu ( dst src rep -- )
 HOOK: %shl-vector cpu ( dst src1 src2 rep -- )
 HOOK: %shr-vector cpu ( dst src1 src2 rep -- )
-HOOK: %horizontal-shl-vector cpu ( dst src1 src2 rep -- )
-HOOK: %horizontal-shr-vector cpu ( dst src1 src2 rep -- )
+HOOK: %shl-vector-imm cpu ( dst src1 src2 rep -- )
+HOOK: %shr-vector-imm cpu ( dst src1 src2 rep -- )
+HOOK: %horizontal-shl-vector-imm cpu ( dst src1 src2 rep -- )
+HOOK: %horizontal-shr-vector-imm cpu ( dst src1 src2 rep -- )
 
 HOOK: %integer>scalar cpu ( dst src rep -- )
 HOOK: %scalar>integer cpu ( dst src rep -- )
@@ -324,8 +336,10 @@ HOOK: %xor-vector-reps cpu ( -- reps )
 HOOK: %not-vector-reps cpu ( -- reps )
 HOOK: %shl-vector-reps cpu ( -- reps )
 HOOK: %shr-vector-reps cpu ( -- reps )
-HOOK: %horizontal-shl-vector-reps cpu ( -- reps )
-HOOK: %horizontal-shr-vector-reps cpu ( -- reps )
+HOOK: %shl-vector-imm-reps cpu ( -- reps )
+HOOK: %shr-vector-imm-reps cpu ( -- reps )
+HOOK: %horizontal-shl-vector-imm-reps cpu ( -- reps )
+HOOK: %horizontal-shr-vector-imm-reps cpu ( -- reps )
 
 M: object %zero-vector-reps { } ;
 M: object %fill-vector-reps { } ;
@@ -366,13 +380,15 @@ M: object %xor-vector-reps { } ;
 M: object %not-vector-reps { } ;
 M: object %shl-vector-reps { } ;
 M: object %shr-vector-reps { } ;
-M: object %horizontal-shl-vector-reps { } ;
-M: object %horizontal-shr-vector-reps { } ;
+M: object %shl-vector-imm-reps { } ;
+M: object %shr-vector-imm-reps { } ;
+M: object %horizontal-shl-vector-imm-reps { } ;
+M: object %horizontal-shr-vector-imm-reps { } ;
 
 HOOK: %unbox-alien cpu ( dst src -- )
-HOOK: %unbox-any-c-ptr cpu ( dst src temp -- )
+HOOK: %unbox-any-c-ptr cpu ( dst src -- )
 HOOK: %box-alien cpu ( dst src temp -- )
-HOOK: %box-displaced-alien cpu ( dst displacement base temp1 temp2 base-class -- )
+HOOK: %box-displaced-alien cpu ( dst displacement base temp base-class -- )
 
 HOOK: %alien-unsigned-1 cpu ( dst src offset -- )
 HOOK: %alien-unsigned-2 cpu ( dst src offset -- )
index cd877cfafe733f5178768340ea89d9a9597d4083..7e7de6d4bcb0dd5a6301cac6c954bfb9f1e64c80 100644 (file)
@@ -69,7 +69,7 @@ CONSTANT: rs-reg 14
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg dup 4 SUBI\r
-    0 3 \ f tag-number CMPI\r
+    0 3 \ f type-number CMPI\r
     2 BEQ\r
     0 B rc-relative-ppc-3 rt-xt jit-rel\r
     0 B rc-relative-ppc-3 rt-xt jit-rel\r
@@ -174,40 +174,15 @@ CONSTANT: rs-reg 14
 \r
 [ load-tag ] pic-tag jit-define\r
 \r
-! Hi-tag\r
-[\r
-    3 4 MR\r
-    load-tag\r
-    0 4 object tag-number tag-fixnum CMPI\r
-    2 BNE\r
-    4 3 object tag-number neg LWZ\r
-] pic-hi-tag jit-define\r
-\r
 ! Tuple\r
 [\r
     3 4 MR\r
     load-tag\r
-    0 4 tuple tag-number tag-fixnum CMPI\r
+    0 4 tuple type-number tag-fixnum CMPI\r
     2 BNE\r
-    4 3 tuple tag-number neg bootstrap-cell + LWZ\r
+    4 3 tuple type-number neg bootstrap-cell + LWZ\r
 ] pic-tuple jit-define\r
 \r
-! Hi-tag and tuple\r
-[\r
-    3 4 MR\r
-    load-tag\r
-    ! If bits 2 and 3 are set, the tag is either 6 (object) or 7 (tuple)\r
-    0 4 BIN: 110 tag-fixnum CMPI\r
-    5 BLT\r
-    ! Untag r3\r
-    3 3 0 0 31 tag-bits get - RLWINM\r
-    ! Set r4 to 0 for objects, and bootstrap-cell for tuples\r
-    4 4 1 tag-fixnum ANDI\r
-    4 4 1 SRAWI\r
-    ! Load header cell or tuple layout cell\r
-    4 4 3 LWZX\r
-] pic-hi-tag-tuple jit-define\r
-\r
 [\r
     0 4 0 CMPI rc-absolute-ppc-2 rt-immediate jit-rel\r
 ] pic-check-tag jit-define\r
@@ -215,7 +190,7 @@ CONSTANT: rs-reg 14
 [\r
     0 5 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
     4 0 5 CMP\r
-] pic-check jit-define\r
+] pic-check-tuple jit-define\r
 \r
 [ 2 BNE 0 B rc-relative-ppc-3 rt-xt jit-rel ] pic-hit jit-define\r
 \r
@@ -224,8 +199,8 @@ CONSTANT: rs-reg 14
 [\r
     ! cache = ...\r
     0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
-    ! key = class\r
-    5 4 MR\r
+    ! key = hashcode(class)\r
+    5 4 1 SRAWI\r
     ! key &= cache.length - 1\r
     5 5 mega-cache-size get 1 - bootstrap-cell * ANDI\r
     ! cache += array-start-offset\r
@@ -278,7 +253,7 @@ CONSTANT: rs-reg 14
 [\r
     3 ds-reg 0 LWZ\r
     4 ds-reg -4 LWZU\r
-    3 3 1 SRAWI\r
+    3 3 2 SRAWI\r
     4 4 0 0 31 tag-bits get - RLWINM\r
     4 3 3 LWZX\r
     3 ds-reg 0 STW\r
@@ -349,14 +324,6 @@ CONSTANT: rs-reg 14
     3 ds-reg 4 STWU\r
 ] \ dupd define-sub-primitive\r
 \r
-[\r
-    3 ds-reg 0 LWZ\r
-    4 ds-reg -4 LWZ\r
-    3 ds-reg 4 STWU\r
-    4 ds-reg -4 STW\r
-    3 ds-reg -8 STW\r
-] \ tuck define-sub-primitive\r
-\r
 [\r
     3 ds-reg 0 LWZ\r
     4 ds-reg -4 LWZ\r
@@ -399,7 +366,7 @@ CONSTANT: rs-reg 14
     5 ds-reg -4 LWZU\r
     5 0 4 CMP\r
     2 swap execute( offset -- ) ! magic number\r
-    \ f tag-number 3 LI\r
+    \ f type-number 3 LI\r
     3 ds-reg 0 STW ;\r
 \r
 : define-jit-compare ( insn word -- )\r
@@ -418,7 +385,7 @@ CONSTANT: rs-reg 14
     4 ds-reg 0 LWZ\r
     3 3 4 OR\r
     3 3 tag-mask get ANDI\r
-    \ f tag-number 4 LI\r
+    \ f type-number 4 LI\r
     0 3 0 CMPI\r
     2 BNE\r
     1 tag-fixnum 4 LI\r
@@ -503,7 +470,7 @@ CONSTANT: rs-reg 14
 \r
 [\r
     3 ds-reg 0 LWZ\r
-    3 3 1 SRAWI\r
+    3 3 2 SRAWI\r
     rs-reg 3 3 LWZX\r
     3 ds-reg 0 STW\r
 ] \ get-local define-sub-primitive\r
@@ -511,7 +478,7 @@ CONSTANT: rs-reg 14
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg ds-reg 4 SUBI\r
-    3 3 1 SRAWI\r
+    3 3 2 SRAWI\r
     rs-reg 3 rs-reg SUBF\r
 ] \ drop-locals define-sub-primitive\r
 \r
index cf6517b664739cb052ef723481ba0228bb5f5630..a5250414ab22dbb7abd63ca75ff43e219f2d316e 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: parser layouts system kernel ;
+USING: parser layouts system kernel sequences ;
 IN: bootstrap.ppc
 
 : c-area-size ( -- n ) 10 bootstrap-cells ;
 : lr-save ( -- n ) bootstrap-cell ;
 
-<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
 call
index 0c383c2fb08f77c04665d7f7ccac9c4374a4687f..2aa0ddc4a27f4ec8e5e392e5442add49aea30531 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: parser layouts system kernel ;
+USING: parser layouts system kernel sequences ;
 IN: bootstrap.ppc
 
 : c-area-size ( -- n ) 14 bootstrap-cells ;
 : lr-save ( -- n ) 2 bootstrap-cells ;
 
-<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
 call
index c742cf2ddc2aba25ecef3d8e828626dd4ba0ac87..152a3aa7209e81f1c2f982802c27b5a4fb66ca48 100644 (file)
@@ -4,12 +4,6 @@ USING: accessors system kernel layouts
 alien.c-types cpu.architecture cpu.ppc ;
 IN: cpu.ppc.macosx
 
-<<
-4 "longlong" c-type (>>align)
-4 "ulonglong" c-type (>>align)
-4 "double" c-type (>>align)
->>
-
 M: macosx reserved-area-size 6 cells ;
 
 M: macosx lr-save 2 cells ;
index 517aa7587dcfddec0898937bcae3fe44bcc5e3e0..a7eb3bb4a59f410afcf88b5688cbc00deaa9152b 100644 (file)
@@ -256,95 +256,108 @@ M: ppc %double>single-float FRSP ;
 M: ppc %unbox-alien ( dst src -- )
     alien-offset LWZ ;
 
-M:: ppc %unbox-any-c-ptr ( dst src temp -- )
+M:: ppc %unbox-any-c-ptr ( dst src -- )
     [
-        { "is-byte-array" "end" "start" } [ define-label ] each
-        ! Address is computed in dst
+        "end" define-label
         0 dst LI
-        ! Load object into scratch-reg
-        scratch-reg src MR
-        ! We come back here with displaced aliens
-        "start" resolve-label
         ! Is the object f?
-        0 scratch-reg \ f tag-number CMPI
-        ! If so, done
+        0 src \ f type-number CMPI
         "end" get BEQ
+        ! Compute tag in dst register
+        dst src tag-mask get ANDI
         ! Is the object an alien?
-        0 scratch-reg header-offset LWZ
-        0 0 alien type-number tag-fixnum CMPI
-        "is-byte-array" get BNE
-        ! If so, load the offset
-        0 scratch-reg alien-offset LWZ
-        ! Add it to address being computed
-        dst dst 0 ADD
-        ! Now recurse on the underlying alien
-        scratch-reg scratch-reg underlying-alien-offset LWZ
-        "start" get B
-        "is-byte-array" resolve-label
-        ! Add byte array address to address being computed
-        dst dst scratch-reg ADD
-        ! Add an offset to start of byte array's data area
-        dst dst byte-array-offset ADDI
+        0 dst alien type-number CMPI
+        ! Add an offset to start of byte array's data
+        dst src byte-array-offset ADDI
+        "end" get BNE
+        ! If so, load the offset and add it to the address
+        dst src alien-offset LWZ
         "end" resolve-label
     ] with-scope ;
 
-: alien@ ( n -- n' ) cells object tag-number - ;
-
-:: %allot-alien ( dst displacement base temp -- )
-    dst 4 cells alien temp %allot
-    temp \ f tag-number %load-immediate
-    ! Store underlying-alien slot
-    base dst 1 alien@ STW
-    ! Store expired slot
-    temp dst 2 alien@ STW
-    ! Store offset
-    displacement dst 3 alien@ STW ;
+: alien@ ( n -- n' ) cells alien type-number - ;
 
 M:: ppc %box-alien ( dst src temp -- )
     [
         "f" define-label
-        dst \ f tag-number %load-immediate
+        dst \ f type-number %load-immediate
         0 src 0 CMPI
         "f" get BEQ
-        dst src temp temp %allot-alien
+        dst 5 cells alien temp %allot
+        temp \ f type-number %load-immediate
+        temp dst 1 alien@ STW
+        temp dst 2 alien@ STW
+        src dst 3 alien@ STW
+        src dst 4 alien@ STW
         "f" resolve-label
     ] with-scope ;
 
-M:: ppc %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
+M:: ppc %box-displaced-alien ( dst displacement base temp base-class -- )
+    ! This is ridiculous
     [
         "end" define-label
-        "alloc" define-label
-        "simple-case" define-label
+        "not-f" define-label
+        "not-alien" define-label
+
         ! If displacement is zero, return the base
         dst base MR
         0 displacement 0 CMPI
         "end" get BEQ
-        ! Quickly use displacement' before its needed for real, as allot temporary
-        displacement' :> temp
-        dst 4 cells alien temp %allot
-        ! If base is already a displaced alien, unpack it
-        0 base \ f tag-number CMPI
-        "simple-case" get BEQ
-        temp base header-offset LWZ
-        0 temp alien type-number tag-fixnum CMPI
-        "simple-case" get BNE
-        ! displacement += base.displacement
-        temp base 3 alien@ LWZ
-        displacement' displacement temp ADD
-        ! base = base.base
-        base' base 1 alien@ LWZ
-        "alloc" get B
-        "simple-case" resolve-label
-        displacement' displacement MR
-        base' base MR
-        "alloc" resolve-label
-        ! Store underlying-alien slot
-        base' dst 1 alien@ STW
-        ! Store offset
-        displacement' dst 3 alien@ STW
-        ! Store expired slot (its ok to clobber displacement')
-        temp \ f tag-number %load-immediate
+
+        ! Displacement is non-zero, we're going to be allocating a new
+        ! object
+        dst 5 cells alien temp %allot
+
+        ! Set expired to f
+        temp \ f type-number %load-immediate
         temp dst 2 alien@ STW
+
+        ! Is base f?
+        0 base \ f type-number CMPI
+        "not-f" get BNE
+
+        ! Yes, it is f. Fill in new object
+        base dst 1 alien@ STW
+        displacement dst 3 alien@ STW
+        displacement dst 4 alien@ STW
+
+        "end" get B
+
+        "not-f" resolve-label
+
+        ! Check base type
+        temp base tag-mask get ANDI
+
+        ! Is base an alien?
+        0 temp alien type-number CMPI
+        "not-alien" get BNE
+
+        ! Yes, it is an alien. Set new alien's base to base.base
+        temp base 1 alien@ LWZ
+        temp dst 1 alien@ STW
+
+        ! Compute displacement
+        temp base 3 alien@ LWZ
+        temp temp displacement ADD
+        temp dst 3 alien@ STW
+
+        ! Compute address
+        temp base 4 alien@ LWZ
+        temp temp displacement ADD
+        temp dst 4 alien@ STW
+
+        ! We are done
+        "end" get B
+
+        ! Is base a byte array? It has to be, by now...
+        "not-alien" resolve-label
+
+        base dst 1 alien@ STW
+        displacement dst 3 alien@ STW
+        temp base byte-array-offset ADDI
+        temp temp displacement ADD
+        temp dst 4 alien@ STW
+
         "end" resolve-label
     ] with-scope ;
 
@@ -374,15 +387,15 @@ M: ppc %set-alien-double -rot STFD ;
     [ drop load-zone-ptr ] [ swap 0 LWZ ] 2bi ;
 
 :: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
-    scratch-reg allot-ptr n 8 align ADDI
+    scratch-reg allot-ptr n data-alignment get align ADDI
     scratch-reg nursery-ptr 0 STW ;
 
 :: store-header ( dst class -- )
-    class type-number tag-fixnum scratch-reg LI
+    class type-number tag-header scratch-reg LI
     scratch-reg dst 0 STW ;
 
 : store-tagged ( dst tag -- )
-    dupd tag-number ORI ;
+    dupd type-number ORI ;
 
 M:: ppc %allot ( dst size class nursery-ptr -- )
     nursery-ptr dst load-allot-ptr
@@ -460,7 +473,7 @@ M: ppc %epilogue ( n -- )
 
 :: (%boolean) ( dst temp branch1 branch2 -- )
     "end" define-label
-    dst \ f tag-number %load-immediate
+    dst \ f type-number %load-immediate
     "end" get branch1 execute( label -- )
     branch2 [ "end" get branch2 execute( label -- ) ] when
     dst \ t %load-reference
@@ -504,11 +517,11 @@ M: ppc %compare [ (%compare) ] 2dip %boolean ;
 M: ppc %compare-imm [ (%compare-imm) ] 2dip %boolean ;
 
 M:: ppc %compare-float-ordered ( dst src1 src2 cc temp -- )
-    src1 src2 cc negate-cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
+    src1 src2 cc negate-cc \ (%compare-float-ordered) (%compare-float) :> ( branch1 branch2 )
     dst temp branch1 branch2 (%boolean) ;
 
 M:: ppc %compare-float-unordered ( dst src1 src2 cc temp -- )
-    src1 src2 cc negate-cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
+    src1 src2 cc negate-cc \ (%compare-float-unordered) (%compare-float) :> ( branch1 branch2 )
     dst temp branch1 branch2 (%boolean) ;
 
 :: %branch ( label cc -- )
@@ -534,11 +547,11 @@ M:: ppc %compare-imm-branch ( label src1 src2 cc -- )
     branch2 [ label branch2 execute( label -- ) ] when ; inline
 
 M:: ppc %compare-float-ordered-branch ( label src1 src2 cc -- )
-    src1 src2 cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
+    src1 src2 cc \ (%compare-float-ordered) (%compare-float) :> ( branch1 branch2 )
     label branch1 branch2 (%branch) ;
 
 M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
-    src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
+    src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> ( branch1 branch2 )
     label branch1 branch2 (%branch) ;
 
 : load-from-frame ( dst n rep -- )
@@ -742,14 +755,3 @@ USE: vocabs.loader
 } cond
 
 "complex-double" c-type t >>return-in-registers? drop
-
-[
-    <c-type>
-        [ alien-unsigned-4 c-bool> ] >>getter
-        [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
-        4 >>size
-        4 >>align
-        "box_boolean" >>boxer
-        "to_boolean" >>unboxer
-    bool define-primitive-type
-] with-compilation-unit
index cff5c561c81c39270e9b84de87d6a823bbe7a72e..8867ca659739c009e59e7773f1863ec38bed10f1 100755 (executable)
@@ -11,9 +11,6 @@ cpu.x86.assembler 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.
-
 M: x86.32 machine-registers
     {
         { int-regs { EAX ECX EDX EBP EBX } }
@@ -327,10 +324,4 @@ M: x86.32 dummy-fp-params? f ;
 ! Dreadful
 M: object flatten-value-type (flatten-int-type) ;
 
-os windows? [
-    cell longlong c-type (>>align)
-    cell ulonglong c-type (>>align)
-    4 double c-type (>>align)
-] unless
-
 check-sse
index c5f6975d33b7a731ff655bdc8ed0d6a3f655e5fe..f777040e86fa8599f7b811755016439d1118ee6c 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: bootstrap.image.private kernel namespaces system
 cpu.x86.assembler cpu.x86.assembler.operands layouts
-vocabs parser compiler.constants ;
+vocabs parser compiler.constants sequences ;
 IN: bootstrap.x86
 
 4 \ cell set
@@ -21,7 +21,7 @@ IN: bootstrap.x86
 : stack-reg ( -- reg ) ESP ;
 : ds-reg ( -- reg ) ESI ;
 : rs-reg ( -- reg ) EDI ;
-: fixnum>slot@ ( -- ) temp0 1 SAR ;
+: fixnum>slot@ ( -- ) temp0 2 SAR ;
 : rex-length ( -- n ) 0 ;
 
 [
@@ -35,5 +35,5 @@ IN: bootstrap.x86
     0 JMP rc-relative rt-primitive jit-rel
 ] jit-primitive jit-define
 
-<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
 call
index b42a38b2d2d6feb513b96537361654726758c61c..0fc029fdfee4438875f9f998cad4ef91b1dc33c7 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: bootstrap.image.private kernel namespaces system
 layouts vocabs parser compiler.constants math
-cpu.x86.assembler cpu.x86.assembler.operands ;
+cpu.x86.assembler cpu.x86.assembler.operands sequences ;
 IN: bootstrap.x86
 
 8 \ cell set
@@ -18,7 +18,7 @@ IN: bootstrap.x86
 : stack-reg ( -- reg ) RSP ;
 : ds-reg ( -- reg ) R14 ;
 : rs-reg ( -- reg ) R15 ;
-: fixnum>slot@ ( -- ) ;
+: fixnum>slot@ ( -- ) temp0 1 SAR ;
 : rex-length ( -- n ) 1 ;
 
 [
@@ -35,5 +35,5 @@ IN: bootstrap.x86
     temp1 JMP
 ] jit-primitive jit-define
 
-<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
 call
index 2ad3a721af0ae082cecb906161b4c22c30e993aa..238fad984a86420115d186df8433a648f64c05e4 100644 (file)
@@ -1,12 +1,13 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: bootstrap.image.private kernel namespaces system
-cpu.x86.assembler cpu.x86.assembler.operands layouts vocabs parser ;
+USING: bootstrap.image.private cpu.x86.assembler
+cpu.x86.assembler.operands kernel layouts namespaces parser
+sequences system vocabs ;
 IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 4 bootstrap-cells ;
 : arg1 ( -- reg ) RDI ;
 : arg2 ( -- reg ) RSI ;
 
-<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
 call
index 2dd3e889a554abc9392aaaeaa771df520084177c..2e3944fcaf10177c88e8158b02fff2388b8356cb 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: bootstrap.image.private kernel namespaces system
-layouts vocabs parser cpu.x86.assembler
+layouts vocabs parser sequences cpu.x86.assembler parser
 cpu.x86.assembler.operands ;
 IN: bootstrap.x86
 
@@ -9,5 +9,5 @@ IN: bootstrap.x86
 : arg1 ( -- reg ) RCX ;
 : arg2 ( -- reg ) RDX ;
 
-<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
 call
index 3ecd56bdd1c88e9879ad909fa9bae9d58511d3a8..a398c6565c651d383b783171e313fcd909f81a34 100644 (file)
@@ -24,9 +24,3 @@ M: x86.64 dummy-fp-params? t ;
 
 M: x86.64 temp-reg RAX ;
 
-<<
-longlong ptrdiff_t typedef
-longlong intptr_t  typedef
-int  c-type long  define-primitive-type
-uint c-type ulong define-primitive-type
->>
index df49ae0a15f8c085cce8881b638158fb0db8c009..bd9a3f6cddff869c2b899b93f8ceca6d2a302636 100644 (file)
@@ -65,7 +65,7 @@ M: indirect extended? base>> extended? ;
 ERROR: bad-index indirect ;
 
 : check-ESP ( indirect -- indirect )
-    dup index>> { ESP RSP } memq? [ bad-index ] when ;
+    dup index>> { ESP RSP } member-eq? [ bad-index ] when ;
 
 : canonicalize ( indirect -- indirect )
     #! Modify the indirect to work around certain addressing mode
@@ -103,7 +103,7 @@ TUPLE: byte value ;
 C: <byte> byte
 
 : extended-8-bit-register? ( register -- ? )
-    { SPL BPL SIL DIL } memq? ;
+    { SPL BPL SIL DIL } member-eq? ;
 
 : n-bit-version-of ( register n -- register' )
     ! Certain 8-bit registers don't exist in 32-bit mode...
@@ -115,4 +115,4 @@ C: <byte> byte
 : 16-bit-version-of ( register -- register' ) 16 n-bit-version-of ;
 : 32-bit-version-of ( register -- register' ) 32 n-bit-version-of ;
 : 64-bit-version-of ( register -- register' ) 64 n-bit-version-of ;
-: native-version-of ( register -- register' ) cell-bits n-bit-version-of ;
\ No newline at end of file
+: native-version-of ( register -- register' ) cell-bits n-bit-version-of ;
index fb94445f780bac9944012a3dc906111cbe67eb7c..c993a1fdeca988b94cf5b253359b51ac23cc6030 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: bootstrap.image.private kernel kernel.private namespaces system
-layouts compiler.units math math.private compiler.constants vocabs
-slots.private words locals.backend make sequences combinators arrays
- cpu.x86.assembler cpu.x86.assembler.operands ;
+USING: bootstrap.image.private compiler.constants
+compiler.units cpu.x86.assembler cpu.x86.assembler.operands
+kernel kernel.private layouts locals.backend make math
+math.private namespaces sequences slots.private vocabs ;
 IN: bootstrap.x86
 
 big-endian off
@@ -60,7 +60,7 @@ big-endian off
     ! pop boolean
     ds-reg bootstrap-cell SUB
     ! compare boolean with f
-    temp0 \ f tag-number CMP
+    temp0 \ f type-number CMP
     ! jump to true branch if not equal
     0 JNE rc-relative rt-xt jit-rel
     ! jump to false branch if equal
@@ -154,7 +154,7 @@ big-endian off
 
 ! ! ! Polymorphic inline caches
 
-! The PIC and megamorphic code stubs are not permitted to touch temp3.
+! The PIC stubs are not permitted to touch temp3.
 
 ! Load a value from a stack position
 [
@@ -171,41 +171,15 @@ big-endian off
 ! The 'make' trick lets us compute the jump distance for the
 ! conditional branches there
 
-! Hi-tag
-[
-    temp0 temp1 MOV
-    load-tag
-    temp1 object tag-number tag-fixnum CMP
-    [ temp1 temp0 object tag-number neg [+] MOV ] { } make
-    [ length JNE ] [ % ] bi
-] pic-hi-tag jit-define
-
 ! Tuple
 [
     temp0 temp1 MOV
     load-tag
-    temp1 tuple tag-number tag-fixnum CMP
-    [ temp1 temp0 tuple tag-number neg bootstrap-cell + [+] MOV ] { } make
+    temp1 tuple type-number tag-fixnum CMP
+    [ temp1 temp0 tuple type-number neg bootstrap-cell + [+] MOV ] { } make
     [ length JNE ] [ % ] bi
 ] pic-tuple jit-define
 
-! Hi-tag and tuple
-[
-    temp0 temp1 MOV
-    load-tag
-    ! If bits 2 and 3 are set, the tag is either 6 (object) or 7 (tuple)
-    temp1 BIN: 110 tag-fixnum CMP
-    [
-        ! Untag temp0
-        temp0 tag-mask get bitnot AND
-        ! Set temp1 to 0 for objects, and bootstrap-cell for tuples
-        temp1 1 tag-fixnum AND
-        bootstrap-cell 4 = [ temp1 1 SHR ] when
-        ! Load header cell or tuple layout cell
-        temp1 temp0 temp1 [+] MOV
-    ] [ ] make [ length JL ] [ % ] bi
-] pic-hi-tag-tuple jit-define
-
 [
     temp1 HEX: ffffffff CMP rc-absolute rt-immediate jit-rel
 ] pic-check-tag jit-define
@@ -213,7 +187,7 @@ big-endian off
 [
     temp2 HEX: ffffffff MOV rc-absolute-cell rt-immediate jit-rel
     temp1 temp2 CMP
-] pic-check jit-define
+] pic-check-tuple jit-define
 
 [ 0 JE rc-relative rt-xt jit-rel ] pic-hit jit-define
 
@@ -222,9 +196,9 @@ big-endian off
 [
     ! cache = ...
     temp0 0 MOV rc-absolute-cell rt-immediate jit-rel
-    ! key = class
+    ! key = hashcode(class)
     temp2 temp1 MOV
-    bootstrap-cell 8 = [ temp2 1 SHL ] when
+    bootstrap-cell 4 = [ temp2 1 SHR ] when
     ! key &= cache.length - 1
     temp2 mega-cache-size get 1 - bootstrap-cell * AND
     ! cache += array-start-offset
@@ -361,15 +335,6 @@ big-endian off
     ds-reg [] temp0 MOV
 ] \ dupd define-sub-primitive
 
-[
-    temp0 ds-reg [] MOV
-    temp1 ds-reg -1 bootstrap-cells [+] MOV
-    ds-reg bootstrap-cell ADD
-    ds-reg [] temp0 MOV
-    ds-reg -1 bootstrap-cells [+] temp1 MOV
-    ds-reg -2 bootstrap-cells [+] temp0 MOV
-] \ tuck define-sub-primitive
-
 [
     temp0 ds-reg [] MOV
     temp1 ds-reg bootstrap-cell neg [+] MOV
@@ -410,7 +375,7 @@ big-endian off
     t jit-literal
     temp3 0 MOV rc-absolute-cell rt-immediate jit-rel
     ! load f
-    temp1 \ f tag-number MOV
+    temp1 \ f type-number MOV
     ! load first value
     temp0 ds-reg [] MOV
     ! adjust stack pointer
@@ -540,7 +505,7 @@ big-endian off
     ds-reg bootstrap-cell SUB
     temp0 ds-reg [] OR
     temp0 tag-mask get AND
-    temp0 \ f tag-number MOV
+    temp0 \ f type-number MOV
     temp1 1 tag-fixnum MOV
     temp0 temp1 CMOVE
     ds-reg [] temp0 MOV
index 1f5afffe5de49d110fdeec86257de507111ee612..86006f843ec11f57397d4f9d73222d5a1fa6b06f 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors assocs alien alien.c-types arrays strings
 cpu.x86.assembler cpu.x86.assembler.private cpu.x86.assembler.operands
 cpu.x86.features cpu.x86.features.private cpu.architecture kernel
 kernel.private math memory namespaces make sequences words system
-layouts combinators math.order fry locals compiler.constants
+layouts combinators math.order math.vectors fry locals compiler.constants
 byte-arrays io macros quotations compiler compiler.units init vm
 compiler.cfg.registers
 compiler.cfg.instructions
@@ -45,8 +45,7 @@ HOOK: extra-stack-space cpu ( stack-frame -- n )
 : incr-stack-reg ( n -- )
     dup 0 = [ drop ] [ stack-reg swap ADD ] if ;
 
-: align-stack ( n -- n' )
-    os macosx? cpu x86.64? or [ 16 align ] when ;
+: align-stack ( n -- n' ) 16 align ;
 
 M: x86 stack-frame-size ( stack-frame -- i )
     [ (stack-frame-size) ]
@@ -141,20 +140,27 @@ M: x86 %not     int-rep one-operand NOT ;
 M: x86 %neg     int-rep one-operand NEG ;
 M: x86 %log2    BSR ;
 
+! A bit of logic to avoid using MOVSS/MOVSD for reg-reg moves
+! since this induces partial register stalls
 GENERIC: copy-register* ( dst src rep -- )
+GENERIC: copy-memory* ( dst src rep -- )
 
 M: int-rep copy-register* drop MOV ;
 M: tagged-rep copy-register* drop MOV ;
-M: float-rep copy-register* drop MOVSS ;
-M: double-rep copy-register* drop MOVSD ;
-M: float-4-rep copy-register* drop MOVUPS ;
-M: double-2-rep copy-register* drop MOVUPD ;
-M: vector-rep copy-register* drop MOVDQU ;
+M: float-rep copy-register* drop MOVAPS ;
+M: double-rep copy-register* drop MOVAPS ;
+M: float-4-rep copy-register* drop MOVAPS ;
+M: double-2-rep copy-register* drop MOVAPS ;
+M: vector-rep copy-register* drop MOVDQA ;
+
+M: object copy-memory* copy-register* ;
+M: float-rep copy-memory* drop MOVSS ;
+M: double-rep copy-memory* drop MOVSD ;
 
 M: x86 %copy ( dst src rep -- )
     2over eq? [ 3drop ] [
         [ [ dup spill-slot? [ n>> spill@ ] when ] bi@ ] dip
-        copy-register*
+        2over [ register? ] both? [ copy-register* ] [ copy-memory* ] if
     ] if ;
 
 M: x86 %fixnum-add ( label dst src1 src2 -- )
@@ -169,76 +175,109 @@ M: x86 %fixnum-mul ( label dst src1 src2 -- )
 M: x86 %unbox-alien ( dst src -- )
     alien-offset [+] MOV ;
 
-M:: x86 %unbox-any-c-ptr ( dst src temp -- )
+M:: x86 %unbox-any-c-ptr ( dst src -- )
     [
-        { "is-byte-array" "end" "start" } [ define-label ] each
-        dst 0 MOV
-        temp src MOV
-        ! We come back here with displaced aliens
-        "start" resolve-label
+        "end" define-label
+        dst dst XOR
         ! Is the object f?
-        temp \ f tag-number CMP
+        src \ f type-number CMP
         "end" get JE
+        ! Compute tag in dst register
+        dst src MOV
+        dst tag-mask get AND
         ! Is the object an alien?
-        temp header-offset [+] alien type-number tag-fixnum CMP
-        "is-byte-array" get JNE
-        ! If so, load the offset and add it to the address
-        dst temp alien-offset [+] ADD
-        ! Now recurse on the underlying alien
-        temp temp underlying-alien-offset [+] MOV
-        "start" get JMP
-        "is-byte-array" resolve-label
-        ! Add byte array address to address being computed
-        dst temp ADD
+        dst alien type-number CMP
         ! Add an offset to start of byte array's data
-        dst byte-array-offset ADD
+        dst src byte-array-offset [+] LEA
+        "end" get JNE
+        ! If so, load the offset and add it to the address
+        dst src alien-offset [+] MOV
         "end" resolve-label
     ] with-scope ;
 
-: alien@ ( reg n -- op ) cells alien tag-number - [+] ;
-
-:: %allot-alien ( dst displacement base temp -- )
-    dst 4 cells alien temp %allot
-    dst 1 alien@ base MOV ! alien
-    dst 2 alien@ \ f tag-number MOV ! expired
-    dst 3 alien@ displacement MOV ! displacement
-    ;
+: alien@ ( reg n -- op ) cells alien type-number - [+] ;
 
 M:: x86 %box-alien ( dst src temp -- )
     [
         "end" define-label
-        dst \ f tag-number MOV
-        src 0 CMP
+        dst \ f type-number MOV
+        src src TEST
         "end" get JE
-        dst src \ f tag-number temp %allot-alien
+        dst 5 cells alien temp %allot
+        dst 1 alien@ \ f type-number MOV ! base
+        dst 2 alien@ \ f type-number MOV ! expired
+        dst 3 alien@ src MOV ! displacement
+        dst 4 alien@ src MOV ! address
         "end" resolve-label
     ] with-scope ;
 
-M:: x86 %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
+M:: x86 %box-displaced-alien ( dst displacement base temp base-class -- )
+    ! This is ridiculous
     [
         "end" define-label
-        "ok" define-label
+        "not-f" define-label
+        "not-alien" define-label
+
         ! If displacement is zero, return the base
         dst base MOV
-        displacement 0 CMP
+        displacement displacement TEST
         "end" get JE
-        ! Quickly use displacement' before its needed for real, as allot temporary
-        dst 4 cells alien displacement' %allot
-        ! If base is already a displaced alien, unpack it
-        base' base MOV
-        displacement' displacement MOV
-        base \ f tag-number CMP
-        "ok" get JE
-        base header-offset [+] alien type-number tag-fixnum CMP
-        "ok" get JNE
-        ! displacement += base.displacement
-        displacement' base 3 alien@ ADD
-        ! base = base.base
-        base' base 1 alien@ MOV
-        "ok" resolve-label
-        dst 1 alien@ base' MOV ! alien
-        dst 2 alien@ \ f tag-number MOV ! expired
-        dst 3 alien@ displacement' MOV ! displacement
+
+        ! Displacement is non-zero, we're going to be allocating a new
+        ! object
+        dst 5 cells alien temp %allot
+
+        ! Set expired to f
+        dst 2 alien@ \ f type-number MOV
+
+        ! Is base f?
+        base \ f type-number CMP
+        "not-f" get JNE
+
+        ! Yes, it is f. Fill in new object
+        dst 1 alien@ base MOV
+        dst 3 alien@ displacement MOV
+        dst 4 alien@ displacement MOV
+
+        "end" get JMP
+
+        "not-f" resolve-label
+
+        ! Check base type
+        temp base MOV
+        temp tag-mask get AND
+
+        ! Is base an alien?
+        temp alien type-number CMP
+        "not-alien" get JNE
+
+        ! Yes, it is an alien. Set new alien's base to base.base
+        temp base 1 alien@ MOV
+        dst 1 alien@ temp MOV
+
+        ! Compute displacement
+        temp base 3 alien@ MOV
+        temp displacement ADD
+        dst 3 alien@ temp MOV
+
+        ! Compute address
+        temp base 4 alien@ MOV
+        temp displacement ADD
+        dst 4 alien@ temp MOV
+
+        ! We are done
+        "end" get JMP
+
+        ! Is base a byte array? It has to be, by now...
+        "not-alien" resolve-label
+
+        dst 1 alien@ base MOV
+        dst 3 alien@ displacement MOV
+        temp base MOV
+        temp byte-array-offset ADD
+        temp displacement ADD
+        dst 4 alien@ temp MOV
+
         "end" resolve-label
     ] with-scope ;
 
@@ -254,7 +293,7 @@ CONSTANT: have-byte-regs { EAX ECX EDX EBX }
 
 M: x86.32 has-small-reg?
     {
-        { 8 [ have-byte-regs memq? ] }
+        { 8 [ have-byte-regs member-eq? ] }
         { 16 [ drop t ] }
         { 32 [ drop t ] }
     } case ;
@@ -264,7 +303,7 @@ M: x86.64 has-small-reg? 2drop t ;
 : small-reg-that-isn't ( exclude -- reg' )
     [ have-byte-regs ] dip
     [ native-version-of ] map
-    '[ _ memq? not ] find nip ;
+    '[ _ member-eq? not ] find nip ;
 
 : with-save/restore ( reg quot -- )
     [ drop PUSH ] [ call ] [ drop POP ] 2tri ; inline
@@ -356,7 +395,7 @@ M: x86 %set-alien-float [ [+] ] dip MOVSS ;
 M: x86 %set-alien-double [ [+] ] dip MOVSD ;
 M: x86 %set-alien-vector [ [+] ] 2dip %copy ;
 
-: shift-count? ( reg -- ? ) { ECX RCX } memq? ;
+: shift-count? ( reg -- ? ) { ECX RCX } member-eq? ;
 
 :: emit-shift ( dst src quot -- )
     src shift-count? [
@@ -388,13 +427,13 @@ M: x86 %vm-field-ptr ( dst field -- )
     [ drop "nursery" %vm-field-ptr ] [ swap [] MOV ] 2bi ;
 
 : inc-allot-ptr ( nursery-ptr n -- )
-    [ [] ] dip 8 align ADD ;
+    [ [] ] dip data-alignment get align ADD ;
 
 : store-header ( temp class -- )
-    [ [] ] [ type-number tag-fixnum ] bi* MOV ;
+    [ [] ] [ type-number tag-header ] bi* MOV ;
 
 : store-tagged ( dst tag -- )
-    tag-number OR ;
+    type-number OR ;
 
 M:: x86 %allot ( dst size class nursery-ptr -- )
     nursery-ptr dst load-allot-ptr
@@ -436,7 +475,7 @@ M: x86 %alien-global ( dst symbol library -- )
 M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
 
 :: %boolean ( dst temp word -- )
-    dst \ f tag-number MOV
+    dst \ f type-number MOV
     temp 0 MOV \ t rc-absolute-cell rel-immediate
     dst temp word execute ; inline
 
@@ -481,10 +520,13 @@ M: x86 %min-float double-rep two-operand MINSD ;
 M: x86 %max-float double-rep two-operand MAXSD ;
 M: x86 %sqrt SQRTSD ;
 
-M: x86 %single>double-float CVTSS2SD ;
-M: x86 %double>single-float CVTSD2SS ;
+: %clear-unless-in-place ( dst src -- )
+    over = [ drop ] [ dup XORPS ] if ;
 
-M: x86 %integer>float CVTSI2SD ;
+M: x86 %single>double-float [ %clear-unless-in-place ] [ CVTSS2SD ] 2bi ;
+M: x86 %double>single-float [ %clear-unless-in-place ] [ CVTSD2SS ] 2bi ;
+
+M: x86 %integer>float [ drop dup XORPS ] [ CVTSI2SD ] 2bi ;
 M: x86 %float>integer CVTTSD2SI ;
 
 : %cmov-float= ( dst src -- )
@@ -583,7 +625,7 @@ M: x86 %alien-vector-reps
 
 M: x86 %zero-vector
     {
-        { double-2-rep [ dup XORPD ] }
+        { double-2-rep [ dup XORPS ] }
         { float-4-rep [ dup XORPS ] }
         [ drop dup PXOR ]
     } case ;
@@ -596,7 +638,7 @@ M: x86 %zero-vector-reps
 
 M: x86 %fill-vector
     {
-        { double-2-rep [ dup [ XORPD ] [ CMPEQPD ] 2bi ] }
+        { double-2-rep [ dup [ XORPS ] [ CMPEQPS ] 2bi ] }
         { float-4-rep  [ dup [ XORPS ] [ CMPEQPS ] 2bi ] }
         [ drop dup PCMPEQB ]
     } case ;
@@ -671,7 +713,7 @@ M:: x86 %gather-vector-2 ( dst src1 src2 rep -- )
     rep unsign-rep {
         { double-2-rep [
             dst src1 double-2-rep %copy
-            dst src2 UNPCKLPD
+            dst src2 MOVLHPS
         ] }
         { longlong-2-rep [
             dst src1 longlong-2-rep %copy
@@ -684,14 +726,6 @@ M: x86 %gather-vector-2-reps
         { sse2? { double-2-rep longlong-2-rep ulonglong-2-rep } }
     } available-reps ;
 
-: double-2-shuffle ( dst shuffle -- )
-    {
-        { { 0 1 } [ drop ] }
-        { { 0 0 } [ dup UNPCKLPD ] }
-        { { 1 1 } [ dup UNPCKHPD ] }
-        [ dupd SHUFPD ]
-    } case ;
-
 : sse1-float-4-shuffle ( dst shuffle -- )
     {
         { { 0 1 2 3 } [ drop ] }
@@ -724,10 +758,13 @@ M: x86 %gather-vector-2-reps
 : longlong-2-shuffle ( dst shuffle -- )
     first2 [ 2 * dup 1 + ] bi@ 4array int-4-shuffle ;
 
+: >float-4-shuffle ( double-2-shuffle -- float-4-shuffle )
+    [ 2 * { 0 1 } n+v ] map concat ;
+
 M:: x86 %shuffle-vector-imm ( dst src shuffle rep -- )
     dst src rep %copy
     dst shuffle rep unsign-rep {
-        { double-2-rep [ double-2-shuffle ] }
+        { double-2-rep [ >float-4-shuffle float-4-shuffle ] }
         { float-4-rep [ float-4-shuffle ] }
         { int-4-rep [ int-4-shuffle ] }
         { longlong-2-rep [ longlong-2-shuffle ] }
@@ -750,7 +787,7 @@ M: x86 %shuffle-vector-reps
 M: x86 %merge-vector-head
     [ two-operand ] keep
     unsign-rep {
-        { double-2-rep   [ UNPCKLPD ] }
+        { double-2-rep   [ MOVLHPS ] }
         { float-4-rep    [ UNPCKLPS ] }
         { longlong-2-rep [ PUNPCKLQDQ ] }
         { int-4-rep      [ PUNPCKLDQ ] }
@@ -802,8 +839,8 @@ M: x86 %unsigned-pack-vector-reps
 
 M: x86 %tail>head-vector ( dst src rep -- )
     dup {
-        { float-4-rep [ drop MOVHLPS ] }
-        { double-2-rep [ [ %copy ] [ drop UNPCKHPD ] 3bi ] }
+        { float-4-rep [ drop UNPCKHPD ] }
+        { double-2-rep [ drop UNPCKHPD ] }
         [ drop [ %copy ] [ drop PUNPCKHQDQ ] 3bi ]
     } case ;
 
@@ -888,12 +925,12 @@ M: x86 %compare-vector ( dst src1 src2 rep cc -- )
     {
         { sse? { float-4-rep } }
         { sse2? { double-2-rep char-16-rep short-8-rep int-4-rep } }
-        { sse4.1? { longlong-2-rep } }
+        { sse4.2? { longlong-2-rep } }
     } available-reps ;
 
 M: x86 %compare-vector-reps
     {
-        { [ dup { cc= cc/= } memq? ] [ drop %compare-vector-eq-reps ] }
+        { [ dup { cc= cc/= cc/<>= cc<>= } member-eq? ] [ drop %compare-vector-eq-reps ] }
         [ drop %compare-vector-ord-reps ]
     } cond ;
 
@@ -942,7 +979,7 @@ M: x86 %compare-vector-ccs
 
 : %move-vector-mask ( dst src rep -- mask )
     {
-        { double-2-rep [ MOVMSKPD HEX: 3 ] }
+        { double-2-rep [ MOVMSKPS HEX: f ] }
         { float-4-rep  [ MOVMSKPS HEX: f ] }
         [ drop PMOVMSKB HEX: ffff ]
     } case ;
@@ -1098,7 +1135,7 @@ M: x86 %min-vector ( dst src1 src2 rep -- )
 M: x86 %min-vector-reps
     {
         { sse? { float-4-rep } }
-        { sse2? { uchar-16-rep short-8-rep double-2-rep short-8-rep uchar-16-rep } }
+        { sse2? { uchar-16-rep short-8-rep double-2-rep } }
         { sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
     } available-reps ;
 
@@ -1118,7 +1155,7 @@ M: x86 %max-vector ( dst src1 src2 rep -- )
 M: x86 %max-vector-reps
     {
         { sse? { float-4-rep } }
-        { sse2? { uchar-16-rep short-8-rep double-2-rep short-8-rep uchar-16-rep } }
+        { sse2? { uchar-16-rep short-8-rep double-2-rep } }
         { sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
     } available-reps ;
 
@@ -1155,18 +1192,18 @@ M: x86 %horizontal-add-vector-reps
         { sse3? { float-4-rep double-2-rep } }
     } available-reps ;
 
-M: x86 %horizontal-shl-vector ( dst src1 src2 rep -- )
+M: x86 %horizontal-shl-vector-imm ( dst src1 src2 rep -- )
     two-operand PSLLDQ ;
 
-M: x86 %horizontal-shl-vector-reps
+M: x86 %horizontal-shl-vector-imm-reps
     {
         { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
     } available-reps ;
 
-M: x86 %horizontal-shr-vector ( dst src1 src2 rep -- )
+M: x86 %horizontal-shr-vector-imm ( dst src1 src2 rep -- )
     two-operand PSRLDQ ;
 
-M: x86 %horizontal-shr-vector-reps
+M: x86 %horizontal-shr-vector-imm-reps
     {
         { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
     } available-reps ;
@@ -1199,7 +1236,7 @@ M: x86 %and-vector ( dst src1 src2 rep -- )
     [ two-operand ] keep
     {
         { float-4-rep [ ANDPS ] }
-        { double-2-rep [ ANDPD ] }
+        { double-2-rep [ ANDPS ] }
         [ drop PAND ]
     } case ;
 
@@ -1213,7 +1250,7 @@ M: x86 %andn-vector ( dst src1 src2 rep -- )
     [ two-operand ] keep
     {
         { float-4-rep [ ANDNPS ] }
-        { double-2-rep [ ANDNPD ] }
+        { double-2-rep [ ANDNPS ] }
         [ drop PANDN ]
     } case ;
 
@@ -1227,7 +1264,7 @@ M: x86 %or-vector ( dst src1 src2 rep -- )
     [ two-operand ] keep
     {
         { float-4-rep [ ORPS ] }
-        { double-2-rep [ ORPD ] }
+        { double-2-rep [ ORPS ] }
         [ drop POR ]
     } case ;
 
@@ -1241,7 +1278,7 @@ M: x86 %xor-vector ( dst src1 src2 rep -- )
     [ two-operand ] keep
     {
         { float-4-rep [ XORPS ] }
-        { double-2-rep [ XORPD ] }
+        { double-2-rep [ XORPS ] }
         [ drop PXOR ]
     } case ;
 
@@ -1282,6 +1319,11 @@ M: x86 %shr-vector-reps
         { sse2? { short-8-rep ushort-8-rep int-4-rep uint-4-rep ulonglong-2-rep } }
     } available-reps ;
 
+M: x86 %shl-vector-imm %shl-vector ;
+M: x86 %shl-vector-imm-reps %shl-vector-reps ;
+M: x86 %shr-vector-imm %shr-vector ;
+M: x86 %shr-vector-imm-reps %shr-vector-reps ;
+
 : scalar-sized-reg ( reg rep -- reg' )
     rep-size 8 * n-bit-version-of ;
 
index 6ba8e2d5b8a965b67767fc7400ce751aed0c3892..829637b4aa18b2e916ac4e6f9aed77d954ffdf4c 100644 (file)
@@ -70,11 +70,12 @@ IN: csv.tests
 
 "can write csv too!"
 [ "foo1,bar1\nfoo2,bar2\n" ]
-[ { { "foo1" "bar1" } { "foo2" "bar2" } } <string-writer> tuck write-csv >string ] named-unit-test
+[ { { "foo1" "bar1" } { "foo2" "bar2" } } <string-writer> [ write-csv ] keep >string ] named-unit-test
+
 
 "escapes quotes commas and newlines when writing"
 [ "\"fo\"\"o1\",bar1\n\"fo\no2\",\"b,ar2\"\n" ]
-[ { { "fo\"o1" "bar1" } { "fo\no2" "b,ar2" } } <string-writer> tuck write-csv >string ] named-unit-test ! "
+[ { { "fo\"o1" "bar1" } { "fo\no2" "b,ar2" } } <string-writer> [ write-csv ] keep >string ] named-unit-test ! "
 
 [ { { "writing" "some" "csv" "tests" } } ]
 [
index 61394391a00cc5b285ba30e406bc58f0d83e68e9..c180df9bf545f9deab319365946ad5c3980a61f1 100644 (file)
@@ -99,8 +99,8 @@ CONSTANT: SQLITE_OPEN_TEMP_JOURNAL     HEX: 00001000
 CONSTANT: SQLITE_OPEN_SUBJOURNAL       HEX: 00002000
 CONSTANT: SQLITE_OPEN_MASTER_JOURNAL   HEX: 00004000
 
-TYPEDEF: void sqlite3
-TYPEDEF: void sqlite3_stmt
+TYPEDEF: void* sqlite3*
+TYPEDEF: void* sqlite3_stmt*
 TYPEDEF: longlong sqlite3_int64
 TYPEDEF: ulonglong sqlite3_uint64
 
@@ -120,8 +120,8 @@ FUNCTION: int sqlite3_bind_int ( sqlite3_stmt* pStmt, int index, int n ) ;
 FUNCTION: int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_int64 n ) ;
 ! Bind the same function as above, but for unsigned 64bit integers
 : sqlite3-bind-uint64 ( pStmt index in64 -- int )
-    "int" "sqlite" "sqlite3_bind_int64"
-    { "sqlite3_stmt*" "int" "sqlite3_uint64" } alien-invoke ;
+    int "sqlite" "sqlite3_bind_int64"
+    { sqlite3_stmt* int sqlite3_uint64 } alien-invoke ;
 FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n ) ;
 FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, char* text, int len, int destructor ) ;
 FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, char* name ) ;
@@ -134,8 +134,8 @@ FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ;
 ! Bind the same function as above, but for unsigned 64bit integers
 : sqlite3-column-uint64 ( pStmt col -- uint64 )
-    "sqlite3_uint64" "sqlite" "sqlite3_column_int64"
-    { "sqlite3_stmt*" "int" } alien-invoke ;
+    sqlite3_uint64 "sqlite" "sqlite3_column_int64"
+    { sqlite3_stmt* int } alien-invoke ;
 FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: char* sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: char* sqlite3_column_text ( sqlite3_stmt* pStmt, int col ) ;
index ffcbec70d08340f8b0456c71034c2aa61a207660..8d26d3b098c185a2fdcb5bf016c865dcd6a81bf4 100755 (executable)
@@ -4,7 +4,7 @@ USING: alien arrays assocs classes compiler db hashtables
 io.files kernel math math.parser namespaces prettyprint fry
 sequences strings classes.tuple alien.c-types continuations
 db.sqlite.lib db.sqlite.ffi db.tuples words db.types combinators
-math.intervals io nmake accessors vectors math.ranges random
+math.intervals io locals nmake accessors vectors math.ranges random
 math.bitwise db.queries destructors db.tuples.private interpolate
 io.streams.string make db.private sequences.deep
 db.errors.sqlite ;
@@ -85,12 +85,11 @@ M: literal-bind sqlite-bind-conversion ( tuple literal-bind -- array )
     nip [ key>> ] [ value>> ] [ type>> ] tri
     <sqlite-low-level-binding> ;
 
-M: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array )
-    tuck
-    [ generator-singleton>> eval-generator tuck ] [ slot-name>> ] bi
-    rot set-slot-named
-    [ [ key>> ] [ type>> ] bi ] dip
-    swap <sqlite-low-level-binding> ;
+M:: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array )
+    generate-bind generator-singleton>> eval-generator :> obj
+    generate-bind slot-name>> :> name
+    obj name tuple set-slot-named
+    generate-bind key>> obj generate-bind type>> <sqlite-low-level-binding> ;
 
 M: sqlite-statement bind-tuple ( tuple statement -- )
     [
index 87e70d69e7e64baa662de1cd298dc628bb26dae2..4bcd9c5b789fa2edd3cbf08a48fd8ba9429cad77 100644 (file)
@@ -129,9 +129,6 @@ HELP: c-string-error.
 HELP: ffi-error.
 { $error-description "Thrown by " { $link dlopen } " and " { $link dlsym } " if a problem occurs while loading a native library or looking up a symbol. See " { $link "alien" } "." } ;
 
-HELP: heap-scan-error.
-{ $error-description "Thrown if " { $link next-object } " is called outside of a " { $link begin-scan } "/" { $link end-scan } " pair." } ;
-
 HELP: undefined-symbol-error.
 { $error-description "Thrown if a previously-compiled " { $link alien-invoke } " call refers to a native library symbol which no longer exists." } ;
 
index 48888968662880fc6b69996c994cd31e51f99640..5c76216c4fdf402b8402595d189250ba4218ccef 100644 (file)
@@ -8,21 +8,27 @@ continuations.private combinators generic.math classes.builtin classes
 compiler.units generic.standard generic.single vocabs init
 kernel.private io.encodings accessors math.order destructors
 source-files parser classes.tuple.parser effects.parser lexer
-generic.parser strings.parser vocabs.loader vocabs.parser see
+generic.parser strings.parser vocabs.loader vocabs.parser
 source-files.errors ;
 IN: debugger
 
-GENERIC: error. ( error -- )
 GENERIC: error-help ( error -- topic )
 
-M: object error. . ;
-
 M: object error-help drop f ;
 
 M: tuple error-help class ;
 
+M: source-file-error error-help error>> error-help ;
+
+GENERIC: error. ( error -- )
+
+M: object error. short. ;
+
 M: string error. print ;
 
+: traceback-link. ( continuation -- )
+    "[" write [ "Traceback" ] dip write-object "]" print ;
+
 : :s ( -- )
     error-continuation get data>> stack. ;
 
@@ -100,9 +106,6 @@ HOOK: signal-error. os ( obj -- )
 : ffi-error. ( obj -- )
     "FFI error" print drop ;
 
-: heap-scan-error. ( obj -- )
-    "Cannot do next-object outside begin/end-scan" print drop ;
-
 : undefined-symbol-error. ( obj -- )
     "The image refers to a library or symbol that was not found at load time"
     print drop ;
@@ -145,14 +148,13 @@ PREDICATE: vm-error < array
         { 6  [ array-size-error.       ] }
         { 7  [ c-string-error.         ] }
         { 8  [ ffi-error.              ] }
-        { 9  [ heap-scan-error.        ] }
-        { 10 [ undefined-symbol-error. ] }
-        { 11 [ datastack-underflow.    ] }
-        { 12 [ datastack-overflow.     ] }
-        { 13 [ retainstack-underflow.  ] }
-        { 14 [ retainstack-overflow.   ] }
-        { 15 [ memory-error.           ] }
-        { 16 [ fp-trap-error.          ] }
+        { 9  [ undefined-symbol-error. ] }
+        { 10 [ datastack-underflow.    ] }
+        { 11 [ datastack-overflow.     ] }
+        { 12 [ retainstack-underflow.  ] }
+        { 13 [ retainstack-overflow.   ] }
+        { 14 [ memory-error.           ] }
+        { 15 [ fp-trap-error.          ] }
     } ; inline
 
 M: vm-error summary drop "VM error" ;
@@ -331,6 +333,8 @@ M: not-found-in-roots summary drop "Cannot resolve vocab: path" ;
 
 M: wrong-values summary drop "Quotation called with wrong stack effect" ;
 
+M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ;
+
 {
     { [ os windows? ] [ "debugger.windows" require ] }
     { [ os unix? ] [ "debugger.unix" require ] }
old mode 100644 (file)
new mode 100755 (executable)
index 1f4b8fb..319f100
@@ -1,6 +1,42 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: debugger io prettyprint sequences system ;
+USING: assocs debugger io kernel literals math.parser namespaces
+prettyprint sequences system windows.kernel32 ;
 IN: debugger.windows
 
-M: windows signal-error. "Windows exception #" write third .h ;
\ No newline at end of file
+CONSTANT: seh-names
+    H{
+        { $ STATUS_GUARD_PAGE_VIOLATION       "STATUS_GUARD_PAGE_VIOLATION"     }
+        { $ STATUS_DATATYPE_MISALIGNMENT      "STATUS_DATATYPE_MISALIGNMENT"    }
+        { $ STATUS_BREAKPOINT                 "STATUS_BREAKPOINT"               }
+        { $ STATUS_SINGLE_STEP                "STATUS_SINGLE_STEP"              }
+        { $ STATUS_ACCESS_VIOLATION           "STATUS_ACCESS_VIOLATION"         }
+        { $ STATUS_IN_PAGE_ERROR              "STATUS_IN_PAGE_ERROR"            }
+        { $ STATUS_INVALID_HANDLE             "STATUS_INVALID_HANDLE"           }
+        { $ STATUS_NO_MEMORY                  "STATUS_NO_MEMORY"                }
+        { $ STATUS_ILLEGAL_INSTRUCTION        "STATUS_ILLEGAL_INSTRUCTION"      }
+        { $ STATUS_NONCONTINUABLE_EXCEPTION   "STATUS_NONCONTINUABLE_EXCEPTION" }
+        { $ STATUS_INVALID_DISPOSITION        "STATUS_INVALID_DISPOSITION"      }
+        { $ STATUS_ARRAY_BOUNDS_EXCEEDED      "STATUS_ARRAY_BOUNDS_EXCEEDED"    }
+        { $ STATUS_FLOAT_DENORMAL_OPERAND     "STATUS_FLOAT_DENORMAL_OPERAND"   }
+        { $ STATUS_FLOAT_DIVIDE_BY_ZERO       "STATUS_FLOAT_DIVIDE_BY_ZERO"     }
+        { $ STATUS_FLOAT_INEXACT_RESULT       "STATUS_FLOAT_INEXACT_RESULT"     }
+        { $ STATUS_FLOAT_INVALID_OPERATION    "STATUS_FLOAT_INVALID_OPERATION"  }
+        { $ STATUS_FLOAT_OVERFLOW             "STATUS_FLOAT_OVERFLOW"           }
+        { $ STATUS_FLOAT_STACK_CHECK          "STATUS_FLOAT_STACK_CHECK"        }
+        { $ STATUS_FLOAT_UNDERFLOW            "STATUS_FLOAT_UNDERFLOW"          }
+        { $ STATUS_INTEGER_DIVIDE_BY_ZERO     "STATUS_INTEGER_DIVIDE_BY_ZERO"   }
+        { $ STATUS_INTEGER_OVERFLOW           "STATUS_INTEGER_OVERFLOW"         }
+        { $ STATUS_PRIVILEGED_INSTRUCTION     "STATUS_PRIVILEGED_INSTRUCTION"   }
+        { $ STATUS_STACK_OVERFLOW             "STATUS_STACK_OVERFLOW"           }
+        { $ STATUS_CONTROL_C_EXIT             "STATUS_CONTROL_C_EXIT"           }
+        { $ STATUS_FLOAT_MULTIPLE_FAULTS      "STATUS_FLOAT_MULTIPLE_FAULTS"    }
+        { $ STATUS_FLOAT_MULTIPLE_TRAPS       "STATUS_FLOAT_MULTIPLE_TRAPS"     }
+    }
+
+: seh-name. ( n -- )
+    seh-names at [ " (" ")" surround write ] when* ;
+
+M: windows signal-error.
+    "Windows exception 0x" write
+    third [ >hex write ] [ seh-name. ] bi nl ;
index 4ce3776277e208fee5ff0abaec6cdea38aee152a..d4867714d36d7487bf3030811f78f0fd30f9bc28 100644 (file)
@@ -2,7 +2,7 @@ USING: help.syntax help.markup delegate.private ;
 IN: delegate
 
 HELP: define-protocol
-{ $values { "wordlist" "a sequence of words" } { "protocol" "a word for the new protocol" } }
+{ $values { "protocol" "a word for the new protocol" } { "wordlist" "a sequence of words" } }
 { $description "Defines a symbol as a protocol." }
 { $notes "Usually, " { $link POSTPONE: PROTOCOL: } " should be used instead. This is only for runtime use." } ;
 
index 850c68fd9d77b9718f296e3cdc845ecc6c586630..a4e02009df257530a81efefc4413b6597991965a 100644 (file)
@@ -12,11 +12,11 @@ HELP: +line
 { $description "Adds an integer to the line number of a line/column pair." } ;
 
 HELP: =col
-{ $values { "loc" "a pair of integers" } { "n" integer } { "newloc" "a pair of integers" } }
+{ $values { "n" integer } { "loc" "a pair of integers" } { "newloc" "a pair of integers" } }
 { $description "Sets the column number of a line/column pair." } ;
 
 HELP: =line
-{ $values { "loc" "a pair of integers" } { "n" integer } { "newloc" "a pair of integers" } }
+{ $values { "n" integer } { "loc" "a pair of integers" } { "newloc" "a pair of integers" } }
 { $description "Sets the line number of a line/column pair." } ;
 
 HELP: lines-equal?
index b05c86c36556a7bdca5bff8e6d5aef42a5649099..aef4f4de784bca14664ccfddc1941a9e098c5775 100644 (file)
@@ -34,7 +34,7 @@ TUPLE: document < model locs undos redos inside-undo? ;
 
 : add-loc ( loc document -- ) locs>> push ;
 
-: remove-loc ( loc document -- ) locs>> delete ;
+: remove-loc ( loc document -- ) locs>> remove! drop ;
 
 : update-locs ( loc document -- )
     locs>> [ set-model ] with each ;
index 4a6dd9b5bef93fa6e0850491a607b32fdc2f0f7e..feb19af04057f6c0def58ed57d9b7f988067d416 100644 (file)
@@ -28,7 +28,7 @@ SYMBOL: edit-hook
     require ;
 
 : edit-location ( file line -- )
-    [ (normalize-path) ] dip edit-hook get-global
+    [ absolute-path ] dip edit-hook get-global
     [ call( file line -- ) ] [ no-edit-hook edit-location ] if* ;
 
 ERROR: cannot-find-source definition ;
index 2a1ac85de06312fffc8e526f6433ff24fc95d9fe..57954385706ed1a007bb0e0b1f8803eb6bab31c9 100644 (file)
@@ -114,8 +114,8 @@ DEFER: (parse-paragraph)
 
 :: (take-until) ( state delimiter accum -- string/f state' )
     state empty? [ accum "\n" join f ] [
-        state unclip-slice :> first :> rest
-        first delimiter split1 :> after :> before
+        state unclip-slice :> ( rest first )
+        first delimiter split1 :> ( before after )
         before accum push
         after [
             accum "\n" join
index 13b9e61632112829c116d128cc5d17304e76f992..b3d2ff296e196b367706b6031cb87b9feb417c92 100644 (file)
@@ -2,17 +2,20 @@ USING: help.markup help.syntax quotations kernel ;
 IN: fry\r
 \r
 HELP: _\r
-{ $description "Fry specifier. Inserts a literal value into the fried quotation." } ;\r
+{ $description "Fry specifier. Inserts a literal value into the fried quotation." }\r
+{ $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 HELP: @\r
-{ $description "Fry specifier. Splices a quotation into the fried quotation." } ;\r
+{ $description "Fry specifier. Splices a quotation into the fried quotation." }\r
+{ $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 HELP: fry\r
 { $values { "quot" quotation } { "quot'" quotation } }\r
 { $description "Outputs a quotation that when called, fries " { $snippet "quot" } " by taking values from the stack and substituting them in." }\r
 { $notes "This word is used to implement " { $link POSTPONE: '[ } "; the following two lines are equivalent:"\r
     { $code "[ X ] fry call" "'[ X ]" }\r
-} ;\r
+}\r
+{ $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 HELP: '[\r
 { $syntax "'[ code... ]" }\r
@@ -59,7 +62,6 @@ $nl
     { { $link literalize } { $snippet ": literalize '[ _ ] ;" } }\r
     { { $link curry } { $snippet ": curry '[ _ @ ] ;" } }\r
     { { $link compose } { $snippet ": compose '[ @ @ ] ;" } }\r
-    { { $link bi@ } { $snippet ": bi@ tuck '[ _ @ _ @ ] call ;" } }\r
 } ;\r
 \r
 ARTICLE: "fry.philosophy" "Fried quotation philosophy"\r
@@ -68,10 +70,10 @@ ARTICLE: "fry.philosophy" "Fried quotation philosophy"
     "'[ [ _ key? ] all? ] filter"\r
     "[ [ key? ] curry all? ] curry filter"\r
 }\r
-"There is a mapping from fried quotations to lexical closures as defined in the " { $vocab-link "locals" } " vocabulary. Namely, a fried quotation is equivalent to a “let” form where each local binding is only used once, and bindings are used in the same order in which they are defined. The following two lines are equivalent:"\r
+"There is a mapping from fried quotations to lexical closures as defined in the " { $vocab-link "locals" } " vocabulary. Namely, a fried quotation is equivalent to a " { $snippet "[| | ]" } " form where each local binding is only used once, and bindings are used in the same order in which they are defined. The following two lines are equivalent:"\r
 { $code\r
     "'[ 3 _ + 4 _ / ]"\r
-    "[let | a [ ] b [ ] | [ 3 a + 4 b / ] ]"\r
+    "[| a b | 3 a + 4 b / ]"\r
 } ;\r
 \r
 ARTICLE: "fry" "Fried quotations"\r
index 549db25e09e96e76639dbfe6fa44e411c98968b7..10d9b282adef77dd86f16b034dfd107385160da1 100644 (file)
@@ -1,18 +1,41 @@
+! (c)2009 Slava Pestov, Eduardo Cavazos, Joe Groff bsd license
 USING: fry tools.test math prettyprint kernel io arrays
 sequences eval accessors ;
 IN: fry.tests
 
+SYMBOLS: a b c d e f g h ;
+
+[ [ 1 ] ] [ 1 '[ _ ] ] unit-test
+[ [ 1 ] ] [ [ 1 ] '[ @ ] ] unit-test
+[ [ 1 2 ] ] [ [ 1 ] [ 2 ] '[ @ @ ] ] unit-test
+
+[ [ 1 2 a ] ] [ 1 2 '[ _ _ a ] ] unit-test
+[ [ 1 2 ] ] [ 1 2 '[ _ _ ] ] unit-test
+[ [ a 1 2 ] ] [ 1 2 '[ a _ _ ] ] unit-test
+[ [ 1 2 a ] ] [ [ 1 ] [ 2 ] '[ @ @ a ] ] unit-test
+[ [ 1 a 2 b ] ] [ 1 2 '[ _ a _ b ] ] unit-test
+[ [ 1 a 2 b ] ] [ 1 [ 2 ] '[ _ a @ b ] ] unit-test
+[ [ a 1 b ] ] [ 1 '[ a _ b ] ] unit-test
+
+[ [ a 1 b ] ] [ [ 1 ] '[ a @ b ] ] unit-test
+[ [ a 1 2 ] ] [ [ 1 ] [ 2 ] '[ a @ @ ] ] unit-test
+
+[ [ a [ 1 ] b ] ] [ 1 '[ a [ _ ] b ] ] unit-test
+[ [ a 1 b [ c 2 d ] e 3 f ] ] [ 1 2 3 '[ a _ b [ c _ d ] e _ f ] ] unit-test
+[ [ a 1 b [ c 2 d [ e 3 f ] ] g 4 h ] ] [ 1 2 3 4 '[ a _ b [ c _ d [ e _ f ] ] g _ h ] ] unit-test
+[ [ a 1 b [ [ c 2 d ] e 3 f ] g 4 h ] ] [ 1 2 3 4 '[ a _ b [ [ c _ d ] e _ f ] g _ h ] ] unit-test
+
 [ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
 
 [ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test
 
-[ [ 1 [ + ] call ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
+[ [ 1 + ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
 
-[ [ 1 [ + ] call . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
+[ [ 1 + . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
 
-[ [ [ + ] [ - ] [ call ] dip call ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
+[ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
 
-[ [ "a" "b" [ write ] dip print ] ]
+[ [ "a" write "b" print ] ]
 [ "a" "b" '[ _ write _ print ] ] unit-test
 
 [ 1/2 ] [
index fd029cc329f8c61551ca0149e7ed1b1787398c99..931397e933f9cdb206bfcb5ecdf6b98180b58dca 100644 (file)
@@ -1,7 +1,6 @@
-! Copyright (C) 2008 Slava Pestov, Eduardo Cavazos.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences combinators parser splitting math
-quotations arrays make words locals.backend summary sets ;
+! (c)2009 Slava Pestov, Eduardo Cavazos, Joe Groff bsd license
+USING: accessors combinators kernel locals.backend math parser
+quotations sequences sets splitting words ;
 IN: fry
 
 : _ ( -- * ) "Only valid inside a fry" throw ;
@@ -9,48 +8,138 @@ IN: fry
 
 ERROR: >r/r>-in-fry-error ;
 
-<PRIVATE
-
-: [ncurry] ( n -- quot )
-    {
-        { 0 [ [ ] ] }
-        { 1 [ [ curry ] ] }
-        { 2 [ [ 2curry ] ] }
-        { 3 [ [ 3curry ] ] }
-        [ \ curry <repetition> ]
-    } case ;
+GENERIC: fry ( quot -- quot' )
 
-M: >r/r>-in-fry-error summary
-    drop
-    "Explicit retain stack manipulation is not permitted in fried quotations" ;
+<PRIVATE
 
 : check-fry ( quot -- quot )
     dup { load-local load-locals get-local drop-locals } intersect
     [ >r/r>-in-fry-error ] unless-empty ;
 
-PREDICATE: fry-specifier < word { _ @ } memq? ;
+PREDICATE: fry-specifier < word { _ @ } member-eq? ;
 
 GENERIC: count-inputs ( quot -- n )
 
-M: callable count-inputs [ count-inputs ] sigma ;
+M: callable count-inputs [ count-inputs ] map-sum ;
 M: fry-specifier count-inputs drop 1 ;
 M: object count-inputs drop 0 ;
 
-GENERIC: deep-fry ( obj -- )
+MIXIN: fried
+PREDICATE: fried-callable < callable
+    count-inputs 0 > ;
+INSTANCE: fried-callable fried
 
-: shallow-fry ( quot -- quot' curry# )
-    check-fry
-    [ [ deep-fry ] each ] [ ] make
-    [ dup \ @ = [ drop [ _ call ] ] [ 1array ] if ] map concat
-    { _ } split [ spread>quot ] [ length 1 - ] bi ;
+: (ncurry) ( quot n -- quot )
+    {
+        { 0 [ ] }
+        { 1 [ \ curry  suffix! ] }
+        { 2 [ \ 2curry suffix! ] }
+        { 3 [ \ 3curry suffix! ] }
+        [ [ \ 3curry suffix! ] dip 3 - (ncurry) ]
+    } case ;
 
-PRIVATE>
+: wrap-non-callable ( obj -- quot )
+    dup callable? [ ] [ [ call ] curry ] if ; inline
 
-: fry ( quot -- quot' ) shallow-fry [ncurry] swap prefix ;
+: [ncurry] ( n -- quot )
+    [ V{ } clone ] dip (ncurry) >quotation ;
 
-M: callable deep-fry
-    [ count-inputs \ _ <repetition> % ] [ fry % ] bi ;
+: [ndip] ( quot n -- quot' )
+    {
+        { 0 [ wrap-non-callable ] }
+        { 1 [ \ dip  [ ] 2sequence ] }
+        { 2 [ \ 2dip [ ] 2sequence ] }
+        { 3 [ \ 3dip [ ] 2sequence ] }
+        [ [ \ 3dip [ ] 2sequence ] dip 3 - [ndip] ]
+    } case ;
+
+: (make-curry) ( tail quot -- quot' )
+    swap [ncurry] curry [ compose ] compose ;
+
+: make-compose ( consecutive quot -- consecutive quot' )
+    [
+        [ [ ] ]
+        [ [ncurry] ] if-zero
+    ] [
+        [ [ compose ] ]
+        [ [ compose compose ] curry ] if-empty
+    ] bi* compose
+    0 swap ;
+
+: make-curry ( consecutive quot -- consecutive' quot' )
+    [ 1 + ] dip
+    [ [ ] ] [ (make-curry) 0 swap ] if-empty ;
+
+: convert-curry ( consecutive quot -- consecutive' quot' )
+    [ [ ] make-curry ] [
+        dup first \ @ =
+        [ rest >quotation make-compose ]
+        [ >quotation make-curry ] if
+    ] if-empty ;
+
+: prune-curries ( seq -- seq' )
+    dup [ empty? not ] find 
+    [ [ 1 + tail ] dip but-last prefix ]
+    [ 2drop { } ] if* ;
+
+: convert-curries ( seq -- tail seq' )
+    unclip-slice [ 0 swap [ convert-curry ] map ] dip
+    [ prune-curries ]
+    [ >quotation 1quotation prefix ] if-empty ;
+
+: mark-composes ( quot -- quot' )
+    [ dup \ @ = [ drop [ _ @ ] ] [ 1quotation ] if ] map concat ; inline
+
+: shallow-fry ( quot -- quot' )
+    check-fry mark-composes
+    { _ } split convert-curries
+    [ [ [ ] ] [ [ ] (make-curry) but-last ] if-zero ]
+    [ spread>quot swap [ [ ] (make-curry) compose ] unless-zero ] if-empty ;
+
+DEFER: dredge-fry
+
+TUPLE: dredge-fry-state
+    { in-quot read-only }
+    { prequot read-only }
+    { quot read-only } ;
+
+: <dredge-fry> ( quot -- dredge-fry )
+    V{ } clone V{ } clone dredge-fry-state boa ; inline
+
+: in-quot-slices ( n i state -- head tail )
+    in-quot>>
+    [ <slice> ]
+    [ [ drop ] 2dip swap 1 + tail-slice ] 3bi ; inline
+
+: push-head-slice ( head state -- )
+    quot>> [ push-all ] [ \ _ swap push ] bi ; inline
+
+: push-subquot ( tail elt state -- )
+    [ fry swap >quotation count-inputs [ndip] ] dip prequot>> push-all ; inline
+
+: (dredge-fry-subquot) ( n state i elt -- )
+    rot {
+        [ nip in-quot-slices ] ! head tail i elt state
+        [ [ 2drop swap ] dip push-head-slice ]
+        [ [ drop ] 2dip push-subquot ]
+        [ [ 1 + ] [ drop ] [ ] tri* dredge-fry ]
+    } 3cleave ; inline recursive
+
+: (dredge-fry-simple) ( n state -- )
+    [ in-quot>> swap tail-slice ] [ quot>> ] bi push-all ; inline recursive
+
+: dredge-fry ( n dredge-fry -- )
+    2dup in-quot>> [ fried? ] find-from
+    [ (dredge-fry-subquot) ]
+    [ drop (dredge-fry-simple) ] if* ; inline recursive
+
+PRIVATE>
 
-M: object deep-fry , ;
+M: callable fry ( quot -- quot' )
+    0 swap <dredge-fry>
+    [ dredge-fry ] [
+        [ prequot>> >quotation ]
+        [ quot>> >quotation shallow-fry ] bi append
+    ] bi ;
 
-SYNTAX: '[ parse-quotation fry over push-all ;
+SYNTAX: '[ parse-quotation fry append! ;
index 3484fb447484664b00848dbff36050736c58d7b2..2572f36cb0ef902741b54074618be6fb4dd4ad51 100644 (file)
@@ -1,7 +1,7 @@
 USING: calendar ftp.server io.encodings.ascii io.files
 io.files.unique namespaces threads tools.test kernel
 io.servers.connection ftp.client accessors urls
-io.pathnames io.directories sequences fry ;
+io.pathnames io.directories sequences fry io.backend ;
 FROM: ftp.client => ftp-get ;
 IN: ftp.server.tests
 
@@ -11,7 +11,7 @@ IN: ftp.server.tests
 : create-test-file ( -- path )
     test-file-contents
     "ftp.server" "test" make-unique-file
-    [ ascii set-file-contents ] keep canonicalize-path ;
+    [ ascii set-file-contents ] [ normalize-path ] bi ;
 
 : test-ftp-server ( quot -- )
     '[
index c9518bdef1d149d494471f9434bce0cebc1b86c6..251a99115efaa31dcecf204172002f7ac35e13e4 100644 (file)
@@ -3,13 +3,13 @@
 USING: accessors assocs byte-arrays calendar classes
 combinators combinators.short-circuit concurrency.promises
 continuations destructors ftp io io.backend io.directories
-io.encodings io.encodings.8-bit io.encodings.binary
+io.encodings io.encodings.binary
 tools.files io.encodings.utf8 io.files io.files.info
 io.pathnames io.launcher.unix.parser io.servers.connection
 io.sockets io.streams.duplex io.streams.string io.timeouts
 kernel make math math.bitwise math.parser namespaces sequences
 splitting threads unicode.case logging calendar.format
-strings io.files.links io.files.types ;
+strings io.files.links io.files.types io.encodings.8-bit.latin1 ;
 IN: ftp.server
 
 SYMBOL: server
@@ -58,7 +58,7 @@ C: <ftp-disconnect> ftp-disconnect
     send-response ;
 
 : serving? ( path -- ? )
-    canonicalize-path server get serving-directory>> head? ;
+    normalize-path server get serving-directory>> head? ;
 
 : can-serve-directory? ( path -- ? )
     { [ exists? ] [ file-info directory? ] [ serving? ] } 1&& ;
@@ -343,7 +343,7 @@ M: ftp-server handle-client* ( server -- )
 : <ftp-server> ( directory port -- server )
     latin1 ftp-server new-threaded-server
         swap >>insecure
-        swap canonicalize-path >>serving-directory
+        swap normalize-path >>serving-directory
         "ftp.server" >>name
         5 minutes >>timeout ;
 
index dacd87507bd66b760c25b254d5105746e31f1fcb..a03463e91171fa2447daf3d5960ab47bc7882a83 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays classes.mixin classes.parser
+USING: accessors arrays assocs classes.mixin classes.parser
 classes.singleton classes.tuple classes.tuple.parser
 combinators effects.parser fry functors.backend generic
 generic.parser interpolate io.streams.string kernel lexer
@@ -42,85 +42,85 @@ M: fake-call-next-method (fake-quotations>)
 M: object (fake-quotations>) , ;
 
 : parse-definition* ( accum -- accum )
-    parse-definition >fake-quotations parsed
-    [ fake-quotations> first ] over push-all ;
+    parse-definition >fake-quotations suffix!
+    [ fake-quotations> first ] append! ;
 
 : parse-declared* ( accum -- accum )
     complete-effect
     [ parse-definition* ] dip
-    parsed ;
+    suffix! ;
 
 FUNCTOR-SYNTAX: TUPLE:
-    scan-param parsed
+    scan-param suffix!
     scan {
-        { ";" [ tuple parsed f parsed ] }
-        { "<" [ scan-param parsed [ parse-tuple-slots ] { } make parsed ] }
+        { ";" [ tuple suffix! f suffix! ] }
+        { "<" [ scan-param suffix! [ parse-tuple-slots ] { } make suffix! ] }
         [
-            [ tuple parsed ] dip
+            [ tuple suffix! ] dip
             [ parse-slot-name [ parse-tuple-slots ] when ] { }
-            make parsed
+            make suffix!
         ]
     } case
-    \ define-tuple-class parsed ;
+    \ define-tuple-class suffix! ;
 
 FUNCTOR-SYNTAX: SINGLETON:
-    scan-param parsed
-    \ define-singleton-class parsed ;
+    scan-param suffix!
+    \ define-singleton-class suffix! ;
 
 FUNCTOR-SYNTAX: MIXIN:
-    scan-param parsed
-    \ define-mixin-class parsed ;
+    scan-param suffix!
+    \ define-mixin-class suffix! ;
 
 FUNCTOR-SYNTAX: M:
-    scan-param parsed
-    scan-param parsed
-    [ create-method-in dup method-body set ] over push-all
+    scan-param suffix!
+    scan-param suffix!
+    [ create-method-in dup method-body set ] append! 
     parse-definition*
-    \ define* parsed ;
+    \ define* suffix! ;
 
 FUNCTOR-SYNTAX: C:
-    scan-param parsed
-    scan-param parsed
+    scan-param suffix!
+    scan-param suffix!
     complete-effect
-    [ [ [ boa ] curry ] over push-all ] dip parsed
-    \ define-declared* parsed ;
+    [ [ [ boa ] curry ] append! ] dip suffix!
+    \ define-declared* suffix! ;
 
 FUNCTOR-SYNTAX: :
-    scan-param parsed
+    scan-param suffix!
     parse-declared*
-    \ define-declared* parsed ;
+    \ define-declared* suffix! ;
 
 FUNCTOR-SYNTAX: SYMBOL:
-    scan-param parsed
-    \ define-symbol parsed ;
+    scan-param suffix!
+    \ define-symbol suffix! ;
 
 FUNCTOR-SYNTAX: SYNTAX:
-    scan-param parsed
+    scan-param suffix!
     parse-definition*
-    \ define-syntax parsed ;
+    \ define-syntax suffix! ;
 
 FUNCTOR-SYNTAX: INSTANCE:
-    scan-param parsed
-    scan-param parsed
-    \ add-mixin-instance parsed ;
+    scan-param suffix!
+    scan-param suffix!
+    \ add-mixin-instance suffix! ;
 
 FUNCTOR-SYNTAX: GENERIC:
-    scan-param parsed
-    complete-effect parsed
-    \ define-simple-generic* parsed ;
+    scan-param suffix!
+    complete-effect suffix!
+    \ define-simple-generic* suffix! ;
 
 FUNCTOR-SYNTAX: MACRO:
-    scan-param parsed
+    scan-param suffix!
     parse-declared*
-    \ define-macro parsed ;
+    \ define-macro suffix! ;
 
-FUNCTOR-SYNTAX: inline [ word make-inline ] over push-all ;
+FUNCTOR-SYNTAX: inline [ word make-inline ] append! ;
 
-FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } parsed ;
+FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } suffix! ;
 
 : (INTERPOLATE) ( accum quot -- accum )
     [ scan interpolate-locals ] dip
-    '[ _ with-string-writer @ ] parsed ;
+    '[ _ with-string-writer @ ] suffix! ;
 
 PRIVATE>
 
@@ -144,10 +144,31 @@ DEFER: ;FUNCTOR delimiter
 : pop-functor-words ( -- )
     functor-words unuse-words ;
 
+: (parse-bindings) ( end -- )
+    dup parse-binding dup [
+        first2 [ make-local ] dip 2array ,
+        (parse-bindings)
+    ] [ 2drop ] if ;
+
+: with-bindings ( quot -- words assoc )
+    '[
+        in-lambda? on
+        _ H{ } make-assoc
+    ] { } make swap ; inline
+
+: parse-bindings ( end -- words assoc )
+    [
+        namespace use-words
+        (parse-bindings)
+        namespace unuse-words
+    ] with-bindings ;
+
 : parse-functor-body ( -- form )
     push-functor-words
-    "WHERE" parse-bindings*
-    [ \ ;FUNCTOR parse-until >quotation ] ((parse-lambda)) <let*> 1quotation
+    "WHERE" parse-bindings
+    [ [ swap <def> suffix ] { } assoc>map concat ]
+    [ [ \ ;FUNCTOR parse-until >quotation ] ((parse-lambda)) ] bi*
+    [ ] append-as
     pop-functor-words ;
 
 : (FUNCTOR:) ( -- word def effect )
index c7fc0d5f0b676ad1929218b50be2fe911afdccd3..5aab80876379bd5dff7628d6c54de4d6ea18dc5d 100644 (file)
@@ -63,7 +63,7 @@ HELP: realm
 { $class-description "The class of authentication realms. See " { $link "furnace.auth.realms" } " for details." } ;
 
 HELP: uchange
-{ $values { "key" symbol } { "quot" { $quotation "( old -- new )" } } }
+{ $values { "quot" { $quotation "( old -- new )" } } { "key" symbol } }
 { $description "Applies the quotation to the old value of the user profile variable, and assigns the resulting value back to the variable." } ;
 
 HELP: uget
index 1933fc8c59db682b97edb8f216816d663e2a7b21..44374fb5a62c78645da25713d4b28f3bd6636bf2 100644 (file)
@@ -23,26 +23,24 @@ GENERIC: new-user ( user provider -- user/f )
 ! Password recovery support\r
 \r
 :: issue-ticket ( email username provider -- user/f )\r
-    [let | user [ username provider get-user ] |\r
-        user [\r
-            user email>> length 0 > [\r
-                user email>> email = [\r
-                    user\r
-                    256 random-bits >hex >>ticket\r
-                    dup provider update-user\r
-                ] [ f ] if\r
+    username provider get-user :> user\r
+    user [\r
+        user email>> length 0 > [\r
+            user email>> email = [\r
+                user\r
+                256 random-bits >hex >>ticket\r
+                dup provider update-user\r
             ] [ f ] if\r
         ] [ f ] if\r
-    ] ;\r
+    ] [ f ] if ;\r
 \r
 :: claim-ticket ( ticket username provider -- user/f )\r
-    [let | user [ username provider get-user ] |\r
-        user [\r
-            user ticket>> ticket = [\r
-                user f >>ticket dup provider update-user\r
-            ] [ f ] if\r
+    username provider get-user :> user\r
+    user [\r
+        user ticket>> ticket = [\r
+            user f >>ticket dup provider update-user\r
         ] [ f ] if\r
-    ] ;\r
+    ] [ f ] if ;\r
 \r
 ! For configuration\r
 \r
index 3426b891419fa46bc30d54a18b60b1949a2e713e..b9f21f70a291665b0b9ca24a09dc52cfa64a78dc 100755 (executable)
@@ -1,5 +1,5 @@
 USING: sequences sequences.private math
-accessors alien.data ;
+accessors alien.c-types ;
 IN: game.input.dinput.keys-array
 
 TUPLE: keys-array
index 25283df4bfb4515fb849386ab1e3bfdb653eaab4..261f19cb9e908689d869c9fa9a9f59238ab2f835 100755 (executable)
@@ -75,9 +75,8 @@ SYMBOLS:
     get-controllers [ product-id = ] with filter ;
 : find-controller-instance ( product-id instance-id -- controller/f )
     get-controllers [
-        tuck
         [ product-id  = ]
-        [ instance-id = ] 2bi* and
+        [ instance-id = ] bi-curry bi* and
     ] with with find nip ;
 
 TUPLE: keyboard-state keys ;
index f5c0de2ea2127efc19137bd509cb38a0dbaef08b..5b869f138ee09205fa10db5d13f2382e9eed4dcc 100644 (file)
@@ -212,7 +212,7 @@ HELP: nwith
 } ;\r
 \r
 HELP: napply\r
-{ $values { "n" integer } }\r
+{ $values { "quot" quotation } { "n" integer } }\r
 { $description "A generalization of " { $link bi@ } " and " { $link tri@ } " that can work for any stack depth."\r
 } \r
 { $examples\r
@@ -266,26 +266,6 @@ HELP: spread-curry
 { $description "Curries the " { $snippet "n" } " quotations on the top of the datastack with the " { $snippet "n" } " values just below them. A generalization of " { $link bi-curry* } " and " { $link tri-curry* } "." }\r
 { $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry* bi" } ", " { $snippet "tri-curry* tri" } ", " { $snippet "bi-curry* bi*" } ", and " { $snippet "tri-curry* tri*" } "." } ;\r
 \r
-HELP: neach\r
-{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- )" } } { "n" integer } }\r
-{ $description "A generalization of " { $link each } ", " { $link 2each } ", and " { $link 3each } " that can iterate over any number of sequences in parallel." } ;\r
-\r
-HELP: nmap\r
-{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- result )" } } { "n" integer } { "result" "a sequence of the same type as the first " { $snippet "seq" } } }\r
-{ $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel." } ;\r
-\r
-HELP: nmap-as\r
-{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- result )" } } { "exemplar" sequence } { "n" integer } { "result" "a sequence of the same type as " { $snippet "exemplar" } } }\r
-{ $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel." } ;\r
-\r
-HELP: mnmap\r
-{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( m*element -- result*n )" } } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences of the same type as the first " { $snippet "seq" } } }\r
-{ $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel and provide any number of output sequences." } ;\r
-\r
-HELP: mnmap-as\r
-{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( m*element -- result*n )" } } { "n*exemplar" { $snippet "n" } " sequences on the datastack" } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences of the same type as the " { $snippet "exemplar" } "s" } }\r
-{ $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel and provide any number of output sequences of distinct types." } ;\r
-\r
 HELP: mnswap\r
 { $values { "m" integer } { "n" integer } }\r
 { $description "Swaps the top " { $snippet "m" } " stack elements with the " { $snippet "n" } " elements directly underneath." }\r
@@ -352,18 +332,6 @@ HELP: nappend-as
 \r
 { nappend nappend-as } related-words\r
 \r
-HELP: ntuck\r
-{ $values\r
-     { "n" integer }\r
-}\r
-{ $description "A generalization of " { $link tuck } " that can work for any stack depth. The top item will be copied and placed " { $snippet "n" } " items down on the stack." } ;\r
-\r
-HELP: nspin\r
-{ $values\r
-    { "n" integer }\r
-}\r
-{ $description "A generalization of " { $link spin } " that can work for any stack depth. The top " { $snippet "n" } " items will be reversed in order." } ;\r
-\r
 ARTICLE: "sequence-generalizations" "Generalized sequence operations"\r
 { $subsections\r
     narray\r
@@ -383,8 +351,6 @@ ARTICLE: "shuffle-generalizations" "Generalized shuffle words"
     -nrot\r
     nnip\r
     ndrop\r
-    ntuck\r
-    nspin\r
     mnswap\r
     nweave\r
 } ;\r
@@ -401,11 +367,6 @@ ARTICLE: "combinator-generalizations" "Generalized combinators"
     apply-curry\r
     cleave-curry\r
     spread-curry\r
-    neach\r
-    nmap\r
-    nmap-as\r
-    mnmap\r
-    mnmap-as\r
 } ;\r
 \r
 ARTICLE: "other-generalizations" "Additional generalizations"\r
@@ -424,6 +385,7 @@ ARTICLE: "generalizations" "Generalized shuffle words and combinators"
     "shuffle-generalizations"\r
     "combinator-generalizations"\r
     "other-generalizations"\r
-} ;\r
+}\r
+"Also see the " { $vocab-link "sequences.generalizations" } " vocabulary for generalized sequence iteration combinators." ;\r
 \r
 ABOUT: "generalizations"\r
index cb2c40ca0acf2e21c670966099552c0a21ed2233..546413447e6a28fc1b385ec1f43af84c12fccc11 100644 (file)
@@ -26,8 +26,6 @@ IN: generalizations.tests
 { 0 } [ 0 1 2 3 4 4 ndrop ] unit-test\r
 [ [ 1 ] 5 ndip ] must-infer\r
 [ 1 2 3 4 ] [ 2 3 4 [ 1 ] 3 ndip ] unit-test\r
-[ 5 nspin ] must-infer\r
-[ 1 5 4 3 2 ] [ 1 2 3 4 5 4 nspin ] unit-test\r
 \r
 [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer\r
 [ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] must-infer\r
@@ -82,108 +80,6 @@ IN: generalizations.tests
 \r
 [ '[ number>string _ append ] 4 napply ] must-infer\r
 \r
-: neach-test ( a b c d -- )\r
-    [ 4 nappend print ] 4 neach ;\r
-: nmap-test ( a b c d -- e )\r
-    [ 4 nappend ] 4 nmap ;\r
-: nmap-as-test ( a b c d -- e )\r
-    [ 4 nappend ] [ ] 4 nmap-as ;\r
-: mnmap-3-test ( a b c d -- e f g )\r
-    [ append ] 4 3 mnmap ;\r
-: mnmap-2-test ( a b c d -- e f )\r
-    [ [ append ] 2bi@ ] 4 2 mnmap ;\r
-: mnmap-as-test ( a b c d -- e f )\r
-    [ [ append ] 2bi@ ] { } [ ] 4 2 mnmap-as ;\r
-: mnmap-1-test ( a b c d -- e )\r
-    [ 4 nappend ] 4 1 mnmap ;\r
-: mnmap-0-test ( a b c d -- )\r
-    [ 4 nappend print ] 4 0 mnmap ;\r
-\r
-[ """A1a!\r
-B2b@\r
-C3c#\r
-D4d$\r
-""" ] [\r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    [ neach-test ] with-string-writer\r
-] unit-test\r
-\r
-[ { "A1a!" "B2b@" "C3c#" "D4d$" } ]\r
-[ \r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    nmap-test\r
-] unit-test\r
-\r
-[ [ "A1a!" "B2b@" "C3c#" "D4d$" ] ]\r
-[ \r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    nmap-as-test\r
-] unit-test\r
-\r
-[\r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a!" "b@" "c#" "d$" }\r
-] [ \r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    mnmap-3-test\r
-] unit-test\r
-\r
-[\r
-    { "A1" "B2" "C3" "D4" }\r
-    { "a!" "b@" "c#" "d$" }\r
-] [ \r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    mnmap-2-test\r
-] unit-test\r
-\r
-[\r
-    { "A1" "B2" "C3" "D4" }\r
-    [ "a!" "b@" "c#" "d$" ]\r
-] [ \r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    mnmap-as-test\r
-] unit-test\r
-\r
-[ { "A1a!" "B2b@" "C3c#" "D4d$" } ]\r
-[ \r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    mnmap-1-test\r
-] unit-test\r
-\r
-[ """A1a!\r
-B2b@\r
-C3c#\r
-D4d$\r
-""" ] [\r
-    { "A" "B" "C" "D" }\r
-    { "1" "2" "3" "4" }\r
-    { "a" "b" "c" "d" }\r
-    { "!" "@" "#" "$" }\r
-    [ mnmap-0-test ] with-string-writer\r
-] unit-test\r
-\r
 [ 6 8 10 12 ] [\r
     1 2 3 4\r
     5 6 7 8 [ + ] 4 apply-curry 4 spread*\r
index 2ae076655e771a0507d546321ae286023481e4ab..6c8a0b5fdecf9558538ead28593a5d2904c3bba0 100644 (file)
@@ -71,9 +71,6 @@ MACRO: ndrop ( n -- )
 MACRO: nnip ( n -- )
     '[ [ _ ndrop ] dip ] ;
 
-MACRO: ntuck ( n -- )
-    2 + '[ dup _ -nrot ] ;
-
 MACRO: ndip ( n -- )
     [ [ dip ] curry ] n*quot [ call ] compose ;
 
@@ -112,8 +109,8 @@ MACRO: cleave* ( n -- )
     [ 1 - [ [ [ keep ] curry ] dip compose ] n*quot [ call ] compose ] 
     if-zero ;
 
-MACRO: napply ( n -- )
-    [ [ drop ] ] dip [ '[ tuck _ 2dip call ] ] times ;
+: napply ( quot n -- )
+    [ dupn ] [ spread* ] bi ; inline
 
 : apply-curry ( ...a quot n -- )
     [ [curry] ] dip napply ; inline
@@ -139,60 +136,3 @@ MACRO: nbi-curry ( n -- )
 
 : nappend ( n -- seq ) narray concat ; inline
 
-MACRO: nspin ( n -- )
-    [ [ ] ] swap [ swap [ ] curry compose ] n*quot [ call ] 3append ;
-
-MACRO: nmin-length ( n -- )
-    dup 1 - [ min ] n*quot
-    '[ [ length ] _ napply @ ] ;
-
-: nnth-unsafe ( n ...seq n -- )
-    [ nth-unsafe ] swap [ apply-curry ] [ cleave* ] bi ; inline
-MACRO: nset-nth-unsafe ( n -- )
-    [ [ drop ] ]
-    [ '[ [ set-nth-unsafe ] _ [ apply-curry ] [ cleave-curry ] [ spread* ] tri ] ]
-    if-zero ;
-
-: (neach) ( ...seq quot n -- len quot' )
-    dup dup dup
-    '[ [ _ nmin-length ] _ nkeep [ _ nnth-unsafe ] _ ncurry ] dip compose ; inline
-
-: neach ( ...seq quot n -- )
-    (neach) each-integer ; inline
-
-: nmap-as ( ...seq quot exemplar n -- result )
-    '[ _ (neach) ] dip map-integers ; inline
-
-: nmap ( ...seq quot n -- result )
-    dup '[ [ _ npick ] dip swap ] dip nmap-as ; inline
-
-MACRO: nnew-sequence ( n -- )
-    [ [ drop ] ]
-    [ dup '[ [ new-sequence ] _ apply-curry _ cleave* ] ] if-zero ;
-
-: nnew-like ( len ...exemplar quot n -- result... )
-    dup dup dup dup '[
-        _ nover
-        [ [ _ nnew-sequence ] dip call ]
-        _ ndip [ like ]
-        _ apply-curry
-        _ spread*
-    ] call ; inline
-
-MACRO: (ncollect) ( n -- )
-    dup dup 1 +
-    '[ [ [ keep ] _ ndip _ nset-nth-unsafe ] _ ncurry ] ;
-
-: ncollect ( len quot ...into n -- )
-    (ncollect) each-integer ; inline
-
-: nmap-integers ( len quot ...exemplar n -- result... )
-    dup dup dup
-    '[ [ over ] _ ndip [ [ _ ncollect ] _ nkeep ] _ nnew-like ] call ; inline
-
-: mnmap-as ( m*seq quot n*exemplar m n -- result*n )
-    dup '[ [ _ (neach) ] _ ndip _ nmap-integers ] call ; inline
-
-: mnmap ( m*seq quot m n -- result*n )
-    2dup '[ [ _ npick ] dip swap _ dupn ] 2dip mnmap-as ; inline
-
index d64745b83484e9727da02fc1ae25d871770e6564..e1044b0feb0e5ef1bddff64fd1c97ab9b01dc820 100644 (file)
@@ -52,7 +52,7 @@ HELP: <groups>
 { $examples
     { $example
         "USING: arrays kernel prettyprint sequences grouping ;"
-        "9 >array 3 <groups> dup reverse-here concat >array ." "{ 6 7 8 3 4 5 0 1 2 }"
+        "9 >array 3 <groups> reverse! concat >array ." "{ 6 7 8 3 4 5 0 1 2 }"
     }
     { $example
         "USING: kernel prettyprint sequences grouping ;"
@@ -68,7 +68,7 @@ HELP: <sliced-groups>
     { $example
         "USING: arrays kernel prettyprint sequences grouping ;"
         "9 >array 3 <sliced-groups>"
-        "dup [ reverse-here ] each concat >array ."
+        "dup [ reverse! drop ] each concat >array ."
         "{ 2 1 0 5 4 3 8 7 6 }"
     }
     { $example
index c91e5a56d683ab83e274c66ecd7246f75450a4e4..52b436507e209da5ebf55ff125c072ffbfc264ef 100644 (file)
@@ -1,5 +1,5 @@
 USING: grouping tools.test kernel sequences arrays
-math ;
+math accessors ;
 IN: grouping.tests
 
 [ { 1 2 3 } 0 group ] must-fail
@@ -12,6 +12,15 @@ IN: grouping.tests
     >array
 ] unit-test
 
+[ 0 ] [ { } 2 <clumps> length ] unit-test
+[ 0 ] [ { 1 } 2 <clumps> length ] unit-test
+[ 1 ] [ { 1 2 } 2 <clumps> length ] unit-test
+[ 2 ] [ { 1 2 3 } 2 <clumps> length ] unit-test
+
+[ 1 ] [ V{ } 2 <clumps> 0 over set-length seq>> length ] unit-test
+[ 2 ] [ V{ } 2 <clumps> 1 over set-length seq>> length ] unit-test
+[ 3 ] [ V{ } 2 <clumps> 2 over set-length seq>> length ] unit-test
+
 [ { { 1 2 } { 2 3 } } ] [ { 1 2 3 } 2 <sliced-clumps> [ >array ] map ] unit-test
 
 [ f ] [ [ { } { } "Hello" ] all-equal? ] unit-test
index 83579d2beb518bc00433992d1b79bff0b543a0a6..8a39a5d5cf5fd2511c5e6541481900604cbcf631 100644 (file)
@@ -46,7 +46,7 @@ M: abstract-groups group@
 TUPLE: abstract-clumps < chunking-seq ;
 
 M: abstract-clumps length
-    [ seq>> length ] [ n>> ] bi - 1 + ; inline
+    [ seq>> length 1 + ] [ n>> ] bi [-] ; inline
 
 M: abstract-clumps set-length
     [ n>> + 1 - ] [ seq>> ] bi set-length ; inline
diff --git a/basis/half-floats/authors.txt b/basis/half-floats/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/basis/half-floats/half-floats-tests.factor b/basis/half-floats/half-floats-tests.factor
new file mode 100644 (file)
index 0000000..d6b26cb
--- /dev/null
@@ -0,0 +1,49 @@
+USING: accessors alien.c-types alien.syntax half-floats kernel
+math tools.test specialized-arrays alien.data classes.struct ;
+SPECIALIZED-ARRAY: half
+IN: half-floats.tests
+
+[ HEX: 0000 ] [  0.0  half>bits ] unit-test
+[ HEX: 8000 ] [ -0.0  half>bits ] unit-test
+[ HEX: 3e00 ] [  1.5  half>bits ] unit-test
+[ HEX: be00 ] [ -1.5  half>bits ] unit-test
+[ HEX: 7c00 ] [  1/0. half>bits ] unit-test
+[ HEX: fc00 ] [ -1/0. half>bits ] unit-test
+[ HEX: 7eaa ] [ NAN: aaaaaaaaaaaaa half>bits ] unit-test
+
+! too-big floats overflow to infinity
+[ HEX: 7c00 ] [   65536.0 half>bits ] unit-test
+[ HEX: fc00 ] [  -65536.0 half>bits ] unit-test
+[ HEX: 7c00 ] [  131072.0 half>bits ] unit-test
+[ HEX: fc00 ] [ -131072.0 half>bits ] unit-test
+
+! too-small floats flush to zero
+[ HEX: 0000 ] [  1.0e-9 half>bits ] unit-test
+[ HEX: 8000 ] [ -1.0e-9 half>bits ] unit-test
+
+[  0.0  ] [ HEX: 0000 bits>half ] unit-test
+[ -0.0  ] [ HEX: 8000 bits>half ] unit-test
+[  1.5  ] [ HEX: 3e00 bits>half ] unit-test
+[ -1.5  ] [ HEX: be00 bits>half ] unit-test
+[  1/0. ] [ HEX: 7c00 bits>half ] unit-test
+[ -1/0. ] [ HEX: fc00 bits>half ] unit-test
+[  3.0  ] [ HEX: 4200 bits>half ] unit-test
+[    t  ] [ HEX: 7e00 bits>half fp-nan? ] unit-test
+
+STRUCT: halves
+    { tom half }
+    { dick half }
+    { harry half }
+    { harry-jr half } ;
+
+[ 8 ] [ halves heap-size ] unit-test
+
+[ 3.0 ] [
+    halves <struct>
+        3.0 >>dick
+    dick>>
+] unit-test
+
+[ half-array{ 1.0 2.0 3.0 1/0. -1/0. } ]
+[ { 1.0 2.0 3.0 1/0. -1/0. } >half-array ] unit-test
+
diff --git a/basis/half-floats/half-floats.factor b/basis/half-floats/half-floats.factor
new file mode 100755 (executable)
index 0000000..4c84bb8
--- /dev/null
@@ -0,0 +1,46 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors alien.accessors alien.c-types alien.data
+alien.syntax kernel math math.order ;
+FROM: math => float ;
+IN: half-floats
+
+: half>bits ( float -- bits )
+    float>bits
+    [ -31 shift 15 shift ] [
+        HEX: 7fffffff bitand
+        dup zero? [
+            dup HEX: 7f800000 >= [ -13 shift HEX: 7fff bitand ] [
+                -13 shift
+                112 10 shift -
+                0 HEX: 7c00 clamp
+            ] if
+        ] unless
+    ] bi bitor ;
+
+: bits>half ( bits -- float )
+    [ -15 shift 31 shift ] [
+        HEX: 7fff bitand
+        dup zero? [
+            dup HEX: 7c00 >= [ 13 shift HEX: 7f800000 bitor ] [
+                13 shift
+                112 23 shift + 
+            ] if
+        ] unless
+    ] bi bitor bits>float ;
+
+SYMBOL: half
+
+<<
+
+<c-type>
+    float >>class
+    float >>boxed-class
+    [ alien-unsigned-2 bits>half ] >>getter
+    [ [ >float half>bits ] 2dip set-alien-unsigned-2 ] >>setter
+    2 >>size
+    2 >>align
+    2 >>align-first
+    [ >float ] >>unboxer-quot
+\ half define-primitive-type
+
+>>
diff --git a/basis/half-floats/summary.txt b/basis/half-floats/summary.txt
new file mode 100644 (file)
index 0000000..b22448f
--- /dev/null
@@ -0,0 +1 @@
+Half-precision float support for FFI
index 32b6ffe7edeee0632038a1f5c1b1208873e5d019..8ceb7bb78ff45893a3389d57b67baa534867fc4b 100644 (file)
@@ -53,12 +53,12 @@ HELP: <max-heap>
 { $description "Create a new " { $link max-heap } "." } ;
 
 HELP: heap-push
-{ $values { "key" "a comparable object" } { "value" object } { "heap" "a heap" } }
+{ $values { "value" object } { "key" "a comparable object" } { "heap" "a heap" } }
 { $description "Push a pair onto a heap. The key must be comparable with all other keys by the " { $link <=> } " generic word." }
 { $side-effects "heap" } ;
 
 HELP: heap-push*
-{ $values { "key" "a comparable object" } { "value" object } { "heap" "a heap" } { "entry" entry } }
+{ $values { "value" object } { "key" "a comparable object" } { "heap" "a heap" } { "entry" entry } }
 { $description "Push a pair onto a heap, and output an entry which may later be passed to " { $link heap-delete } "." }
 { $side-effects "heap" } ;
 
@@ -68,7 +68,7 @@ HELP: heap-push-all
 { $side-effects "heap" } ;
 
 HELP: heap-peek
-{ $values { "heap" "a heap" } { "key" object } { "value" object } }
+{ $values { "heap" "a heap" } { "value" object } { "key" object } }
 { $description "Output the first element in the heap, leaving it in the heap." } ;
 
 HELP: heap-pop*
@@ -77,7 +77,7 @@ HELP: heap-pop*
 { $side-effects "heap" } ;
 
 HELP: heap-pop
-{ $values { "heap" "a heap" } { "key" object } { "value" object } }
+{ $values { "heap" "a heap" } { "value" object } { "key" object } }
 { $description "Output and remove the first element in the heap." }
 { $side-effects "heap" } ;
 
index 3bcc8151911fb042ccab52becf2966e8c78f743c..e77e7bccad0b13a3be79eb785a7b420c309ad559 100644 (file)
@@ -73,4 +73,4 @@ M: apropos >link ;
 INSTANCE: apropos topic
 
 : apropos ( str -- )
-    <apropos> print-topic ;
+    <apropos> print-topic nl ;
index 4022d3bd382a2ac8ccb5fcea0d24cf8f4d50e170..6fb4c562cfd9038fe9e8b4c0451ee2557c1b078b 100644 (file)
@@ -1,6 +1,7 @@
 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 ;
+io.streams.string continuations debugger compiler.units eval
+help.syntax ;
 IN: help.crossref.tests
 
 [ ] [
@@ -54,3 +55,11 @@ IN: help.crossref.tests
 ] unit-test
 
 [ "xxx" ] [ "yyy" article-parent ] unit-test
+
+ARTICLE: "crossref-test-1" "Crossref test 1"
+"Hello world" ;
+
+ARTICLE: "crossref-test-2" "Crossref test 2"
+{ $markup-example { $subsection "crossref-test-1" } } ;
+
+[ V{ } ] [ "crossref-test-2" >link article-children ] unit-test
index afb88bbd3c55badac63e70988b96bad66b4a7e80..0cfa419dd0b503679f3b25f52f8f5227a953b40e 100644 (file)
@@ -10,16 +10,42 @@ IN: help.handbook
 
 ARTICLE: "conventions" "Conventions"
 "Various conventions are used throughout the Factor documentation and source code."
+{ $heading "Glossary of terms" }
+"Common terminology and abbreviations used throughout Factor and its documentation:"
+{ $table
+    { "Term" "Definition" }
+    { "alist" { "an association list; see " { $link "alists" } } }
+    { "assoc" { "an associative mapping; see " { $link "assocs" } } }
+    { "associative mapping" { "an object whose class implements the " { $link "assocs-protocol" } } }
+    { "boolean"               { { $link t } " or " { $link f } } }
+    { "class"                 { "a set of objects identified by a " { $emphasis "class word" } " together with a discriminating predicate. See " { $link "classes" } } }
+    { "combinator"            { "a word taking a quotation or another word as input; a higher-order function. See " { $link "combinators" } } }
+    { "definition specifier"  { "an instance of " { $link definition } " which implements the " { $link "definition-protocol" } } }
+    { "generalized boolean"   { "an object interpreted as a boolean; a value of " { $link f } " denotes false and anything else denotes true" } }
+    { "generic word"          { "a word whose behavior depends can be specialized on the class of one of its inputs. See " { $link "generic" } } }
+    { "method"                { "a specialized behavior of a generic word on a class. See " { $link "generic" } } }
+    { "object"                { "any datum which can be identified" } }
+    { "ordering specifier"    { "see " { $link "order-specifiers" } } }
+    { "pathname string"       { "an OS-specific pathname which identifies a file" } }
+    { "quotation"             { "an anonymous function; an instance of the " { $link quotation } " class. More generally, instances of the " { $link callable } " class can be used in many places documented to expect quotations" } }
+    { "sequence" { "a sequence; see " { $link "sequence-protocol" } } }
+    { "slot"                  { "a component of an object which can store a value" } }
+    { "stack effect"          { "a pictorial representation of a word's inputs and outputs, for example " { $snippet "+ ( x y -- z )" } ". See " { $link "effects" } } }
+    { "true value"            { "any object not equal to " { $link f } } }
+    { { "vocabulary " { $strong "or" } " vocab" } { "a named set of words. See " { $link "vocabularies" } } }
+    { "vocabulary specifier"  { "a " { $link vocab } ", " { $link vocab-link } " or a string naming a vocabulary" } }
+    { "word"                  { "the basic unit of code, analogous to a function or procedure in other programming languages. See " { $link "words" } } }
+} 
 { $heading "Documentation conventions" }
 "Factor documentation consists of two distinct bodies of text. There is a hierarchy of articles, much like this one, and there is word documentation. Help articles reference word documentation, and vice versa, but not every documented word is referenced from some help article."
 $nl
+"The browser, completion popups and other tools use a common set of " { $link "definitions.icons" } "."
+$nl
 "Every article has links to parent articles at the top. Explore these if the article you are reading is too specific."
 $nl
 "Some generic words have " { $strong "Description" } " headings, and others have " { $strong "Contract" } " headings. A distinction is made between words which are not intended to be extended with user-defined methods, and those that are."
 { $heading "Vocabulary naming conventions" }
-"A vocabulary name ending in " { $snippet ".private" } " contains words which are either implementation detail, unsafe, or both. For example, the " { $snippet "sequence.private" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } ")."
-$nl
-"You should avoid using internal words from the Factor library unless absolutely necessary. Similarly, your own code can place words in internal vocabularies if you do not want other people to use them unless they have a good reason."
+"A vocabulary name ending in " { $snippet ".private" } " contains words which are either implementation details, unsafe, or both. For example, the " { $snippet "sequence.private" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } "). You should avoid using private words from the Factor library unless absolutely necessary. Similarly, your own code can place words in private vocabularies using " { $link POSTPONE: <PRIVATE } " if you do not want other people using them without good reason."
 { $heading "Word naming conventions" }
 "These conventions are not hard and fast, but are usually a good first step in understanding a word's behavior:"
 { $table
@@ -40,32 +66,7 @@ $nl
 }
 { $heading "Stack effect conventions" }
 "Stack effect conventions are documented in " { $link "effects" } "."
-{ $heading "Glossary of terms" }
-"Common terminology and abbreviations used throughout Factor and its documentation:"
-{ $table
-    { "Term" "Definition" }
-    { "alist" { "an association list; see " { $link "alists" } } }
-    { "assoc" { "an associative mapping; see " { $link "assocs" } } }
-    { "associative mapping" { "an object whose class implements the " { $link "assocs-protocol" } } }
-    { "boolean"               { { $link t } " or " { $link f } } }
-    { "class"                 { "a set of objects identified by a " { $emphasis "class word" } " together with a discriminating predicate. See " { $link "classes" } } }
-    { "combinator"            { "a word taking a quotation or another word as input; a higher-order function. See " { $link "combinators" } } }
-    { "definition specifier"  { "an instance of " { $link definition } " which implements the " { $link "definition-protocol" } } }
-    { "generalized boolean"   { "an object interpreted as a boolean; a value of " { $link f } " denotes false and anything else denotes true" } }
-    { "generic word"          { "a word whose behavior depends can be specialized on the class of one of its inputs. See " { $link "generic" } } }
-    { "method"                { "a specialized behavior of a generic word on a class. See " { $link "generic" } } }
-    { "object"                { "any datum which can be identified" } }
-    { "ordering specifier"    { "see " { $link "order-specifiers" } } }
-    { "pathname string"       { "an OS-specific pathname which identifies a file" } }
-    { "quotation"             { "an anonymous function; an instance of the " { $link quotation } " class. More generally, instances of the " { $link callable } " class can be used in many places documented to expect quotations" } }
-    { "sequence" { "a sequence; see " { $link "sequence-protocol" } } }
-    { "slot"                  { "a component of an object which can store a value" } }
-    { "stack effect"          { "a pictorial representation of a word's inputs and outputs, for example " { $snippet "+ ( x y -- z )" } ". See " { $link "effects" } } }
-    { "true value"            { "any object not equal to " { $link f } } }
-    { "vocabulary" { "a named set of words. See " { $link "vocabularies" } } }
-    { "vocabulary specifier"  { "a " { $link vocab } ", " { $link vocab-link } " or a string naming a vocabulary" } }
-    { "word"                  { "the basic unit of code, analogous to a function or procedure in other programming languages. See " { $link "words" } } }
-} ;
+;
 
 ARTICLE: "tail-call-opt" "Tail-call optimization"
 "If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $emphasis "tail-call optimization" } " and the Factor implementation guarantees that it will be performed."
@@ -363,7 +364,7 @@ ARTICLE: "handbook-library-reference" "Libraries"
 { $index [ orphan-articles { "help.home" "handbook" } diff ] } ;
 
 ARTICLE: "handbook" "Factor handbook"
-{ $heading "Getting Started" }
+{ $heading "Getting started" }
 { $subsections
     "cookbook"
     "first-program"
@@ -379,14 +380,14 @@ ARTICLE: "handbook" "Factor handbook"
     "alien"
     "handbook-library-reference"
 }
-{ $heading "Explore loaded libraries" }
+{ $heading "Index" }
 { $subsections
-    "article-index"
-    "primitive-index"
-    "error-index"
-    "class-index"
+  "vocab-index"
+  "article-index"
+  "primitive-index"
+  "error-index"
+  "class-index"
 }
-{ $heading "Explore the code base" }
-{ $subsections "vocab-index" } ;
+;
 
 ABOUT: "handbook"
index ddd6ce23fca8566b1c3689c1708d3c79d5dee7c4..6fb87d7a33a74c35cf61c989c00e2db8dcbeb3d8 100644 (file)
@@ -129,7 +129,7 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
 
 SYMBOL: help-hook
 
-help-hook [ [ print-topic ] ] initialize
+help-hook [ [ print-topic nl ] ] initialize
 
 : help ( topic -- )
     help-hook get call( topic -- ) ;
index b40d1626702c24a9d4db273c89e057f4ca7f2557..b5d23bd7fcea635c640deb789b066a25f0d34024 100644 (file)
@@ -2,22 +2,33 @@ IN: help.home
 USING: help.markup help.syntax ;
 
 ARTICLE: "help.home" "Factor documentation"
-"If this is your first time with Factor, you can start by writing " { $link "first-program" } "."
+{ $heading "Getting started" }
+{ $subsections
+    "cookbook"
+    "first-program"
+}
+{ $heading "User interface" }
+{ $subsections
+  "listener"
+  "ui-tools"
+}
 { $heading "Reference" }
-{ $list
-  { $link "handbook" }
-  { $link "vocab-index" }
-  { $link "ui-tools" }
-  { $link "ui-listener" }
+{ $subsections
+  "handbook"
+  "vocab-index"
+  "article-index"
+  "primitive-index"
+  "error-index"
+  "class-index"
 }
-{ $heading "Recently visited" }
+{ $heading "Searches" }
+"Use the search field in the top-right of the " { $link "ui-browser" } " window to search for words, vocabularies, and help articles."
+{ $recent-searches }
+{ $heading "Recently visited pages" }
 { $table
   { "Words" "Articles" "Vocabs" }
   { { $recent recent-words } { $recent recent-articles } { $recent recent-vocabs } }
 }
-"The browser, completion popups and other tools use a common set of " { $link "definitions.icons" } "."
-{ $heading "Recent searches" }
-{ $recent-searches }
-"Use the search field in the top-right of the " { $link "ui-browser" } " window to search for words, vocabularies and help articles." ;
+;
 
-ABOUT: "help.home"
\ No newline at end of file
+ABOUT: "help.home"
index 56f104a1a1234cf258dbeeb469b2efe7c487390b..340f9b16d3c1255f5c6c4abe03c81c59b895ccbc 100644 (file)
@@ -33,18 +33,18 @@ SYMBOL: vocab-articles
 
 : extract-values ( element -- seq )
     \ $values swap elements dup empty? [
-        first rest [ first ] map prune natural-sort
+        first rest [ first ] map prune
     ] unless ;
 
 : effect-values ( word -- seq )
     stack-effect
     [ in>> ] [ out>> ] bi append
-    [ dup pair? [ first ] when effect>string ] map
-    prune natural-sort ;
+    [ dup pair? [ first ] when effect>string ] map prune ;
 
 : contains-funky-elements? ( element -- ? )
     {
         $shuffle
+        $complex-shuffle
         $values-x/y
         $predicate
         $class-description
index ea64df3edcf3b724c6e93a24b32a707530823c8f..75e65382435fa8c60259fe39c6b848e0199a4766 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs classes colors colors.constants
-combinators definitions definitions.icons effects fry generic
-hashtables help.stylesheet help.topics io io.styles kernel make
-math namespaces parser present prettyprint
+combinators combinators.smart definitions definitions.icons effects
+fry generic hashtables help.stylesheet help.topics io io.styles
+kernel make math namespaces parser present prettyprint
 prettyprint.stylesheet quotations see sequences sets slots
 sorting splitting strings vectors vocabs vocabs.loader words
 words.symbol ;
@@ -398,7 +398,12 @@ M: f ($instance)
 
 : $shuffle ( element -- )
     drop
-    "Shuffle word. Re-arranges the stack according to the stack effect pattern." $description ;
+    "Shuffle word. Rearranges the top of the datastack as indicated in the stack effect pattern." $description ;
+
+: $complex-shuffle ( element -- )
+    drop
+    "Shuffle word. Rearranges the top of the datastack as indicated in the stack effect pattern." $description
+    { "The data flow represented by this shuffle word can be more clearly expressed using " { $link "locals" } "." } $deprecated ;
 
 : $low-level-note ( children -- )
     drop
@@ -430,8 +435,8 @@ M: simple-element elements*
 M: object elements* 2drop ;
 
 M: array elements*
-    [ [ elements* ] with each ] 2keep
-    [ first eq? ] keep swap [ , ] [ drop ] if ;
+    [ dup first \ $markup-example eq? [ 2drop ] [ [ elements* ] with each ] if ]
+    [ [ first eq? ] keep swap [ , ] [ drop ] if ] 2bi ;
 
 : elements ( elt-type element -- seq ) [ elements* ] { } make ;
 
@@ -449,4 +454,4 @@ M: array elements*
     icons get >alist sort-keys
     [ [ <$link> ] [ definition-icon-path <$image> ] bi* swap ] assoc-map
     { "" "Definition class" } prefix
-    $table ;
\ No newline at end of file
+    $table ;
index 8569be0b8f900ce66a61139624916da1c2dc34ab..06f2255dfaa0f28a9f089fa287b2fe142c491ac6 100644 (file)
@@ -10,7 +10,7 @@ tips [ V{ } clone ] initialize
 
 TUPLE: tip < identity-tuple content loc ;
 
-M: tip forget* tips get delq ;
+M: tip forget* tips get remove-eq! drop ;
 
 M: tip where loc>> ;
 
@@ -58,4 +58,4 @@ H{
 : $tips-of-the-day ( element -- )
     drop tips get [ nl nl ] [ content>> print-element ] interleave ;
 
-INSTANCE: tip definition
\ No newline at end of file
+INSTANCE: tip definition
index 5637dd92f450d549426c25107c78a28d0c041355..aca1ae43c9d6e878a3b55f0d8585f38d00809722 100644 (file)
@@ -1,5 +1,6 @@
-USING: help.vocabs tools.test help.markup help vocabs ;
+USING: help.vocabs tools.test help.markup help vocabs io ;
 IN: help.vocabs.tests
 
 [ ] [ { $vocab "scratchpad" } print-content ] unit-test
 [ ] [ "classes" vocab print-topic ] unit-test
+[ ] [ nl ] unit-test
index 56a2cb9142a1bdc2c1a90ab7c804ef929269a089..46bdc698b73a59874c1884ba25626bfec96aa5fa 100644 (file)
@@ -20,7 +20,7 @@ HELP: specialized-def
 { $description "Outputs the definition of a word after it has been split into specialized branches. This is the definition which will actually be compiled by the compiler." } ;
 
 HELP: HINTS:
-{ $values { "defspec" "a definition specifier" } { "hints..." "a list of sequences of classes or literals" } }
+{ $values { "defspec" "a word or method" } { "hints..." "a list of sequences of classes or literals" } }
 { $description "Defines specialization hints for a word or a method."
 $nl
 "Each sequence in the list will cause a specialized version of the word to be compiled. Classes are tested for using their predicate, and literals are tested using " { $link eq? } "." }
@@ -35,8 +35,8 @@ $nl
     "M: assoc count-occurrences"
     "    swap [ = nip ] curry assoc-filter assoc-size ;"
     ""
-    "HINTS: { sequence count-occurrences } { object array } ;"
-    "HINTS: { assoc count-occurrences } { object hashtable } ;"
+    "HINTS: M\ sequence count-occurrences { object array } ;"
+    "HINTS: M\ assoc count-occurrences { object hashtable } ;"
 }
 } ;
 
index f49d2e4229c88a84dcfa89946f61b04e180c738e..1ca5bf1bc54ff898a1fec4d11b8c5be848f463cc 100644 (file)
@@ -3,8 +3,9 @@
 USING: accessors arrays assocs byte-arrays byte-vectors classes
 combinators definitions effects fry generic generic.single
 generic.standard hashtables io.binary io.streams.string kernel
-kernel.private math math.parser namespaces parser sbufs
-sequences splitting splitting.private strings vectors words ;
+kernel.private math math.integers.private math.parser math.parser.private
+namespaces parser sbufs sequences splitting splitting.private strings
+vectors words ;
 IN: hints
 
 GENERIC: specializer-predicate ( spec -- quot )
@@ -78,9 +79,6 @@ SYNTAX: HINTS:
     [ parse-definition { } like "specializer" set-word-prop ] tri ;
 
 ! Default specializers
-{ first first2 first3 first4 }
-[ { array } "specializer" set-word-prop ] each
-
 { last pop* pop } [
     { vector } "specializer" set-word-prop
 ] each
@@ -103,7 +101,7 @@ SYNTAX: HINTS:
 { { fixnum fixnum string } { fixnum fixnum array } }
 "specializer" set-word-prop
 
-\ reverse-here
+\ reverse!
 { { string } { array } }
 "specializer" set-word-prop
 
@@ -121,7 +119,7 @@ SYNTAX: HINTS:
 
 \ split, { string string } "specializer" set-word-prop
 
-\ memq? { array } "specializer" set-word-prop
+\ member-eq? { array } "specializer" set-word-prop
 
 \ member? { array } "specializer" set-word-prop
 
@@ -136,3 +134,11 @@ SYNTAX: HINTS:
 M\ hashtable at* { { fixnum object } { word object } } "specializer" set-word-prop
 
 M\ hashtable set-at { { object fixnum object } { object word object } } "specializer" set-word-prop
+
+\ dec>float { string } "specializer" set-word-prop
+
+\ hex>float { string } "specializer" set-word-prop
+
+\ string>integer { string fixnum } "specializer" set-word-prop
+
+\ bignum/f { { bignum bignum } { bignum fixnum } { fixnum bignum } { fixnum fixnum } } "specializer" set-word-prop
index a98a21f177c2ca6ebdbaa4daf3e89a201220bec3..d4cb484a7919821c4615efe68216ca2f14a857d6 100644 (file)
@@ -31,14 +31,14 @@ DEFER: <% delimiter
 : found-<% ( accum lexer col -- accum )
     [
         over line-text>>
-        [ column>> ] 2dip subseq parsed
-        \ write parsed
+        [ column>> ] 2dip subseq suffix!
+        \ write suffix!
     ] 2keep 2 + >>column drop ;
 
 : still-looking ( accum lexer -- accum )
     [
         [ line-text>> ] [ column>> ] bi tail
-        parsed \ print parsed
+        suffix! \ print suffix!
     ] keep next-line ;
 
 : parse-%> ( accum lexer -- accum )
index 330db4467b12b5d07d67da1d47d1e01ed8b6a24d..04077fc2f7b0369b4cab6750041a1e57de778f6a 100644 (file)
@@ -1,7 +1,7 @@
 USING: http help.markup help.syntax io.pathnames io.streams.string
-io.encodings.8-bit io.encodings.binary kernel urls
+io.encodings.binary kernel urls
 urls.encoding byte-arrays strings assocs sequences destructors
-http.client.post-data.private ;
+http.client.post-data.private io.encodings.8-bit.latin1 ;
 IN: http.client
 
 HELP: download-failed
index 016e347e89bc2b66d62d5c2a8a983f3215cef796..482a23aeaa644328712528762155b16e210b9202 100644 (file)
@@ -5,7 +5,7 @@ sequences strings splitting calendar continuations accessors vectors
 math.order hashtables byte-arrays destructors
 io io.sockets io.streams.string io.files io.timeouts
 io.pathnames io.encodings io.encodings.string io.encodings.ascii
-io.encodings.utf8 io.encodings.8-bit io.encodings.binary io.crlf
+io.encodings.utf8 io.encodings.binary io.crlf
 io.streams.duplex fry ascii urls urls.encoding present locals
 http http.parsers http.client.post-data ;
 IN: http.client
index 3fe5e84abd6762a3cdd781ebbff437392d10041f..35d01c10141d7ebbd6157cb02206af74dcc1039e 100644 (file)
@@ -2,7 +2,8 @@ USING: http http.server http.client http.client.private tools.test
 multiline io.streams.string io.encodings.utf8 io.encodings.8-bit
 io.encodings.binary io.encodings.string io.encodings.ascii kernel
 arrays splitting sequences assocs io.sockets db db.sqlite
-continuations urls hashtables accessors namespaces xml.data ;
+continuations urls hashtables accessors namespaces xml.data
+io.encodings.8-bit.latin1 ;
 IN: http.tests
 
 [ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
index 4c32954eee29cddac0b1de331530209bb6ec3e02..6f898e949cfadbe4f818528caf565fb12254653a 100755 (executable)
@@ -5,9 +5,7 @@ sequences splitting sorting sets strings vectors hashtables
 quotations arrays byte-arrays math.parser calendar
 calendar.format present urls fry
 io io.encodings io.encodings.iana io.encodings.binary
-io.encodings.8-bit io.crlf ascii
-http.parsers
-base64 ;
+io.crlf ascii io.encodings.8-bit.latin1 http.parsers base64 ;
 IN: http
 
 CONSTANT: max-redirects 10
@@ -193,7 +191,7 @@ M: response clone
     [ cookies>> ] dip '[ [ _ ] dip name>> = ] find nip ;
 
 : delete-cookie ( request/response name -- )
-    over cookies>> [ get-cookie ] dip delete ;
+    over cookies>> [ get-cookie ] dip remove! drop ;
 
 : put-cookie ( request/response cookie -- request/response )
     [ name>> dupd get-cookie [ dupd delete-cookie ] when* ] keep
index 50926666f6239205473b2018e05e4e3a7520aa71..702fd14472fa2f2dc45a6035b93cff0c2c0fa8cb 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types arrays byte-arrays combinators
 compression.run-length fry grouping images images.loader io
-io.binary io.encodings.8-bit io.encodings.binary
+io.binary io.encodings.binary
 io.encodings.string io.streams.limited kernel math math.bitwise
-sequences specialized-arrays summary images.bitmap ;
+io.encodings.8-bit.latin1 sequences specialized-arrays summary images.bitmap ;
 QUALIFIED-WITH: bitstreams b
 SPECIALIZED-ARRAY: ushort
 IN: images.bitmap.loading
index 6e45dd1ce8813a545c2292a0b0220ea9ac17496f..e305c8477a18f63f2f3a80a0202d4a09018a48f7 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Marc Fauconneau.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays byte-arrays combinators
-grouping compression.huffman images
+grouping compression.huffman images fry
 images.processing io io.binary io.encodings.binary io.files
 io.streams.byte-array kernel locals math math.bitwise
 math.constants math.functions math.matrices math.order
@@ -232,7 +232,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
     block dup length>> sqrt >fixnum group flip
     dup matrix-dim coord-matrix flip
     [
-        [ first2 spin nth nth ]
+        [ '[ _ [ second ] [ first ] bi ] dip nth nth ]
         [ x,y v+ color-id jpeg-image draw-color ] bi
     ] with each^2 ;
 
@@ -295,7 +295,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
     binary [
         [
             { HEX: FF } read-until
-            read1 tuck HEX: 00 = and
+            read1 [ HEX: 00 = and ] keep swap
         ]
         [ drop ] produce
         swap >marker {  EOI } assert=
@@ -354,7 +354,7 @@ SINGLETONS: YUV420 YUV444 Y MAGIC! ;
     [ decode-macroblock 2array ] accumulator 
     [ all-macroblocks ] dip
     jpeg> setup-bitmap draw-macroblocks 
-    jpeg> bitmap>> 3 <groups> [ color-transform ] change-each
+    jpeg> bitmap>> 3 <groups> [ color-transform ] map! drop
     jpeg> [ >byte-array ] change-bitmap drop ;
 
 ERROR: not-a-jpeg-image ;
diff --git a/basis/images/normalization/authors.txt b/basis/images/normalization/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/images/normalization/normalization-docs.factor b/basis/images/normalization/normalization-docs.factor
new file mode 100644 (file)
index 0000000..8ed4b65
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2009 Keith Lazuka.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel images ;
+IN: images.normalization
+
+HELP: normalize-image
+{ $values
+    { "image" image }
+    { "image" image }
+}
+{ $description "Converts the image to RGBA with ubyte-components. If the image is upside-down, it will be flipped right side up such that the 1st byte in the bitmap slot's byte array corresponds to the first color component of the pixel in the upper-left corner of the image." } ;
+
+HELP: reorder-components
+{ $values
+    { "image" image } { "component-order" component-order }
+    { "image" image }
+}
+{ $description "Convert the bitmap in " { $snippet "image" } " such that the pixel sample layout corresponds to " { $snippet "component-order" } ". If the destination layout cannot find a corresponding value from the source layout, the value " { $snippet "255" } " will be substituted for that byte." }
+{ $warning "The image's " { $snippet "component-type" } " will be changed to " { $snippet "ubyte-components" } " if it is not already in that format."
+$nl
+"You cannot use this word to reorder " { $link DEPTH } ", " { $link DEPTH-STENCIL } " or " { $link INTENSITY } " component orders." } ;
+
+ARTICLE: "images.normalization" "Image normalization"
+"The " { $vocab-link "images.normalization" } " vocab can be used to convert between " { $link image } " representations."
+$nl
+"You can normalize any image to a RGBA with ubyte-components representation:"
+{ $subsections normalize-image }
+"Convert an image's pixel layout to match an arbitrary " { $link component-order } ":"
+{ $subsections reorder-components } ;
+
+ABOUT: "images.normalization"
diff --git a/basis/images/normalization/normalization-tests.factor b/basis/images/normalization/normalization-tests.factor
new file mode 100644 (file)
index 0000000..c85aed4
--- /dev/null
@@ -0,0 +1,108 @@
+! Copyright (C) 2009 Keith Lazuka.
+! See http://factorcode.org/license.txt for BSD license.
+USING: images images.normalization images.normalization.private
+sequences tools.test ;
+IN: images.normalization.tests
+
+! 1>x
+
+[ B{ 255 255 } ]
+[ B{ 0 1 } A L permute ] unit-test
+
+[ B{ 255 255 255 255 } ]
+[ B{ 0 1 } A RG permute ] unit-test
+
+[ B{ 255 255 255 255 255 255 } ]
+[ B{ 0 1 } A BGR permute ] unit-test
+
+[ B{ 0 255 255 255 1 255 255 255 } ]
+[ B{ 0 1 } A ABGR permute ] unit-test
+
+! 2>x
+
+[ B{ 0 2 } ]
+[ B{ 0 1 2 3 } LA L permute ] unit-test
+
+[ B{ 255 255 255 255 } ]
+[ B{ 0 1 2 3 } LA RG permute ] unit-test
+
+[ B{ 255 255 255 255 255 255 } ]
+[ B{ 0 1 2 3 } LA BGR permute ] unit-test
+
+[ B{ 1 255 255 255 3 255 255 255 } ]
+[ B{ 0 1 2 3 } LA ABGR permute ] unit-test
+
+! 3>x
+
+[ B{ 255 255 } ]
+[ B{ 0 1 2 3 4 5 } RGB L permute ] unit-test
+
+[ B{ 0 1 3 4 } ]
+[ B{ 0 1 2 3 4 5 } RGB RG permute ] unit-test
+
+[ B{ 2 1 0 5 4 3 } ]
+[ B{ 0 1 2 3 4 5 } RGB BGR permute ] unit-test
+
+[ B{ 255 2 1 0 255 5 4 3 } ]
+[ B{ 0 1 2 3 4 5 } RGB ABGR permute ] unit-test
+
+! 4>x
+
+[ B{ 255 255 } ]
+[ B{ 0 1 2 3 4 5 6 7 } RGBA L permute ] unit-test
+
+[ B{ 0 1 4 5 } ]
+[ B{ 0 1 2 3 4 5 6 7 } RGBA RG permute ] unit-test
+
+[ B{ 2 1 0 6 5 4 } ]
+[ B{ 0 1 2 3 4 5 6 7 } RGBA BGR permute ] unit-test
+
+[ B{ 3 2 1 0 7 6 5 4 } ]
+[ B{ 0 1 2 3 4 5 6 7 } RGBA ABGR permute ] unit-test
+
+! Edge cases
+
+[ B{ 0 4 } ]
+[ B{ 0 1 2 3 4 5 6 7 } RGBA R permute ] unit-test
+
+[ B{ 255 0 1 2 255 4 5 6 } ]
+[ B{ 0 1 2 3 4 5 6 7 } RGBA XRGB permute ] unit-test
+
+[ B{ 1 2 3 255 5 6 7 255 } ]
+[ B{ 0 1 2 3 4 5 6 7 } XRGB RGBA permute ] unit-test
+
+[ B{ 255 255 255 255 255 255 255 255 } ]
+[ B{ 0 1 } L RGBA permute ] unit-test
+
+! Invalid inputs
+
+[
+    T{ image f { 1 1 } DEPTH ubyte-components f B{ 0 } }
+    RGB reorder-components
+] must-fail
+
+[
+    T{ image f { 1 1 } DEPTH-STENCIL ubyte-components f B{ 0 } }
+    RGB reorder-components
+] must-fail
+
+[
+    T{ image f { 1 1 } INTENSITY ubyte-components f B{ 0 } }
+    RGB reorder-components
+] must-fail
+
+[
+    T{ image f { 1 1 } RGB ubyte-components f B{ 0 0 0 } }
+    DEPTH reorder-components
+] must-fail
+
+[
+    T{ image f { 1 1 } RGB ubyte-components f B{ 0 0 0 } }
+    DEPTH-STENCIL reorder-components
+] must-fail
+
+[
+    T{ image f { 1 1 } RGB ubyte-components f B{ 0 0 0 } }
+    INTENSITY reorder-components
+] must-fail
+
diff --git a/basis/images/normalization/normalization.factor b/basis/images/normalization/normalization.factor
new file mode 100755 (executable)
index 0000000..2bd7e68
--- /dev/null
@@ -0,0 +1,85 @@
+! Copyright (C) 2009 Doug Coleman, Keith Lazuka
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.c-types byte-arrays combinators fry
+grouping images kernel locals math math.vectors
+sequences specialized-arrays half-floats ;
+FROM: alien.c-types => float ;
+SPECIALIZED-ARRAY: half
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: ushort
+IN: images.normalization
+
+<PRIVATE
+
+CONSTANT: don't-care 127
+CONSTANT: fill-value 255
+
+: permutation ( src dst -- seq )
+    swap '[ _ index [ don't-care ] unless* ] { } map-as
+    4 don't-care pad-tail ;
+
+: pad4 ( seq -- newseq ) 4 fill-value pad-tail ;
+
+: shuffle ( seq permutation -- newseq )
+    swap '[
+        dup 4 >= [ drop fill-value ] [ _ nth ] if
+    ] B{ } map-as ;
+
+:: permute ( bytes src-order dst-order -- new-bytes )
+    src-order name>> :> src
+    dst-order name>> :> dst
+    bytes src length group
+    [ pad4 src dst permutation shuffle dst length head ]
+    map concat ;
+
+: (reorder-components) ( image src-order dest-order -- image )
+    [ permute ] 2curry change-bitmap ;
+
+GENERIC: normalize-component-type* ( image component-type -- image )
+
+: normalize-floats ( float-array -- byte-array )
+    [ 255.0 * >integer ] B{ } map-as ;
+
+M: float-components normalize-component-type*
+    drop byte-array>float-array normalize-floats ;
+
+M: half-components normalize-component-type*
+    drop byte-array>half-array normalize-floats ;
+
+: ushorts>ubytes ( bitmap -- bitmap' )
+    byte-array>ushort-array [ -8 shift ] B{ } map-as ; inline
+
+M: ushort-components normalize-component-type*
+    drop ushorts>ubytes ;
+
+M: ubyte-components normalize-component-type*
+    drop ;
+
+: normalize-scan-line-order ( image -- image )
+    dup upside-down?>> [
+        dup dim>> first 4 * '[
+            _ <groups> reverse concat
+        ] change-bitmap
+        f >>upside-down?
+    ] when ;
+
+: validate-request ( src-order dst-order -- src-order dst-order )
+    [
+        [ { DEPTH DEPTH-STENCIL INTENSITY } member? ] bi@
+        or [ "Invalid component-order" throw ] when
+    ] 2keep ;
+
+PRIVATE>
+
+: reorder-components ( image component-order -- image )
+    [
+        dup component-type>> '[ _ normalize-component-type* ] change-bitmap
+        dup component-order>>
+    ] dip
+    validate-request [ (reorder-components) ] keep >>component-order ;
+
+: normalize-image ( image -- image )
+    [ >byte-array ] change-bitmap
+    RGBA reorder-components
+    normalize-scan-line-order ;
+
index cb9a347de14507ea4e06157acf392e3c5e6b92df..26c3ebee349fbcbe59db9cf5f335d12598881bda 100755 (executable)
@@ -290,6 +290,14 @@ ERROR: invalid-color-type/bit-depth loading-png ;
 : validate-truecolor-alpha ( loading-png -- loading-png )
     { 8 16 } validate-bit-depth ;
 
+: pad-bitmap ( image -- image )
+    dup dim>> first 4 divisor? [
+        dup [ bytes-per-pixel ]
+        [ dim>> first * ]
+        [ dim>> first 4 mod ] tri
+        '[ _ group [ _ 0 <array> append ] map B{ } concat-as ] change-bitmap
+    ] unless ;
+
 : loading-png>bitmap ( loading-png -- bytes component-order )
     dup color-type>> {
         { greyscale [
@@ -315,7 +323,7 @@ ERROR: invalid-color-type/bit-depth loading-png ;
         [ loading-png>bitmap [ >>bitmap ] [ >>component-order ] bi* ]
         [ [ width>> ] [ height>> ] bi 2array >>dim ]
         [ png-component >>component-type ]
-    } cleave ;
+    } cleave pad-bitmap ;
 
 : load-png ( stream -- loading-png )
     [
diff --git a/basis/images/testing/bmp/1bit.bmp b/basis/images/testing/bmp/1bit.bmp
deleted file mode 100644 (file)
index 2f244c1..0000000
Binary files a/basis/images/testing/bmp/1bit.bmp and /dev/null differ
diff --git a/basis/images/testing/bmp/42red_24bit.bmp b/basis/images/testing/bmp/42red_24bit.bmp
deleted file mode 100644 (file)
index e95a4f7..0000000
Binary files a/basis/images/testing/bmp/42red_24bit.bmp and /dev/null differ
diff --git a/basis/images/testing/bmp/42red_24bit.fig b/basis/images/testing/bmp/42red_24bit.fig
deleted file mode 100644 (file)
index 9c2ce17..0000000
Binary files a/basis/images/testing/bmp/42red_24bit.fig and /dev/null differ
diff --git a/basis/images/testing/bmp/rgb_4bit.bmp b/basis/images/testing/bmp/rgb_4bit.bmp
deleted file mode 100644 (file)
index 0c6f00d..0000000
Binary files a/basis/images/testing/bmp/rgb_4bit.bmp and /dev/null differ
diff --git a/basis/images/testing/bmp/rgb_8bit.bmp b/basis/images/testing/bmp/rgb_8bit.bmp
deleted file mode 100644 (file)
index bc95c0f..0000000
Binary files a/basis/images/testing/bmp/rgb_8bit.bmp and /dev/null differ
diff --git a/basis/images/testing/bmp/rgb_8bit.fig b/basis/images/testing/bmp/rgb_8bit.fig
deleted file mode 100644 (file)
index 4b75a10..0000000
Binary files a/basis/images/testing/bmp/rgb_8bit.fig and /dev/null differ
diff --git a/basis/images/testing/gif/alpha.fig b/basis/images/testing/gif/alpha.fig
deleted file mode 100644 (file)
index b36a8f6..0000000
Binary files a/basis/images/testing/gif/alpha.fig and /dev/null differ
diff --git a/basis/images/testing/gif/alpha.gif b/basis/images/testing/gif/alpha.gif
deleted file mode 100644 (file)
index c4c38bd..0000000
Binary files a/basis/images/testing/gif/alpha.gif and /dev/null differ
diff --git a/basis/images/testing/gif/astronaut_animation.fig b/basis/images/testing/gif/astronaut_animation.fig
deleted file mode 100644 (file)
index 905da6d..0000000
Binary files a/basis/images/testing/gif/astronaut_animation.fig and /dev/null differ
diff --git a/basis/images/testing/gif/astronaut_animation.gif b/basis/images/testing/gif/astronaut_animation.gif
deleted file mode 100644 (file)
index 8c76848..0000000
Binary files a/basis/images/testing/gif/astronaut_animation.gif and /dev/null differ
diff --git a/basis/images/testing/gif/checkmark.fig b/basis/images/testing/gif/checkmark.fig
deleted file mode 100644 (file)
index c177d89..0000000
Binary files a/basis/images/testing/gif/checkmark.fig and /dev/null differ
diff --git a/basis/images/testing/gif/checkmark.gif b/basis/images/testing/gif/checkmark.gif
deleted file mode 100644 (file)
index df83efa..0000000
Binary files a/basis/images/testing/gif/checkmark.gif and /dev/null differ
diff --git a/basis/images/testing/gif/circle.fig b/basis/images/testing/gif/circle.fig
deleted file mode 100644 (file)
index 330397f..0000000
Binary files a/basis/images/testing/gif/circle.fig and /dev/null differ
diff --git a/basis/images/testing/gif/circle.gif b/basis/images/testing/gif/circle.gif
deleted file mode 100644 (file)
index 101a48a..0000000
Binary files a/basis/images/testing/gif/circle.gif and /dev/null differ
diff --git a/basis/images/testing/gif/monochrome.fig b/basis/images/testing/gif/monochrome.fig
deleted file mode 100644 (file)
index 69de845..0000000
Binary files a/basis/images/testing/gif/monochrome.fig and /dev/null differ
diff --git a/basis/images/testing/gif/monochrome.gif b/basis/images/testing/gif/monochrome.gif
deleted file mode 100644 (file)
index b0875fa..0000000
Binary files a/basis/images/testing/gif/monochrome.gif and /dev/null differ
diff --git a/basis/images/testing/gif/noise.fig b/basis/images/testing/gif/noise.fig
deleted file mode 100644 (file)
index a2650e9..0000000
Binary files a/basis/images/testing/gif/noise.fig and /dev/null differ
diff --git a/basis/images/testing/gif/noise.gif b/basis/images/testing/gif/noise.gif
deleted file mode 100644 (file)
index 31dffae..0000000
Binary files a/basis/images/testing/gif/noise.gif and /dev/null differ
diff --git a/basis/images/testing/png/basn2c08.fig b/basis/images/testing/png/basn2c08.fig
deleted file mode 100644 (file)
index 84f8c97..0000000
Binary files a/basis/images/testing/png/basn2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/basn2c08.png b/basis/images/testing/png/basn2c08.png
deleted file mode 100644 (file)
index db5ad15..0000000
Binary files a/basis/images/testing/png/basn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/basn6a08.fig b/basis/images/testing/png/basn6a08.fig
deleted file mode 100644 (file)
index f188879..0000000
Binary files a/basis/images/testing/png/basn6a08.fig and /dev/null differ
diff --git a/basis/images/testing/png/basn6a08.png b/basis/images/testing/png/basn6a08.png
deleted file mode 100644 (file)
index e608738..0000000
Binary files a/basis/images/testing/png/basn6a08.png and /dev/null differ
diff --git a/basis/images/testing/png/f00n2c08.fig b/basis/images/testing/png/f00n2c08.fig
deleted file mode 100644 (file)
index 6a6aef9..0000000
Binary files a/basis/images/testing/png/f00n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/f00n2c08.png b/basis/images/testing/png/f00n2c08.png
deleted file mode 100644 (file)
index d6a1fff..0000000
Binary files a/basis/images/testing/png/f00n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/f01n2c08.fig b/basis/images/testing/png/f01n2c08.fig
deleted file mode 100644 (file)
index f08c0bb..0000000
Binary files a/basis/images/testing/png/f01n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/f01n2c08.png b/basis/images/testing/png/f01n2c08.png
deleted file mode 100644 (file)
index 26fee95..0000000
Binary files a/basis/images/testing/png/f01n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/f02n2c08.fig b/basis/images/testing/png/f02n2c08.fig
deleted file mode 100644 (file)
index 722f02a..0000000
Binary files a/basis/images/testing/png/f02n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/f02n2c08.png b/basis/images/testing/png/f02n2c08.png
deleted file mode 100644 (file)
index e590f12..0000000
Binary files a/basis/images/testing/png/f02n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/f03n2c08.fig b/basis/images/testing/png/f03n2c08.fig
deleted file mode 100644 (file)
index 2a37fe6..0000000
Binary files a/basis/images/testing/png/f03n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/f03n2c08.png b/basis/images/testing/png/f03n2c08.png
deleted file mode 100644 (file)
index 7581150..0000000
Binary files a/basis/images/testing/png/f03n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/f04n2c08.fig b/basis/images/testing/png/f04n2c08.fig
deleted file mode 100644 (file)
index c0db771..0000000
Binary files a/basis/images/testing/png/f04n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/f04n2c08.png b/basis/images/testing/png/f04n2c08.png
deleted file mode 100644 (file)
index 3c8b511..0000000
Binary files a/basis/images/testing/png/f04n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi0g01.png b/basis/images/testing/png/suite/basi0g01.png
deleted file mode 100644 (file)
index 556fa72..0000000
Binary files a/basis/images/testing/png/suite/basi0g01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi0g02.png b/basis/images/testing/png/suite/basi0g02.png
deleted file mode 100644 (file)
index ce09821..0000000
Binary files a/basis/images/testing/png/suite/basi0g02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi0g04.png b/basis/images/testing/png/suite/basi0g04.png
deleted file mode 100644 (file)
index 3853273..0000000
Binary files a/basis/images/testing/png/suite/basi0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi0g08.png b/basis/images/testing/png/suite/basi0g08.png
deleted file mode 100644 (file)
index faed8be..0000000
Binary files a/basis/images/testing/png/suite/basi0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi0g16.png b/basis/images/testing/png/suite/basi0g16.png
deleted file mode 100644 (file)
index a9f2816..0000000
Binary files a/basis/images/testing/png/suite/basi0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi2c08.png b/basis/images/testing/png/suite/basi2c08.png
deleted file mode 100644 (file)
index 2aab44d..0000000
Binary files a/basis/images/testing/png/suite/basi2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi2c16.png b/basis/images/testing/png/suite/basi2c16.png
deleted file mode 100644 (file)
index cd7e50f..0000000
Binary files a/basis/images/testing/png/suite/basi2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi3p01.png b/basis/images/testing/png/suite/basi3p01.png
deleted file mode 100644 (file)
index 00a7cea..0000000
Binary files a/basis/images/testing/png/suite/basi3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi3p02.png b/basis/images/testing/png/suite/basi3p02.png
deleted file mode 100644 (file)
index bb16b44..0000000
Binary files a/basis/images/testing/png/suite/basi3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi3p04.png b/basis/images/testing/png/suite/basi3p04.png
deleted file mode 100644 (file)
index b4e888e..0000000
Binary files a/basis/images/testing/png/suite/basi3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi3p08.png b/basis/images/testing/png/suite/basi3p08.png
deleted file mode 100644 (file)
index 50a6d1c..0000000
Binary files a/basis/images/testing/png/suite/basi3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi4a08.png b/basis/images/testing/png/suite/basi4a08.png
deleted file mode 100644 (file)
index 398132b..0000000
Binary files a/basis/images/testing/png/suite/basi4a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi4a16.png b/basis/images/testing/png/suite/basi4a16.png
deleted file mode 100644 (file)
index 51192e7..0000000
Binary files a/basis/images/testing/png/suite/basi4a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi6a08.png b/basis/images/testing/png/suite/basi6a08.png
deleted file mode 100644 (file)
index aecb32e..0000000
Binary files a/basis/images/testing/png/suite/basi6a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basi6a16.png b/basis/images/testing/png/suite/basi6a16.png
deleted file mode 100644 (file)
index 4181533..0000000
Binary files a/basis/images/testing/png/suite/basi6a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn0g01.png b/basis/images/testing/png/suite/basn0g01.png
deleted file mode 100644 (file)
index 1d72242..0000000
Binary files a/basis/images/testing/png/suite/basn0g01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn0g02.png b/basis/images/testing/png/suite/basn0g02.png
deleted file mode 100644 (file)
index 5083324..0000000
Binary files a/basis/images/testing/png/suite/basn0g02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn0g04.png b/basis/images/testing/png/suite/basn0g04.png
deleted file mode 100644 (file)
index 0bf3687..0000000
Binary files a/basis/images/testing/png/suite/basn0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn0g08.png b/basis/images/testing/png/suite/basn0g08.png
deleted file mode 100644 (file)
index 23c8237..0000000
Binary files a/basis/images/testing/png/suite/basn0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn0g16.png b/basis/images/testing/png/suite/basn0g16.png
deleted file mode 100644 (file)
index e7c82f7..0000000
Binary files a/basis/images/testing/png/suite/basn0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn2c08.png b/basis/images/testing/png/suite/basn2c08.png
deleted file mode 100644 (file)
index db5ad15..0000000
Binary files a/basis/images/testing/png/suite/basn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn2c16.png b/basis/images/testing/png/suite/basn2c16.png
deleted file mode 100644 (file)
index 50c1cb9..0000000
Binary files a/basis/images/testing/png/suite/basn2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn3p01.png b/basis/images/testing/png/suite/basn3p01.png
deleted file mode 100644 (file)
index b145c2b..0000000
Binary files a/basis/images/testing/png/suite/basn3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn3p02.png b/basis/images/testing/png/suite/basn3p02.png
deleted file mode 100644 (file)
index 8985b3d..0000000
Binary files a/basis/images/testing/png/suite/basn3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn3p04.png b/basis/images/testing/png/suite/basn3p04.png
deleted file mode 100644 (file)
index 0fbf9e8..0000000
Binary files a/basis/images/testing/png/suite/basn3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn3p08.png b/basis/images/testing/png/suite/basn3p08.png
deleted file mode 100644 (file)
index 0ddad07..0000000
Binary files a/basis/images/testing/png/suite/basn3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn4a08.png b/basis/images/testing/png/suite/basn4a08.png
deleted file mode 100644 (file)
index 3e13052..0000000
Binary files a/basis/images/testing/png/suite/basn4a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn4a16.png b/basis/images/testing/png/suite/basn4a16.png
deleted file mode 100644 (file)
index 8243644..0000000
Binary files a/basis/images/testing/png/suite/basn4a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn6a08.png b/basis/images/testing/png/suite/basn6a08.png
deleted file mode 100644 (file)
index e608738..0000000
Binary files a/basis/images/testing/png/suite/basn6a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/basn6a16.png b/basis/images/testing/png/suite/basn6a16.png
deleted file mode 100644 (file)
index 984a995..0000000
Binary files a/basis/images/testing/png/suite/basn6a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgai4a08.png b/basis/images/testing/png/suite/bgai4a08.png
deleted file mode 100644 (file)
index 398132b..0000000
Binary files a/basis/images/testing/png/suite/bgai4a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgai4a16.png b/basis/images/testing/png/suite/bgai4a16.png
deleted file mode 100644 (file)
index 51192e7..0000000
Binary files a/basis/images/testing/png/suite/bgai4a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgan6a08.png b/basis/images/testing/png/suite/bgan6a08.png
deleted file mode 100644 (file)
index e608738..0000000
Binary files a/basis/images/testing/png/suite/bgan6a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgan6a16.png b/basis/images/testing/png/suite/bgan6a16.png
deleted file mode 100644 (file)
index 984a995..0000000
Binary files a/basis/images/testing/png/suite/bgan6a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgbn4a08.png b/basis/images/testing/png/suite/bgbn4a08.png
deleted file mode 100644 (file)
index 7cbefc3..0000000
Binary files a/basis/images/testing/png/suite/bgbn4a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bggn4a16.png b/basis/images/testing/png/suite/bggn4a16.png
deleted file mode 100644 (file)
index 13fd85b..0000000
Binary files a/basis/images/testing/png/suite/bggn4a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgwn6a08.png b/basis/images/testing/png/suite/bgwn6a08.png
deleted file mode 100644 (file)
index a67ff20..0000000
Binary files a/basis/images/testing/png/suite/bgwn6a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/bgyn6a16.png b/basis/images/testing/png/suite/bgyn6a16.png
deleted file mode 100644 (file)
index ae3e9be..0000000
Binary files a/basis/images/testing/png/suite/bgyn6a16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ccwn2c08.png b/basis/images/testing/png/suite/ccwn2c08.png
deleted file mode 100644 (file)
index 47c2481..0000000
Binary files a/basis/images/testing/png/suite/ccwn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ccwn3p08.png b/basis/images/testing/png/suite/ccwn3p08.png
deleted file mode 100644 (file)
index 8bb2c10..0000000
Binary files a/basis/images/testing/png/suite/ccwn3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cdfn2c08.png b/basis/images/testing/png/suite/cdfn2c08.png
deleted file mode 100644 (file)
index 559e526..0000000
Binary files a/basis/images/testing/png/suite/cdfn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cdhn2c08.png b/basis/images/testing/png/suite/cdhn2c08.png
deleted file mode 100644 (file)
index 3e07e8e..0000000
Binary files a/basis/images/testing/png/suite/cdhn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cdsn2c08.png b/basis/images/testing/png/suite/cdsn2c08.png
deleted file mode 100644 (file)
index 076c32c..0000000
Binary files a/basis/images/testing/png/suite/cdsn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cdun2c08.png b/basis/images/testing/png/suite/cdun2c08.png
deleted file mode 100644 (file)
index 846033b..0000000
Binary files a/basis/images/testing/png/suite/cdun2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ch1n3p04.png b/basis/images/testing/png/suite/ch1n3p04.png
deleted file mode 100644 (file)
index 17cd12d..0000000
Binary files a/basis/images/testing/png/suite/ch1n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ch2n3p08.png b/basis/images/testing/png/suite/ch2n3p08.png
deleted file mode 100644 (file)
index 25c1798..0000000
Binary files a/basis/images/testing/png/suite/ch2n3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cm0n0g04.png b/basis/images/testing/png/suite/cm0n0g04.png
deleted file mode 100644 (file)
index 9fba5db..0000000
Binary files a/basis/images/testing/png/suite/cm0n0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cm7n0g04.png b/basis/images/testing/png/suite/cm7n0g04.png
deleted file mode 100644 (file)
index f7dc46e..0000000
Binary files a/basis/images/testing/png/suite/cm7n0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cm9n0g04.png b/basis/images/testing/png/suite/cm9n0g04.png
deleted file mode 100644 (file)
index dd70911..0000000
Binary files a/basis/images/testing/png/suite/cm9n0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cs3n2c16.png b/basis/images/testing/png/suite/cs3n2c16.png
deleted file mode 100644 (file)
index bf5fd20..0000000
Binary files a/basis/images/testing/png/suite/cs3n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cs3n3p08.png b/basis/images/testing/png/suite/cs3n3p08.png
deleted file mode 100644 (file)
index f4a6623..0000000
Binary files a/basis/images/testing/png/suite/cs3n3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cs5n2c08.png b/basis/images/testing/png/suite/cs5n2c08.png
deleted file mode 100644 (file)
index 40f947c..0000000
Binary files a/basis/images/testing/png/suite/cs5n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cs5n3p08.png b/basis/images/testing/png/suite/cs5n3p08.png
deleted file mode 100644 (file)
index dfd6e6e..0000000
Binary files a/basis/images/testing/png/suite/cs5n3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cs8n2c08.png b/basis/images/testing/png/suite/cs8n2c08.png
deleted file mode 100644 (file)
index 8e01d32..0000000
Binary files a/basis/images/testing/png/suite/cs8n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/cs8n3p08.png b/basis/images/testing/png/suite/cs8n3p08.png
deleted file mode 100644 (file)
index a44066e..0000000
Binary files a/basis/images/testing/png/suite/cs8n3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ct0n0g04.png b/basis/images/testing/png/suite/ct0n0g04.png
deleted file mode 100644 (file)
index 40d1e06..0000000
Binary files a/basis/images/testing/png/suite/ct0n0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ct1n0g04.png b/basis/images/testing/png/suite/ct1n0g04.png
deleted file mode 100644 (file)
index 3ba110a..0000000
Binary files a/basis/images/testing/png/suite/ct1n0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ctzn0g04.png b/basis/images/testing/png/suite/ctzn0g04.png
deleted file mode 100644 (file)
index b4401c9..0000000
Binary files a/basis/images/testing/png/suite/ctzn0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f00n0g08.png b/basis/images/testing/png/suite/f00n0g08.png
deleted file mode 100644 (file)
index 45a0075..0000000
Binary files a/basis/images/testing/png/suite/f00n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f00n2c08.png b/basis/images/testing/png/suite/f00n2c08.png
deleted file mode 100644 (file)
index d6a1fff..0000000
Binary files a/basis/images/testing/png/suite/f00n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f01n0g08.png b/basis/images/testing/png/suite/f01n0g08.png
deleted file mode 100644 (file)
index 4a1107b..0000000
Binary files a/basis/images/testing/png/suite/f01n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f01n2c08.png b/basis/images/testing/png/suite/f01n2c08.png
deleted file mode 100644 (file)
index 26fee95..0000000
Binary files a/basis/images/testing/png/suite/f01n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f02n0g08.png b/basis/images/testing/png/suite/f02n0g08.png
deleted file mode 100644 (file)
index bfe410c..0000000
Binary files a/basis/images/testing/png/suite/f02n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f02n2c08.png b/basis/images/testing/png/suite/f02n2c08.png
deleted file mode 100644 (file)
index e590f12..0000000
Binary files a/basis/images/testing/png/suite/f02n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f03n0g08.png b/basis/images/testing/png/suite/f03n0g08.png
deleted file mode 100644 (file)
index ed01e29..0000000
Binary files a/basis/images/testing/png/suite/f03n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f03n2c08.png b/basis/images/testing/png/suite/f03n2c08.png
deleted file mode 100644 (file)
index 7581150..0000000
Binary files a/basis/images/testing/png/suite/f03n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f04n0g08.png b/basis/images/testing/png/suite/f04n0g08.png
deleted file mode 100644 (file)
index 663fdae..0000000
Binary files a/basis/images/testing/png/suite/f04n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/f04n2c08.png b/basis/images/testing/png/suite/f04n2c08.png
deleted file mode 100644 (file)
index 3c8b511..0000000
Binary files a/basis/images/testing/png/suite/f04n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g03n0g16.png b/basis/images/testing/png/suite/g03n0g16.png
deleted file mode 100644 (file)
index 41083ca..0000000
Binary files a/basis/images/testing/png/suite/g03n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g03n2c08.png b/basis/images/testing/png/suite/g03n2c08.png
deleted file mode 100644 (file)
index a9354db..0000000
Binary files a/basis/images/testing/png/suite/g03n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g03n3p04.png b/basis/images/testing/png/suite/g03n3p04.png
deleted file mode 100644 (file)
index 60396c9..0000000
Binary files a/basis/images/testing/png/suite/g03n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g04n0g16.png b/basis/images/testing/png/suite/g04n0g16.png
deleted file mode 100644 (file)
index 32395b7..0000000
Binary files a/basis/images/testing/png/suite/g04n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g04n2c08.png b/basis/images/testing/png/suite/g04n2c08.png
deleted file mode 100644 (file)
index a652b0c..0000000
Binary files a/basis/images/testing/png/suite/g04n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g04n3p04.png b/basis/images/testing/png/suite/g04n3p04.png
deleted file mode 100644 (file)
index 5661cc3..0000000
Binary files a/basis/images/testing/png/suite/g04n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g05n0g16.png b/basis/images/testing/png/suite/g05n0g16.png
deleted file mode 100644 (file)
index 70b37f0..0000000
Binary files a/basis/images/testing/png/suite/g05n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g05n2c08.png b/basis/images/testing/png/suite/g05n2c08.png
deleted file mode 100644 (file)
index 932c136..0000000
Binary files a/basis/images/testing/png/suite/g05n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g05n3p04.png b/basis/images/testing/png/suite/g05n3p04.png
deleted file mode 100644 (file)
index 9619930..0000000
Binary files a/basis/images/testing/png/suite/g05n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g07n0g16.png b/basis/images/testing/png/suite/g07n0g16.png
deleted file mode 100644 (file)
index d6a47c2..0000000
Binary files a/basis/images/testing/png/suite/g07n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g07n2c08.png b/basis/images/testing/png/suite/g07n2c08.png
deleted file mode 100644 (file)
index 5973464..0000000
Binary files a/basis/images/testing/png/suite/g07n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g07n3p04.png b/basis/images/testing/png/suite/g07n3p04.png
deleted file mode 100644 (file)
index c73fb61..0000000
Binary files a/basis/images/testing/png/suite/g07n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g10n0g16.png b/basis/images/testing/png/suite/g10n0g16.png
deleted file mode 100644 (file)
index 85f2c95..0000000
Binary files a/basis/images/testing/png/suite/g10n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g10n2c08.png b/basis/images/testing/png/suite/g10n2c08.png
deleted file mode 100644 (file)
index b303997..0000000
Binary files a/basis/images/testing/png/suite/g10n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g10n3p04.png b/basis/images/testing/png/suite/g10n3p04.png
deleted file mode 100644 (file)
index 1b6a6be..0000000
Binary files a/basis/images/testing/png/suite/g10n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g25n0g16.png b/basis/images/testing/png/suite/g25n0g16.png
deleted file mode 100644 (file)
index a9f6787..0000000
Binary files a/basis/images/testing/png/suite/g25n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g25n2c08.png b/basis/images/testing/png/suite/g25n2c08.png
deleted file mode 100644 (file)
index 03f505a..0000000
Binary files a/basis/images/testing/png/suite/g25n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/g25n3p04.png b/basis/images/testing/png/suite/g25n3p04.png
deleted file mode 100644 (file)
index 4f943c6..0000000
Binary files a/basis/images/testing/png/suite/g25n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi1n0g16.png b/basis/images/testing/png/suite/oi1n0g16.png
deleted file mode 100644 (file)
index e7c82f7..0000000
Binary files a/basis/images/testing/png/suite/oi1n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi1n2c16.png b/basis/images/testing/png/suite/oi1n2c16.png
deleted file mode 100644 (file)
index 50c1cb9..0000000
Binary files a/basis/images/testing/png/suite/oi1n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi2n0g16.png b/basis/images/testing/png/suite/oi2n0g16.png
deleted file mode 100644 (file)
index 14d64c5..0000000
Binary files a/basis/images/testing/png/suite/oi2n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi2n2c16.png b/basis/images/testing/png/suite/oi2n2c16.png
deleted file mode 100644 (file)
index 4c2e3e3..0000000
Binary files a/basis/images/testing/png/suite/oi2n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi4n0g16.png b/basis/images/testing/png/suite/oi4n0g16.png
deleted file mode 100644 (file)
index 69e73ed..0000000
Binary files a/basis/images/testing/png/suite/oi4n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi4n2c16.png b/basis/images/testing/png/suite/oi4n2c16.png
deleted file mode 100644 (file)
index 93691e3..0000000
Binary files a/basis/images/testing/png/suite/oi4n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi9n0g16.png b/basis/images/testing/png/suite/oi9n0g16.png
deleted file mode 100644 (file)
index 9248413..0000000
Binary files a/basis/images/testing/png/suite/oi9n0g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/oi9n2c16.png b/basis/images/testing/png/suite/oi9n2c16.png
deleted file mode 100644 (file)
index f0512e4..0000000
Binary files a/basis/images/testing/png/suite/oi9n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/pngsuite.doc b/basis/images/testing/png/suite/pngsuite.doc
deleted file mode 100644 (file)
index 7da918b..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-        PNGSUITE
-----------------
-
-        testset for PNG-(de)coders
-        created by Willem van Schaik
-------------------------------------
-
-This is a collection of graphics images created to test the png applications
-like viewers, converters and editors. All (as far as that is possible)
-formats supported by the PNG standard are represented.
-
-
-1.      INTRODUCTION
---------------------
-
-1.1     PNG capabilities
-------------------------
-
-Supported color-types are:
-
-        -   grayscale
-        -   grayscale + alpha-channel
-        -   color palettes
-        -   rgb
-        -   rgb + alpha-channel
-
-Allowed bitdepths are depending on the color-type, but are in the range
-of 1-bit (grayscale, which is b&w) upto 16-bits.
-
-Special features are:
-
-        -   interlacing (Adam-7)
-        -   gamma-support
-        -   transparency (a poor-man's alpha solution)
-
-
-1.2     File naming
--------------------
-
-Where possible, the testfiles are 32x32 bits icons. This results in a still
-reasonable size of the suite even with a large number of tests. The name
-of each test-file reflects thetype in the following way:
-
-        g04i2c08.png
-        || |||+---- bit-depth
-        || ||+----- color-type (descriptive)
-        || |+------ color-type (numerical)
-        || +------- interlaced or non-interlaced
-        |+--------- parameter of test (in this case gamma-value)
-        +---------- test feature (in this case gamma)
-
-
-1.3     PNG formats
--------------------
-
-color-type:
-        0g          -   grayscale
-        2c          -   rgb color
-        3p          -   paletted
-        4a          -   grayscale + alpha channel
-        6a          -   rgb color + alpha channel
-
-bit-depth:
-        01          -   with color-type 0, 3
-        02          -   with color-type 0, 3
-        04          -   with color-type 0, 3
-        08          -   with color-type 0, 2, 3, 4, 6
-        16          -   with color-type 0, 2, 4, 6
-
-interlacing:
-        n           -   non-interlaced
-        i           -   interlaced
-
-
-2.      THE TESTS
------------------
-
-2.1     Sizes
--------------
-
-These tests are there to check if your software handles pictures well, with
-picture sizes that are not a multiple of 8. This is particularly important
-with Adam-7 type interlacing. In the same way these tests check if pictures
-size 1x1 and similar are ok.
-
-        s01         -   1x1 pixel picture
-        s02         -   2x2 pixel picture
-        s03         -   3x3 pixel picture
-        s04         -   4x4 pixel picture
-        s05         -   5x5 pixel picture
-        s06         -   6x6 pixel picture
-        s07         -   7x7 pixel picture
-        s08         -   8x8 pixel picture
-        s09         -   9x9 pixel picture
-        s32         -   32x32 pixel picture
-        s33         -   33x33 pixel picture
-        s34         -   34x34 pixel picture
-        s35         -   35x35 pixel picture
-        s36         -   36x36 pixel picture
-        s37         -   37x37 pixel picture
-        s38         -   38x38 pixel picture
-        s39         -   39x39 pixel picture
-        s40         -   40x40 pixel picture
-
-
-2.2     Background
-------------------
-
-When the PNG file contains a background chunck, this should be used for
-pictures with alpha-channel or pictures with a transparency chunck. For
-pictures without this background-chunk, but with alpha, this testset
-assumes a black background.
-
-For the images in this test, the left-side should be 100% the background
-color, where moving to the right the color should gradually become the
-image pattern.
-
-        bga         -   alpha + no background
-        bgw         -   alpha + white background
-        bgg         -   alpha + gray background
-        bgb         -   alpha + black background
-        bgy         -   alpha + yellow background
-
-
-2.3     Transparency
---------------------
-
-Transparency should be used together with a background chunk. To test the
-combination of the two the latter 4 tests are there. How to handle pictures
-with transparancy, but without a background, opinions can differ. Here we
-use black, but especially in the case of paletted images, the normal color
-would maybe even be better.
-
-        tp0         -   not transparent for reference
-        tp1         -   transparent, but no background chunk
-        tbw         -   transparent + white background
-        tbg         -   transparent + gray background
-        tbb         -   transparent + black background
-        tby         -   transparent + yellow background
-
-
-2.4     Gamma
--------------
-
-To test if your viewer handles gamma-correction, 6 testfiles are available.
-They contain corrected color-ramps and a corresponding gamma-chunk with the
-file-gamma value. These are created in such a way that when the viewer does
-the gamma correction right, all 6 should be displayed identical.
-
-If they are different, probably the gamma correction is omitted. In that
-case, have a look at the two right coloumns in the 6 pictures. The image
-where those two look the same (when looked from far) reflects the gamma of
-your system. However, because of the limited size of the image, you should
-do more elaborate tests to determine your display gamma.
-
-        g03         -   file-gamma = 0.35, for display with gamma = 2.8
-        g04         -   file-gamma = 0.45, for display with gamma = 2.2 (PC)
-        g05         -   file-gamma = 0.55, for display with gamma = 1.8 (Mac)
-        g07         -   file-gamma = 0.70, for display with gamma = 1.4
-        g10         -   file-gamma = 1.00, for display with gamma = 1.0 (NeXT)
-        g25         -   file-gamma = 2.50, for display with gamma = 0.4
-
-
-2.5     Filtering
------------------
-
-PNG uses file-filtering, for optimal compression. Normally the type is of
-filtering is adjusted to the contents of the picture, but here each file
-has the same picture, with a different filtering.
-
-        f0          -   no filtering
-        f1          -   sub filtering
-        f2          -   up filtering
-        f3          -   average filtering
-        f4          -   paeth filtering
-
-
-2.6     Additional palettes
----------------------------
-
-Besides the normal use of paletted images, palette chunks can in combination
-with true-color (and other) images also be used to select color lookup-tables
-when the video system is of limited capabilities. The suggested palette chunk
-is specially created for this purpose.
-
-        pp          -   normal palette chunk
-        ps          -   suggested palette chunk
-
-
-2.7     Ancillary chunks (under construction)
-------------------------
-
-To test the correct decoding of ancillary chunks, these test-files contain
-one or more examples of these chunkcs. Depending on the type of chunk, a
-number of typical values are selected to test. Unluckily, the testset can
-not contain all combinations, because that would be an endless set.
-
-The significant bits are used in files with the next higher bit-depth. They
-indicate howmany bits are valid.
-
-        cs3         -   3 significant bits
-        cs5         -   5 significant bits
-        cs8         -   8 significant bits (reference)
-        cs3         -   13 significant bits
-
-For the physical pixel dimensions, the result of each decoding should be
-a sqare picture. The first (cdf) image is an example of flat (horizontal)
-pixels, where the pHYS chunk (x is 1 per unit, y = 4 per unit) must take
-care of the correction. The second is just the other way round. The last
-example uses the unit specifier, for 1000 pixels per meter. This should
-result in a picture of 3.2 cm square.
-
-        cdf         -   physical pixel dimensions, 8x32 flat pixels
-        cdh         -   physical pixel dimensions, 32x8 high pixels
-        cds         -   physical pixel dimensions, 8x8 square pixels
-        cdu         -   physical pixel dimensions, with unit-specifier
-
-        ccw         -   primary chromaticities and white point
-
-        ch1         -   histogram 15 colors
-        ch2         -   histogram 256 colors
-
-        cm7         -   modification time, 01-jan-1970
-        cm9         -   modification time, 31-dec-1999
-        cm0         -   modification time, 01-jan-2000
-
-In the textual chunk, a number of the standard, and some non-standard
-text items are included.
-
-        ct0         -   no textual data
-        ct1         -   with textual data
-        ctz         -   with compressed textual data
-
-
-2.8     Chunk ordering (still under construction)
-----------------------
-
-These testfiles will test the obligatory ordering relations between various
-chunk types (not yet) as well as the number of data chunks used for the image.
-
-        oi1         -   mother image with 1 idat-chunk
-        oi2         -   image with 2 idat-chunks
-        oi4         -   image with 4 unequal sized idat-chunks
-        oi9         -   all idat-chunks of length one
-
-
-2.9     Compression level
--------------------------
-
-Here you will find a set of images compressed by zlib, ranging from level 0 
-for no compression at maximum speed upto level 9 for maximum compression.
-
-        z00         -   zlib compression level 0 - none
-        z03         -   zlib compression level 3
-        z06         -   zlib compression level 6 - default
-        z09         -   zlib compression level 9 - maximum
-
-
-2.10     Corrupted files (under construction)
------------------------
-
-All these files are illegal. When decoding they should generate appropriate
-error-messages.
-
-        x00         -   empty IDAT chunk
-        xcr         -   added cr bytes
-        xlf         -   added lf bytes
-        xc0         -   color type 0
-        xc9         -   color type 9
-        xd0         -   bit-depth 0
-        xd3         -   bit-depth 3
-        xd9         -   bit-depth 99
-        xcs         -   incorrect IDAT checksum
-
-
-3.      TEST FILES
-------------------
-
-For each of the tests listed above, one or more test-files are created. A
-selection is made (for each test) for the color-type and bitdepth to be used
-for the tests. Further for a number of tests, both a non-interlaced as well
-as an interlaced version is available.
-
-
-3.1     Basic format test files (non-interlaced)
-------------------------------------------------
-
-        basn0g01    -   black & white
-        basn0g02    -   2 bit (4 level) grayscale
-        basn0g04    -   4 bit (16 level) grayscale
-        basn0g08    -   8 bit (256 level) grayscale
-        basn0g16    -   16 bit (64k level) grayscale
-        basn2c08    -   3x8 bits rgb color
-        basn2c16    -   3x16 bits rgb color
-        basn3p01    -   1 bit (2 color) paletted
-        basn3p02    -   2 bit (4 color) paletted
-        basn3p04    -   4 bit (16 color) paletted
-        basn3p08    -   8 bit (256 color) paletted
-        basn4a08    -   8 bit grayscale + 8 bit alpha-channel
-        basn4a16    -   16 bit grayscale + 16 bit alpha-channel
-        basn6a08    -   3x8 bits rgb color + 8 bit alpha-channel
-        basn6a16    -   3x16 bits rgb color + 16 bit alpha-channel
-
-
-3.2     Basic format test files (Adam-7 interlaced)
----------------------------------------------------
-
-        basi0g01    -   black & white
-        basi0g02    -   2 bit (4 level) grayscale
-        basi0g04    -   4 bit (16 level) grayscale
-        basi0g08    -   8 bit (256 level) grayscale
-        basi0g16    -   16 bit (64k level) grayscale
-        basi2c08    -   3x8 bits rgb color
-        basi2c16    -   3x16 bits rgb color
-        basi3p01    -   1 bit (2 color) paletted
-        basi3p02    -   2 bit (4 color) paletted
-        basi3p04    -   4 bit (16 color) paletted
-        basi3p08    -   8 bit (256 color) paletted
-        basi4a08    -   8 bit grayscale + 8 bit alpha-channel
-        basi4a16    -   16 bit grayscale + 16 bit alpha-channel
-        basi6a08    -   3x8 bits rgb color + 8 bit alpha-channel
-        basi6a16    -   3x16 bits rgb color + 16 bit alpha-channel
-
-
-3.3     Sizes test files
------------------------
-
-        s01n3p01    -   1x1 paletted file, no interlacing
-        s02n3p01    -   2x2 paletted file, no interlacing
-        s03n3p01    -   3x3 paletted file, no interlacing
-        s04n3p01    -   4x4 paletted file, no interlacing
-        s05n3p02    -   5x5 paletted file, no interlacing
-        s06n3p02    -   6x6 paletted file, no interlacing
-        s07n3p02    -   7x7 paletted file, no interlacing
-        s08n3p02    -   8x8 paletted file, no interlacing
-        s09n3p02    -   9x9 paletted file, no interlacing
-        s32n3p04    -   32x32 paletted file, no interlacing
-        s33n3p04    -   33x33 paletted file, no interlacing
-        s34n3p04    -   34x34 paletted file, no interlacing
-        s35n3p04    -   35x35 paletted file, no interlacing
-        s36n3p04    -   36x36 paletted file, no interlacing
-        s37n3p04    -   37x37 paletted file, no interlacing
-        s38n3p04    -   38x38 paletted file, no interlacing
-        s39n3p04    -   39x39 paletted file, no interlacing
-        s40n3p04    -   40x40 paletted file, no interlacing
-
-        s01i3p01    -   1x1 paletted file, interlaced
-        s02i3p01    -   2x2 paletted file, interlaced
-        s03i3p01    -   3x3 paletted file, interlaced
-        s04i3p01    -   4x4 paletted file, interlaced
-        s05i3p02    -   5x5 paletted file, interlaced
-        s06i3p02    -   6x6 paletted file, interlaced
-        s07i3p02    -   7x7 paletted file, interlaced
-        s08i3p02    -   8x8 paletted file, interlaced
-        s09i3p02    -   9x9 paletted file, interlaced
-        s32i3p04    -   32x32 paletted file, interlaced
-        s33i3p04    -   33x33 paletted file, interlaced
-        s34i3p04    -   34x34 paletted file, interlaced
-        s35i3p04    -   35x35 paletted file, interlaced
-        s36i3p04    -   36x36 paletted file, interlaced
-        s37i3p04    -   37x37 paletted file, interlaced
-        s38i3p04    -   38x38 paletted file, interlaced
-        s39i3p04    -   39x39 paletted file, interlaced
-        s40i3p04    -   40x40 paletted file, interlaced
-
-
-3.4     Background test files (with alpha)
-------------------------------------------
-
-        bgai4a08    -   8 bit grayscale, alpha, no background chunk, interlaced
-        bgai4a16    -   16 bit grayscale, alpha, no background chunk, interlaced
-        bgan6a08    -   3x8 bits rgb color, alpha, no background chunk
-        bgan6a16    -   3x16 bits rgb color, alpha, no background chunk
-
-        bgbn4a08    -   8 bit grayscale, alpha, black background chunk
-        bggn4a16    -   16 bit grayscale, alpha, gray background chunk
-        bgwn6a08    -   3x8 bits rgb color, alpha, white background chunk
-        bgyn6a16    -   3x16 bits rgb color, alpha, yellow background chunk
-
-
-3.5     Transparency (and background) test files
-------------------------------------------------
-
-        tp0n1g08    -   not transparent for reference (logo on gray)
-        tbbn1g04    -   transparent, black background chunk
-        tbwn1g16    -   transparent, white background chunk
-        tp0n2c08    -   not transparent for reference (logo on gray)
-        tbrn2c08    -   transparent, red background chunk
-        tbgn2c16    -   transparent, green background chunk
-        tbbn2c16    -   transparent, blue background chunk
-        tp0n3p08    -   not transparent for reference (logo on gray)
-        tp1n3p08    -   transparent, but no background chunk
-        tbbn3p08    -   transparent, black background chunk
-        tbgn3p08    -   transparent, light-gray background chunk
-        tbwn3p08    -   transparent, white background chunk
-        tbyn3p08    -   transparent, yellow background chunk
-
-
-3.6     Gamma test files
-------------------------
-
-        g03n0g16    -   grayscale, file-gamma = 0.35
-        g04n0g16    -   grayscale, file-gamma = 0.45
-        g05n0g16    -   grayscale, file-gamma = 0.55
-        g07n0g16    -   grayscale, file-gamma = 0.70
-        g10n0g16    -   grayscale, file-gamma = 1.00
-        g25n0g16    -   grayscale, file-gamma = 2.50
-        g03n2c08    -   color, file-gamma = 0.35
-        g04n2c08    -   color, file-gamma = 0.45
-        g05n2c08    -   color, file-gamma = 0.55
-        g07n2c08    -   color, file-gamma = 0.70
-        g10n2c08    -   color, file-gamma = 1.00
-        g25n2c08    -   color, file-gamma = 2.50
-        g03n3p04    -   paletted, file-gamma = 0.35
-        g04n3p04    -   paletted, file-gamma = 0.45
-        g05n3p04    -   paletted, file-gamma = 0.55
-        g07n3p04    -   paletted, file-gamma = 0.70
-        g10n3p04    -   paletted, file-gamma = 1.00
-        g25n3p04    -   paletted, file-gamma = 2.50
-
-
-3.7     Filtering test files
-----------------------------
-
-        f00n0g08    -   grayscale, no interlacing, filter-type 0
-        f01n0g08    -   grayscale, no interlacing, filter-type 1
-        f02n0g08    -   grayscale, no interlacing, filter-type 2
-        f03n0g08    -   grayscale, no interlacing, filter-type 3
-        f04n0g08    -   grayscale, no interlacing, filter-type 4
-        f00n2c08    -   color, no interlacing, filter-type 0
-        f01n2c08    -   color, no interlacing, filter-type 1
-        f02n2c08    -   color, no interlacing, filter-type 2
-        f03n2c08    -   color, no interlacing, filter-type 3
-        f04n2c08    -   color, no interlacing, filter-type 4
-
-
-3.8     Additional palette chunk test files
--------------------------------------------
-
-        pp0n2c16    -   six-cube palette-chunk in true-color image
-        pp0n6a08    -   six-cube palette-chunk in true-color+alpha image
-        ps1n0g08    -   six-cube suggested palette (1 byte) in grayscale image
-        ps1n2c16    -   six-cube suggested palette (1 byte) in true-color image
-        ps2n0g08    -   six-cube suggested palette (2 bytes) in grayscale image
-        ps2n2c16    -   six-cube suggested palette (2 bytes) in true-color image
-
-
-3.9     Ancillary chunks test files
------------------------------------
-
-        cs5n2c08    -   color, 5 significant bits
-        cs8n2c08    -   color, 8 significant bits (reference)
-        cs3n2c16    -   color, 13 significant bits
-        cs3n3p08    -   paletted, 3 significant bits
-        cs5n3p08    -   paletted, 5 significant bits
-        cs8n3p08    -   paletted, 8 significant bits (reference)
-
-        cdfn2c08    -   physical pixel dimensions, 8x32 flat pixels
-        cdhn2c08    -   physical pixel dimensions, 32x8 high pixels
-        cdsn2c08    -   physical pixel dimensions, 8x8 square pixels
-        cdun2c08    -   physical pixel dimensions, 1000 pixels per 1 meter
-
-        ccwn2c08    -   chroma chunk w:0.3127,0.3290 r:0.64,0.33 g:0.30,0.60 b:0.15,0.06
-        ccwn3p08    -   chroma chunk w:0.3127,0.3290 r:0.64,0.33 g:0.30,0.60 b:0.15,0.06
-
-        ch1n3p04    -   histogram 15 colors
-        ch2n3p08    -   histogram 256 colors
-
-        cm7n0g04    -   modification time, 01-jan-1970 00:00:00
-        cm9n0g04    -   modification time, 31-dec-1999 23:59:59
-        cm0n0g04    -   modification time, 01-jan-2000 12:34:56
-
-        ct0n0g04    -   no textual data
-        ct1n0g04    -   with textual data
-        ctzn0g04    -   with compressed textual data
-
-
-
-3.10    Chunk ordering
-----------------------
-
-        oi1n0g16    -   grayscale mother image with 1 idat-chunk
-        oi2n0g16    -   grayscale image with 2 idat-chunks
-        oi4n0g16    -   grayscale image with 4 unequal sized idat-chunks
-        oi9n0g16    -   grayscale image with all idat-chunks length one
-        oi1n2c16    -   color mother image with 1 idat-chunk
-        oi2n2c16    -   color image with 2 idat-chunks
-        oi4n2c16    -   color image with 4 unequal sized idat-chunks
-        oi9n2c16    -   color image with all idat-chunks length one
-
-
-
-3.11    Compression level
--------------------------
-
-        z00n2c08    -   color, no interlacing, compression level 0 (none)
-        z03n2c08    -   color, no interlacing, compression level 3
-        z06n2c08    -   color, no interlacing, compression level 6 (default)
-        z09n2c08    -   color, no interlacing, compression level 9 (maximum)
-
-
-
-3.12     Currupted files
------------------------
-
-        x00n0g01    -   empty 0x0 grayscale file
-        xcrn0g04    -   added cr bytes
-        xlfn0g04    -   added lf bytes
-        xc0n0c08    -   color type 0
-        xc9n0c08    -   color type 9
-        xd0n2c00    -   bit-depth 0
-        xd3n2c03    -   bit-depth 3
-        xd9n2c99    -   bit-depth 99
-        xcsn2c08    -   incorrect IDAT checksum
-
-
---------
-    (c) Willem van Schaik
-        willem@schaik.com
-        Singapore, October 1996
diff --git a/basis/images/testing/png/suite/pngsuite_logo.png b/basis/images/testing/png/suite/pngsuite_logo.png
deleted file mode 100644 (file)
index 205460d..0000000
Binary files a/basis/images/testing/png/suite/pngsuite_logo.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/pp0n2c16.png b/basis/images/testing/png/suite/pp0n2c16.png
deleted file mode 100644 (file)
index 8f2aad7..0000000
Binary files a/basis/images/testing/png/suite/pp0n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/pp0n6a08.png b/basis/images/testing/png/suite/pp0n6a08.png
deleted file mode 100644 (file)
index 4ed7a30..0000000
Binary files a/basis/images/testing/png/suite/pp0n6a08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ps1n0g08.png b/basis/images/testing/png/suite/ps1n0g08.png
deleted file mode 100644 (file)
index 2053df2..0000000
Binary files a/basis/images/testing/png/suite/ps1n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ps1n2c16.png b/basis/images/testing/png/suite/ps1n2c16.png
deleted file mode 100644 (file)
index b03ecfc..0000000
Binary files a/basis/images/testing/png/suite/ps1n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ps2n0g08.png b/basis/images/testing/png/suite/ps2n0g08.png
deleted file mode 100644 (file)
index beeab8f..0000000
Binary files a/basis/images/testing/png/suite/ps2n0g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/ps2n2c16.png b/basis/images/testing/png/suite/ps2n2c16.png
deleted file mode 100644 (file)
index c256f90..0000000
Binary files a/basis/images/testing/png/suite/ps2n2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s01i3p01.png b/basis/images/testing/png/suite/s01i3p01.png
deleted file mode 100644 (file)
index 6c0fad1..0000000
Binary files a/basis/images/testing/png/suite/s01i3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s01n3p01.png b/basis/images/testing/png/suite/s01n3p01.png
deleted file mode 100644 (file)
index cb2c8c7..0000000
Binary files a/basis/images/testing/png/suite/s01n3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s02i3p01.png b/basis/images/testing/png/suite/s02i3p01.png
deleted file mode 100644 (file)
index 2defaed..0000000
Binary files a/basis/images/testing/png/suite/s02i3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s02n3p01.png b/basis/images/testing/png/suite/s02n3p01.png
deleted file mode 100644 (file)
index 2b1b669..0000000
Binary files a/basis/images/testing/png/suite/s02n3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s03i3p01.png b/basis/images/testing/png/suite/s03i3p01.png
deleted file mode 100644 (file)
index c23fdc4..0000000
Binary files a/basis/images/testing/png/suite/s03i3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s03n3p01.png b/basis/images/testing/png/suite/s03n3p01.png
deleted file mode 100644 (file)
index 6d96ee4..0000000
Binary files a/basis/images/testing/png/suite/s03n3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s04i3p01.png b/basis/images/testing/png/suite/s04i3p01.png
deleted file mode 100644 (file)
index 0e710c2..0000000
Binary files a/basis/images/testing/png/suite/s04i3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s04n3p01.png b/basis/images/testing/png/suite/s04n3p01.png
deleted file mode 100644 (file)
index 956396c..0000000
Binary files a/basis/images/testing/png/suite/s04n3p01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s05i3p02.png b/basis/images/testing/png/suite/s05i3p02.png
deleted file mode 100644 (file)
index d14cbd3..0000000
Binary files a/basis/images/testing/png/suite/s05i3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s05n3p02.png b/basis/images/testing/png/suite/s05n3p02.png
deleted file mode 100644 (file)
index bf940f0..0000000
Binary files a/basis/images/testing/png/suite/s05n3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s06i3p02.png b/basis/images/testing/png/suite/s06i3p02.png
deleted file mode 100644 (file)
index 456ada3..0000000
Binary files a/basis/images/testing/png/suite/s06i3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s06n3p02.png b/basis/images/testing/png/suite/s06n3p02.png
deleted file mode 100644 (file)
index 501064d..0000000
Binary files a/basis/images/testing/png/suite/s06n3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s07i3p02.png b/basis/images/testing/png/suite/s07i3p02.png
deleted file mode 100644 (file)
index 44b66ba..0000000
Binary files a/basis/images/testing/png/suite/s07i3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s07n3p02.png b/basis/images/testing/png/suite/s07n3p02.png
deleted file mode 100644 (file)
index 6a58259..0000000
Binary files a/basis/images/testing/png/suite/s07n3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s08i3p02.png b/basis/images/testing/png/suite/s08i3p02.png
deleted file mode 100644 (file)
index acf74f3..0000000
Binary files a/basis/images/testing/png/suite/s08i3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s08n3p02.png b/basis/images/testing/png/suite/s08n3p02.png
deleted file mode 100644 (file)
index b7094e1..0000000
Binary files a/basis/images/testing/png/suite/s08n3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s09i3p02.png b/basis/images/testing/png/suite/s09i3p02.png
deleted file mode 100644 (file)
index 0bfae8e..0000000
Binary files a/basis/images/testing/png/suite/s09i3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s09n3p02.png b/basis/images/testing/png/suite/s09n3p02.png
deleted file mode 100644 (file)
index 711ab82..0000000
Binary files a/basis/images/testing/png/suite/s09n3p02.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s32i3p04.png b/basis/images/testing/png/suite/s32i3p04.png
deleted file mode 100644 (file)
index 0841910..0000000
Binary files a/basis/images/testing/png/suite/s32i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s32n3p04.png b/basis/images/testing/png/suite/s32n3p04.png
deleted file mode 100644 (file)
index fa58e3e..0000000
Binary files a/basis/images/testing/png/suite/s32n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s33i3p04.png b/basis/images/testing/png/suite/s33i3p04.png
deleted file mode 100644 (file)
index ab0dc14..0000000
Binary files a/basis/images/testing/png/suite/s33i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s33n3p04.png b/basis/images/testing/png/suite/s33n3p04.png
deleted file mode 100644 (file)
index 764f1a3..0000000
Binary files a/basis/images/testing/png/suite/s33n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s34i3p04.png b/basis/images/testing/png/suite/s34i3p04.png
deleted file mode 100644 (file)
index bd99039..0000000
Binary files a/basis/images/testing/png/suite/s34i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s34n3p04.png b/basis/images/testing/png/suite/s34n3p04.png
deleted file mode 100644 (file)
index 9cbc68b..0000000
Binary files a/basis/images/testing/png/suite/s34n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s35i3p04.png b/basis/images/testing/png/suite/s35i3p04.png
deleted file mode 100644 (file)
index e2a5e0a..0000000
Binary files a/basis/images/testing/png/suite/s35i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s35n3p04.png b/basis/images/testing/png/suite/s35n3p04.png
deleted file mode 100644 (file)
index 90b892e..0000000
Binary files a/basis/images/testing/png/suite/s35n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s36i3p04.png b/basis/images/testing/png/suite/s36i3p04.png
deleted file mode 100644 (file)
index eb61b6f..0000000
Binary files a/basis/images/testing/png/suite/s36i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s36n3p04.png b/basis/images/testing/png/suite/s36n3p04.png
deleted file mode 100644 (file)
index b38d179..0000000
Binary files a/basis/images/testing/png/suite/s36n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s37i3p04.png b/basis/images/testing/png/suite/s37i3p04.png
deleted file mode 100644 (file)
index 6e2b1e9..0000000
Binary files a/basis/images/testing/png/suite/s37i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s37n3p04.png b/basis/images/testing/png/suite/s37n3p04.png
deleted file mode 100644 (file)
index 4d3054d..0000000
Binary files a/basis/images/testing/png/suite/s37n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s38i3p04.png b/basis/images/testing/png/suite/s38i3p04.png
deleted file mode 100644 (file)
index a0a8a14..0000000
Binary files a/basis/images/testing/png/suite/s38i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s38n3p04.png b/basis/images/testing/png/suite/s38n3p04.png
deleted file mode 100644 (file)
index 1233ed0..0000000
Binary files a/basis/images/testing/png/suite/s38n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s39i3p04.png b/basis/images/testing/png/suite/s39i3p04.png
deleted file mode 100644 (file)
index 04fee93..0000000
Binary files a/basis/images/testing/png/suite/s39i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s39n3p04.png b/basis/images/testing/png/suite/s39n3p04.png
deleted file mode 100644 (file)
index c750100..0000000
Binary files a/basis/images/testing/png/suite/s39n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s40i3p04.png b/basis/images/testing/png/suite/s40i3p04.png
deleted file mode 100644 (file)
index 68f358b..0000000
Binary files a/basis/images/testing/png/suite/s40i3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/s40n3p04.png b/basis/images/testing/png/suite/s40n3p04.png
deleted file mode 100644 (file)
index 864b6b9..0000000
Binary files a/basis/images/testing/png/suite/s40n3p04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbbn1g04.png b/basis/images/testing/png/suite/tbbn1g04.png
deleted file mode 100644 (file)
index fc80020..0000000
Binary files a/basis/images/testing/png/suite/tbbn1g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbbn2c16.png b/basis/images/testing/png/suite/tbbn2c16.png
deleted file mode 100644 (file)
index 5abfbbb..0000000
Binary files a/basis/images/testing/png/suite/tbbn2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbbn3p08.png b/basis/images/testing/png/suite/tbbn3p08.png
deleted file mode 100644 (file)
index 4210d16..0000000
Binary files a/basis/images/testing/png/suite/tbbn3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbgn2c16.png b/basis/images/testing/png/suite/tbgn2c16.png
deleted file mode 100644 (file)
index 236c81d..0000000
Binary files a/basis/images/testing/png/suite/tbgn2c16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbgn3p08.png b/basis/images/testing/png/suite/tbgn3p08.png
deleted file mode 100644 (file)
index 42db232..0000000
Binary files a/basis/images/testing/png/suite/tbgn3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbrn2c08.png b/basis/images/testing/png/suite/tbrn2c08.png
deleted file mode 100644 (file)
index 8c21474..0000000
Binary files a/basis/images/testing/png/suite/tbrn2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbwn1g16.png b/basis/images/testing/png/suite/tbwn1g16.png
deleted file mode 100644 (file)
index dba2cbb..0000000
Binary files a/basis/images/testing/png/suite/tbwn1g16.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbwn3p08.png b/basis/images/testing/png/suite/tbwn3p08.png
deleted file mode 100644 (file)
index 7922135..0000000
Binary files a/basis/images/testing/png/suite/tbwn3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tbyn3p08.png b/basis/images/testing/png/suite/tbyn3p08.png
deleted file mode 100644 (file)
index 5b2c6cb..0000000
Binary files a/basis/images/testing/png/suite/tbyn3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tp0n1g08.png b/basis/images/testing/png/suite/tp0n1g08.png
deleted file mode 100644 (file)
index caad31d..0000000
Binary files a/basis/images/testing/png/suite/tp0n1g08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tp0n2c08.png b/basis/images/testing/png/suite/tp0n2c08.png
deleted file mode 100644 (file)
index f26be44..0000000
Binary files a/basis/images/testing/png/suite/tp0n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tp0n3p08.png b/basis/images/testing/png/suite/tp0n3p08.png
deleted file mode 100644 (file)
index 4d6cf9e..0000000
Binary files a/basis/images/testing/png/suite/tp0n3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/tp1n3p08.png b/basis/images/testing/png/suite/tp1n3p08.png
deleted file mode 100644 (file)
index 6c5fd6e..0000000
Binary files a/basis/images/testing/png/suite/tp1n3p08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/x00n0g01.png b/basis/images/testing/png/suite/x00n0g01.png
deleted file mode 100644 (file)
index db3a5fd..0000000
Binary files a/basis/images/testing/png/suite/x00n0g01.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/xcrn0g04.png b/basis/images/testing/png/suite/xcrn0g04.png
deleted file mode 100644 (file)
index 5bce9f3..0000000
Binary files a/basis/images/testing/png/suite/xcrn0g04.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/xlfn0g04.png b/basis/images/testing/png/suite/xlfn0g04.png
deleted file mode 100644 (file)
index 1fd104b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-\89PNG
-
-
-\1a
-
-
-IHDR  \ 4\93áÈ)ÈIDATx\9c]ÑÁ
-Â0\f\ 5P\1f*@\bð\b\1d¡#°
-
-#TâÈ\ 51\ 1\e0\ 2lPF`\ 3Ø F=\95\ 2\9fÄIQâ\1c*çÅuí\94`\16%qk\81
-H\9eñ\9a\88©ñ´\80m\ 2÷\7fÍ\büµàß\9f   Ñ\8d=,\14¸fìOK
-
\a Ðt\8eÀ(Èï\ 5ä\92×\1e¦íF\v;èPº\80¯¾{xpç]\ 39\87/\ap\8f*$(ì*éyìÕ\83 ×þ\1eÚéçè@÷C¼ \12 cÔq\16\9e\8bNÛU#\84)11·.\8d\81\15r\10äðf\ 3\17ä0°\81ägh(¥\81\1eÙÂEøÿ\89kIEND®B`\82
\ No newline at end of file
diff --git a/basis/images/testing/png/suite/z00n2c08.png b/basis/images/testing/png/suite/z00n2c08.png
deleted file mode 100644 (file)
index 7669eb8..0000000
Binary files a/basis/images/testing/png/suite/z00n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/z03n2c08.png b/basis/images/testing/png/suite/z03n2c08.png
deleted file mode 100644 (file)
index bfb10de..0000000
Binary files a/basis/images/testing/png/suite/z03n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/z06n2c08.png b/basis/images/testing/png/suite/z06n2c08.png
deleted file mode 100644 (file)
index b90ebc1..0000000
Binary files a/basis/images/testing/png/suite/z06n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/suite/z09n2c08.png b/basis/images/testing/png/suite/z09n2c08.png
deleted file mode 100644 (file)
index 5f191a7..0000000
Binary files a/basis/images/testing/png/suite/z09n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/z00n2c08.fig b/basis/images/testing/png/z00n2c08.fig
deleted file mode 100644 (file)
index 9d171e6..0000000
Binary files a/basis/images/testing/png/z00n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/z00n2c08.png b/basis/images/testing/png/z00n2c08.png
deleted file mode 100644 (file)
index 7669eb8..0000000
Binary files a/basis/images/testing/png/z00n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/z03n2c08.fig b/basis/images/testing/png/z03n2c08.fig
deleted file mode 100644 (file)
index 9d171e6..0000000
Binary files a/basis/images/testing/png/z03n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/z03n2c08.png b/basis/images/testing/png/z03n2c08.png
deleted file mode 100644 (file)
index bfb10de..0000000
Binary files a/basis/images/testing/png/z03n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/z06n2c08.fig b/basis/images/testing/png/z06n2c08.fig
deleted file mode 100644 (file)
index 9d171e6..0000000
Binary files a/basis/images/testing/png/z06n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/z06n2c08.png b/basis/images/testing/png/z06n2c08.png
deleted file mode 100644 (file)
index b90ebc1..0000000
Binary files a/basis/images/testing/png/z06n2c08.png and /dev/null differ
diff --git a/basis/images/testing/png/z09n2c08.fig b/basis/images/testing/png/z09n2c08.fig
deleted file mode 100644 (file)
index 9d171e6..0000000
Binary files a/basis/images/testing/png/z09n2c08.fig and /dev/null differ
diff --git a/basis/images/testing/png/z09n2c08.png b/basis/images/testing/png/z09n2c08.png
deleted file mode 100644 (file)
index 5f191a7..0000000
Binary files a/basis/images/testing/png/z09n2c08.png and /dev/null differ
diff --git a/basis/images/testing/testing-docs.factor b/basis/images/testing/testing-docs.factor
deleted file mode 100644 (file)
index 6b90b63..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-! Copyright (C) 2009 Keith Lazuka.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax images images.viewer kernel
-quotations strings ;
-IN: images.testing
-
-HELP: decode-test
-{ $values
-    { "path" "a pathname string" }
-}
-{ $description "Runs a unit-test on the image at " { $snippet "path" } " to test the image decoder. The image is decoded and compared against its corresponding " { $link { "images" "testing" "reference" } } "." } ;
-
-HELP: encode-test
-{ $values
-    { "path" "a pathname string" } { "image-class" object }
-}
-{ $description "Runs a unit-test on the image at " { $snippet "path" } " to test the image encoder. The image is decoded, encoded, and then decoded again to verify that the final decoded output matches the original decoded output. Before comparison for equality, the images are normalized in order to accomodate differences in representation between the two potential encoders." }
-{ $warning "This test assumes that the image decoder is working correctly. If the image fails both the " { $link decode-test } " and the " { $link encode-test } ", then you should first debug the decoder. Once the decoder is working correctly, proceed with testing the encoder." } ;
-
-HELP: images.
-{ $values
-    { "dirpath" "a pathname string" } { "extension" string }
-}
-{ $description "Renders each image at " { $snippet "dirpath" } " directly to the Listener tool." } ;
-{ images. image. } related-words
-
-HELP: load-reference-image
-{ $values
-    { "path" "a pathname string" }
-    { "image" image }
-}
-{ $description "Loads the " { $link { "images" "testing" "reference" } } " that corresponds to the original image at " { $snippet "path" } " into memory."  } ;
-
-HELP: ls
-{ $values
-    { "dirpath" "a pathname string" } { "extension" object }
-}
-{ $description "Prints out the name of each file surrounded in double quotes so that you can easily copy and paste into your unit test." } ;
-
-HELP: save-all-as-reference-images
-{ $values
-    { "dirpath" "a pathname string" } { "extension" object }
-}
-{ $description "Saves a " { $link { "images" "testing" "reference" } } " for each image in " { $snippet "dirpath" } " with file extension " { $snippet "extension" } "." }
-{ $warning "You should only call this word after you have manually verified that every image in " { $snippet "dirpath" } " decodes and renders correctly!" } ;
-
-HELP: save-as-reference-image
-{ $values
-    { "path" "a pathname string" }
-}
-{ $description "Saves a " { $link { "images" "testing" "reference" } } " for the image at " { $snippet "path" } "." }
-{ $warning "You should only call this word after you have manually verified that the image at " { $snippet "path" } " decodes and renders correctly!" } ;
-
-HELP: with-matching-files
-{ $values
-    { "dirpath" "a pathname string" } { "extension" string } { "quot" quotation }
-}
-{ $description "Perform an operation on each file in " { $snippet "dirpath" } " with file extension " { $snippet "extension" } "." } ;
-
-ARTICLE: { "images" "testing" "reference" } "Reference image"
-"For the purposes of the " { $vocab-link "images.testing" } " vocab, a reference image is an " { $link image } " which has been serialized to disk by the " { $vocab-link "serialize" } " vocab. The file on disk has a " { $snippet ".fig" } " extension."
-$nl
-"Reference images are used by " { $link decode-test } " to compare the decoder's output against a saved image that is known to be correct."
-$nl
-"You can create your own reference image after you verify that the image has been correctly decoded:"
-{ $subsections
-    save-as-reference-image
-    save-all-as-reference-images
-}
-"A reference image can be loaded by the path of the original image:"
-{ $subsections load-reference-image }
-;
-
-ARTICLE: "images.testing" "Testing image encoders and decoders"
-"The " { $vocab-link "images.testing" } " vocab facilitates writing unit tests for image encoders and decoders by providing common functionality"
-$nl
-"Creating a unit test:"
-{ $subsections
-    decode-test
-    encode-test
-}
-"Establishing a " { $link { "images" "testing" "reference" } } ":"
-{ $subsections save-as-reference-image }
-"You should only create a reference image after you manually verify that your decoder is generating a valid " { $link image } " object and that it renders correctly to the screen. The following words are useful for manual verification:"
-{ $subsections
-    image.
-    images.
-}
-"Helpful words for writing potentially tedious unit tests for each image file under test:"
-{ $subsections
-    save-all-as-reference-images
-    ls
-    with-matching-files
-}
-{ $notes "This vocabulary is only intended for implementors of image encoders and image decoders. If you are an end-user, you are in the wrong place :-)" }
-;
-
-ABOUT: "images.testing"
diff --git a/basis/images/testing/testing.factor b/basis/images/testing/testing.factor
deleted file mode 100644 (file)
index 538f098..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-! Copyright (C) 2009 Keith Lazuka.
-! See http://factorcode.org/license.txt for BSD license.
-USING: fry images.loader images.normalization images.viewer io
-io.directories io.encodings.binary io.files io.pathnames
-io.streams.byte-array kernel locals namespaces quotations
-sequences serialize tools.test ;
-IN: images.testing
-
-<PRIVATE
-
-: fig-name ( path -- newpath )
-    [ parent-directory canonicalize-path ]
-    [ file-stem ".fig" append ] bi
-    append-path ;
-
-PRIVATE>
-
-:: with-matching-files ( dirpath extension quot -- )
-    dirpath [
-        [
-            dup file-extension extension = quot [ drop ] if
-        ] each
-    ] with-directory-files ; inline
-
-: images. ( dirpath extension -- )
-    [ image. ] with-matching-files ;
-
-: ls ( dirpath extension -- )
-    [ "\"" dup surround print ] with-matching-files ;
-
-: save-as-reference-image ( path -- )
-    [ load-image ] [ fig-name ] bi
-    binary [ serialize ] with-file-writer ;
-
-: save-all-as-reference-images ( dirpath extension -- )
-    [ save-as-reference-image ] with-matching-files ;
-
-: load-reference-image ( path -- image )
-    fig-name binary [ deserialize ] with-file-reader ;
-
-:: encode-test ( path image-class -- )
-    f verbose-tests? [
-        path load-image dup clone normalize-image 1quotation swap
-        '[
-            binary [ _ image-class image>stream ] with-byte-writer
-            image-class load-image* normalize-image
-        ] unit-test
-    ] with-variable ;
-
-: decode-test ( path -- )
-    f verbose-tests? [
-        [ load-image 1quotation ]
-        [ '[ _ load-reference-image ] ] bi
-        unit-test
-    ] with-variable ;
diff --git a/basis/images/testing/tiff/alpha.fig b/basis/images/testing/tiff/alpha.fig
deleted file mode 100644 (file)
index b36a8f6..0000000
Binary files a/basis/images/testing/tiff/alpha.fig and /dev/null differ
diff --git a/basis/images/testing/tiff/alpha.tiff b/basis/images/testing/tiff/alpha.tiff
deleted file mode 100644 (file)
index 27215d6..0000000
Binary files a/basis/images/testing/tiff/alpha.tiff and /dev/null differ
diff --git a/basis/images/testing/tiff/color_spectrum.fig b/basis/images/testing/tiff/color_spectrum.fig
deleted file mode 100644 (file)
index 7050c13..0000000
Binary files a/basis/images/testing/tiff/color_spectrum.fig and /dev/null differ
diff --git a/basis/images/testing/tiff/color_spectrum.tiff b/basis/images/testing/tiff/color_spectrum.tiff
deleted file mode 100644 (file)
index f596deb..0000000
Binary files a/basis/images/testing/tiff/color_spectrum.tiff and /dev/null differ
diff --git a/basis/images/testing/tiff/elephants.tiff b/basis/images/testing/tiff/elephants.tiff
deleted file mode 100644 (file)
index f462a0c..0000000
Binary files a/basis/images/testing/tiff/elephants.tiff and /dev/null differ
diff --git a/basis/images/testing/tiff/noise.fig b/basis/images/testing/tiff/noise.fig
deleted file mode 100644 (file)
index dd582aa..0000000
Binary files a/basis/images/testing/tiff/noise.fig and /dev/null differ
diff --git a/basis/images/testing/tiff/noise.tiff b/basis/images/testing/tiff/noise.tiff
deleted file mode 100644 (file)
index 2958b0b..0000000
Binary files a/basis/images/testing/tiff/noise.tiff and /dev/null differ
diff --git a/basis/images/testing/tiff/octagon.fig b/basis/images/testing/tiff/octagon.fig
deleted file mode 100644 (file)
index 0b66c62..0000000
Binary files a/basis/images/testing/tiff/octagon.fig and /dev/null differ
diff --git a/basis/images/testing/tiff/octagon.tiff b/basis/images/testing/tiff/octagon.tiff
deleted file mode 100644 (file)
index 2b4ba39..0000000
Binary files a/basis/images/testing/tiff/octagon.tiff and /dev/null differ
diff --git a/basis/images/testing/tiff/rgb.fig b/basis/images/testing/tiff/rgb.fig
deleted file mode 100644 (file)
index c09b1cd..0000000
Binary files a/basis/images/testing/tiff/rgb.fig and /dev/null differ
diff --git a/basis/images/testing/tiff/rgb.tiff b/basis/images/testing/tiff/rgb.tiff
deleted file mode 100755 (executable)
index 71cbaa9..0000000
Binary files a/basis/images/testing/tiff/rgb.tiff and /dev/null differ
index c15debd9b546c193df96febfaeb88954d15056da..8f84da4ff797467319bb5de915699464d0693b8a 100644 (file)
@@ -16,7 +16,8 @@ IN: interpolate.tests
 ] unit-test
 
 [ "Oops, I accidentally the whole economy..." ] [
-    [let | noun [ "economy" ] |
+    [let
+        "economy" :> noun
         [ I[ Oops, I accidentally the whole ${noun}...]I ] with-string-writer
     ]
 ] unit-test
index ea965aac5b48e1922c9b946c325bf27326507c3c..6e5f68fcdfba9c494244ff507b5451aaaa0a6e30 100644 (file)
@@ -40,4 +40,4 @@ MACRO: interpolate ( string -- )
 
 SYNTAX: I[
     "]I" parse-multiline-string
-    interpolate-locals over push-all ;
+    interpolate-locals append! ;
index 6b1e839ca6d47173c0b15907c9b314e369683983..4ecb1e12a8a133e52f4db1bcd845bbf154927f6b 100755 (executable)
@@ -97,7 +97,7 @@ SYMBOL: visited
         [
             dup flattenable? [
                 def>>
-                [ visited get memq? [ no-recursive-inverse ] when ]
+                [ visited get member-eq? [ no-recursive-inverse ] when ]
                 [ flatten ]
                 bi
             ] [ 1quotation ] if
@@ -141,7 +141,6 @@ MACRO: undo ( quot -- ) [undo] ;
 \ 2dup [ over =/fail over =/fail ] define-inverse
 \ 3dup [ pick =/fail pick =/fail pick =/fail ] define-inverse
 \ pick [ [ pick ] dip =/fail ] define-inverse
-\ tuck [ swapd [ =/fail ] keep ] define-inverse
 
 \ bi@ 1 [ [undo] '[ _ bi@ ] ] define-pop-inverse
 \ tri@ 1 [ [undo] '[ _ tri@ ] ] define-pop-inverse
@@ -149,7 +148,7 @@ MACRO: undo ( quot -- ) [undo] ;
 \ tri* 3 [ [ [undo] ] tri@ '[ _ _ _ tri* ] ] define-pop-inverse
 
 \ not define-involution
-\ >boolean [ dup { t f } memq? assure ] define-inverse
+\ >boolean [ dup { t f } member-eq? assure ] define-inverse
 
 \ tuple>array \ >tuple define-dual
 \ reverse define-involution
index 84a609643abde1514b9c7ba3c6349e81e4343467..276949a99fadcb501776a8981994e082ab117299 100644 (file)
@@ -3,13 +3,14 @@
 USING: kernel arrays namespaces math accessors alien locals
 destructors system threads io.backend.unix.multiplexers
 io.backend.unix.multiplexers.kqueue core-foundation
-core-foundation.run-loop ;
+core-foundation.run-loop core-foundation.file-descriptors ;
+FROM: alien.c-types => void void* ;
 IN: io.backend.unix.multiplexers.run-loop
 
 TUPLE: run-loop-mx kqueue-mx ;
 
 : file-descriptor-callback ( -- callback )
-    "void" { "CFFileDescriptorRef" "CFOptionFlags" "void*" }
+    void { CFFileDescriptorRef CFOptionFlags void* }
     "cdecl" [
         3drop
         0 mx get kqueue-mx>> wait-for-events
index 452dc4a409d91908aa301b2052d658c42624d2ba..1301d699134b23147b09814d2eea4648f9d05b7b 100755 (executable)
@@ -50,16 +50,17 @@ M: winnt add-completion ( win32-handle -- )
         } cond
     ] with-timeout ;
 
-:: wait-for-overlapped ( us -- bytes-transferred overlapped error? )
+:: wait-for-overlapped ( usec -- bytes-transferred overlapped error? )
     master-completion-port get-global
-    0 <int> [ ! bytes
-        f <void*> ! key
-        f <void*> [ ! overlapped
-            us [ 1000 /i ] [ INFINITE ] if* ! timeout
-            GetQueuedCompletionStatus zero?
-        ] keep
-        *void* dup [ OVERLAPPED memory>struct ] when
-    ] keep *int spin ;
+    0 <int> :> bytes
+    f <void*> :> key
+    f <void*> :> overlapped
+    usec [ 1000 /i ] [ INFINITE ] if* :> timeout
+    bytes key overlapped timeout GetQueuedCompletionStatus zero? :> error?
+
+    bytes *int
+    overlapped *void* dup [ OVERLAPPED memory>struct ] when
+    error? ;
 
 : resume-callback ( result overlapped -- )
     >c-ptr pending-overlapped get-global delete-at* drop resume-with ;
index d366df7c54ff33aa97b696ff0796eec9ce3740dd..93d2f5b2fc60ce3a1107c4b97918f9296a7660b4 100644 (file)
@@ -8,7 +8,7 @@ strings accessors destructors ;
     [ length ] dip buffer-reset ;
 
 : string>buffer ( string -- buffer )
-    dup length <buffer> tuck buffer-set ;
+    dup length <buffer> [ buffer-set ] keep ;
 
 : buffer-read-all ( buffer -- byte-array )
     [ [ pos>> ] [ ptr>> ] bi <displaced-alien> ]
index aa9cedf3404e3fe147e14efa315f0c8529534784..f45d3bb06223ba8d1619921c081a5ebeb4f76ebe 100644 (file)
@@ -8,7 +8,7 @@ IN: io.buffers
 
 TUPLE: buffer
 { size fixnum }
-{ ptr simple-alien }
+{ ptr alien }
 { fill fixnum }
 { pos fixnum }
 disposed ;
@@ -73,7 +73,7 @@ HINTS: >buffer byte-array buffer ;
     bi ; inline
 
 : search-buffer-until ( pos fill ptr separators -- n )
-    [ [ swap alien-unsigned-1 ] dip memq? ] 2curry find-from drop ; inline
+    [ [ swap alien-unsigned-1 ] dip member-eq? ] 2curry find-from drop ; inline
 
 : finish-buffer-until ( buffer n -- byte-array separator )
     [
index 36b46e19ee11c9e367b0f1667693843437b8e9e2..e93023523d21eaaa8a63d57dcedb0507f11cdd2d 100644 (file)
@@ -119,7 +119,7 @@ ARTICLE: "current-directory" "Current working directory"
     with-directory
 }
 "This variable is independent of the operating system notion of “current working directory”. While all Factor I/O operations use the variable and not the operating system's value, care must be taken when making FFI calls which expect a pathname. The first option is to resolve relative paths:"
-{ $subsections (normalize-path) }
+{ $subsections absolute-path }
 "The second is to change the working directory of the current process:"
 { $subsections
     cd
index 30f4cebf8d58498f37ab3145bce245edd205cdcc..05243983041c35c4f8bd650fac1c30e7858dbc53 100755 (executable)
@@ -6,10 +6,10 @@ sequences system vocabs.loader fry ;
 IN: io.directories
 
 : set-current-directory ( path -- )
-    (normalize-path) current-directory set ;
+    absolute-path current-directory set ;
 
 : with-directory ( path quot -- )
-    [ (normalize-path) current-directory ] dip with-variable ; inline
+    [ absolute-path current-directory ] dip with-variable ; inline
 
 ! Creating directories
 HOOK: make-directory io-backend ( path -- )
index 0c947e5bc63ec709d94730f4b4dca1704bfa95b6..4356a0b988c711943e21636112f18e1cb036990a 100755 (executable)
@@ -6,11 +6,11 @@ locals math sequences sorting system unicode.case vocabs.loader ;
 IN: io.directories.search
 
 : qualified-directory-entries ( path -- seq )
-    (normalize-path)
+    absolute-path
     dup directory-entries [ [ append-path ] change-name ] with map ;
 
 : qualified-directory-files ( path -- seq )
-    (normalize-path)
+    absolute-path
     dup directory-files [ append-path ] with map ;
 
 : with-qualified-directory-files ( path quot -- )
index 203d7c187ff6cc5254d7c2ad49cb8c658aa78fa1..b0677e80bd201e5937071417006d826bb2db7ec5 100644 (file)
@@ -5,106 +5,34 @@ strings ;
 IN: io.encodings.8-bit
 
 ARTICLE: "io.encodings.8-bit" "Legacy 8-bit encodings"
-"Many encodings are a simple mapping of bytes onto characters. The " { $vocab-link "io.encodings.8-bit" } " vocabulary implements these generically using existing resource files. These encodings should be used with extreme caution, as fully general Unicode encodings like UTF-8 are nearly always more appropriate. The following 8-bit encodings are already defined:"
-{ $subsections
-    latin1
-    latin2
-    latin3
-    latin4
-    latin/cyrillic
-    latin/arabic
-    latin/greek
-    latin/hebrew
-    latin5
-    latin6
-    latin/thai
-    latin7
-    latin8
-    latin9
-    latin10
-    koi8-r
-    windows-1252
-    ebcdic
-    mac-roman
+"Many encodings are a simple mapping of bytes onto characters. The " { $vocab-link "io.encodings.8-bit" } " vocabulary implements these generically using existing resource files. These encodings should be used with extreme caution, as fully general Unicode encodings like UTF-8 are nearly always more appropriate. The following 8-bit encodings are available:"
+{ $list
+    { $vocab-link "io.encodings.8-bit.ebcdic" }
+    { $vocab-link "io.encodings.8-bit.latin1" }
+    { $vocab-link "io.encodings.8-bit.latin2" }
+    { $vocab-link "io.encodings.8-bit.latin3" }
+    { $vocab-link "io.encodings.8-bit.latin4" }
+    { $vocab-link "io.encodings.8-bit.cyrillic" }
+    { $vocab-link "io.encodings.8-bit.arabic" }
+    { $vocab-link "io.encodings.8-bit.greek" }
+    { $vocab-link "io.encodings.8-bit.hebrew" }
+    { $vocab-link "io.encodings.8-bit.latin5" }
+    { $vocab-link "io.encodings.8-bit.latin6" }
+    { $vocab-link "io.encodings.8-bit.thai" }
+    { $vocab-link "io.encodings.8-bit.latin7" }
+    { $vocab-link "io.encodings.8-bit.latin8" }
+    { $vocab-link "io.encodings.8-bit.latin9" }
+    { $vocab-link "io.encodings.8-bit.koi8-r" }
+    { $vocab-link "io.encodings.8-bit.mac-roman" }
+    { $vocab-link "io.encodings.8-bit.windows-1250" }
+    { $vocab-link "io.encodings.8-bit.windows-1251" }
+    { $vocab-link "io.encodings.8-bit.windows-1252" }
+    { $vocab-link "io.encodings.8-bit.windows-1253" }
+    { $vocab-link "io.encodings.8-bit.windows-1254" }
+    { $vocab-link "io.encodings.8-bit.windows-1255" }
+    { $vocab-link "io.encodings.8-bit.windows-1256" }
+    { $vocab-link "io.encodings.8-bit.windows-1257" }
+    { $vocab-link "io.encodings.8-bit.windows-1258" }
 } ;
 
 ABOUT: "io.encodings.8-bit"
-
-HELP: 8-bit
-{ $class-description "Describes an 8-bit encoding, including its name (a symbol) and a table used for encoding and decoding." } ;
-
-HELP: latin1
-{ $description "This is the ISO-8859-1 encoding, also called Latin-1: Western European. It is an 8-bit superset of ASCII which is the default for a mimetype starting with 'text' and provides the characters necessary for most western European languages." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin2
-{ $description "This is the ISO-8859-2 encoding, also called Latin-2: Eastern European. It is an 8-bit superset of ASCII and provides the characters necessary for most eastern European languages." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin3
-{ $description "This is the ISO-8859-3 encoding, also called Latin-3: South European. It is an 8-bit superset of ASCII and provides the characters necessary for Turkish, Maltese and Esperanto." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin4
-{ $description "This is the ISO-8859-4 encoding, also called Latin-4: North European. It is an 8-bit superset of ASCII and provides the characters necessary for Latvian, Lithuanian, Estonian, Greenlandic and Sami." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin/cyrillic
-{ $description "This is the ISO-8859-5 encoding, also called Latin/Cyrillic. It is an 8-bit superset of ASCII and provides the characters necessary for most languages which use Cyrilic, including Russian, Macedonian, Belarusian, Bulgarian, Serbian, and Ukrainian. KOI8-R is used much more commonly." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin/arabic
-{ $description "This is the ISO-8859-6 encoding, also called Latin/Arabic. It is an 8-bit superset of ASCII and provides the characters necessary for Arabic, though not other languages which use Arabic script." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin/greek
-{ $description "This is the ISO-8859-7 encoding, also called Latin/Greek. It is an 8-bit superset of ASCII and provides the characters necessary for Greek written in modern monotonic orthography, or ancient Greek without accent marks." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin/hebrew
-{ $description "This is the ISO-8859-8 encoding, also called Latin/Hebrew. It is an 8-bit superset of ASCII and provides the characters necessary for modern Hebrew without explicit vowels. Generally, this is interpreted in logical order, making it ISO-8859-8-I, technically." }
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin5
-{ $description "This is the ISO-8859-9 encoding, also called Latin-5: Turkish. It is an 8-bit superset of ASCII and provides the characters necessary for Turkish, similar to Latin-1 but replacing the spots used for Icelandic with characters used in Turkish." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin6
-{ $description "This is the ISO-8859-10 encoding, also called Latin-6: Nordic. It is an 8-bit superset of ASCII containing the same characters as Latin-4, but rearranged to be of better use to nordic languages." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin/thai
-{ $description "This is the ISO-8859-11 encoding, also called Latin/Thai. It is an 8-bit superset of ASCII containing the characters necessary to represent Thai. It is basically identical to TIS-620." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin7
-{ $description "This is the ISO-8859-13 encoding, also called Latin-7: Baltic Rim. It is an 8-bit superset of ASCII containing all characters necesary to represent Baltic Rim languages, as previous character sets were incomplete." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin8
-{ $description "This is the ISO-8859-14 encoding, also called Latin-8: Celtic. It is an 8-bit superset of ASCII designed for Celtic languages like Gaelic and Breton." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin9
-{ $description "This is the ISO-8859-15 encoding, also called Latin-9 and unoffically as Latin-0. It is an 8-bit superset of ASCII designed as a modification of Latin-1, removing little-used characters in favor of the Euro symbol and other characters." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: latin10
-{ $description "This is the ISO-8859-16 encoding, also called Latin-10: South-Eastern European. It is an 8-bit superset of ASCII." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: windows-1252
-{ $description "Windows 1252 is an 8-bit superset of ASCII which is closely related to Latin-1. Control characters in the 0x80 to 0x9F range are replaced with printable characters such as the Euro symbol." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: ebcdic
-{ $description "EBCDIC is an 8-bit legacy encoding designed for IBM mainframes like System/360 in the 1960s. It has since fallen into disuse. It contains large unallocated regions, and the version included here (code page 37) contains auxiliary characters in this region for English- and Portugese-speaking countries." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: mac-roman
-{ $description "Mac Roman is an 8-bit superset of ASCII which was the standard encoding on Mac OS prior to version 10. It is incompatible with Latin-1 in all but a few places and ASCII, and it is suitable for encoding many Western European languages." } 
-{ $see-also "encodings-introduction" } ;
-
-HELP: koi8-r
-{ $description "KOI8-R is an 8-bit superset of ASCII which encodes the Cyrillic alphabet, as used in Russian and Bulgarian. Characters are in such an order that, if the eight bit is stripped, text is still interpretable as ASCII. Block-building characters also exist." } 
-{ $see-also "encodings-introduction" } ;
index 55b9c44934e2c0448fe22de49f6b7e5b1446c841..5178630f0fa0cecda1cdf58306415731435a61ef 100644 (file)
@@ -1,5 +1,6 @@
 USING: io.encodings.string io.encodings.8-bit
-io.encodings.8-bit.private tools.test strings arrays ;
+io.encodings.8-bit.private tools.test strings arrays
+io.encodings.8-bit.latin1 io.encodings.8-bit.windows-1252 ;
 IN: io.encodings.8-bit.tests
 
 [ B{ CHAR: f CHAR: o CHAR: o } ] [ "foo" latin1 encode ] unit-test
index bba22268c6bedb4964723401d8d04bfca1a3cc6c..7f92028c312ff3417e28047ba79e520f43603b9f 100644 (file)
@@ -1,41 +1,19 @@
-! Copyright (C) 2008 Daniel Ehrenberg
+! Copyright (C) 2008 Daniel Ehrenberg, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math.parser arrays io.encodings sequences kernel assocs
 hashtables io.encodings.ascii generic parser classes.tuple words
 words.symbol io io.files splitting namespaces math
 compiler.units accessors classes.singleton classes.mixin
-io.encodings.iana fry simple-flat-file ;
+io.encodings.iana fry simple-flat-file lexer ;
 IN: io.encodings.8-bit
 
 <PRIVATE
 
-CONSTANT: mappings {
-    ! encoding-name iana-name file-name
-    { "latin1" "ISO_8859-1:1987" "8859-1" }
-    { "latin2" "ISO_8859-2:1987" "8859-2" }
-    { "latin3" "ISO_8859-3:1988" "8859-3" }
-    { "latin4" "ISO_8859-4:1988" "8859-4" }
-    { "latin/cyrillic" "ISO_8859-5:1988" "8859-5" }
-    { "latin/arabic" "ISO_8859-6:1987" "8859-6" }
-    { "latin/greek" "ISO_8859-7:1987" "8859-7" }
-    { "latin/hebrew" "ISO_8859-8:1988" "8859-8" }
-    { "latin5" "ISO_8859-9:1989" "8859-9" }
-    { "latin6" "ISO-8859-10" "8859-10" }
-    { "latin/thai" "TIS-620" "8859-11" }
-    { "latin7" "ISO-8859-13" "8859-13" }
-    { "latin8" "ISO-8859-14" "8859-14" }
-    { "latin9" "ISO-8859-15" "8859-15" }
-    { "latin10" "ISO-8859-16" "8859-16" }
-    { "koi8-r" "KOI8-R" "KOI8-R" }
-    { "windows-1252" "windows-1252" "CP1252" }
-    { "ebcdic" "IBM037" "CP037" }
-    { "mac-roman" "macintosh" "ROMAN" }
-}
-
 : encoding-file ( file-name -- stream )
     "vocab:io/encodings/8-bit/" ".TXT" surround ;
 
 SYMBOL: 8-bit-encodings
+8-bit-encodings [ H{ } clone ] initialize
 
 TUPLE: 8-bit biassoc ;
 
@@ -61,20 +39,17 @@ M: 8-bit-encoding <decoder>
     8-bit-encodings get-global at <decoder> ;
 
 : create-encoding ( name -- word )
-    "io.encodings.8-bit" create
+    create-in
     [ define-singleton-class ]
     [ 8-bit-encoding add-mixin-instance ]
     [ ] tri ;
 
+: load-encoding ( name iana-name file-name -- )
+    [ create-encoding dup ]
+    [ register-encoding ]
+    [ encoding-file flat-file>biassoc 8-bit boa ] tri*
+    swap 8-bit-encodings get-global set-at ;
+
 PRIVATE>
 
-[
-    mappings [
-        first3
-        [ create-encoding ]
-        [ dupd register-encoding ]
-        [ encoding-file flat-file>biassoc 8-bit boa ]
-        tri*
-    ] H{ } map>assoc
-    8-bit-encodings set-global
-] with-compilation-unit
+SYNTAX: 8-BIT: scan scan scan load-encoding ;
diff --git a/basis/io/encodings/8-bit/CP1250.TXT b/basis/io/encodings/8-bit/CP1250.TXT
new file mode 100644 (file)
index 0000000..6bfab93
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1250 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1250 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1250 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83           #UNDEFINED
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88           #UNDEFINED
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0160  #LATIN CAPITAL LETTER S WITH CARON
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x015A  #LATIN CAPITAL LETTER S WITH ACUTE
+0x8D   0x0164  #LATIN CAPITAL LETTER T WITH CARON
+0x8E   0x017D  #LATIN CAPITAL LETTER Z WITH CARON
+0x8F   0x0179  #LATIN CAPITAL LETTER Z WITH ACUTE
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0161  #LATIN SMALL LETTER S WITH CARON
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x015B  #LATIN SMALL LETTER S WITH ACUTE
+0x9D   0x0165  #LATIN SMALL LETTER T WITH CARON
+0x9E   0x017E  #LATIN SMALL LETTER Z WITH CARON
+0x9F   0x017A  #LATIN SMALL LETTER Z WITH ACUTE
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x02C7  #CARON
+0xA2   0x02D8  #BREVE
+0xA3   0x0141  #LATIN CAPITAL LETTER L WITH STROKE
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x0104  #LATIN CAPITAL LETTER A WITH OGONEK
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x015E  #LATIN CAPITAL LETTER S WITH CEDILLA
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x017B  #LATIN CAPITAL LETTER Z WITH DOT ABOVE
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x02DB  #OGONEK
+0xB3   0x0142  #LATIN SMALL LETTER L WITH STROKE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x0105  #LATIN SMALL LETTER A WITH OGONEK
+0xBA   0x015F  #LATIN SMALL LETTER S WITH CEDILLA
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x013D  #LATIN CAPITAL LETTER L WITH CARON
+0xBD   0x02DD  #DOUBLE ACUTE ACCENT
+0xBE   0x013E  #LATIN SMALL LETTER L WITH CARON
+0xBF   0x017C  #LATIN SMALL LETTER Z WITH DOT ABOVE
+0xC0   0x0154  #LATIN CAPITAL LETTER R WITH ACUTE
+0xC1   0x00C1  #LATIN CAPITAL LETTER A WITH ACUTE
+0xC2   0x00C2  #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0xC3   0x0102  #LATIN CAPITAL LETTER A WITH BREVE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x0139  #LATIN CAPITAL LETTER L WITH ACUTE
+0xC6   0x0106  #LATIN CAPITAL LETTER C WITH ACUTE
+0xC7   0x00C7  #LATIN CAPITAL LETTER C WITH CEDILLA
+0xC8   0x010C  #LATIN CAPITAL LETTER C WITH CARON
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x0118  #LATIN CAPITAL LETTER E WITH OGONEK
+0xCB   0x00CB  #LATIN CAPITAL LETTER E WITH DIAERESIS
+0xCC   0x011A  #LATIN CAPITAL LETTER E WITH CARON
+0xCD   0x00CD  #LATIN CAPITAL LETTER I WITH ACUTE
+0xCE   0x00CE  #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0xCF   0x010E  #LATIN CAPITAL LETTER D WITH CARON
+0xD0   0x0110  #LATIN CAPITAL LETTER D WITH STROKE
+0xD1   0x0143  #LATIN CAPITAL LETTER N WITH ACUTE
+0xD2   0x0147  #LATIN CAPITAL LETTER N WITH CARON
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x00D4  #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xD5   0x0150  #LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x0158  #LATIN CAPITAL LETTER R WITH CARON
+0xD9   0x016E  #LATIN CAPITAL LETTER U WITH RING ABOVE
+0xDA   0x00DA  #LATIN CAPITAL LETTER U WITH ACUTE
+0xDB   0x0170  #LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x00DD  #LATIN CAPITAL LETTER Y WITH ACUTE
+0xDE   0x0162  #LATIN CAPITAL LETTER T WITH CEDILLA
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x0155  #LATIN SMALL LETTER R WITH ACUTE
+0xE1   0x00E1  #LATIN SMALL LETTER A WITH ACUTE
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x0103  #LATIN SMALL LETTER A WITH BREVE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x013A  #LATIN SMALL LETTER L WITH ACUTE
+0xE6   0x0107  #LATIN SMALL LETTER C WITH ACUTE
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x010D  #LATIN SMALL LETTER C WITH CARON
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x0119  #LATIN SMALL LETTER E WITH OGONEK
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x011B  #LATIN SMALL LETTER E WITH CARON
+0xED   0x00ED  #LATIN SMALL LETTER I WITH ACUTE
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x010F  #LATIN SMALL LETTER D WITH CARON
+0xF0   0x0111  #LATIN SMALL LETTER D WITH STROKE
+0xF1   0x0144  #LATIN SMALL LETTER N WITH ACUTE
+0xF2   0x0148  #LATIN SMALL LETTER N WITH CARON
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x0151  #LATIN SMALL LETTER O WITH DOUBLE ACUTE
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x0159  #LATIN SMALL LETTER R WITH CARON
+0xF9   0x016F  #LATIN SMALL LETTER U WITH RING ABOVE
+0xFA   0x00FA  #LATIN SMALL LETTER U WITH ACUTE
+0xFB   0x0171  #LATIN SMALL LETTER U WITH DOUBLE ACUTE
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x00FD  #LATIN SMALL LETTER Y WITH ACUTE
+0xFE   0x0163  #LATIN SMALL LETTER T WITH CEDILLA
+0xFF   0x02D9  #DOT ABOVE
diff --git a/basis/io/encodings/8-bit/CP1251.TXT b/basis/io/encodings/8-bit/CP1251.TXT
new file mode 100644 (file)
index 0000000..4d9b355
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1251 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1251 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1251 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x0402  #CYRILLIC CAPITAL LETTER DJE
+0x81   0x0403  #CYRILLIC CAPITAL LETTER GJE
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0453  #CYRILLIC SMALL LETTER GJE
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x20AC  #EURO SIGN
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0409  #CYRILLIC CAPITAL LETTER LJE
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x040A  #CYRILLIC CAPITAL LETTER NJE
+0x8D   0x040C  #CYRILLIC CAPITAL LETTER KJE
+0x8E   0x040B  #CYRILLIC CAPITAL LETTER TSHE
+0x8F   0x040F  #CYRILLIC CAPITAL LETTER DZHE
+0x90   0x0452  #CYRILLIC SMALL LETTER DJE
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0459  #CYRILLIC SMALL LETTER LJE
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x045A  #CYRILLIC SMALL LETTER NJE
+0x9D   0x045C  #CYRILLIC SMALL LETTER KJE
+0x9E   0x045B  #CYRILLIC SMALL LETTER TSHE
+0x9F   0x045F  #CYRILLIC SMALL LETTER DZHE
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x040E  #CYRILLIC CAPITAL LETTER SHORT U
+0xA2   0x045E  #CYRILLIC SMALL LETTER SHORT U
+0xA3   0x0408  #CYRILLIC CAPITAL LETTER JE
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x0490  #CYRILLIC CAPITAL LETTER GHE WITH UPTURN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x0401  #CYRILLIC CAPITAL LETTER IO
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x0404  #CYRILLIC CAPITAL LETTER UKRAINIAN IE
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x0407  #CYRILLIC CAPITAL LETTER YI
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x0406  #CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+0xB3   0x0456  #CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+0xB4   0x0491  #CYRILLIC SMALL LETTER GHE WITH UPTURN
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x0451  #CYRILLIC SMALL LETTER IO
+0xB9   0x2116  #NUMERO SIGN
+0xBA   0x0454  #CYRILLIC SMALL LETTER UKRAINIAN IE
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x0458  #CYRILLIC SMALL LETTER JE
+0xBD   0x0405  #CYRILLIC CAPITAL LETTER DZE
+0xBE   0x0455  #CYRILLIC SMALL LETTER DZE
+0xBF   0x0457  #CYRILLIC SMALL LETTER YI
+0xC0   0x0410  #CYRILLIC CAPITAL LETTER A
+0xC1   0x0411  #CYRILLIC CAPITAL LETTER BE
+0xC2   0x0412  #CYRILLIC CAPITAL LETTER VE
+0xC3   0x0413  #CYRILLIC CAPITAL LETTER GHE
+0xC4   0x0414  #CYRILLIC CAPITAL LETTER DE
+0xC5   0x0415  #CYRILLIC CAPITAL LETTER IE
+0xC6   0x0416  #CYRILLIC CAPITAL LETTER ZHE
+0xC7   0x0417  #CYRILLIC CAPITAL LETTER ZE
+0xC8   0x0418  #CYRILLIC CAPITAL LETTER I
+0xC9   0x0419  #CYRILLIC CAPITAL LETTER SHORT I
+0xCA   0x041A  #CYRILLIC CAPITAL LETTER KA
+0xCB   0x041B  #CYRILLIC CAPITAL LETTER EL
+0xCC   0x041C  #CYRILLIC CAPITAL LETTER EM
+0xCD   0x041D  #CYRILLIC CAPITAL LETTER EN
+0xCE   0x041E  #CYRILLIC CAPITAL LETTER O
+0xCF   0x041F  #CYRILLIC CAPITAL LETTER PE
+0xD0   0x0420  #CYRILLIC CAPITAL LETTER ER
+0xD1   0x0421  #CYRILLIC CAPITAL LETTER ES
+0xD2   0x0422  #CYRILLIC CAPITAL LETTER TE
+0xD3   0x0423  #CYRILLIC CAPITAL LETTER U
+0xD4   0x0424  #CYRILLIC CAPITAL LETTER EF
+0xD5   0x0425  #CYRILLIC CAPITAL LETTER HA
+0xD6   0x0426  #CYRILLIC CAPITAL LETTER TSE
+0xD7   0x0427  #CYRILLIC CAPITAL LETTER CHE
+0xD8   0x0428  #CYRILLIC CAPITAL LETTER SHA
+0xD9   0x0429  #CYRILLIC CAPITAL LETTER SHCHA
+0xDA   0x042A  #CYRILLIC CAPITAL LETTER HARD SIGN
+0xDB   0x042B  #CYRILLIC CAPITAL LETTER YERU
+0xDC   0x042C  #CYRILLIC CAPITAL LETTER SOFT SIGN
+0xDD   0x042D  #CYRILLIC CAPITAL LETTER E
+0xDE   0x042E  #CYRILLIC CAPITAL LETTER YU
+0xDF   0x042F  #CYRILLIC CAPITAL LETTER YA
+0xE0   0x0430  #CYRILLIC SMALL LETTER A
+0xE1   0x0431  #CYRILLIC SMALL LETTER BE
+0xE2   0x0432  #CYRILLIC SMALL LETTER VE
+0xE3   0x0433  #CYRILLIC SMALL LETTER GHE
+0xE4   0x0434  #CYRILLIC SMALL LETTER DE
+0xE5   0x0435  #CYRILLIC SMALL LETTER IE
+0xE6   0x0436  #CYRILLIC SMALL LETTER ZHE
+0xE7   0x0437  #CYRILLIC SMALL LETTER ZE
+0xE8   0x0438  #CYRILLIC SMALL LETTER I
+0xE9   0x0439  #CYRILLIC SMALL LETTER SHORT I
+0xEA   0x043A  #CYRILLIC SMALL LETTER KA
+0xEB   0x043B  #CYRILLIC SMALL LETTER EL
+0xEC   0x043C  #CYRILLIC SMALL LETTER EM
+0xED   0x043D  #CYRILLIC SMALL LETTER EN
+0xEE   0x043E  #CYRILLIC SMALL LETTER O
+0xEF   0x043F  #CYRILLIC SMALL LETTER PE
+0xF0   0x0440  #CYRILLIC SMALL LETTER ER
+0xF1   0x0441  #CYRILLIC SMALL LETTER ES
+0xF2   0x0442  #CYRILLIC SMALL LETTER TE
+0xF3   0x0443  #CYRILLIC SMALL LETTER U
+0xF4   0x0444  #CYRILLIC SMALL LETTER EF
+0xF5   0x0445  #CYRILLIC SMALL LETTER HA
+0xF6   0x0446  #CYRILLIC SMALL LETTER TSE
+0xF7   0x0447  #CYRILLIC SMALL LETTER CHE
+0xF8   0x0448  #CYRILLIC SMALL LETTER SHA
+0xF9   0x0449  #CYRILLIC SMALL LETTER SHCHA
+0xFA   0x044A  #CYRILLIC SMALL LETTER HARD SIGN
+0xFB   0x044B  #CYRILLIC SMALL LETTER YERU
+0xFC   0x044C  #CYRILLIC SMALL LETTER SOFT SIGN
+0xFD   0x044D  #CYRILLIC SMALL LETTER E
+0xFE   0x044E  #CYRILLIC SMALL LETTER YU
+0xFF   0x044F  #CYRILLIC SMALL LETTER YA
diff --git a/basis/io/encodings/8-bit/CP1253.TXT b/basis/io/encodings/8-bit/CP1253.TXT
new file mode 100644 (file)
index 0000000..20a55b0
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1253 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1253 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1253 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88           #UNDEFINED
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C           #UNDEFINED
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C           #UNDEFINED
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F           #UNDEFINED
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x0385  #GREEK DIALYTIKA TONOS
+0xA2   0x0386  #GREEK CAPITAL LETTER ALPHA WITH TONOS
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA           #UNDEFINED
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x2015  #HORIZONTAL BAR
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x0384  #GREEK TONOS
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x0388  #GREEK CAPITAL LETTER EPSILON WITH TONOS
+0xB9   0x0389  #GREEK CAPITAL LETTER ETA WITH TONOS
+0xBA   0x038A  #GREEK CAPITAL LETTER IOTA WITH TONOS
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x038C  #GREEK CAPITAL LETTER OMICRON WITH TONOS
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x038E  #GREEK CAPITAL LETTER UPSILON WITH TONOS
+0xBF   0x038F  #GREEK CAPITAL LETTER OMEGA WITH TONOS
+0xC0   0x0390  #GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+0xC1   0x0391  #GREEK CAPITAL LETTER ALPHA
+0xC2   0x0392  #GREEK CAPITAL LETTER BETA
+0xC3   0x0393  #GREEK CAPITAL LETTER GAMMA
+0xC4   0x0394  #GREEK CAPITAL LETTER DELTA
+0xC5   0x0395  #GREEK CAPITAL LETTER EPSILON
+0xC6   0x0396  #GREEK CAPITAL LETTER ZETA
+0xC7   0x0397  #GREEK CAPITAL LETTER ETA
+0xC8   0x0398  #GREEK CAPITAL LETTER THETA
+0xC9   0x0399  #GREEK CAPITAL LETTER IOTA
+0xCA   0x039A  #GREEK CAPITAL LETTER KAPPA
+0xCB   0x039B  #GREEK CAPITAL LETTER LAMDA
+0xCC   0x039C  #GREEK CAPITAL LETTER MU
+0xCD   0x039D  #GREEK CAPITAL LETTER NU
+0xCE   0x039E  #GREEK CAPITAL LETTER XI
+0xCF   0x039F  #GREEK CAPITAL LETTER OMICRON
+0xD0   0x03A0  #GREEK CAPITAL LETTER PI
+0xD1   0x03A1  #GREEK CAPITAL LETTER RHO
+0xD2           #UNDEFINED
+0xD3   0x03A3  #GREEK CAPITAL LETTER SIGMA
+0xD4   0x03A4  #GREEK CAPITAL LETTER TAU
+0xD5   0x03A5  #GREEK CAPITAL LETTER UPSILON
+0xD6   0x03A6  #GREEK CAPITAL LETTER PHI
+0xD7   0x03A7  #GREEK CAPITAL LETTER CHI
+0xD8   0x03A8  #GREEK CAPITAL LETTER PSI
+0xD9   0x03A9  #GREEK CAPITAL LETTER OMEGA
+0xDA   0x03AA  #GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+0xDB   0x03AB  #GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+0xDC   0x03AC  #GREEK SMALL LETTER ALPHA WITH TONOS
+0xDD   0x03AD  #GREEK SMALL LETTER EPSILON WITH TONOS
+0xDE   0x03AE  #GREEK SMALL LETTER ETA WITH TONOS
+0xDF   0x03AF  #GREEK SMALL LETTER IOTA WITH TONOS
+0xE0   0x03B0  #GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+0xE1   0x03B1  #GREEK SMALL LETTER ALPHA
+0xE2   0x03B2  #GREEK SMALL LETTER BETA
+0xE3   0x03B3  #GREEK SMALL LETTER GAMMA
+0xE4   0x03B4  #GREEK SMALL LETTER DELTA
+0xE5   0x03B5  #GREEK SMALL LETTER EPSILON
+0xE6   0x03B6  #GREEK SMALL LETTER ZETA
+0xE7   0x03B7  #GREEK SMALL LETTER ETA
+0xE8   0x03B8  #GREEK SMALL LETTER THETA
+0xE9   0x03B9  #GREEK SMALL LETTER IOTA
+0xEA   0x03BA  #GREEK SMALL LETTER KAPPA
+0xEB   0x03BB  #GREEK SMALL LETTER LAMDA
+0xEC   0x03BC  #GREEK SMALL LETTER MU
+0xED   0x03BD  #GREEK SMALL LETTER NU
+0xEE   0x03BE  #GREEK SMALL LETTER XI
+0xEF   0x03BF  #GREEK SMALL LETTER OMICRON
+0xF0   0x03C0  #GREEK SMALL LETTER PI
+0xF1   0x03C1  #GREEK SMALL LETTER RHO
+0xF2   0x03C2  #GREEK SMALL LETTER FINAL SIGMA
+0xF3   0x03C3  #GREEK SMALL LETTER SIGMA
+0xF4   0x03C4  #GREEK SMALL LETTER TAU
+0xF5   0x03C5  #GREEK SMALL LETTER UPSILON
+0xF6   0x03C6  #GREEK SMALL LETTER PHI
+0xF7   0x03C7  #GREEK SMALL LETTER CHI
+0xF8   0x03C8  #GREEK SMALL LETTER PSI
+0xF9   0x03C9  #GREEK SMALL LETTER OMEGA
+0xFA   0x03CA  #GREEK SMALL LETTER IOTA WITH DIALYTIKA
+0xFB   0x03CB  #GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+0xFC   0x03CC  #GREEK SMALL LETTER OMICRON WITH TONOS
+0xFD   0x03CD  #GREEK SMALL LETTER UPSILON WITH TONOS
+0xFE   0x03CE  #GREEK SMALL LETTER OMEGA WITH TONOS
+0xFF           #UNDEFINED
diff --git a/basis/io/encodings/8-bit/CP1254.TXT b/basis/io/encodings/8-bit/CP1254.TXT
new file mode 100644 (file)
index 0000000..987ed98
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1254 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1254 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1254 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0160  #LATIN CAPITAL LETTER S WITH CARON
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x0152  #LATIN CAPITAL LIGATURE OE
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x02DC  #SMALL TILDE
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0161  #LATIN SMALL LETTER S WITH CARON
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x0153  #LATIN SMALL LIGATURE OE
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F   0x0178  #LATIN CAPITAL LETTER Y WITH DIAERESIS
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x00A1  #INVERTED EXCLAMATION MARK
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x00AA  #FEMININE ORDINAL INDICATOR
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x00BA  #MASCULINE ORDINAL INDICATOR
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00BF  #INVERTED QUESTION MARK
+0xC0   0x00C0  #LATIN CAPITAL LETTER A WITH GRAVE
+0xC1   0x00C1  #LATIN CAPITAL LETTER A WITH ACUTE
+0xC2   0x00C2  #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0xC3   0x00C3  #LATIN CAPITAL LETTER A WITH TILDE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0xC6   0x00C6  #LATIN CAPITAL LETTER AE
+0xC7   0x00C7  #LATIN CAPITAL LETTER C WITH CEDILLA
+0xC8   0x00C8  #LATIN CAPITAL LETTER E WITH GRAVE
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x00CA  #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+0xCB   0x00CB  #LATIN CAPITAL LETTER E WITH DIAERESIS
+0xCC   0x00CC  #LATIN CAPITAL LETTER I WITH GRAVE
+0xCD   0x00CD  #LATIN CAPITAL LETTER I WITH ACUTE
+0xCE   0x00CE  #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0xCF   0x00CF  #LATIN CAPITAL LETTER I WITH DIAERESIS
+0xD0   0x011E  #LATIN CAPITAL LETTER G WITH BREVE
+0xD1   0x00D1  #LATIN CAPITAL LETTER N WITH TILDE
+0xD2   0x00D2  #LATIN CAPITAL LETTER O WITH GRAVE
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x00D4  #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xD5   0x00D5  #LATIN CAPITAL LETTER O WITH TILDE
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0xD9   0x00D9  #LATIN CAPITAL LETTER U WITH GRAVE
+0xDA   0x00DA  #LATIN CAPITAL LETTER U WITH ACUTE
+0xDB   0x00DB  #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x0130  #LATIN CAPITAL LETTER I WITH DOT ABOVE
+0xDE   0x015E  #LATIN CAPITAL LETTER S WITH CEDILLA
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0xE1   0x00E1  #LATIN SMALL LETTER A WITH ACUTE
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x00E3  #LATIN SMALL LETTER A WITH TILDE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0xE6   0x00E6  #LATIN SMALL LETTER AE
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x00EC  #LATIN SMALL LETTER I WITH GRAVE
+0xED   0x00ED  #LATIN SMALL LETTER I WITH ACUTE
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0xF0   0x011F  #LATIN SMALL LETTER G WITH BREVE
+0xF1   0x00F1  #LATIN SMALL LETTER N WITH TILDE
+0xF2   0x00F2  #LATIN SMALL LETTER O WITH GRAVE
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x00F5  #LATIN SMALL LETTER O WITH TILDE
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0xF9   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xFA   0x00FA  #LATIN SMALL LETTER U WITH ACUTE
+0xFB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x0131  #LATIN SMALL LETTER DOTLESS I
+0xFE   0x015F  #LATIN SMALL LETTER S WITH CEDILLA
+0xFF   0x00FF  #LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/basis/io/encodings/8-bit/CP1255.TXT b/basis/io/encodings/8-bit/CP1255.TXT
new file mode 100644 (file)
index 0000000..585f993
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1255 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          1/7/2000
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1255 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1255 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C           #UNDEFINED
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x02DC  #SMALL TILDE
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C           #UNDEFINED
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F           #UNDEFINED
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x00A1  #INVERTED EXCLAMATION MARK
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x20AA  #NEW SHEQEL SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x00D7  #MULTIPLICATION SIGN
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x00F7  #DIVISION SIGN
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00BF  #INVERTED QUESTION MARK
+0xC0   0x05B0  #HEBREW POINT SHEVA
+0xC1   0x05B1  #HEBREW POINT HATAF SEGOL
+0xC2   0x05B2  #HEBREW POINT HATAF PATAH
+0xC3   0x05B3  #HEBREW POINT HATAF QAMATS
+0xC4   0x05B4  #HEBREW POINT HIRIQ
+0xC5   0x05B5  #HEBREW POINT TSERE
+0xC6   0x05B6  #HEBREW POINT SEGOL
+0xC7   0x05B7  #HEBREW POINT PATAH
+0xC8   0x05B8  #HEBREW POINT QAMATS
+0xC9   0x05B9  #HEBREW POINT HOLAM
+0xCA           #UNDEFINED
+0xCB   0x05BB  #HEBREW POINT QUBUTS
+0xCC   0x05BC  #HEBREW POINT DAGESH OR MAPIQ
+0xCD   0x05BD  #HEBREW POINT METEG
+0xCE   0x05BE  #HEBREW PUNCTUATION MAQAF
+0xCF   0x05BF  #HEBREW POINT RAFE
+0xD0   0x05C0  #HEBREW PUNCTUATION PASEQ
+0xD1   0x05C1  #HEBREW POINT SHIN DOT
+0xD2   0x05C2  #HEBREW POINT SIN DOT
+0xD3   0x05C3  #HEBREW PUNCTUATION SOF PASUQ
+0xD4   0x05F0  #HEBREW LIGATURE YIDDISH DOUBLE VAV
+0xD5   0x05F1  #HEBREW LIGATURE YIDDISH VAV YOD
+0xD6   0x05F2  #HEBREW LIGATURE YIDDISH DOUBLE YOD
+0xD7   0x05F3  #HEBREW PUNCTUATION GERESH
+0xD8   0x05F4  #HEBREW PUNCTUATION GERSHAYIM
+0xD9           #UNDEFINED
+0xDA           #UNDEFINED
+0xDB           #UNDEFINED
+0xDC           #UNDEFINED
+0xDD           #UNDEFINED
+0xDE           #UNDEFINED
+0xDF           #UNDEFINED
+0xE0   0x05D0  #HEBREW LETTER ALEF
+0xE1   0x05D1  #HEBREW LETTER BET
+0xE2   0x05D2  #HEBREW LETTER GIMEL
+0xE3   0x05D3  #HEBREW LETTER DALET
+0xE4   0x05D4  #HEBREW LETTER HE
+0xE5   0x05D5  #HEBREW LETTER VAV
+0xE6   0x05D6  #HEBREW LETTER ZAYIN
+0xE7   0x05D7  #HEBREW LETTER HET
+0xE8   0x05D8  #HEBREW LETTER TET
+0xE9   0x05D9  #HEBREW LETTER YOD
+0xEA   0x05DA  #HEBREW LETTER FINAL KAF
+0xEB   0x05DB  #HEBREW LETTER KAF
+0xEC   0x05DC  #HEBREW LETTER LAMED
+0xED   0x05DD  #HEBREW LETTER FINAL MEM
+0xEE   0x05DE  #HEBREW LETTER MEM
+0xEF   0x05DF  #HEBREW LETTER FINAL NUN
+0xF0   0x05E0  #HEBREW LETTER NUN
+0xF1   0x05E1  #HEBREW LETTER SAMEKH
+0xF2   0x05E2  #HEBREW LETTER AYIN
+0xF3   0x05E3  #HEBREW LETTER FINAL PE
+0xF4   0x05E4  #HEBREW LETTER PE
+0xF5   0x05E5  #HEBREW LETTER FINAL TSADI
+0xF6   0x05E6  #HEBREW LETTER TSADI
+0xF7   0x05E7  #HEBREW LETTER QOF
+0xF8   0x05E8  #HEBREW LETTER RESH
+0xF9   0x05E9  #HEBREW LETTER SHIN
+0xFA   0x05EA  #HEBREW LETTER TAV
+0xFB           #UNDEFINED
+0xFC           #UNDEFINED
+0xFD   0x200E  #LEFT-TO-RIGHT MARK
+0xFE   0x200F  #RIGHT-TO-LEFT MARK
+0xFF           #UNDEFINED
diff --git a/basis/io/encodings/8-bit/CP1256.TXT b/basis/io/encodings/8-bit/CP1256.TXT
new file mode 100644 (file)
index 0000000..244dcce
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1256 to Unicode table
+#    Unicode version: 2.1
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          01/5/99
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1256 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1256 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81   0x067E  #ARABIC LETTER PEH
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0679  #ARABIC LETTER TTEH
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x0152  #LATIN CAPITAL LIGATURE OE
+0x8D   0x0686  #ARABIC LETTER TCHEH
+0x8E   0x0698  #ARABIC LETTER JEH
+0x8F   0x0688  #ARABIC LETTER DDAL
+0x90   0x06AF  #ARABIC LETTER GAF
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x06A9  #ARABIC LETTER KEHEH
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0691  #ARABIC LETTER RREH
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x0153  #LATIN SMALL LIGATURE OE
+0x9D   0x200C  #ZERO WIDTH NON-JOINER
+0x9E   0x200D  #ZERO WIDTH JOINER
+0x9F   0x06BA  #ARABIC LETTER NOON GHUNNA
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x060C  #ARABIC COMMA
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x06BE  #ARABIC LETTER HEH DOACHASHMEE
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x061B  #ARABIC SEMICOLON
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x061F  #ARABIC QUESTION MARK
+0xC0   0x06C1  #ARABIC LETTER HEH GOAL
+0xC1   0x0621  #ARABIC LETTER HAMZA
+0xC2   0x0622  #ARABIC LETTER ALEF WITH MADDA ABOVE
+0xC3   0x0623  #ARABIC LETTER ALEF WITH HAMZA ABOVE
+0xC4   0x0624  #ARABIC LETTER WAW WITH HAMZA ABOVE
+0xC5   0x0625  #ARABIC LETTER ALEF WITH HAMZA BELOW
+0xC6   0x0626  #ARABIC LETTER YEH WITH HAMZA ABOVE
+0xC7   0x0627  #ARABIC LETTER ALEF
+0xC8   0x0628  #ARABIC LETTER BEH
+0xC9   0x0629  #ARABIC LETTER TEH MARBUTA
+0xCA   0x062A  #ARABIC LETTER TEH
+0xCB   0x062B  #ARABIC LETTER THEH
+0xCC   0x062C  #ARABIC LETTER JEEM
+0xCD   0x062D  #ARABIC LETTER HAH
+0xCE   0x062E  #ARABIC LETTER KHAH
+0xCF   0x062F  #ARABIC LETTER DAL
+0xD0   0x0630  #ARABIC LETTER THAL
+0xD1   0x0631  #ARABIC LETTER REH
+0xD2   0x0632  #ARABIC LETTER ZAIN
+0xD3   0x0633  #ARABIC LETTER SEEN
+0xD4   0x0634  #ARABIC LETTER SHEEN
+0xD5   0x0635  #ARABIC LETTER SAD
+0xD6   0x0636  #ARABIC LETTER DAD
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x0637  #ARABIC LETTER TAH
+0xD9   0x0638  #ARABIC LETTER ZAH
+0xDA   0x0639  #ARABIC LETTER AIN
+0xDB   0x063A  #ARABIC LETTER GHAIN
+0xDC   0x0640  #ARABIC TATWEEL
+0xDD   0x0641  #ARABIC LETTER FEH
+0xDE   0x0642  #ARABIC LETTER QAF
+0xDF   0x0643  #ARABIC LETTER KAF
+0xE0   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0xE1   0x0644  #ARABIC LETTER LAM
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x0645  #ARABIC LETTER MEEM
+0xE4   0x0646  #ARABIC LETTER NOON
+0xE5   0x0647  #ARABIC LETTER HEH
+0xE6   0x0648  #ARABIC LETTER WAW
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x0649  #ARABIC LETTER ALEF MAKSURA
+0xED   0x064A  #ARABIC LETTER YEH
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0xF0   0x064B  #ARABIC FATHATAN
+0xF1   0x064C  #ARABIC DAMMATAN
+0xF2   0x064D  #ARABIC KASRATAN
+0xF3   0x064E  #ARABIC FATHA
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x064F  #ARABIC DAMMA
+0xF6   0x0650  #ARABIC KASRA
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x0651  #ARABIC SHADDA
+0xF9   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xFA   0x0652  #ARABIC SUKUN
+0xFB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x200E  #LEFT-TO-RIGHT MARK
+0xFE   0x200F  #RIGHT-TO-LEFT MARK
+0xFF   0x06D2  #ARABIC LETTER YEH BARREE
diff --git a/basis/io/encodings/8-bit/CP1257.TXT b/basis/io/encodings/8-bit/CP1257.TXT
new file mode 100644 (file)
index 0000000..0dc475e
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1257 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1257 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1257 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83           #UNDEFINED
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88           #UNDEFINED
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C           #UNDEFINED
+0x8D   0x00A8  #DIAERESIS
+0x8E   0x02C7  #CARON
+0x8F   0x00B8  #CEDILLA
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C           #UNDEFINED
+0x9D   0x00AF  #MACRON
+0x9E   0x02DB  #OGONEK
+0x9F           #UNDEFINED
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1           #UNDEFINED
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5           #UNDEFINED
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x0156  #LATIN CAPITAL LETTER R WITH CEDILLA
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00C6  #LATIN CAPITAL LETTER AE
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x0157  #LATIN SMALL LETTER R WITH CEDILLA
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00E6  #LATIN SMALL LETTER AE
+0xC0   0x0104  #LATIN CAPITAL LETTER A WITH OGONEK
+0xC1   0x012E  #LATIN CAPITAL LETTER I WITH OGONEK
+0xC2   0x0100  #LATIN CAPITAL LETTER A WITH MACRON
+0xC3   0x0106  #LATIN CAPITAL LETTER C WITH ACUTE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0xC6   0x0118  #LATIN CAPITAL LETTER E WITH OGONEK
+0xC7   0x0112  #LATIN CAPITAL LETTER E WITH MACRON
+0xC8   0x010C  #LATIN CAPITAL LETTER C WITH CARON
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x0179  #LATIN CAPITAL LETTER Z WITH ACUTE
+0xCB   0x0116  #LATIN CAPITAL LETTER E WITH DOT ABOVE
+0xCC   0x0122  #LATIN CAPITAL LETTER G WITH CEDILLA
+0xCD   0x0136  #LATIN CAPITAL LETTER K WITH CEDILLA
+0xCE   0x012A  #LATIN CAPITAL LETTER I WITH MACRON
+0xCF   0x013B  #LATIN CAPITAL LETTER L WITH CEDILLA
+0xD0   0x0160  #LATIN CAPITAL LETTER S WITH CARON
+0xD1   0x0143  #LATIN CAPITAL LETTER N WITH ACUTE
+0xD2   0x0145  #LATIN CAPITAL LETTER N WITH CEDILLA
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x014C  #LATIN CAPITAL LETTER O WITH MACRON
+0xD5   0x00D5  #LATIN CAPITAL LETTER O WITH TILDE
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x0172  #LATIN CAPITAL LETTER U WITH OGONEK
+0xD9   0x0141  #LATIN CAPITAL LETTER L WITH STROKE
+0xDA   0x015A  #LATIN CAPITAL LETTER S WITH ACUTE
+0xDB   0x016A  #LATIN CAPITAL LETTER U WITH MACRON
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x017B  #LATIN CAPITAL LETTER Z WITH DOT ABOVE
+0xDE   0x017D  #LATIN CAPITAL LETTER Z WITH CARON
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x0105  #LATIN SMALL LETTER A WITH OGONEK
+0xE1   0x012F  #LATIN SMALL LETTER I WITH OGONEK
+0xE2   0x0101  #LATIN SMALL LETTER A WITH MACRON
+0xE3   0x0107  #LATIN SMALL LETTER C WITH ACUTE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0xE6   0x0119  #LATIN SMALL LETTER E WITH OGONEK
+0xE7   0x0113  #LATIN SMALL LETTER E WITH MACRON
+0xE8   0x010D  #LATIN SMALL LETTER C WITH CARON
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x017A  #LATIN SMALL LETTER Z WITH ACUTE
+0xEB   0x0117  #LATIN SMALL LETTER E WITH DOT ABOVE
+0xEC   0x0123  #LATIN SMALL LETTER G WITH CEDILLA
+0xED   0x0137  #LATIN SMALL LETTER K WITH CEDILLA
+0xEE   0x012B  #LATIN SMALL LETTER I WITH MACRON
+0xEF   0x013C  #LATIN SMALL LETTER L WITH CEDILLA
+0xF0   0x0161  #LATIN SMALL LETTER S WITH CARON
+0xF1   0x0144  #LATIN SMALL LETTER N WITH ACUTE
+0xF2   0x0146  #LATIN SMALL LETTER N WITH CEDILLA
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x014D  #LATIN SMALL LETTER O WITH MACRON
+0xF5   0x00F5  #LATIN SMALL LETTER O WITH TILDE
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x0173  #LATIN SMALL LETTER U WITH OGONEK
+0xF9   0x0142  #LATIN SMALL LETTER L WITH STROKE
+0xFA   0x015B  #LATIN SMALL LETTER S WITH ACUTE
+0xFB   0x016B  #LATIN SMALL LETTER U WITH MACRON
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x017C  #LATIN SMALL LETTER Z WITH DOT ABOVE
+0xFE   0x017E  #LATIN SMALL LETTER Z WITH CARON
+0xFF   0x02D9  #DOT ABOVE
diff --git a/basis/io/encodings/8-bit/CP1258.TXT b/basis/io/encodings/8-bit/CP1258.TXT
new file mode 100644 (file)
index 0000000..f402b34
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1258 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1258 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1258 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x0152  #LATIN CAPITAL LIGATURE OE
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x02DC  #SMALL TILDE
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x0153  #LATIN SMALL LIGATURE OE
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F   0x0178  #LATIN CAPITAL LETTER Y WITH DIAERESIS
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x00A1  #INVERTED EXCLAMATION MARK
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x00AA  #FEMININE ORDINAL INDICATOR
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x00BA  #MASCULINE ORDINAL INDICATOR
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00BF  #INVERTED QUESTION MARK
+0xC0   0x00C0  #LATIN CAPITAL LETTER A WITH GRAVE
+0xC1   0x00C1  #LATIN CAPITAL LETTER A WITH ACUTE
+0xC2   0x00C2  #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0xC3   0x0102  #LATIN CAPITAL LETTER A WITH BREVE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0xC6   0x00C6  #LATIN CAPITAL LETTER AE
+0xC7   0x00C7  #LATIN CAPITAL LETTER C WITH CEDILLA
+0xC8   0x00C8  #LATIN CAPITAL LETTER E WITH GRAVE
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x00CA  #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+0xCB   0x00CB  #LATIN CAPITAL LETTER E WITH DIAERESIS
+0xCC   0x0300  #COMBINING GRAVE ACCENT
+0xCD   0x00CD  #LATIN CAPITAL LETTER I WITH ACUTE
+0xCE   0x00CE  #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0xCF   0x00CF  #LATIN CAPITAL LETTER I WITH DIAERESIS
+0xD0   0x0110  #LATIN CAPITAL LETTER D WITH STROKE
+0xD1   0x00D1  #LATIN CAPITAL LETTER N WITH TILDE
+0xD2   0x0309  #COMBINING HOOK ABOVE
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x00D4  #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xD5   0x01A0  #LATIN CAPITAL LETTER O WITH HORN
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0xD9   0x00D9  #LATIN CAPITAL LETTER U WITH GRAVE
+0xDA   0x00DA  #LATIN CAPITAL LETTER U WITH ACUTE
+0xDB   0x00DB  #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x01AF  #LATIN CAPITAL LETTER U WITH HORN
+0xDE   0x0303  #COMBINING TILDE
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0xE1   0x00E1  #LATIN SMALL LETTER A WITH ACUTE
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x0103  #LATIN SMALL LETTER A WITH BREVE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0xE6   0x00E6  #LATIN SMALL LETTER AE
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x0301  #COMBINING ACUTE ACCENT
+0xED   0x00ED  #LATIN SMALL LETTER I WITH ACUTE
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0xF0   0x0111  #LATIN SMALL LETTER D WITH STROKE
+0xF1   0x00F1  #LATIN SMALL LETTER N WITH TILDE
+0xF2   0x0323  #COMBINING DOT BELOW
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x01A1  #LATIN SMALL LETTER O WITH HORN
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0xF9   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xFA   0x00FA  #LATIN SMALL LETTER U WITH ACUTE
+0xFB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x01B0  #LATIN SMALL LETTER U WITH HORN
+0xFE   0x20AB  #DONG SIGN
+0xFF   0x00FF  #LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/basis/io/encodings/8-bit/arabic/arabic-docs.factor b/basis/io/encodings/8-bit/arabic/arabic-docs.factor
new file mode 100644 (file)
index 0000000..5c86326
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.arabic
+
+HELP: latin/arabic
+{ $var-description "This is the ISO-8859-6 encoding, also called Latin/Arabic. It is an 8-bit superset of ASCII and provides the characters necessary for Arabic, though not other languages which use Arabic script." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.arabic" "Arabic encoding"
+"The " { $vocab-link "io.encodings.8-bit.arabic" }  " vocabulary provides the " { $link latin/arabic } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.arabic"
diff --git a/basis/io/encodings/8-bit/arabic/arabic.factor b/basis/io/encodings/8-bit/arabic/arabic.factor
new file mode 100644 (file)
index 0000000..5a80921
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.arabic
+
+8-BIT: latin/arabic ISO_8859-6:1987 8859-6
diff --git a/basis/io/encodings/8-bit/arabic/authors.txt b/basis/io/encodings/8-bit/arabic/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/basis/io/encodings/8-bit/cyrillic/authors.txt b/basis/io/encodings/8-bit/cyrillic/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/basis/io/encodings/8-bit/cyrillic/cyrillic-docs.factor b/basis/io/encodings/8-bit/cyrillic/cyrillic-docs.factor
new file mode 100644 (file)
index 0000000..741f1de
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.cyrillic
+
+HELP: latin/cyrillic
+{ $var-description "This is the ISO-8859-5 encoding, also called Latin/Cyrillic. It is an 8-bit superset of ASCII and provides the characters necessary for most languages which use Cyrilic, including Russian, Macedonian, Belarusian, Bulgarian, Serbian, and Ukrainian. KOI8-R is used much more commonly." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.cyrillic" "Cyrillic encoding"
+"The " { $vocab-link "io.encodings.8-bit.cyrillic" } " vocabulary provides the " { $link latin/cyrillic } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.cyrillic"
diff --git a/basis/io/encodings/8-bit/cyrillic/cyrillic.factor b/basis/io/encodings/8-bit/cyrillic/cyrillic.factor
new file mode 100644 (file)
index 0000000..13cfbc0
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.cyrillic
+
+8-BIT: latin/cyrillic ISO_8859-5:1988 8859-5
diff --git a/basis/io/encodings/8-bit/ebcdic/authors.txt b/basis/io/encodings/8-bit/ebcdic/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/basis/io/encodings/8-bit/ebcdic/ebcdic-docs.factor b/basis/io/encodings/8-bit/ebcdic/ebcdic-docs.factor
new file mode 100644 (file)
index 0000000..09646fd
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.ebcdic
+
+HELP: ebcdic
+{ $var-description "EBCDIC is an 8-bit legacy encoding designed for IBM mainframes like System/360 in the 1960s. It has since fallen into disuse. It contains large unallocated regions, and the version included here (code page 37) contains auxiliary characters in this region for English- and Portugese-speaking countries." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.ebcdic" "EBCDIC encoding"
+"The " { $vocab-link "io.encodings.8-bit.ebcdic" } " vocabulary provides the " { $link ebcdic } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.ebcdic"
diff --git a/basis/io/encodings/8-bit/ebcdic/ebcdic.factor b/basis/io/encodings/8-bit/ebcdic/ebcdic.factor
new file mode 100644 (file)
index 0000000..fd8f29c
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.ebcdic
+
+8-BIT: ebcdic IBM037 CP037
diff --git a/basis/io/encodings/8-bit/greek/authors.txt b/basis/io/encodings/8-bit/greek/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/basis/io/encodings/8-bit/greek/greek-docs.factor b/basis/io/encodings/8-bit/greek/greek-docs.factor
new file mode 100644 (file)
index 0000000..b7d658a
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.greek
+
+HELP: latin/greek
+{ $description "This is the ISO-8859-7 encoding, also called Latin/Greek. It is an 8-bit superset of ASCII and provides the characters necessary for Greek written in modern monotonic orthography, or ancient Greek without accent marks." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.greek" "Greek encoding"
+"The " { $vocab-link "io.encodings.8-bit.greek" }  " vocabulary provides the " { $link latin/greek } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.greek"
diff --git a/basis/io/encodings/8-bit/greek/greek.factor b/basis/io/encodings/8-bit/greek/greek.factor
new file mode 100644 (file)
index 0000000..98eb09a
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.greek
+
+8-BIT: latin/greek ISO_8859-7:1987 8859-7
diff --git a/basis/io/encodings/8-bit/hebrew/authors.txt b/basis/io/encodings/8-bit/hebrew/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/basis/io/encodings/8-bit/hebrew/hebrew-docs.factor b/basis/io/encodings/8-bit/hebrew/hebrew-docs.factor
new file mode 100644 (file)
index 0000000..43433e2
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.hebrew
+
+HELP: latin/hebrew
+{ $var-description "This is the ISO-8859-8 encoding, also called Latin/Hebrew. It is an 8-bit superset of ASCII and provides the characters necessary for modern Hebrew without explicit vowels. Generally, this is interpreted in logical order, making it ISO-8859-8-I, technically." }
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.hebrew" "Hebrew encoding"
+"The " { $vocab-link "io.encodings.8-bit.hebrew" } " vocabulary provides the " { $link latin/hebrew } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.hebrew"
diff --git a/basis/io/encodings/8-bit/hebrew/hebrew.factor b/basis/io/encodings/8-bit/hebrew/hebrew.factor
new file mode 100644 (file)
index 0000000..6619f64
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.hebrew
+
+8-BIT: latin/hebrew ISO_8859-8:1988 8859-8
diff --git a/basis/io/encodings/8-bit/koi8-r/authors.txt b/basis/io/encodings/8-bit/koi8-r/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/basis/io/encodings/8-bit/koi8-r/koi8-r-docs.factor b/basis/io/encodings/8-bit/koi8-r/koi8-r-docs.factor
new file mode 100644 (file)
index 0000000..94e2652
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.koi8-r
+
+HELP: koi8-r
+{ $var-description "KOI8-R is an 8-bit superset of ASCII which encodes the Cyrillic alphabet, as used in Russian and Bulgarian. Characters are in such an order that, if the eight bit is stripped, text is still interpretable as ASCII. Block-building characters also exist." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.koi8-r" "KOI8-R encoding"
+"The " { $vocab-link "io.encodings.8-bit.koi8-r" } " vocabulary provides the " { $link koi8-r } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.koi8-r"
diff --git a/basis/io/encodings/8-bit/koi8-r/koi8-r.factor b/basis/io/encodings/8-bit/koi8-r/koi8-r.factor
new file mode 100644 (file)
index 0000000..6203fbd
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.koi8-r
+
+8-BIT: koi8-r KOI8-R KOI8-R
diff --git a/basis/io/encodings/8-bit/latin1/authors.txt b/basis/io/encodings/8-bit/latin1/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/basis/io/encodings/8-bit/latin1/latin1-docs.factor b/basis/io/encodings/8-bit/latin1/latin1-docs.factor
new file mode 100644 (file)
index 0000000..90bc012
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin1
+
+HELP: latin1
+{ $var-description "This is the ISO-8859-1 encoding, also called Latin-1: Western European. It is an 8-bit superset of ASCII which is the default for a mimetype starting with 'text' and provides the characters necessary for most western European languages." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin1" "Latin1 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin1" } " vocabulary provides the " { $link latin1 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin1"
diff --git a/basis/io/encodings/8-bit/latin1/latin1.factor b/basis/io/encodings/8-bit/latin1/latin1.factor
new file mode 100644 (file)
index 0000000..17a2941
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin1
+
+8-BIT: latin1 ISO_8859-1:1987 8859-1
diff --git a/basis/io/encodings/8-bit/latin10/authors.txt b/basis/io/encodings/8-bit/latin10/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/basis/io/encodings/8-bit/latin10/latin10-docs.factor b/basis/io/encodings/8-bit/latin10/latin10-docs.factor
new file mode 100644 (file)
index 0000000..382b083
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin10
+
+HELP: latin10
+{ $var-description "This is the ISO-8859-16 encoding, also called Latin-10: South-Eastern European. It is an 8-bit superset of ASCII." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin10" "Latin10 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin10" } " vocabulary provides the " { $link latin10 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin10"
diff --git a/basis/io/encodings/8-bit/latin10/latin10.factor b/basis/io/encodings/8-bit/latin10/latin10.factor
new file mode 100644 (file)
index 0000000..86831d4
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin10
+
+8-BIT: latin10 ISO-8859-16 8859-16
diff --git a/basis/io/encodings/8-bit/latin2/authors.txt b/basis/io/encodings/8-bit/latin2/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/basis/io/encodings/8-bit/latin2/latin2-docs.factor b/basis/io/encodings/8-bit/latin2/latin2-docs.factor
new file mode 100644 (file)
index 0000000..1da488f
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin2
+
+HELP: latin2
+{ $var-description "This is the ISO-8859-2 encoding, also called Latin-2: Eastern European. It is an 8-bit superset of ASCII and provides the characters necessary for most eastern European languages." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin2" "Latin2 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin2" }  " vocabulary provides the " { $link latin2 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin2"
diff --git a/basis/io/encodings/8-bit/latin2/latin2.factor b/basis/io/encodings/8-bit/latin2/latin2.factor
new file mode 100644 (file)
index 0000000..52ecc64
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin2
+
+8-BIT: latin2 ISO_8859-2:1987 8859-2
diff --git a/basis/io/encodings/8-bit/latin3/authors.txt b/basis/io/encodings/8-bit/latin3/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/basis/io/encodings/8-bit/latin3/latin3-docs.factor b/basis/io/encodings/8-bit/latin3/latin3-docs.factor
new file mode 100644 (file)
index 0000000..8cb719b
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin3
+
+HELP: latin3
+{ $var-description "This is the ISO-8859-3 encoding, also called Latin-3: South European. It is an 8-bit superset of ASCII and provides the characters necessary for Turkish, Maltese and Esperanto." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin3" "Latin3 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin3" }  " vocabulary provides the " { $link latin3 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin3"
diff --git a/basis/io/encodings/8-bit/latin3/latin3.factor b/basis/io/encodings/8-bit/latin3/latin3.factor
new file mode 100644 (file)
index 0000000..a9a6333
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin3
+
+8-BIT: latin3 ISO_8859-3:1988 8859-3
diff --git a/basis/io/encodings/8-bit/latin4/authors.txt b/basis/io/encodings/8-bit/latin4/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/basis/io/encodings/8-bit/latin4/latin4-docs.factor b/basis/io/encodings/8-bit/latin4/latin4-docs.factor
new file mode 100644 (file)
index 0000000..cfb53d2
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin4
+
+HELP: latin4
+{ $description "This is the ISO-8859-4 encoding, also called Latin-4: North European. It is an 8-bit superset of ASCII and provides the characters necessary for Latvian, Lithuanian, Estonian, Greenlandic and Sami." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin4" "Latin4 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin4" }  " vocabulary provides the " { $link latin4 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin4"
diff --git a/basis/io/encodings/8-bit/latin4/latin4.factor b/basis/io/encodings/8-bit/latin4/latin4.factor
new file mode 100644 (file)
index 0000000..34a68a8
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin4
+
+8-BIT: latin4 ISO_8859-4:1988 8859-4
+
diff --git a/basis/io/encodings/8-bit/latin5/authors.txt b/basis/io/encodings/8-bit/latin5/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/basis/io/encodings/8-bit/latin5/latin5-docs.factor b/basis/io/encodings/8-bit/latin5/latin5-docs.factor
new file mode 100644 (file)
index 0000000..60feed1
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin5
+
+HELP: latin5
+{ $var-description "This is the ISO-8859-9 encoding, also called Latin-5: Turkish. It is an 8-bit superset of ASCII and provides the characters necessary for Turkish, similar to Latin-1 but replacing the spots used for Icelandic with characters used in Turkish." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin5" "Latin5 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin5" }  " vocabulary provides the " { $link latin5 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin5"
diff --git a/basis/io/encodings/8-bit/latin5/latin5.factor b/basis/io/encodings/8-bit/latin5/latin5.factor
new file mode 100644 (file)
index 0000000..502c10f
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin5
+
+8-BIT: latin5 ISO_8859-9:1989 8859-9
diff --git a/basis/io/encodings/8-bit/latin6/authors.txt b/basis/io/encodings/8-bit/latin6/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/basis/io/encodings/8-bit/latin6/latin6-docs.factor b/basis/io/encodings/8-bit/latin6/latin6-docs.factor
new file mode 100644 (file)
index 0000000..f1866c3
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin6
+
+HELP: latin6
+{ $var-description "This is the ISO-8859-10 encoding, also called Latin-6: Nordic. It is an 8-bit superset of ASCII containing the same characters as Latin-4, but rearranged to be of better use to nordic languages." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin6" "Latin6 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin6" }  " vocabulary provides the " { $link latin6 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin6"
diff --git a/basis/io/encodings/8-bit/latin6/latin6.factor b/basis/io/encodings/8-bit/latin6/latin6.factor
new file mode 100644 (file)
index 0000000..5e71f75
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin6
+
+8-BIT: latin6 ISO-8859-10 8859-10
+
diff --git a/basis/io/encodings/8-bit/latin7/authors.txt b/basis/io/encodings/8-bit/latin7/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/basis/io/encodings/8-bit/latin7/latin7-docs.factor b/basis/io/encodings/8-bit/latin7/latin7-docs.factor
new file mode 100644 (file)
index 0000000..ebd5eb6
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin7
+
+HELP: latin7
+{ $var-description "This is the ISO-8859-13 encoding, also called Latin-7: Baltic Rim. It is an 8-bit superset of ASCII containing all characters necessary to represent Baltic Rim languages, as previous character sets were incomplete." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin7" "Latin7 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin7" }  " vocabulary provides the " { $link latin7 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin7"
diff --git a/basis/io/encodings/8-bit/latin7/latin7.factor b/basis/io/encodings/8-bit/latin7/latin7.factor
new file mode 100644 (file)
index 0000000..862daae
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin7
+
+8-BIT: latin7 ISO-8859-13 8859-13
diff --git a/basis/io/encodings/8-bit/latin8/authors.txt b/basis/io/encodings/8-bit/latin8/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/basis/io/encodings/8-bit/latin8/latin8-docs.factor b/basis/io/encodings/8-bit/latin8/latin8-docs.factor
new file mode 100644 (file)
index 0000000..5dc2f1e
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin8
+
+HELP: latin8
+{ $var-description "This is the ISO-8859-14 encoding, also called Latin-8: Celtic. It is an 8-bit superset of ASCII designed for Celtic languages like Gaelic and Breton." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin8" "Latin8 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin8" }  " vocabulary provides the " { $link latin8 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin8"
diff --git a/basis/io/encodings/8-bit/latin8/latin8.factor b/basis/io/encodings/8-bit/latin8/latin8.factor
new file mode 100644 (file)
index 0000000..e925737
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin8
+
+8-BIT: latin8 ISO-8859-14 8859-14
diff --git a/basis/io/encodings/8-bit/latin9/authors.txt b/basis/io/encodings/8-bit/latin9/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/basis/io/encodings/8-bit/latin9/latin9-docs.factor b/basis/io/encodings/8-bit/latin9/latin9-docs.factor
new file mode 100644 (file)
index 0000000..2416db3
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin9
+
+HELP: latin9
+{ $var-description "This is the ISO-8859-15 encoding, also called Latin-9 and unoffically as Latin-0. It is an 8-bit superset of ASCII designed as a modification of Latin-1, removing little-used characters in favor of the Euro symbol and other characters." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin9" "Latin9 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin9" }  " vocabulary provides the " { $link latin9 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin9"
diff --git a/basis/io/encodings/8-bit/latin9/latin9.factor b/basis/io/encodings/8-bit/latin9/latin9.factor
new file mode 100644 (file)
index 0000000..b55ecb3
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin9
+
+8-BIT: latin9 ISO-8859-15 8859-15
diff --git a/basis/io/encodings/8-bit/mac-roman/authors.txt b/basis/io/encodings/8-bit/mac-roman/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/basis/io/encodings/8-bit/mac-roman/mac-roman-docs.factor b/basis/io/encodings/8-bit/mac-roman/mac-roman-docs.factor
new file mode 100644 (file)
index 0000000..3fd00fa
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.mac-roman
+
+HELP: mac-roman
+{ $var-description "Mac Roman is an 8-bit superset of ASCII which was the standard encoding on Mac OS prior to version 10. It is incompatible with Latin-1 in all but a few places and ASCII, and it is suitable for encoding many Western European languages." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.mac-roman" "Mac Roman encoding"
+"The " { $vocab-link "io.encodings.8-bit.mac-roman" } " vocabulary provides the " { $link mac-roman } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.mac-roman"
diff --git a/basis/io/encodings/8-bit/mac-roman/mac-roman.factor b/basis/io/encodings/8-bit/mac-roman/mac-roman.factor
new file mode 100644 (file)
index 0000000..0b70765
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.mac-roman
+
+8-BIT: mac-roman macintosh ROMAN
diff --git a/basis/io/encodings/8-bit/thai/authors.txt b/basis/io/encodings/8-bit/thai/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/basis/io/encodings/8-bit/thai/thai-docs.factor b/basis/io/encodings/8-bit/thai/thai-docs.factor
new file mode 100644 (file)
index 0000000..5d2640b
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.thai
+
+HELP: latin/thai
+{ $var-description "This is the ISO-8859-11 encoding, also called Latin/Thai. It is an 8-bit superset of ASCII containing the characters necessary to represent Thai. It is basically identical to TIS-620." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.thai" "Thai encoding"
+"The " { $vocab-link "io.encodings.8-bit.thai" }  " vocabulary provides the " { $link latin/thai } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.thai"
diff --git a/basis/io/encodings/8-bit/thai/thai.factor b/basis/io/encodings/8-bit/thai/thai.factor
new file mode 100644 (file)
index 0000000..8d119f6
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.thai
+
+8-BIT: latin/thai TIS-620 8859-11
diff --git a/basis/io/encodings/8-bit/windows-1250/authors.txt b/basis/io/encodings/8-bit/windows-1250/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/basis/io/encodings/8-bit/windows-1250/windows-1250.factor b/basis/io/encodings/8-bit/windows-1250/windows-1250.factor
new file mode 100644 (file)
index 0000000..745ebe4
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1250
+
+8-BIT: windows-1250 windows-1250 CP1250
diff --git a/basis/io/encodings/8-bit/windows-1251/authors.txt b/basis/io/encodings/8-bit/windows-1251/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/basis/io/encodings/8-bit/windows-1251/windows-1251.factor b/basis/io/encodings/8-bit/windows-1251/windows-1251.factor
new file mode 100644 (file)
index 0000000..3c50d3c
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1251
+
+8-BIT: windows-1251 windows-1251 CP1251
diff --git a/basis/io/encodings/8-bit/windows-1252/authors.txt b/basis/io/encodings/8-bit/windows-1252/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/basis/io/encodings/8-bit/windows-1252/windows-1252-docs.factor b/basis/io/encodings/8-bit/windows-1252/windows-1252-docs.factor
new file mode 100644 (file)
index 0000000..cd9461e
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.windows-1252
+
+HELP: windows-1252
+{ $var-description "Windows 1252 is an 8-bit superset of ASCII which is closely related to Latin-1. Control characters in the 0x80 to 0x9F range are replaced with printable characters such as the Euro symbol." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.windows-1252" "Windows 1252 encoding"
+"The " { $vocab-link "io.encodings.8-bit.windows-1252" } " vocabulary provides the " { $link windows-1252 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.windows-1252"
diff --git a/basis/io/encodings/8-bit/windows-1252/windows-1252.factor b/basis/io/encodings/8-bit/windows-1252/windows-1252.factor
new file mode 100644 (file)
index 0000000..ddcc4df
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1252
+
+8-BIT: windows-1252 windows-1252 CP1252
diff --git a/basis/io/encodings/8-bit/windows-1253/authors.txt b/basis/io/encodings/8-bit/windows-1253/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/basis/io/encodings/8-bit/windows-1253/windows-1253.factor b/basis/io/encodings/8-bit/windows-1253/windows-1253.factor
new file mode 100644 (file)
index 0000000..ba335be
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1253
+
+8-BIT: windows-1253 windows-1253 CP1253
diff --git a/basis/io/encodings/8-bit/windows-1254/authors.txt b/basis/io/encodings/8-bit/windows-1254/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/basis/io/encodings/8-bit/windows-1254/windows-1254.factor b/basis/io/encodings/8-bit/windows-1254/windows-1254.factor
new file mode 100644 (file)
index 0000000..982d21a
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1254
+
+8-BIT: windows-1254 windows-1254 CP1254
diff --git a/basis/io/encodings/8-bit/windows-1255/authors.txt b/basis/io/encodings/8-bit/windows-1255/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/basis/io/encodings/8-bit/windows-1255/windows-1255.factor b/basis/io/encodings/8-bit/windows-1255/windows-1255.factor
new file mode 100644 (file)
index 0000000..952e5fe
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1255
+
+8-BIT: windows-1255 windows-1255 CP1255
diff --git a/basis/io/encodings/8-bit/windows-1256/authors.txt b/basis/io/encodings/8-bit/windows-1256/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/basis/io/encodings/8-bit/windows-1256/windows-1256.factor b/basis/io/encodings/8-bit/windows-1256/windows-1256.factor
new file mode 100644 (file)
index 0000000..303d25c
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1256
+
+8-BIT: windows-1256 windows-1256 CP1256
diff --git a/basis/io/encodings/8-bit/windows-1257/authors.txt b/basis/io/encodings/8-bit/windows-1257/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/basis/io/encodings/8-bit/windows-1257/windows-1257.factor b/basis/io/encodings/8-bit/windows-1257/windows-1257.factor
new file mode 100644 (file)
index 0000000..80b21e8
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1257
+
+8-BIT: windows-1257 windows-1257 CP1257
diff --git a/basis/io/encodings/8-bit/windows-1258/authors.txt b/basis/io/encodings/8-bit/windows-1258/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/basis/io/encodings/8-bit/windows-1258/windows-1258.factor b/basis/io/encodings/8-bit/windows-1258/windows-1258.factor
new file mode 100644 (file)
index 0000000..1c7bf63
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1258
+
+8-BIT: windows-1258 windows-1258 CP1258
index 2be709dbc9bb71bdc14763ccec9e52718d7b84fe..512b52ef19e85f165c0022e73139f4a982095c12 100644 (file)
@@ -48,7 +48,8 @@ TUPLE: range ufirst ulast bfirst blast ;
     ] dip set-at ;
 
 : xml>gb-data ( stream -- mapping ranges )
-    [let | mapping [ H{ } clone ] ranges [ V{ } clone ] |
+    [let
+        H{ } clone :> mapping V{ } clone :> ranges
         [
             dup contained? [ 
                 dup name>> main>> {
@@ -57,7 +58,7 @@ TUPLE: range ufirst ulast bfirst blast ;
                     [ 2drop ]
                 } case
             ] [ drop ] if
-        ] each-element mapping ranges 
+        ] each-element mapping ranges
     ] ;
 
 : unlinear ( num -- bytes )
@@ -66,7 +67,7 @@ TUPLE: range ufirst ulast bfirst blast ;
     126 /mod HEX: 81 + swap
     10 /mod HEX: 30 + swap
     HEX: 81 +
-    4byte-array dup reverse-here ;
+    4byte-array reverse! ;
 
 : >interval-map-by ( start-quot end-quot value-quot seq -- interval-map )
     '[ _ [ @ 2array ] _ tri ] { } map>assoc <interval-map> ; inline
index 594e245a9c11328ac17ca1d22a97ca24890f8fad..a2a919da0db276e1eeb473b6420dc253ed0f3c36 100644 (file)
@@ -57,4 +57,4 @@ e>n-table [ initial-e>n ] initialize
 ascii "ANSI_X3.4-1968" register-encoding
 utf16be "UTF-16BE" register-encoding
 utf16le "UTF-16LE" register-encoding
-utf16 "UTF-16" register-encoding
\ No newline at end of file
+utf16 "UTF-16" register-encoding
index a057df28e0aa2a0b90e60b2fba0b1568b4fbafe4..17264267777486fc000ae91e6d7bd5daa0e7744b 100644 (file)
@@ -31,7 +31,7 @@ M: iso2022 <encoder>
 M: iso2022 <decoder>
     make-iso-coder <decoder> ;
 
-<< SYNTAX: ESC HEX: 16 parsed ; >>
+<< SYNTAX: ESC HEX: 16 suffix! ; >>
 
 CONSTANT: switch-ascii B{ ESC CHAR: ( CHAR: B }
 CONSTANT: switch-jis201 B{ ESC CHAR: ( CHAR: J }
index 04dfce76435cbc6d7f6fa0675d4e8de5c959f085..8ec5753e1185d8b89b5308db9c2667bb3187bc16 100644 (file)
@@ -80,7 +80,7 @@ M: linux file-systems
     ] if ;
 
 : find-mount-point ( path -- mtab-entry )
-    canonicalize-path
+    resolve-symlinks
     parse-mtab [ [ mount-point>> ] keep ] H{ } map>assoc (find-mount-point) ;
 
 ERROR: file-system-not-found ;
index 5ae21fcfee111898ae48b66d7ddfefb177dcf998..9f0e4534e9290d0812db627a23409a06eb96edaf 100755 (executable)
@@ -151,12 +151,16 @@ PRIVATE>
 M: winnt file-system-info ( path -- file-system-info )
     normalize-path root-directory (file-system-info) ;
 
-: volume>paths ( string -- array )
-    16384 <ushort-array> tuck dup length
-    0 <uint> dup [ GetVolumePathNamesForVolumeName 0 = ] dip swap [
-        win32-error-string throw
+:: volume>paths ( string -- array )
+    16384 :> names-buf-length
+    names-buf-length <ushort-array> :> names
+    0 <uint> :> names-length
+
+    string names names-buf-length names-length GetVolumePathNamesForVolumeName :> ret
+    ret 0 = [
+        ret win32-error-string throw
     ] [
-        *uint "ushort" heap-size * head
+        names names-length *uint "ushort" heap-size * head
         utf16n alien>string CHAR: \0 split
     ] if ;
 
@@ -166,13 +170,16 @@ M: winnt file-system-info ( path -- file-system-info )
     FindFirstVolume dup win32-error=0/f
     [ utf16n alien>string ] dip ;
 
-: find-next-volume ( handle -- string/f )
-    MAX_PATH 1 + [ <ushort-array> tuck ] keep
-    FindNextVolume 0 = [
+:: find-next-volume ( handle -- string/f )
+    MAX_PATH 1 + :> buf-length
+    buf-length <ushort-array> :> buf
+
+    handle buf buf-length FindNextVolume :> ret
+    ret 0 = [
         GetLastError ERROR_NO_MORE_FILES =
-        [ drop f ] [ win32-error-string throw ] if
+        [ f ] [ win32-error-string throw ] if
     ] [
-        utf16n alien>string
+        buf utf16n alien>string
     ] if ;
 
 : find-volumes ( -- array )
index c9a651b4844cfa5a004b1bdb4fa927b2651654c9..f41adfa7311e2f948eaebbeef96d12ff53b57e3d 100644 (file)
@@ -13,6 +13,6 @@ M: unix make-hard-link ( path1 path2 -- )
 M: unix read-link ( path -- path' )
     normalize-path read-symbolic-link ;
 
-M: unix canonicalize-path ( path -- path' )
+M: unix resolve-symlinks ( path -- path' )
     path-components "/"
     [ append-path dup exists? [ follow-links ] when ] reduce ;
index 97754cf237ae9e8114161d960d8e4a483ed8abe6..10c5710f7dff8c2b187cd12955629e5fe286555c 100755 (executable)
@@ -38,7 +38,7 @@ M: winnt root-directory? ( path -- ? )
 TR: normalize-separators "/" "\\" ;
 
 M: winnt normalize-path ( string -- string' )
-    (normalize-path)
+    absolute-path
     normalize-separators
     prepend-prefix ;
 
index d1a41a1f09a829e1caf2b659dd99ef2c25df315b..cb20f78a3301c764436b386370b2da0190a5c6cd 100755 (executable)
@@ -82,8 +82,6 @@ SYMBOL: wait-flag
     V{ } clone swap processes get set-at
     wait-flag get-global raise-flag ;
 
-M: process hashcode* handle>> hashcode* ;
-
 : pass-environment? ( process -- ? )
     dup environment>> assoc-empty? not
     swap environment-mode>> +replace-environment+ eq? or ;
index 852d8171e403233ea31a49ea4d295fe7ed2eb5ac..7fa7f4b2c68d0357dd8ecb17ce6de04815130ba3 100644 (file)
@@ -125,14 +125,15 @@ concurrency.promises threads unix.process ;
 
 ! Killed processes were exiting with code 0 on FreeBSD
 [ f ] [
-    [let | p [ <promise> ]
-           s [ <promise> ] |
-       [
-           "sleep 1000" run-detached
-           [ p fulfill ] [ wait-for-process s fulfill ] bi
-       ] in-thread
-
-       p ?promise handle>> 9 kill drop
-       s ?promise 0 =
+    [let 
+        <promise> :> p
+        <promise> :> s
+        [
+            "sleep 1000" run-detached
+            [ p fulfill ] [ wait-for-process s fulfill ] bi
+        ] in-thread
+
+        p ?promise handle>> 9 kill drop
+        s ?promise 0 =
     ]
 ] unit-test
index 5424ab423823c3d4bc0e88670cfd66a9673c66fb..a9e3324986d041ad5de58cd755af81b0b69efc11 100644 (file)
@@ -71,7 +71,7 @@ IN: io.launcher.unix
 : spawn-process ( process -- * )
     [ setup-priority ] [ 250 _exit ] recover
     [ setup-redirection ] [ 251 _exit ] recover
-    [ current-directory get (normalize-path) cd ] [ 252 _exit ] recover
+    [ current-directory get absolute-path cd ] [ 252 _exit ] recover
     [ setup-environment ] [ 253 _exit ] recover
     [ get-arguments exec-args-with-path ] [ 254 _exit ] recover
     255 _exit ;
index 39455da5780b4f5f3de343a3b31ed2a42a2fc8ea..8a800115f6421e607744c40514d3ca99f52c036a 100755 (executable)
@@ -129,10 +129,10 @@ M: windows current-process-handle ( -- handle )
 
 M: windows run-process* ( process -- handle )
     [
-        current-directory get (normalize-path) cd
+        current-directory get absolute-path cd
 
         dup make-CreateProcess-args
-        tuck fill-redirection
+        [ fill-redirection ] keep
         dup call-CreateProcess
         lpProcessInformation>>
     ] with-destructors ;
index fe16e08467cecfb38832c8ffa6053a77dabb9c03..33ba6850a531ce900935db4d7b37295fb99a897d 100644 (file)
@@ -68,8 +68,7 @@ ARTICLE: "io.mmap.arrays" "Working with memory-mapped data"
 "The " { $link <mapped-file> } " word returns an instance of " { $link mapped-file } ", which doesn't directly support the sequence protocol. Instead, it needs to be wrapped in a specialized array of the appropriate C type:"
 { $subsections <mapped-array> }
 "Additionally, files may be opened with two combinators which take a c-type as input:"
-{ $subsections with-mapped-array }
-{ $subsections with-mapped-array-reader }
+{ $subsections with-mapped-array with-mapped-array-reader }
 "The appropriate specialized array type must first be generated with " { $link POSTPONE: SPECIALIZED-ARRAY: } "."
 $nl
 "Data can also be read and written from the " { $link mapped-file } " by applying low-level alien words to the " { $slot "address" } " slot. This approach is not recommended, though, since in most cases the compiler will generate efficient code for specialized array usage. See " { $link "reading-writing-memory" } " for a description of low-level memory access primitives." ;
@@ -82,7 +81,7 @@ ARTICLE: "io.mmap.examples" "Memory-mapped file examples"
     ""
     "\"mydata.dat\" char ["
     "    4 <sliced-groups>"
-    "    [ reverse-here ] change-each"
+    "    [ reverse! drop ] map! drop"
     "] with-mapped-array"
 }
 "Normalize a file containing packed quadrupes of floats:"
@@ -92,7 +91,7 @@ ARTICLE: "io.mmap.examples" "Memory-mapped file examples"
     "SPECIALIZED-ARRAY: float-4"
     ""
     "\"mydata.dat\" float-4 ["
-    "    [ normalize ] change-each"
+    "    [ normalize ] map! drop"
     "] with-mapped-array"
 } ;
 
@@ -101,10 +100,10 @@ ARTICLE: "io.mmap" "Memory-mapped files"
 { $subsections <mapped-file> }
 "Memory-mapped files are disposable and can be closed with " { $link dispose } " or " { $link with-disposal } "." $nl
 "Utility combinators which wrap the above:"
-{ $subsections with-mapped-file }
-{ $subsections with-mapped-file-reader }
-{ $subsections with-mapped-array }
-{ $subsections with-mapped-array-reader }
+{ $subsections with-mapped-file
+    with-mapped-file-reader
+    with-mapped-array
+    with-mapped-array-reader }
 "Instances of " { $link mapped-file } " don't support any interesting operations in themselves. There are two facilities for accessing their contents:"
 { $subsections
     "io.mmap.arrays"
index a2c1f972a6c1bbc7b36182bcb06ae7671d0fcde5..e3e3116b59047f5852b9912f7cecdab773bce76a 100644 (file)
@@ -12,14 +12,13 @@ IN: io.mmap.windows
     MapViewOfFile [ win32-error=0/f ] keep ;
 
 :: mmap-open ( path length access-mode create-mode protect access -- handle handle address )
-    [let | lo [ length 32 bits ]
-           hi [ length -32 shift 32 bits ] |
-        { "SeCreateGlobalPrivilege" "SeLockMemoryPrivilege" } [
-            path access-mode create-mode 0 open-file |dispose
-            dup handle>> f protect hi lo f create-file-mapping |dispose
-            dup handle>> access 0 0 0 map-view-of-file
-        ] with-privileges
-    ] ;
+    length 32 bits :> lo
+    length -32 shift 32 bits :> hi
+    { "SeCreateGlobalPrivilege" "SeLockMemoryPrivilege" } [
+        path access-mode create-mode 0 open-file |dispose
+        dup handle>> f protect hi lo f create-file-mapping |dispose
+        dup handle>> access 0 0 0 map-view-of-file
+    ] with-privileges ;
 
 TUPLE: win32-mapped-file file mapping ;
 
index 3e1e9192175f443305772589811caedf0d341b5a..7653eaa84cbcbd563ef06ede7266c6a0b2045601 100644 (file)
@@ -36,7 +36,7 @@ TUPLE: linux-monitor < monitor wd inotify watches ;
     inotify-fd -rot inotify_add_watch dup io-error dup check-existing ;
 
 : add-watch ( path mask mailbox -- monitor )
-    [ [ (normalize-path) ] dip [ (add-watch) ] [ drop ] 2bi ] dip
+    [ [ absolute-path ] dip [ (add-watch) ] [ drop ] 2bi ] dip
     <linux-monitor> [ ] [ ] [ wd>> ] tri watches get set-at ;
 
 : check-inotify ( -- )
index 96f178fb7967ad9dba79970c19dfdf8dace7bb69..e71fb2eca2f9476ac364fbae266684a252104e80 100644 (file)
@@ -11,11 +11,10 @@ TUPLE: macosx-monitor < monitor handle ;
     '[ first { +modify-file+ } _ queue-change ] each ;
 
 M:: macosx (monitor) ( path recursive? mailbox -- monitor )
-    [let | path [ path normalize-path ] |
-        path mailbox macosx-monitor new-monitor
-        dup [ enqueue-notifications ] curry
-        path 1array 0 0 <event-stream> >>handle
-    ] ;
+    path normalize-path :> path
+    path mailbox macosx-monitor new-monitor
+    dup [ enqueue-notifications ] curry
+    path 1array 0 0 <event-stream> >>handle ;
 
 M: macosx-monitor dispose* handle>> dispose ;
 
index 75dfd234a8ce77ac4decf28f2049382037867227..33477abdb639b738943e177a1240c6fa96322204 100644 (file)
@@ -95,7 +95,7 @@ M: recursive-monitor dispose*
     ready>> ?promise ?linked drop ;
 
 : <recursive-monitor> ( path mailbox -- monitor )
-    [ (normalize-path) ] dip
+    [ absolute-path ] dip
     recursive-monitor new-monitor
         H{ } clone >>children
         <promise> >>ready
index 8cdd1d97bd9d35b9bf4df4b12fe68aa4457e85ce..3ea4c105f5009a651450a88f1570e285a956a6fa 100644 (file)
@@ -53,7 +53,7 @@ M: input-port stream-read-partial ( max stream -- byte-array/f )
 : read-loop ( count port accum -- )
     pick over length - dup 0 > [
         pick read-step dup [
-            over push-all read-loop
+            append! read-loop
         ] [
             2drop 2drop
         ] if
@@ -78,7 +78,7 @@ M: input-port stream-read
 
 : read-until-loop ( seps port buf -- separator/f )
     2over read-until-step over [
-        [ over push-all ] dip dup [
+        [ append! ] dip dup [
             [ 3drop ] dip
         ] [
             drop read-until-loop
diff --git a/basis/io/servers/packet/authors.txt b/basis/io/servers/packet/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/basis/io/servers/packet/packet.factor b/basis/io/servers/packet/packet.factor
deleted file mode 100644 (file)
index 2a346b4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-USING: concurrency.combinators destructors fry
-io.sockets kernel logging ;
-IN: io.servers.packet
-
-<PRIVATE
-
-LOG: received-datagram NOTICE
-
-: datagram-loop ( quot datagram -- )
-    [
-        [ receive dup received-datagram [ swap call ] dip ] keep
-        pick [ send ] [ 3drop ] if
-    ] 2keep datagram-loop ; inline
-
-: spawn-datagrams ( quot addrspec -- )
-    <datagram> [ datagram-loop ] with-disposal ; inline
-
-\ spawn-datagrams NOTICE add-input-logging
-
-PRIVATE>
-
-: with-datagrams ( seq service quot -- )
-    '[ [ [ _ ] dip spawn-datagrams ] parallel-each ] with-logging ; inline
diff --git a/basis/io/servers/packet/summary.txt b/basis/io/servers/packet/summary.txt
deleted file mode 100644 (file)
index 29247a2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Multi-threaded UDP/IP servers
diff --git a/basis/io/servers/packet/tags.txt b/basis/io/servers/packet/tags.txt
deleted file mode 100644 (file)
index 992ae12..0000000
+++ /dev/null
@@ -1 +0,0 @@
-network
index 400a44ea020c78daa5e4d7165de773af5ac4f638..b3cf28a497909e1b22c91992d15e82157f3e10df 100644 (file)
@@ -5,7 +5,7 @@ math.order combinators init alien alien.c-types alien.data
 alien.strings libc continuations destructors summary splitting
 assocs random math.parser locals unicode.case openssl
 openssl.libcrypto openssl.libssl io.backend io.ports io.pathnames
-io.encodings.8-bit io.timeouts io.sockets.secure ;
+io.encodings.8-bit.latin1 io.timeouts io.sockets.secure ;
 IN: io.sockets.secure.openssl
 
 GENERIC: ssl-method ( symbol -- method )
@@ -25,7 +25,7 @@ TUPLE: openssl-context < secure-context aliens sessions ;
 
 : load-certificate-chain ( ctx -- )
     dup config>> key-file>> [
-        [ handle>> ] [ config>> key-file>> (normalize-path) ] bi
+        [ handle>> ] [ config>> key-file>> absolute-path ] bi
         SSL_CTX_use_certificate_chain_file
         ssl-error
     ] [ drop ] if ;
@@ -35,10 +35,9 @@ TUPLE: openssl-context < secure-context aliens sessions ;
     [| buf size rwflag password! |
         password [ B{ 0 } password! ] unless
 
-        [let | len [ password strlen ] |
-            buf password len 1 + size min memcpy
-            len
-        ]
+        password strlen :> len
+        buf password len 1 + size min memcpy
+        len
     ] alien-callback ;
 
 : default-pasword ( ctx -- alien )
@@ -56,7 +55,7 @@ TUPLE: openssl-context < secure-context aliens sessions ;
 
 : use-private-key-file ( ctx -- )
     dup config>> key-file>> [
-        [ handle>> ] [ config>> key-file>> (normalize-path) ] bi
+        [ handle>> ] [ config>> key-file>> absolute-path ] bi
         SSL_FILETYPE_PEM SSL_CTX_use_PrivateKey_file
         ssl-error
     ] [ drop ] if ;
@@ -66,8 +65,8 @@ TUPLE: openssl-context < secure-context aliens sessions ;
         [ handle>> ]
         [
             config>>
-            [ ca-file>> dup [ (normalize-path) ] when ]
-            [ ca-path>> dup [ (normalize-path) ] when ] bi
+            [ ca-file>> dup [ absolute-path ] when ]
+            [ ca-path>> dup [ absolute-path ] when ] bi
         ] bi
         SSL_CTX_load_verify_locations
     ] [ handle>> SSL_CTX_set_default_verify_paths ] if ssl-error ;
index a542575446d4717ebc2339b841b55797f56565c6..e45224fcc20fba3b07abeaa9551a3e9ff76095b9 100755 (executable)
@@ -173,6 +173,8 @@ GENERIC: (get-remote-address) ( handle remote -- sockaddr )
         [ <input-port> |dispose ] [ <output-port> |dispose ] bi
     ] with-destructors ;
 
+SYMBOL: bind-local-address
+
 GENERIC: establish-connection ( client-out remote -- )
 
 GENERIC: ((client)) ( remote -- handle )
@@ -321,6 +323,18 @@ M: invalid-inet-server summary
 M: inet (server)
     invalid-inet-server ;
 
+ERROR: invalid-local-address addrspec ;
+
+M: invalid-local-address summary
+    drop "Cannot use with-local-address with <inet>; use <inet4> or <inet6> instead" ;
+
+: with-local-address ( addr quot -- )
+    [
+        [ ] [ inet4? ] [ inet6? ] tri or
+        [ bind-local-address ]
+        [ invalid-local-address ] if
+    ] dip with-variable ; inline
+
 {
     { [ os unix? ] [ "io.sockets.unix" require ] }
     { [ os winnt? ] [ "io.sockets.windows.nt" require ] }
index d2df4d9e13947a3bb86d3f93031e6d8ecbaf5c88..71ad5a57582a91b7aa4866cc4497e01dc6a5953a 100755 (executable)
@@ -69,8 +69,12 @@ M: object establish-connection ( client-out remote -- )
         [ (io-error) ]
     } cond ;
 
+: ?bind-client ( socket -- )
+    bind-local-address get [ [ fd>> ] dip make-sockaddr/size bind io-error ] [ drop ] if* ; inline
+
 M: object ((client)) ( addrspec -- fd )
-    protocol-family SOCK_STREAM socket-fd dup init-client-socket ;
+    protocol-family SOCK_STREAM socket-fd
+    [ init-client-socket ] [ ?bind-client ] [ ] tri ;
 
 ! Server sockets - TCP and Unix domain
 : init-server-socket ( fd -- )
@@ -116,7 +120,7 @@ CONSTANT: packet-size 65536
 [ packet-size malloc &free receive-buffer set-global ] "io.sockets.unix" add-startup-hook
 
 :: do-receive ( port -- packet sockaddr )
-    port addr>> empty-sockaddr/size :> len :> sockaddr
+    port addr>> empty-sockaddr/size :> ( sockaddr len )
     port handle>> handle-fd ! s
     receive-buffer get-global ! buf
     packet-size ! nbytes
@@ -159,7 +163,7 @@ M: local sockaddr-size drop sockaddr-un heap-size ;
 M: local empty-sockaddr drop sockaddr-un <struct> ;
 
 M: local make-sockaddr
-    path>> (normalize-path)
+    path>> absolute-path
     dup length 1 + max-un-path > [ "Path too long" throw ] when
     sockaddr-un <struct>
         AF_UNIX >>family
index ccf86ca3087b5155c946eeb92d78e69dc54dff93..0f3ac39607e089ac63c99c92c12d14d7a9ae1529 100755 (executable)
@@ -1,6 +1,9 @@
+! Copyright (C) 2007, 2009 Slava Pestov, Doug Coleman.\r
+! See http://factorcode.org/license.txt for BSD license.\r
 USING: kernel accessors io.sockets io.sockets.private\r
 io.backend.windows io.backend windows.winsock system destructors\r
 alien.c-types classes.struct combinators ;\r
+FROM: namespaces => get ;\r
 IN: io.sockets.windows\r
 \r
 M: windows addrinfo-error ( n -- )\r
@@ -55,7 +58,11 @@ M: object (get-remote-address) ( socket addrspec -- sockaddr )
 \r
 M: object ((client)) ( addrspec -- handle )\r
     [ SOCK_STREAM open-socket ] keep\r
-    [ unspecific-sockaddr/size bind-socket ] [ drop ] 2bi ;\r
+    [\r
+        bind-local-address get\r
+        [ nip make-sockaddr/size ]\r
+        [ unspecific-sockaddr/size ] if* bind-socket\r
+    ] [ drop ] 2bi ;\r
 \r
 : server-socket ( addrspec type -- fd )\r
     [ open-socket ] [ drop ] 2bi\r
index 022d20eb5e9e1effb7b90aa4c20c68fb911b07ad..047cd117a02907da5c659f391a695d5bd8fcdea1 100644 (file)
@@ -1,8 +1,9 @@
 USING: accessors continuations destructors io io.encodings
-io.encodings.8-bit io.encodings.ascii io.encodings.binary
+io.encodings.ascii io.encodings.binary
 io.encodings.string io.encodings.utf8 io.files io.pipes
 io.streams.byte-array io.streams.limited io.streams.string
-kernel namespaces strings tools.test system ;
+kernel namespaces strings tools.test system
+io.encodings.8-bit.latin1 ;
 IN: io.streams.limited.tests
 
 [ ] [
index 403643ed73aadec4464e9b75ed13a104f1b5bd25..f5aab9c97619a5e66ea5cabed0e2735c190b36c7 100755 (executable)
@@ -123,7 +123,7 @@ M: limited-stream stream-read-partial
 <PRIVATE
 
 : (read-until) ( stream seps buf -- stream seps buf sep/f )
-    3dup [ [ stream-read1 dup ] dip memq? ] dip
+    3dup [ [ stream-read1 dup ] dip member-eq? ] dip
     swap [ drop ] [ push (read-until) ] if ;
 
 :: limited-stream-seek ( n seek-type stream -- )
index 529db6bf78917073d2116ab9615d531f5f2e5bf5..2b31e5c8a814022623ba57d4d37cb82641488a33 100755 (executable)
@@ -1,6 +1,6 @@
 USING: alien.syntax alien.c-types core-foundation
 core-foundation.bundles core-foundation.dictionaries system
-combinators kernel sequences io accessors ;
+combinators kernel sequences io accessors unix.types ;
 IN: iokit
 
 <<
@@ -99,19 +99,6 @@ CONSTANT: kOSBuildVersionKey   "OS Build Version"
 
 CONSTANT: kNilOptions 0
 
-TYPEDEF: uint mach_port_t
-TYPEDEF: int kern_return_t
-TYPEDEF: int boolean_t
-TYPEDEF: mach_port_t io_object_t
-TYPEDEF: io_object_t io_iterator_t
-TYPEDEF: io_object_t io_registry_entry_t
-TYPEDEF: io_object_t io_service_t
-TYPEDEF: char[128] io_name_t
-TYPEDEF: char[512] io_string_t
-TYPEDEF: kern_return_t IOReturn
-
-TYPEDEF: uint IOOptionBits
-
 CONSTANT: MACH_PORT_NULL 0
 CONSTANT: KERN_SUCCESS 0
 
index aabd4bbafcd6e84d55d4dbb7e008e197b30ecf0d..38920f5764669daffbb2d6f07602de6dca37b27f 100644 (file)
@@ -25,11 +25,11 @@ 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
-        old length [| i |\r
-            new length\r
-            [| j | i j matrix old new step loop-step ] each\r
-        ] each matrix ] ; inline\r
+    old length 1 + new length 1 + init call :> matrix\r
+    old length [| i |\r
+        new length\r
+        [| j | i j matrix old new step loop-step ] each\r
+    ] each matrix ; inline\r
 PRIVATE>\r
 \r
 : levenshtein ( old new -- n )\r
index c6a2d0c0508b8a9e5e300a5a0ac41e05940f8d1d..a054067755ca5b678b8585c54eb3d000f9f26abf 100644 (file)
@@ -48,10 +48,12 @@ $nl
 "Multi-line expressions are supported:"
 { $example "{ 1 2 3 } [\n    .\n] each" "1\n2\n3" }
 "The listener knows when to expect more input by looking at the height of the stack. Parsing words such as " { $link POSTPONE: { } " leave elements on the parser stack, and corresponding words such as " { $link POSTPONE: } } " pop them."
+$nl
+"The listener will display the current contents of the datastack after every expression is evaluated. The listener can additionally watch dynamic variables:"
 { $subsections "listener-watch" }
 "To start a nested listener:"
 { $subsections listener }
-"To exit the listener, invoke the " { $link return } " word."
+"To exit a listener, invoke the " { $link return } " word."
 $nl
 "Multi-line quotations can be read independently of the rest of the listener:"
 { $subsections read-quot } ;
index 57d1fd3964efd91f430e317339e06e10860bca50..a42eada5634f81e16d79395dcb2d05cae653b414 100644 (file)
@@ -163,8 +163,10 @@ SYMBOL: interactive-vocabs
     "syntax"
     "tools.annotations"
     "tools.crossref"
+    "tools.deprecation"
     "tools.destructors"
     "tools.disassembler"
+    "tools.dispatch"
     "tools.errors"
     "tools.memory"
     "tools.profiler"
index 8fb638b8566992c52016260beeec9aa137d8b153..39f92158a68bbff851097c1b6a8f6fe70e2248ed 100644 (file)
@@ -35,5 +35,7 @@ IN: lists.lazy.tests
 [ [ drop ] leach ] must-infer
 [ lnth ] must-infer
 
+[ { 1 2 3 } ] [ { 1 2 3 4 5 } >list [ 2 > ] luntil list>array ] unit-test
+
 [ ] [ "resource:license.txt" utf8 <file-reader> llines list>array drop ] unit-test
 [ ] [ "resource:license.txt" utf8 <file-reader> lcontents list>array drop ] unit-test
index 7b386e9c819ea1acfc93988b97227fcfb8666355..122a2205dd27664e73877879862cfde7c8daf908 100644 (file)
@@ -111,14 +111,15 @@ C: <lazy-until> lazy-until
     over nil? [ drop ] [ <lazy-until> ] if ;
 
 M: lazy-until car ( lazy-until -- car )
-     cons>> car ;
+    cons>> car ;
 
 M: lazy-until cdr ( lazy-until -- cdr )
-     [ cons>> unswons ] keep quot>> tuck call( elt -- ? )
-     [ 2drop nil ] [ luntil ] if ;
+    [ [ cons>> cdr ] [ quot>> ] bi ]
+    [ [ cons>> car ] [ quot>> ] bi call( elt -- ? ) ] bi
+    [ 2drop nil ] [ luntil ] if ;
 
 M: lazy-until nil? ( lazy-until -- ? )
-     drop f ;
+    drop f ;
 
 TUPLE: lazy-while cons quot ;
 
@@ -128,13 +129,13 @@ C: <lazy-while> lazy-while
     over nil? [ drop ] [ <lazy-while> ] if ;
 
 M: lazy-while car ( lazy-while -- car )
-     cons>> car ;
+    cons>> car ;
 
 M: lazy-while cdr ( lazy-while -- cdr )
-     [ cons>> cdr ] keep quot>> lwhile ;
+    [ cons>> cdr ] keep quot>> lwhile ;
 
 M: lazy-while nil? ( lazy-while -- ? )
-     [ car ] keep quot>> call( elt -- ? ) not ;
+    [ car ] keep quot>> call( elt -- ? ) not ;
 
 TUPLE: lazy-filter cons quot ;
 
index f70b6ff4a1b8d391182170a34fd12f6623fe3efd..53fde946872390a1e3b7365477e89994247220f6 100644 (file)
@@ -44,7 +44,6 @@ ARTICLE: { "lists" "combinators" } "Combinators for lists"
     foldl
     foldr
     lmap>array
-    traverse
 } ;
 
 ARTICLE: { "lists" "manipulation" } "Manipulating lists"
@@ -122,7 +121,7 @@ HELP: uncons
 { $description "Put the head and tail of the list on the stack." } ;
 
 HELP: unswons
-{ $values { "cons" list } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
+{ $values { "cons" list } { "cdr" "the tail of the list" } { "car" "the head of the list" } }
 { $description "Put the head and tail of the list on the stack." } ;
 
 { leach foldl lmap>array } related-words
@@ -151,12 +150,6 @@ HELP: list>array
 { $values { "list" list } { "array" array } }
 { $description "Convert a list into an array." } ;
 
-HELP: traverse    
-{ $values { "list"  list } { "pred" { $quotation "( list/elt -- ? )" } }
-          { "quot" { $quotation "( list/elt -- result)" } }  { "result" "a new cons object" } }
-{ $description "Recursively traverses the list object, replacing any elements (which can themselves be sublists) that pred" 
- " returns true for with the result of applying quot to." } ;
-
 HELP: list
 { $class-description "The class of lists. All lists are expected to conform to " { $link { "lists" "protocol" } } "." } ;
 
index ddf1ab91098e2e7abab454a4424775fbc4af404b..f3475f960b54077a42142167f7d01a0991e256d5 100644 (file)
@@ -93,11 +93,5 @@ PRIVATE>
 : list>array ( list -- array )  
     [ ] lmap>array ;
 
-:: traverse ( list pred quot: ( list/elt -- result ) -- result )
-    list [| elt |
-        elt dup pred call [ quot call ] when
-        dup list? [ pred quot traverse ] when
-    ] lmap ; inline recursive
-
 INSTANCE: cons list
 INSTANCE: +nil+ list
index e7b4c5a88439954b03b0b9350a9825f4e41bb564..468671361f8fe34f63674e6ab30e94e38159ae74 100644 (file)
@@ -9,10 +9,10 @@ M: >r/r>-in-lambda-error summary
     drop
     "Explicit retain stack manipulation is not permitted in lambda bodies" ;
 
-ERROR: binding-form-in-literal-error ;
+ERROR: let-form-in-literal-error ;
 
-M: binding-form-in-literal-error summary
-    drop "[let, [let* and [wlet not permitted inside literals" ;
+M: let-form-in-literal-error summary
+    drop "[let not permitted inside literals" ;
 
 ERROR: local-writer-in-literal-error ;
 
@@ -27,7 +27,7 @@ M: local-word-in-literal-error summary
 ERROR: :>-outside-lambda-error ;
 
 M: :>-outside-lambda-error summary
-    drop ":> cannot be used outside of lambda expressions" ;
+    drop ":> cannot be used outside of [let, [|, or :: forms" ;
 
 ERROR: bad-local args obj ;
 
index 9dc924334c742a833f8948bc9049542b3018a760..a2a1a6c17820ea684203978cdba1e4544b9694fc 100644 (file)
@@ -1,18 +1,21 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors fry fry.private generalizations kernel
-locals.types make sequences ;
+locals.types sequences ;
 IN: locals.fry
 
 ! Support for mixing locals with fry
 
-M: binding-form count-inputs body>> count-inputs ;
-
+M: let count-inputs body>> count-inputs ;
 M: lambda count-inputs body>> count-inputs ;
 
-M: lambda deep-fry
-    clone [ shallow-fry swap ] change-body
-    [ [ vars>> length ] keep '[ _ _ mnswap @ ] , ] [ drop [ncurry] % ] 2bi ;
+M: lambda fry
+    clone [ [ count-inputs ] [ fry ] bi ] change-body
+    [ [ vars>> length ] keep '[ _ _ mnswap _ call ] ]
+    [ drop [ncurry] curry [ call ] compose ] 2bi ;
+
+M: let fry
+    clone [ fry ] change-body ;
 
-M: binding-form deep-fry
-    clone [ fry '[ @ call ] ] change-body , ;
+INSTANCE: lambda fried
+INSTANCE: let    fried
index c9c5e7330eabfdb2f285f7f8974b5a641882c041..f44b5177e14172cb164b4899b5e7daf299d33c6a 100644 (file)
@@ -4,125 +4,166 @@ IN: locals
 
 HELP: [|
 { $syntax "[| bindings... | body... ]" }
-{ $description "A lambda abstraction. When called, reads stack values into the bindings from left to right; the body may then refer to these bindings." }
-{ $examples
-    { $example
-        "USING: kernel locals math prettyprint ;"
-        "IN: scratchpad"
-        ":: adder ( n -- quot ) [| m | m n + ] ;"
-        "3 5 adder call ."
-        "8"
-    }
-} ;
+{ $description "A literal quotation with named variable bindings. When the quotation is " { $link call } "ed, it will take values off the datastack values and place them into the bindings from left to right. The body may then refer to these bindings. The quotation may also bind to named variables in an enclosing scope to create a closure." }
+{ $examples "See " { $link "locals-examples" } "." } ;
 
 HELP: [let
-{ $syntax "[let | binding1 [ value1... ]\n       binding2 [ value2... ]\n       ... |\n    body... ]" }
-{ $description "Introduces a set of lexical bindings and evaluates the body. The values are evaluated in parallel, and may not refer to other bindings within the same " { $link POSTPONE: [let } " form; for Lisp programmers, this means that " { $link POSTPONE: [let } " is equivalent to the Lisp " { $snippet "let" } ", not " { $snippet "let*" } "." }
-{ $examples
-    { $example
-        "USING: kernel locals math math.functions prettyprint sequences ;"
-        "IN: scratchpad"
-        ":: frobnicate ( n seq -- newseq )"
-        "    [let | n' [ n 6 * ] |"
-        "        seq [ n' gcd nip ] map ] ;"
-        "6 { 36 14 } frobnicate ."
-        "{ 36 2 }"
-    }
-} ;
-
-HELP: [let*
-{ $syntax "[let* | binding1 [ value1... ]\n        binding2 [ value2... ]\n        ... |\n    body... ]" }
-{ $description "Introduces a set of lexical bindings and evaluates the body. The values are evaluated sequentially, and may refer to previous bindings from the same " { $link POSTPONE: [let* } " form; for Lisp programmers, this means that " { $link POSTPONE: [let* } " is equivalent to the Lisp " { $snippet "let*" } ", not " { $snippet "let" } "." }
-{ $examples
-    { $example
-        "USING: kernel locals math math.functions prettyprint sequences ;"
-        "IN: scratchpad"
-        ":: frobnicate ( n seq -- newseq )"
-        "    [let* | a [ n 3 + ]"
-        "            b [ a 4 * ] |"
-        "        seq [ b / ] map ] ;"
-        "1 { 32 48 } frobnicate ."
-        "{ 2 3 }"
-    }
-} ;
-
-{ POSTPONE: [let POSTPONE: [let* } related-words
-
-HELP: [wlet
-{ $syntax "[wlet | binding1 [ body1... ]\n        binding2 [ body2... ]\n        ... |\n     body... ]" }
-{ $description "Introduces a set of lexically-scoped non-recursive local functions. The bodies may not refer to other bindings within the same " { $link POSTPONE: [wlet } " form; for Lisp programmers, this means that Factor's " { $link POSTPONE: [wlet } " is equivalent to the Lisp " { $snippet "flet" } ", not " { $snippet "labels" } "." }
-{ $examples
-    { $example
-        "USING: locals math prettyprint sequences ;"
-        "IN: scratchpad"
-        ":: quuxify ( n seq -- newseq )"
-        "    [wlet | add-n [| m | m n + ] |"
-        "        seq [ add-n ] map ] ;"
-        "2 { 1 2 3 } quuxify ."
-        "{ 3 4 5 }"
-    }
-} ;
+{ $syntax "[let code :> var code :> var code... ]" }
+{ $description "Establishes a new scope for lexical variable bindings. Variables bound with " { $link POSTPONE: :> } " within the body of the " { $snippet "[let" } " will be lexically scoped to the body of the " { $snippet "[let" } " form." }
+{ $examples "See " { $link "locals-examples" } "." } ;
 
 HELP: :>
-{ $syntax ":> binding" }
-{ $description "Introduces a new binding, lexically scoped to the enclosing quotation or definition." }
+{ $syntax ":> var" ":> var!" ":> ( var-1 var-2 ... )" }
+{ $description "Binds one or more new lexical variables. In the " { $snippet ":> var" } " form, the value on the top of the datastack to a new lexical variable named " { $snippet "var" } " and scoped to the enclosing quotation, " { $link POSTPONE: [let } " form, or " { $link POSTPONE: :: } " definition."
+$nl
+"The " { $snippet ":> ( var-1 ... )" } " form binds multiple variables to the top values off the datastack in left to right order. These two snippets have the same effect:"
+{ $code ":> c :> b :> a" }
+{ $code ":> ( a b c )" }
+$nl
+"If any " { $snippet "var" } " name is followed by an exclamation point (" { $snippet "!" } "), that new variable is mutable. See " { $link "locals-mutable" } " for more information on mutable lexical variables." }
 { $notes
-    "This word can only be used inside a lambda word, lambda quotation or let binding form."
-    $nl
-    "Lambda and let forms are really just syntax sugar for " { $link POSTPONE: :> } "."
-    $nl
-    "Lambdas desugar as follows:"
-    { $code
-        "[| a b | a b + b / ]"
-        "[ :> b :> a a b + b / ]"
-    }
-    "Let forms desugar as follows:"
-    { $code
-        "[|let | x [ 10 random ] | { x x } ]"
-        "10 random :> x { x x }"
-    }
-}
-{ $examples
-    { $code
-        "USING: locals math kernel ;"
-        "IN: scratchpad"
-        ":: quadratic ( a b c -- x y )"
-        "    b sq 4 a c * * - sqrt :> disc"
-        "    b neg disc [ + ] [ - ] 2bi [ 2 a * / ] bi@ ;"
-    }
-} ;
+    "This syntax can only be used inside a lexical scope established by a " { $link POSTPONE: :: } " definition, " { $link POSTPONE: [let } " form, or " { $link POSTPONE: [| } " quotation. Normal quotations have their own lexical scope only if they are inside an outer scope. Definition forms such as " { $link POSTPONE: : } " do not establish a lexical scope by themselves unless documented otherwise, nor is there a lexical scope available at the top level of source files or in the listener. " { $link POSTPONE: [let } " can be used to create a lexical scope where one is not otherwise available." }
+{ $examples "See " { $link "locals-examples" } "." } ;
+
+{ POSTPONE: [let POSTPONE: :> } related-words
 
 HELP: ::
-{ $syntax ":: word ( bindings... -- outputs... ) body... ;" }
-{ $description "Defines a word with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope." }
-{ $notes "The output names do not affect the word's behavior, however the compiler attempts to check the stack effect as with other definitions." }
-{ $examples "See " { $link POSTPONE: [| } ", " { $link POSTPONE: [let } " and " { $link POSTPONE: [wlet } "." } ;
+{ $syntax ":: word ( vars... -- outputs... ) body... ;" }
+{ $description "Defines a word with named inputs. The word binds its input values to lexical variables from left to right, then executes the body with those bindings in scope."
+$nl
+"If any " { $snippet "var" } " name is followed by an exclamation point (" { $snippet "!" } "), the corresponding new variable is made mutable. See " { $link "locals-mutable" } " for more information on mutable lexical variables." }
+{ $notes "The names of the " { $snippet "outputs" } " do not affect the word's behavior. However, the compiler verifies that the stack effect accurately represents the number of outputs as with " { $link POSTPONE: : } " definitions." }
+{ $examples "See " { $link "locals-examples" } "." } ;
 
 { POSTPONE: : POSTPONE: :: } related-words
 
 HELP: MACRO::
-{ $syntax "MACRO:: word ( bindings... -- outputs... ) body... ;" }
-{ $description "Defines a macro with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope." }
-{ $notes "The output names do not affect the word's behavior, however the compiler attempts to check the stack effect as with other definitions." } ;
+{ $syntax "MACRO:: word ( vars... -- outputs... ) body... ;" }
+{ $description "Defines a macro with named inputs. The macro binds its input variables to lexical variables from left to right, then executes the body with those bindings in scope."
+$nl
+"If any " { $snippet "var" } " name is followed by an exclamation point (" { $snippet "!" } "), the corresponding new variable is made mutable. See " { $link "locals-mutable" } " for more information on mutable lexical variables." }
+{ $notes "The expansion of a macro cannot reference lexical variables bound in the outer scope. There are also limitations on passing arguments involving lexical variables into macros. See " { $link "locals-limitations" } " for details." }
+{ $examples "See " { $link "locals-examples" } "." } ;
 
 { POSTPONE: MACRO: POSTPONE: MACRO:: } related-words
 
 HELP: MEMO::
-{ $syntax "MEMO:: word ( bindings... -- outputs... ) body... ;" }
-{ $description "Defines a memoized word with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope." } ;
+{ $syntax "MEMO:: word ( vars... -- outputs... ) body... ;" }
+{ $description "Defines a memoized word with named inputs. The word binds its input values to lexical variables from left to right, then executes the body with those bindings in scope."
+$nl
+"If any " { $snippet "var" } " name is followed by an exclamation point (" { $snippet "!" } "), the corresponding new variable is made mutable. See " { $link "locals-mutable" } " for more information on mutable lexical variables." }
+{ $examples "See " { $link "locals-examples" } "." } ;
 
 { POSTPONE: MEMO: POSTPONE: MEMO:: } related-words
                                           
 HELP: M::
-{ $syntax "M:: class generic ( bindings... -- outputs... ) body... ;" }
-{ $description "Defines a method with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope." }
-{ $notes "The output names do not affect the word's behavior, however the compiler attempts to check the stack effect as with other definitions." } ;
+{ $syntax "M:: class generic ( vars... -- outputs... ) body... ;" }
+{ $description "Defines a new method on " { $snippet "generic" } " for " { $snippet "class" } " with named inputs. The method binds its input values to lexical variables from left to right, then executes the body with those bindings in scope."
+$nl
+"If any " { $snippet "var" } " name is followed by an exclamation point (" { $snippet "!" } "), the corresponding new variable is made mutable. See " { $link "locals-mutable" } " for more information on mutable lexical variables." }
+{ $notes "The names of the " { $snippet "outputs" } " do not affect the word's behavior. However, the compiler verifies that the stack effect accurately represents the number of outputs as with " { $link POSTPONE: M: } " definitions." }
+{ $examples "See " { $link "locals-examples" } "." } ;
 
 { POSTPONE: M: POSTPONE: M:: } related-words
 
+ARTICLE: "locals-examples" "Examples of lexical variables"
+{ $heading "Definitions with lexical variables" }
+"The following example demonstrates lexical variable bindings in word definitions. The " { $snippet "quadratic-roots" } " word is defined with " { $link POSTPONE: :: } ", so it takes its inputs from the top three elements of the datastack and binds them to the variables " { $snippet "a" } ", " { $snippet "b" } ", and " { $snippet "c" } ". In the body, the " { $snippet "disc" } " variable is bound using " { $link POSTPONE: :> } " and then used in the following line of code."
+{ $example """USING: locals math math.functions kernel ;
+IN: scratchpad
+:: quadratic-roots ( a b c -- x y )
+    b sq 4 a c * * - sqrt :> disc
+    b neg disc [ + ] [ - ] 2bi [ 2 a * / ] bi@ ;
+1.0 1.0 -6.0 quadratic-roots [ . ] bi@"""
+"""2.0
+-3.0"""
+}
+"If you wanted to perform the quadratic formula interactively from the listener, you could use " { $link POSTPONE: [let } " to provide a scope for the variables:"
+{ $example """USING: locals math math.functions kernel ;
+IN: scratchpad
+[let 1.0 :> a 1.0 :> b -6.0 :> c
+    b sq 4 a c * * - sqrt :> disc
+    b neg disc [ + ] [ - ] 2bi [ 2 a * / ] bi@
+] [ . ] bi@"""
+"""2.0
+-3.0"""
+}
+
+$nl
+
+{ $heading "Quotations with lexical variables, and closures" }
+"These next two examples demonstrate lexical variable bindings in quotations defined with " { $link POSTPONE: [| } ". In this example, the values " { $snippet "5" } " and " { $snippet "3" } " are put on the datastack. When the quotation is called, it takes those values as inputs and binds them respectively to " { $snippet "m" } " and " { $snippet "n" } " before executing the quotation:"
+{ $example
+    "USING: kernel locals math prettyprint ;"
+    "IN: scratchpad"
+    "5 3 [| m n | m n - ] call ."
+    "2"
+}
+$nl
+
+"In this example, the " { $snippet "adder" } " word creates a quotation that closes over its argument " { $snippet "n" } ". When called, the result quotation of " { $snippet "5 adder" } " pulls " { $snippet "3" } " off the datastack and binds it to " { $snippet "m" } ", which is added to the value " { $snippet "5" } " bound to " { $snippet "n" } " in the outer scope of " { $snippet "adder" } ":"
+{ $example
+    "USING: kernel locals math prettyprint ;"
+    "IN: scratchpad"
+    ":: adder ( n -- quot ) [| m | m n + ] ;"
+    "3 5 adder call ."
+    "8"
+}
+$nl
+
+{ $heading "Mutable bindings" }
+"This next example demonstrates closures and mutable variable bindings. The " { $snippet "make-counter" } " word outputs a tuple containing a pair of quotations that respectively increment and decrement an internal counter in the mutable " { $snippet "value" } " variable and then return the new value. The quotations close over the counter, so each invocation of the word gives new quotations with a new internal counter."
+{ $example
+"""USING: locals kernel math ;
+IN: scratchpad
+
+TUPLE: counter adder subtractor ;
+
+:: <counter> ( -- counter )
+    0 :> value!
+    counter new
+    [ value 1 + dup value! ] >>adder
+    [ value 1 - dup value! ] >>subtractor ;
+<counter>
+[ adder>>      call . ]
+[ adder>>      call . ]
+[ subtractor>> call . ] tri """
+"""1
+2
+1"""
+}
+    $nl
+    "The same variable name can be bound multiple times in the same scope. This is different from reassigning the value of a mutable variable. The most recent binding for a variable name will mask previous bindings for that name. However, the old binding referring to the previous value can still persist in closures. The following contrived example demonstrates this:"
+    { $example
+"""USING: kernel locals prettyprint ;
+IN: scratchpad
+:: rebinding-example ( -- quot1 quot2 )
+    5 :> a [ a ]
+    6 :> a [ a ] ;
+:: mutable-example ( -- quot1 quot2 )
+    5 :> a! [ a ]
+    6 a! [ a ] ;
+rebinding-example [ call . ] bi@
+mutable-example [ call . ] bi@"""
+"""5
+6
+6
+6"""
+} 
+    "In " { $snippet "rebinding-example" } ", the binding of " { $snippet "a" } " to " { $snippet "5" } " is closed over in the first quotation, and the binding of " { $snippet "a" } " to " { $snippet "6" } " is closed over in the second, so calling both quotations results in " { $snippet "5" } " and " { $snippet "6" } " respectively. By contrast, in " { $snippet "mutable-example" } ", both quotations close over a single binding of " { $snippet "a" } ". Even though " { $snippet "a" } " is assigned to " { $snippet "6" } " after the first quotation is made, calling either quotation will output the new value of " { $snippet "a" } "."
+{ $heading "Lexical variables in literals" }
+"Some kinds of literals can include references to lexical variables as described in " { $link "locals-literals" } ". For example, the " { $link 3array } " word could be implemented as follows:"
+{ $example
+"""USING: locals prettyprint ;
+IN: scratchpad
+
+:: my-3array ( x y z -- array ) { x y z } ;
+1 "two" 3.0 my-3array ."""
+"""{ 1 "two" 3.0 }"""
+} ;
                                                  
-ARTICLE: "locals-literals" "Locals in literals"
-"Certain data type literals are permitted to contain free variables. Any such literals are written into code which constructs an instance of the type with the free variable values spliced in. Conceptually, this is similar to the transformation applied to quotations containing free variables."
+ARTICLE: "locals-literals" "Lexical variables in literals"
+"Certain data type literals are permitted to contain lexical variables. Any such literals are rewritten into code which constructs an instance of the type with the values of the variables spliced in. Conceptually, this is similar to the transformation applied to quotations containing free variables."
 $nl
 "The data types which receive this special handling are the following:"
 { $list
@@ -142,7 +183,7 @@ $nl
     "ordinary-word-test ordinary-word-test eq? ."
     "t"
 }
-"In a word with locals, literals which do not contain locals still behave in the same way:"
+"Inside a lexical scope, literals which do not contain lexical variables still behave in the same way:"
 { $example
     "USE: locals"
     "IN: scratchpad"
@@ -152,7 +193,7 @@ $nl
     "locals-word-test locals-word-test eq? ."
     "t"
 }
-"However, literals with locals in them actually expand into code for constructing a new object:"
+"However, literals with lexical variables in them actually construct a new object:"
 { $example
     "USING: locals splitting ;"
     "IN: scratchpad"
@@ -163,29 +204,19 @@ $nl
     "constructor-test constructor-test eq? ."
     "f"
 }
-"One exception to the above rule is that array instances containing no free variables do retain identity. This allows macros such as " { $link cond } " to recognize that the array is constant and expand at compile-time."
-{ $heading "Example" }
-"Here is an implementation of the " { $link 3array } " word which uses this feature:"
-{ $code ":: 3array ( x y z -- array ) { x y z } ;" } ;
+"One exception to the above rule is that array instances containing free lexical variables (that is, immutable lexical variables not referenced in a closure) do retain identity. This allows macros such as " { $link cond } " to expand at compile time even when their arguments reference variables." ;
 
-ARTICLE: "locals-mutable" "Mutable locals"
-"In the list of bindings supplied to " { $link POSTPONE: :: } ", " { $link POSTPONE: [let } ", " { $link POSTPONE: [let* } " or " { $link POSTPONE: [| } ", a mutable binding may be introduced by suffixing its named with " { $snippet "!" } ". Mutable bindings are read by giving their name as usual; the suffix is not part of the binding's name. To write to a mutable binding, use the binding's name with the " { $snippet "!" } " suffix."
+ARTICLE: "locals-mutable" "Mutable lexical variables"
+"When a lexical variable is bound using " { $link POSTPONE: :> } ", " { $link POSTPONE: :: } ", or " { $link POSTPONE: [| } ", the variable may be made mutable by suffixing its name with an exclamation point (" { $snippet "!" } "). A mutable variable's value is read by giving its name without the exclamation point as usual. To write to the variable, use its name with the " { $snippet "!" } " suffix."
 $nl
-"Here is a example word which outputs a pair of quotations which increment and decrement an internal counter, and then return the new value. The quotations are closed over the counter and each invocation of the word yields new quotations with their unique internal counter:"
-{ $code
-    ":: counter ( -- )"
-    "    [let | value! [ 0 ] |"
-    "        [ 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."
+"Mutable bindings are implemented in a manner similar to the ML language; each mutable binding is actually an immutable binding of a mutable cell. Reading the binding automatically unboxes the value from the cell, and writing to the binding stores into it."
 $nl
-"Unlike some languages such as Python and Java, writing to mutable locals in outer scopes is fully supported and has the expected semantics." ;
+"Writing to mutable variables from outer lexical scopes is fully supported and has full closure semantics. See " { $link "locals-examples" } " for examples of mutable lexical variables in action." ;
 
-ARTICLE: "locals-fry" "Locals and fry"
-"Locals integrate with " { $link "fry" } " so that mixing locals with fried quotations gives intuitive results."
+ARTICLE: "locals-fry" "Lexical variables and fry"
+"Lexical variables integrate with " { $link "fry" } " so that mixing variables with fried quotations gives intuitive results."
 $nl
-"Recall that the following two code snippets are equivalent:"
+"The following two code snippets are equivalent:"
 { $code "'[ sq _ + ]" }
 { $code "[ [ sq ] dip + ] curry" }
 "The semantics of " { $link dip } " and " { $link curry } " are such that the first example behaves as if the top of the stack as “inserted” in the “hole” in the quotation's second element."
@@ -193,29 +224,28 @@ $nl
 "Conceptually, " { $link curry } " is defined so that the following two code snippets are equivalent:"
 { $code "3 [ - ] curry" }
 { $code "[ 3 - ]" }
-"With lambdas, " { $link curry } " behaves differently. Rather than prepending an element, it fills in named parameters from right to left. The following two snippets are equivalent:"
+"When quotations take named parameters using " { $link POSTPONE: [| } ", " { $link curry } " fills in the variable bindings from right to left. The following two snippets are equivalent:"
 { $code "3 [| a b | a b - ] curry" }
 { $code "[| a | a 3 - ]" }
-"Because of this, the behavior of fry changes when applied to a lambda, to ensure that conceptually, fry behaves as with quotations. So the following snippets are no longer equivalent:"
+"Because of this, the behavior of " { $snippet "fry" } " changes when applied to such a quotation to ensure that fry conceptually behaves the same as with normal quotations, placing the fried values “underneath” the variable bindings. Thus, the following snippets are no longer equivalent:"
 { $code "'[ [| a | _ a - ] ]" }
 { $code "'[ [| a | a - ] curry ] call" }
 "Instead, the first line above expands into something like the following:"
 { $code "[ [ swap [| a | a - ] ] curry call ]" }
-"This ensures that the fried value appears “underneath” the local variable " { $snippet "a" } " when the quotation calls."
 $nl
-"The precise behavior is the following. When frying a lambda, a stack shuffle (" { $link mnswap } ") is prepended to the lambda so that the " { $snippet "m" } " curried values, which start off at the top of the stack, are transposed with the " { $snippet "n" } " inputs to the lambda." ;
+"The precise behavior is as follows. When frying a " { $link POSTPONE: [| } " quotation, a stack shuffle (" { $link mnswap } ") is prepended so that the " { $snippet "m" } " curried values, which start off at the top of the stack, are transposed with the quotation's " { $snippet "n" } " named input bindings." ;
 
-ARTICLE: "locals-limitations" "Limitations of locals"
-"There are two main limitations of the current locals implementation, and both concern macros."
+ARTICLE: "locals-limitations" "Limitations of lexical variables"
+"There are two main limitations of the current implementation, and both concern macros."
 { $heading "Macro expansions with free variables" }
-"The expansion of a macro cannot reference local variables bound in the outer scope. For example, the following macro is invalid:"
+"The expansion of a macro cannot reference lexical variables bound in the outer scope. For example, the following macro is invalid:"
 { $code "MACRO:: twice ( quot -- ) [ quot call quot call ] ;" }
 "The following is fine, though:"
 { $code "MACRO:: twice ( quot -- ) quot quot '[ @ @ ] ;" }
 { $heading "Static stack effect inference and macros" }
-"Recall that a macro will only expand at compile-time, and the word containing it will only get a static stack effect, if all inputs to the macro are literal. When locals are used, there is an additional restriction; the literals must immediately precede the macro call, lexically."
+"A macro will only expand at compile-time if all of its inputs are literal. Likewise, the word containing the macro will only have a static stack effect and compile successfully if the macro's inputs are literal. When lexical variables are used in a macro's literal arguments, there is an additional restriction: The literals must immediately precede the macro call lexically."
 $nl
-"For example, all of the following three examples are equivalent semantically, but only the first will have a static stack effect and compile with the optimizing compiler:"
+"For example, all of the following three code snippets are superficially equivalent, but only the first will compile:"
 { $code
     ":: good-cond-usage ( a -- ... )"
     "    {"
@@ -224,7 +254,7 @@ $nl
     "        { [ a 0 = ] [ ... ] }"
     "    } cond ;"
 }
-"The following two will not, and will run slower as a result:"
+"The next two snippets will not compile because the argument to " { $link cond } " does not immediately precede the call:"
 { $code
     ": my-cond ( alist -- ) cond ; inline"
     ""
@@ -243,30 +273,27 @@ $nl
     "        { [ a 0 = ] [ ... ] }"
     "    } swap swap cond ;"
 }
-"The reason is that locals are rewritten into stack code at parse time, whereas macro expansion is performed later during compile time. To circumvent this problem, the " { $vocab-link "macros.expander" } " vocabulary is used to rewrite simple macro usages prior to local transformation, however "{ $vocab-link "macros.expander" } " does not deal with more complicated cases where the literal inputs to the macro do not immediately precede the macro call in the source." ;
+"The reason is that lexical variable references are rewritten into stack code at parse time, whereas macro expansion is performed later during compile time. To circumvent this problem, the " { $vocab-link "macros.expander" } " vocabulary is used to rewrite simple macro usages prior to lexical variable transformation. However, " { $vocab-link "macros.expander" } " cannot deal with more complicated cases where the literal inputs to the macro do not immediately precede the macro call in the source." ;
 
-ARTICLE: "locals" "Lexical variables and closures"
-"The " { $vocab-link "locals" } " vocabulary implements lexical scope with full closures, both downward and upward. Mutable bindings are supported, including assignment to bindings in outer scope."
-$nl
-"Compile-time transformation is used to compile local variables to efficient code; prettyprinter extensions are defined so that " { $link see } " can display original word definitions with local variables and not the closure-converted concatenative code which results."
-$nl
-"Applicative word definitions where the inputs are named local variables:"
+ARTICLE: "locals" "Lexical variables"
+"The " { $vocab-link "locals" } " vocabulary provides lexically scoped local variables. Full closure semantics, both downward and upward, are supported. Mutable variable bindings are also provided, supporting assignment to bindings in the current scope or in outer scopes."
+{ $subsections
+    "locals-examples"
+}
+"Word definitions where the inputs are bound to lexical variables:"
 { $subsections
     POSTPONE: ::
     POSTPONE: M::
     POSTPONE: MEMO::
     POSTPONE: MACRO::
 }
-"Lexical binding forms:"
+"Lexical scoping and binding forms:"
 { $subsections
     POSTPONE: [let
-    POSTPONE: [let*
-    POSTPONE: [wlet
+    POSTPONE: :>
 }
-"Lambda abstractions:"
+"Quotation literals where the inputs are bound to lexical variables:"
 { $subsections POSTPONE: [| }
-"Lightweight binding form:"
-{ $subsections POSTPONE: :> }
 "Additional topics:"
 { $subsections
     "locals-literals"
@@ -274,6 +301,6 @@ $nl
     "locals-fry"
     "locals-limitations"
 }
-"Locals complement dynamically scoped variables implemented in the " { $vocab-link "namespaces" } " vocabulary." ;
+"Lexical variables complement " { $link "namespaces" } "." ;
 
 ABOUT: "locals"
index 63b6d68feb3a4131eb5ed4415711ad754c67c48a..7aa8032cddeefbdaf7d0e5d2abd5716a79758d73 100644 (file)
@@ -26,58 +26,35 @@ IN: locals.tests
 [ { 5 6 7 } ] [ { 1 2 3 } 4 map-test-2 ] unit-test
 
 :: let-test ( c -- d )
-    [let | a [ 1 ] b [ 2 ] | a b + c + ] ;
+    [let 1 :> a 2 :> b a b + c + ] ;
 
 [ 7 ] [ 4 let-test ] unit-test
 
 :: let-test-2 ( a -- a )
-    a [let | a [ ] | [let | b [ a ] | a ] ] ;
+    a [let :> a [let a :> b a ] ] ;
 
 [ 3 ] [ 3 let-test-2 ] unit-test
 
 :: let-test-3 ( a -- a )
-    a [let | a [ ] | [let | b [ [ a ] ] | [let | a [ 3 ] | b ] ] ] ;
+    a [let :> a [let [ a ] :> b [let 3 :> a b ] ] ] ;
 
 :: let-test-4 ( a -- b )
-    a [let | a [ 1 ] b [ ] | a b 2array ] ;
+    a [let 1 :> a :> b a b 2array ] ;
 
 [ { 1 2 } ] [ 2 let-test-4 ] unit-test
 
 :: let-test-5 ( a b -- b )
-    a b [let | a [ ] b [ ] | a b 2array ] ;
+    a b [let :> a :> b a b 2array ] ;
 
 [ { 2 1 } ] [ 1 2 let-test-5 ] unit-test
 
 :: let-test-6 ( a -- b )
-    a [let | a [ ] b [ 1 ] | a b 2array ] ;
+    a [let :> a 1 :> b a b 2array ] ;
 
 [ { 2 1 } ] [ 2 let-test-6 ] unit-test
 
 [ -1 ] [ -1 let-test-3 call ] unit-test
 
-[ 5 ] [
-    [let | a [ 3 ] | [wlet | func [ a + ] | 2 func ] ]
-] unit-test
-
-:: wlet-test-2 ( a b -- seq )
-    [wlet | add-b [ b + ] |
-        a [ add-b ] map ] ;
-
-
-[ { 4 5 6 } ] [ { 2 3 4 } 2 wlet-test-2 ] unit-test
-    
-:: wlet-test-3 ( a -- b )
-    [wlet | add-a [ a + ] | [ add-a ] ]
-    [let | a [ 3 ] | a swap call ] ;
-
-[ 5 ] [ 2 wlet-test-3 ] unit-test
-
-:: wlet-test-4 ( a -- b )
-    [wlet | sub-a [| b | b a - ] |
-        3 sub-a ] ;
-
-[ -7 ] [ 10 wlet-test-4 ] unit-test
-
 :: write-test-1 ( n! -- q )
     [| i | n i + dup n! ] ;
 
@@ -94,8 +71,7 @@ IN: locals.tests
 [ 5 ] [ 2 "q" get call ] unit-test
 
 :: write-test-2 ( -- q )
-    [let | n! [ 0 ] |
-        [| i | n i + dup n! ] ] ;
+    [let 0 :> n! [| i | n i + dup n! ] ] ;
 
 write-test-2 "q" set
 
@@ -116,17 +92,11 @@ write-test-2 "q" set
 
 [ ] [ 1 2 write-test-3 call ] unit-test
 
-:: write-test-4 ( x! -- q ) [ [let | y! [ 0 ] | f x! ] ] ;
+:: write-test-4 ( x! -- q ) [ [let 0 :> y! f x! ] ] ;
 
 [ ] [ 5 write-test-4 drop ] unit-test
 
-! Not really a write test; just enforcing consistency
-:: write-test-5 ( x -- y )
-    [wlet | fun! [ x + ] | 5 fun! ] ;
-
-[ 9 ] [ 4 write-test-5 ] unit-test
-
-:: let-let-test ( n -- n ) [let | n [ n 3 + ] | n ] ;
+:: let-let-test ( n -- n ) [let n 3 + :> n n ] ;
 
 [ 13 ] [ 10 let-let-test ] unit-test
 
@@ -164,18 +134,12 @@ M:: string lambda-generic ( a b -- c ) a b lambda-generic-2 ;
 
 [ ] [ \ lambda-generic see ] unit-test
 
-:: unparse-test-1 ( a -- ) [let | a! [ 3 ] | ] ;
+:: unparse-test-1 ( a -- ) [let 3 :> a! 4 :> b ] ;
 
-[ "[let | a! [ 3 ] | ]" ] [
+[ "[let 3 :> a! 4 :> b ]" ] [
     \ unparse-test-1 "lambda" word-prop body>> first unparse
 ] unit-test
 
-:: unparse-test-2 ( -- ) [wlet | a! [ ] | ] ;
-
-[ "[wlet | a! [ ] | ]" ] [
-    \ unparse-test-2 "lambda" word-prop body>> first unparse
-] unit-test
-
 :: unparse-test-3 ( -- b ) [| a! | ] ;
 
 [ "[| a! | ]" ] [
@@ -198,38 +162,6 @@ DEFER: xyzzy
 
 [ 5 ] [ 10 xyzzy ] unit-test
 
-:: let*-test-1 ( a -- b )
-    [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 + ] |
-        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 ] ;
-
-[ { 1 2 4 } ] [ 1 let*-test-3 ] unit-test
-
-:: let*-test-4 ( a b -- c d )
-    [let | a [ b ]
-           b [ a ] |
-        [let* | a'  [ a  ]
-                a'' [ a' ]
-                b'  [ b  ]
-                b'' [ b' ] |
-            a'' b'' ] ] ;
-
-[ "xxx" "yyy" ] [ "yyy" "xxx" let*-test-4 ] unit-test
-
 GENERIC: next-method-test ( a -- b )
 
 M: integer next-method-test 3 + ;
@@ -244,11 +176,11 @@ M:: fixnum next-method-test ( a -- b ) a call-next-method 1 + ;
 
 { 3 0 } [| a b c | ] must-infer-as
 
-[ ] [ 1 [let | a [ ] | ] ] unit-test
+[ ] [ 1 [let :> a ] ] unit-test
 
-[ 3 ] [ 1 [let | a [ ] | 3 ] ] unit-test
+[ 3 ] [ 1 [let :> a 3 ] ] unit-test
 
-[ ] [ 1 2 [let | a [ ] b [ ] | ] ] unit-test
+[ ] [ 1 2 [let :> a :> b ] ] unit-test
 
 :: a-word-with-locals ( a b -- ) ;
 
@@ -306,10 +238,10 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
 [ t ] [ 12 &&-test ] unit-test
 
 :: let-and-cond-test-1 ( -- a )
-    [let | a [ 10 ] |
-        [let | a [ 20 ] |
+    [let 10 :> a
+        [let 20 :> a
             {
-                { [ t ] [ [let | c [ 30 ] | a ] ] }
+                { [ t ] [ [let 30 :> c a ] ] }
             } cond
         ]
     ] ;
@@ -319,8 +251,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
 [ 20 ] [ let-and-cond-test-1 ] unit-test
 
 :: let-and-cond-test-2 ( -- pair )
-    [let | A [ 10 ] |
-        [let | B [ 20 ] |
+    [let 10 :> A
+        [let 20 :> B
             { { [ t ] [ { A B } ] } } cond
         ]
     ] ;
@@ -333,7 +265,7 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
 [ { 10 20    } ] [ 10 20    [| a b   | { a b   } ] call ] unit-test
 [ { 10 20 30 } ] [ 10 20 30 [| a b c | { a b c } ] call ] unit-test
 
-[ { 10 20 30 } ] [ [let | a [ 10 ] b [ 20 ] c [ 30 ] | { a b c } ] ] unit-test
+[ { 10 20 30 } ] [ [let 10 :> a 20 :> b 30 :> c { a b c } ] ] unit-test
 
 [ V{ 10 20 30 } ] [ 10 20 30 [| a b c | V{ a b c } ] call ] unit-test
 
@@ -453,11 +385,11 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
 [ 10 ] [ 10 [| A | { [ A ] } ] call first call ] unit-test
 
 [
-    "USING: locals fry math ; 1 '[ [let | A [ 10 ] | A _ + ] ]"
+    "USING: locals fry math ; 1 '[ [let 10 :> A A _ + ] ]"
     eval( -- ) call
 ] [ error>> >r/r>-in-fry-error? ] must-fail-with
     
-:: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline
+:: (funny-macro-test) ( obj quot -- ? ) obj { [ quot call ] } 1&& ; inline
 : funny-macro-test ( n -- ? ) [ odd? ] (funny-macro-test) ;
 
 \ funny-macro-test def>> must-infer
@@ -465,10 +397,7 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
 [ t ] [ 3 funny-macro-test ] unit-test
 [ f ] [ 2 funny-macro-test ] unit-test
 
-! Some odd parser corner cases
 [ "USE: locals [let" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
-[ "USE: locals [let |" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
-[ "USE: locals [let | a" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
 [ "USE: locals [|" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
 
 [ 25 ] [ 5 [| a | { [ a sq ] } cond ] call ] unit-test
@@ -484,15 +413,9 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
 
 [ 3 ] [ 3 [| a | \ a ] call ] unit-test
 
-[ "USE: locals [| | { [let | a [ 0 ] | a ] } ]" eval( -- ) ] must-fail
+[ "USE: locals [| | { [let 0 :> a a ] } ]" eval( -- ) ] must-fail
 
-[ "USE: locals [| | { [wlet | a [ 0 ] | a ] } ]" eval( -- ) ] must-fail
-
-[ "USE: locals [| | { [let* | a [ 0 ] | a ] } ]" eval( -- ) ] must-fail
-
-[ "USE: locals [| | [let | a! [ 0 ] | { a! } ] ]" eval( -- ) ] must-fail
-
-[ "USE: locals [| | [wlet | a [ 0 ] | { a } ] ]" eval( -- ) ] must-fail
+[ "USE: locals [| | [let 0 :> a! { a! } ] ]" eval( -- ) ] must-fail
 
 [ "USE: locals [| | { :> a } ]" eval( -- ) ] must-fail
 
@@ -504,27 +427,14 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
 
 [ 3 ] [ 2 [| | :> a! a 1 + a! a ] call ] unit-test
 
-:: wlet-&&-test ( a -- ? )
-    [wlet | is-integer? [ a integer? ]
-            is-even? [ a even? ]
-            >10? [ a 10 > ] |
-        { [ is-integer? ] [ is-even? ] [ >10? ] } &&
-    ] ;
-
-\ wlet-&&-test def>> must-infer
-[ f ] [ 1.5 wlet-&&-test ] unit-test
-[ f ] [ 3 wlet-&&-test ] unit-test
-[ f ] [ 8 wlet-&&-test ] unit-test
-[ t ] [ 12 wlet-&&-test ] unit-test
-
 : fry-locals-test-1 ( -- n )
-    [let | | 6 '[ [let | A [ 4 ] | A _ + ] ] call ] ;
+    [let 6 '[ [let 4 :> A A _ + ] ] call ] ;
 
 \ fry-locals-test-1 def>> must-infer
 [ 10 ] [ fry-locals-test-1 ] unit-test
 
 :: fry-locals-test-2 ( -- n )
-    [let | | 6 '[ [let | A [ 4 ] | A _ + ] ] call ] ;
+    [let 6 '[ [let 4 :> A A _ + ] ] call ] ;
 
 \ fry-locals-test-2 def>> must-infer
 [ 10 ] [ fry-locals-test-2 ] unit-test
@@ -542,18 +452,18 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
 ] unit-test
 
 [ 10 ] [
-    [| | 0 '[ [let | A [ 10 ] | A _ + ] ] call ] call
+    [| | 0 '[ [let 10 :> A A _ + ] ] call ] call
 ] unit-test
 
 ! littledan found this problem
-[ "bar" ] [ [let | a [ [let | foo [ "bar" ] | foo ] ] | a ] ] unit-test
-[ 10 ] [ [let | a [ 10 ] | [let | b [ a ] | b ] ] ] unit-test
+[ "bar" ] [ [let [let "bar" :> foo foo ] :> a a ] ] unit-test
+[ 10 ] [ [let 10 :> a [let a :> b b ] ] ] unit-test
 
-[ { \ + } ] [ [let | x [ \ + ] | { \ x } ] ] unit-test
+[ { \ + } ] [ [let \ + :> x { \ x } ] ] unit-test
 
-[ { \ + 3 } ] [ [let | a [ 3 ] | { \ + a } ] ] unit-test
+[ { \ + 3 } ] [ [let 3 :> a { \ + a } ] ] unit-test
 
-[ 3 ] [ [let | a [ \ + ] | 1 2 [ \ a execute ] ] call ] unit-test
+[ 3 ] [ [let \ + :> a 1 2 [ \ a execute ] ] call ] unit-test
 
 ! erg found this problem
 :: erg's-:>-bug ( n ? -- n ) ? [ n :> n n ] [ n :> b b ] if ;
@@ -578,3 +488,6 @@ M: integer ed's-bug neg ;
    { [ a ed's-bug ] } && ;
 
 [ t ] [ \ ed's-test-case optimized? ] unit-test
+
+! multiple bind
+[ 3 1 2 ] [ [let 1 2 3 :> ( a b c ) c a b ] ] unit-test
index 9e26a8caaa413c143e06563021286e57412b58de..8e940bfdd8b8100fb9eedc68c0253e0b8411d795 100644 (file)
@@ -7,15 +7,11 @@ IN: locals
 
 SYNTAX: :>
     scan locals get [ :>-outside-lambda-error ] unless*
-    [ make-local ] bind <def> parsed ;
+    parse-def suffix! ;
 
-SYNTAX: [| parse-lambda over push-all ;
+SYNTAX: [| parse-lambda append! ;
 
-SYNTAX: [let parse-let over push-all ;
-
-SYNTAX: [let* parse-let* over push-all ;
-
-SYNTAX: [wlet parse-wlet over push-all ;
+SYNTAX: [let parse-let append! ;
 
 SYNTAX: :: (::) define-declared ;
 
index 2b52c53eb5a792eebdbc4d4a4b225c41729b0052..1f9525e5ebbe42259eebc02c40036cc940a7d4e8 100644 (file)
@@ -7,13 +7,11 @@ M: lambda expand-macros clone [ expand-macros ] change-body ;
 
 M: lambda expand-macros* expand-macros literal ;
 
-M: binding-form expand-macros
-    clone
-        [ [ expand-macros ] assoc-map ] change-bindings
-        [ expand-macros ] change-body ;
+M: let expand-macros
+    clone [ expand-macros ] change-body ;
 
-M: binding-form expand-macros* expand-macros literal ;
+M: let expand-macros* expand-macros literal ;
 
 M: lambda condomize? drop t ;
 
-M: lambda condomize '[ @ ] ;
\ No newline at end of file
+M: lambda condomize [ call ] curry ;
index 8cfe45d1ba7e53e1265b693c2168342e5da4b5ee..c0184ee0efed1be229a01e3eee80d41f813b478b 100644 (file)
@@ -46,6 +46,12 @@ SYMBOL: locals
     (parse-lambda) <lambda>
     ?rewrite-closures ;
 
+: parse-multi-def ( locals -- multi-def )
+    ")" parse-tokens swap [ [ make-local ] map ] bind <multi-def> ;
+
+: parse-def ( name/paren locals -- def )
+    over "(" = [ nip parse-multi-def ] [ [ make-local ] bind <def> ] if ;
+
 M: lambda-parser parse-quotation ( -- quotation )
     H{ } clone (parse-lambda) ;
 
@@ -56,48 +62,8 @@ M: lambda-parser parse-quotation ( -- quotation )
         [ nip scan-object 2array ]
     } cond ;
 
-: (parse-bindings) ( end -- )
-    dup parse-binding dup [
-        first2 [ make-local ] dip 2array ,
-        (parse-bindings)
-    ] [ 2drop ] if ;
-
-: with-bindings ( quot -- words assoc )
-    '[
-        in-lambda? on
-        _ H{ } make-assoc
-    ] { } make swap ; inline
-
-: parse-bindings ( end -- bindings vars )
-    [ (parse-bindings) ] with-bindings ;
-
 : parse-let ( -- form )
-    "|" expect "|" parse-bindings
-    (parse-lambda) <let> ?rewrite-closures ;
-
-: parse-bindings* ( end -- words assoc )
-    [
-        namespace use-words
-        (parse-bindings)
-        namespace unuse-words
-    ] with-bindings ;
-
-: parse-let* ( -- form )
-    "|" expect "|" parse-bindings*
-    (parse-lambda) <let*> ?rewrite-closures ;
-
-: (parse-wbindings) ( end -- )
-    dup parse-binding dup [
-        first2 [ make-local-word ] keep 2array ,
-        (parse-wbindings)
-    ] [ 2drop ] if ;
-
-: parse-wbindings ( end -- bindings vars )
-    [ (parse-wbindings) ] with-bindings ;
-
-: parse-wlet ( -- form )
-    "|" expect "|" parse-wbindings
-    (parse-lambda) <wlet> ?rewrite-closures ;
+    H{ } clone (parse-lambda) <let> ?rewrite-closures ;
 
 : parse-locals ( -- effect vars assoc )
     complete-effect
@@ -121,4 +87,4 @@ M: lambda-parser parse-quotation ( -- quotation )
     [
         [ parse-definition ] 
         parse-locals-definition drop
-    ] with-method-definition ;
\ No newline at end of file
+    ] with-method-definition ;
index 187b663c3c60f9888da19da695a3072d22926b13..b0fbebbf31a8cf892d1a4dba322f1c6a853fe182 100644 (file)
@@ -27,22 +27,17 @@ M: lambda pprint*
 
 : pprint-let ( let word -- )
     pprint-word
-    [ body>> ] [ bindings>> ] bi
-    \ | pprint-word
-    t <inset
-    <block
-    [ <block [ pprint-var ] dip pprint* block> ] assoc-each
-    block>
-    \ | pprint-word
-    <block pprint-elements block>
-    block>
+    <block body>> pprint-elements block>
     \ ] pprint-word ;
 
 M: let pprint* \ [let pprint-let ;
 
-M: wlet pprint* \ [wlet pprint-let ;
-
-M: let* pprint* \ [let* pprint-let ;
-
 M: def pprint*
-    <block \ :> pprint-word local>> pprint-word block> ;
+    dup local>> word?
+    [ <block \ :> pprint-word local>> pprint-var block> ]
+    [ pprint-tuple ] if ;
+
+M: multi-def pprint*
+    dup locals>> [ word? ] all?
+    [ <block \ :> pprint-word "(" text locals>> [ pprint-var ] each ")" text block> ]
+    [ pprint-tuple ] if ;
index 87568d596aba4bdc104a26d69f42023214b8117f..a8a12d2614d86c3e353e44e93ca76db7d9e3db76 100755 (executable)
@@ -6,7 +6,7 @@ locals.errors locals.types make quotations sequences vectors
 words ;
 IN: locals.rewrite.sugar
 
-! Step 1: rewrite [| [let [let* [wlet into :> forms, turn
+! Step 1: rewrite [| into :> forms, turn
 ! literals with locals in them into code which constructs
 ! the literal after pushing locals on the stack
 
@@ -73,7 +73,7 @@ M: quotation rewrite-element rewrite-sugar* ;
 
 M: lambda rewrite-element rewrite-sugar* ;
 
-M: binding-form rewrite-element binding-form-in-literal-error ;
+M: let rewrite-element let-form-in-literal-error ;
 
 M: local rewrite-element , ;
 
@@ -104,28 +104,18 @@ M: tuple rewrite-sugar* rewrite-element ;
 
 M: def rewrite-sugar* , ;
 
+M: multi-def rewrite-sugar* locals>> <reversed> [ <def> , ] each ;
+
 M: hashtable rewrite-sugar* rewrite-element ;
 
 M: wrapper rewrite-sugar*
     rewrite-wrapper ;
 
 M: word rewrite-sugar*
-    dup { load-locals get-local drop-locals } memq?
+    dup { load-locals get-local drop-locals } member-eq?
     [ >r/r>-in-lambda-error ] [ call-next-method ] if ;
 
 M: object rewrite-sugar* , ;
 
-: let-rewrite ( body bindings -- )
-    [ quotation-rewrite % <def> , ] assoc-each
-    quotation-rewrite % ;
-
 M: let rewrite-sugar*
-    [ body>> ] [ bindings>> ] bi let-rewrite ;
-
-M: let* rewrite-sugar*
-    [ body>> ] [ bindings>> ] bi let-rewrite ;
-
-M: wlet rewrite-sugar*
-    [ body>> ] [ bindings>> ] bi
-    [ '[ _ ] ] assoc-map
-    let-rewrite ;
+    body>> quotation-rewrite % ;
index 3ed753e094c9cda310b37fde12adf41f56c6f991..424ef682439edad6faaa049f2aec34366b09533c 100644 (file)
@@ -8,20 +8,10 @@ TUPLE: lambda vars body ;
 
 C: <lambda> lambda
 
-TUPLE: binding-form bindings body ;
-
-TUPLE: let < binding-form ;
+TUPLE: let body ;
 
 C: <let> let
 
-TUPLE: let* < binding-form ;
-
-C: <let*> let*
-
-TUPLE: wlet < binding-form ;
-
-C: <wlet> wlet
-
 TUPLE: quote local ;
 
 C: <quote> quote
@@ -32,6 +22,10 @@ TUPLE: def local ;
 
 C: <def> def
 
+TUPLE: multi-def locals ;
+
+C: <multi-def> multi-def
+
 PREDICATE: local < word "local?" word-prop ;
 
 : <local> ( name -- word )
index 0ba98996b3b0099bfdec6541d8f60b9e95947ff6..eb8a2eaf76b77c63a5113a7754a8a09478fdb07f 100644 (file)
@@ -12,7 +12,7 @@ SYMBOL: word-histogram
 SYMBOL: message-histogram\r
 \r
 : analyze-entry ( entry -- )\r
-    dup level>> { ERROR CRITICAL } memq? [ dup errors get push ] when\r
+    dup level>> { ERROR CRITICAL } member-eq? [ dup errors get push ] when\r
     dup word-name>> word-histogram get inc-at\r
     dup word-name>> word-names get member? [\r
         dup [ level>> ] [ word-name>> ] [ message>> ] tri 3array\r
index 2dc5918bdae53fb49dce007316ee671792edc78b..4af3f01ef7bb50911b13f6210a9488f36d04895d 100644 (file)
@@ -47,19 +47,19 @@ HELP: log-message
 { $description "Sends a message to the current log if the level is more urgent than " { $link log-level } ". Does nothing if not executing in a dynamic scope established by " { $link with-logging } "." } ;
 
 HELP: add-logging
-{ $values { "level" "a log level" } { "word" word } }
+{ $values { "word" word } { "level" "a log level" } }
 { $description "Causes the word to log a message every time it is called." } ;
 
 HELP: add-input-logging
-{ $values { "level" "a log level" } { "word" word } }
+{ $values { "word" word } { "level" "a log level" } }
 { $description "Causes the word to log its input values every time it is called. The word must have a stack effect declaration." } ;
 
 HELP: add-output-logging
-{ $values { "level" "a log level" } { "word" word } }
+{ $values { "word" word } { "level" "a log level" } }
 { $description "Causes the word to log its output values every time it is called. The word must have a stack effect declaration." } ;
 
 HELP: add-error-logging
-{ $values { "level" "a log level" } { "word" word } }
+{ $values { "word" word } { "level" "a log level" } }
 { $description "Causes the word to log its input values and any errors it throws."
 $nl
 "If the word is not executed in a dynamic scope established by " { $link with-logging } ", its behavior is unchanged, and any errors it throws are passed to the caller."
index 0e5ef30f51cf4a13d77a0071cb63a49bff5b75f9..0186f6181f802b18337c04204617cf71b1e96d0f 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: parser kernel sequences words effects combinators assocs
-definitions quotations namespaces memoize accessors ;
+definitions quotations namespaces memoize accessors
+compiler.units ;
 IN: macros
 
 <PRIVATE
@@ -28,3 +29,5 @@ M: macro definition "macro" word-prop ;
 
 M: macro reset-word
     [ call-next-method ] [ f "macro" set-word-prop ] bi ;
+
+M: macro bump-effect-counter* drop t ;
index 8d057de720d8673852c7104ef50f4fe77a4e066f..083400224e98adf1b59aef23c44616624d512d74 100755 (executable)
@@ -78,10 +78,10 @@ PRIVATE>
 : n*V+V ( alpha x y -- alpha*x+y ) clone n*V+V! ; inline
 : n*V ( alpha x -- alpha*x ) clone n*V! ; inline
 
-: V+ ( x y -- x+y )
-    1.0 -rot n*V+V ; inline
-: V- ( x y -- x-y )
-    -1.0 spin n*V+V ; inline
+:: V+ ( x y -- x+y )
+    1.0 x y n*V+V ; inline
+:: V- ( x y -- x-y )
+    -1.0 y x n*V+V ; inline
 
 : Vneg ( x -- -x )
     -1.0 swap n*V ; inline
@@ -117,7 +117,7 @@ M: blas-vector-base equal?
 
 M: blas-vector-base length
     length>> ;
-M: blas-vector-base virtual-seq
+M: blas-vector-base virtual-exemplar
     (blas-direct-array) ;
 M: blas-vector-base virtual@
     [ inc>> * ] [ nip (blas-direct-array) ] 2bi ;
index bc09f9fe0fa9b609147c751e7eb01a8e05fba3bc..5c03e4187079a3712a9e821cd50048905dba94c8 100644 (file)
@@ -96,9 +96,9 @@ C: <combo> combo
     initial-values [ over 0 > ] [ next-values ] produce
     [ 3drop ] dip ;
 
-: combination-indices ( m combo -- seq )
-    [ tuck dual-index combinadic ] keep
-    seq>> length 1 - swap [ - ] with map ;
+:: combination-indices ( m combo -- seq )
+    combo m combo dual-index combinadic
+    combo seq>> length 1 - swap [ - ] with map ;
 
 : apply-combination ( m combo -- seq )
     [ combination-indices ] keep seq>> nths ;
index 5b1920f57204baacd7c26284ad9b38b8505017a6..5f7c066efa4db96b89e4be6c132b7ceb258cb6a8 100644 (file)
@@ -54,6 +54,8 @@ ARTICLE: "power-functions" "Powers and logarithms"
 { $subsections log1+ log10 }
 "Raising a number to a power:"
 { $subsections ^ 10^ }
+"Finding the root of a number:"
+{ $subsections nth-root }
 "Converting between rectangular and polar form:"
 { $subsections
     abs
@@ -239,7 +241,7 @@ HELP: cis
 { cis exp } related-words
 
 HELP: polar>
-{ $values { "z" number } { "abs" "a non-negative real number" } { "arg" real } }
+{ $values { "abs" "a non-negative real number" } { "arg" real } { "z" number } }
 { $description "Converts an absolute value and argument (polar form) to a complex number." } ;
 
 HELP: [-1,1]?
@@ -259,6 +261,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: nth-root
+{ $values { "n" integer } { "x" number } { "y" number } }
+{ $description "Calculates the nth root of a number, such that " { $snippet "y^n=x" } "." } ;
+
 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." } ;
index 1914bae008308c5ac2d158d68333a28deadf06c0..73f08e2665ae559253b50535a5373fb62431e06d 100644 (file)
@@ -25,6 +25,9 @@ IN: math.functions.tests
 [ t ] [ e pi i* ^ real-part -1.0 = ] unit-test
 [ t ] [ e pi i* ^ imaginary-part -0.00001 0.00001 between? ] unit-test
 
+[ 1/0. ] [ 2.0 1024 ^ ] unit-test
+[ HEX: 1.0p-1024 ] [ 2.0 -1024 ^ ] unit-test
+
 [ t ] [ 0 0 ^ fp-nan? ] unit-test
 [ 0.0 ] [ 0.0 1.0 ^ ] unit-test
 [ 1/0. ] [ 0 -2 ^ ] unit-test
index a9ad00341149a9f62de22e6f63a420b90e454786..d91b4b6b92a0c5904d418037be7a6999e573322c 100644 (file)
@@ -39,7 +39,7 @@ M: float ^n (^n) ;
 M: complex ^n (^n) ;
 
 : integer^ ( x y -- z )
-    dup 0 > [ ^n ] [ neg ^n recip ] if ; inline
+    dup 0 >= [ ^n ] [ [ recip ] dip neg ^n ] if ; inline
 
 PRIVATE>
 
@@ -106,6 +106,8 @@ PRIVATE>
         [ ^complex ]
     } cond ; inline
 
+: nth-root ( n x -- y ) swap recip ^ ; inline
+
 : gcd ( x y -- a d )
     [ 0 1 ] 2dip (gcd) dup 0 < [ neg ] when ; foldable
 
@@ -304,4 +306,3 @@ M: real atan >float atan ; inline
     [ [ / floor ] [ * ] bi ] unless-zero ;
 
 : lerp ( a b t -- a_t ) [ over - ] dip * + ; inline
-
index 1ee4e1e100f6c7285edb9a7f2ace547bdd95c0af..a569b4af7bb39b852c752d83c85d5c83f48466b0 100644 (file)
@@ -79,7 +79,7 @@ IN: math.intervals.tests
 
 [ t ] [ 1 2 [a,b] dup empty-interval interval-union = ] unit-test
 
-[ t ] [ empty-interval 1 2 [a,b] tuck interval-union = ] unit-test
+[ t ] [ 1 2 [a,b] empty-interval over interval-union = ] unit-test
 
 [ t ] [
     0 1 (a,b) 0 1 [a,b] interval-union 0 1 [a,b] =
@@ -250,7 +250,7 @@ IN: math.intervals.tests
     dup full-interval eq? [
         drop 32 random-bits 31 2^ -
     ] [
-        dup to>> first over from>> first tuck - random +
+        [ ] [ from>> first ] [ to>> first ] tri over - random +
         2dup swap interval-contains? [
             nip
         ] [
index 05f9906bb9d6602d2aa6e1862ff9d2315ae54e8c..ec742cb1ce82015de7a62497aff6f814f368f128 100755 (executable)
@@ -192,7 +192,7 @@ MEMO: array-capacity-interval ( -- interval )
 : interval-sq ( i1 -- i2 ) dup interval* ;
 
 : special-interval? ( interval -- ? )
-    { empty-interval full-interval } memq? ;
+    { empty-interval full-interval } member-eq? ;
 
 : interval-singleton? ( int -- ? )
     dup special-interval? [
index 8411447aac3a183e1ba7b99558b3770c32146a03..5c154a6820a2f68dce5049b3ed3d9ce2b69dd74d 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.vectors math.matrices namespaces
-sequences ;
+USING: kernel locals math math.vectors math.matrices
+namespaces sequences ;
 IN: math.matrices.elimination
 
 SYMBOL: matrix
@@ -85,12 +85,11 @@ SYMBOL: matrix
         ] each
     ] with-matrix ;
 
-: basis-vector ( row col# -- )
-    [ clone ] dip
-    [ swap nth neg recip ] 2keep
-    [ 0 spin set-nth ] 2keep
-    [ n*v ] dip
-    matrix get set-nth ;
+:: basis-vector ( row col# -- )
+    row clone :> row'
+    col# row' nth neg recip :> a
+    0 col# row' set-nth
+    a row n*v col# matrix get set-nth ;
 
 : nullspace ( matrix -- seq )
     echelon reduced dup empty? [
index 4a76a20598e7957081b09f2e0b9f680ec8253aa4..75b9be5caec547429b2ff10422bf45dafa9c6e97 100644 (file)
@@ -16,7 +16,7 @@ IN: math.matrices
 :: rotation-matrix3 ( axis theta -- matrix )
     theta cos :> c
     theta sin :> s
-    axis first3 :> z :> y :> x
+    axis first3 :> ( x y z )
     x sq 1.0 x sq - c * +     x y * 1.0 c - * z s * -   x z * 1.0 c - * y s * + 3array
     x y * 1.0 c - * z s * +   y sq 1.0 y sq - c * +     y z * 1.0 c - * x s * - 3array
     x z * 1.0 c - * y s * -   y z * 1.0 c - * x s * +   z sq 1.0 z sq - c * +   3array
@@ -25,14 +25,14 @@ IN: math.matrices
 :: rotation-matrix4 ( axis theta -- matrix )
     theta cos :> c
     theta sin :> s
-    axis first3 :> z :> y :> x
+    axis first3 :> ( x y z )
     x sq 1.0 x sq - c * +     x y * 1.0 c - * z s * -   x z * 1.0 c - * y s * +   0 4array
     x y * 1.0 c - * z s * +   y sq 1.0 y sq - c * +     y z * 1.0 c - * x s * -   0 4array
     x z * 1.0 c - * y s * -   y z * 1.0 c - * x s * +   z sq 1.0 z sq - c * +     0 4array
     { 0.0 0.0 0.0 1.0 } 4array ;
 
 :: translation-matrix4 ( offset -- matrix )
-    offset first3 :> z :> y :> x
+    offset first3 :> ( x y z )
     {
         { 1.0 0.0 0.0 x   }
         { 0.0 1.0 0.0 y   }
@@ -44,7 +44,7 @@ IN: math.matrices
     dup number? [ dup dup ] [ first3 ] if ;
 
 :: scale-matrix3 ( factors -- matrix )
-    factors >scale-factors :> z :> y :> x
+    factors >scale-factors :> ( x y z )
     {
         { x   0.0 0.0 }
         { 0.0 y   0.0 }
@@ -52,7 +52,7 @@ IN: math.matrices
     } ;
 
 :: scale-matrix4 ( factors -- matrix )
-    factors >scale-factors :> z :> y :> x
+    factors >scale-factors :> ( x y z )
     {
         { x   0.0 0.0 0.0 }
         { 0.0 y   0.0 0.0 }
@@ -64,7 +64,7 @@ IN: math.matrices
     [ recip ] map scale-matrix4 ;
 
 :: frustum-matrix4 ( xy-dim near far -- matrix )
-    xy-dim first2 :> y :> x
+    xy-dim first2 :> ( x y )
     near x /f :> xf
     near y /f :> yf
     near far + near far - /f :> zf
@@ -110,19 +110,9 @@ IN: math.matrices
 : mmax ( m -- n ) [ -1/0. ] dip [ [ max ] each ] each ;
 : mnorm ( m -- n ) dup mmax abs m/n ;
 
-<PRIVATE
-
-: x ( seq -- elt ) first ; inline
-: y ( seq -- elt ) second ; inline
-: z ( seq -- elt ) third ; inline
-
-: i ( seq1 seq2 -- n ) [ [ y ] [ z ] bi* * ] [ [ z ] [ y ] bi* * ] 2bi - ;
-: j ( seq1 seq2 -- n ) [ [ z ] [ x ] bi* * ] [ [ x ] [ z ] bi* * ] 2bi - ;
-: k ( seq1 seq2 -- n ) [ [ y ] [ x ] bi* * ] [ [ x ] [ y ] bi* * ] 2bi - ;
-
-PRIVATE>
-
-: cross ( vec1 vec2 -- vec3 ) [ [ i ] [ j ] [ k ] 2tri ] keep 3sequence ;
+: cross ( vec1 vec2 -- vec3 )
+    [ [ { 1 2 1 } vshuffle ] [ { 2 0 0 } vshuffle ] bi* v* ]
+    [ [ { 2 0 0 } vshuffle ] [ { 1 2 1 } vshuffle ] bi* v* ] 2bi v- ; inline
 
 : proj ( v u -- w )
     [ [ v. ] [ norm-sq ] bi / ] keep n*v ;
index 29979b62d357ceedb089676a4f216ea3282bdeb1..8bca1459c053556f5fcb9474fb1918ad9f21ec64 100644 (file)
@@ -10,9 +10,9 @@ tools.test math kernel sequences ;
 [ f ] [ \ + object number math-both-known? ] unit-test
 [ f ] [ \ number= fixnum object math-both-known? ] unit-test
 [ t ] [ \ number= integer fixnum math-both-known? ] unit-test
-[ f ] [ \ >fixnum \ shift derived-ops memq? ] unit-test
-[ f ] [ \ >integer \ /i derived-ops memq? ] unit-test
-[ t ] [ \ fixnum-shift \ shift derived-ops memq? ] unit-test
+[ f ] [ \ >fixnum \ shift derived-ops member-eq? ] unit-test
+[ f ] [ \ >integer \ /i derived-ops member-eq? ] unit-test
+[ t ] [ \ fixnum-shift \ shift derived-ops member-eq? ] unit-test
 
 [ { integer fixnum } ] [ \ +-integer-fixnum integer-op-input-classes ] unit-test
 [ { fixnum fixnum } ] [ \ fixnum+ integer-op-input-classes ] unit-test
@@ -30,4 +30,4 @@ tools.test math kernel sequences ;
 [ 3 ] [ 1 2 +-integer-integer ] unit-test
 [ 3 ] [ 1 >bignum 2 +-integer-integer ] unit-test
 [ 3 ] [ 1 2 >bignum +-integer-integer ] unit-test
-[ 3 ] [ 1 >bignum 2 >bignum +-integer-integer ] unit-test
\ No newline at end of file
+[ 3 ] [ 1 >bignum 2 >bignum +-integer-integer ] unit-test
index e78e5210f94c2b37eb76c1538a98388dcb27f256..e6f7765bd693e8996b06b43083025a3f10b49bb4 100644 (file)
@@ -7,4 +7,4 @@ USING: byte-arrays math math.bitwise math.primes.erato sequences tools.test ;
 [ t ] [ 113 100 sieve marked-prime? ] unit-test
 
 ! There are 25997 primes below 300000. 1 must be removed and 3 5 7 added.
-[ 25997 ] [ 299999 sieve [ bit-count ] sigma 2 + ] unit-test
\ No newline at end of file
+[ 25997 ] [ 299999 sieve [ bit-count ] map-sum 2 + ] unit-test
index b0dfc4ed35900a66f23282e534f8feb8d1342dbb..04b1330cc2e0bec710355bf32b387d812a28fa5f 100755 (executable)
@@ -8,7 +8,7 @@ IN: math.primes.miller-rabin
 
 :: (miller-rabin) ( n trials -- ? )
     n 1 - :> n-1
-    n-1 factor-2s :> s :> r
+    n-1 factor-2s :> ( r s )
     0 :> a!
     trials [
         drop
index 7f525debfe2f3b431707a86c049ae3dd9f1e3193..74aa2ebca36763d93ec9016d03e40e5b411c0ed1 100644 (file)
@@ -44,7 +44,8 @@ HELP: random-prime
 
 HELP: unique-primes
 { $values
-    { "numbits" integer } { "n" integer }
+    { "n" integer }
+    { "numbits" integer }
     { "seq" sequence }
 }
 { $description "Generates a sequence of " { $snippet "n" } " unique prime numbers with exactly " { $snippet "numbits" } " bits." } ;
index 584bb3115b6e2fbd96ed5e8ae6920aab3c428665..1c82f516c9c1da0bd0a8bb06cf80715485aaf8a9 100644 (file)
@@ -23,6 +23,6 @@ $nl
 { $code "3 10 [a,b] [ sqrt ] map" }
 "Computing the factorial of 100 with a descending range:"
 { $code "100 1 [a,b] product" }
-"A range can be converted into a concrete sequence using a word such as " { $link >array } ". In most cases this is unnecessary since ranges implement the sequence protocol already. It is necessary if a mutable sequence is needed, for use with words such as " { $link set-nth } " or " { $link change-each } "." ;
+"A range can be converted into a concrete sequence using a word such as " { $link >array } ". In most cases this is unnecessary since ranges implement the sequence protocol already. It is necessary if a mutable sequence is needed, for use with words such as " { $link set-nth } " or " { $link map! } "." ;
   
 ABOUT: "math.ranges"
index 8124fcdd24610f39670c5af67cbe9d51ba753bb1..153d6509142437ec658c6cb95312b2cfe71624a1 100644 (file)
@@ -84,8 +84,8 @@ unit-test
 [ 1.0 ] [ 0.5 1/2 + ] unit-test
 [ 1.0 ] [ 1/2 0.5 + ] unit-test
 
-[ 1/268435456 ] [ -1 -268435456 >fixnum / ] unit-test
-[ 268435456 ] [ -268435456 >fixnum -1 / ] unit-test
+[ 1/134217728 ] [ -1 -134217728 >fixnum / ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 / ] unit-test
 
 [ 5 ]
 [ "10/2" string>number ]
index c8569dfdb9a12d02af8667a9d295c8bbf0471ba3..bfde3918841d1e2375f5bbade28e2d9edc940bdd 100644 (file)
@@ -8,7 +8,7 @@ TUPLE: rect { loc initial: { 0 0 } } { dim initial: { 0 0 } } ;
 
 : <rect> ( loc dim -- rect ) rect boa ; inline
 
-SYNTAX: RECT: scan-object scan-object <rect> parsed ;
+SYNTAX: RECT: scan-object scan-object <rect> suffix! ;
 
 : <zero-rect> ( -- rect ) rect new ; inline
 
@@ -64,4 +64,4 @@ M: rect contains-point?
 
 USING: vocabs vocabs.loader ;
 
-"prettyprint" vocab [ "math.rectangles.prettyprint" require ] when
\ No newline at end of file
+"prettyprint" vocab [ "math.rectangles.prettyprint" require ] when
index 1a29d611f916d8500573fbe7283bcb7d4feff612..9834f44add4167491d2d154b7b26e4bcf81b5d4b 100644 (file)
@@ -1,56 +1,67 @@
-USING: help.markup help.syntax debugger ;
+USING: assocs debugger hashtables help.markup help.syntax
+quotations sequences math ;
 IN: math.statistics
 
 HELP: geometric-mean
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
-{ $description "Computes the geometric mean of all elements in " { $snippet "seq" } ". The geometric mean measures the central tendency of a data set that minimizes the effects of extreme values." }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $description "Computes the geometric mean of all elements in " { $snippet "seq" } ". The geometric mean measures the central tendency of a data set and minimizes the effects of extreme values." }
 { $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } geometric-mean ." "1.81712059283214" } }
 { $errors "Throws a " { $link signal-error. } " (square-root of 0) if the sequence is empty." } ;
 
 HELP: harmonic-mean
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
 { $description "Computes the harmonic mean of the elements in " { $snippet "seq" } ". The harmonic mean is appropriate when the average of rates is desired." }
 { $notes "Positive reals only." }
 { $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } harmonic-mean ." "6/11" } }
 { $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ;
 
 HELP: mean
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
-{ $description "Computes the arithmetic mean of all elements in " { $snippet "seq" } "." }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $description "Computes the arithmetic mean of the elements in " { $snippet "seq" } "." }
 { $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } mean ." "2" } }
 { $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ;
 
 HELP: median
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
-{ $description "Computes the median of " { $snippet "seq" } " by sorting the sequence from lowest value to highest and outputting the middle one. If there is an even number of elements in the sequence, the median is not unique, so the mean of the two middle values is outputted." }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $description "Computes the median of " { $snippet "seq" } " by finding the middle element of the sequence using " { $link kth-smallest } ". If there is an even number of elements in the sequence, the median is not unique, so the mean of the two middle values is output." }
 { $examples
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } median ." "2" }
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } median ." "2+1/2" } }
 { $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ;
 
 HELP: range
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
-{ $description "Computes the distance of the maximum and minimum values in " { $snippet "seq" } "." }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $description "Computes the difference of the maximum and minimum values in " { $snippet "seq" } "." }
 { $examples
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } range ." "2" }
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } range ." "3" } }  ;
 
+HELP: minmax
+{ $values { "seq" sequence } { "min" real } { "max" real } }
+{ $description "Finds the minimum and maximum elements of " { $snippet "seq" } " in one pass." }
+{ $examples
+    { $example "USING: arrays math.statistics prettyprint ;"
+        "{ 1 2 3 } minmax 2array ."
+        "{ 1 3 }"
+    }
+} ;
+
 HELP: std
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
 { $description "Computes the standard deviation of " { $snippet "seq" } ", which is the square root of the variance. It measures how widely spread the values in a sequence are about the mean." }
 { $examples
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } std ." "1.0" }
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } std ." "1.290994448735806" } } ;
 
 HELP: ste
-  { $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
+  { $values { "seq" sequence } { "x" "a non-negative real number"} }
   { $description "Computes the standard error of the mean for " { $snippet "seq" } ". It's defined as the standard deviation divided by the square root of the length of the sequence, and measures uncertainty associated with the estimate of the mean." }
   { $examples
     { $example "USING: math.statistics prettyprint ;" "{ -2 2 } ste ." "2.0" }
     { $example "USING: math.statistics prettyprint ;" "{ -2 2 2 } ste ." "1.333333333333333" } } ;
 
 HELP: var
-{ $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number"} }
 { $description "Computes the variance of " { $snippet "seq" } ". It's a measurement of the spread of values in a sequence. The larger the variance, the larger the distance of values from the mean." }
 { $notes "If the number of elements in " { $snippet "seq" } " is 1 or less, it outputs 0." }
 { $examples
@@ -58,3 +69,118 @@ HELP: var
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } var ." "1" }
   { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } var ." "1+2/3" } } ;
 
+
+HELP: histogram
+{ $values
+    { "seq" sequence }
+    { "hashtable" hashtable }
+}
+{ $examples 
+    { $example "! Count the number of times an element appears in a sequence."
+               "USING: prettyprint math.statistics ;"
+               "\"aaabc\" histogram ."
+               "H{ { 97 3 } { 98 1 } { 99 1 } }"
+    }
+}
+{ $description "Returns a hashtable where the keys are the elements of the sequence and the values are the number of times they appeared in that sequence." } ;
+
+HELP: histogram*
+{ $values
+    { "hashtable" hashtable } { "seq" sequence }
+    { "hashtable" hashtable }
+}
+{ $examples 
+    { $example "! Count the number of times the elements of two sequences appear."
+               "USING: prettyprint math.statistics ;"
+               "\"aaabc\" histogram \"aaaaaabc\" histogram* ."
+               "H{ { 97 9 } { 98 2 } { 99 2 } }"
+    }
+}
+{ $description "Takes an existing hashtable and uses " { $link histogram } " to continue counting the number of occurences of each element." } ;
+
+HELP: sorted-histogram
+{ $values
+    { "seq" sequence }
+    { "alist" "an array of key/value pairs" }
+}
+{ $description "Outputs a " { $link histogram } " of a sequence sorted by number of occurences from lowest to highest." }
+{ $examples
+    { $example "USING: prettyprint math.statistics ;"
+        """"abababbbbbbc" sorted-histogram ."""
+        "{ { 99 1 } { 97 3 } { 98 8 } }"
+    }
+} ;
+
+HELP: sequence>assoc
+{ $values
+    { "seq" sequence } { "quot" quotation } { "exemplar" "an exemplar assoc" }
+    { "assoc" assoc }
+}
+{ $examples 
+    { $example "! Iterate over a sequence and increment the count at each element"
+               "USING: assocs prettyprint math.statistics ;"
+               "\"aaabc\" [ inc-at ] H{ } sequence>assoc ."
+               "H{ { 97 3 } { 98 1 } { 99 1 } }"
+    }
+}
+{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a newly created " { $snippet "assoc" } " according to the passed quotation." } ;
+
+HELP: sequence>assoc*
+{ $values
+    { "assoc" assoc } { "seq" sequence } { "quot" quotation }
+    { "assoc" assoc }
+}
+{ $examples 
+    { $example "! Iterate over a sequence and add the counts to an existing assoc"
+               "USING: assocs prettyprint math.statistics kernel ;"
+               "H{ { 97 2 } { 98 1 } } clone \"aaabc\" [ inc-at ] sequence>assoc* ."
+               "H{ { 97 5 } { 98 2 } { 99 1 } }"
+    }
+}
+{ $description "Iterates over a sequence, allowing elements of the sequence to be added to an existing " { $snippet "assoc" } " according to the passed quotation." } ;
+
+HELP: sequence>hashtable
+{ $values
+    { "seq" sequence } { "quot" quotation }
+    { "hashtable" hashtable }
+}
+{ $examples 
+    { $example "! Count the number of times an element occurs in a sequence"
+               "USING: assocs prettyprint math.statistics ;"
+               "\"aaabc\" [ inc-at ] sequence>hashtable ."
+               "H{ { 97 3 } { 98 1 } { 99 1 } }"
+    }
+}
+{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a hashtable according to the passed quotation." } ;
+
+ARTICLE: "histogram" "Computing histograms"
+"Counting elements in a sequence:"
+{ $subsections
+    histogram
+    histogram*
+    sorted-histogram
+}
+"Combinators for implementing histogram:"
+{ $subsections
+    sequence>assoc
+    sequence>assoc*
+    sequence>hashtable
+} ;
+
+ARTICLE: "math.statistics" "Statistics"
+"Computing the mean:"
+{ $subsections mean geometric-mean harmonic-mean }
+"Computing the median:"
+{ $subsections median lower-median upper-median medians }
+"Computing the mode:"
+{ $subsections mode }
+"Computing the standard deviation, standard error, and variance:"
+{ $subsections std ste var }
+"Computing the range and minimum and maximum elements:"
+{ $subsections range minmax }
+"Computing the kth smallest element:"
+{ $subsections kth-smallest }
+"Counting the frequency of occurrence of elements:"
+{ $subsection "histogram" } ;
+
+ABOUT: "math.statistics"
index 32ebcbc6a19b85a871b90b0e403005994ec6ef0b..0d3172f685800936875776b007b48fdb48775698 100644 (file)
@@ -43,3 +43,13 @@ IN: math.statistics.tests
 [ 0 ] [ { 1 } var ] unit-test
 [ 0.0 ] [ { 1 } std ] unit-test
 [ 0.0 ] [ { 1 } ste ] unit-test
+
+[
+    H{
+        { 97 2 }
+        { 98 2 }
+        { 99 2 }
+    }
+] [
+    "aabbcc" histogram
+] unit-test
index a1a214b2c015cebc694ac06e52bbbbb7b3e97e98..73a87ffb72fe95f922d4f97fafaebc65ffe4e0af 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman, Michael Judge.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators kernel math math.analysis
-math.functions math.order sequences sorting locals
-sequences.private assocs fry ;
+USING: arrays combinators kernel math math.functions
+math.order sequences sorting locals sequences.private
+assocs fry ;
 IN: math.statistics
 
 : mean ( seq -- x )
@@ -12,7 +12,7 @@ IN: math.statistics
     [ length ] [ product ] bi nth-root ;
 
 : harmonic-mean ( seq -- x )
-    [ recip ] sigma recip ;
+    [ recip ] map-sum recip ;
 
 :: kth-smallest ( seq k -- elt )
     #! Wirth's method, Algorithm's + Data structues = Programs p. 84
@@ -33,7 +33,7 @@ IN: math.statistics
             [ i seq nth-unsafe x < ] [ i 1 + i! ] while
             [ x j seq nth-unsafe < ] [ j 1 - j! ] while
             i j <= [
-                i j seq exchange
+                i j seq exchange-unsafe
                 i 1 + i!
                 j 1 - j!
             ] when
@@ -45,7 +45,8 @@ IN: math.statistics
     k seq nth ; inline
 
 : lower-median ( seq -- elt )
-    dup dup length odd? [ midpoint@ ] [ midpoint@ 1 - ] if kth-smallest ;
+    [ ] [ ] [ length odd? ] tri
+    [ midpoint@ ] [ midpoint@ 1 - ] if kth-smallest ;
 
 : upper-median ( seq -- elt )
     dup midpoint@ kth-smallest ;
@@ -54,13 +55,38 @@ IN: math.statistics
     [ lower-median ] [ upper-median ] bi ;
 
 : median ( seq -- x )
-    dup length odd? [ lower-median ] [ medians + 2 / ] if ;
+    [ ] [ length odd? ] bi [ lower-median ] [ medians + 2 / ] if ;
 
-: frequency ( seq -- hashtable )
-    H{ } clone [ '[ _ inc-at ] each ] keep ;
+<PRIVATE
+
+: (sequence>assoc) ( seq quot assoc -- assoc )
+    [ swap curry each ] keep ; inline
+
+PRIVATE>
+
+: sequence>assoc* ( assoc seq quot: ( obj assoc -- ) -- assoc )
+    rot (sequence>assoc) ; inline
+
+: sequence>assoc ( seq quot: ( obj assoc -- ) exemplar -- assoc )
+    clone (sequence>assoc) ; inline
+
+: sequence>hashtable ( seq quot: ( obj hashtable -- ) -- hashtable )
+    H{ } sequence>assoc ; inline
+
+: histogram* ( hashtable seq -- hashtable )
+    [ inc-at ] sequence>assoc* ;
+
+: histogram ( seq -- hashtable )
+    [ inc-at ] sequence>hashtable ;
+
+: sorted-histogram ( seq -- alist )
+    histogram >alist sort-values ;
+
+: collect-values ( seq quot: ( obj hashtable -- ) -- hash )
+    '[ [ dup @ ] dip push-at ] sequence>hashtable ; inline
 
 : mode ( seq -- x )
-    frequency >alist
+    histogram >alist
     [ ] [ [ [ second ] bi@ > ] 2keep ? ] map-reduce first ;
 
 : minmax ( seq -- min max )
@@ -75,7 +101,7 @@ IN: math.statistics
     dup length 1 <= [
         drop 0
     ] [
-        [ [ mean ] keep [ - sq ] with sigma ]
+        [ [ mean ] keep [ - sq ] with map-sum ]
         [ length 1 - ] bi /
     ] if ;
 
index f70dfc9b27667b3d92a17a2142b135213563ac22..fd58b11dc8a31526fc5498bec4721355e9a18da0 100644 (file)
@@ -11,9 +11,9 @@ ERROR: bad-vconvert-input value expected-type ;
 <PRIVATE
 
 : float-type? ( c-type -- ? )
-    { float double } memq? ;
+    { float double } member-eq? ;
 : unsigned-type? ( c-type -- ? )
-    { uchar ushort uint ulonglong } memq? ;
+    { uchar ushort uint ulonglong } member-eq? ;
 
 : check-vconvert-type ( value expected-type -- value )
     2dup instance? [ drop ] [ bad-vconvert-input ] if ; inline
@@ -81,8 +81,8 @@ ERROR: bad-vconvert-input value expected-type ;
 PRIVATE>
 
 MACRO:: vconvert ( from-type to-type -- )
-    from-type new [ element-type ] [ byte-length ] bi :> from-length :> from-element
-    to-type   new [ element-type ] [ byte-length ] bi :> to-length   :> to-element
+    from-type new [ element-type ] [ byte-length ] bi :> ( from-element from-length )
+    to-type   new [ element-type ] [ byte-length ] bi :> ( to-element   to-length   )
     from-element heap-size :> from-size
     to-element   heap-size :> to-size   
 
index 480981d165a23589c06a1f67028b30520bfe3fe2..cdb67f976fc9dad1048e224824c4b0a76bf4201c 100644 (file)
@@ -146,7 +146,8 @@ TUPLE: simd class elt-class ops special-wrappers schema-wrappers ctor rep ;
         [ rep alien-vector class boa ] >>getter
         [ [ underlying>> ] 2dip rep set-alien-vector ] >>setter
         16 >>size
-        8 >>align
+        16 >>align
+        16 >>align-first
         rep >>rep
     class c:typedef ;
 
@@ -315,7 +316,8 @@ SLOT: underlying2
             3bi
         ] >>setter
         32 >>size
-        8 >>align
+        16 >>align
+        16 >>align-first
         rep >>rep
     class c:typedef ;
 
index 1bd5834f2cefa12eb17bf9b8c36607e063525bd7..003b42fe83f28b19d2f77226e9e64be1a0ed22d5 100644 (file)
@@ -163,8 +163,8 @@ M: vector-rep supported-simd-op?
         { \ (simd-v*)            [ %mul-vector-reps            ] }
         { \ (simd-vs*)           [ %saturated-mul-vector-reps  ] }
         { \ (simd-v/)            [ %div-vector-reps            ] }
-        { \ (simd-vmin)          [ %min-vector-reps            ] }
-        { \ (simd-vmax)          [ %max-vector-reps            ] }
+        { \ (simd-vmin)          [ %min-vector-reps cc< %compare-vector-reps union ] }
+        { \ (simd-vmax)          [ %max-vector-reps cc> %compare-vector-reps union ] }
         { \ (simd-v.)            [ %dot-vector-reps            ] }
         { \ (simd-vsqrt)         [ %sqrt-vector-reps           ] }
         { \ (simd-sum)           [ %horizontal-add-vector-reps ] }
@@ -181,8 +181,8 @@ M: vector-rep supported-simd-op?
         { \ (simd-vnot)          [ %xor-vector-reps            ] }
         { \ (simd-vlshift)       [ %shl-vector-reps            ] }
         { \ (simd-vrshift)       [ %shr-vector-reps            ] }
-        { \ (simd-hlshift)       [ %horizontal-shl-vector-reps ] }
-        { \ (simd-hrshift)       [ %horizontal-shr-vector-reps ] }
+        { \ (simd-hlshift)       [ %horizontal-shl-vector-imm-reps ] }
+        { \ (simd-hrshift)       [ %horizontal-shr-vector-imm-reps ] }
         { \ (simd-vshuffle-elements) [ (%shuffle-imm-reps)         ] }
         { \ (simd-vshuffle-bytes)    [ %shuffle-vector-reps        ] }
         { \ (simd-(vmerge-head)) [ %merge-vector-reps          ] }
@@ -193,12 +193,12 @@ M: vector-rep supported-simd-op?
         { \ (simd-(vpack-unsigned)) [ %unsigned-pack-vector-reps ] }
         { \ (simd-(vunpack-head))   [ (%unpack-reps)             ] }
         { \ (simd-(vunpack-tail))   [ (%unpack-reps)             ] }
-        { \ (simd-v<=)           [ cc<= %compare-vector-reps   ] }
-        { \ (simd-v<)            [ cc< %compare-vector-reps    ] }
-        { \ (simd-v=)            [ cc= %compare-vector-reps    ] }
-        { \ (simd-v>)            [ cc> %compare-vector-reps    ] }
-        { \ (simd-v>=)           [ cc>= %compare-vector-reps   ] }
-        { \ (simd-vunordered?)   [ cc/<>= %compare-vector-reps ] }
+        { \ (simd-v<=)           [ unsign-rep cc<= %compare-vector-reps   ] }
+        { \ (simd-v<)            [ unsign-rep cc< %compare-vector-reps    ] }
+        { \ (simd-v=)            [ unsign-rep cc= %compare-vector-reps    ] }
+        { \ (simd-v>)            [ unsign-rep cc> %compare-vector-reps    ] }
+        { \ (simd-v>=)           [ unsign-rep cc>= %compare-vector-reps   ] }
+        { \ (simd-vunordered?)   [ unsign-rep cc/<>= %compare-vector-reps ] }
         { \ (simd-gather-2)      [ %gather-vector-2-reps       ] }
         { \ (simd-gather-4)      [ %gather-vector-4-reps       ] }
         { \ (simd-vany?)         [ %test-vector-reps           ] }
index 7803c009547cbcde14c6ac3a394138b10407940c..46cced3cb7a7188744c7533346ab198014f565ab 100644 (file)
@@ -88,8 +88,8 @@ CONSTANT: simd-classes
         {
             [ "print-mr" get [ nip test-mr mr. ] [ 2drop ] if ]
             [ "print-checks" get [ [ . ] bi@ ] [ 2drop ] if ]
-            [ [ call ] dip call ]
-            [ [ call ] dip compile-call ]
+            [ [ [ call ] dip call ] call( quot quot -- result ) ]
+            [ [ [ call ] dip compile-call ] call( quot quot -- result ) ]
         } 2cleave
         @ not
     ] filter ; inline
@@ -233,7 +233,7 @@ simd-classes&reps [
     ] [ ] map-as
     word '[ _ execute ] ;
 
-: check-boolean-ops ( class elt-class compare-quot -- )
+: check-boolean-ops ( class elt-class compare-quot -- seq )
     [
         [ boolean-ops [ dup word-schema ] { } map>assoc ] 2dip
         '[ first2 inputs _ _ check-boolean-op ]
@@ -357,13 +357,15 @@ simd-classes [
     new [ drop 16 random ] map ;
 
 :: test-shift-vector ( class -- ? )
-    class random-int-vector :> src
-    char-16 random-shift-vector :> perm
-    { class char-16 } :> decl
-
-    src perm vshuffle
-    src perm [ decl declare vshuffle ] compile-call
-    = ; inline
+    [
+        class random-int-vector :> src
+        char-16 random-shift-vector :> perm
+        { class char-16 } :> decl
+    
+        src perm vshuffle
+        src perm [ decl declare vshuffle ] compile-call
+        =
+    ] call( -- ? ) ;
 
 { char-16 uchar-16 short-8 ushort-8 int-4 uint-4 longlong-2 ulonglong-2 }
 [ 10 swap '[ [ t ] [ _ test-shift-vector ] unit-test ] times ] each
@@ -371,19 +373,23 @@ simd-classes [
 "== Checking vector tests" print
 
 :: test-vector-tests-bool ( vector declaration -- none? any? all? )
-    vector
-    [ [ declaration declare vnone? ] compile-call ]
-    [ [ declaration declare vany?  ] compile-call ]
-    [ [ declaration declare vall?  ] compile-call ] tri ; inline
+    [
+        vector
+        [ [ declaration declare vnone? ] compile-call ]
+        [ [ declaration declare vany?  ] compile-call ]
+        [ [ declaration declare vall?  ] compile-call ] tri
+    ] call( -- none? any? all? ) ;
 
 : yes ( -- x ) t ;
 : no ( -- x ) f ;
 
 :: test-vector-tests-branch ( vector declaration -- none? any? all? )
-    vector
-    [ [ declaration declare vnone? [ yes ] [ no ] if ] compile-call ]
-    [ [ declaration declare vany?  [ yes ] [ no ] if ] compile-call ]
-    [ [ declaration declare vall?  [ yes ] [ no ] if ] compile-call ] tri ; inline
+    [
+        vector
+        [ [ declaration declare vnone? [ yes ] [ no ] if ] compile-call ]
+        [ [ declaration declare vany?  [ yes ] [ no ] if ] compile-call ]
+        [ [ declaration declare vall?  [ yes ] [ no ] if ] compile-call ] tri
+    ] call( -- none? any? all? ) ;
 
 TUPLE: inconsistent-vector-test bool branch ;
 
@@ -391,12 +397,14 @@ TUPLE: inconsistent-vector-test bool branch ;
     2dup = [ drop ] [ inconsistent-vector-test boa ] if ;
 
 :: test-vector-tests ( vector decl -- none? any? all? )
-    vector decl test-vector-tests-bool :> bool-all :> bool-any :> bool-none
-    vector decl test-vector-tests-branch :> branch-all :> branch-any :> branch-none
-    
-    bool-none branch-none ?inconsistent
-    bool-any  branch-any  ?inconsistent
-    bool-all  branch-all  ?inconsistent ; inline
+    [
+        vector decl test-vector-tests-bool :> ( bool-none bool-any bool-all )
+        vector decl test-vector-tests-branch :> ( branch-none branch-any branch-all )
+        
+        bool-none branch-none ?inconsistent
+        bool-any  branch-any  ?inconsistent
+        bool-all  branch-all  ?inconsistent
+    ] call( -- none? any? all? ) ;
 
 [ f t t ]
 [ float-4{ t t t t } { float-4 } test-vector-tests ] unit-test
@@ -470,7 +478,7 @@ TUPLE: inconsistent-vector-test bool branch ;
 "== Checking broadcast" print
 : test-broadcast ( seq -- failures )
     [ length >array ] keep
-    '[ [ _ 1quotation ] dip '[ _ vbroadcast ] ] [ = ] check-optimizer ; inline
+    '[ [ _ 1quotation ] dip '[ _ vbroadcast ] ] [ = ] check-optimizer ;
 
 [ { } ] [ float-4{ 1.0 2.0 3.0 4.0 } test-broadcast ] unit-test
 [ { } ] [ int-4{ HEX: 7fffffff 3 4 -8 } test-broadcast ] unit-test
@@ -582,3 +590,20 @@ STRUCT: simd-struct
     float-4{ 1.0 0.0 1.0 0.0 } pi [ broken 3array ]
     [ compile-call ] [ call ] 3bi =
 ] unit-test
+
+! Spilling SIMD values -- this basically just tests that the
+! stack was aligned properly by the runtime
+
+: simd-spill-test-1 ( a b c -- v )
+    { float-4 float-4 float } declare 
+    [ v+ ] dip sin v*n ;
+
+[ float-4{ 0 0 0 0 } ]
+[ float-4{ 1 2 3 4 } float-4{ 4 5 6 7 } 0.0 simd-spill-test-1 ] unit-test
+
+: simd-spill-test-2 ( a b d c -- v )
+    { float float-4 float-4 float } declare 
+    [ [ 3.0 + ] 2dip v+ ] dip sin v*n n*v ;
+
+[ float-4{ 0 0 0 0 } ]
+[ 5.0 float-4{ 1 2 3 4 } float-4{ 4 5 6 7 } 0.0 simd-spill-test-2 ] unit-test
index ffa6b5ba1876bad1d4fce40e62d88f059db80c4e..388fed5f31cee345692a202f09c12e698c49e01c 100644 (file)
@@ -15,7 +15,7 @@ ERROR: bad-base-type type ;
     name>> "math.vectors.simd.instances." prepend ;
 
 : parse-base-type ( c-type -- c-type )
-    dup { c:char c:uchar c:short c:ushort c:int c:uint c:longlong c:ulonglong c:float c:double } memq?
+    dup { c:char c:uchar c:short c:ushort c:int c:uint c:longlong c:ulonglong c:float c:double } member-eq?
     [ bad-base-type ] unless ;
 
 : forget-instances ( -- )
index 3ff286d50884bcf80b295908ecb88c9257498a79..602fd9802ce73de4e181d1d08a71f08dcad3b5b6 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words kernel make sequences effects sets kernel.private
 accessors combinators math math.intervals math.vectors
-math.vectors.conversion.backend
-namespaces assocs fry splitting classes.algebra generalizations
-locals compiler.tree.propagation.info ;
+math.vectors.conversion.backend namespaces assocs fry splitting
+classes.algebra generalizations locals
+compiler.tree.propagation.info ;
 IN: math.vectors.specialization
 
 SYMBOLS: -> +vector+ +any-vector+ +scalar+ +boolean+ +nonnegative+ +literal+ ;
index 71e86417f58a2b21d26d9a2b193b1766ed450235..b831ac7dbe116c7e5450c2ad6a12126cc0f5068d 100644 (file)
@@ -101,6 +101,7 @@ $nl
     vxor
     vnot
     v?
+    vif
 }
 "Entire vector tests:"
 { $subsections
@@ -534,10 +535,19 @@ HELP: vnot
 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
 
 HELP: v?
-{ $values { "mask" "a sequence of booleans" } { "true" "a sequence of numbers" } { "false" "a sequence of numbers" } { "w" "a sequence of numbers" } }
+{ $values { "mask" "a sequence of booleans" } { "true" "a sequence of numbers" } { "false" "a sequence of numbers" } { "result" "a sequence of numbers" } }
 { $description "Creates a new sequence by selecting elements from the " { $snippet "true" } " and " { $snippet "false" } " sequences based on whether the corresponding bits of the " { $snippet "mask" } " sequence are set or not." }
 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
 
+HELP: vif
+{ $values { "mask" "a sequence of booleans" } { "true-quot" { $quotation "( -- vector )" } } { "false-quot" { $quotation "( -- vector )" } } { "result" "a sequence" } }
+{ $description "If all of the elements of " { $snippet "mask" } " are true, " { $snippet "true-quot" } " is called and its output value returned. If all of the elements of " { $snippet "mask" } " are false, " { $snippet "false-quot" } " is called and its output value returned. Otherwise, both quotations are called and " { $snippet "mask" } " is used to select elements from each output as with " { $link v? } "." }
+{ $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types."
+$nl
+"For most conditional SIMD code, unless a case is exceptionally expensive to compute, it is usually most efficient to just compute all cases and blend them with " { $link v? } " instead of using " { $snippet "vif" } "." } ;
+
+{ v? vif } related-words
+
 HELP: vany?
 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
 { $description "Returns true if any element of " { $snippet "v" } " is true." }
index 51e44d00f0734276787452e5e597f0df9ea15eef..63564f064d5756bd226e23d72ab40c07a52f49bc 100644 (file)
@@ -96,6 +96,7 @@ PRIVATE>
 :: vbroadcast ( u n -- v ) u length n u nth <repetition> u like ;
 
 : vshuffle-elements ( u perm -- v )
+    over length 0 pad-tail
     swap [ '[ _ nth ] ] keep map-as ;
 
 : vshuffle-bytes ( u perm -- v )
@@ -142,9 +143,16 @@ M: simd-128 vshuffle ( u perm -- v )
 : vunordered? ( u v -- w ) [ unordered? ] 2map ;
 : v=  ( u v -- w ) [ =   ] 2map ;
 
-: v? ( mask true false -- w )
+: v? ( mask true false -- result )
     [ vand ] [ vandn ] bi-curry* bi vor ; inline
 
+:: vif ( mask true-quot false-quot -- result )
+    {
+        { [ mask vall?  ] [ true-quot  call ] }
+        { [ mask vnone? ] [ false-quot call ] }
+        [ mask true-quot call false-quot call v? ]
+    } cond ; inline
+
 : vfloor    ( u -- v ) [ floor ] map ;
 : vceiling  ( u -- v ) [ ceiling ] map ;
 : vtruncate ( u -- v ) [ truncate ] map ;
@@ -175,20 +183,20 @@ PRIVATE>
 
 : bilerp ( aa ba ab bb {t,u} -- a_tu )
     [ first lerp ] [ second lerp ] bi-curry
-    [ 2bi@ ] [ call ] bi* ;
+    [ 2bi@ ] [ call ] bi* ; inline
 
 : vlerp ( a b t -- a_t )
-    [ lerp ] 3map ;
+    [ over v- ] dip v* v+ ; inline
 
 : vnlerp ( a b t -- a_t )
-    [ lerp ] curry 2map ;
+    [ over v- ] dip v*n v+ ; inline
 
 : vbilerp ( aa ba ab bb {t,u} -- a_tu )
     [ first vnlerp ] [ second vnlerp ] bi-curry
-    [ 2bi@ ] [ call ] bi* ;
+    [ 2bi@ ] [ call ] bi* ; inline
 
 : v~ ( a b epsilon -- ? )
-    [ ~ ] curry 2all? ;
+    [ ~ ] curry 2all? ; inline
 
 HINTS: vneg { array } ;
 HINTS: norm-sq { array } ;
index b9f90192457db503f2f670f471d73d4ab220e960..65978f0b46af4d4b68d93744740e2949c6f7d012 100644 (file)
@@ -3,7 +3,7 @@
 USING: assocs hashtables kernel sequences generic words
 arrays classes slots slots.private classes.tuple
 classes.tuple.private math vectors math.vectors quotations
-accessors combinators byte-arrays specialized-arrays ;
+accessors combinators byte-arrays vocabs vocabs.loader ;
 IN: mirrors
 
 TUPLE: mirror { object read-only } ;
@@ -53,12 +53,13 @@ INSTANCE: array             enumerated-sequence
 INSTANCE: vector            enumerated-sequence
 INSTANCE: callable          enumerated-sequence
 INSTANCE: byte-array        enumerated-sequence
-INSTANCE: specialized-array enumerated-sequence
-INSTANCE: simd-128          enumerated-sequence
-INSTANCE: simd-256          enumerated-sequence
 
 GENERIC: make-mirror ( obj -- assoc )
 M: hashtable make-mirror ;
 M: integer make-mirror drop f ;
 M: enumerated-sequence make-mirror <enum> ;
 M: object make-mirror <mirror> ;
+
+"specialized-arrays" vocab [
+    "specialized-arrays.mirrors" require
+] when
index d7900f1dbd5e32ab5b534b35ad9dfd8e73eda488..6bd6395ac058009605438389130cae76b180718f 100644 (file)
@@ -6,12 +6,12 @@ IN: models.arrow.tests
 "x" get [ 2 * ] <arrow> dup "z" set\r
 [ 1 + ] <arrow> "y" set\r
 [ ] [ "y" get activate-model ] unit-test\r
-[ t ] [ "z" get "x" get connections>> memq? ] unit-test\r
+[ t ] [ "z" get "x" get connections>> member-eq? ] unit-test\r
 [ 7 ] [ "y" get value>> ] unit-test\r
 [ ] [ 4 "x" get set-model ] unit-test\r
 [ 9 ] [ "y" get value>> ] unit-test\r
 [ ] [ "y" get deactivate-model ] unit-test\r
-[ f ] [ "z" get "x" get connections>> memq? ] unit-test\r
+[ f ] [ "z" get "x" get connections>> member-eq? ] unit-test\r
 \r
 3 <model> "x" set\r
 "x" get [ sq ] <arrow> "y" set\r
diff --git a/basis/models/illusion/authors.txt b/basis/models/illusion/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/basis/models/illusion/illusion.factor b/basis/models/illusion/illusion.factor
deleted file mode 100644 (file)
index 0016979..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-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
deleted file mode 100644 (file)
index 8ea7cf1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Two Way Arrows
\ No newline at end of file
index 27504bc0fa769d7e9b014aa6c9a424f286abbee2..f9927cfd4cc181b1f549a59a904117c525498cff 100644 (file)
@@ -17,13 +17,11 @@ value connections dependencies ref locked? ;
 : <model> ( value -- model )
     model new-model ;
 
-M: model hashcode* drop model hashcode* ;
-
 : add-dependency ( dep model -- )
     dependencies>> push ;
 
 : remove-dependency ( dep model -- )
-    dependencies>> delete ;
+    dependencies>> remove! drop ;
 
 DEFER: add-connection
 
@@ -63,7 +61,7 @@ GENERIC: model-changed ( model observer -- )
     connections>> push ;
 
 : remove-connection ( observer model -- )
-    [ connections>> delete ] keep
+    [ connections>> remove! drop ] keep
     dup connections>> empty? [ dup deactivate-model ] when
     drop ;
 
index f52dc8a3b0a3c29f887936acf2cc9c4a121a694c..c26866e83b41630c9311ca14921e9bb368520bc7 100644 (file)
@@ -27,11 +27,12 @@ TUPLE: an-observer { i integer } ;
 M: an-observer model-changed nip [ 1 + ] change-i drop ;\r
 \r
 [ 1 0 ] [\r
-    [let* | m1 [ 1 <model> ]\r
-            m2 [ 2 <model> ]\r
-            c [ { m1 m2 } <product> ]\r
-            o1 [ an-observer new ]\r
-            o2 [ an-observer new ] |\r
+    [let\r
+        1 <model> :> m1\r
+        2 <model> :> m2\r
+        { m1 m2 } <product> :> c\r
+        an-observer new :> o1\r
+        an-observer new :> o2\r
         \r
         o1 m1 add-connection\r
         o2 m2 add-connection\r
index e28537066bac43893e270734b744e30563ae972e..5182c33e599bba3853324109e8d53a63dfaaf8c5 100644 (file)
@@ -81,10 +81,10 @@ SYNTAX: HEREDOC:
     lexer get skip-blank
     rest-of-line
     lexer get next-line
-    parse-til-line-begins parsed ;
+    parse-til-line-begins suffix! ;
 
 SYNTAX: DELIMITED:
     lexer get skip-blank
     rest-of-line
     lexer get next-line
-    0 (parse-multiline-string) parsed ;
+    0 (parse-multiline-string) suffix! ;
index 7cbdf623462fe1d66b8d2aa50ba6f034da4bc2dc..0662a9c08ae87d115beb2901fa5442f19b109329 100644 (file)
@@ -1,5 +1,5 @@
 ! (c)2009 Joe Groff bsd license
-USING: accessors kernel namespaces parser tools.continuations
+USING: accessors kernel namespaces parser sequences tools.continuations
 ui.backend ui.gadgets.worlds words ;
 IN: opengl.debug
 
@@ -19,5 +19,5 @@ SYMBOL: G-world
 << \ gl-break t "break?" set-word-prop >>
 
 SYNTAX: GB
-    \ gl-break parsed ;
+    \ gl-break suffix! ;
 
diff --git a/basis/opengl/opengl-tests.factor b/basis/opengl/opengl-tests.factor
new file mode 100644 (file)
index 0000000..818d0db
--- /dev/null
@@ -0,0 +1,6 @@
+USING: tools.test math opengl opengl.gl ;
+IN: opengl.tests
+
+{ 2 1 } [ { GL_TEXTURE_2D } [ + ] all-enabled ] must-infer-as
+
+{ 2 1 } [ { GL_TEXTURE_2D } [ + ] all-enabled-client-state ] must-infer-as
index cdf68cebd35720a2223ec0e23039587dbb672f22..1f6205e64fda4575661a31fa8b12096593611d24 100755 (executable)
@@ -56,7 +56,9 @@ TUPLE: gl-error function code string ;
     [ ?execute ] map ;
 
 : (all-enabled) ( seq quot -- )
-    over [ glEnable ] each dip [ glDisable ] each ; inline
+    [ dup [ glEnable ] each ] dip
+    dip
+    [ glDisable ] each ; inline
 
 : (all-enabled-client-state) ( seq quot -- )
     [ dup [ glEnableClientState ] each ] dip
@@ -95,8 +97,8 @@ MACRO: all-enabled-client-state ( seq quot -- )
     #! We use GL_LINE_STRIP with a duplicated first vertex
     #! instead of GL_LINE_LOOP to work around a bug in Apple's
     #! X3100 driver.
-    loc first2 :> y :> x
-    dim first2 :> h :> w
+    loc first2 :> ( x y )
+    dim first2 :> ( w h )
     [
         x 0.5 +     y 0.5 +
         x w + 0.3 - y 0.5 +
@@ -115,8 +117,8 @@ MACRO: all-enabled-client-state ( seq quot -- )
     rect-vertices (gl-rect) ;
 
 :: (fill-rect-vertices) ( loc dim -- vertices )
-    loc first2 :> y :> x
-    dim first2 :> h :> w
+    loc first2 :> ( x y )
+    dim first2 :> ( w h )
     [
         x      y
         x w +  y
index d846afe3a90cb492ed63bc47703b7c102203e94e..e53383c98bf9899215e6eebf58e0dcdd449825eb 100755 (executable)
@@ -278,7 +278,7 @@ TUPLE: single-texture < disposable image dim loc texture-coords texture display-
     ] unless ;
 
 :: tex-image ( image bitmap -- )
-    image image-format :> type :> format :> internal-format
+    image image-format :> ( internal-format format type )
     GL_TEXTURE_2D 0 internal-format
     image dim>> adjust-texture-dim first2 0
     format type bitmap glTexImage2D ;
index 3b9739fb0f143dc6169b06dcfb972737d1de99b3..a330337c5e992b391eeb30e7233d5806714d0b1b 100755 (executable)
@@ -97,7 +97,7 @@ MACRO: pack ( str -- quot )
     packed-length-table at ; inline
 
 : packed-length ( str -- n )
-    [ ch>packed-length ] sigma ;
+    [ ch>packed-length ] map-sum ;
  
 : pack-native ( seq str -- seq )
     '[ _ _ pack ] with-native-endian ; inline
index 136007e7ce01114371181ff21cb133a346e88805..5ddd5f9bf08e04699ac9ce3bdf16b145553b762d 100644 (file)
@@ -445,16 +445,16 @@ M: ebnf-sequence build-locals ( code ast -- code )
       drop \r
     ] [ \r
       [\r
-        "FROM: locals => [let* ; FROM: sequences => nth ; [let* | " %\r
-          dup length swap [\r
-            dup ebnf-var? [\r
+        "FROM: locals => [let :> ; FROM: sequences => nth ; [let " %\r
+          dup length [\r
+            over ebnf-var? [\r
+              " " % # " over nth :> " %\r
               name>> % \r
-              " [ " % # " over nth ] " %\r
             ] [\r
               2drop\r
             ] if\r
           ] 2each\r
-          " " %\r
+          " " %\r
           %  \r
           " nip ]" %     \r
       ] "" make \r
@@ -463,9 +463,9 @@ M: ebnf-sequence build-locals ( code ast -- code )
 \r
 M: ebnf-var build-locals ( code ast -- )\r
   [\r
-    "FROM: locals => [let* ; FROM: kernel => dup nip ; [let* | " %\r
-    name>> % " [ dup ] " %\r
-    " " %\r
+    "FROM: locals => [let :> ; FROM: kernel => dup nip ; [let " %\r
+    " dup :> " % name>> %\r
+    " " %\r
     %  \r
     " nip ]" %     \r
   ] "" make ;\r
@@ -547,12 +547,12 @@ PRIVATE>
 SYNTAX: <EBNF\r
   "EBNF>"\r
   reset-tokenizer parse-multiline-string parse-ebnf main swap at  \r
-  parsed reset-tokenizer ;\r
+  suffix! reset-tokenizer ;\r
 \r
 SYNTAX: [EBNF\r
   "EBNF]"\r
   reset-tokenizer parse-multiline-string ebnf>quot nip \r
-  parsed \ call parsed reset-tokenizer ;\r
+  suffix! \ call suffix! reset-tokenizer ;\r
 \r
 SYNTAX: EBNF: \r
   reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string  \r
index 850b585190646384904f7ec17f1785f7c593dc61..c8a8080f38f4ac9df3ded6272bd4f30093913ca3 100644 (file)
@@ -40,7 +40,7 @@ M: just-parser (compile) ( parser -- quot )
 <PRIVATE
 
 : flatten-vectors ( pair -- vector )
-  first2 over push-all ;
+  first2 append! ;
 
 PRIVATE>
 
index 9e777b86afe384e976a3774e7ef77a0e4916134f..d4397627e809d216665762b075b8360e0d837d33 100644 (file)
@@ -172,9 +172,7 @@ TUPLE: peg-head rule-id involved-set eval-set ;
   l lrstack get (setup-lr) ;
 
 :: lr-answer ( r p m -- ast )
-  [let* |
-          h [ m ans>> head>> ]
-        |
+    m ans>> head>> :> h
     h rule-id>> r rule-id eq? [
       m ans>> seed>> m (>>ans)
       m ans>> failed? [
@@ -184,14 +182,11 @@ TUPLE: peg-head rule-id involved-set eval-set ;
       ] if
     ] [
       m ans>> seed>>
-    ] if
-  ] ; inline
+    ] if ; inline
 
 :: recall ( r p -- memo-entry )
-  [let* |
-          m [ p r rule-id memo ]
-          h [ p heads at ]
-        |
+    p r rule-id memo :> m
+    p heads at :> h
     h [
       m r rule-id h involved-set>> h rule-id>> suffix member? not and [
         fail p memo-entry boa
@@ -207,15 +202,12 @@ TUPLE: peg-head rule-id involved-set eval-set ;
       ] if
     ] [
       m
-    ] if
-  ] ; inline
+    ] if ; inline
 
 :: apply-non-memo-rule ( r p -- ast )
-  [let* |
-          lr  [ fail r rule-id f lrstack get left-recursion boa ]
-          m   [ lr lrstack set lr p memo-entry boa dup p r rule-id set-memo ]
-          ans [ r eval-rule ]
-        |
+    fail r rule-id f lrstack get left-recursion boa :> lr
+    lr lrstack set lr p memo-entry boa dup p r rule-id set-memo :> m
+    r eval-rule :> ans
     lrstack get next>> lrstack set
     pos get m (>>pos)
     lr head>> [
@@ -226,8 +218,7 @@ TUPLE: peg-head rule-id involved-set eval-set ;
     ] [
       ans m (>>ans)
       ans
-    ] if
-  ] ; inline
+    ] if ; inline
 
 : apply-memo-rule ( r m -- ast )
   [ ans>> ] [ pos>> ] bi pos set
@@ -622,20 +613,19 @@ PRIVATE>
 ERROR: parse-failed input word ;
 
 SYNTAX: PEG:
-  (:)
-  [let | effect [ ] def [ ] word [ ] |
-    [
-      [
-        [let | compiled-def [ def call compile ] |
+    [let
+        (:) :> ( word def effect )
+        [
           [
-            dup compiled-def compiled-parse
-            [ ast>> ] [ word parse-failed ] ?if
-          ]
-          word swap effect define-declared
-        ]
-      ] with-compilation-unit
-    ] over push-all
-  ] ;
+            def call compile :> compiled-def
+            [
+              dup compiled-def compiled-parse
+              [ ast>> ] [ word parse-failed ] ?if
+            ]
+            word swap effect define-declared
+          ] with-compilation-unit
+        ] append!
+    ] ;
 
 USING: vocabs vocabs.loader ;
 
index cb2abd801568773df3bcb066be453b4ef2d678dc..190db9e9ab88d0342c3661ee61e4f6f16d2bd527 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: layouts kernel parser math ;
+USING: layouts kernel parser math sequences ;
 IN: persistent.hashtables.config
 
-: radix-bits ( -- n ) << cell 4 = 4 5 ? parsed >> ; foldable
+: radix-bits ( -- n ) << cell 4 = 4 5 ? suffix! >> ; foldable
 : radix-mask ( -- n ) radix-bits 2^ 1 - ; foldable
 : full-bitmap-mask ( -- n ) radix-bits 2^ 2^ 1 - ; inline
index eea31dd34e700c5475d231658dea0468da04ae29..d66fdd0c089eaacd055ef5926006c17123d4267a 100644 (file)
@@ -1,6 +1,6 @@
 IN: persistent.hashtables.tests
 USING: persistent.hashtables persistent.assocs hashtables assocs
-tools.test kernel namespaces random math.ranges sequences fry ;
+tools.test kernel locals namespaces random math.ranges sequences fry ;
 
 [ t ] [ PH{ } assoc-empty? ] unit-test
 
@@ -86,7 +86,7 @@ M: hash-0-b hashcode* 2drop 0 ;
 : random-assocs ( n -- hash phash )
     [ random-string ] replicate
     [ H{ } clone [ '[ swap _ set-at ] each-index ] keep ]
-    [ PH{ } clone swap [ spin new-at ] each-index ]
+    [ PH{ } clone swap [| ph elt i | i elt ph new-at ] each-index ]
     bi ;
 
 : ok? ( assoc1 assoc2 -- ? )
index 0179216e62a7acc1f0a474e613695316dac56150..256baabd5ed825c457cf8b72a73cfad945286092 100644 (file)
@@ -1,7 +1,7 @@
 ! Based on Clojure's PersistentHashMap by Rich Hickey.
 
 USING: kernel math accessors assocs fry combinators parser
-prettyprint.custom make
+prettyprint.custom locals make
 persistent.assocs
 persistent.hashtables.nodes
 persistent.hashtables.nodes.empty
@@ -38,8 +38,8 @@ M: persistent-hash pluck-at
 
 M: persistent-hash >alist [ root>> >alist% ] { } make ;
 
-: >persistent-hash ( assoc -- phash )
-    T{ persistent-hash } swap [ spin new-at ] assoc-each ;
+:: >persistent-hash ( assoc -- phash )
+    T{ persistent-hash } assoc [| ph k v | v k ph new-at ] assoc-each ;
 
 M: persistent-hash equal?
     over persistent-hash? [ assoc= ] [ 2drop f ] if ;
index 4c764eba9331d2bbdfeeb407e41758b054a51ccd..d623e900192dd5e2696aa7cb67c4945b26c29298 100644 (file)
@@ -10,77 +10,70 @@ IN: persistent.hashtables.nodes.bitmap
 : 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>> ]
-            bit [ hashcode shift bitpos ]
-            bitmap [ bitmap-node bitmap>> ]
-            nodes [ bitmap-node nodes>> ] |
-       bitmap bit bitand 0 eq? [ f ] [
-           key hashcode
-           bit bitmap index nodes nth-unsafe
-           (entry-at)
-        ] if
-    ] ;
+    bitmap-node shift>> :> shift
+    hashcode shift bitpos :> bit
+    bitmap-node bitmap>> :> bitmap
+    bitmap-node nodes>> :> nodes
+    bitmap bit bitand 0 eq? [ f ] [
+        key hashcode
+        bit bitmap index nodes nth-unsafe
+        (entry-at)
+    ] if ;
 
 M:: bitmap-node (new-at) ( shift value key hashcode bitmap-node -- node' added-leaf )
-    [let* | shift [ bitmap-node shift>> ]
-            bit [ hashcode shift bitpos ]
-            bitmap [ bitmap-node bitmap>> ]
-            idx [ bit bitmap index ]
-            nodes [ bitmap-node nodes>> ] |
-        bitmap bit bitand 0 eq? [
-            [let | new-leaf [ value key hashcode <leaf-node> ] |
-                bitmap bit bitor
-                new-leaf idx nodes insert-nth
-                shift
-                <bitmap-node>
-                new-leaf
-            ]
+    bitmap-node shift>> :> shift
+    hashcode shift bitpos :> bit
+    bitmap-node bitmap>> :> bitmap
+    bit bitmap index :> idx
+    bitmap-node nodes>> :> nodes
+
+    bitmap bit bitand 0 eq? [
+        value key hashcode <leaf-node> :> new-leaf
+        bitmap bit bitor
+        new-leaf idx nodes insert-nth
+        shift
+        <bitmap-node>
+        new-leaf
+    ] [
+        idx nodes nth :> n
+        shift radix-bits + value key hashcode n (new-at) :> ( n' new-leaf )
+        n n' eq? [
+            bitmap-node
         ] [
-            [let | n [ idx nodes nth ] |
-                shift radix-bits + value key hashcode n (new-at)
-                [let | new-leaf [ ] n' [ ] |
-                    n n' eq? [
-                        bitmap-node
-                    ] [
-                        bitmap
-                        n' idx nodes new-nth
-                        shift
-                        <bitmap-node>
-                    ] if
-                    new-leaf
-                ]
-            ]
+            bitmap
+            n' idx nodes new-nth
+            shift
+            <bitmap-node>
         ] if
-    ] ;
+        new-leaf
+    ] if ;
 
 M:: bitmap-node (pluck-at) ( key hashcode bitmap-node -- node' )
-    [let | bit [ hashcode bitmap-node shift>> bitpos ]
-           bitmap [ bitmap-node bitmap>> ]
-           nodes [ bitmap-node nodes>> ]
-           shift [ bitmap-node shift>> ] |
-           bit bitmap bitand 0 eq? [ bitmap-node ] [
-            [let* | idx [ bit bitmap index ]
-                    n [ idx nodes nth-unsafe ]
-                    n' [ key hashcode n (pluck-at) ] |
-                n n' eq? [
-                    bitmap-node
-                ] [
-                    n' [
-                        bitmap
-                        n' idx nodes new-nth
-                        shift
-                        <bitmap-node>
-                    ] [
-                        bitmap bit eq? [ f ] [
-                            bitmap bit bitnot bitand
-                            idx nodes remove-nth
-                            shift
-                            <bitmap-node>
-                        ] if
-                    ] if
+    hashcode bitmap-node shift>> bitpos :> bit
+    bitmap-node bitmap>> :> bitmap
+    bitmap-node nodes>> :> nodes
+    bitmap-node shift>> :> shift
+    bit bitmap bitand 0 eq? [ bitmap-node ] [
+        bit bitmap index :> idx
+        idx nodes nth-unsafe :> n
+        key hashcode n (pluck-at) :> n'
+        n n' eq? [
+            bitmap-node
+        ] [
+            n' [
+                bitmap
+                n' idx nodes new-nth
+                shift
+                <bitmap-node>
+            ] [
+                bitmap bit eq? [ f ] [
+                    bitmap bit bitnot bitand
+                    idx nodes remove-nth
+                    shift
+                    <bitmap-node>
                 ] if
-            ]
+            ] if
         ] if
-    ] ;
+    ] if ;
 
 M: bitmap-node >alist% ( node -- ) nodes>> >alist-each% ;
index 2ee4008f2b437ce7e159f474a8ae7cd4bacaade4..3d1612862a3b46d9d0059bceeafef770048f1538 100644 (file)
@@ -15,43 +15,39 @@ M:: collision-node (entry-at) ( key hashcode collision-node -- leaf-node )
 
 M:: collision-node (pluck-at) ( key hashcode collision-node -- leaf-node )
     hashcode collision-node hashcode>> eq? [
-        [let | idx [ key hashcode collision-node find-index drop ] |
-            idx [
-                idx collision-node leaves>> smash [
-                    collision-node hashcode>>
-                    <collision-node>
-                ] when
-            ] [ collision-node ] if
-        ]
+        key hashcode collision-node find-index drop :> idx
+        idx [
+            idx collision-node leaves>> smash [
+                collision-node hashcode>>
+                <collision-node>
+            ] when
+        ] [ collision-node ] if
     ] [ collision-node ] if ;
 
 M:: collision-node (new-at) ( shift value key hashcode collision-node -- node' added-leaf )
     hashcode collision-node hashcode>> eq? [
-        key hashcode collision-node find-index
-        [let | leaf-node [ ] idx [ ] |
-            idx [
-                value leaf-node value>> = [
-                    collision-node f
-                ] [
-                    hashcode
-                    value key hashcode <leaf-node>
-                    idx
-                    collision-node leaves>>
-                    new-nth
-                    <collision-node>
-                    f
-                ] if
+        key hashcode collision-node find-index :> ( idx leaf-node )
+        idx [
+            value leaf-node value>> = [
+                collision-node f
             ] [
-                [let | new-leaf-node [ value key hashcode <leaf-node> ] |
-                    hashcode
-                    collision-node leaves>>
-                    new-leaf-node
-                    suffix
-                    <collision-node>
-                    new-leaf-node
-                ]
+                hashcode
+                value key hashcode <leaf-node>
+                idx
+                collision-node leaves>>
+                new-nth
+                <collision-node>
+                f
             ] if
-        ]
+        ] [
+            value key hashcode <leaf-node> :> new-leaf-node
+            hashcode
+            collision-node leaves>>
+            new-leaf-node
+            suffix
+            <collision-node>
+            new-leaf-node
+        ] if
     ] [
         shift collision-node value key hashcode make-bitmap-node
     ] if ;
index 5c60c91dca39aa53d91fe2139264226e83496f45..5a9cc2506d2fe79e6fc1e92c00d13f710c347866 100644 (file)
@@ -8,39 +8,37 @@ persistent.hashtables.nodes ;
 IN: persistent.hashtables.nodes.full
 
 M:: full-node (new-at) ( shift value key hashcode full-node -- node' added-leaf )
-    [let* | nodes [ full-node nodes>> ] 
-            idx [ hashcode full-node shift>> mask ]
-            n [ idx nodes nth-unsafe ] |
-        shift radix-bits + value key hashcode n (new-at)
-        [let | new-leaf [ ] n' [ ] |
-            n n' eq? [
-                full-node
-            ] [
-                n' idx nodes new-nth shift <full-node>
-            ] if
-            new-leaf
-        ]
-    ] ;
+    full-node nodes>> :> nodes
+    hashcode full-node shift>> mask :> idx
+    idx nodes nth-unsafe :> n
+
+    shift radix-bits + value key hashcode n (new-at) :> ( n' new-leaf )
+    n n' eq? [
+        full-node
+    ] [
+        n' idx nodes new-nth shift <full-node>
+    ] if
+    new-leaf ;
 
 M:: full-node (pluck-at) ( key hashcode full-node -- node' )
-    [let* | idx [ hashcode full-node shift>> mask ]
-            n [ idx full-node nodes>> nth ]
-            n' [ key hashcode n (pluck-at) ] |
-        n n' eq? [
-            full-node
+    hashcode full-node shift>> mask :> idx
+    idx full-node nodes>> nth :> n
+    key hashcode n (pluck-at) :> n'
+
+    n n' eq? [
+        full-node
+    ] [
+        n' [
+            n' idx full-node nodes>> new-nth
+            full-node shift>>
+            <full-node>
         ] [
-            n' [
-                n' idx full-node nodes>> new-nth
-                full-node shift>>
-                <full-node>
-            ] [
-                hashcode full-node shift>> bitpos bitnot full-bitmap-mask bitand
-                idx full-node nodes>> remove-nth
-                full-node shift>>
-                <bitmap-node>
-            ] if
+            hashcode full-node shift>> bitpos bitnot full-bitmap-mask bitand
+            idx full-node nodes>> remove-nth
+            full-node shift>>
+            <bitmap-node>
         ] if
-    ] ;
+    ] if ;
 
 M:: full-node (entry-at) ( key hashcode full-node -- node' )
     key hashcode
index 94174d566704019b34a6c976b27d3546f8791616..0a15ea6305f11ff4969ec6c2f8f9d0cd17953ed3 100644 (file)
@@ -19,10 +19,9 @@ M:: leaf-node (new-at) ( shift value key hashcode leaf-node -- node' added-leaf
             value leaf-node value>> =
             [ leaf-node f ] [ value key hashcode <leaf-node> f ] if
         ] [
-            [let | new-leaf [ value key hashcode <leaf-node> ] |
-                hashcode leaf-node new-leaf 2array <collision-node>
-                new-leaf
-            ]
+            value key hashcode <leaf-node> :> new-leaf
+            hashcode leaf-node new-leaf 2array <collision-node>
+            new-leaf
         ] if
     ] [ shift leaf-node value key hashcode make-bitmap-node ] if ;
 
index 49852bac4db6c4e76a322be58c2b68cf2d996b96..31422f23b9c894fec7b493a474db310fb30f10b2 100644 (file)
@@ -18,7 +18,7 @@ HELP: pheap-peek
 { $description "Gets the object in the heap with minumum priority." } ;
 
 HELP: pheap-push
-{ $values { "heap" "a persistent heap" } { "value" object } { "prio" "a priority" } { "newheap" "a new persistent heap" } }
+{ $values { "value" object } { "prio" "a priority" } { "heap" "a persistent heap" } { "newheap" "a new persistent heap" } }
 { $description "Creates a new persistent heap also containing the given object of the given priority." } ;
 
 HELP: pheap-pop*
index 2527959f325f0317cd6540a0c3ab2a625e45f2fe..b02604e9bd8ca02f856a2cd27d1d8c7697cef08a 100644 (file)
@@ -58,7 +58,7 @@ M: persistent-vector nth-unsafe
     [ 2array ] [ drop level>> 1 + ] 2bi node boa ;
 
 : new-child ( new-child node -- node' expansion/f )
-    dup full? [ tuck level>> 1node ] [ node-add f ] if ;
+    dup full? [ [ level>> 1node ] keep swap ] [ node-add f ] if ;
 
 : new-last ( val seq -- seq' )
     [ length 1 - ] keep new-nth ;
@@ -70,7 +70,7 @@ M: persistent-vector nth-unsafe
     dup level>> 1 = [
         new-child
     ] [
-        tuck children>> last (ppush-new-tail)
+        [ nip ] 2keep children>> last (ppush-new-tail)
         [ swap new-child ] [ swap node-set-last f ] ?if
     ] if ;
 
index f919573ea95aed3e6237769a5f19fe02594b9302..04617a6c672cfeed553a89cbcaede6f22bb91e0a 100644 (file)
@@ -116,10 +116,9 @@ M: pathname pprint*
 : check-recursion ( obj quot -- )
     nesting-limit? [
         drop
-        "~" over class name>> "~" 3append
-        swap present-text
+        [ class name>> "~" dup surround ] keep present-text 
     ] [
-        over recursion-check get memq? [
+        over recursion-check get member-eq? [
             drop "~circularity~" swap present-text
         ] [
             over recursion-check get push
@@ -175,7 +174,7 @@ M: tuple pprint*
 : pprint-elements ( seq -- )
     do-length-limit
     [ [ pprint* ] each ] dip
-    [ "~" swap number>string " more~" 3append text ] when* ;
+    [ number>string "~" " more~" surround text ] when* ;
 
 M: quotation pprint-delims drop \ [ \ ] ;
 M: curry pprint-delims drop \ [ \ ] ;
index e17e14f323d24b25552124e439ffb2a1196cd2e8..bd2c4bd924d9dffd0546952f07a6c95436e5812a 100644 (file)
@@ -121,7 +121,7 @@ ARTICLE: "prettyprint-literal" "Literal prettyprinting protocol"
     "    scan-word \\ * assert="
     "    scan-word"
     "    scan-word \\ ] assert="
-    "    <rect> parsed ;"
+    "    <rect> suffix! ;"
 }
 "An example literal might be:"
 { $code "RECT[ 100 * 200 ]" }
index db3331305ee2dbc1e1b49b560a6a024610188e7e..8ba6e94a49539aed5f863d6af48059529a1728d0 100644 (file)
@@ -196,7 +196,7 @@ DEFER: parse-error-file
         "    {"
         "        { [ dup continuation? ] [ append ] }"
         "        { [ dup not ] [ drop reverse ] }"
-        "        { [ dup pair? ] [ [ delete ] keep ] }"
+        "        { [ dup pair? ] [ [ remove! drop ] keep ] }"
         "    } cond ;"
     } ;
 
index 718de7e84c38174525ce4f0e5cf8bebf1607d798..6cff3992019b36f43cac5645b7275a3c4091c9a4 100644 (file)
@@ -110,3 +110,7 @@ SYMBOL: pprint-string-cells?
             ] with-row
         ] each
     ] tabular-output nl ;
+
+: object-table. ( obj alist -- )
+    [ [ nip first ] [ second call( obj -- str ) ] 2bi 2array ] with map
+    simple-table. ;
index e258cb9a96d48327369e8708662ca376cb4a1863..2a3239c72faa20d0c12e654b63a1162e46122220 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.test quoted-printable io.encodings.string
-sequences io.encodings.8-bit splitting kernel ;
+sequences splitting kernel io.encodings.8-bit.latin2 ;
 IN: quoted-printable.tests
 
 [ """José was the
index 59df4f6e27bc2431a17ad4e3d3d21c4f20a0abdf..788a6e700a45b3b92cf0a4c4d98b1027243fb4df 100755 (executable)
@@ -96,7 +96,7 @@ HELP: delete-random
 { $values
      { "seq" sequence }
      { "elt" object } }
-{ $description "Deletes a random number from a sequence using " { $link delete-nth } " and returns the deleted object." } ;
+{ $description "Deletes a random number from a sequence using " { $link remove-nth! } " and returns the deleted object." } ;
 
 ARTICLE: "random-protocol" "Random protocol"
 "A random number generator must implement one of these two words:"
index 197c2324046bf5461e3485d5c43ca2ccc251ca3d..bfd107dbb64772824b5757e79a0c796296bbdd2e 100755 (executable)
@@ -19,7 +19,7 @@ M: object random-bytes* ( n tuple -- byte-array )
     [ pick '[ _ random-32* 4 >le _ push-all ] times ]
     [
         over zero?
-        [ 2drop ] [ random-32* 4 >le swap head over push-all ] if
+        [ 2drop ] [ random-32* 4 >le swap head append! ] if
     ] bi-curry bi* ;
 
 M: object random-32* ( tuple -- r ) 4 swap random-bytes* le> ;
@@ -82,7 +82,7 @@ PRIVATE>
     '[ _ dup random _ _ next-sample ] replicate ;
 
 : delete-random ( seq -- elt )
-    [ length random-integer ] keep [ nth ] 2keep delete-nth ;
+    [ length random-integer ] keep [ nth ] 2keep remove-nth! drop ;
 
 : with-random ( tuple quot -- )
     random-generator swap with-variable ; inline
index 2de4e8b0e02322d7a3391c86f607944d18125ace..fa75232fd5c0b7472da6c765b6bca3b60a43aa8b 100644 (file)
@@ -25,7 +25,7 @@ IN: regexp.dfa
     ] unless ;
 
 : epsilon-table ( states nfa -- table )
-    [ H{ } clone tuck ] dip
+    [ [ H{ } clone ] dip over ] dip
     '[ _ _ t epsilon-loop ] each ;
 
 : find-epsilon-closure ( states nfa -- dfa-state )
index 876d898cb4e48ca36ad058bf5758b704bdbc7f4e..fcde135cf887c0fb1af245ef8332f1d634624f91 100644 (file)
@@ -44,12 +44,12 @@ TUPLE: parts in out ;
         [ _ meaningful-integers ] keep add-out
     ] map ;
 
-: class-partitions ( classes -- assoc )
-    [ integer? ] partition [
-        dup powerset-partition spin add-integers
-        [ [ partition>class ] keep 2array ] map
-        [ first ] filter
-    ] [ '[ _ singleton-partition ] map ] 2bi append ;
+:: class-partitions ( classes -- assoc )
+    classes [ integer? ] partition :> ( integers classes )
+    
+    classes powerset-partition classes integers add-integers
+    [ [ partition>class ] keep 2array ] map [ first ] filter
+    integers [ classes singleton-partition ] map append ;
 
 : new-transitions ( transitions -- assoc ) ! assoc is class, partition
     values [ keys ] gather
index 1885144e6ccb45937d7aa3d8174fa37aa5870ff5..a6eb4f00a288dbf752ccd8a1d2fd74aa9b441321 100644 (file)
@@ -85,7 +85,7 @@ IN: regexp.minimize
     '[ _ delete-duplicates ] change-transitions ;
 
 : combine-state-transitions ( hash -- hash )
-    H{ } clone tuck '[
+    [ H{ } clone ] dip over '[
         _ [ 2array <or-class> ] change-at
     ] assoc-each [ swap ] assoc-map ;
 
index a692f707780f239754fe7570ce116f580f304542..35edcf328af1afea0b564a3eceb95a087c715df5 100644 (file)
@@ -46,7 +46,7 @@ GENERIC: nfa-node ( node -- start-state end-state )
     epsilon nfa-table get add-transition ;
 
 M:: star nfa-node ( node -- start end )
-    node term>> nfa-node :> s1 :> s0
+    node term>> nfa-node :> ( s0 s1 )
     next-state :> s2
     next-state :> s3
     s1 s0 epsilon-transition
index ba4aa47e7b87f7dcd26ff157cc5b86d4ff25501c..e9a86516cacda4de84ae629e9e30903bccb219aa 100644 (file)
@@ -200,7 +200,7 @@ PRIVATE>
 
 : parsing-regexp ( accum end -- accum )
     lexer get [ take-until ] [ parse-noblank-token ] bi
-    <optioned-regexp> compile-next-match parsed ;
+    <optioned-regexp> compile-next-match suffix! ;
 
 PRIVATE>
 
index a510514e2344cbcd5e6c6f37eb8eb7c204301c7a..c7ab7fafd9177081f2407468dc5ae2bf86184326 100644 (file)
@@ -29,7 +29,7 @@ USING: arrays kernel math roman roman.private sequences tools.test ;
 [ 3444 ] [ 3444 >roman roman> ] unit-test
 [ 3999 ] [ 3999 >roman roman> ] unit-test
 [ 0 >roman ] must-fail
-[ 4000 >roman ] must-fail
+[ 40000 >roman ] must-fail
 [ "vi" ] [ "iii" "iii"  roman+ ] unit-test
 [ "viii" ] [ "x" "ii"  roman- ] unit-test
 [ "ix" ] [ "iii" "iii"  roman* ] unit-test
index 817b6637d6ea4a8fbdb2e3eff3bc2c8bb1a2c9d5..a645898c034e9838c970e2216795ebb15c7b8b2c 100644 (file)
@@ -17,7 +17,7 @@ CONSTANT: roman-values
 ERROR: roman-range-error n ;
 
 : roman-range-check ( n -- n )
-    dup 1 3999 between? [ roman-range-error ] unless ;
+    dup 1 10000 between? [ roman-range-error ] unless ;
 
 : roman-digit-index ( ch -- n )
     1string roman-digits index ; inline
@@ -43,7 +43,7 @@ PRIVATE>
 : >ROMAN ( n -- str ) >roman >upper ;
 
 : roman> ( str -- n )
-    >lower [ roman>= ] monotonic-split [ (roman>) ] sigma ;
+    >lower [ roman>= ] monotonic-split [ (roman>) ] map-sum ;
 
 <PRIVATE
 
@@ -69,4 +69,4 @@ ROMAN-OP: *
 ROMAN-OP: /i
 ROMAN-OP: /mod
 
-SYNTAX: ROMAN: scan roman> parsed ;
+SYNTAX: ROMAN: scan roman> suffix! ;
index ae9d67e29c2174a375b6399a6cb624b2a36e57fc..e8b9ddea6d4bb19aa1de2b368e9ebb3140d48da3 100755 (executable)
@@ -30,10 +30,10 @@ HELP: flatten
 { $values { "obj" object } { "seq" "a sequence" } }
 { $description "Creates a sequence of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ;
 
-HELP: deep-change-each
-{ $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } }
-{ $description "Modifies each sub-node of an object in place, in preorder." }
-{ $see-also change-each } ;
+HELP: deep-map!
+{ $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } { "obj" object } }
+{ $description "Modifies each sub-node of an object in place, in preorder, and returns that object." }
+{ $see-also map! } ;
 
 ARTICLE: "sequences.deep" "Deep sequence combinators"
 "The combinators in the " { $vocab-link "sequences.deep" } " vocabulary are variants of standard sequence combinators which traverse nested subsequences."
@@ -43,7 +43,7 @@ ARTICLE: "sequences.deep" "Deep sequence combinators"
     deep-filter
     deep-find
     deep-any?
-    deep-change-each
+    deep-map!
 }
 "A utility word to collapse nested subsequences:"
 { $subsections flatten } ;
index e26241abc374aadb6cdd2921415ee3aac45a17ed..63611967b9b7f859ee475a0f2cad16009c3fa471 100755 (executable)
@@ -17,7 +17,7 @@ IN: sequences.deep.tests
 [ "hey" 1array 1array [ change-something ] deep-map ] unit-test
 
 [ { { "heyhello" "hihello" } } ]
-[ "hey" 1array 1array [ [ change-something ] deep-change-each ] keep ] unit-test
+[ "hey" 1array 1array [ change-something ] deep-map! ] unit-test
 
 [ t ] [ "foo" [ string? ] deep-any?  ] unit-test
 
index bfc102fdc2c16a9d9218b0b43b4a82a61ce3bc5c..8e01025b94036f8f71ce394578d70e66b0b1f698 100755 (executable)
@@ -48,10 +48,10 @@ M: object branch? drop f ;
         _ swap dup branch? [ subseq? ] [ 2drop f ] if
     ] deep-find >boolean ;
 
-: deep-change-each ( obj quot: ( elt -- elt' ) -- )
+: deep-map! ( obj quot: ( elt -- elt' ) -- obj )
     over branch? [
-        '[ _ [ call ] keep over [ deep-change-each ] dip ] change-each
-    ] [ 2drop ] if ; inline recursive
+        '[ _ [ call ] keep over [ deep-map! drop ] dip ] map!
+    ] [ drop ] if ; inline recursive
 
 : flatten ( obj -- seq )
     [ branch? not ] deep-filter ;
diff --git a/basis/sequences/generalizations/generalizations-docs.factor b/basis/sequences/generalizations/generalizations-docs.factor
new file mode 100644 (file)
index 0000000..7940427
--- /dev/null
@@ -0,0 +1,46 @@
+! (c)2009 Joe Groff bsd license
+USING: help.syntax help.markup kernel sequences quotations
+math arrays combinators ;
+IN: sequences.generalizations
+
+HELP: neach
+{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- )" } } { "n" integer } }
+{ $description "A generalization of " { $link each } ", " { $link 2each } ", and " { $link 3each } " that can iterate over any number of sequences in parallel." } ;
+
+HELP: nmap
+{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- result )" } } { "n" integer } { "result" "a sequence of the same type as the first " { $snippet "seq" } } }
+{ $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel." } ;
+
+HELP: nmap-as
+{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- result )" } } { "exemplar" sequence } { "n" integer } { "result" "a sequence of the same type as " { $snippet "exemplar" } } }
+{ $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel." } ;
+
+HELP: mnmap
+{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( m*element -- result*n )" } } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences of the same type as the first " { $snippet "seq" } } }
+{ $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel and provide any number of output sequences." } ;
+
+HELP: mnmap-as
+{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( m*element -- result*n )" } } { "n*exemplar" { $snippet "n" } " sequences on the datastack" } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } }
+{ $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel and provide any number of output sequences of distinct types." } ;
+
+HELP: nproduce
+{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "n" integer } { "seq..." { $snippet "n" } " arrays on the datastack" } }
+{ $description "A generalization of " { $link produce } " that generates " { $snippet "n" } " arrays in parallel by calling " { $snippet "quot" } " repeatedly until " { $snippet "pred" } " outputs false." } ;
+
+HELP: nproduce-as
+{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "...exemplar" { $snippet "n" } " sequences on the datastack" } { "n" integer } { "seq..." { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } }
+{ $description "A generalization of " { $link produce-as } " that generates " { $snippet "n" } " sequences in parallel by calling " { $snippet "quot" } " repeatedly until " { $snippet "pred" } " outputs false." } ;
+
+ARTICLE: "sequences.generalizations" "Generalized sequence iteration combinators"
+"The " { $vocab-link "sequences.generalizations" } " vocabulary defines generalized versions of the iteration " { $link "sequences-combinators" } "."
+{ $subsections
+    neach
+    nmap
+    nmap-as
+    mnmap
+    mnmap-as
+    nproduce
+    nproduce-as
+} ;
+
+ABOUT: "sequences.generalizations"
diff --git a/basis/sequences/generalizations/generalizations-tests.factor b/basis/sequences/generalizations/generalizations-tests.factor
new file mode 100644 (file)
index 0000000..d1861b8
--- /dev/null
@@ -0,0 +1,120 @@
+! (c)2009 Joe Groff bsd license
+USING: tools.test generalizations kernel math arrays sequences
+sequences.generalizations ascii fry math.parser io io.streams.string ;
+IN: sequences.generalizations.tests
+
+: neach-test ( a b c d -- )
+    [ 4 nappend print ] 4 neach ;
+: nmap-test ( a b c d -- e )
+    [ 4 nappend ] 4 nmap ;
+: nmap-as-test ( a b c d -- e )
+    [ 4 nappend ] [ ] 4 nmap-as ;
+: mnmap-3-test ( a b c d -- e f g )
+    [ append ] 4 3 mnmap ;
+: mnmap-2-test ( a b c d -- e f )
+    [ [ append ] 2bi@ ] 4 2 mnmap ;
+: mnmap-as-test ( a b c d -- e f )
+    [ [ append ] 2bi@ ] { } [ ] 4 2 mnmap-as ;
+: mnmap-1-test ( a b c d -- e )
+    [ 4 nappend ] 4 1 mnmap ;
+: mnmap-0-test ( a b c d -- )
+    [ 4 nappend print ] 4 0 mnmap ;
+: nproduce-as-test ( n -- a b )
+    [ dup zero? not ]
+    [ [ 2 - ] [ ] [ 1 - ] tri ] { } B{ } 2 nproduce-as
+    [ drop ] 2dip ;
+: nproduce-test ( n -- a b )
+    [ dup zero? not ]
+    [ [ 2 - ] [ ] [ 1 - ] tri ] 2 nproduce
+    [ drop ] 2dip ;
+
+[ """A1a!
+B2b@
+C3c#
+D4d$
+""" ] [
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    [ neach-test ] with-string-writer
+] unit-test
+
+[ { "A1a!" "B2b@" "C3c#" "D4d$" } ]
+[ 
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    nmap-test
+] unit-test
+
+[ [ "A1a!" "B2b@" "C3c#" "D4d$" ] ]
+[ 
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    nmap-as-test
+] unit-test
+
+[
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a!" "b@" "c#" "d$" }
+] [ 
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    mnmap-3-test
+] unit-test
+
+[
+    { "A1" "B2" "C3" "D4" }
+    { "a!" "b@" "c#" "d$" }
+] [ 
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    mnmap-2-test
+] unit-test
+
+[
+    { "A1" "B2" "C3" "D4" }
+    [ "a!" "b@" "c#" "d$" ]
+] [ 
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    mnmap-as-test
+] unit-test
+
+[ { "A1a!" "B2b@" "C3c#" "D4d$" } ]
+[ 
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    mnmap-1-test
+] unit-test
+
+[ """A1a!
+B2b@
+C3c#
+D4d$
+""" ] [
+    { "A" "B" "C" "D" }
+    { "1" "2" "3" "4" }
+    { "a" "b" "c" "d" }
+    { "!" "@" "#" "$" }
+    [ mnmap-0-test ] with-string-writer
+] unit-test
+
+[ { 10 8 6 4 2 } B{ 9 7 5 3 1 } ]
+[ 10 nproduce-as-test ] unit-test
+
+[ { 10 8 6 4 2 } { 9 7 5 3 1 } ]
+[ 10 nproduce-test ] unit-test
diff --git a/basis/sequences/generalizations/generalizations.factor b/basis/sequences/generalizations/generalizations.factor
new file mode 100644 (file)
index 0000000..210b27f
--- /dev/null
@@ -0,0 +1,79 @@
+! (c)2009 Joe Groff bsd license
+USING: kernel sequences sequences.private math
+combinators macros math.order math.ranges quotations fry effects
+memoize.private generalizations ;
+IN: sequences.generalizations
+
+MACRO: nmin-length ( n -- )
+    dup 1 - [ min ] n*quot
+    '[ [ length ] _ napply @ ] ;
+
+: nnth-unsafe ( n ...seq n -- )
+    [ nth-unsafe ] swap [ apply-curry ] [ cleave* ] bi ; inline
+MACRO: nset-nth-unsafe ( n -- )
+    [ [ drop ] ]
+    [ '[ [ set-nth-unsafe ] _ [ apply-curry ] [ cleave-curry ] [ spread* ] tri ] ]
+    if-zero ;
+
+: (neach) ( ...seq quot n -- len quot' )
+    dup dup dup
+    '[ [ _ nmin-length ] _ nkeep [ _ nnth-unsafe ] _ ncurry ] dip compose ; inline
+
+: neach ( ...seq quot n -- )
+    (neach) each-integer ; inline
+
+: nmap-as ( ...seq quot exemplar n -- result )
+    '[ _ (neach) ] dip map-integers ; inline
+
+: nmap ( ...seq quot n -- result )
+    dup '[ [ _ npick ] dip swap ] dip nmap-as ; inline
+
+MACRO: nnew-sequence ( n -- )
+    [ [ drop ] ]
+    [ dup '[ [ new-sequence ] _ apply-curry _ cleave* ] ] if-zero ;
+
+: nnew-like ( len ...exemplar quot n -- result... )
+    5 dupn '[
+        _ nover
+        [ [ _ nnew-sequence ] dip call ]
+        _ ndip [ like ]
+        _ apply-curry
+        _ spread*
+    ] call ; inline
+
+MACRO: (ncollect) ( n -- )
+    3 dupn 1 +
+    '[ [ [ keep ] _ ndip _ nset-nth-unsafe ] _ ncurry ] ;
+
+: ncollect ( len quot ...into n -- )
+    (ncollect) each-integer ; inline
+
+: nmap-integers ( len quot ...exemplar n -- result... )
+    4 dupn
+    '[ [ over ] _ ndip [ [ _ ncollect ] _ nkeep ] _ nnew-like ] call ; inline
+
+: mnmap-as ( m*seq quot n*exemplar m n -- result*n )
+    dup '[ [ _ (neach) ] _ ndip _ nmap-integers ] call ; inline
+
+: mnmap ( m*seq quot m n -- result*n )
+    2dup '[ [ _ npick ] dip swap _ dupn ] 2dip mnmap-as ; inline
+
+: naccumulator-for ( quot ...exemplar n -- quot' vec... )
+    5 dupn '[
+        [ [ length ] keep new-resizable ] _ napply
+        [ [ [ push ] _ apply-curry _ spread* ] _ ncurry compose ] _ nkeep
+    ] call ; inline
+
+: naccumulator ( quot n -- quot' vec... )
+    [ V{ } swap dupn ] keep naccumulator-for ; inline
+
+: nproduce-as ( pred quot ...exemplar n -- seq... )
+    7 dupn '[
+        _ ndup
+        [ _ naccumulator-for [ while ] _ ndip ]
+        _ ncurry _ ndip
+        [ like ] _ apply-curry _ spread*
+    ] call ; inline
+
+: nproduce ( pred quot n -- seq... )
+    [ { } swap dupn ] keep nproduce-as ; inline
diff --git a/basis/sequences/merged/authors.txt b/basis/sequences/merged/authors.txt
new file mode 100644 (file)
index 0000000..e9c193b
--- /dev/null
@@ -0,0 +1 @@
+Alex Chapman
diff --git a/basis/sequences/merged/merged-docs.factor b/basis/sequences/merged/merged-docs.factor
new file mode 100644 (file)
index 0000000..9b98cd1
--- /dev/null
@@ -0,0 +1,53 @@
+USING: help.markup help.syntax sequences ;
+IN: sequences.merged
+
+ARTICLE: "sequences-merge" "Merging sequences"
+"When multiple sequences are merged into one sequence, the new sequence takes an element from each input sequence in turn. For example, if we merge " { $code "{ 1 2 3 }" } "and" { $code "{ \"a\" \"b\" \"c\" }" } "we get:" { $code "{ 1 \"a\" 2 \"b\" 3 \"c\" }" } "."
+{ $subsections
+    merge
+    2merge
+    3merge
+    <merged>
+    <2merged>
+    <3merged>
+} ;
+
+ABOUT: "sequences-merge"
+
+HELP: merged
+{ $class-description "A virtual sequence which presents a merged view of its underlying elements. New instances are created by calling one of " { $link <merged> } ", " { $link <2merged> } ", or " { $link <3merged> } "." }
+{ $see-also merge } ;
+
+HELP: <merged> ( seqs -- merged )
+{ $values { "seqs" "a sequence of sequences to merge" } { "merged" "a virtual sequence" } }
+{ $description "Creates an instance of the " { $link merged } " virtual sequence. The length of the created virtual sequences is the minimum length of the input sequences times the number of input sequences." }
+{ $see-also <2merged> <3merged> merge } ;
+
+HELP: <2merged> ( seq1 seq2 -- merged )
+{ $values { "seq1" sequence } { "seq2" sequence } { "merged" "a virtual sequence" } }
+{ $description "Creates an instance of the " { $link merged } " virtual sequence which merges the two input sequences." }
+{ $see-also <merged> <3merged> 2merge } ;
+
+HELP: <3merged> ( seq1 seq2 seq3 -- merged )
+{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "merged" "a virtual sequence" } }
+{ $description "Creates an instance of the " { $link merged } " virtual sequence which merges the three input sequences." }
+{ $see-also <merged> <2merged> 3merge } ;
+
+HELP: merge ( seqs -- seq )
+{ $values { "seqs" "a sequence of sequences to merge" } { "seq" "a new sequence" } }
+{ $description "Outputs a new sequence which merges the elements of each sequence in " { $snippet "seqs" } "." }
+{ $examples
+    { $example "USING: prettyprint sequences.merged ;" "{ { 1 2 } { 3 4 } { 5 6 } } merge ." "{ 1 3 5 2 4 6 }" }
+    { $example "USING: prettyprint sequences.merged ;" "{ \"abc\" \"def\" } merge ." "\"adbecf\"" }
+}
+{ $see-also 2merge 3merge <merged> } ;
+
+HELP: 2merge ( seq1 seq2 -- seq )
+{ $values { "seq1" sequence } { "seq2" sequence } { "seq" "a new sequence" } }
+{ $description "Creates a new sequence of the same type as " { $snippet "seq1" } " which merges the elements of " { $snippet "seq1" } " and " { $snippet "seq2" } }
+{ $see-also merge 3merge <2merged> } ;
+
+HELP: 3merge ( seq1 seq2 seq3 -- seq )
+{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "seq" "a new sequence" } }
+{ $description "Creates a new sequence of the same type as " { $snippet "seq1" } " which merges the elements of all three sequences" }
+{ $see-also merge 2merge <3merged> } ;
diff --git a/basis/sequences/merged/merged-tests.factor b/basis/sequences/merged/merged-tests.factor
new file mode 100644 (file)
index 0000000..cbd4176
--- /dev/null
@@ -0,0 +1,20 @@
+USING: sequences sequences.merged tools.test ;
+IN: sequences.merged.tests
+
+[ 0 { 1 2 } ] [ 0 T{ merged f { { 1 2 } { 3 4 } } } virtual@ ] unit-test
+[ 0 { 3 4 } ] [ 1 T{ merged f { { 1 2 } { 3 4 } } } virtual@ ] unit-test
+[ 1 { 1 2 } ] [ 2 T{ merged f { { 1 2 } { 3 4 } } } virtual@ ] unit-test
+[ 4 ] [ 3 { { 1 2 3 4 } } <merged> nth ] unit-test
+[ 4 { { 1 2 3 4 } } <merged> nth ] must-fail
+
+[ 1 ] [ 0 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
+[ 4 ] [ 1 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
+[ 2 ] [ 2 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
+[ 5 ] [ 3 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
+[ 3 ] [ 4 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
+[ 6 ] [ 5 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
+
+[ 4 ] [ 4 { 1 2 } { 3 4 } { 5 6 } 3merge nth ] unit-test
+
+[ "" ] [ "abcdefg" "" 2merge ] unit-test
+[ "a1b2" ] [ "abc" "12" <2merged> "" like ] unit-test
diff --git a/basis/sequences/merged/merged.factor b/basis/sequences/merged/merged.factor
new file mode 100644 (file)
index 0000000..c14ccf2
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2008 Alex Chapman
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors arrays kernel math math.order sequences
+sequences.private ;
+IN: sequences.merged
+
+TUPLE: merged seqs ;
+C: <merged> merged
+
+: <2merged> ( seq1 seq2 -- merged ) 2array <merged> ;
+: <3merged> ( seq1 seq2 seq3 -- merged ) 3array <merged> ;
+
+: merge ( seqs -- seq )
+    [ <merged> ] keep first like ;
+
+: 2merge ( seq1 seq2 -- seq )
+    [ <2merged> ] 2keep drop like ;
+
+: 3merge ( seq1 seq2 seq3 -- seq )
+    [ <3merged> ] 3keep 2drop like ;
+
+M: merged length
+    seqs>> [ [ length ] [ min ] map-reduce ] [ length ] bi * ; inline
+
+M: merged virtual@ ( n seq -- n' seq' )
+    seqs>> [ length /mod ] [ nth-unsafe ] bi ; inline
+
+M: merged virtual-exemplar ( merged -- seq )
+    seqs>> [ f ] [ first ] if-empty ; inline
+
+INSTANCE: merged virtual-sequence
diff --git a/basis/sequences/merged/summary.txt b/basis/sequences/merged/summary.txt
new file mode 100644 (file)
index 0000000..1a514df
--- /dev/null
@@ -0,0 +1 @@
+A virtual sequence which merges (interleaves) other sequences.
diff --git a/basis/sequences/merged/tags.txt b/basis/sequences/merged/tags.txt
new file mode 100644 (file)
index 0000000..42d711b
--- /dev/null
@@ -0,0 +1 @@
+collections
diff --git a/basis/sequences/parser/authors.txt b/basis/sequences/parser/authors.txt
new file mode 100644 (file)
index 0000000..a07c427
--- /dev/null
@@ -0,0 +1,2 @@
+Daniel Ehrenberg
+Doug Coleman
diff --git a/basis/sequences/parser/parser-tests.factor b/basis/sequences/parser/parser-tests.factor
new file mode 100644 (file)
index 0000000..0c4f139
--- /dev/null
@@ -0,0 +1,106 @@
+USING: tools.test sequences.parser unicode.categories kernel
+accessors ;
+IN: sequences.parser.tests
+
+[ "hello" ]
+[ "hello" [ take-rest ] parse-sequence ] unit-test
+
+[ "hi" " how are you?" ]
+[
+    "hi how are you?"
+    [ [ [ current blank? ] take-until ] [ take-rest ] bi ] parse-sequence
+] unit-test
+
+[ "foo" ";bar" ]
+[
+    "foo;bar" [
+        [ CHAR: ; take-until-object ] [ take-rest ] bi
+    ] parse-sequence
+] unit-test
+
+[ "foo " "and bar" ]
+[
+    "foo and bar" [
+        [ "and" take-until-sequence ] [ take-rest ] bi 
+    ] parse-sequence
+] unit-test
+
+[ "foo " " bar" ]
+[
+    "foo and bar" [
+        [ "and" take-until-sequence ]
+        [ "and" take-sequence drop ]
+        [ take-rest ] tri
+    ] parse-sequence
+] unit-test
+
+[ "foo " " bar" ]
+[
+    "foo and bar" [
+        [ "and" take-until-sequence* ]
+        [ take-rest ] bi
+    ] parse-sequence
+] unit-test
+
+[ { 1 2 } ]
+[ { 1 2 3 4 } <sequence-parser> { 3 4 } take-until-sequence ] unit-test
+
+[ f "aaaa" ]
+[
+    "aaaa" <sequence-parser>
+    [ "b" take-until-sequence ] [ take-rest ] bi
+] unit-test
+
+[ 6 ]
+[
+    "      foo   " [ skip-whitespace n>> ] parse-sequence
+] unit-test
+
+[ { 1 2 } ]
+[ { 1 2 3 } <sequence-parser> [ current 3 = ] take-until ] unit-test
+
+[ "ab" ]
+[ "abcd" <sequence-parser> "ab" take-sequence ] unit-test
+
+[ f ]
+[ "abcd" <sequence-parser> "lol" take-sequence ] unit-test
+
+[ "ab" ]
+[
+    "abcd" <sequence-parser>
+    [ "lol" take-sequence drop ] [ "ab" take-sequence ] bi
+] unit-test
+
+[ "" ]
+[ "abcd" <sequence-parser> "" take-sequence ] unit-test
+
+[ "cd" ]
+[ "abcd" <sequence-parser> [ "ab" take-sequence drop ] [ "cd" take-sequence ] bi ] unit-test
+
+[ f ]
+[ "" <sequence-parser> take-rest ] unit-test
+
+[ f ]
+[ "abc" <sequence-parser> dup "abc" take-sequence drop take-rest ] unit-test
+
+[ f ]
+[ "abc" <sequence-parser> "abcdefg" take-sequence ] unit-test
+
+[ "1234" ]
+[ "1234f" <sequence-parser> take-integer ] unit-test
+
+[ "yes" ]
+[
+    "yes1234f" <sequence-parser>
+    [ take-integer drop ] [ "yes" take-sequence ] bi 
+] unit-test
+
+[ f ] [ "" <sequence-parser> 4 take-n ] unit-test
+[ "abcd" ] [ "abcd" <sequence-parser> 4 take-n ] unit-test
+[ "abcd" "efg" ] [ "abcdefg" <sequence-parser> [ 4 take-n ] [ take-rest ] bi ] unit-test
+
+[ f ]
+[ "\n" <sequence-parser> take-integer ] unit-test
+
+[ "\n" ] [ "\n" <sequence-parser> [ ] take-while ] unit-test
+[ f ] [ "\n" <sequence-parser> [ not ] take-while ] unit-test
diff --git a/basis/sequences/parser/parser.factor b/basis/sequences/parser/parser.factor
new file mode 100644 (file)
index 0000000..93bbbdf
--- /dev/null
@@ -0,0 +1,148 @@
+! Copyright (C) 2005, 2009 Daniel Ehrenberg, Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors circular combinators.short-circuit fry io
+kernel locals math math.order sequences sorting.functor
+sorting.slots unicode.categories ;
+IN: sequences.parser
+
+TUPLE: sequence-parser sequence n ;
+
+: <sequence-parser> ( sequence -- sequence-parser )
+    sequence-parser new
+        swap >>sequence
+        0 >>n ;
+
+:: with-sequence-parser ( sequence-parser quot -- seq/f )
+    sequence-parser n>> :> n
+    sequence-parser quot call [
+        n sequence-parser (>>n) f
+    ] unless* ; inline
+
+: offset  ( sequence-parser offset -- char/f )
+    swap
+    [ n>> + ] [ sequence>> ?nth ] bi ; inline
+
+: current ( sequence-parser -- char/f ) 0 offset ; inline
+
+: previous ( sequence-parser -- char/f ) -1 offset ; inline
+
+: peek-next ( sequence-parser -- char/f ) 1 offset ; inline
+
+: advance ( sequence-parser -- sequence-parser )
+    [ 1 + ] change-n ; inline
+
+: advance* ( sequence-parser -- )
+    advance drop ; inline
+
+: next ( sequence-parser -- obj ) [ current ] [ advance* ] bi ;
+
+: get+increment ( sequence-parser -- char/f )
+    [ current ] [ advance drop ] bi ; inline
+
+:: skip-until ( sequence-parser quot: ( obj -- ? ) -- )
+    sequence-parser current [
+        sequence-parser quot call
+        [ sequence-parser advance quot skip-until ] unless
+    ] when ; inline recursive
+
+: sequence-parse-end? ( sequence-parser -- ? ) current not ;
+
+: take-until ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
+    over sequence-parse-end? [
+        2drop f
+    ] [
+        [ drop n>> ]
+        [ skip-until ]
+        [ drop [ n>> ] [ sequence>> ] bi ] 2tri subseq f like
+    ] if ; inline
+
+: take-while ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
+    [ not ] compose take-until ; inline
+
+: <safe-slice> ( from to seq -- slice/f )
+    3dup {
+        [ 2drop 0 < ]
+        [ [ drop ] 2dip length > ]
+        [ drop > ]
+    } 3|| [ 3drop f ] [ slice boa ] if ; inline
+
+:: take-sequence ( sequence-parser sequence -- obj/f )
+    sequence-parser [ n>> dup sequence length + ] [ sequence>> ] bi
+    <safe-slice> sequence sequence= [
+        sequence
+        sequence-parser [ sequence length + ] change-n drop
+    ] [
+        f
+    ] if ;
+
+: take-sequence* ( sequence-parser sequence -- )
+    take-sequence drop ;
+
+:: take-until-sequence ( sequence-parser sequence -- sequence'/f )
+    sequence-parser n>> :> saved
+    sequence length <growing-circular> :> growing
+    sequence-parser
+    [
+        current growing push-growing-circular
+        sequence growing sequence=
+    ] take-until :> found
+    growing sequence sequence= [
+        found dup length
+        growing length 1 - - head
+        sequence-parser [ growing length - 1 + ] change-n drop
+        ! sequence-parser advance drop
+    ] [
+        saved sequence-parser (>>n)
+        f
+    ] if ;
+
+:: take-until-sequence* ( sequence-parser sequence -- sequence'/f )
+    sequence-parser sequence take-until-sequence :> out
+    out [
+        sequence-parser [ sequence length + ] change-n drop
+    ] when out ;
+
+: skip-whitespace ( sequence-parser -- sequence-parser )
+    [ [ current blank? not ] take-until drop ] keep ;
+
+: skip-whitespace-eol ( sequence-parser -- sequence-parser )
+    [ [ current " \t\r" member? not ] take-until drop ] keep ;
+
+: take-rest-slice ( sequence-parser -- sequence/f )
+    [ sequence>> ] [ n>> ] bi
+    2dup [ length ] dip < [ 2drop f ] [ tail-slice ] if ; inline
+
+: take-rest ( sequence-parser -- sequence )
+    [ take-rest-slice ] [ sequence>> like ] bi f like ;
+
+: take-until-object ( sequence-parser obj -- sequence )
+    '[ current _ = ] take-until ;
+
+: parse-sequence ( sequence quot -- )
+    [ <sequence-parser> ] dip call ; inline
+
+: take-integer ( sequence-parser -- n/f )
+    [ current digit? ] take-while ;
+
+:: take-n ( sequence-parser n -- seq/f )
+    n sequence-parser [ n>> + ] [ sequence>> length ] bi > [
+        sequence-parser take-rest
+    ] [
+        sequence-parser n>> dup n + sequence-parser sequence>> subseq
+        sequence-parser [ n + ] change-n drop
+    ] if ;
+
+<< "length" [ length ] define-sorting >>
+
+: sort-tokens ( seq -- seq' )
+    { length>=< <=> } sort-by ;
+
+: take-first-matching ( sequence-parser seq -- seq )
+    swap
+    '[ _ [ swap take-sequence ] with-sequence-parser ] find nip ;
+
+: take-longest ( sequence-parser seq -- seq )
+    sort-tokens take-first-matching ;
+
+: write-full ( sequence-parser -- ) sequence>> write ;
+: write-rest ( sequence-parser -- ) take-rest write ;
diff --git a/basis/sequences/product/authors.txt b/basis/sequences/product/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/basis/sequences/product/product-docs.factor b/basis/sequences/product/product-docs.factor
new file mode 100644 (file)
index 0000000..0b6805e
--- /dev/null
@@ -0,0 +1,63 @@
+! (c)2009 Joe Groff bsd license
+USING: help.markup help.syntax quotations sequences ;
+IN: sequences.product
+
+HELP: product-sequence
+{ $class-description "A class of virtual sequences that present the cartesian product of their underlying set of sequences. Product sequences are constructed with the " { $link <product-sequence> } " word." }
+{ $examples
+{ $example """USING: arrays prettyprint sequences.product ;
+{ { 1 2 3 } { "a" "b" "c" } } <product-sequence> >array .
+""" """{
+    { 1 "a" }
+    { 2 "a" }
+    { 3 "a" }
+    { 1 "b" }
+    { 2 "b" }
+    { 3 "b" }
+    { 1 "c" }
+    { 2 "c" }
+    { 3 "c" }
+}""" } } ;
+
+HELP: <product-sequence>
+{ $values { "sequences" sequence } { "product-sequence" product-sequence } }
+{ $description "Constructs a " { $link product-sequence } " over " { $snippet "sequences" } "." }
+{ $examples
+{ $example """USING: arrays prettyprint sequences.product ;
+{ { 1 2 3 } { "a" "b" "c" } } <product-sequence> >array ."""
+"""{
+    { 1 "a" }
+    { 2 "a" }
+    { 3 "a" }
+    { 1 "b" }
+    { 2 "b" }
+    { 3 "b" }
+    { 1 "c" }
+    { 2 "c" }
+    { 3 "c" }
+}""" } } ;
+
+{ product-sequence <product-sequence> } related-words
+
+HELP: product-map
+{ $values { "sequences" sequence } { "quot" { $quotation "( sequence -- value )" } } { "sequence" sequence } }
+{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output sequence." }
+{ $notes { $snippet "[ ... ] product-map" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] map" } "." } ;
+
+HELP: product-each
+{ $values { "sequences" sequence } { "quot" { $quotation "( sequence -- )" } } }
+{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } "." }
+{ $notes { $snippet "[ ... ] product-each" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] each" } "." } ;
+
+{ product-map product-each } related-words
+
+ARTICLE: "sequences.product" "Product sequences"
+"The " { $vocab-link "sequences.product" } " vocabulary provides a virtual sequence and combinators for manipulating the cartesian product of a set of sequences."
+{ $subsections
+    product-sequence
+    <product-sequence>
+    product-map
+    product-each
+} ;
+
+ABOUT: "sequences.product"
diff --git a/basis/sequences/product/product-tests.factor b/basis/sequences/product/product-tests.factor
new file mode 100644 (file)
index 0000000..9f93129
--- /dev/null
@@ -0,0 +1,29 @@
+! (c)2009 Joe Groff bsd license
+USING: arrays kernel make sequences sequences.product tools.test ;
+IN: sequences.product.tests
+
+
+[ { { 0 "a" } { 1 "a" } { 2 "a" } { 0 "b" } { 1 "b" } { 2 "b" } } ]
+[ { { 0 1 2 } { "a" "b" } } <product-sequence> >array ] unit-test
+
+: x ( n s -- sss ) <repetition> concat ;
+
+[ { "a" "aa" "aaa" "b" "bb" "bbb" } ]
+[ { { 1 2 3 } { "a" "b" } } [ first2 x ] product-map ] unit-test
+
+[
+    {
+        { 0 "a" t } { 1 "a" t } { 2 "a" t } { 0 "b" t } { 1 "b" t } { 2 "b" t }
+        { 0 "a" f } { 1 "a" f } { 2 "a" f } { 0 "b" f } { 1 "b" f } { 2 "b" f }
+    }
+] [ { { 0 1 2 } { "a" "b" } { t f } } [ ] product-map ] unit-test
+
+[ "a1b1c1a2b2c2" ] [
+    [
+        { { "a" "b" "c" } { "1" "2" } }
+        [ [ % ] each ] product-each
+    ] "" make
+] unit-test
+
+[ { } ] [ { { } { 1 } } [ ] product-map ] unit-test
+[ ] [ { { } { 1 } } [ drop ] product-each ] unit-test
diff --git a/basis/sequences/product/product.factor b/basis/sequences/product/product.factor
new file mode 100644 (file)
index 0000000..f783fad
--- /dev/null
@@ -0,0 +1,65 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors arrays kernel locals math sequences ;
+IN: sequences.product
+
+TUPLE: product-sequence { sequences array read-only } { lengths array read-only } ;
+
+: <product-sequence> ( sequences -- product-sequence )
+    >array dup [ length ] map product-sequence boa ;
+
+INSTANCE: product-sequence sequence
+
+M: product-sequence length lengths>> product ;
+
+<PRIVATE
+
+: ns ( n lengths -- ns )
+    [ V{ } clone ] 2dip [ /mod swap [ over push ] dip ] each drop ;
+
+: nths ( ns seqs -- nths )
+    [ nth ] { } 2map-as ;
+
+: product@ ( n product-sequence -- ns seqs )
+    [ lengths>> ns ] [ nip sequences>> ] 2bi ;
+
+:: (carry-n) ( ns lengths i -- )
+    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)
+        ] when
+    ] unless ;
+
+: carry-ns ( ns lengths -- )
+    0 (carry-n) ;
+    
+: product-iter ( ns lengths -- )
+    [ 0 over [ 1 + ] change-nth ] dip carry-ns ;
+
+: start-product-iter ( sequences -- ns lengths )
+    [ [ drop 0 ] map ] [ [ length ] map ] bi ;
+
+: end-product-iter? ( ns lengths -- ? )
+    [ 1 tail* first ] bi@ = ;
+
+PRIVATE>
+
+M: product-sequence nth 
+    product@ nths ;
+
+:: product-each ( sequences quot -- )
+    sequences start-product-iter :> ( ns lengths )
+    lengths [ 0 = ] any? [
+        [ ns lengths end-product-iter? ]
+        [ ns sequences nths quot call ns lengths product-iter ] until
+    ] unless ; inline
+
+:: product-map ( sequences quot -- sequence )
+    0 :> i!
+    sequences [ length ] [ * ] map-reduce sequences
+    [| result |
+        sequences [ quot call i result set-nth i 1 + i! ] product-each
+        result
+    ] new-like ; inline
+
diff --git a/basis/sequences/product/summary.txt b/basis/sequences/product/summary.txt
new file mode 100644 (file)
index 0000000..c234c84
--- /dev/null
@@ -0,0 +1 @@
+Cartesian products of sequences
index cebf69595f523ff91b61c90d186cbed939e8330b..6dbc76386d1c4824f9546d3203d041a88e1cdec0 100644 (file)
@@ -50,7 +50,7 @@ CONSTANT: objects
         B{ 50 13 55 64 1 }
         ?{ t f t f f t f }
         double-array{ 1.0 3.0 4.0 1.0 2.35 0.33 }
-        << 1 [ 2 ] curry parsed >>
+        << 1 [ 2 ] curry suffix! >>
         { { "a" "bc" } { "de" "fg" } }
         H{ { "a" "bc" } { "de" "fg" } }
     }
index 2b4294bda4ca9250643d255b26c24be28945bcc5..9b4b0ac46b9651be7bd68fafe8668728d35c66bf 100644 (file)
@@ -26,7 +26,7 @@ TUPLE: id obj ;
 
 C: <id> id
 
-M: id hashcode* obj>> hashcode* ;
+M: id hashcode* nip obj>> identity-hashcode ;
 
 M: id equal? over id? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
 
@@ -222,7 +222,7 @@ SYMBOL: deserialized
 :: (deserialize-seq) ( exemplar quot -- seq )
     deserialize-cell exemplar new-sequence
     [ intern-object ]
-    [ dup [ drop quot call ] change-each ] bi ; inline
+    [ [ drop quot call ] map! ] bi ; inline
 
 : deserialize-array ( -- array )
     { } [ (deserialize) ] (deserialize-seq) ;
diff --git a/basis/shuffle/shuffle-docs.factor b/basis/shuffle/shuffle-docs.factor
new file mode 100644 (file)
index 0000000..363727a
--- /dev/null
@@ -0,0 +1,7 @@
+USING: help.markup help.syntax ;
+IN: shuffle
+
+HELP: spin  $complex-shuffle ;
+HELP: roll  $complex-shuffle ;
+HELP: -roll $complex-shuffle ;
+HELP: tuck  $complex-shuffle ;
index e091af2d06eed05140c14b02db1d38d48bbac411..4165efdcfdf94da344bcd50906d65bfdb04da966 100644 (file)
@@ -1,5 +1,10 @@
 USING: shuffle tools.test ;
+IN: shuffle.tests
 
 [ 1 2 3 4 ] [ 3 4 1 2 2swap ] unit-test
 
 [ 4 2 3 ] [ 1 2 3 4 shuffle( a b c d -- d b c ) ] unit-test
+
+[ 2 3 4 1 ] [ 1 2 3 4 roll ] unit-test
+[ 1 2 3 4 ] [ 2 3 4 1 -roll ] unit-test
+
index d6a4ba8bbbfad58715825ca05269955eaeabad45..0ff41edec621ffc1b74d33f0603b722539cc0228 100644 (file)
@@ -20,7 +20,15 @@ MACRO: shuffle-effect ( effect -- )
     ] [ ] make ;
 
 SYNTAX: shuffle(
-    ")" parse-effect parsed \ shuffle-effect parsed ;
+    ")" parse-effect suffix! \ shuffle-effect suffix! ;
+
+: tuck ( x y -- y x y ) swap over ; inline deprecated
+
+: spin ( x y z -- z y x ) swap rot ; inline deprecated
+
+: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline deprecated
+
+: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline deprecated
 
 : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
 
diff --git a/basis/specialized-arrays/mirrors/mirrors.factor b/basis/specialized-arrays/mirrors/mirrors.factor
new file mode 100644 (file)
index 0000000..ee7953b
--- /dev/null
@@ -0,0 +1,8 @@
+! Copyright (C) 2009 Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
+USING: mirrors specialized-arrays math.vectors ;
+IN: specialized-arrays.mirrors
+
+INSTANCE: specialized-array enumerated-sequence
+INSTANCE: simd-128          enumerated-sequence
+INSTANCE: simd-256          enumerated-sequence
index 423c7ad1ee595368b1db8c9cc6104fb16d10daf2..bc293b19e0342a1c7b7d16e10a91888c6242c0d9 100755 (executable)
@@ -45,7 +45,7 @@ SPECIALIZED-ARRAYS: bool ushort char uint float ulonglong ;
 
 [ ushort-array{ 0 0 0 } ] [
     3 ALIEN: 123 100 <direct-ushort-array> new-sequence
-    dup [ drop 0 ] change-each
+    [ drop 0 ] map!
 ] unit-test
 
 STRUCT: test-struct
index 67c58987a1ecf6f6324510b22fb6b185aa670985..711354d8034970a2120dd6780b8b6bccafa7b29b 100755 (executable)
@@ -105,7 +105,7 @@ M: A pprint-delims drop \ A{ \ } ;
 M: A >pprint-sequence ;
 
 SYNTAX: A{ \ } [ >A ] parse-literal ;
-SYNTAX: A@ scan-object scan-object <direct-A> parsed ;
+SYNTAX: A@ scan-object scan-object <direct-A> suffix! ;
 
 INSTANCE: A specialized-array
 
@@ -168,3 +168,7 @@ SYNTAX: SPECIALIZED-ARRAY:
 "prettyprint" vocab [
     "specialized-arrays.prettyprint" require
 ] when
+
+"mirrors" vocab [
+    "specialized-arrays.mirrors" require
+] when
index 2a20ba74cd79b0ced07da1cb47eee363cd2bc556..f9ab1ae96cb5017bbbad6e92505bf5be4afe5772 100644 (file)
@@ -69,6 +69,6 @@ TUPLE: alien-callback-params < alien-node-params quot xt ;
     pop-literal nip >>abi
     pop-literal nip >>parameters
     pop-literal nip >>return
-    "( callback )" f <word> >>xt
+    "( callback )" <uninterned-word> >>xt
     dup callback-bottom
     #alien-callback, ;
index 48cd10a7ee82243fd140efe8e35dc5efcbbcca30..b58998cb4904208e69b843995f3db6e6c4da02d1 100644 (file)
@@ -1,17 +1,21 @@
 USING: stack-checker.backend tools.test kernel namespaces
-stack-checker.state sequences ;
+stack-checker.state stack-checker.values sequences assocs ;
 IN: stack-checker.backend.tests
 
 [ ] [
     V{ } clone \ meta-d set
     V{ } clone \ meta-r set
     V{ } clone \ literals set
-    0 d-in set
+    H{ } clone known-values set
+    0 input-count set
 ] unit-test
 
 [ 0 ] [ 0 ensure-d length ] unit-test
 
 [ 2 ] [ 2 ensure-d length ] unit-test
+
+[ t ] [ meta-d [ known-values get at input-parameter? ] all? ] unit-test
+
 [ 2 ] [ meta-d length ] unit-test
 
 [ 3 ] [ 3 ensure-d length ] unit-test
index 5411c885ad7165f0a7a44ea55e2c879df6658c79..b2a99f07316f41b24e5b000674049eb305dd47dc 100755 (executable)
@@ -5,15 +5,19 @@ 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 summary ;
+stack-checker.recursive-state stack-checker.dependencies summary ;
 IN: stack-checker.backend
 
 : push-d ( obj -- ) meta-d push ;
 
+: introduce-values ( values -- )
+    [ [ [ input-parameter ] dip set-known ] each ]
+    [ length input-count +@ ]
+    [ #introduce, ]
+    tri ;
+
 : pop-d  ( -- obj )
-    meta-d [
-        <value> dup 1array #introduce, d-in inc
-    ] [ pop ] if-empty ;
+    meta-d [ <value> dup 1array introduce-values ] [ pop ] if-empty ;
 
 : peek-d ( -- obj ) pop-d dup push-d ;
 
@@ -24,7 +28,7 @@ IN: stack-checker.backend
     meta-d 2dup length > [
         2dup
         [ nip >array ] [ length - make-values ] [ nip delete-all ] 2tri
-        [ length d-in +@ ] [ #introduce, ] [ meta-d push-all ] tri
+        [ introduce-values ] [ meta-d push-all ] bi
         meta-d push-all
     ] when swap tail* ;
 
index 8b0665aa4981de39cd138da63e2f645db4def49b..99e5a7040943bbab03c5902bc682fdb0adeef1b0 100755 (executable)
@@ -11,7 +11,7 @@ IN: stack-checker.branches
 
 SYMBOLS: +bottom+ +top+ ;
 
-: unify-inputs ( max-d-in d-in meta-d -- new-meta-d )
+: unify-inputs ( max-input-count input-count meta-d -- new-meta-d )
     ! Introduced values can be anything, and don't unify with
     ! literals.
     dup [ [ - +top+ <repetition> ] dip append ] [ 3drop f ] if ;
@@ -24,7 +24,7 @@ SYMBOLS: +bottom+ +top+ ;
         '[ _ +bottom+ pad-head ] map
     ] unless ;
 
-: phi-inputs ( max-d-in pairs -- newseq )
+: phi-inputs ( max-input-count pairs -- newseq )
     dup empty? [ nip ] [
         swap '[ [ _ ] dip first2 unify-inputs ] map
         pad-with-bottom
@@ -61,9 +61,9 @@ SYMBOL: quotations
     branch-variable ;
 
 : datastack-phi ( seq -- phi-in phi-out )
-    [ d-in branch-variable ] [ \ meta-d active-variable ] bi
+    [ input-count branch-variable ] [ \ meta-d active-variable ] bi
     unify-branches
-    [ d-in set ] [ ] [ dup >vector \ meta-d set ] tri* ;
+    [ input-count set ] [ ] [ dup >vector \ meta-d set ] tri* ;
 
 : terminated-phi ( seq -- terminated )
     terminated? branch-variable ;
@@ -80,7 +80,7 @@ SYMBOL: quotations
 : copy-inference ( -- )
     \ meta-d [ clone ] change
     literals [ clone ] change
-    d-in [ ] change ;
+    input-count [ ] change ;
 
 GENERIC: infer-branch ( literal -- namespace )
 
diff --git a/basis/stack-checker/dependencies/authors.txt b/basis/stack-checker/dependencies/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/stack-checker/dependencies/dependencies-tests.factor b/basis/stack-checker/dependencies/dependencies-tests.factor
new file mode 100644 (file)
index 0000000..9bcec64
--- /dev/null
@@ -0,0 +1,37 @@
+IN: stack-checker.dependencies.tests
+USING: tools.test stack-checker.dependencies words kernel namespaces
+definitions ;
+
+: computing-dependencies ( quot -- dependencies )
+    H{ } clone [ dependencies rot with-variable ] keep ;
+    inline
+
+SYMBOL: a
+SYMBOL: b
+
+[ ] [ a called-dependency depends-on ] unit-test
+
+[ H{ { a called-dependency } } ] [
+    [ a called-dependency depends-on ] computing-dependencies
+] unit-test
+
+[ H{ { a called-dependency } { b inlined-dependency } } ] [
+    [
+        a called-dependency depends-on b inlined-dependency depends-on
+    ] computing-dependencies
+] unit-test
+
+[ H{ { a inlined-dependency } { b inlined-dependency } } ] [
+    [
+        a inlined-dependency depends-on
+        a called-dependency depends-on
+        b inlined-dependency depends-on
+    ] computing-dependencies
+] unit-test
+
+[ flushed-dependency ] [ f flushed-dependency strongest-dependency ] unit-test
+[ flushed-dependency ] [ flushed-dependency f strongest-dependency ] unit-test
+[ inlined-dependency ] [ flushed-dependency inlined-dependency strongest-dependency ] unit-test
+[ inlined-dependency ] [ called-dependency inlined-dependency strongest-dependency ] unit-test
+[ flushed-dependency ] [ called-dependency flushed-dependency strongest-dependency ] unit-test
+[ called-dependency ] [ called-dependency f strongest-dependency ] unit-test
diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor
new file mode 100644 (file)
index 0000000..f0c77b8
--- /dev/null
@@ -0,0 +1,37 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs classes.algebra fry kernel math namespaces
+sequences words ;
+IN: stack-checker.dependencies
+
+! Words that the current quotation depends on
+SYMBOL: dependencies
+
+SYMBOLS: inlined-dependency flushed-dependency called-dependency ;
+
+: index>= ( obj1 obj2 seq -- ? )
+    [ index ] curry bi@ >= ;
+
+: dependency>= ( how1 how2 -- ? )
+    { called-dependency flushed-dependency inlined-dependency }
+    index>= ;
+
+: strongest-dependency ( how1 how2 -- how )
+    [ called-dependency or ] bi@ [ dependency>= ] most ;
+
+: depends-on ( word how -- )
+    over primitive? [ 2drop ] [
+        dependencies get dup [
+            swap '[ _ strongest-dependency ] change-at
+        ] [ 3drop ] if
+    ] if ;
+
+! Generic words that the current quotation depends on
+SYMBOL: generic-dependencies
+
+: ?class-or ( class/f class -- class' )
+    swap [ class-or ] when* ;
+
+: depends-on-generic ( generic class -- )
+    generic-dependencies get dup
+    [ swap '[ _ ?class-or ] change-at ] [ 3drop ] if ;
index 5da51977006588f99270d53a62068044c0c94e50..4b432e733f38cf5083c566c5938b33405b871040 100755 (executable)
@@ -12,10 +12,10 @@ HELP: do-not-compile
     }
 } ;
 
-HELP: literal-expected
-{ $error-description "Thrown when inference encounters a combinator or macro being applied to a value which is not known to be a literal, or constructed in a manner which can be analyzed statically. Such code needs changes before it can compile and run. See " { $link "inference-combinators" } " and " { $link "inference-escape" } " for details." }
+HELP: unknown-macro-input
+{ $error-description "Thrown when inference encounters a combinator or macro being applied to an input parameter of a non-" { $link POSTPONE: inline } " word. The word needs to be declared " { $link POSTPONE: inline } " before its callers can compile and run. See " { $link "inference-combinators" } " and " { $link "inference-escape" } " for details." }
 { $examples
-    "In this example, the words being defined cannot be called, because they fail to compile with a " { $link literal-expected } " error:"
+    "In this example, the words being defined cannot be called, because they fail to compile with a " { $link unknown-macro-input } " error:"
     { $code
         ": bad-example ( quot -- )"
         "    [ call ] [ call ] bi ;"
@@ -41,6 +41,27 @@ HELP: literal-expected
     }
 } ;
 
+HELP: bad-macro-input
+{ $error-description "Thrown when inference encounters a combinator or macro being applied to a value which is not known at compile time. Such code needs changes before it can compile and run. See " { $link "inference-combinators" } " and " { $link "inference-escape" } " for details." }
+{ $examples
+    "In this example, the words being defined cannot be called, because they fail to compile with a " { $link bad-macro-input } " error:"
+    { $code
+        ": bad-example ( quot -- )"
+        "    [ . ] append call ; inline"
+        ""
+        ": usage ( -- )"
+        "    2 2 [ + ] bad-example ;"
+    }
+    "One fix is to use " { $link compose } " instead of " { $link append } ":"
+    { $code
+        ": good-example ( quot -- )"
+        "    [ . ] compose call ; inline"
+        ""
+        ": usage ( -- )"
+        "    2 2 [ + ] good-example ;"
+    }
+} ;
+
 HELP: unbalanced-branches-error
 { $values { "in" "a sequence of integers" } { "out" "a sequence of integers" } }
 { $description "Throws an " { $link unbalanced-branches-error } "." }
@@ -121,7 +142,8 @@ ARTICLE: "inference-errors" "Stack checker errors"
 "Errors thrown when insufficient information is available to calculate the stack effect of a call to a combinator or macro (see " { $link "inference-combinators" } "):"
 { $subsections
     do-not-compile
-    literal-expected
+    unknown-macro-input
+    bad-macro-input
 }
 "Error thrown when a word's stack effect declaration does not match the composition of the stack effects of its factors:"
 { $subsections effect-error }
index b1071df7080d16ab8cc4d45d65c6731ff8635257..d476de84c50b3c073ea8805c992681815e108023 100644 (file)
@@ -1,13 +1,14 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel stack-checker.values ;
 IN: stack-checker.errors
 
 TUPLE: inference-error ;
 
 ERROR: do-not-compile < inference-error word ;
 
-ERROR: literal-expected < inference-error what ;
+ERROR: bad-macro-input < inference-error macro ;
+
+ERROR: unknown-macro-input < inference-error macro ;
 
 ERROR: unbalanced-branches-error < inference-error branches quots ;
 
@@ -31,8 +32,6 @@ ERROR: inconsistent-recursive-call-error < inference-error word ;
 
 ERROR: unknown-primitive-error < inference-error ;
 
-ERROR: transform-expansion-error < inference-error word error ;
-
-ERROR: bad-declaration-error < inference-error declaration ;
+ERROR: transform-expansion-error < inference-error error continuation word ;
 
-M: object (literal) "literal value" literal-expected ;
\ No newline at end of file
+ERROR: bad-declaration-error < inference-error declaration ;
\ No newline at end of file
index 5be5722c23f675815c25aee32932513fbbce4ebc..eef35b61cd0756681d116a8e311a0c4cf89cea1e 100644 (file)
@@ -4,10 +4,11 @@ USING: accessors kernel prettyprint io debugger
 sequences assocs stack-checker.errors summary effects ;
 IN: stack-checker.errors.prettyprint
 
-M: literal-expected summary
-    what>> "Got a computed value where a " " was expected" surround ;
+M: unknown-macro-input summary
+    macro>> name>> "Cannot apply “" "” to an input parameter of a non-inline word" surround ;
 
-M: literal-expected error. summary print ;
+M: bad-macro-input summary
+    macro>> name>> "Cannot apply “" "” to a run-time computed value" surround ;
 
 M: unbalanced-branches-error summary
     drop "Unbalanced branches" ;
@@ -56,7 +57,10 @@ M: transform-expansion-error summary
     word>> name>> "Macro expansion of " " threw an error" surround ;
 
 M: transform-expansion-error error.
-    [ summary print ] [ error>> error. ] bi ;
+    [ summary print ]
+    [ nl "The error was:" print error>> error. nl ]
+    [ continuation>> traceback-link. ]
+    tri ;
 
 M: do-not-compile summary
     word>> name>> "Cannot compile call to " prepend ;
\ No newline at end of file
index c99e0f02521032af919b3bd44407c3e9cd222b6e..38ac2b0e719a24fb66f63e9c35f6dd928da46fab 100644 (file)
@@ -10,6 +10,7 @@ stack-checker.visitor
 stack-checker.backend
 stack-checker.branches
 stack-checker.known-words
+stack-checker.dependencies
 stack-checker.recursive-state ;
 IN: stack-checker.inlining
 
@@ -28,8 +29,6 @@ fixed-point
 introductions
 loop? ;
 
-M: inline-recursive hashcode* id>> hashcode* ;
-
 : inlined-block? ( word -- ? ) "inlined-block" word-prop ;
 
 : <inline-recursive> ( word -- label )
@@ -81,7 +80,7 @@ SYMBOL: enter-out
     bi ;
 
 : recursive-word-inputs ( label -- n )
-    entry-stack-height d-in get + ;
+    entry-stack-height input-count get + ;
 
 : (inline-recursive-word) ( word -- label in out visitor terminated? )
     dup prepare-stack
index 8cddac5a752e52e8871da9048d071a166811d325..3be5244231278bb03cef5f1daabbbb6cff326a81 100644 (file)
@@ -13,7 +13,7 @@ words.private definitions assocs summary compiler.units
 system.private combinators combinators.short-circuit locals
 locals.backend locals.types combinators.private
 stack-checker.values generic.single generic.single.private
-alien.libraries
+alien.libraries tools.dispatch.private tools.profiler.private
 stack-checker.alien
 stack-checker.state
 stack-checker.errors
@@ -21,6 +21,7 @@ stack-checker.visitor
 stack-checker.backend
 stack-checker.branches
 stack-checker.transforms
+stack-checker.dependencies
 stack-checker.recursive-state ;
 IN: stack-checker.known-words
 
@@ -43,7 +44,6 @@ IN: stack-checker.known-words
     { swapd (( x y z -- y x z       )) }
     { nip   (( x y   -- y           )) }
     { 2nip  (( x y z -- z           )) }
-    { tuck  (( x y   -- y x y       )) }
     { over  (( x y   -- x y x       )) }
     { pick  (( x y z -- x y z x     )) }
     { swap  (( x y   -- y x         )) }
@@ -98,8 +98,8 @@ M: composed infer-call*
     1 infer->r infer-call
     terminated? get [ 1 infer-r> infer-call ] unless ;
 
-M: object infer-call*
-    "literal quotation" literal-expected ;
+M: input-parameter infer-call* \ call unknown-macro-input ;
+M: object infer-call* \ call bad-macro-input ;
 
 : infer-ndip ( word n -- )
     [ literals get ] 2dip
@@ -192,17 +192,17 @@ M: bad-executable summary
 
 \ load-local [ infer-load-local ] "special" set-word-prop
 
-: infer-get-local ( -- )
-    [let* | n [ pop-literal nip 1 swap - ]
-            in-r [ n consume-r ]
-            out-d [ in-r first copy-value 1array ]
-            out-r [ in-r copy-values ] |
-         out-d output-d
-         out-r output-r
-         f out-d in-r out-r
-         out-r in-r zip out-d first in-r first 2array suffix
-         #shuffle,
-    ] ;
+:: infer-get-local ( -- )
+    pop-literal nip 1 swap - :> n
+    n consume-r :> in-r
+    in-r first copy-value 1array :> out-d
+    in-r copy-values :> out-r
+
+    out-d output-d
+    out-r output-r
+    f out-d in-r out-r
+    out-r in-r zip out-d first in-r first 2array suffix
+    #shuffle, ;
 
 \ get-local [ infer-get-local ] "special" set-word-prop
 
@@ -231,7 +231,7 @@ M: bad-executable summary
 \ alien-callback [ infer-alien-callback ] "special" set-word-prop
 
 : infer-special ( word -- )
-    "special" word-prop call( -- ) ;
+    [ current-word set ] [ "special" word-prop call( -- ) ] bi ;
 
 : infer-local-reader ( word -- )
     (( -- value )) apply-word/effect ;
@@ -501,16 +501,14 @@ M: bad-executable summary
 
 \ compact-gc { } { } define-primitive
 
-\ gc-stats { } { array } define-primitive
-
 \ (save-image) { byte-array } { } define-primitive
 
 \ (save-image-and-exit) { byte-array } { } define-primitive
 
-\ data-room { } { integer integer array } define-primitive
+\ data-room { } { byte-array } define-primitive
 \ data-room make-flushable
 
-\ code-room { } { integer integer integer integer } define-primitive
+\ code-room { } { byte-array } define-primitive
 \ code-room  make-flushable
 
 \ micros { } { integer } define-primitive
@@ -594,7 +592,7 @@ M: bad-executable summary
 
 \ set-alien-double { float c-ptr integer } { } define-primitive
 
-\ alien-cell { c-ptr integer } { simple-c-ptr } define-primitive
+\ alien-cell { c-ptr integer } { pinned-c-ptr } define-primitive
 \ alien-cell make-flushable
 
 \ set-alien-cell { c-ptr c-ptr integer } { } define-primitive
@@ -625,11 +623,7 @@ M: bad-executable summary
 \ <array> { integer object } { array } define-primitive
 \ <array> make-flushable
 
-\ begin-scan { } { } define-primitive
-
-\ next-object { } { object } define-primitive
-
-\ end-scan { } { } define-primitive
+\ all-instances { } { array } define-primitive
 
 \ size { object } { fixnum } define-primitive
 \ size make-flushable
@@ -701,21 +695,24 @@ M: bad-executable summary
 
 \ unimplemented { } { } define-primitive
 
-\ gc-reset { } { } define-primitive
-
-\ gc-stats { } { array } define-primitive
-
 \ jit-compile { quotation } { } define-primitive
 
 \ lookup-method { object array } { word } define-primitive
 
 \ reset-dispatch-stats { } { } define-primitive
-\ dispatch-stats { } { array } define-primitive
-\ reset-inline-cache-stats { } { } define-primitive
-\ inline-cache-stats { } { array } define-primitive
+\ dispatch-stats { } { byte-array } define-primitive
 
 \ optimized? { word } { object } define-primitive
 
 \ strip-stack-traces { } { } define-primitive
 
 \ <callback> { word } { alien } define-primitive
+
+\ enable-gc-events { } { } define-primitive
+\ disable-gc-events { } { object } define-primitive
+
+\ profiling { object } { } define-primitive
+
+\ (identity-hashcode) { object } { fixnum } define-primitive
+
+\ compute-identity-hashcode { object } { } define-primitive
index 97155bc6d93d95e92300f05d2e62da56a4d60a98..cc4a688f7aea9dc510c46434dbfc7c899c74ad4f 100644 (file)
@@ -21,16 +21,19 @@ $nl
 { $example "[ 2 + ] infer." "( object -- object )" } ;
 
 ARTICLE: "inference-combinators" "Combinator stack effects"
-"If a word, call it " { $snippet "W" } ", calls a combinator, one of the following two conditions must hold:"
+"If a word calls a combinator, one of the following two conditions must hold for the stack checker to succeed:"
 { $list
-  { "The combinator may be called with a quotation that is either a literal, or built from literals, " { $link curry } " and " { $link compose } "." }
-  { "The combinator must be called on an input parameter, or be built from input parameters, literals, " { $link curry } " and " { $link compose } ", " { $strong "if" } " the word " { $snippet "W" } " must be declared " { $link POSTPONE: inline } ". Then " { $snippet "W" } " is itself considered to be a combinator, and its callers must satisfy one of these two conditions." }
+  { "The combinator must be called with a quotation that is either literal or built from literal quotations, " { $link curry } ", and " { $link compose } ". (Note that quotations that use " { $vocab-link "fry" } " or " { $vocab-link "locals" } " use " { $link curry } " and " { $link compose } " from the perspective of the stack checker.)" }
+  { "If the word is declared " { $link POSTPONE: inline } ", the combinator may additionally be called on one of the word's input parameters or with quotations built from the word's input parameters, literal quotations, " { $link curry } ", and " { $link compose } ". When inline, a word is itself considered to be a combinator, and its callers must in turn satisfy these conditions." }
 }
-"If neither condition holds, the stack checker throws a " { $link literal-expected } " error, and an escape hatch such as " { $link POSTPONE: call( } " must be used instead. See " { $link "inference-escape" } " for details. An inline combinator can be called with an unknown quotation by currying the quotation onto a literal quotation that uses " { $link POSTPONE: call( } "."
+"If neither condition holds, the stack checker throws a " { $link unknown-macro-input } " or " { $link bad-macro-input } " error. To make the code compile, a runtime checking combinator such as " { $link POSTPONE: call( } " must be used instead. See " { $link "inference-escape" } " for details. An inline combinator can be called with an unknown quotation by " { $link curry } "ing the quotation onto a literal quotation that uses " { $link POSTPONE: call( } "."
 { $heading "Examples" }
 { $subheading "Calling a combinator" }
 "The following usage of " { $link map } " passes the stack checker, because the quotation is the result of " { $link curry } ":"
-{ $example "[ [ + ] curry map ] infer." "( object object -- object )" }
+{ $example "USING: math sequences ;" "[ [ + ] curry map ] infer." "( object object -- object )" }
+"The equivalent code using " { $vocab-link "fry" } " and " { $vocab-link "locals" } " likewise passes the stack checker:"
+{ $example "USING: fry math sequences ;" "[ '[ _ + ] map ] infer." "( object object -- object )" }
+{ $example "USING: locals math sequences ;" "[| a | [ a + ] map ] infer." "( object object -- object )" }
 { $subheading "Defining an inline combinator" }
 "The following word calls a quotation twice; the word is declared " { $link POSTPONE: inline } ", since it invokes " { $link call } " on the result of " { $link compose } " on an input parameter:"
 { $code ": twice ( value quot -- result ) dup compose call ; inline" }
@@ -48,15 +51,15 @@ ARTICLE: "inference-combinators" "Combinator stack effects"
 "However this fails to pass the stack checker since there is no guarantee the quotation has the right stack effect for " { $link map } ". It can be wrapped in a new quotation with a declaration:"
 { $code ": perform ( values action -- results )" "    quot>> [ call( value -- result ) ] curry map ;" }
 { $heading "Explanation" }
-"This restriction exists because without further information, one cannot say what the stack effect of " { $link call } " is; it depends on the given quotation. If the stack checker encounters a " { $link call } " without further information, a " { $link literal-expected } " error is raised."
+"This restriction exists because without further information, one cannot say what the stack effect of " { $link call } " is; it depends on the given quotation. If the stack checker encounters a " { $link call } " without further information, a " { $link unknown-macro-input } " or " { $link bad-macro-input } " error is raised."
 $nl
 "On the other hand, the stack effect of applying " { $link call } " to a literal quotation or a " { $link curry } " of a literal quotation is easy to compute; it behaves as if the quotation was substituted at that point."
 { $heading "Limitations" }
-"Passing a literal quotation on the data stack through an inlined recursive combinator nullifies its literal status. For example, the following will not infer:"
+"The stack checker cannot guarantee that a literal quotation is still literal if it is passed on the data stack to an inlined recursive combinator such as " { $link each } " or " { $link map } ". For example, the following will not infer:"
 { $example
-  "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Got a computed value where a literal quotation was expected"
+  "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Cannot apply “call” to a run-time computed value\nmacro call"
 }
-"To make this work, pass the quotation on the retain stack instead:"
+"To make this work, use " { $link dip } " to pass the quotation instead:"
 { $example
   "[ [ reverse ] [ [ reverse ] map ] dip call ] infer." "( object -- object )"
 } ;
@@ -74,7 +77,7 @@ $nl
 "Combinators which are recursive require additional care. In addition to being declared " { $link POSTPONE: inline } ", they must be declared " { $link POSTPONE: recursive } ". There are three restrictions that only apply to combinators with this declaration:"
 { $heading "Input quotation declaration" }
 "Input parameters which are quotations must be annotated as much in the stack effect. For example, the following will not infer:"
-{ $example ": bad ( quot -- ) [ call ] keep bad ; inline recursive" "[ [ ] bad ] infer." "Got a computed value where a literal quotation was expected" }
+{ $unchecked-example ": bad ( quot -- ) [ call ] keep bad ; inline recursive" "[ [ ] bad ] infer." "Cannot apply “call” to a run-time computed value\nmacro call" }
 "The following is correct:"
 { $example ": good ( quot: ( -- ) -- ) [ call ] keep good ; inline recursive" "[ [ ] good ] infer." "( -- )" }
 "The effect of the nested quotation itself is only present for documentation purposes; the mere presence of a nested effect is sufficient to mark that value as a quotation parameter."
@@ -82,7 +85,7 @@ $nl
 "The stack checker does not trace data flow in two instances."
 $nl
 "An inline recursive word cannot pass a quotation on the data stack through the recursive call. For example, the following will not infer:"
-{ $example ": bad ( ? quot: ( ? -- ) -- ) 2dup [ not ] dip bad call ; inline recursive" "[ [ drop ] bad ] infer." "Got a computed value where a literal quotation was expected" }
+{ $unchecked-example ": bad ( ? quot: ( ? -- ) -- ) 2dup [ not ] dip bad call ; inline recursive" "[ [ drop ] bad ] infer." "Cannot apply “call” to a run-time computed value\nmacro call" }
 "However a small change can be made:"
 { $example ": good ( ? quot: ( ? -- ) -- ) [ good ] 2keep [ not ] dip call ; inline recursive" "[ [ drop ] good ] infer." "( object -- )" }
 "An inline recursive word must have a fixed stack effect in its base case. The following will not infer:"
index 8fee8df5386180af13a38c3147330b3b45cd76cb..7ee7b8e0dd6498fdc7125db0e839085b7873612b 100644 (file)
@@ -7,7 +7,7 @@ sorting assocs definitions prettyprint io inspector
 classes.tuple classes.union classes.predicate debugger
 threads.private io.streams.string io.timeouts io.thread
 sequences.private destructors combinators eval locals.backend
-system compiler.units ;
+system compiler.units shuffle ;
 IN: stack-checker.tests
 
 [ 1234 infer ] must-fail
@@ -16,14 +16,18 @@ IN: stack-checker.tests
 { 1 2 } [ dup ] must-infer-as
 
 { 1 2 } [ [ dup ] call ] must-infer-as
-[ [ call ] infer ] must-fail
+[ [ call ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
+[ [ curry call ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
+[ [ { } >quotation call ] infer ] [ T{ bad-macro-input f call } = ] must-fail-with
+[ [ append curry call ] infer ] [ T{ bad-macro-input f call } = ] must-fail-with
 
 { 2 4 } [ 2dup ] must-infer-as
 
 { 1 0 } [ [ ] [ ] if ] must-infer-as
-[ [ if ] infer ] must-fail
-[ [ [ ] if ] infer ] must-fail
-[ [ [ 2 ] [ ] if ] infer ] must-fail
+[ [ if ] infer ] [ T{ unknown-macro-input f if } = ] must-fail-with
+[ [ { } >quotation { } >quotation if ] infer ] [ T{ bad-macro-input f if } = ] must-fail-with
+[ [ [ ] if ] infer ] [ T{ unknown-macro-input f if } = ] must-fail-with
+[ [ [ 2 ] [ ] if ] infer ] [ unbalanced-branches-error? ] must-fail-with
 { 4 3 } [ [ rot ] [ -rot ] if ] must-infer-as
 
 { 4 3 } [
@@ -46,7 +50,7 @@ IN: stack-checker.tests
 
 [
     [ [ [ 2 2 fixnum+ ] ] [ [ 2 2 fixnum* ] ] if call ] infer
-] must-fail
+] [ T{ bad-macro-input f call } = ] must-fail-with
 
 ! Test inference of termination of control flow
 : termination-test-1 ( -- * ) "foo" throw ;
@@ -198,42 +202,42 @@ DEFER: blah4
 
 ! This used to hang
 [ [ [ dup call ] dup call ] infer ]
-[ inference-error? ] must-fail-with
+[ recursive-quotation-error? ] must-fail-with
 
 : m ( q -- ) dup call ; inline
 
-[ [ [ m ] m ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m ] m ] infer ] [ recursive-quotation-error? ] must-fail-with
 
 : m' ( quot -- ) dup curry call ; inline
 
-[ [ [ m' ] m' ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m' ] m' ] infer ] [ recursive-quotation-error? ] must-fail-with
 
 : m'' ( -- q ) [ dup curry ] ; inline
 
 : m''' ( -- ) m'' call call ; inline
 
-[ [ [ m''' ] m''' ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m''' ] m''' ] infer ] [ recursive-quotation-error? ] must-fail-with
 
-: m-if ( a b c -- ) t over if ; inline
+: m-if ( a b c -- ) t over when ; inline
 
-[ [ [ m-if ] m-if ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m-if ] m-if ] infer ] [ recursive-quotation-error? ] must-fail-with
 
 ! This doesn't hang but it's also an example of the
 ! undedicable case
 [ [ [ [ drop 3 ] swap call ] dup call ] infer ]
-[ inference-error? ] must-fail-with
+[ recursive-quotation-error? ] must-fail-with
 
-[ [ 1 drop-locals ] infer ] [ inference-error? ] must-fail-with
+[ [ 1 drop-locals ] infer ] [ too-many-r>? ] must-fail-with
 
 ! Regression
-[ [ cleave ] infer ] [ inference-error? ] must-fail-with
+[ [ cleave ] infer ] [ T{ unknown-macro-input f cleave } = ] must-fail-with
 
 ! Test some curry stuff
 { 1 1 } [ 3 [ ] curry 4 [ ] curry if ] must-infer-as
 
 { 2 1 } [ [ ] curry 4 [ ] curry if ] must-infer-as
 
-[ [ 3 [ ] curry 1 2 [ ] 2curry if ] infer ] must-fail
+[ [ 3 [ ] curry 1 2 [ ] 2curry if ] infer ] [ unbalanced-branches-error? ] must-fail-with
 
 { 1 3 } [ [ 2drop f ] assoc-find ] must-infer-as
 
@@ -304,7 +308,7 @@ ERROR: custom-error ;
 ] unit-test
 
 ! Regression
-[ [ 1 load-locals ] infer ] must-fail
+[ [ 1 load-locals ] infer ] [ too-many->r? ] must-fail-with
 
 ! Corner case
 [ [ [ f dup ] [ dup ] produce ] infer ] must-fail
@@ -319,7 +323,7 @@ FORGET: erg's-inference-bug
 [ [ bad-recursion-3 ] infer ] must-fail
 FORGET: bad-recursion-3
 
-: bad-recursion-4 ( -- ) 4 [ dup call roll ] times ; inline recursive
+: bad-recursion-4 ( -- ) 4 [ dup call [ rot ] dip swap ] times ; inline recursive
 [ [ [ ] [ 1 2 3 ] over dup bad-recursion-4 ] infer ] must-fail
 
 : bad-recursion-5 ( obj quot: ( -- ) -- ) dup call swap bad-recursion-5 ; inline recursive
@@ -329,6 +333,8 @@ FORGET: bad-recursion-3
     dup bad-recursion-6 call ; inline recursive
 [ [ [ drop f ] bad-recursion-6 ] infer ] must-fail
 
+[ ] [ [ \ bad-recursion-6 forget ] with-compilation-unit ] unit-test
+
 { 3 0 } [ [ 2drop "A" throw ] [ ] if 2drop ] must-infer-as
 { 2 0 } [ drop f f [ 2drop "A" throw ] [ ] if 2drop ] must-infer-as
 
@@ -346,6 +352,9 @@ DEFER: eee'
 
 [ [ eee' ] infer ] [ inference-error? ] must-fail-with
 
+[ ] [ [ \ ddd' forget ] with-compilation-unit ] unit-test
+[ ] [ [ \ eee' forget ] with-compilation-unit ] unit-test
+
 : bogus-error ( x -- )
     dup "A" throw [ bogus-error ] [ drop ] if ; inline recursive
 
@@ -367,9 +376,9 @@ DEFER: eee'
 [ ] [ [ \ forget-test forget ] with-compilation-unit ] unit-test
 [ forget-test ] must-infer
 
-[ [ cond ] infer ] must-fail
-[ [ bi ] infer ] must-fail
-[ at ] must-infer
+[ [ cond ] infer ] [ T{ unknown-macro-input f cond } = ] must-fail-with
+[ [ bi ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
+[ [ each ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
 
 [ [ [ "OOPS" throw ] dip ] [ drop ] if ] must-infer
 
@@ -380,5 +389,5 @@ DEFER: eee'
 { 3 1 } [ call( a b -- c ) ] must-infer-as
 { 3 1 } [ execute( a b -- c ) ] must-infer-as
 
-[ [ call-effect ] infer ] must-fail
-[ [ execute-effect ] infer ] must-fail
+[ [ call-effect ] infer ] [ T{ unknown-macro-input f call-effect } = ] must-fail-with
+[ [ execute-effect ] infer ] [ T{ unknown-macro-input f execute-effect } = ] must-fail-with
diff --git a/basis/stack-checker/state/state-tests.factor b/basis/stack-checker/state/state-tests.factor
deleted file mode 100644 (file)
index a4dea99..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-IN: stack-checker.state.tests
-USING: tools.test stack-checker.state words kernel namespaces
-definitions ;
-
-: computing-dependencies ( quot -- dependencies )
-    H{ } clone [ dependencies rot with-variable ] keep ;
-    inline
-
-SYMBOL: a
-SYMBOL: b
-
-[ ] [ a called-dependency depends-on ] unit-test
-
-[ H{ { a called-dependency } } ] [
-    [ a called-dependency depends-on ] computing-dependencies
-] unit-test
-
-[ H{ { a called-dependency } { b inlined-dependency } } ] [
-    [
-        a called-dependency depends-on b inlined-dependency depends-on
-    ] computing-dependencies
-] unit-test
-
-[ H{ { a inlined-dependency } { b inlined-dependency } } ] [
-    [
-        a inlined-dependency depends-on
-        a called-dependency depends-on
-        b inlined-dependency depends-on
-    ] computing-dependencies
-] unit-test
index a76d302a7ea469f628c18fff73d24cc712e162a7..1c527abfe49e63eb59f6ae889dd3911fb82049af 100644 (file)
@@ -2,14 +2,15 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs arrays namespaces sequences kernel definitions
 math effects accessors words fry classes.algebra
-compiler.units stack-checker.values stack-checker.visitor ;
+compiler.units stack-checker.values stack-checker.visitor
+stack-checker.errors ;
 IN: stack-checker.state
 
 ! Did the current control-flow path throw an error?
 SYMBOL: terminated?
 
 ! Number of inputs current word expects from the stack
-SYMBOL: d-in
+SYMBOL: input-count
 
 DEFER: commit-literals
 
@@ -34,33 +35,13 @@ SYMBOL: literals
         [ [ (push-literal) ] each ] [ delete-all ] bi
     ] unless-empty ;
 
-: current-stack-height ( -- n ) meta-d length d-in get - ;
+: current-stack-height ( -- n ) meta-d length input-count get - ;
 
 : current-effect ( -- effect )
-    d-in get meta-d length terminated? get effect boa ;
+    input-count get meta-d length terminated? get effect boa ;
 
 : init-inference ( -- )
     terminated? off
     V{ } clone \ meta-d set
     V{ } clone literals set
-    0 d-in set ;
-
-! Words that the current quotation depends on
-SYMBOL: dependencies
-
-: depends-on ( word how -- )
-    over primitive? [ 2drop ] [
-        dependencies get dup [
-            swap '[ _ strongest-dependency ] change-at
-        ] [ 3drop ] if
-    ] if ;
-
-! Generic words that the current quotation depends on
-SYMBOL: generic-dependencies
-
-: ?class-or ( class/f class -- class' )
-    swap [ class-or ] when* ;
-
-: depends-on-generic ( generic class -- )
-    generic-dependencies get dup
-    [ swap '[ _ ?class-or ] change-at ] [ 3drop ] if ;
+    0 input-count set ;
index 843083bd52b3c7735abc62cde31eef2c0094ff3c..bbe3cb2ed9a8959072060da2aa886d479846adfe 100644 (file)
@@ -1,15 +1,9 @@
 IN: stack-checker.transforms.tests
 USING: sequences stack-checker.transforms tools.test math kernel
-quotations stack-checker stack-checker.errors accessors combinators words arrays
-classes classes.tuple ;
+quotations stack-checker stack-checker.errors accessors
+combinators words arrays classes classes.tuple macros ;
 
-: compose-n ( quot n -- ) "OOPS" throw ;
-
-<<
-: compose-n-quot ( n word -- quot' ) <repetition> >quotation ;
-\ compose-n [ compose-n-quot ] 2 define-transform
-\ compose-n t "no-compile" set-word-prop
->>
+MACRO: compose-n ( n word -- quot' ) <repetition> >quotation ;
 
 : compose-n-test ( a b c -- x ) 2 \ + compose-n ;
 
@@ -64,14 +58,16 @@ DEFER: smart-combo ( quot -- )
 [ [ [ "a" "b" ] very-smart-combo "c" ] very-smart-combo ] must-infer
 
 ! Caveat found by Doug
-DEFER: curry-folding-test ( quot -- )
-
-\ curry-folding-test [ length \ drop <repetition> >quotation ] 1 define-transform
+MACRO: curry-folding-test ( quot -- )
+    length \ drop <repetition> >quotation ;
 
 { 3 0 } [ [ 1 2 3 ] curry-folding-test ] must-infer-as
 { 3 0 } [ 1 [ 2 3 ] curry curry-folding-test ] must-infer-as
 { 3 0 } [ [ 1 2 ] 3 [ ] curry compose curry-folding-test ] must-infer-as
 
+[ [ curry curry-folding-test ] infer ]
+[ T{ unknown-macro-input f curry-folding-test } = ] must-fail-with
+
 : member?-test ( a -- ? ) { 1 2 3 10 7 58 } member? ;
 
 [ f ] [ 1.0 member?-test ] unit-test
@@ -82,4 +78,8 @@ DEFER: curry-folding-test ( quot -- )
 
 \ bad-macro [ "OOPS" throw ] 0 define-transform
 
-[ [ bad-macro ] infer ] [ inference-error? ] must-fail-with
\ No newline at end of file
+[ [ bad-macro ] infer ] [ f >>continuation T{ transform-expansion-error f "OOPS" f bad-macro } = ] must-fail-with
+
+MACRO: two-params ( a b -- c ) + 1quotation ;
+
+[ [ 3 two-params ] infer ] [ T{ unknown-macro-input f two-params } = ] must-fail-with
\ No newline at end of file
index 11534c58f9f215bd356f85a88e26e7a0fd7bf138..3fdf29b85eaf9cb3922077f4ddd10bc3cb78e97a 100755 (executable)
@@ -7,40 +7,49 @@ classes.tuple.private effects summary hashtables classes sets
 definitions generic.standard slots.private continuations locals
 sequences.private generalizations stack-checker.backend
 stack-checker.state stack-checker.visitor stack-checker.errors
-stack-checker.values stack-checker.recursive-state ;
+stack-checker.values stack-checker.recursive-state
+stack-checker.dependencies ;
 IN: stack-checker.transforms
 
-: call-transformer ( word stack quot -- newquot )
-    '[ _ _ with-datastack [ length 1 assert= ] [ first ] bi nip ]
-    [ transform-expansion-error ]
+: call-transformer ( stack quot -- newquot )
+    '[ _ _ with-datastack [ length 1 assert= ] [ first ] bi ]
+    [ error-continuation get current-word get transform-expansion-error ]
     recover ;
 
-:: ((apply-transform)) ( word quot values stack rstate -- )
-    rstate recursive-state
-    [ word stack quot call-transformer ] with-variable
-    [
-        values [ length meta-d shorten-by ] [ #drop, ] bi
-        rstate infer-quot
-    ] [ word infer-word ] if* ;
-
-: literals? ( values -- ? ) [ literal-value? ] all? ;
-
-: (apply-transform) ( word quot n -- )
-    ensure-d dup literals? [
-        dup empty? [ dup recursive-state get ] [
-            [ ]
-            [ [ literal value>> ] map ]
-            [ first literal recursion>> ] tri
-        ] if
-        ((apply-transform))
-    ] [ 2drop infer-word ] if ;
+:: ((apply-transform)) ( quot values stack rstate -- )
+    rstate recursive-state [ stack quot call-transformer ] with-variable
+    values [ length meta-d shorten-by ] [ #drop, ] bi
+    rstate infer-quot ;
+
+: literal-values? ( values -- ? ) [ literal-value? ] all? ;
+
+: input-values? ( values -- ? )
+    [ { [ literal-value? ] [ input-value? ] } 1|| ] all? ;
+
+: (apply-transform) ( quot n -- )
+    ensure-d {
+        { [ dup literal-values? ] [
+            dup empty? [ dup recursive-state get ] [
+                [ ]
+                [ [ literal value>> ] map ]
+                [ first literal recursion>> ] tri
+            ] if
+            ((apply-transform))
+        ] }
+        { [ dup input-values? ] [ drop current-word get unknown-macro-input ] }
+        [ drop current-word get bad-macro-input ]
+    } cond ;
 
 : apply-transform ( word -- )
-    [ ] [ "transform-quot" word-prop ] [ "transform-n" word-prop ] tri
+    [ current-word set ]
+    [ "transform-quot" word-prop ]
+    [ "transform-n" word-prop ] tri
     (apply-transform) ;
 
 : apply-macro ( word -- )
-    [ ] [ "macro" word-prop ] [ "declared-effect" word-prop in>> length ] tri
+    [ current-word set ]
+    [ "macro" word-prop ]
+    [ "declared-effect" word-prop in>> length ] tri
     (apply-transform) ;
 
 : define-transform ( word quot n -- )
index 19db441381d021f51ce2db78b63ee6d26af184d4..7e11ec3edb57a85f51f73e1219e2d5299bdc0eea 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: accessors namespaces kernel assocs sequences
-stack-checker.recursive-state ;
+stack-checker.recursive-state stack-checker.errors ;
 IN: stack-checker.values
 
 ! Values
@@ -28,21 +28,25 @@ SYMBOL: known-values
 
 GENERIC: (literal-value?) ( value -- ? )
 
-M: object (literal-value?) drop f ;
+: literal-value? ( value -- ? ) known (literal-value?) ;
+
+GENERIC: (input-value?) ( value -- ? )
+
+: input-value? ( value -- ? ) known (input-value?) ;
 
-GENERIC: (literal) ( value -- literal )
+GENERIC: (literal) ( known -- literal )
 
 ! Literal value
-TUPLE: literal < identity-tuple value recursion hashcode ;
+TUPLE: literal < identity-tuple value recursion ;
 
 : literal ( value -- literal ) known (literal) ;
 
-: literal-value? ( value -- ? ) known (literal-value?) ;
-
-M: literal hashcode* nip hashcode>> ;
+M: literal hashcode* nip value>> identity-hashcode ;
 
 : <literal> ( obj -- value )
-    recursive-state get over hashcode \ literal boa ;
+    recursive-state get \ literal boa ;
+
+M: literal (input-value?) drop f ;
 
 M: literal (literal-value?) drop t ;
 
@@ -51,7 +55,7 @@ M: literal (literal) ;
 : curried/composed-literal ( input1 input2 quot -- literal )
     [ [ literal ] bi@ ] dip
     [ [ [ value>> ] bi@ ] dip call ] [ drop nip recursion>> ] 3bi
-    over hashcode \ literal boa ; inline
+    \ literal boa ; inline
 
 ! Result of curry
 TUPLE: curried obj quot ;
@@ -61,7 +65,10 @@ C: <curried> curried
 : >curried< ( curried -- obj quot )
     [ obj>> ] [ quot>> ] bi ; inline
 
+M: curried (input-value?) >curried< [ input-value? ] either? ;
+
 M: curried (literal-value?) >curried< [ literal-value? ] both? ;
+
 M: curried (literal) >curried< [ curry ] curried/composed-literal ;
 
 ! Result of compose
@@ -72,5 +79,27 @@ C: <composed> composed
 : >composed< ( composed -- quot1 quot2 )
     [ quot1>> ] [ quot2>> ] bi ; inline
 
+M: composed (input-value?)
+    [ quot1>> input-value? ] [ quot2>> input-value? ] bi or ;
+
 M: composed (literal-value?) >composed< [ literal-value? ] both? ;
-M: composed (literal) >composed< [ compose ] curried/composed-literal ;
\ No newline at end of file
+
+M: composed (literal) >composed< [ compose ] curried/composed-literal ;
+
+! Input parameters
+SINGLETON: input-parameter
+
+SYMBOL: current-word
+
+M: input-parameter (input-value?) drop t ;
+
+M: input-parameter (literal-value?) drop f ;
+
+M: input-parameter (literal) current-word get unknown-macro-input ;
+
+! Computed values
+M: f (input-value?) drop f ;
+
+M: f (literal-value?) drop f ;
+
+M: f (literal) current-word get bad-macro-input ;
\ No newline at end of file
index 931cb36ea949b8c394164e3e85d9bbdaa34b09bb..f486adcb32e27f882289eb4a6b4b567c41706126 100755 (executable)
@@ -22,8 +22,7 @@ IN: suffix-arrays
 
 : <funky-slice> ( from/f to/f seq -- slice )
     [
-        tuck
-        [ drop 0 or ] [ length or ] 2bi*
+        [ drop 0 or ] [ length or ] bi-curry bi*
         [ min ] keep
     ] keep <slice> ; inline
 
index 5f83eb268b0fcd0c353f999adbd2a72643ccc9d1..0c21597a2f4ca9d1ecbb19a25ddb3866862e9c29 100644 (file)
@@ -7,7 +7,7 @@ SPECIALIZED-ARRAY: char
 IN: system-info.linux
 
 : (uname) ( buf -- int )
-    "int" f "uname" { "char*" } alien-invoke ;
+    int f "uname" { char* } alien-invoke ;
 
 : uname ( -- seq )
     65536 <char-array> [ (uname) io-error ] keep
index 610a664c7b85f6542e6c3038051d0ee7bf20892f..79aad20b856b0e875dbdf222b96b43b530b7de37 100644 (file)
@@ -32,13 +32,12 @@ yield
 [ [ 3 throw ] "A" suspend ] [ 3 = ] must-fail-with
 
 :: spawn-namespace-test ( -- ? )
-    [let | p [ <promise> ] g [ gensym ] |
-        [
-            g "x" set
-            [ "x" get p fulfill ] "B" spawn drop
-        ] with-scope
-        p ?promise g eq?
-    ] ;
+    <promise> :> p gensym :> g
+    [
+        g "x" set
+        [ "x" get p fulfill ] "B" spawn drop
+    ] with-scope
+    p ?promise g eq? ;
 
 [ t ] [ spawn-namespace-test ] unit-test
 
index f5d4b5512909c35f29a40e1a48c7c9e3cff874ef..134395f1a85881e02a047c8f90f2fd3e8fa9659f 100644 (file)
@@ -24,13 +24,13 @@ M: word quot-uses over crossref? [ conjoin ] [ 2drop ] if ;
     [ quot-uses ] curry each ;
 
 : seq-uses ( seq assoc -- )
-    over visited get memq? [ 2drop ] [
+    over visited get member-eq? [ 2drop ] [
         over visited get push
         (seq-uses)
     ] if ;
 
 : assoc-uses ( assoc' assoc -- )
-    over visited get memq? [ 2drop ] [
+    over visited get member-eq? [ 2drop ] [
         over visited get push
         [ >alist ] dip (seq-uses)
     ] if ;
index 784b034665a68462193c223238b4cd08c1258fb0..9244f06b4e9d99dda7d1f46c07b78af76b27c60e 100644 (file)
@@ -5,32 +5,32 @@ io.launcher arrays namespaces continuations layouts accessors
 urls math.parser io.directories tools.deploy.test ;\r
 IN: tools.deploy.tests\r
 \r
-[ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test\r
+[ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test\r
 \r
-[ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test\r
+[ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test\r
 \r
-[ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test\r
+[ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test\r
 \r
 [ "staging.math-threads-compiler-ui.image" ] [\r
     "hello-ui" deploy-config\r
     [ bootstrap-profile staging-image-name file-name ] bind\r
 ] unit-test\r
 \r
-[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test\r
+[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test\r
 \r
-[ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test\r
+[ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test\r
 \r
-[ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test\r
+[ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test\r
 \r
-[ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test\r
+[ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test\r
 \r
-[ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test\r
+[ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test\r
 \r
 os macosx? [\r
-    [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test\r
+    [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test\r
 ] when\r
 \r
-[ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test\r
+[ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test\r
 \r
 {\r
     "tools.deploy.test.1"\r
index 470194ed9d166d0b42e6bf11c9249b9992419090..c79065bb29b17baf8ca449199c5e62f8b19cb44f 100755 (executable)
@@ -9,6 +9,7 @@ compiler.units definitions generic generic.standard
 generic.single tools.deploy.config combinators classes
 classes.builtin slots.private grouping command-line ;
 QUALIFIED: bootstrap.stage2
+QUALIFIED: compiler.crossref
 QUALIFIED: compiler.errors
 QUALIFIED: continuations
 QUALIFIED: definitions
@@ -258,7 +259,7 @@ IN: tools.deploy.shaker
             ! otherwise do nothing
             [ 2drop ]
         } cond
-    ] change-each ;
+    ] map! drop ;
 
 : strip-default-method ( generic new-default -- )
     [
@@ -340,8 +341,8 @@ IN: tools.deploy.shaker
                 implementors-map
                 update-map
                 main-vocab-hook
-                compiled-crossref
-                compiled-generic-crossref
+                compiler.crossref:compiled-crossref
+                compiler.crossref:compiled-generic-crossref
                 compiler-impl
                 compiler.errors:compiler-errors
                 lexer-factory
@@ -477,7 +478,7 @@ SYMBOL: deploy-vocab
     next-method ;
 
 : calls-next-method? ( method -- ? )
-    def>> flatten \ (call-next-method) swap memq? ;
+    def>> flatten \ (call-next-method) swap member-eq? ;
 
 : compute-next-methods ( -- )
     [ standard-generic? ] instances [
index d6caa0e68bfb816977595087be8f665b0ecda361..65fd50b5b88f0494897f1fd514bd2fc242bd6ccd 100644 (file)
@@ -1,7 +1,9 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors classes.struct cocoa cocoa.classes
-cocoa.subclassing core-graphics.types kernel math ;
+cocoa.runtime cocoa.subclassing cocoa.types core-graphics.types
+kernel math ;
+FROM: alien.c-types => float ;
 IN: tools.deploy.test.14
 
 CLASS: {
@@ -9,8 +11,8 @@ CLASS: {
     { +name+ "Bar" }
 } {
     "bar:"
-    "float"
-    { "id" "SEL" "NSRect" }
+    float
+    { id SEL NSRect }
     [
         [ origin>> [ x>> ] [ y>> ] bi + ]
         [ size>> [ w>> ] [ h>> ] bi + ]
index a9ee71131ceb70e74c8a487cbebced7308d240c0..fb005d2a4683b9aae04bfd13274641b542998653 100644 (file)
@@ -1,5 +1,5 @@
+USING: io.encodings.string kernel io.encodings.8-bit.latin7 ;
 IN: tools.deploy.test.4
-USING: io.encodings.8-bit io.encodings.string kernel ;
 
 : deploy-test-4 ( -- )
     "xyzthg" \ latin7 encode drop ;
index a1cbd5bc668f3fa27bac0352ced9406bd8466a66..642ee48e6769a8b6f3a58e8154d5f198ff6ad6bc 100644 (file)
@@ -1,10 +1,10 @@
-USING: alien kernel math ;
+USING: alien alien.c-types kernel math ;
 IN: tools.deploy.test.9
 
 : callback-test ( -- callback )
-    "int" { "int" } "cdecl" [ 1 + ] alien-callback ;
+    int { int } "cdecl" [ 1 + ] alien-callback ;
 
 : indirect-test ( -- )
-    10 callback-test "int" { "int" } "cdecl" alien-indirect 11 assert= ;
+    10 callback-test int { int } "cdecl" alien-indirect 11 assert= ;
 
 MAIN: indirect-test
index c799ec615e8dd8ae60fad784266e339074d68a0e..d8414baba7842956137e5ced29db9987e87b3c10 100755 (executable)
@@ -10,14 +10,16 @@ IN: tools.deploy.test
         dup deploy-config make-deploy-image
     ] with-directory ;
 
-: small-enough? ( n -- ? )
+ERROR: image-too-big actual-size max-size ;
+
+: small-enough? ( n -- )
     [ "test.image" temp-file file-info size>> ]
     [
         cell 4 / *
         cpu ppc? [ 100000 + ] when
         os windows? [ 150000 + ] when
     ] bi*
-    <= ;
+    2dup <= [ 2drop ] [ image-too-big ] if ;
 
 : deploy-test-command ( -- args )
     os macosx?
index fb3df736f4ef69c0bab0770c0916097254d08392..a7390010d0104e8f6ffd62d0b0f89be223fbe29d 100644 (file)
@@ -6,7 +6,7 @@ HELP: :deprecations
 { $description "Prints all deprecation notes." } ;
 
 ARTICLE: "tools.deprecation" "Deprecation tracking"
-"Factor's core syntax defines a " { $link POSTPONE: deprecated } " word that can be applied to words to mark them as deprecated. When the " { $vocab-link "tools.deprecation" } " vocabulary is loaded, notes will be collected and reported by the " { $link "tools.errors" } " mechanism when deprecated words are used to define other words."
+"Factor's core syntax defines a " { $link POSTPONE: deprecated } " word that can be applied to words to mark them as deprecated. Notes are collected and reported by the " { $link "tools.errors" } " mechanism when deprecated words are used to define other words."
 { $subsections
     POSTPONE: deprecated
     :deprecations
diff --git a/basis/tools/dispatch/authors.txt b/basis/tools/dispatch/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/tools/dispatch/dispatch-docs.factor b/basis/tools/dispatch/dispatch-docs.factor
new file mode 100644 (file)
index 0000000..e93ea16
--- /dev/null
@@ -0,0 +1,8 @@
+IN: tools.dispatch
+USING: help.markup help.syntax vm quotations ;
+
+HELP: last-dispatch-stats
+{ $var-description "A " { $link dispatch-statistics } " instance, set by " { $link collect-dispatch-stats } "." } ;
+
+HELP: dispatch-stats.
+{ $description "Prints method dispatch statistics from the last call to " { $link collect-dispatch-stats } "." } ;
diff --git a/basis/tools/dispatch/dispatch.factor b/basis/tools/dispatch/dispatch.factor
new file mode 100644 (file)
index 0000000..7d30dac
--- /dev/null
@@ -0,0 +1,24 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel namespaces prettyprint classes.struct
+vm tools.dispatch.private ;
+IN: tools.dispatch
+
+SYMBOL: last-dispatch-stats
+
+: dispatch-stats. ( -- )
+    last-dispatch-stats get {
+        { "Megamorphic hits" [ megamorphic-cache-hits>> ] }
+        { "Megamorphic misses" [ megamorphic-cache-misses>> ] }
+        { "Cold to monomorphic" [ cold-call-to-ic-transitions>> ] }
+        { "Mono to polymorphic" [ ic-to-pic-transitions>> ] }
+        { "Poly to megamorphic" [ pic-to-mega-transitions>> ] }
+        { "Tag check count" [ pic-tag-count>> ] }
+        { "Tuple check count" [ pic-tuple-count>> ] }
+    } object-table. ;
+
+: collect-dispatch-stats ( quot -- )
+    reset-dispatch-stats
+    call
+    dispatch-stats dispatch-statistics memory>struct
+    last-dispatch-stats set ; inline
index 963ea7592ccec5ddd5709f7ced0211f36e4c5cb0..0bf271535a31b0d80ffc1b4d0541ff0f28bebbac 100644 (file)
@@ -8,10 +8,6 @@ IN: tools.errors
 #! Tools for source-files.errors. Used by tools.tests and others
 #! for error reporting
 
-M: source-file-error compute-restarts error>> compute-restarts ;
-
-M: source-file-error error-help error>> error-help ;
-
 CONSTANT: +listener-input+ "<Listener input>"
 
 : error-location ( error -- string )
index 7ecbf402ab42dd5554e346219eea03cb2b9e3881..b18396538f3f09c1034fb694286a6cacb4832352 100644 (file)
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax memory sequences ;
+USING: help.markup help.syntax memory sequences vm ;
 IN: tools.memory
 
 ARTICLE: "tools.memory" "Object memory tools"
@@ -13,11 +13,8 @@ ARTICLE: "tools.memory" "Object memory tools"
     data-room
     code-room
 }
-"There are a pair of combinators, analogous to " { $link each } " and " { $link filter } ", which operate on the entire collection of objects in the object heap:"
-{ $subsections
-    each-object
-    instances
-}
+"A combinator to get objects from the heap:"
+{ $subsections instances }
 "You can check an object's the heap memory usage:"
 { $subsections size }
 "The garbage collector can be invoked manually:"
@@ -39,3 +36,15 @@ HELP: heap-stats.
 { $description "For each class, prints the number of instances and total memory consumed by those instances." } ;
 
 { heap-stats heap-stats. } related-words
+
+HELP: gc-events.
+{ $description "Prints all garbage collection events that took place during the last call to " { $link collect-gc-events } "." } ;
+
+HELP: gc-stats.
+{ $description "Prints a breakdown of different garbage collection events that took place during the last call to " { $link collect-gc-events } "." } ;
+
+HELP: gc-summary.
+{ $description "Prints aggregate garbage collection statistics from the last call to " { $link collect-gc-events } "." } ;
+
+HELP: gc-events
+{ $var-description "A sequence of " { $link gc-event } " instances, set by " { $link collect-gc-events } ". Can be inspected directly, or with the " { $link gc-events. } ", " { $link gc-stats. } " and " { $link gc-summary. } " words." } ;
index 4b75cf0bfa33ed04d436bc9ae31834ef0945ac01..4711f472a390e17ab8643f198625fed40b29aa18 100644 (file)
@@ -1,5 +1,9 @@
-USING: tools.test tools.memory ;
+USING: tools.test tools.memory memory ;
 IN: tools.memory.tests
 
 [ ] [ room. ] unit-test
 [ ] [ heap-stats. ] unit-test
+[ ] [ [ gc gc ] collect-gc-events ] unit-test
+[ ] [ gc-events. ] unit-test
+[ ] [ gc-stats. ] unit-test
+[ ] [ gc-summary. ] unit-test
index 81785f7ea47875d8a684b13b0893079d278e8ce1..cf7e3ee38d81b6aa67001da1ef313302cd93b572 100644 (file)
@@ -1,55 +1,77 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences arrays generic assocs io math
-namespaces parser prettyprint strings io.styles words
-system sorting splitting grouping math.parser classes memory
-combinators fry ;
+USING: accessors arrays assocs classes classes.struct
+combinators combinators.smart continuations fry generalizations
+generic grouping io io.styles kernel make math math.parser
+math.statistics memory namespaces parser prettyprint sequences
+sorting splitting strings system vm words ;
 IN: tools.memory
 
 <PRIVATE
 
-: write-size ( n -- )
-    number>string
-    dup length 4 > [ 3 cut* "," glue ] when
-    " KB" append write-cell ;
+: commas ( n -- str )
+    dup 0 < [ neg commas "-" prepend ] [
+        number>string
+        reverse 3 group "," join reverse
+    ] if ;
 
-: write-total/used/free ( free total str -- )
-    [
-        write-cell
-        dup write-size
-        over - write-size
-        write-size
-    ] with-row ;
+: kilobytes ( n -- str )
+    1024 /i commas " KB" append ;
 
-: write-total ( n str -- )
-    [
-        write-cell
-        write-size
-        [ ] with-cell
-        [ ] with-cell
-    ] with-row ;
-
-: write-headings ( seq -- )
-    [ [ write-cell ] each ] with-row ;
-
-: (data-room.) ( -- )
-    data-room 2 <groups> [
-        [ first2 ] [ number>string "Generation " prepend ] bi*
-        write-total/used/free
-    ] each-index
-    "Decks" write-total
-    "Cards" write-total ;
-
-: write-labeled-size ( n string -- )
-    [ write-cell write-size ] with-row ;
-
-: (code-room.) ( -- )
-    code-room {
-        [ "Size:" write-labeled-size ]
-        [ "Used:" write-labeled-size ]
-        [ "Total free space:" write-labeled-size ]
-        [ "Largest free block:" write-labeled-size ]
-    } spread ;
+: micros>string ( n -- str )
+    commas " µs" append ;
+
+: copying-room. ( copying-sizes -- )
+    {
+        { "Size:" [ size>> kilobytes ] }
+        { "Occupied:" [ occupied>> kilobytes ] }
+        { "Free:" [ free>> kilobytes ] }
+    } object-table. ;
+
+: nursery-room. ( data-room -- )
+    "- Nursery space" print nursery>> copying-room. ;
+
+: aging-room. ( data-room -- )
+    "- Aging space" print aging>> copying-room. ;
+
+: mark-sweep-table. ( mark-sweep-sizes -- )
+    {
+        { "Size:" [ size>> kilobytes ] }
+        { "Occupied:" [ occupied>> kilobytes ] }
+        { "Total free:" [ total-free>> kilobytes ] }
+        { "Contiguous free:" [ contiguous-free>> kilobytes ] }
+        { "Free block count:" [ free-block-count>> number>string ] }
+    } object-table. ;
+
+: tenured-room. ( data-room -- )
+    "- Tenured space" print tenured>> mark-sweep-table. ;
+
+: misc-room. ( data-room -- )
+    "- Miscellaneous buffers" print
+    {
+        { "Card array:" [ cards>> kilobytes ] }
+        { "Deck array:" [ decks>> kilobytes ] }
+        { "Mark stack:" [ mark-stack>> kilobytes ] }
+    } object-table. ;
+
+: data-room. ( -- )
+    "== Data heap ==" print nl
+    data-room data-heap-room memory>struct {
+        [ nursery-room. nl ]
+        [ aging-room. nl ]
+        [ tenured-room. nl ]
+        [ misc-room. ]
+    } cleave ;
+
+: code-room. ( -- )
+    "== Code heap ==" print nl
+    code-room mark-sweep-sizes memory>struct mark-sweep-table. ;
+
+PRIVATE>
+
+: room. ( -- ) data-room. nl code-room. ;
+
+<PRIVATE
 
 : heap-stat-step ( obj counts sizes -- )
     [ [ class ] dip inc-at ]
@@ -57,26 +79,13 @@ IN: tools.memory
 
 PRIVATE>
 
-: room. ( -- )
-    "==== DATA HEAP" print
-    standard-table-style [
-        { "" "Total" "Used" "Free" } write-headings
-        (data-room.)
-    ] tabular-output
-    nl nl
-    "==== CODE HEAP" print
-    standard-table-style [
-        (code-room.)
-    ] tabular-output
-    nl ;
-
 : heap-stats ( -- counts sizes )
     [ ] instances H{ } clone H{ } clone
     [ '[ _ _ heap-stat-step ] each ] 2keep ;
 
 : heap-stats. ( -- )
     heap-stats dup keys natural-sort standard-table-style [
-        { "Class" "Bytes" "Instances" } write-headings
+        [ { "Class" "Bytes" "Instances" } [ write-cell ] each ] with-row
         [
             [
                 dup pprint-cell
@@ -85,3 +94,104 @@ PRIVATE>
             ] with-row
         ] each 2drop
     ] tabular-output nl ;
+
+SYMBOL: gc-events
+
+: collect-gc-events ( quot -- )
+    enable-gc-events
+    [ ] [ disable-gc-events drop ] cleanup
+    disable-gc-events [ gc-event memory>struct ] map gc-events set ; inline
+
+<PRIVATE
+
+: gc-op-string ( op -- string )
+    {
+        { collect-nursery-op      [ "Copying from nursery" ] }
+        { collect-aging-op        [ "Copying from aging"   ] }
+        { collect-to-tenured-op   [ "Copying to tenured"   ] }
+        { collect-full-op         [ "Mark and sweep"       ] }
+        { collect-compact-op      [ "Mark and compact"     ] }
+        { collect-growing-heap-op [ "Grow heap"            ] }
+    } case ;
+
+: (space-occupied) ( data-heap-room code-heap-room -- n )
+    [
+        [ [ nursery>> ] [ aging>> ] [ tenured>> ] tri [ occupied>> ] tri@ ]
+        [ occupied>> ]
+        bi*
+    ] sum-outputs ;
+
+: space-occupied-before ( event -- bytes )
+    [ data-heap-before>> ] [ code-heap-before>> ] bi (space-occupied) ;
+
+: space-occupied-after ( event -- bytes )
+    [ data-heap-after>> ] [ code-heap-after>> ] bi (space-occupied) ;
+
+: space-reclaimed ( event -- bytes )
+    [ space-occupied-before ] [ space-occupied-after ] bi - ;
+
+TUPLE: gc-stats collections times ;
+
+: <gc-stats> ( -- stats )
+    gc-stats new
+        0 >>collections
+        V{ } clone >>times ; inline
+
+: compute-gc-stats ( events -- stats )
+    V{ } clone [
+        '[
+            dup op>> _ [ drop <gc-stats> ] cache
+            [ 1 + ] change-collections
+            [ total-time>> ] dip times>> push
+        ] each
+    ] keep sort-keys ;
+
+: gc-stats-table-row ( pair -- row )
+    [
+        [ first gc-op-string ] [
+            second
+            [ collections>> ]
+            [
+                times>> {
+                    [ sum micros>string ]
+                    [ mean >integer micros>string ]
+                    [ median >integer micros>string ]
+                    [ infimum micros>string ]
+                    [ supremum micros>string ]
+                } cleave
+            ] bi
+        ] bi
+    ] output>array ;
+
+: gc-stats-table ( stats -- table )
+    [ gc-stats-table-row ] map
+    { "" "Number" "Total" "Mean" "Median" "Min" "Max" } prefix ;
+
+PRIVATE>
+
+: gc-event. ( event -- )
+    {
+        { "Event type:" [ op>> gc-op-string ] }
+        { "Total time:" [ total-time>> micros>string ] }
+        { "Space reclaimed:" [ space-reclaimed kilobytes ] }
+    } object-table. ;
+
+: gc-events. ( -- )
+    gc-events get [ gc-event. nl ] each ;
+
+: gc-stats. ( -- )
+    gc-events get compute-gc-stats gc-stats-table simple-table. ;
+
+: gc-summary. ( -- )
+    gc-events get {
+        { "Collections:" [ length commas ] }
+        { "Cards scanned:" [ [ cards-scanned>> ] map-sum commas ] }
+        { "Decks scanned:" [ [ decks-scanned>> ] map-sum commas ] }
+        { "Code blocks scanned:" [ [ code-blocks-scanned>> ] map-sum commas ] }
+        { "Total time:" [ [ total-time>> ] map-sum micros>string ] }
+        { "Card scan time:" [ [ card-scan-time>> ] map-sum micros>string ] }
+        { "Code block scan time:" [ [ code-scan-time>> ] map-sum micros>string ] }
+        { "Data heap sweep time:" [ [ data-sweep-time>> ] map-sum micros>string ] }
+        { "Code heap sweep time:" [ [ code-sweep-time>> ] map-sum micros>string ] }
+        { "Compaction time:" [ [ compaction-time>> ] map-sum micros>string ] }
+    } object-table. ;
index 0fda4a65e553b8f5ff5dd6abeaab7b86ba1c78cf..66ae5d7bd332485175e53182b8c4761d42c11f30 100644 (file)
@@ -25,7 +25,7 @@ $nl
     method-profile.
     "profiler-limitations"
 }
-{ $see-also "ui.tools.profiler" } ;
+{ $see-also "ui.tools.profiler" "tools.annotations" "timing" } ;
 
 ABOUT: "profiling"
 
index dda531faeed1c0e3871806c2efb196b7c16b5cf5..6e5177fbae9088df87b844b137cb4a271d0f8948 100644 (file)
@@ -1,7 +1,7 @@
-IN: tools.profiler.tests
 USING: accessors tools.profiler tools.test kernel memory math
-threads alien tools.profiler.private sequences compiler compiler.units
-words ;
+threads alien alien.c-types tools.profiler.private sequences
+compiler compiler.units words ;
+IN: tools.profiler.tests
 
 [ t ] [
     \ length counter>>
@@ -21,9 +21,9 @@ words ;
 
 [ ] [ \ + usage-profile. ] unit-test
 
-: callback-test ( -- callback ) "void" { } "cdecl" [ ] alien-callback ;
+: callback-test ( -- callback ) void { } "cdecl" [ ] alien-callback ;
 
-: indirect-test ( callback -- ) "void" { } "cdecl" alien-indirect ;
+: indirect-test ( callback -- ) void { } "cdecl" alien-indirect ;
 
 : foobar ( -- ) ;
 
@@ -60,7 +60,7 @@ words ;
 
 [ [ gensym execute ] profile ] [ T{ undefined } = ] must-fail-with
 
-: crash-bug-1 ( -- x ) "hi" "bye" <word> ;
+: crash-bug-1 ( -- x ) "hi" <uninterned-word> ;
 : crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ;
 
 [ ] [ [ crash-bug-2 ] profile ] unit-test
index 219344db3b0b2cfd364d3e86290111c39b3bbc92..8279a905147003a2260b37f46117cd1d1350c349 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors words sequences math prettyprint kernel arrays io
-io.styles namespaces assocs kernel.private strings combinators
-sorting math.parser vocabs definitions tools.profiler.private
-tools.crossref continuations generic compiler.units sets classes fry ;
+USING: accessors words sequences math prettyprint kernel arrays
+io io.styles namespaces assocs kernel.private strings
+combinators sorting math.parser vocabs definitions
+tools.profiler.private tools.crossref continuations generic
+compiler.units compiler.crossref sets classes fry ;
 IN: tools.profiler
 
 : profile ( quot -- )
@@ -19,7 +20,7 @@ IN: tools.profiler
     [ dup counter>> ] map-counters ;
 
 : cumulative-counters ( obj quot -- alist )
-    '[ dup @ [ counter>> ] sigma ] map-counters ; inline
+    '[ dup @ [ counter>> ] map-sum ] map-counters ; inline
 
 : vocab-counters ( -- alist )
     vocabs [ words [ predicate? not ] filter ] cumulative-counters ;
index 089bad3158ba44dde8506b8b11a2956039421bd1..936d388b0126095ecfc58e72ec32cdfd4b997648 100755 (executable)
@@ -98,7 +98,7 @@ M: bad-developer-name summary
     [ main-file-string ] dip utf8 set-file-contents ;
 
 : scaffold-main ( vocab-root vocab -- )
-    tuck ".factor" vocab-root/vocab/suffix>path scaffolding? [
+    [ ".factor" vocab-root/vocab/suffix>path ] keep swap scaffolding? [
         set-scaffold-main-file
     ] [
         2drop
index 097460837bfa5f83210835436c4fe66fd756512c..559b1357c80ac34188d9e962d94a244444e071ba 100644 (file)
@@ -96,9 +96,9 @@ MACRO: <experiment> ( word -- )
     ] [ drop ] if ; inline
 
 : parse-test ( accum word -- accum )
-    literalize parsed
-    lexer get line>> parsed
-    \ experiment parsed ; inline
+    literalize suffix!
+    lexer get line>> suffix!
+    \ experiment suffix! ; inline
 
 <<
 
@@ -121,9 +121,6 @@ SYNTAX: TEST:
         vocab-tests [ run-test-file ] each
     ] [ drop ] if ;
 
-: traceback-button. ( failure -- )
-    "[" write [ "Traceback" ] dip continuation>> write-object "]" print ;
-
 PRIVATE>
 
 TEST: unit-test
@@ -137,7 +134,7 @@ M: test-failure error. ( error -- )
         [ error-location print nl ]
         [ asset>> [ experiment. nl ] when* ]
         [ error>> error. ]
-        [ traceback-button. ]
+        [ continuation>> traceback-link. ]
     } cleave ;
 
 : :test-failures ( -- ) test-failures get errors. ;
index 408592d0c67c52b6bd457ee580cd7168784ba03a..9e892c33eccf24f2834f64704358971253602706 100644 (file)
@@ -1,28 +1,38 @@
-USING: help.markup help.syntax memory system ;
+USING: help.markup help.syntax memory system tools.dispatch
+tools.memory quotations vm ;
 IN: tools.time
 
-ARTICLE: "timing" "Timing code"
+ARTICLE: "timing" "Timing code and collecting statistics"
 "You can time the execution of a quotation in the listener:"
 { $subsections time }
+"This word also collects statistics about method dispatch and garbage collection:"
+{ $subsections dispatch-stats. gc-events. gc-stats. gc-summary. }
 "A lower-level word puts timings on the stack, intead of printing:"
 { $subsections benchmark }
-"You can also read the system clock and garbage collection statistics directly:"
-{ $subsections
-    micros
-    gc-stats
-}
-{ $see-also "profiling" } ;
+"You can also read the system clock directly:"
+{ $subsections micros }
+{ $see-also "profiling" "calendar" } ;
 
 ABOUT: "timing"
 
 HELP: benchmark
-{ $values { "quot" "a quotation" }
+{ $values { "quot" quotation }
           { "runtime" "the runtime in microseconds" } }
       { $description "Runs a quotation, measuring the total wall clock time." }
 { $notes "A nicer word for interactive use is " { $link time } "." } ;
 
 HELP: time
-{ $values { "quot" "a quotation" } }
-{ $description "Runs a quotation and then prints the total run time and some garbage collection statistics." } ;
+{ $values { "quot" quotation } }
+{ $description "Runs a quotation, gathering statistics about method dispatch and garbage collection, and then prints the total run time." } ;
 
 { benchmark micros time } related-words
+
+HELP: collect-gc-events
+{ $values { "quot" quotation } }
+{ $description "Calls the quotation, storing an array of " { $link gc-event } " instances in the " { $link gc-events } " variable." }
+{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
+
+HELP: collect-dispatch-stats
+{ $values { "quot" quotation } }
+{ $description "Calls the quotation, collecting method dispatch statistics and storing them in the " { $link last-dispatch-stats } " variable. " }
+{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
diff --git a/basis/tools/time/time-tests.factor b/basis/tools/time/time-tests.factor
new file mode 100644 (file)
index 0000000..00c7746
--- /dev/null
@@ -0,0 +1,4 @@
+IN: tools.time.tests
+USING: tools.time tools.test compiler ;
+
+[ ] [ [ [ ] time ] compile-call ] unit-test
index 948c0d482db0ea7dbd985a7bf0592891de67ca4e..3724a741b7f6e068e5b8173961cdecff20a03efc 100644 (file)
@@ -1,74 +1,22 @@
-! Copyright (C) 2003, 2008 Slava Pestov.
+! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math memory io io.styles prettyprint
-namespaces system sequences splitting grouping assocs strings
-generic.single combinators ;
+USING: system kernel math io prettyprint tools.memory
+tools.dispatch ;
 IN: tools.time
 
 : benchmark ( quot -- runtime )
     micros [ call micros ] dip - ; inline
 
 : time. ( time -- )
-    "== Running time ==" print nl 1000000 /f pprint " seconds" print ;
+    "Running time: " write 1000000 /f pprint " seconds" print ;
 
-: gc-stats. ( stats -- )
-    5 cut*
-    "== Garbage collection ==" print nl
-    "Times are in microseconds." print nl
-    [
-        6 group
-        {
-            "GC count:"
-            "Total GC time:"
-            "Longest GC pause:"
-            "Average GC pause:"
-            "Objects copied:"
-            "Bytes copied:"
-        } prefix
-        flip
-        { "" "Nursery" "Aging" "Tenured" } prefix
-        simple-table.
-    ]
-    [
-        nl
-        {
-            "Total GC time:"
-            "Cards scanned:"
-            "Decks scanned:"
-            "Card scan time:"
-            "Code heap literal scans:"
-        } swap zip simple-table.
-    ] bi* ;
-
-: dispatch-stats. ( stats -- )
-    "== Megamorphic caches ==" print nl
-    { "Hits" "Misses" } swap zip simple-table. ;
-
-: inline-cache-stats. ( stats -- )
-    nl "== Polymorphic inline caches ==" print nl
-    3 cut
-    [
-        "Transitions:" print
-        { "Cold to monomorphic" "Mono to polymorphic" "Poly to megamorphic" } swap zip
-        simple-table. nl
-    ] [
-        "Type check stubs:" print
-        { "Tag only" "Hi-tag" "Tuple" "Hi-tag and tuple" } swap zip
-        simple-table.
-    ] bi* ;
+: time-banner. ( -- )
+    "Additional information was collected." print
+    "dispatch-stats.  - Print method dispatch statistics" print
+    "gc-events.       - Print all garbage collection events" print
+    "gc-stats.        - Print breakdown of different garbage collection events" print
+    "gc-summary.      - Print aggregate garbage collection statistics" print ;
 
 : time ( quot -- )
-    gc-reset
-    reset-dispatch-stats
-    reset-inline-cache-stats
-    benchmark gc-stats dispatch-stats inline-cache-stats
-    H{ { table-gap { 20 20 } } } [
-        [
-            [ [ time. ] 3dip ] with-cell
-            [ ] with-cell
-        ] with-row
-        [
-            [ [ gc-stats. ] 2dip ] with-cell
-            [ [ dispatch-stats. ] [ inline-cache-stats. ] bi* ] with-cell
-        ] with-row
-    ] tabular-output nl ; inline
+    [ [ benchmark ] collect-dispatch-stats ] collect-gc-events
+    time. nl time-banner. ; inline
index 80113607d42c44349ddd35607d737130f8ec8273..2ab74bf7359b3f19e212484c0357b069043ce0ea 100644 (file)
@@ -6,26 +6,25 @@ namespaces namespaces.private assocs accessors ;
 IN: tools.walker.debug
 
 :: test-walker ( quot -- data )
-    [let | p [ <promise> ] |
-        [
-            H{ } clone >n
+    <promise> :> p
+    [
+        H{ } clone >n
 
-            [
-                p promise-fulfilled?
-                [ drop ] [ p fulfill ] if
-                2drop
-            ] show-walker-hook set
+        [
+            p promise-fulfilled?
+            [ drop ] [ p fulfill ] if
+            2drop
+        ] show-walker-hook set
 
-            break
+        break
 
-            quot call
-        ] "Walker test" spawn drop
+        quot call
+    ] "Walker test" spawn drop
 
-        step-into-all
-        p ?promise
-        send-synchronous drop
+    step-into-all
+    p ?promise
+    send-synchronous drop
 
-        p ?promise
-        variables>> walker-continuation swap at
-        value>> data>>
-    ] ;
+    p ?promise
+    variables>> walker-continuation swap at
+    value>> data>> ;
index bbfb9cbd9f0e2b0f0f67bd53e213e08640f8947d..318f7e065c3208a0745e05ca05d3aaf1e279ecd3 100644 (file)
@@ -6,7 +6,7 @@ HELP: breakpoint
 { $description "Annotates a word definition to enter the single stepper when executed." } ;
 
 HELP: breakpoint-if
-{ $values { "quot" { $quotation "( -- ? )" } } { "word" word } }
+{ $values { "word" word } { "quot" { $quotation "( -- ? )" } } }
 { $description "Annotates a word definition to enter the single stepper if the quotation yields true." } ;
 
 HELP: B
index 19924d67e43e650a3555329da3990e4412d51d3e..35a9ce7787e831f99acdabced598c16a654328b0 100644 (file)
@@ -167,4 +167,4 @@ SYMBOL: +stopped+
 ! For convenience
 IN: syntax
 
-SYNTAX: B \ break parsed ;
+SYNTAX: B \ break suffix! ;
index daac3c96c75035122abb8f9cb0b291f873c08484..f75adcbf04d6944b670346f7813ef0a921b2e819 100644 (file)
@@ -33,7 +33,7 @@ M: bad-tr summary
     tr-quot (( seq -- translated )) define-declared ;
 
 : fast-tr-quot ( mapping -- quot )
-    '[ [ _ tr-nth ] change-each ] ;
+    '[ [ _ tr-nth ] map! drop ] ;
 
 : define-fast-tr ( word mapping -- )
     fast-tr-quot (( seq -- )) define-declared ;
index d8cbb814d8f9cf076118aad56bf63e18f07cfd45..f7b853cff796911ab36b3655984c3dc4f5cf3218 100644 (file)
@@ -1,4 +1,5 @@
-USING: accessors effects eval kernel layouts math quotations tools.test typed words ;
+USING: accessors effects eval kernel layouts math namespaces
+quotations tools.test typed words ;
 IN: typed.tests
 
 TYPED: f+ ( a: float b: float -- c: float )
@@ -71,3 +72,28 @@ IN: typed.tests
 T{ unboxable f 12 3 4.0 } unboxy xy>>
 """ eval( -- xy )
 ] unit-test
+
+TYPED: no-inputs ( -- out: integer )
+    1 ;
+
+[ 1 ] [ no-inputs ] unit-test
+
+TUPLE: unboxable3
+    { x read-only } ;
+
+TYPED: no-inputs-unboxable-output ( -- out: unboxable3 )
+    T{ unboxable3 } ;
+
+[ T{ unboxable3 } ] [ no-inputs-unboxable-output ] unit-test
+
+SYMBOL: buh
+
+TYPED: no-outputs ( x: integer -- )
+    buh set ;
+
+[ 2 ] [ 2 no-outputs buh get ] unit-test
+
+TYPED: no-outputs-unboxable-input ( x: unboxable3 -- )
+    buh set ;
+
+[ T{ unboxable3 } ] [ T{ unboxable3 } no-outputs-unboxable-input buh get ] unit-test
index 84a8ea3217353a2b04e39a5cefb220821b635b66..0b3ac9d5f8f96107a4261e9c6e50d91e146badf3 100644 (file)
@@ -3,7 +3,7 @@ USING: accessors arrays classes classes.tuple combinators
 combinators.short-circuit definitions effects fry hints
 math kernel kernel.private namespaces parser quotations
 sequences slots words locals 
-locals.parser macros stack-checker.state ;
+locals.parser macros stack-checker.dependencies ;
 IN: typed
 
 ERROR: type-mismatch-error word expected-types ;
@@ -79,7 +79,8 @@ DEFER: make-boxer
     [ drop [ ] ] if ;
 
 : make-boxer ( types -- quot )
-    [ boxer ] [ swap '[ @ _ dip ] ] map-reduce ;
+    [ [ ] ]
+    [ [ boxer ] [ swap '[ @ _ dip ] ] map-reduce ] if-empty ;
 
 ! defining typed words
 
index 84e55ed1344a79e01876464737caba1e25506751..8eeca89c2f14903c396d40e4abbd673eee0e17ad 100755 (executable)
@@ -130,7 +130,7 @@ CONSTANT: window-control>styleMask
 M:: cocoa-ui-backend (open-window) ( world -- )
     world [ [ dim>> ] dip <FactorView> ]
     with-world-pixel-format :> view
-    world window-controls>> textured-background swap memq?
+    world window-controls>> textured-background swap member-eq?
     [ view make-context-transparent ] when
     view world [ world>NSRect ] [ world>styleMask ] bi <ViewWindow> :> window
     view -> release
@@ -218,7 +218,7 @@ CLASS: {
     { +name+ "FactorApplicationDelegate" }
 }
 
-{ "applicationDidUpdate:" "void" { "id" "SEL" "id" }
+{ "applicationDidUpdate:" void { id SEL id }
     [ 3drop reset-run-loop ]
 } ;
 
index ddcf79208d8e5c7b49aab044d821c288e9f8436e..00c1ad35831b3cbf639eb60daa864e574076f9d3 100644 (file)
@@ -1,11 +1,12 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.syntax cocoa cocoa.nibs cocoa.application
-cocoa.classes cocoa.dialogs cocoa.pasteboard cocoa.subclassing
-core-foundation core-foundation.strings help.topics kernel
-memory namespaces parser system ui ui.tools.browser
-ui.tools.listener ui.backend.cocoa eval locals
-vocabs.refresh ;
+cocoa.classes cocoa.dialogs cocoa.pasteboard cocoa.runtime
+cocoa.subclassing core-foundation core-foundation.strings
+help.topics kernel memory namespaces parser system ui
+ui.tools.browser ui.tools.listener ui.backend.cocoa eval
+locals vocabs.refresh ;
+FROM: alien.c-types => int void ;
 IN: ui.backend.cocoa.tools
 
 : finder-run-files ( alien -- )
@@ -25,43 +26,43 @@ CLASS: {
     { +name+ "FactorWorkspaceApplicationDelegate" }
 }
 
-{ "application:openFiles:" "void" { "id" "SEL" "id" "id" }
+{ "application:openFiles:" void { id SEL id id }
     [ [ 3drop ] dip finder-run-files ]
 }
 
-{ "applicationShouldHandleReopen:hasVisibleWindows:" "int" { "id" "SEL" "id" "int" }
+{ "applicationShouldHandleReopen:hasVisibleWindows:" int { id SEL id int }
     [ [ 3drop ] dip 0 = [ show-listener ] when 1 ]
 }
 
-{ "factorListener:" "id" { "id" "SEL" "id" }
+{ "factorListener:" id { id SEL id }
     [ 3drop show-listener f ]
 }
 
-{ "factorBrowser:" "id" { "id" "SEL" "id" }
+{ "factorBrowser:" id { id SEL id }
     [ 3drop show-browser f ]
 }
 
-{ "newFactorListener:" "id" { "id" "SEL" "id" }
+{ "newFactorListener:" id { id SEL id }
     [ 3drop listener-window f ]
 }
 
-{ "newFactorBrowser:" "id" { "id" "SEL" "id" }
+{ "newFactorBrowser:" id { id SEL id }
     [ 3drop browser-window f ]
 }
 
-{ "runFactorFile:" "id" { "id" "SEL" "id" }
+{ "runFactorFile:" id { id SEL id }
     [ 3drop menu-run-files f ]
 }
 
-{ "saveFactorImage:" "id" { "id" "SEL" "id" }
+{ "saveFactorImage:" id { id SEL id }
     [ 3drop save f ]
 }
 
-{ "saveFactorImageAs:" "id" { "id" "SEL" "id" }
+{ "saveFactorImageAs:" id { id SEL id }
     [ 3drop menu-save-image f ]
 }
 
-{ "refreshAll:" "id" { "id" "SEL" "id" }
+{ "refreshAll:" id { id SEL id }
     [ 3drop [ refresh-all ] \ refresh-all call-listener f ]
 } ;
 
@@ -79,13 +80,13 @@ CLASS: {
     { +name+ "FactorServiceProvider" }
 } {
     "evalInListener:userData:error:"
-    "void"
-    { "id" "SEL" "id" "id" "id" }
+    void
+    { id SEL id id id }
     [ nip [ eval-listener f ] do-service 2drop ]
 } {
     "evalToString:userData:error:"
-    "void"
-    { "id" "SEL" "id" "id" "id" }
+    void
+    { id SEL id id id }
     [ nip [ eval>string ] do-service 2drop ]
 } ;
 
index 9577696314480d4d1f7e8863fa92b5d06350b940..88e5f243ad5602be777a118e50ce555b7cad4833 100644 (file)
@@ -3,8 +3,8 @@
 USING: accessors alien alien.c-types alien.data alien.strings
 arrays assocs cocoa kernel math cocoa.messages cocoa.subclassing
 cocoa.classes cocoa.views cocoa.application cocoa.pasteboard
-cocoa.types cocoa.windows sequences io.encodings.utf8 ui ui.private
-ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures
+cocoa.runtime cocoa.types cocoa.windows sequences io.encodings.utf8
+ui ui.private ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures
 core-foundation.strings core-graphics core-graphics.types threads
 combinators math.rectangles ;
 IN: ui.backend.cocoa.views
@@ -148,76 +148,76 @@ CLASS: {
 }
 
 ! Rendering
-{ "drawRect:" "void" { "id" "SEL" "NSRect" }
+{ "drawRect:" void { id SEL NSRect }
     [ 2drop window relayout-1 yield ]
 }
 
 ! Events
-{ "acceptsFirstMouse:" "char" { "id" "SEL" "id" }
+{ "acceptsFirstMouse:" char { id SEL id }
     [ 3drop 1 ]
 }
 
-{ "mouseEntered:" "void" { "id" "SEL" "id" }
+{ "mouseEntered:" void { id SEL id }
     [ nip send-mouse-moved ]
 }
 
-{ "mouseExited:" "void" { "id" "SEL" "id" }
+{ "mouseExited:" void { id SEL id }
     [ 3drop forget-rollover ]
 }
 
-{ "mouseMoved:" "void" { "id" "SEL" "id" }
+{ "mouseMoved:" void { id SEL id }
     [ nip send-mouse-moved ]
 }
 
-{ "mouseDragged:" "void" { "id" "SEL" "id" }
+{ "mouseDragged:" void { id SEL id }
     [ nip send-mouse-moved ]
 }
 
-{ "rightMouseDragged:" "void" { "id" "SEL" "id" }
+{ "rightMouseDragged:" void { id SEL id }
     [ nip send-mouse-moved ]
 }
 
-{ "otherMouseDragged:" "void" { "id" "SEL" "id" }
+{ "otherMouseDragged:" void { id SEL id }
     [ nip send-mouse-moved ]
 }
 
-{ "mouseDown:" "void" { "id" "SEL" "id" }
+{ "mouseDown:" void { id SEL id }
     [ nip send-button-down$ ]
 }
 
-{ "mouseUp:" "void" { "id" "SEL" "id" }
+{ "mouseUp:" void { id SEL id }
     [ nip send-button-up$ ]
 }
 
-{ "rightMouseDown:" "void" { "id" "SEL" "id" }
+{ "rightMouseDown:" void { id SEL id }
     [ nip send-button-down$ ]
 }
 
-{ "rightMouseUp:" "void" { "id" "SEL" "id" }
+{ "rightMouseUp:" void { id SEL id }
     [ nip send-button-up$ ]
 }
 
-{ "otherMouseDown:" "void" { "id" "SEL" "id" }
+{ "otherMouseDown:" void { id SEL id }
     [ nip send-button-down$ ]
 }
 
-{ "otherMouseUp:" "void" { "id" "SEL" "id" }
+{ "otherMouseUp:" void { id SEL id }
     [ nip send-button-up$ ]
 }
 
-{ "scrollWheel:" "void" { "id" "SEL" "id" }
+{ "scrollWheel:" void { id SEL id }
     [ nip send-wheel$ ]
 }
 
-{ "keyDown:" "void" { "id" "SEL" "id" }
+{ "keyDown:" void { id SEL id }
     [ nip send-key-down-event ]
 }
 
-{ "keyUp:" "void" { "id" "SEL" "id" }
+{ "keyUp:" void { id SEL id }
     [ nip send-key-up-event ]
 }
 
-{ "validateUserInterfaceItem:" "char" { "id" "SEL" "id" }
+{ "validateUserInterfaceItem:" char { id SEL id }
     [
         nip -> action
         2dup [ window ] [ utf8 alien>string ] bi* validate-action
@@ -225,57 +225,57 @@ CLASS: {
     ]
 }
 
-{ "undo:" "id" { "id" "SEL" "id" }
+{ "undo:" id { id SEL id }
     [ nip undo-action send-action$ ]
 }
 
-{ "redo:" "id" { "id" "SEL" "id" }
+{ "redo:" id { id SEL id }
     [ nip redo-action send-action$ ]
 }
 
-{ "cut:" "id" { "id" "SEL" "id" }
+{ "cut:" id { id SEL id }
     [ nip cut-action send-action$ ]
 }
 
-{ "copy:" "id" { "id" "SEL" "id" }
+{ "copy:" id { id SEL id }
     [ nip copy-action send-action$ ]
 }
 
-{ "paste:" "id" { "id" "SEL" "id" }
+{ "paste:" id { id SEL id }
     [ nip paste-action send-action$ ]
 }
 
-{ "delete:" "id" { "id" "SEL" "id" }
+{ "delete:" id { id SEL id }
     [ nip delete-action send-action$ ]
 }
 
-{ "selectAll:" "id" { "id" "SEL" "id" }
+{ "selectAll:" id { id SEL id }
     [ nip select-all-action send-action$ ]
 }
 
-{ "newDocument:" "id" { "id" "SEL" "id" }
+{ "newDocument:" id { id SEL id }
     [ nip new-action send-action$ ]
 }
 
-{ "openDocument:" "id" { "id" "SEL" "id" }
+{ "openDocument:" id { id SEL id }
     [ nip open-action send-action$ ]
 }
 
-{ "saveDocument:" "id" { "id" "SEL" "id" }
+{ "saveDocument:" id { id SEL id }
     [ nip save-action send-action$ ]
 }
 
-{ "saveDocumentAs:" "id" { "id" "SEL" "id" }
+{ "saveDocumentAs:" id { id SEL id }
     [ nip save-as-action send-action$ ]
 }
 
-{ "revertDocumentToSaved:" "id" { "id" "SEL" "id" }
+{ "revertDocumentToSaved:" id { id SEL id }
     [ nip revert-action send-action$ ]
 }
 
 ! Multi-touch gestures: this is undocumented.
 ! http://cocoadex.com/2008/02/nsevent-modifications-swipe-ro.html
-{ "magnifyWithEvent:" "void" { "id" "SEL" "id" }
+{ "magnifyWithEvent:" void { id SEL id }
     [
         nip
         dup -> deltaZ sgn {
@@ -286,7 +286,7 @@ CLASS: {
     ]
 }
 
-{ "swipeWithEvent:" "void" { "id" "SEL" "id" }
+{ "swipeWithEvent:" void { id SEL id }
     [
         nip
         dup -> deltaX sgn {
@@ -305,14 +305,14 @@ CLASS: {
     ]
 }
 
-! "rotateWithEvent:" "void" { "id" "SEL" "id" }}
+! "rotateWithEvent:" void { id SEL id }}
 
-{ "acceptsFirstResponder" "char" { "id" "SEL" }
+{ "acceptsFirstResponder" char { id SEL }
     [ 2drop 1 ]
 }
 
 ! Services
-{ "validRequestorForSendType:returnType:" "id" { "id" "SEL" "id" "id" }
+{ "validRequestorForSendType:returnType:" id { id SEL id id }
     [
         ! We return either self or nil
         [ over window-focus ] 2dip
@@ -320,7 +320,7 @@ CLASS: {
     ]
 }
 
-{ "writeSelectionToPasteboard:types:" "char" { "id" "SEL" "id" "id" }
+{ "writeSelectionToPasteboard:types:" char { id SEL id id }
     [
         CF>string-array NSStringPboardType swap member? [
             [ drop window-focus gadget-selection ] dip over
@@ -329,7 +329,7 @@ CLASS: {
     ]
 }
 
-{ "readSelectionFromPasteboard:" "char" { "id" "SEL" "id" }
+{ "readSelectionFromPasteboard:" char { id SEL id }
     [
         pasteboard-string dup [
             [ drop window ] dip swap user-input 1
@@ -338,60 +338,60 @@ CLASS: {
 }
 
 ! Text input
-{ "insertText:" "void" { "id" "SEL" "id" }
+{ "insertText:" void { id SEL id }
     [ nip CF>string swap window user-input ]
 }
 
-{ "hasMarkedText" "char" { "id" "SEL" }
+{ "hasMarkedText" char { id SEL }
     [ 2drop 0 ]
 }
 
-{ "markedRange" "NSRange" { "id" "SEL" }
+{ "markedRange" NSRange { id SEL }
     [ 2drop 0 0 <NSRange> ]
 }
 
-{ "selectedRange" "NSRange" { "id" "SEL" }
+{ "selectedRange" NSRange { id SEL }
     [ 2drop 0 0 <NSRange> ]
 }
 
-{ "setMarkedText:selectedRange:" "void" { "id" "SEL" "id" "NSRange" }
+{ "setMarkedText:selectedRange:" void { id SEL id NSRange }
     [ 2drop 2drop ]
 }
 
-{ "unmarkText" "void" { "id" "SEL" }
+{ "unmarkText" void { id SEL }
     [ 2drop ]
 }
 
-{ "validAttributesForMarkedText" "id" { "id" "SEL" }
+{ "validAttributesForMarkedText" id { id SEL }
     [ 2drop NSArray -> array ]
 }
 
-{ "attributedSubstringFromRange:" "id" { "id" "SEL" "NSRange" }
+{ "attributedSubstringFromRange:" id { id SEL NSRange }
     [ 3drop f ]
 }
 
-{ "characterIndexForPoint:" "NSUInteger" { "id" "SEL" "NSPoint" }
+{ "characterIndexForPoint:" NSUInteger { id SEL NSPoint }
     [ 3drop 0 ]
 }
 
-{ "firstRectForCharacterRange:" "NSRect" { "id" "SEL" "NSRange" }
+{ "firstRectForCharacterRange:" NSRect { id SEL NSRange }
     [ 3drop 0 0 0 0 <CGRect> ]
 }
 
-{ "conversationIdentifier" "NSInteger" { "id" "SEL" }
+{ "conversationIdentifier" NSInteger { id SEL }
     [ drop alien-address ]
 }
 
 ! Initialization
-{ "updateFactorGadgetSize:" "void" { "id" "SEL" "id" }
+{ "updateFactorGadgetSize:" void { id SEL id }
     [ 2drop [ window ] [ view-dim ] bi >>dim drop yield ]
 }
 
-{ "doCommandBySelector:" "void" { "id" "SEL" "SEL" }
+{ "doCommandBySelector:" void { id SEL SEL }
     [ 3drop ]
 }
 
-{ "initWithFrame:pixelFormat:" "id" { "id" "SEL" "NSRect" "id" }
+{ "initWithFrame:pixelFormat:" id { id SEL NSRect id }
     [
         [ drop ] 2dip
         SUPER-> initWithFrame:pixelFormat:
@@ -399,13 +399,13 @@ CLASS: {
     ]
 }
 
-{ "isOpaque" "char" { "id" "SEL" }
+{ "isOpaque" char { id SEL }
     [
         2drop 0
     ]
 }
 
-{ "dealloc" "void" { "id" "SEL" }
+{ "dealloc" void { id SEL }
     [
         drop
         [ unregister-window ]
@@ -430,19 +430,19 @@ CLASS: {
     { +name+ "FactorWindowDelegate" }
 }
 
-{ "windowDidMove:" "void" { "id" "SEL" "id" }
+{ "windowDidMove:" void { id SEL id }
     [
         2nip -> object [ -> contentView window ] keep save-position
     ]
 }
 
-{ "windowDidBecomeKey:" "void" { "id" "SEL" "id" }
+{ "windowDidBecomeKey:" void { id SEL id }
     [
         2nip -> object -> contentView window focus-world
     ]
 }
 
-{ "windowDidResignKey:" "void" { "id" "SEL" "id" }
+{ "windowDidResignKey:" void { id SEL id }
     [
         forget-rollover
         2nip -> object -> contentView
@@ -452,13 +452,13 @@ CLASS: {
     ]
 }
 
-{ "windowShouldClose:" "char" { "id" "SEL" "id" }
+{ "windowShouldClose:" char { id SEL id }
     [
         3drop 1
     ]
 }
 
-{ "windowWillClose:" "void" { "id" "SEL" "id" }
+{ "windowWillClose:" void { id SEL id }
     [
         2nip -> object -> contentView window ungraft
     ]
index 0e07ff6611cac616fc2ac496c01e325db5f690ff..a6d73ca80fa57dbe3c30a911d20b71b8bb9b48d1 100755 (executable)
@@ -470,7 +470,7 @@ SYMBOL: nc-buttons
 : handle-wm-ncbutton ( hWnd uMsg wParam lParam -- )
     2drop nip
     message>button nc-buttons get
-    swap [ push ] [ delete ] if ;
+    swap [ push ] [ remove! drop ] if ;
 
 : mouse-wheel ( wParam -- array ) >lo-hi [ sgn neg ] map ;
 
@@ -498,13 +498,13 @@ SYMBOL: nc-buttons
 : handle-wm-buttondown ( hWnd uMsg wParam lParam -- )
     [
         over set-capture
-        dup message>button drop nc-buttons get delete
+        dup message>button drop nc-buttons get remove! drop
     ] 2dip prepare-mouse send-button-down ;
 
 : handle-wm-buttonup ( hWnd uMsg wParam lParam -- )
     mouse-captured get [ release-capture ] when
     pick message>button drop dup nc-buttons get member? [
-        nc-buttons get delete 4drop
+        nc-buttons get remove! drop 4drop
     ] [
         drop prepare-mouse send-button-up
     ] if ;
@@ -537,7 +537,7 @@ SYMBOL: nc-buttons
     COLOR_BTNFACE GetSysColor RGB>color ;
 
 : ?make-glass ( world hwnd -- )
-    over window-controls>> textured-background swap memq? [
+    over window-controls>> textured-background swap member-eq? [
         composition-enabled? [
             full-window-margins DwmExtendFrameIntoClientArea drop
             T{ rgba f 0.0 0.0 0.0 0.0 }
@@ -596,7 +596,7 @@ SYMBOL: trace-messages?
 
 ! return 0 if you handle the message, else just let DefWindowProc return its val
 : ui-wndproc ( -- object )
-    "uint" { "void*" "uint" "long" "long" } "stdcall" [
+    uint { void* uint long long } "stdcall" [
         pick
         trace-messages? get-global [ dup windows-message-name name>> print flush ] when
         wm-handlers get-global at* [ call ] [ drop DefWindowProc ] if
index 071ac1cffe80401ceab78804cc82a5d8f151cec2..f42fdf46167cef0dcb7f6e96aa4c6ae689173010 100755 (executable)
@@ -533,8 +533,8 @@ PRIVATE>
 
 : join-lines ( string -- string' )
     "\n" split
-    [ rest-slice [ [ blank? ] trim-head-slice ] change-each ]
-    [ but-last-slice [ [ blank? ] trim-tail-slice ] change-each ]
+    [ rest-slice [ [ blank? ] trim-head-slice ] map! drop ]
+    [ but-last-slice [ [ blank? ] trim-tail-slice ] map! drop ]
     [ " " join ]
     tri ;
 
index e4a0e672d231e96b9aa95b0c75668c1eea60cb01..8eb11a7753c7ca8e802de6246bdd01c301b4e199 100644 (file)
@@ -11,7 +11,6 @@ CONSTANT: horizontal { 1 0 }
 CONSTANT: vertical { 0 1 }
 
 TUPLE: gadget < rect
-id
 pref-dim
 parent
 children
@@ -29,7 +28,7 @@ model ;
 
 M: gadget equal? 2drop f ;
 
-M: gadget hashcode* nip [ [ \ gadget counter ] unless* ] change-id id>> ;
+M: gadget hashcode* nip identity-hashcode ;
 
 M: gadget model-changed 2drop ;
 
@@ -306,7 +305,7 @@ M: gadget remove-gadget 2drop ;
             [ remove-gadget ] [
                 over (unparent)
                 [ unfocus-gadget ]
-                [ children>> delete ]
+                [ children>> remove! drop ]
                 [ nip relayout ]
                 2tri
             ] 2bi
index 83d15911e7b1a9832fbecbd4490e3d84da43c989..c655e289b0f6063a21f4ac6486d393f3f714d3ea 100644 (file)
@@ -22,7 +22,7 @@ PREDICATE: string-array < array [ string? ] all? ;
 PRIVATE>
 
 : ?string-lines ( string -- string/array )
-    CHAR: \n over memq? [ string-lines ] when ;
+    CHAR: \n over member-eq? [ string-lines ] when ;
 
 ERROR: not-a-string object ;
 
index bebfaf13fe4109a9f53074ceedc7de669c23a770..b1ae421f52e9eade8467dfcf1da49b90276114ca 100644 (file)
@@ -3,7 +3,7 @@ kernel ;
 IN: ui.gadgets.menus
 
 HELP: <commands-menu>
-{ $values { "target" object } { "commands" "a sequence of commands" } { "hook" { $quotation "( button -- )" } }  { "menu" "a new " { $link gadget } } }
+{ $values { "target" object } { "hook" { $quotation "( button -- )" } } { "commands" "a sequence of commands" } { "menu" "a new " { $link gadget } } }
 { $description "Creates a popup menu of commands which are to be invoked on " { $snippet "target" } ". The " { $snippet "hook" } " quotation is run before a command is invoked." } ;
 
 HELP: show-menu
index fd5ae0b246646f81f3745a2036d54d4a3ebf1f3f..8002fba4aec9df753e497c284a97bf30a046e12b 100644 (file)
@@ -40,13 +40,13 @@ TUPLE: line words height ;
     dup wrap-words [ <line> ] map ;
 
 : line-width ( wrapped-line -- n )
-    [ break?>> ] trim-tail-slice [ width>> ] sigma ;
+    [ break?>> ] trim-tail-slice [ width>> ] map-sum ;
 
 : max-line-width ( wrapped-paragraph -- x )
     [ words>> line-width ] [ max ] map-reduce ;
 
 : sum-line-heights ( wrapped-paragraph -- y )
-    [ height>> ] sigma ;
+    [ height>> ] map-sum ;
 
 M: paragraph pref-dim*
     wrap-paragraph [ max-line-width ] [ sum-line-heights ] bi 2array ;
@@ -82,4 +82,4 @@ M: paragraph baseline
 
 M: paragraph cap-height pack-cap-height ;
     
-PRIVATE>
\ No newline at end of file
+PRIVATE>
index 1e4b875f28afca8957e6a04f77827946c965ef6b..17adb2bd640fc4e2ca0589ed21abac26737c470c 100644 (file)
@@ -24,7 +24,7 @@ HELP: <scroller>
 { <viewport> <scroller> } related-words
 
 HELP: set-scroll-position
-{ $values { "scroller" scroller } { "value" "a pair of integers" } }
+{ $values { "value" "a pair of integers" } { "scroller" scroller } }
 { $description "Sets the offset of the top-left corner of the scroller's " { $link viewport } "'s child." } ;
 
 HELP: relative-scroll-rect
index 0bbedc8d0d438098b8fc2a693811dcc008a637bf..cf5c94aa6baad13b53a895eb391ba590bec77b1d 100644 (file)
@@ -18,7 +18,7 @@ HELP: <track>
 { $description "Creates a new track which lays out children along the given orientation, either " { $link horizontal } " or " { $link vertical } "." } ;
 
 HELP: track-add
-{ $values { "gadget" gadget } { "track" track } { "constraint" "a number between 0 and 1, or " { $link f } } }
+{ $values { "track" track } { "gadget" gadget } { "constraint" "a number between 0 and 1, or " { $link f } } }
 { $description "Adds a new child to a track. If the constraint is " { $link f } ", the child always occupies its preferred size. Otherwise, the constrant is a fraction of the total size which is allocated for the child." } ;
 
 ABOUT: "ui-track-layout"
index 4bccab8c98c71239dbc5bbb25ab0599eb8e0fd7d..387f41a6a4e461144315a25f0c5ffd82a3af53cb 100644 (file)
@@ -61,7 +61,7 @@ PRIVATE>
     pick sizes>> push add-gadget ;
 
 M: track remove-gadget
-    [ [ children>> index ] [  sizes>> ] bi delete-nth ]
+    [ [ children>> index ] [  sizes>> ] bi remove-nth! drop ]
     [ call-next-method ] 2bi ;
 
 : clear-track ( track -- ) [ sizes>> delete-all ] [ clear-gadget ] bi ;
index b736c3f74f377247ef27e3f3d121415ec32399e3..8f38cee988c308db60eb461bf28a8d6f957b3fe0 100755 (executable)
@@ -120,7 +120,7 @@ M: world request-focus-on ( child gadget -- )
         V{ } clone >>window-resources ;
 
 : initial-background-color ( attributes -- color )
-    window-controls>> textured-background swap memq?
+    window-controls>> textured-background swap member-eq?
     [ T{ rgba f 0.0 0.0 0.0 0.0 } ]
     [ T{ rgba f 1.0 1.0 1.0 1.0 } ] if ;
 
@@ -151,8 +151,8 @@ M: world focusable-child* children>> [ t ] [ first ] if-empty ;
 M: world children-on nip children>> ;
 
 M: world remove-gadget
-    2dup layers>> memq?
-    [ layers>> delq ] [ call-next-method ] if ;
+    2dup layers>> member-eq?
+    [ layers>> remove-eq! drop ] [ call-next-method ] if ;
 
 SYMBOL: flush-layout-cache-hook
 
index 26eb45c8d02196b2a5f20911057866de39abcbe2..8e982f8e4596e7322d361117997989fe878aff98 100644 (file)
@@ -297,7 +297,7 @@ SYMBOL: drag-timer
 
 : send-button-up ( gesture loc world -- )
     move-hand
-    dup #>> hand-buttons get-global delete
+    dup #>> hand-buttons get-global remove! drop
     stop-drag-timer
     button-gesture ;
 
index 4aa0e50945f64846bf2cb654790e1c757f99357c..4a5ec277f0389901fa1c6e7afabd93b3ac024a3d 100644 (file)
@@ -2,11 +2,11 @@ IN: ui.pens
 USING: help.markup help.syntax kernel ui.gadgets ;
 
 HELP: draw-interior
-{ $values { "pen" object } { "gadget" gadget } } 
+{ $values { "gadget" gadget } { "pen" object } } 
 { $contract "Draws the interior of a gadget by making OpenGL calls. The " { $snippet "interior" } " slot may be set to objects implementing this generic word." } ;
 
 HELP: draw-boundary
-{ $values { "pen" object } { "gadget" gadget } } 
+{ $values { "gadget" gadget } { "pen" object } } 
 { $contract "Draws the boundary of a gadget by making OpenGL calls. The " { $snippet "boundary" } " slot may be set to objects implementing this generic word." } ;
 
 ARTICLE: "ui-pen-protocol" "UI pen protocol"
@@ -23,4 +23,4 @@ $nl
 { $vocab-subsection "Polygon pens" "ui.pens.polygon" }
 { $vocab-subsection "Solid pens" "ui.pens.solid" }
 { $vocab-subsection "Tile pens" "ui.pens.tile" }
-"Custom implementations must follow the guidelines set forth in " { $link "ui-paint-custom" } "." ;
\ No newline at end of file
+"Custom implementations must follow the guidelines set forth in " { $link "ui-paint-custom" } "." ;
index 173e1c0595c08406149a61b17c0a46ba14f9f458..c9c2201e33afda008034a87dbd868af600a26f94 100644 (file)
@@ -13,7 +13,7 @@ IN: ui.tools.browser
 
 TUPLE: browser-gadget < tool history scroller search-field popup ;
 
-{ 650 400 } browser-gadget set-tool-dim
+{ 650 700 } browser-gadget set-tool-dim
 
 M: browser-gadget history-value
     [ control-value ] [ scroller>> scroll-position ]
@@ -121,13 +121,17 @@ M: browser-gadget focusable-child* search-field>> ;
 
 : browser-help ( -- ) "ui-browser" com-browse ;
 
+: glossary ( -- ) "conventions" com-browse ;
+
 \ browser-help H{ { +nullary+ t } } define-command
+\ glossary H{ { +nullary+ t } } define-command
 
 browser-gadget "toolbar" f {
     { T{ key-down f { A+ } "LEFT" } com-back }
     { T{ key-down f { A+ } "RIGHT" } com-forward }
     { T{ key-down f { A+ } "H" } com-home }
     { T{ key-down f f "F1" } browser-help }
+    { T{ key-down f { A+ } "F1" } glossary }
 } define-command-map
 
 : ?show-help ( link browser -- )
index 5dd0581cf24c7744da05024ef31683ac6d166bb4..b069de18872356e58872ff56bdbd4e5f9c2702a6 100644 (file)
@@ -64,7 +64,7 @@ M: definition-completion row-columns
 M: word-completion row-color
     [ vocabulary>> ] [ manifest>> ] bi* {
         { [ dup not ] [ COLOR: black ] }
-        { [ 2dup search-vocabs>> memq? ] [ COLOR: black ] }
+        { [ 2dup search-vocabs>> member-eq? ] [ COLOR: black ] }
         { [ over ".private" tail? ] [ COLOR: dark-red ] }
         [ COLOR: dark-gray ]
     } cond 2nip ;
@@ -181,4 +181,4 @@ completion-popup H{
 M: completion-popup handle-gesture ( gesture completion -- ? )
     2dup completion-gesture dup [
         [ nip hide-glass ] [ invoke-command ] 2bi* f
-    ] [ 2drop call-next-method ] if ;
\ No newline at end of file
+    ] [ 2drop call-next-method ] if ;
index 998020c9c455cde73ff4bd0f7509bdcada4da218..8cef10b06fc089b45bc3b0b29da1aebc7b2e66e1 100644 (file)
@@ -12,7 +12,7 @@ $nl
 "Interactors implement the " { $link stream-readln } ", " { $link stream-read } " and " { $link read-quot } " generic words." } ;
 
 ARTICLE: "ui-listener" "UI listener"
-"The graphical listener is based around the terminal listener (" { $link "listener" } ") and adds an input history, and word and vocabulary completion."
+"The graphical listener adds input history and word and vocabulary completion. See " { $link "listener" } " for general information on the listener."
 { $command-map listener-gadget "toolbar" }
 { $command-map interactor "completion" }
 { $command-map interactor "interactor" }
@@ -48,4 +48,4 @@ TIP: "Scroll the listener from the keyboard by pressing " { $command listener-ga
 
 TIP: "Press " { $command tool "common" refresh-all } " or run " { $link refresh-all } " to reload changed source files from disk. " ;
 
-ABOUT: "ui-listener"
\ No newline at end of file
+ABOUT: "ui-listener"
index 990bafec901a10e515f4091e50f09456c765ca96..2a948fddc01342b2ce006e44ef7f67dfdb846dbc 100644 (file)
@@ -379,12 +379,16 @@ interactor "completion" f {
     { T{ key-down f { C+ } "r" } history-completion-popup }
 } define-command-map
 
+: introduction. ( -- )
+    tip-of-the-day. nl
+    { $strong "Press " { $snippet "F1" } " at any time for help." } print-content nl nl ;
+
 : listener-thread ( listener -- )
     dup listener-streams [
         [ com-browse ] help-hook set
         '[ [ _ input>> ] 2dip debugger-popup ] error-hook set
         error-summary? off
-        tip-of-the-day. nl
+        introduction.
         listener
         nl
         "The listener has exited. To start it again, click “Restart Listener”." print
index bb23bc0692b3868a8ee96c97f5f3d9d5155b2633..3de7c9cc702f6d7bf0b730589e8fbff0432473f3 100644 (file)
@@ -107,7 +107,7 @@ M: method-renderer column-titles drop { "" "Method" "Count" } ;
 : method-matches? ( method generic class -- ? )
     [ first ] 2dip
     {
-        [ drop dup [ subwords memq? ] [ 2drop t ] if ]
+        [ drop dup [ subwords member-eq? ] [ 2drop t ] if ]
         [ nip dup [ swap "method-class" word-prop = ] [ 2drop t ] if ]
     } 3&& ;
 
index 11c2a48a2a5408900b03b538f9390eae9f4a36bb..5a92a4cea211c4d711cd7ad7f46b3ec4d8743f97 100644 (file)
@@ -20,8 +20,9 @@ TUPLE: node value children ;
         ] [
             [
                 [ children>> swap first head-slice % ]
-                [ tuck traverse-step traverse-to-path ]
-                2bi
+                [ nip ]
+                [ traverse-step traverse-to-path ]
+                2tri
             ] make-node
         ] if
     ] if ;
@@ -35,7 +36,9 @@ TUPLE: node value children ;
         ] [
             [
                 [ traverse-step traverse-from-path ]
-                [ tuck children>> swap first 1 + tail-slice % ] 2bi
+                [ nip ]
+                [ children>> swap first 1 + tail-slice % ]
+                2tri
             ] make-node
         ] if
     ] if ;
index c75f5956b3f1564a867342676320dc34dd0eff0e..8260608cd4cb40ccb492cc1bd464ce5010264945 100644 (file)
@@ -34,7 +34,7 @@ SYMBOL: windows
 : raised-window ( world -- )
     windows get-global
     [ [ second eq? ] with find drop ] keep
-    [ nth ] [ delete-nth ] [ nip ] 2tri push ;
+    [ nth ] [ remove-nth! drop ] [ nip ] 2tri push ;
 
 : focus-gestures ( new old -- )
     drop-prefix <reversed>
index 5cab884b3c4c7eb6bba2702a971fd048c7d943e0..ea0487c703525e8c9b311ebdf8f7e5484e3ca269 100755 (executable)
@@ -76,10 +76,9 @@ ducet insert-helpers
     drop [ 0 ] unless* tail-slice ;\r
 \r
 :: ?combine ( char slice i -- ? )\r
-    [let | str [ i slice nth char suffix ] |\r
-        str ducet key? dup\r
-        [ str i slice set-nth ] when\r
-    ] ;\r
+    i slice nth char suffix :> str\r
+    str ducet key? dup\r
+    [ str i slice set-nth ] when ;\r
 \r
 : add ( char -- )\r
     dup blocked? [ 1string , ] [\r
index c4392c4c6da9ec3fb009c9d995fb4b58c992940a..02d9f370236d4d0135da2c688af99ebbdbd8e0d4 100644 (file)
@@ -23,7 +23,7 @@ GENERIC: group-struct ( obj -- group/f )
     gr_mem>> utf8 alien>strings ;
 
 : (group-struct) ( id -- group-struct id group-struct byte-array length void* )
-    \ unix:group <struct> tuck 4096
+    [ \ unix:group <struct> ] dip over 4096
     [ <byte-array> ] keep f <void*> ;
 
 : check-group-struct ( group-struct ptr -- group-struct/f )
index 421efa60bc6d66d62f227f675366ca97bc7f207b..2bebc981f95baf00e39b5fae00747624ac972052 100644 (file)
@@ -21,5 +21,19 @@ TYPEDEF: __int32_t  blksize_t
 TYPEDEF: long       ssize_t
 TYPEDEF: __int32_t  pid_t
 TYPEDEF: long       time_t
+TYPEDEF: uint mach_port_t
+TYPEDEF: int kern_return_t
+TYPEDEF: int boolean_t
+TYPEDEF: mach_port_t io_object_t
+TYPEDEF: io_object_t io_iterator_t
+TYPEDEF: io_object_t io_registry_entry_t
+TYPEDEF: io_object_t io_service_t
+TYPEDEF: char[128] io_name_t
+TYPEDEF: char[512] io_string_t
+TYPEDEF: kern_return_t IOReturn
 
-ALIAS: <time_t> <long>
\ No newline at end of file
+TYPEDEF: uint IOOptionBits
+
+
+
+ALIAS: <time_t> <long>
index 7650e9962f64af74f762d0e4b6af93d02e777916..ec638e6f31933885128257c56c6ecdc9cbd0a9d4 100644 (file)
@@ -36,6 +36,7 @@ TYPEDEF: __uint64_t fsfilcnt_t
 TYPEDEF: fsfilcnt_t __fsfilcnt_t
 TYPEDEF: __uint64_t rlim_t
 TYPEDEF: uint32_t id_t
+TYPEDEF: long clockid_t
 
 C-TYPE: DIR
 C-TYPE: FILE
index afe24905d69ba11c18cd227bf64b1d40ee46a90a..a672c850d29914a8cacab1b40dc4d371e0e7b243 100644 (file)
@@ -5,7 +5,7 @@ USING: alien alien.c-types alien.syntax kernel libc
 sequences continuations byte-arrays strings math namespaces
 system combinators vocabs.loader accessors
 stack-checker macros locals generalizations unix.types
-io vocabs classes.struct unix.time ;
+io vocabs classes.struct unix.time alien.libraries ;
 IN: unix
 
 CONSTANT: PROT_NONE   0
@@ -48,18 +48,17 @@ ERROR: unix-error errno message ;
 ERROR: unix-system-call-error args errno message word ;
 
 MACRO:: unix-system-call ( quot -- )
-    [let | n [ quot infer in>> ]
-           word [ quot first ] |
-        [
-            n ndup quot call dup 0 < [
-                drop
-                n narray
-                errno dup strerror
-                word unix-system-call-error
-            ] [
-                n nnip
-            ] if
-        ]
+    quot infer in>> :> n
+    quot first :> word
+    [
+        n ndup quot call dup 0 < [
+            drop
+            n narray
+            errno dup strerror
+            word unix-system-call-error
+        ] [
+            n nnip
+        ] if
     ] ;
 
 HOOK: open-file os ( path flags mode -- fd )
@@ -221,3 +220,4 @@ FUNCTION: int utimes ( char* path, timeval[2] times ) ;
 
 FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ;
 
+"librt" "librt.so" "cdecl" add-library
index a72fac567a28b0f532e786f78583da339ffc228c..bf4a9bb76c9d6cd83cd1c3bf815fa333468fa737 100644 (file)
@@ -181,7 +181,7 @@ PRIVATE>
     clone dup protocol>> '[ _ protocol-port or ] change-port ;
 
 ! Literal syntax
-SYNTAX: URL" lexer get skip-blank parse-string >url parsed ;
+SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ;
 
 USING: vocabs vocabs.loader ;
 
index f0ee13dd382c205cd55806fc3097a290463cc5ee..f2c5691452458497180028612a5185d87aeaf571 100644 (file)
@@ -9,7 +9,7 @@ IN: validators
     >lower "on" = ;
 
 : v-default ( str def -- str/def )
-    over empty? spin ? ;
+    [ nip empty? ] 2keep ? ;
 
 : v-required ( str -- str )
     dup empty? [ "required" throw ] when ;
index b15dcebe491ea0d76494815433a76c1651360e17..4329affe82b33ec342ec5127a54ab458d5b56b61 100644 (file)
@@ -44,8 +44,8 @@ M: value-word definition drop f ;
     def>> first (>>obj) ;
 
 SYNTAX: to:
-    scan-word literalize parsed
-    \ set-value parsed ;
+    scan-word literalize suffix!
+    \ set-value suffix! ;
 
 : get-value ( word -- value )
     def>> first obj>> ;
index b70c7c50509a1ed6b4571447b85913e3b0d650ed..a2a67d58bc6e09efeb17a64042cd8390a0af96e8 100644 (file)
@@ -24,6 +24,8 @@ M: V new-sequence drop [ <A> ] [ >fixnum ] bi V boa ; inline
 
 M: A new-resizable drop <V> ; inline
 
+M: V new-resizable drop <V> ; inline
+
 M: V equal? over V instance? [ sequence= ] [ 2drop f ] if ;
 
 : >V ( seq -- vector ) V new clone-like ; inline
index 11d9dabb3d9a812abf9c55f10991c32ce5a2440a..e3585952db4d7d5d6c00ee1b092ca429cca7f4b6 100644 (file)
@@ -3,20 +3,77 @@
 USING: classes.struct alien.c-types alien.syntax ;
 IN: vm
 
-TYPEDEF: void* cell
+TYPEDEF: uintptr_t cell
 C-TYPE: context
 
 STRUCT: zone
-    { start cell }
-    { here cell }
-    { size cell }
-    { end cell } ;
+{ start cell }
+{ here cell }
+{ size cell }
+{ end cell } ;
 
 STRUCT: vm
-    { stack_chain context* }
-    { nursery zone }
-    { cards_offset cell }
-    { decks_offset cell }
-    { userenv cell[70] } ;
+{ stack_chain context* }
+{ nursery zone }
+{ cards_offset cell }
+{ decks_offset cell }
+{ userenv cell[70] } ;
 
 : vm-field-offset ( field -- offset ) vm offset-of ; inline
+
+C-ENUM:
+collect-nursery-op
+collect-aging-op
+collect-to-tenured-op
+collect-full-op
+collect-compact-op
+collect-growing-heap-op ;
+
+STRUCT: copying-sizes
+{ size cell }
+{ occupied cell }
+{ free cell } ;
+
+STRUCT: mark-sweep-sizes
+{ size cell }
+{ occupied cell }
+{ total-free cell }
+{ contiguous-free cell }
+{ free-block-count cell } ;
+
+STRUCT: data-heap-room
+{ nursery copying-sizes }
+{ aging copying-sizes }
+{ tenured mark-sweep-sizes }
+{ cards cell }
+{ decks cell }
+{ mark-stack cell } ;
+
+STRUCT: gc-event
+{ op uint }
+{ data-heap-before data-heap-room }
+{ code-heap-before mark-sweep-sizes }
+{ data-heap-after data-heap-room }
+{ code-heap-after mark-sweep-sizes }
+{ cards-scanned cell }
+{ decks-scanned cell }
+{ code-blocks-scanned cell }
+{ start-time ulonglong }
+{ total-time cell }
+{ card-scan-time cell }
+{ code-scan-time cell }
+{ data-sweep-time cell }
+{ code-sweep-time cell }
+{ compaction-time cell }
+{ temp-time ulonglong } ;
+
+STRUCT: dispatch-statistics
+{ megamorphic-cache-hits cell }
+{ megamorphic-cache-misses cell }
+
+{ cold-call-to-ic-transitions cell }
+{ ic-to-pic-transitions cell }
+{ pic-to-mega-transitions cell }
+
+{ pic-tag-count cell }
+{ pic-tuple-count cell } ;
index ae8ef62c1631d7272efe80fa532ab3b76a33e789..25e30829c091f13bf77cad24a4a2bbf0092e0d79 100644 (file)
@@ -44,8 +44,8 @@ C: <test-implementation> test-implementation
         [ >>x drop ] ! IInherited::setX
     } }
     { IUnrelated {
-        [ swap x>> + ] ! IUnrelated::xPlus
-        [ spin x>> * + ] ! IUnrelated::xMulAdd
+        [ [ x>> ] [ + ] bi* ] ! IUnrelated::xPlus
+        [ [ x>> ] [ * ] [ + ] tri* ] ! IUnrelated::xMulAdd
     } }
 } <com-wrapper>
 dup +test-wrapper+ set [
index bbade332cc0d77fc22348ba6fa3445187779e880..fc7d986cbc63ccc4a15707b4ca41951e1d0789e1 100755 (executable)
@@ -101,7 +101,7 @@ SYNTAX: COM-INTERFACE:
     dup save-com-interface-definition
     define-words-for-com-interface ;
 
-SYNTAX: GUID: scan string>guid parsed ;
+SYNTAX: GUID: scan string>guid suffix! ;
 
 USING: vocabs vocabs.loader ;
 
index 6a6f6f2bb44ec8dd73699a55e786fc36d37a3fbd..0298e80445fb27436bbc003c72329404e3db2dc9 100644 (file)
@@ -27,8 +27,8 @@ COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c}
         [ >>x drop ]     ! IInherited::setX\r
     } }\r
     { "IUnrelated" {\r
-        [ swap x>> + ]   ! IUnrelated::xPlus\r
-        [ spin x>> * + ] ! IUnrealted::xMulAdd\r
+        [ [ x>> ] [ + ] bi* ]   ! IUnrelated::xPlus\r
+        [ [ x>> ] [ * ] [ + ] tri* ] ! IUnrealted::xMulAdd\r
     } }\r
 } <com-wrapper>""" } ;\r
 \r
index c007a8c40064743ceb202e1658f38812f30f2eb8..696902439ca7f9d075d29c6f5732594ad0cb37fc 100755 (executable)
@@ -159,7 +159,7 @@ PRIVATE>
 
 M: com-wrapper dispose*
     [ [ free ] each f ] change-vtbls
-    +live-wrappers+ get-global delete ;
+    +live-wrappers+ get-global remove! drop ;
 
 : com-wrap ( object wrapper -- wrapped-object )
     [ vtbls>> ] [ (malloc-wrapped-object) ] bi
index ab37f96c2a79e8fd7f714b4c44f85c4564c72a6a..4e97cb0e01e058d9c78766e013305ce94a9b82f5 100755 (executable)
@@ -56,13 +56,12 @@ M: array array-base-type first ;
     DIOBJECTDATAFORMAT <struct-boa> ;
 
 :: make-DIOBJECTDATAFORMAT-array ( struct array -- alien )
-    [let | alien [ array length malloc-DIOBJECTDATAFORMAT-array ] |
-        array [| args i |
-            struct args <DIOBJECTDATAFORMAT>
-            i alien set-nth
-        ] each-index
-        alien
-    ] ;
+    array length malloc-DIOBJECTDATAFORMAT-array :> alien
+    array [| args i |
+        struct args <DIOBJECTDATAFORMAT>
+        i alien set-nth
+    ] each-index
+    alien ;
 
 : <DIDATAFORMAT> ( dwFlags dwDataSize struct rgodf-array -- alien )
     [ DIDATAFORMAT heap-size DIOBJECTDATAFORMAT heap-size ] 4 ndip
index 70c104e2df7694369ecfbe93c20e4ec3e66108aa..80f50ef2b08f50c9ace1346c3e5386354d2a53f6 100755 (executable)
@@ -759,6 +759,34 @@ CONSTANT: PIPE_NOWAIT 1
 
 CONSTANT: PIPE_UNLIMITED_INSTANCES 255
 
+CONSTANT: EXCEPTION_NONCONTINUABLE          HEX:        1
+CONSTANT: STATUS_GUARD_PAGE_VIOLATION       HEX: 80000001
+CONSTANT: STATUS_DATATYPE_MISALIGNMENT      HEX: 80000002
+CONSTANT: STATUS_BREAKPOINT                 HEX: 80000003
+CONSTANT: STATUS_SINGLE_STEP                HEX: 80000004
+CONSTANT: STATUS_ACCESS_VIOLATION           HEX: C0000005
+CONSTANT: STATUS_IN_PAGE_ERROR              HEX: C0000006
+CONSTANT: STATUS_INVALID_HANDLE             HEX: C0000008
+CONSTANT: STATUS_NO_MEMORY                  HEX: C0000017
+CONSTANT: STATUS_ILLEGAL_INSTRUCTION        HEX: C000001D
+CONSTANT: STATUS_NONCONTINUABLE_EXCEPTION   HEX: C0000025
+CONSTANT: STATUS_INVALID_DISPOSITION        HEX: C0000026
+CONSTANT: STATUS_ARRAY_BOUNDS_EXCEEDED      HEX: C000008C
+CONSTANT: STATUS_FLOAT_DENORMAL_OPERAND     HEX: C000008D
+CONSTANT: STATUS_FLOAT_DIVIDE_BY_ZERO       HEX: C000008E
+CONSTANT: STATUS_FLOAT_INEXACT_RESULT       HEX: C000008F
+CONSTANT: STATUS_FLOAT_INVALID_OPERATION    HEX: C0000090
+CONSTANT: STATUS_FLOAT_OVERFLOW             HEX: C0000091
+CONSTANT: STATUS_FLOAT_STACK_CHECK          HEX: C0000092
+CONSTANT: STATUS_FLOAT_UNDERFLOW            HEX: C0000093
+CONSTANT: STATUS_INTEGER_DIVIDE_BY_ZERO     HEX: C0000094
+CONSTANT: STATUS_INTEGER_OVERFLOW           HEX: C0000095
+CONSTANT: STATUS_PRIVILEGED_INSTRUCTION     HEX: C0000096
+CONSTANT: STATUS_STACK_OVERFLOW             HEX: C00000FD
+CONSTANT: STATUS_CONTROL_C_EXIT             HEX: C000013A
+CONSTANT: STATUS_FLOAT_MULTIPLE_FAULTS      HEX: C00002B4
+CONSTANT: STATUS_FLOAT_MULTIPLE_TRAPS       HEX: C00002B5
+
 LIBRARY: kernel32
 ! FUNCTION: _hread
 ! FUNCTION: _hwrite
@@ -1594,8 +1622,8 @@ FUNCTION: HANDLE OpenProcess ( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD
 ! FUNCTION: QueryDosDeviceW
 ! FUNCTION: QueryInformationJobObject
 ! FUNCTION: QueryMemoryResourceNotification
-! FUNCTION: QueryPerformanceCounter
-! FUNCTION: QueryPerformanceFrequency
+FUNCTION: BOOL QueryPerformanceCounter ( LARGE_INTEGER* lpPerformanceCount ) ;
+FUNCTION: BOOL QueryPerformanceFrequency ( LARGE_INTEGER* lpFrequency ) ;
 ! FUNCTION: QueryWin31IniFilesMappedToRegistry
 ! FUNCTION: QueueUserAPC
 ! FUNCTION: QueueUserWorkItem
index bede62c813b63de59b62146a27cbe10679394b6a..08474d4bddb85335329698e460bb6b8030dd2b42 100755 (executable)
@@ -88,7 +88,7 @@ FUNCTION: HINSTANCE ShellExecuteW ( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFi
 ALIAS: ShellExecute ShellExecuteW
 
 : open-in-explorer ( dir -- )
-    [ f "open" ] dip (normalize-path) f f SW_SHOWNORMAL ShellExecute drop ;
+    [ f "open" ] dip absolute-path f f SW_SHOWNORMAL ShellExecute drop ;
 
 : shell32-directory ( n -- str )
     f swap f SHGFP_TYPE_DEFAULT
index 6cd975d42da83172595921b427f2c03cdddd77b0..419dfbba53bfbcd3ec13512d5063380982bfa26e 100644 (file)
@@ -66,7 +66,7 @@ M: attrs clear-assoc
     f >>alist drop ;
 M: attrs delete-at
     [ nip ] [ attr@ drop ] 2bi
-    [ swap alist>> delete-nth ] [ drop ] if* ;
+    [ swap alist>> remove-nth! drop ] [ drop ] if* ;
 
 M: attrs clone
     alist>> clone <attrs> ;
index 04c0b66063f311d8745b3f0b18823d178817c06d..fd8480307a6626d6610a9e1045d8eb21a9047ffe 100644 (file)
@@ -11,8 +11,8 @@ VALUE: html-entities
 
 : get-html ( -- table )
     { "lat1" "special" "symbol" } [
-        "vocab:xml/entities/html/xhtml-"
-        swap ".ent" 3append read-entities-file
+        "vocab:xml/entities/html/xhtml-" ".ent" surround
+        read-entities-file
     ] map first3 assoc-union assoc-union ;
 
 get-html to: html-entities
index 9e0c50a37d40ffbfcc667cba82043572fc7c38de..376c9b3f0ccf8ff1a68804f943f5e809a6e5ac7c 100644 (file)
@@ -74,12 +74,12 @@ $nl
 "Here is an example of the locals version:"
 { $example
 """USING: locals urls xml.syntax xml.writer ;
-[let |
-    number [ 3 ]
-    false [ f ]
-    url [ URL" http://factorcode.org/" ]
-    string [ "hello" ]
-    word [ \\ drop ] |
+[let
+    3 :> number
+    f :> false
+    URL" http://factorcode.org/" :> url
+    "hello" :> string
+    \\ drop :> word
     <XML
         <x
             number=<-number->
index 5c1669adb101671a65c1c1291a9107a590424a6f..40c86237a781d80cce2796156da86652fb761876 100644 (file)
@@ -54,8 +54,7 @@ XML-NS: foo http://blah.com
   y
   <foo/>
 </x>""" ] [
-    [let* | a [ "one" ] c [ "two" ] x [ "y" ]
-           d [ [XML <-x-> <foo/> XML] ] |
+    [let "one" :> a "two" :> c "y" :> x [XML <-x-> <foo/> XML] :> d
         <XML
             <x> <-a-> <b val=<-c->/> <-d-> </x>
         XML> pprint-xml>string
index 5b2a0bcfb4d3dc2223dd82117cda190c497a83a5..4b9900d3b0c4acc18750b4ed22748be505c3ab38 100644 (file)
@@ -156,16 +156,16 @@ MACRO: interpolate-xml ( xml -- quot )
 : collect ( accum variables -- accum ? )
     {
         { [ dup empty? ] [ drop f ] } ! Just a literal
-        { [ dup [ ] all? ] [ >search-hash parsed t ] } ! locals
-        { [ dup [ not ] all? ] [ length parsed \ nenum parsed t ] } ! fry
+        { [ dup [ ] all? ] [ >search-hash suffix! t ] } ! locals
+        { [ dup [ not ] all? ] [ length suffix! \ nenum suffix! t ] } ! fry
         [ drop "XML interpolation contains both fry and locals" throw ] ! mixed
     } cond ;
 
 : parse-def ( accum delimiter quot -- accum )
     [ parse-multiline-string [ blank? ] trim ] dip call
     [ extract-variables collect ] keep swap
-    [ number<-> parsed ] dip
-    [ \ interpolate-xml parsed ] when ; inline
+    [ number<-> suffix! ] dip
+    [ \ interpolate-xml suffix! ] when ; inline
 
 PRIVATE>
 
index 2f1d73f9ca8087840b2cc3640dc985bbc9c2fabf..6149910a558694dceafe79d33d76227e8bdfb81a 100644 (file)
@@ -1,5 +1,4 @@
-USING: xml xml.data xml.traversal tools.test accessors kernel
-io.encodings.8-bit ;
+USING: xml xml.data xml.traversal tools.test accessors kernel ;
 
 [ "\u000131" ] [ "vocab:xml/tests/latin5.xml" file>xml children>string ] unit-test
 [ "\u0000e9" ] [ "vocab:xml/tests/latin1.xml" file>xml children>string ] unit-test
index 894ec264abb4ed02eed51f130aea3fcdc5686194..40b8e2191c1173a329ff4d9cd9e011b5f4e2dc1a 100644 (file)
@@ -48,7 +48,7 @@ SYMBOL: rule-sets
 
 : get-rule-set ( name -- rule-sets rules )
     dup "::" split1 [ swap (load-mode) ] [ rule-sets get ] if*
-    dup -roll at* [ nip ] [ drop no-such-rule-set ] if ;
+    [ at* [ nip ] [ drop no-such-rule-set ] if ] keep swap ;
 
 DEFER: finalize-rule-set
 
@@ -110,7 +110,7 @@ ERROR: mutually-recursive-rulesets ruleset ;
     dup [ glob-matches? ] [ 2drop f ] if ;
 
 : suitable-mode? ( file-name first-line mode -- ? )
-    tuck first-line-glob>> ?glob-matches
+    [ nip ] 2keep first-line-glob>> ?glob-matches
     [ 2drop t ] [ file-name-glob>> ?glob-matches ] if ;
 
 : find-mode ( file-name first-line -- mode )
index d3a4f1e9a22a17c99af1bc999e4a4a159a53bdac..6b8db76ac97e88186280949eb8c9855a38563851 100755 (executable)
@@ -86,7 +86,7 @@ M: regexp text-matches?
     [ >string ] dip first-match dup [ to>> ] when ;
 
 : rule-start-matches? ( rule -- match-count/f )
-    dup start>> tuck swap can-match-here? [
+    [ start>> dup ] keep can-match-here? [
         rest-of-line swap text>> text-matches?
     ] [
         drop f
@@ -96,7 +96,7 @@ M: regexp text-matches?
     dup mark-following-rule? [
         dup start>> swap can-match-here? 0 and
     ] [
-        dup end>> tuck swap can-match-here? [
+        [ end>> dup ] keep can-match-here? [
             rest-of-line
             swap text>> context get end>> or
             text-matches?
@@ -170,7 +170,7 @@ M: seq-rule handle-rule-start
     ?end-rule
     mark-token
     add-remaining-token
-    tuck body-token>> next-token,
+    [ body-token>> next-token, ] keep
     delegate>> [ push-context ] when* ;
 
 UNION: abstract-span-rule span-rule eol-span-rule ;
@@ -179,7 +179,7 @@ M: abstract-span-rule handle-rule-start
     ?end-rule
     mark-token
     add-remaining-token
-    tuck rule-match-token* next-token,
+    [ rule-match-token* next-token, ] keep
     ! ... end subst ...
     dup context get (>>in-rule)
     delegate>> push-context ;
@@ -190,7 +190,7 @@ M: span-rule handle-rule-end
 M: mark-following-rule handle-rule-start
     ?end-rule
     mark-token add-remaining-token
-    tuck rule-match-token* next-token,
+    [ rule-match-token* next-token, ] keep
     f context get (>>end)
     context get (>>in-rule) ;
 
index 51f216fa44bd32e82bdf542999c885d0d77ec2e0..ffe6db3b4696f9cf32a5df17d273ab6f084293ae 100644 (file)
@@ -43,7 +43,7 @@ MEMO: standard-rule-set ( id -- ruleset )
 
 : ?push-all ( seq1 seq2 -- seq1+seq2 )
     [
-        over [ [ V{ } like ] dip over push-all ] [ nip ] if
+        over [ [ V{ } like ] dip append! ] [ nip ] if
     ] when* ;
 
 : rule-set-no-word-sep* ( ruleset -- str )
index 9fb9c042eea605d96f7b73ffd4de267d7076f159..6787d3714b4f5f34cfebc62506639e92d697e33d 100644 (file)
@@ -79,7 +79,7 @@ HELP: alien-callback-error
 HELP: alien-callback
 { $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" "a quotation" } { "alien" alien } }
 { $description
-    "Defines a callback from C to Factor which accepts the given set of parameters from the C caller, pushes them on the data stack, calls the quotation, and passes a return value back to the C caller. A return type of " { $snippet "\"void\"" } " indicates that no value is to be returned."
+    "Defines a callback from C to Factor which accepts the given set of parameters from the C caller, pushes them on the data stack, calls the quotation, and passes a return value back to the C caller. A return type of " { $snippet "void" } " indicates that no value is to be returned."
     $nl
     "When a compiled reference to this word is called, it pushes the callback's alien address on the data stack. This address can be passed to any C function expecting a C function pointer with the correct signature. The callback is actually generated when the word calling " { $link alien-callback } " is compiled."
     $nl
@@ -90,7 +90,7 @@ HELP: alien-callback
     "A simple example, showing a C function which returns the difference of two given integers:"
     { $code
         ": difference-callback ( -- alien )"
-        "    \"int\" { \"int\" \"int\" } \"cdecl\" [ - ] alien-callback ;"
+        "    int { int int } \"cdecl\" [ - ] alien-callback ;"
     }
 }
 { $errors "Throws an " { $link alien-callback-error } " if the word calling " { $link alien-callback } " is not compiled." } ;
index 368f0b25e7938441840eef37b556d8ae28010865..91dd150e8f14f0924754fb57ae64e640734bc763 100644 (file)
@@ -4,19 +4,9 @@ USING: accessors assocs kernel math namespaces sequences system
 kernel.private byte-arrays arrays init ;
 IN: alien
 
-! Some predicate classes used by the compiler for optimization
-! purposes
-PREDICATE: simple-alien < alien underlying>> not ;
+PREDICATE: pinned-alien < alien underlying>> not ;
 
-UNION: simple-c-ptr
-simple-alien POSTPONE: f byte-array ;
-
-DEFER: pinned-c-ptr?
-
-PREDICATE: pinned-alien < alien underlying>> pinned-c-ptr? ;
-
-UNION: pinned-c-ptr
-    pinned-alien POSTPONE: f ;
+UNION: pinned-c-ptr pinned-alien POSTPONE: f ;
 
 GENERIC: >c-ptr ( obj -- c-ptr )
 
@@ -33,7 +23,7 @@ M: alien expired? expired>> ;
 M: f expired? drop t ;
 
 : <alien> ( address -- alien )
-    f <displaced-alien> { simple-c-ptr } declare ; inline
+    f <displaced-alien> { pinned-c-ptr } declare ; inline
 
 : <bad-alien> ( -- alien )
     -1 <alien> t >>expired ; inline
@@ -49,7 +39,8 @@ M: alien equal?
         2drop f
     ] if ;
 
-M: simple-alien hashcode* nip dup expired>> [ drop 1234 ] [ alien-address ] if ;
+M: pinned-alien hashcode*
+    nip dup expired>> [ drop 1234 ] [ alien-address ] if ;
 
 ERROR: alien-callback-error ;
 
index c1b5a9e159f25c67ab3536cce186d6345e69a24e..c6516d3839bf4f80fb962df72d3b4b91520e12c7 100644 (file)
@@ -1,6 +1,6 @@
-USING: alien.strings alien.c-types alien.data tools.test kernel libc
-io.encodings.8-bit io.encodings.utf8 io.encodings.utf16
-io.encodings.utf16n io.encodings.ascii alien io.encodings.string ;
+USING: alien.strings alien.c-types alien.data tools.test
+kernel libc io.encodings.utf8 io.encodings.utf16 io.encodings.utf16n
+io.encodings.ascii alien io.encodings.string io.encodings.8-bit.latin1 ;
 IN: alien.strings.tests
 
 [ "\u0000ff" ]
index 9dd6ae425fb3e503f04221fb5d7354832acaf005..8e09fa8c2c24ea6b9563d37be834d49602c5df7f 100644 (file)
@@ -21,7 +21,7 @@ M: f alien>string
 ERROR: invalid-c-string string ;
 
 : check-string ( string -- )
-    0 over memq? [ invalid-c-string ] [ drop ] if ;
+    0 over member-eq? [ invalid-c-string ] [ drop ] if ;
 
 GENERIC# string>alien 1 ( string encoding -- byte-array )
 
index 22556ef94c14848d18990a9f7e0b357136b806ee..5a69df8cb4367d4f3b5d4a1e0af293e6d28fd91e 100755 (executable)
@@ -28,7 +28,7 @@ ARTICLE: "enums" "Enumerations"
 HELP: enum
 { $class-description "An associative structure which wraps a sequence and maps integers to the corresponding elements of the sequence."
 $nl
-"Enumerations are mutable; note that deleting a key calls " { $link delete-nth } ", which results in all subsequent elements being shifted down." } ;
+"Enumerations are mutable; note that deleting a key calls " { $link remove-nth! } ", which results in all subsequent elements being shifted down." } ;
 
 HELP: <enum>
 { $values { "seq" sequence } { "enum" enum } }
@@ -96,9 +96,7 @@ ARTICLE: "assocs-sets" "Set-theoretic operations on assocs"
     update
     assoc-union
     assoc-diff
-    remove-all
     substitute
-    substitute-here
     extract-keys
 }
 { $see-also key? assoc-any? assoc-all? "sets" } ;
@@ -348,17 +346,6 @@ HELP: assoc-diff
 { $values { "assoc1" assoc } { "assoc2" assoc } { "diff" "a new assoc" } }
 { $description "Outputs an assoc consisting of all entries from " { $snippet "assoc1" } " whose key is not contained in " { $snippet "assoc2" } "." } 
 ;
-HELP: remove-all
-{ $values { "assoc" assoc } { "seq" "a sequence" } { "subseq" "a new sequence" } }
-{ $description "Constructs a sequence consisting of all elements in " { $snippet "seq" } " which do not appear as keys in " { $snippet "assoc" } "." }
-{ $notes "The values of the keys in the assoc are disregarded, so this word is usually used for set-theoretic calculations where the assoc in question either has dummy sentinels as values, or the values equal the keys." }
-{ $side-effects "assoc" } ;
-
-HELP: substitute-here
-{ $values { "seq" "a mutable sequence" } { "assoc" assoc } }
-{ $description "Replaces elements of " { $snippet "seq" } " which appear as keys in " { $snippet "assoc" } " with the corresponding values, acting as the identity on all other elements." }
-{ $errors "Throws an error if " { $snippet "assoc" } " contains values whose types are not permissible in " { $snippet "seq" } "." }
-{ $side-effects "seq" } ;
 
 HELP: substitute
 { $values { "seq" sequence } { "assoc" assoc } { "newseq" sequence } }
index 53c3adcf3e6d0370cf1c0dbe225ece5373a8bc10..646f9a456162e564e336bfe010a92b939c16ca9b 100644 (file)
@@ -79,8 +79,6 @@ H{ } clone "cache-test" set
     H{ { 1 f } } H{ { 1 f } } assoc-intersect
 ] unit-test
 
-[ { 1 3 } ] [ H{ { 2 2 } } { 1 2 3 } remove-all ] unit-test
-
 [ H{ { "hi" 2 } { 3 4 } } ]
 [ "hi" 1 H{ { 1 2 } { 3 4 } } clone [ rename-at ] keep ]
 unit-test
index e633a54843a6dc1e7c70ba10453ef1cf95a9866e..e441855ed1929ba011a029a72004d257dcddcf9c 100755 (executable)
@@ -135,12 +135,6 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
 : assoc-diff ( assoc1 assoc2 -- diff )
     [ nip key? not ] curry assoc-filter ;
 
-: remove-all ( assoc seq -- subseq )
-    swap [ key? not ] curry filter ;
-
-: substitute-here ( seq assoc -- )
-    substituter change-each ;
-
 : substitute ( seq assoc -- newseq )
     substituter map ;
 
@@ -195,7 +189,7 @@ M: sequence clear-assoc delete-all ; inline
 
 M: sequence delete-at
     [ nip ] [ search-alist nip ] 2bi
-    [ swap delete-nth ] [ drop ] if* ;
+    [ swap remove-nth! drop ] [ drop ] if* ;
 
 M: sequence assoc-size length ; inline
 
@@ -208,6 +202,10 @@ M: sequence assoc-like
 M: sequence >alist ; inline
 
 ! Override sequence => assoc instance for f
+M: f at* 2drop f f ; inline
+
+M: f assoc-size drop 0 ; inline
+
 M: f clear-assoc drop ; inline
 
 M: f assoc-like drop dup assoc-empty? [ drop f ] when ; inline
@@ -224,7 +222,7 @@ M: enum at*
 
 M: enum set-at seq>> set-nth ; inline
 
-M: enum delete-at seq>> delete-nth ; inline
+M: enum delete-at seq>> remove-nth! drop ; inline
 
 M: enum >alist ( enum -- alist )
     seq>> [ length ] keep zip ; inline
index 5ed92b7776984daad06677ee4f5a9e2e5724619a..61bff382019b98e00253424911683a2cd764e9b1 100644 (file)
@@ -5,32 +5,30 @@ hashtables vectors strings sbufs arrays
 quotations assocs layouts classes.tuple.private
 kernel.private ;
 
-BIN: 111 tag-mask set
-8 num-tags set
-3 tag-bits set
+16 data-alignment set
 
-15 num-types set
+BIN: 1111 tag-mask set
+4 tag-bits set
+
+14 num-types set
 
 32 mega-cache-size set
 
 H{
-    { fixnum      BIN: 000 }
-    { bignum      BIN: 001 }
-    { array       BIN: 010 }
-    { float       BIN: 011 }
-    { quotation   BIN: 100 }
-    { POSTPONE: f BIN: 101 }
-    { object      BIN: 110 }
-    { hi-tag      BIN: 110 }
-    { tuple       BIN: 111 }
-} tag-numbers set
-
-tag-numbers get H{
+    { fixnum 0 }
+    { POSTPONE: f 1 }
+    { array 2 }
+    { float 3 }
+    { quotation 4 }
+    { bignum 5 }
+    { alien 6 }
+    { tuple 7 }
     { wrapper 8 }
     { byte-array 9 }
     { callstack 10 }
     { string 11 }
     { word 12 }
     { dll 13 }
-    { alien 14 }
-} assoc-union type-numbers set
+} type-numbers set
+
+2 header-bits set
index 8058707efa186c27cc0f07d7d4e9c3f7397a5716..ca9056805e18bf364ee63827598c36560a527a8d 100644 (file)
@@ -16,7 +16,7 @@ H{ } clone sub-primitives set
 
 "vocab:bootstrap/syntax.factor" parse-file
 
-"vocab:cpu/" architecture get {
+architecture get {
     { "x86.32" "x86/32" }
     { "winnt-x86.64" "x86/64/winnt" }
     { "unix-x86.64" "x86/64/unix" }
@@ -24,7 +24,7 @@ H{ } clone sub-primitives set
     { "macosx-ppc" "ppc/macosx" }
     { "arm" "arm" }
 } ?at [ "Bad architecture: " prepend throw ] unless
-"/bootstrap.factor" 3append parse-file
+"vocab:cpu/" "/bootstrap.factor" surround parse-file
 
 "vocab:bootstrap/layouts/layouts.factor" parse-file
 
@@ -55,6 +55,8 @@ num-types get f <array> builtins set
 
 bootstrapping? on
 
+[
+
 ! Create some empty vocabs where the below primitives and
 ! classes will go
 {
@@ -99,6 +101,7 @@ bootstrapping? on
     "system"
     "system.private"
     "threads.private"
+    "tools.dispatch.private"
     "tools.profiler.private"
     "words"
     "words.private"
@@ -177,10 +180,6 @@ bi
 
 "object?" "kernel" vocab-words delete-at
 
-! Class of objects with object tag
-"hi-tag" "kernel.private" create
-builtins get num-tags get tail define-union-class
-
 ! Empty class with no instances
 "null" "kernel" create
 [ f { } f union-class define-class ]
@@ -343,7 +342,6 @@ tuple
     { "swapd" "kernel" (( x y z -- y x z )) }
     { "nip" "kernel" (( x y -- y )) }
     { "2nip" "kernel" (( x y z -- z )) }
-    { "tuck" "kernel" (( x y -- y x y )) }
     { "over" "kernel" (( x y -- x y x )) }
     { "pick" "kernel" (( x y z -- x y z x )) }
     { "swap" "kernel" (( x y -- y x )) }
@@ -423,7 +421,6 @@ tuple
     { "minor-gc" "memory" (( -- )) }
     { "gc" "memory" (( -- )) }
     { "compact-gc" "memory" (( -- )) }
-    { "gc-stats" "memory" f }
     { "(save-image)" "memory.private" (( path -- )) }
     { "(save-image-and-exit)" "memory.private" (( path -- )) }
     { "datastack" "kernel" (( -- ds )) }
@@ -433,8 +430,8 @@ tuple
     { "set-retainstack" "kernel" (( rs -- )) }
     { "set-callstack" "kernel" (( cs -- )) }
     { "(exit)" "system" (( n -- )) }
-    { "data-room" "memory" (( -- cards decks generations )) }
-    { "code-room" "memory" (( -- code-total code-used code-free largest-free-block )) }
+    { "data-room" "memory" (( -- data-room )) }
+    { "code-room" "memory" (( -- code-room )) }
     { "micros" "system" (( -- us )) }
     { "modify-code-heap" "compiler.units" (( alist -- )) }
     { "(dlopen)" "alien.libraries" (( path -- dll )) }
@@ -477,9 +474,7 @@ tuple
     { "resize-array" "arrays" (( n array -- newarray )) }
     { "resize-string" "strings" (( n str -- newstr )) }
     { "<array>" "arrays" (( n elt -- array )) }
-    { "begin-scan" "memory" (( -- )) }
-    { "next-object" "memory" (( -- obj )) }
-    { "end-scan" "memory" (( -- )) }
+    { "all-instances" "memory" (( -- array )) }
     { "size" "memory" (( obj -- n )) }
     { "die" "kernel" (( -- )) }
     { "(fopen)" "io.streams.c" (( path mode -- alien )) }
@@ -509,7 +504,6 @@ tuple
     { "resize-byte-array" "byte-arrays" (( n byte-array -- newbyte-array )) }
     { "dll-valid?" "alien.libraries" (( dll -- ? )) }
     { "unimplemented" "kernel.private" (( -- * )) }
-    { "gc-reset" "memory" (( -- )) }
     { "jit-compile" "quotations" (( quot -- )) }
     { "load-locals" "locals.backend" (( ... n -- )) }
     { "check-datastack" "kernel.private" (( array in# out# -- ? )) }
@@ -517,16 +511,20 @@ tuple
     { "inline-cache-miss-tail" "generic.single.private" (( generic methods index cache -- )) }
     { "mega-cache-miss" "generic.single.private" (( methods index cache -- method )) }
     { "lookup-method" "generic.single.private" (( object methods -- method )) }
-    { "reset-dispatch-stats" "generic.single" (( -- )) }
-    { "dispatch-stats" "generic.single" (( -- stats )) }
-    { "reset-inline-cache-stats" "generic.single" (( -- )) }
-    { "inline-cache-stats" "generic.single" (( -- stats )) }
+    { "reset-dispatch-stats" "tools.dispatch.private" (( -- )) }
+    { "dispatch-stats" "tools.dispatch.private" (( -- stats )) }
     { "optimized?" "words" (( word -- ? )) }
     { "quot-compiled?" "quotations" (( quot -- ? )) }
     { "vm-ptr" "vm" (( -- ptr )) }
     { "strip-stack-traces" "kernel.private" (( -- )) }
     { "<callback>" "alien" (( word -- alien )) }
+    { "enable-gc-events" "memory" (( -- )) }
+    { "disable-gc-events" "memory" (( -- events )) }
+    { "(identity-hashcode)" "kernel.private" (( obj -- code )) }
+    { "compute-identity-hashcode" "kernel.private" (( obj -- )) }
 } [ [ first3 ] dip swap make-primitive ] each-index
 
 ! Bump build number
 "build" "kernel" create build 1 + [ ] curry (( -- n )) define-declared
+
+] with-compilation-unit
index 1e8ebe2938cfa9c3c7c7329cca3ad1f1eb830e3e..29d0a311a311eb5928549d0e9eacfae948c5e2cb 100644 (file)
@@ -14,28 +14,23 @@ IN: bootstrap.stage1
 load-help? off
 { "resource:core" } vocab-roots set
 
-! Create a boot quotation for the target
+! Create a boot quotation for the target by collecting all top-level
+! forms into a quotation, surrounded by some boilerplate.
 [
     [
-        ! Rehash hashtables, since bootstrap.image creates them
-        ! using the host image's hashing algorithms. We don't
-        ! use each-object here since the catch stack isn't yet
-        ! set up.
-        gc
-        begin-scan
-        [ hashtable? ] pusher [ (each-object) ] dip
-        end-scan
-        [ rehash ] each
+        ! Rehash hashtables first, since bootstrap.image creates
+        ! them using the host image's hashing algorithms.
+        [ hashtable? ] instances [ rehash ] each
         boot
     ] %
 
     "math.integers" require
     "math.floats" require
     "memory" require
-    
+
     "io.streams.c" require
     "vocabs.loader" require
-    
+
     "syntax" require
     "bootstrap.layouts" require
 
index 57be2fb90f25b059dc64babaad361fbaddf52a02..bb159f04df985a28c2826e6623cdf5ac2f5ac7f2 100644 (file)
@@ -1,90 +1,93 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: words words.symbol sequences vocabs kernel ;
+USING: words words.symbol sequences vocabs kernel
+compiler.units ;
 IN: bootstrap.syntax
 
-"syntax" create-vocab drop
+[
+    "syntax" create-vocab drop
 
-{
-    "!"
-    "\""
-    "#!"
-    "("
-    "(("
-    ":"
-    ";"
-    "<PRIVATE"
-    "BIN:"
-    "B{"
-    "BV{"
-    "C:"
-    "CHAR:"
-    "DEFER:"
-    "ERROR:"
-    "FORGET:"
-    "GENERIC#"
-    "GENERIC:"
-    "HEX:"
-    "HOOK:"
-    "H{"
-    "IN:"
-    "INSTANCE:"
-    "M:"
-    "MAIN:"
-    "MATH:"
-    "MIXIN:"
-    "NAN:"
-    "OCT:"
-    "P\""
-    "POSTPONE:"
-    "PREDICATE:"
-    "PRIMITIVE:"
-    "PRIVATE>"
-    "SBUF\""
-    "SINGLETON:"
-    "SINGLETONS:"
-    "SYMBOL:"
-    "SYMBOLS:"
-    "CONSTANT:"
-    "TUPLE:"
-    "SLOT:"
-    "T{"
-    "UNION:"
-    "INTERSECTION:"
-    "USE:"
-    "UNUSE:"
-    "USING:"
-    "QUALIFIED:"
-    "QUALIFIED-WITH:"
-    "FROM:"
-    "EXCLUDE:"
-    "RENAME:"
-    "ALIAS:"
-    "SYNTAX:"
-    "V{"
-    "W{"
-    "["
-    "\\"
-    "M\\"
-    "]"
-    "delimiter"
-    "deprecated"
-    "f"
-    "flushable"
-    "foldable"
-    "inline"
-    "recursive"
-    "t"
-    "{"
-    "}"
-    "CS{"
-    "<<"
-    ">>"
-    "call-next-method"
-    "initial:"
-    "read-only"
-    "call("
-    "execute("
-} [ "syntax" create drop ] each
+    {
+        "!"
+        "\""
+        "#!"
+        "("
+        "(("
+        ":"
+        ";"
+        "<PRIVATE"
+        "BIN:"
+        "B{"
+        "BV{"
+        "C:"
+        "CHAR:"
+        "DEFER:"
+        "ERROR:"
+        "FORGET:"
+        "GENERIC#"
+        "GENERIC:"
+        "HEX:"
+        "HOOK:"
+        "H{"
+        "IN:"
+        "INSTANCE:"
+        "M:"
+        "MAIN:"
+        "MATH:"
+        "MIXIN:"
+        "NAN:"
+        "OCT:"
+        "P\""
+        "POSTPONE:"
+        "PREDICATE:"
+        "PRIMITIVE:"
+        "PRIVATE>"
+        "SBUF\""
+        "SINGLETON:"
+        "SINGLETONS:"
+        "SYMBOL:"
+        "SYMBOLS:"
+        "CONSTANT:"
+        "TUPLE:"
+        "SLOT:"
+        "T{"
+        "UNION:"
+        "INTERSECTION:"
+        "USE:"
+        "UNUSE:"
+        "USING:"
+        "QUALIFIED:"
+        "QUALIFIED-WITH:"
+        "FROM:"
+        "EXCLUDE:"
+        "RENAME:"
+        "ALIAS:"
+        "SYNTAX:"
+        "V{"
+        "W{"
+        "["
+        "\\"
+        "M\\"
+        "]"
+        "delimiter"
+        "deprecated"
+        "f"
+        "flushable"
+        "foldable"
+        "inline"
+        "recursive"
+        "t"
+        "{"
+        "}"
+        "CS{"
+        "<<"
+        ">>"
+        "call-next-method"
+        "initial:"
+        "read-only"
+        "call("
+        "execute("
+    } [ "syntax" create drop ] each
 
-"t" "syntax" lookup define-symbol
+    "t" "syntax" lookup define-symbol
+] with-compilation-unit
index 287e9724051a91ead34cad6453cafce3cefdd36d..4f6ade858068b5a22385987f495381e57095ceba 100644 (file)
@@ -43,4 +43,6 @@ M: byte-array like
 \r
 M: byte-array new-resizable drop <byte-vector> ; inline\r
 \r
+M: byte-vector new-resizable drop <byte-vector> ; inline\r
+\r
 INSTANCE: byte-vector growable\r
index 1b2ea7dfd481fa25ace4fe44f53e213e65872702..7b931c80e8260326e2eb1bfe6f76d579671d16f7 100644 (file)
@@ -11,13 +11,7 @@ ARTICLE: "class-operations" "Class operations"
     class-and\r
     class-or\r
     classes-intersect?\r
-}\r
-"Low-level implementation detail:"\r
-{ $subsections\r
     flatten-class\r
-    flatten-builtin-class\r
-    class-types\r
-    class-tags\r
 } ;\r
 \r
 ARTICLE: "class-linearization" "Class linearization"\r
@@ -46,18 +40,10 @@ $nl
 "Metaclass order:"\r
 { $subsections rank-class } ;\r
 \r
-HELP: flatten-builtin-class\r
-{ $values { "class" class } { "assoc" "an assoc whose keys are classes" } }\r
-{ $description "Outputs a set of tuple classes whose union is the smallest cover of " { $snippet "class" } " intersected with " { $link tuple } "." } ;\r
-\r
 HELP: flatten-class\r
 { $values { "class" class } { "assoc" "an assoc whose keys are classes" } }\r
 { $description "Outputs a set of builtin and tuple classes whose union is the smallest cover of " { $snippet "class" } "." } ;\r
 \r
-HELP: class-types\r
-{ $values { "class" class } { "seq" "an increasing sequence of integers" } }\r
-{ $description "Outputs a sequence of builtin type numbers whose instances can possibly be instances of the given class." } ;\r
-\r
 HELP: class<=\r
 { $values { "first" "a class" } { "second" "a class" } { "?" "a boolean" } }\r
 { $description "Tests if all instances of " { $snippet "class1" } " are also instances of " { $snippet "class2" } "." }\r
index 855a15b66f3b0bba66ff63db05720b2cc4e1bcbc..c016b0169bf22808088a86abbd700c94c738fa78 100644 (file)
@@ -7,36 +7,42 @@ stack-checker effects kernel.private sbufs math.order
 classes.tuple accessors generic.private ;\r
 IN: classes.algebra.tests\r
 \r
-: class-and* ( cls1 cls2 cls3 -- ? ) [ class-and ] dip class= ;\r
+TUPLE: first-one ;\r
+TUPLE: second-one ;\r
+UNION: both first-one union-class ;\r
 \r
-: class-or* ( cls1 cls2 cls3 -- ? ) [ class-or ] dip class= ;\r
+PREDICATE: no-docs < word "documentation" word-prop not ;\r
 \r
-[ t ] [ object  object  object class-and* ] unit-test\r
-[ t ] [ fixnum  object  fixnum class-and* ] unit-test\r
-[ t ] [ object  fixnum  fixnum class-and* ] unit-test\r
-[ t ] [ fixnum  fixnum  fixnum class-and* ] unit-test\r
-[ t ] [ fixnum  integer fixnum class-and* ] unit-test\r
-[ t ] [ integer fixnum  fixnum class-and* ] unit-test\r
+UNION: no-docs-union no-docs integer ;\r
 \r
-[ t ] [ vector    fixnum   null   class-and* ] unit-test\r
-[ t ] [ number    object   number class-and* ] unit-test\r
-[ t ] [ object    number   number class-and* ] unit-test\r
-[ t ] [ slice     reversed null   class-and* ] unit-test\r
-[ t ] [ \ f class-not \ f      null   class-and* ] unit-test\r
-[ t ] [ \ f class-not \ f      object class-or*  ] unit-test\r
+TUPLE: a ;\r
+TUPLE: b ;\r
+UNION: c a b ;\r
 \r
-TUPLE: first-one ;\r
-TUPLE: second-one ;\r
-UNION: both first-one union-class ;\r
+TUPLE: tuple-example ;\r
 \r
-[ t ] [ both tuple classes-intersect? ] unit-test\r
-[ t ] [ vector virtual-sequence null class-and* ] unit-test\r
-[ f ] [ vector virtual-sequence classes-intersect? ] unit-test\r
+TUPLE: a1 ;\r
+TUPLE: b1 ;\r
+TUPLE: c1 ;\r
 \r
-[ t ] [ number vector class-or sequence classes-intersect? ] unit-test\r
+UNION: x1 a1 b1 ;\r
+UNION: y1 a1 c1 ;\r
+UNION: z1 b1 c1 ;\r
 \r
-[ f ] [ number vector class-and sequence classes-intersect? ] unit-test\r
+SINGLETON: sa\r
+SINGLETON: sb\r
+SINGLETON: sc\r
+\r
+INTERSECTION: empty-intersection ;\r
+\r
+INTERSECTION: generic-class generic class ;\r
 \r
+UNION: union-with-one-member a ;\r
+\r
+MIXIN: mixin-with-one-member\r
+INSTANCE: union-with-one-member mixin-with-one-member\r
+\r
+! class<=\r
 [ t ] [ \ fixnum \ integer class<= ] unit-test\r
 [ t ] [ \ fixnum \ fixnum class<= ] unit-test\r
 [ f ] [ \ integer \ fixnum class<= ] unit-test\r
@@ -50,73 +56,41 @@ UNION: both first-one union-class ;
 [ f ] [ \ reversed \ slice class<= ] unit-test\r
 [ f ] [ \ slice \ reversed class<= ] unit-test\r
 \r
-PREDICATE: no-docs < word "documentation" word-prop not ;\r
-\r
-UNION: no-docs-union no-docs integer ;\r
-\r
 [ t ] [ no-docs no-docs-union class<= ] unit-test\r
 [ f ] [ no-docs-union no-docs class<= ] unit-test\r
 \r
-TUPLE: a ;\r
-TUPLE: b ;\r
-UNION: c a b ;\r
-\r
 [ t ] [ \ c \ tuple class<= ] unit-test\r
 [ f ] [ \ tuple \ c class<= ] unit-test\r
 \r
 [ t ] [ \ tuple-class \ class class<= ] unit-test\r
 [ f ] [ \ class \ tuple-class class<= ] unit-test\r
 \r
-TUPLE: tuple-example ;\r
-\r
 [ t ] [ \ null \ tuple-example class<= ] unit-test\r
 [ f ] [ \ object \ tuple-example class<= ] unit-test\r
 [ f ] [ \ object \ tuple-example class<= ] unit-test\r
 [ t ] [ \ tuple-example \ tuple class<= ] unit-test\r
 [ f ] [ \ tuple \ tuple-example class<= ] unit-test\r
 \r
-TUPLE: a1 ;\r
-TUPLE: b1 ;\r
-TUPLE: c1 ;\r
-\r
-UNION: x1 a1 b1 ;\r
-UNION: y1 a1 c1 ;\r
-UNION: z1 b1 c1 ;\r
-\r
 [ f ] [ z1 x1 y1 class-and class<= ] unit-test\r
 \r
 [ t ] [ x1 y1 class-and a1 class<= ] unit-test\r
 \r
-[ f ] [ y1 z1 class-and x1 classes-intersect? ] unit-test\r
-\r
 [ f ] [ b1 c1 class-or a1 b1 class-or a1 c1 class-and class-and class<= ] unit-test\r
 \r
 [ t ] [ a1 b1 class-or a1 c1 class-or class-and a1 class<= ] unit-test\r
 \r
-[ f ] [ a1 c1 class-or b1 c1 class-or class-and a1 b1 class-or classes-intersect? ] unit-test\r
-\r
-[ f ] [ growable \ hi-tag classes-intersect? ] unit-test\r
-\r
-[ t ] [\r
-    growable tuple sequence class-and class<=\r
-] unit-test\r
+[ t ] [ growable tuple sequence class-and class<= ] unit-test\r
 \r
-[ t ] [\r
-    growable assoc class-and tuple class<=\r
-] unit-test\r
+[ t ] [ growable assoc class-and tuple class<= ] unit-test\r
 \r
 [ t ] [ object \ f \ f class-not class-or class<= ] unit-test\r
 \r
 [ t ] [ fixnum class-not integer class-and bignum class= ] unit-test\r
 \r
-[ f ] [ integer integer class-not classes-intersect? ] unit-test\r
-\r
 [ t ] [ array number class-not class<= ] unit-test\r
 \r
 [ f ] [ bignum number class-not class<= ] unit-test\r
 \r
-[ vector ] [ vector class-not class-not ] unit-test\r
-\r
 [ t ] [ fixnum fixnum bignum class-or class<= ] unit-test\r
 \r
 [ f ] [ fixnum class-not integer class-and array class<= ] unit-test\r
@@ -129,12 +103,99 @@ UNION: z1 b1 c1 ;
 \r
 [ t ] [ number class-not integer class-not class<= ] unit-test\r
 \r
-[ t ] [ vector array class-not class-and vector class= ] unit-test\r
+[ f ] [ fixnum class-not integer class<= ] unit-test\r
+\r
+[ t ] [ object empty-intersection class<= ] unit-test\r
+[ t ] [ empty-intersection object class<= ] unit-test\r
+[ t ] [ \ f class-not empty-intersection class<= ] unit-test\r
+[ f ] [ empty-intersection \ f class-not class<= ] unit-test\r
+[ t ] [ \ number empty-intersection class<= ] unit-test\r
+[ t ] [ empty-intersection class-not null class<= ] unit-test\r
+[ t ] [ null empty-intersection class-not class<= ] unit-test\r
+\r
+[ t ] [ \ f class-not \ f class-or empty-intersection class<= ] unit-test\r
+[ t ] [ empty-intersection \ f class-not \ f class-or class<= ] unit-test\r
+\r
+[ t ] [ object \ f class-not \ f class-or class<= ] unit-test\r
+\r
+[ t ] [\r
+    fixnum class-not\r
+    fixnum fixnum class-not class-or\r
+    class<=\r
+] unit-test\r
+\r
+[ t ] [ generic-class generic class<= ] unit-test\r
+[ t ] [ generic-class \ class class<= ] unit-test\r
+\r
+[ t ] [ a union-with-one-member class<= ] unit-test\r
+[ f ] [ union-with-one-member class-not integer class<= ] unit-test\r
+\r
+! class-and\r
+: class-and* ( cls1 cls2 cls3 -- ? ) [ class-and ] dip class= ;\r
+\r
+[ t ] [ object  object  object class-and* ] unit-test\r
+[ t ] [ fixnum  object  fixnum class-and* ] unit-test\r
+[ t ] [ object  fixnum  fixnum class-and* ] unit-test\r
+[ t ] [ fixnum  fixnum  fixnum class-and* ] unit-test\r
+[ t ] [ fixnum  integer fixnum class-and* ] unit-test\r
+[ t ] [ integer fixnum  fixnum class-and* ] unit-test\r
+\r
+[ t ] [ vector    fixnum   null   class-and* ] unit-test\r
+[ t ] [ number    object   number class-and* ] unit-test\r
+[ t ] [ object    number   number class-and* ] unit-test\r
+[ t ] [ slice     reversed null   class-and* ] unit-test\r
+[ t ] [ \ f class-not \ f      null   class-and* ] unit-test\r
+\r
+[ t ] [ vector virtual-sequence null class-and* ] unit-test\r
+\r
+[ t ] [ vector array class-not vector class-and* ] unit-test\r
+\r
+! class-or\r
+: class-or* ( cls1 cls2 cls3 -- ? ) [ class-or ] dip class= ;\r
+\r
+[ t ] [ \ f class-not \ f      object class-or*  ] unit-test\r
+\r
+! class-not\r
+[ vector ] [ vector class-not class-not ] unit-test\r
+\r
+! classes-intersect?\r
+[ t ] [ both tuple classes-intersect? ] unit-test\r
+[ f ] [ vector virtual-sequence classes-intersect? ] unit-test\r
+\r
+[ t ] [ number vector class-or sequence classes-intersect? ] unit-test\r
+\r
+[ f ] [ number vector class-and sequence classes-intersect? ] unit-test\r
+\r
+[ f ] [ y1 z1 class-and x1 classes-intersect? ] unit-test\r
+\r
+[ f ] [ a1 c1 class-or b1 c1 class-or class-and a1 b1 class-or classes-intersect? ] unit-test\r
+\r
+[ f ] [ integer integer class-not classes-intersect? ] unit-test\r
 \r
 [ f ] [ fixnum class-not number class-and array classes-intersect? ] unit-test\r
 \r
-[ f ] [ fixnum class-not integer class<= ] unit-test\r
+[ t ] [ \ word generic-class classes-intersect? ] unit-test\r
+[ f ] [ number generic-class classes-intersect? ] unit-test\r
+\r
+[ f ] [ sa sb classes-intersect? ] unit-test\r
 \r
+[ t ] [ a union-with-one-member classes-intersect? ] unit-test\r
+[ f ] [ fixnum union-with-one-member classes-intersect? ] unit-test\r
+[ t ] [ object union-with-one-member classes-intersect? ] unit-test\r
+\r
+[ t ] [ union-with-one-member a classes-intersect? ] unit-test\r
+[ f ] [ union-with-one-member fixnum classes-intersect? ] unit-test\r
+[ t ] [ union-with-one-member object classes-intersect? ] unit-test\r
+\r
+[ t ] [ a mixin-with-one-member classes-intersect? ] unit-test\r
+[ f ] [ fixnum mixin-with-one-member classes-intersect? ] unit-test\r
+[ t ] [ object mixin-with-one-member classes-intersect? ] unit-test\r
+\r
+[ t ] [ mixin-with-one-member a classes-intersect? ] unit-test\r
+[ f ] [ mixin-with-one-member fixnum classes-intersect? ] unit-test\r
+[ t ] [ mixin-with-one-member object classes-intersect? ] unit-test\r
+\r
+! class=\r
 [ t ] [ null class-not object class= ] unit-test\r
 \r
 [ t ] [ object class-not null class= ] unit-test\r
@@ -143,13 +204,14 @@ UNION: z1 b1 c1 ;
 \r
 [ f ] [ null class-not null class= ] unit-test\r
 \r
-[ t ] [\r
-    fixnum class-not\r
-    fixnum fixnum class-not class-or\r
-    class<=\r
-] unit-test\r
+! class<=>\r
 \r
-! Test method inlining\r
+[ +lt+ ] [ integer sequence class<=> ] unit-test\r
+[ +lt+ ] [ sequence object class<=> ] unit-test\r
+[ +gt+ ] [ object sequence class<=> ] unit-test\r
+[ +eq+ ] [ integer integer class<=> ] unit-test\r
+\r
+! smallest-class etc\r
 [ real ] [ { real sequence } smallest-class ] unit-test\r
 [ real ] [ { sequence real } smallest-class ] unit-test\r
 \r
@@ -268,59 +330,10 @@ TUPLE: xh < xb ;
 \r
 [ t ] [ { xa xb xc xd xe xf xg xh } sort-classes dup sort-classes = ] unit-test\r
 \r
-INTERSECTION: generic-class generic class ;\r
-\r
-[ t ] [ generic-class generic class<= ] unit-test\r
-[ t ] [ generic-class \ class class<= ] unit-test\r
-\r
-! Later\r
-[\r
-    [ t ] [ \ class generic class-and generic-class class<= ] unit-test\r
-    [ t ] [ \ class generic class-and generic-class swap class<= ] unit-test\r
-] drop\r
-\r
-[ t ] [ \ word generic-class classes-intersect? ] unit-test\r
-[ f ] [ number generic-class classes-intersect? ] unit-test\r
-\r
 [ H{ { word word } } ] [ \r
     generic-class flatten-class\r
 ] unit-test\r
 \r
-[ \ + flatten-class ] must-fail\r
-\r
-INTERSECTION: empty-intersection ;\r
-\r
-[ t ] [ object empty-intersection class<= ] unit-test\r
-[ t ] [ empty-intersection object class<= ] unit-test\r
-[ t ] [ \ f class-not empty-intersection class<= ] unit-test\r
-[ f ] [ empty-intersection \ f class-not class<= ] unit-test\r
-[ t ] [ \ number empty-intersection class<= ] unit-test\r
-[ t ] [ empty-intersection class-not null class<= ] unit-test\r
-[ t ] [ null empty-intersection class-not class<= ] unit-test\r
-\r
-[ t ] [ \ f class-not \ f class-or empty-intersection class<= ] unit-test\r
-[ t ] [ empty-intersection \ f class-not \ f class-or class<= ] unit-test\r
-\r
-[ t ] [ object \ f class-not \ f class-or class<= ] unit-test\r
-\r
-[ ] [ object flatten-builtin-class drop ] unit-test\r
-\r
-SINGLETON: sa\r
-SINGLETON: sb\r
-SINGLETON: sc\r
-\r
 [ sa ] [ sa { sa sb sc } min-class ] unit-test\r
 \r
-[ f ] [ sa sb classes-intersect? ] unit-test\r
-\r
-[ +lt+ ] [ integer sequence class<=> ] unit-test\r
-[ +lt+ ] [ sequence object class<=> ] unit-test\r
-[ +gt+ ] [ object sequence class<=> ] unit-test\r
-[ +eq+ ] [ integer integer class<=> ] unit-test\r
-\r
-! Limitations:\r
-\r
-! UNION: u1 sa sb ;\r
-! UNION: u2 sc ;\r
-\r
-! [ f ] [ u1 u2 classes-intersect? ] unit-test\r
+[ \ + flatten-class ] must-fail\r
index 2d67403f9423cbcfd83a9a7e8e794191066c2cb2..e98470cd837e3760a60bfd26f8478e6c20d789e2 100755 (executable)
@@ -5,18 +5,44 @@ vectors assocs namespaces words sorting layouts math hashtables
 kernel.private sets math.order ;\r
 IN: classes.algebra\r
 \r
-TUPLE: anonymous-union members ;\r
+<PRIVATE\r
 \r
-C: <anonymous-union> anonymous-union\r
+TUPLE: anonymous-union { members read-only } ;\r
 \r
-TUPLE: anonymous-intersection participants ;\r
+: <anonymous-union> ( members -- class )\r
+    [ null eq? not ] filter prune\r
+    dup length 1 = [ first ] [ anonymous-union boa ] if ;\r
 \r
-C: <anonymous-intersection> anonymous-intersection\r
+TUPLE: anonymous-intersection { participants read-only } ;\r
 \r
-TUPLE: anonymous-complement class ;\r
+: <anonymous-intersection> ( participants -- class )\r
+    prune dup length 1 = [ first ] [ anonymous-intersection boa ] if ;\r
+\r
+TUPLE: anonymous-complement { class read-only } ;\r
 \r
 C: <anonymous-complement> anonymous-complement\r
 \r
+DEFER: (class<=)\r
+\r
+DEFER: (class-not)\r
+\r
+GENERIC: (classes-intersect?) ( first second -- ? )\r
+\r
+DEFER: (class-and)\r
+\r
+DEFER: (class-or)\r
+\r
+GENERIC: (flatten-class) ( class -- )\r
+\r
+: normalize-class ( class -- class' )\r
+    {\r
+        { [ dup members ] [ members <anonymous-union> normalize-class ] }\r
+        { [ dup participants ] [ participants <anonymous-intersection> normalize-class ] }\r
+        [ ]\r
+    } cond ;\r
+\r
+PRIVATE>\r
+\r
 GENERIC: valid-class? ( obj -- ? )\r
 \r
 M: class valid-class? drop t ;\r
@@ -25,40 +51,42 @@ M: anonymous-intersection valid-class? participants>> [ valid-class? ] all? ;
 M: anonymous-complement valid-class? class>> valid-class? ;\r
 M: word valid-class? drop f ;\r
 \r
-DEFER: (class<=)\r
-\r
 : class<= ( first second -- ? )\r
     class<=-cache get [ (class<=) ] 2cache ;\r
 \r
-DEFER: (class-not)\r
-\r
-: class-not ( class -- complement )\r
-    class-not-cache get [ (class-not) ] cache ;\r
-\r
-GENERIC: (classes-intersect?) ( first second -- ? )\r
+: class< ( first second -- ? )\r
+    {\r
+        { [ 2dup class<= not ] [ 2drop f ] }\r
+        { [ 2dup swap class<= not ] [ 2drop t ] }\r
+        [ [ rank-class ] bi@ < ]\r
+    } cond ;\r
 \r
-: normalize-class ( class -- class' )\r
+: class<=> ( first second -- ? )\r
     {\r
-        { [ dup members ] [ members <anonymous-union> ] }\r
-        { [ dup participants ] [ participants <anonymous-intersection> ] }\r
-        [ ]\r
+        { [ 2dup class<= not ] [ 2drop +gt+ ] }\r
+        { [ 2dup swap class<= not ] [ 2drop +lt+ ] }\r
+        [ [ rank-class ] bi@ <=> ]\r
     } cond ;\r
 \r
+: class= ( first second -- ? )\r
+    [ class<= ] [ swap class<= ] 2bi and ;\r
+\r
+: class-not ( class -- complement )\r
+    class-not-cache get [ (class-not) ] cache ;\r
+\r
 : classes-intersect? ( first second -- ? )\r
     classes-intersect-cache get [\r
         normalize-class (classes-intersect?)\r
     ] 2cache ;\r
 \r
-DEFER: (class-and)\r
-\r
 : class-and ( first second -- class )\r
     class-and-cache get [ (class-and) ] 2cache ;\r
 \r
-DEFER: (class-or)\r
-\r
 : class-or ( first second -- class )\r
     class-or-cache get [ (class-or) ] 2cache ;\r
 \r
+<PRIVATE\r
+\r
 : superclass<= ( first second -- ? )\r
     swap superclass dup [ swap class<= ] [ 2drop f ] if ;\r
 \r
@@ -89,6 +117,7 @@ DEFER: (class-or)
             [ class-not normalize-class ] map\r
             <anonymous-union>\r
         ] }\r
+        [ <anonymous-complement> ]\r
     } cond ;\r
 \r
 : left-anonymous-complement<= ( first second -- ? )\r
@@ -108,8 +137,10 @@ PREDICATE: empty-intersection < anonymous-intersection participants>> empty? ;
 \r
 : (class<=) ( first second -- ? )\r
     2dup eq? [ 2drop t ] [\r
+        [ normalize-class ] bi@\r
         2dup superclass<= [ 2drop t ] [\r
-            [ normalize-class ] bi@ {\r
+            {\r
+                { [ 2dup eq? ] [ 2drop t ] }\r
                 { [ dup empty-intersection? ] [ 2drop t ] }\r
                 { [ over empty-union? ] [ 2drop t ] }\r
                 { [ 2dup [ anonymous-complement? ] both? ] [ anonymous-complement<= ] }\r
@@ -185,22 +216,10 @@ M: anonymous-complement (classes-intersect?)
         [ <anonymous-complement> ]\r
     } cond ;\r
 \r
-: class< ( first second -- ? )\r
-    {\r
-        { [ 2dup class<= not ] [ 2drop f ] }\r
-        { [ 2dup swap class<= not ] [ 2drop t ] }\r
-        [ [ rank-class ] bi@ < ]\r
-    } cond ;\r
-\r
-: class<=> ( first second -- ? )\r
-    {\r
-        { [ 2dup class<= not ] [ 2drop +gt+ ] }\r
-        { [ 2dup swap class<= not ] [ 2drop +lt+ ] }\r
-        [ [ rank-class ] bi@ <=> ]\r
-    } cond ;\r
+M: anonymous-union (flatten-class)\r
+    members>> [ (flatten-class) ] each ;\r
 \r
-: class= ( first second -- ? )\r
-    [ class<= ] [ swap class<= ] 2bi and ;\r
+PRIVATE>\r
 \r
 ERROR: topological-sort-failed ;\r
 \r
@@ -211,7 +230,7 @@ ERROR: topological-sort-failed ;
 : sort-classes ( seq -- newseq )\r
     [ name>> ] sort-with >vector\r
     [ dup empty? not ]\r
-    [ dup largest-class [ over delete-nth ] dip ]\r
+    [ dup largest-class [ swap remove-nth! ] dip ]\r
     produce nip ;\r
 \r
 : smallest-class ( classes -- class/f )\r
@@ -220,28 +239,5 @@ ERROR: topological-sort-failed ;
         [ ] [ [ class<= ] most ] map-reduce\r
     ] if-empty ;\r
 \r
-GENERIC: (flatten-class) ( class -- )\r
-\r
-M: anonymous-union (flatten-class)\r
-    members>> [ (flatten-class) ] each ;\r
-\r
 : flatten-class ( class -- assoc )\r
     [ (flatten-class) ] H{ } make-assoc ;\r
-\r
-: flatten-builtin-class ( class -- assoc )\r
-    flatten-class [\r
-        dup tuple class<= [ 2drop tuple tuple ] when\r
-    ] assoc-map ;\r
-\r
-: class-types ( class -- seq )\r
-    flatten-builtin-class keys\r
-    [ "type" word-prop ] map natural-sort ;\r
-\r
-: class-tags ( class -- seq )\r
-    class-types [\r
-        dup num-tags get >=\r
-        [ drop \ hi-tag tag-number ] when\r
-    ] map prune ;\r
-\r
-: class-tag ( class -- tag/f )\r
-    class-tags dup length 1 = [ first ] [ drop f ] if ;\r
index 9d41239206a4396f39d372ce64f1cc24544c6f5f..ecc484df1117ba04436488a9ecd1e4202e2e2ff0 100644 (file)
@@ -9,7 +9,7 @@ $nl
     builtin-class
     builtin-class?
 }
-"See " { $link "type-index" } " for a list of built-in classes." ;
+"See " { $link "class-index" } " for a list of built-in classes." ;
 
 HELP: builtin-class
 { $class-description "The class of built-in classes." }
index 8eeb4ce3575e3884e149cc3aebe3282c4b9ccf6b..028225ec490aada25e0b56d4de2650fcc1c9c2be 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors classes classes.algebra words kernel
-kernel.private namespaces sequences math math.private
-combinators assocs quotations ;
+USING: accessors classes classes.algebra classes.algebra.private
+words kernel kernel.private namespaces sequences math
+math.private combinators assocs quotations ;
 IN: classes.builtin
 
 SYMBOL: builtins
@@ -12,34 +12,20 @@ PREDICATE: builtin-class < class
 
 : class>type ( class -- n ) "type" word-prop ; foldable
 
-PREDICATE: lo-tag-class < builtin-class class>type 7 <= ;
-
-PREDICATE: hi-tag-class < builtin-class class>type 7 > ;
-
 : type>class ( n -- class ) builtins get-global nth ;
 
 : bootstrap-type>class ( n -- class ) builtins get nth ;
 
-M: hi-tag class hi-tag type>class ; inline
-
 M: object class tag type>class ; inline
 
 M: builtin-class rank-class drop 0 ;
 
 GENERIC: define-builtin-predicate ( class -- )
 
-M: lo-tag-class define-builtin-predicate
+M: builtin-class define-builtin-predicate
     dup class>type [ eq? ] curry [ tag ] prepend define-predicate ;
 
-M: hi-tag-class define-builtin-predicate
-    dup class>type [ eq? ] curry [ hi-tag ] prepend 1quotation
-    [ dup tag 6 eq? ] [ [ drop f ] if ] surround
-    define-predicate ;
-
-M: lo-tag-class instance? [ tag ] [ class>type ] bi* eq? ;
-
-M: hi-tag-class instance?
-    over tag 6 eq? [ [ hi-tag ] [ class>type ] bi* eq? ] [ 2drop f ] if ;
+M: builtin-class instance? [ tag ] [ class>type ] bi* eq? ;
 
 M: builtin-class (flatten-class) dup set ;
 
@@ -50,6 +36,6 @@ M: builtin-class (classes-intersect?)
         [ swap classes-intersect? ]
     } cond ;
 
-: full-cover ( -- ) builtins get sift [ (flatten-class) ] each ;
+: full-cover ( -- ) builtins get [ (flatten-class) ] each ;
 
 M: anonymous-complement (flatten-class) drop full-cover ;
index 5607bc3a2215aeb834d5100a65101f665fc564b9..10a5f674bd8fabfc68f50f8b38ddaa0c525b0c07 100644 (file)
@@ -11,7 +11,6 @@ IN: classes.tests
 [ f ] [ 3 float instance? ] unit-test
 [ t ] [ 3 number instance? ] unit-test
 [ f ] [ 3 null instance? ] unit-test
-[ t ] [ "hi" \ hi-tag instance? ] unit-test
 
 ! Regression
 GENERIC: method-forget-test ( obj -- obj )
index a0481a62a730963f14d6ed06d0d9ba64db29ff0d..36514f3cb2e8aef18bb4055142b400ac6b4ae6a8 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words accessors sequences kernel assocs combinators classes
-classes.algebra classes.builtin namespaces arrays math quotations ;
+classes.algebra classes.algebra.private classes.builtin
+namespaces arrays math quotations ;
 IN: classes.intersection
 
 PREDICATE: intersection-class < class
index 6cf95716beb711ecde1e7feacb5444c9d2ca212c..6514f36074ca0bd0acd3ed908a9a683d36d8b854 100644 (file)
@@ -34,7 +34,7 @@ TUPLE: check-mixin-class class ;
     ] unless ;
 
 : if-mixin-member? ( class mixin true false -- )
-    [ check-mixin-class 2dup members memq? ] 2dip if ; inline
+    [ check-mixin-class 2dup members member-eq? ] 2dip if ; inline
 
 : change-mixin-class ( class mixin quot -- )
     [ [ members swap bootstrap-word ] dip call ] [ drop ] 2bi
index e544c7f8aba361cc10715b5bcf2808e335e01556..eab2746dea985427c49e487e7a1fbbfcae773086 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes classes.algebra kernel namespaces make words
-sequences quotations arrays kernel.private assocs combinators ;
+USING: classes classes.algebra classes.algebra.private kernel
+namespaces make words sequences quotations arrays kernel.private
+assocs combinators ;
 IN: classes.predicate
 
 PREDICATE: predicate-class < class
index 0db49cefa05c8eed35fccc35f6b2954ed7d7137b..e1caf4f46b67270d9e6eb3f3410c3210247312d4 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2009 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes classes.algebra classes.predicate kernel
-sequences words ;
+USING: classes classes.algebra classes.algebra.private
+classes.predicate kernel sequences words ;
 IN: classes.singleton
 
 : singleton-predicate-quot ( class -- quot ) [ eq? ] curry ;
index 5ab83aa015f9b1012fb5969ec27182b8003d7435..355514754295321047b8dfd8655c5e04b8949f61 100644 (file)
@@ -110,7 +110,7 @@ TUPLE: yo-momma ;
     [ t ] [ \ yo-momma class? ] unit-test
     [ ] [ \ yo-momma forget ] unit-test
     [ ] [ \ <yo-momma> forget ] unit-test
-    [ f ] [ \ yo-momma update-map get values memq? ] unit-test
+    [ f ] [ \ yo-momma update-map get values member-eq? ] unit-test
 ] with-compilation-unit
 
 TUPLE: loc-recording ;
index ccb4e30c31f4a5ecfb5188e60dd8d44109fbdac0..d5c8b4dcffd8f2566a2823e59e492d1626d3df7d 100755 (executable)
@@ -3,8 +3,9 @@
 USING: arrays definitions hashtables kernel kernel.private math
 namespaces make sequences sequences.private strings vectors
 words quotations memory combinators generic classes
-classes.algebra classes.builtin classes.private slots.private
-slots math.private accessors assocs effects ;
+classes.algebra classes.algebra.private classes.builtin
+classes.private slots.private slots math.private accessors
+assocs effects ;
 IN: classes.tuple
 
 PREDICATE: tuple-class < class
@@ -118,7 +119,7 @@ ERROR: bad-superclass class ;
     } case define-predicate ;
 
 : class-size ( class -- n )
-    superclasses [ "slots" word-prop length ] sigma ;
+    superclasses [ "slots" word-prop length ] map-sum ;
 
 : (instance-check-quot) ( class -- quot )
     [
index e0e86e40c0008582c8012d94be1cbe695a8557df..4615d316ac513d81ae9356ce611c313563d5a38b 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words sequences kernel assocs combinators classes
-classes.algebra namespaces arrays math quotations ;
+classes.algebra classes.algebra.private namespaces arrays math
+quotations ;
 IN: classes.union
 
 PREDICATE: union-class < class
index 4701476d2ac4951b62639987732d7ab6cb4b5663..2e9440a87430094e0dca2f6fb20a98df4dacaadb 100755 (executable)
@@ -4,29 +4,8 @@ math assocs sequences sequences.private combinators.private
 effects words ;
 IN: combinators
 
-ARTICLE: "cleave-shuffle-equivalence" "Expressing shuffle words with cleave combinators"
-"Cleave combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to cleave combinators are discussed in the documentation for " { $link bi } ", " { $link 2bi } ", " { $link 3bi } ", " { $link tri } ", " { $link 2tri } " and " { $link 3tri } "."
-$nl
-"Certain shuffle words can also be expressed in terms of the cleave combinators. Internalizing such identities can help with understanding and writing code using cleave combinators:"
-{ $code
-    ": keep  [ ] bi ;"
-    ": 2keep [ ] 2bi ;"
-    ": 3keep [ ] 3bi ;"
-    ""
-    ": dup   [ ] [ ] bi ;"
-    ": 2dup  [ ] [ ] 2bi ;"
-    ": 3dup  [ ] [ ] 3bi ;"
-    ""
-    ": tuck  [ nip ] [ ] 2bi ;"
-    ": swap  [ nip ] [ drop ] 2bi ;"
-    ""
-    ": over  [ ] [ drop ] 2bi ;"
-    ": pick  [ ] [ 2drop ] 3bi ;"
-    ": 2over [ ] [ drop ] 3bi ;"
-} ;
-
 ARTICLE: "cleave-combinators" "Cleave combinators"
-"The cleave combinators apply multiple quotations to a single value."
+"The cleave combinators apply multiple quotations to a single value or set of values."
 $nl
 "Two quotations:"
 { $subsections
@@ -46,54 +25,21 @@ $nl
     2cleave
     3cleave
 }
-$nl
-"Technically, the cleave combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on the top of the stack can be written in one of two ways:"
+"Cleave combinators provide a more readable alternative to repeated applications of the " { $link keep } " combinators. The following example using " { $link keep } ":"
 { $code
-    "! First alternative; uses keep"
     "[ 1 + ] keep"
     "[ 1 - ] keep"
     "2 *"
-    "! Second alternative: uses tri"
+}
+"can be more clearly written using " { $link tri } ":"
+{ $code
     "[ 1 + ]"
     "[ 1 - ]"
     "[ 2 * ] tri"
-}
-"The latter is more aesthetically pleasing than the former."
-$nl
-{ $subsections "cleave-shuffle-equivalence" } ;
-
-ARTICLE: "spread-shuffle-equivalence" "Expressing shuffle words with spread combinators"
-"Spread combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to spread combinators are discussed in the documentation for " { $link bi* } ", " { $link 2bi* } ", " { $link tri* } ", and " { $link 2tri* } "."
-$nl
-"Certain shuffle words can also be expressed in terms of the spread combinators. Internalizing such identities can help with understanding and writing code using spread combinators:"
-{ $code
-    ": dip   [ ] bi* ;"
-    ": 2dip  [ ] [ ] tri* ;"
-    ""
-    ": nip   [ drop ] [ ] bi* ;"
-    ": 2nip  [ drop ] [ drop ] [ ] tri* ;"
-    ""
-    ": rot"
-    "    [ [ drop ] [      ] [ drop ] tri* ]"
-    "    [ [ drop ] [ drop ] [      ] tri* ]"
-    "    [ [      ] [ drop ] [ drop ] tri* ]"
-    "    3tri ;"
-    ""
-    ": -rot"
-    "    [ [ drop ] [ drop ] [      ] tri* ]"
-    "    [ [      ] [ drop ] [ drop ] tri* ]"
-    "    [ [ drop ] [      ] [ drop ] tri* ]"
-    "    3tri ;"
-    ""
-    ": spin"
-    "    [ [ drop ] [ drop ] [      ] tri* ]"
-    "    [ [ drop ] [      ] [ drop ] tri* ]"
-    "    [ [      ] [ drop ] [ drop ] tri* ]"
-    "    3tri ;"
 } ;
 
 ARTICLE: "spread-combinators" "Spread combinators"
-"The spread combinators apply multiple quotations to multiple values. In this case, " { $snippet "*" } " suffix signify spreading."
+"The spread combinators apply multiple quotations to multiple values. The asterisk (" { $snippet "*" } ") suffixed to these words' names signifies that they are spread combinators."
 $nl
 "Two quotations:"
 { $subsections bi* 2bi* }
@@ -101,33 +47,31 @@ $nl
 { $subsections tri* 2tri* }
 "An array of quotations:"
 { $subsections spread }
-"Technically, the spread combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on three related values can be written in one of two ways:"
+"Spread combinators provide a more readable alternative to repeated applications of the " { $link dip } " combinators. The following example using " { $link dip } ":"
 { $code
-    "! First alternative; uses dip"
     "[ [ 1 + ] dip 1 - ] dip 2 *"
-    "! Second alternative: uses tri*"
+}
+"can be more clearly written using " { $link tri* } ":"
+{ $code
     "[ 1 + ] [ 1 - ] [ 2 * ] tri*"
 }
-"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "."
-$nl
-{ $subsections "spread-shuffle-equivalence" } ;
+"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "." ;
 
 ARTICLE: "apply-combinators" "Apply combinators"
-"The apply combinators apply a single quotation to multiple values. The " { $snippet "@" } " suffix signifies application."
+"The apply combinators apply a single quotation to multiple values. The asterisk (" { $snippet "*" } ") suffixed to these words' names signifies that they are apply combinators."
 $nl
 "Two quotations:"
 { $subsections bi@ 2bi@ }
 "Three quotations:"
 { $subsections tri@ 2tri@ }
-"A pair of utility words built from " { $link bi@ } ":"
-{ $subsections both? either? } ;
+"A pair of condition words built from " { $link bi@ } " to test two values:"
+{ $subsections both? either? }
+"All of the apply combinators are equivalent to using the corresponding " { $link "spread-combinators" } " with the same quotation supplied for every value." ;
 
-ARTICLE: "retainstack-combinators" "Retain stack combinators"
-"Sometimes an additional storage area is needed to hold objects. The " { $emphasis "retain stack" } " is an auxilliary stack for this purpose. Objects can be moved between the data and retain stacks using a set of combinators."
-$nl
-"The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:"
+ARTICLE: "dip-keep-combinators" "Preserving combinators"
+"Sometimes it is necessary to temporarily hide values on the datastack. The " { $snippet "dip" } " combinators invoke the quotation at the top of the stack, hiding some number of values underneath:"
 { $subsections dip 2dip 3dip 4dip }
-"The keep combinators invoke a quotation which takes a number of values off the stack, and then they restore those values:"
+"The " { $snippet "keep" } " combinators invoke a quotation and restore some number of values to the top of the stack when it completes:"
 { $subsections keep 2keep 3keep } ;
 
 ARTICLE: "curried-dataflow" "Curried dataflow combinators"
@@ -237,14 +181,14 @@ ARTICLE: "conditionals" "Conditional combinators"
 { $see-also "booleans" "bitwise-arithmetic" both? either? } ;
 
 ARTICLE: "dataflow-combinators" "Data flow combinators"
-"Data flow combinators pass values between quotations:"
+"Data flow combinators express common dataflow patterns such as performing a operation while preserving its inputs, applying multiple operations to a single value, applying a set of operations to a set of values, or applying a single operation to multiple values."
 { $subsections
-    "retainstack-combinators"
+    "dip-keep-combinators"
     "cleave-combinators"
     "spread-combinators"
     "apply-combinators"
 }
-{ $see-also "curried-dataflow" } ;
+"More intricate data flow can be constructed by composing " { $link "curried-dataflow" } "." ;
 
 ARTICLE: "combinators-quot" "Quotation construction utilities"
 "Some words for creating quotations which can be useful for implementing method combinations and compiler transforms:"
@@ -255,17 +199,17 @@ ARTICLE: "call-unsafe" "Unsafe combinators"
 { $subsections call-effect-unsafe execute-effect-unsafe } ;
 
 ARTICLE: "call" "Fundamental combinators"
-"The most basic combinators are those that take either a quotation or word, and invoke it immediately."
-$nl
-"There are two sets of combinators; they differ in whether or not the stack effect of the expected code is declared."
+"The most basic combinators are those that take either a quotation or word, and invoke it immediately. There are two sets of these fundamental combinators. They differ in whether the compiler is expected to determine the stack effect of the expression at compile time or the stack effect is declared and verified at run time."
 $nl
-"The simplest combinators do not take an effect declaration. The compiler checks the stack effect at compile time, rejecting the program if this cannot be done:"
+{ $heading "Compile-time checked combinators" }
+"With these combinators, the compiler attempts to determine the stack effect of the expression at compile time, rejecting the program if the effect cannot be determined. See " { $link "inference-combinators" } "."
 { $subsections call execute }
-"The second set of combinators takes an effect declaration. Note that the opening parenthesis is actually part of the word name; these are parsing words, and they read a stack effect until the corresponding closing parenthesis. The stack effect of the quotation or word is then checked at runtime:"
+{ $heading "Run-time checked combinators" }
+"With these combinators, the stack effect of the expression is checked at run time."
 { $subsections POSTPONE: call( POSTPONE: execute( }
-"The above are syntax sugar. The underlying words are a bit more verbose but allow non-constant effects to be passed in:"
+"Note that the opening parenthesis is actually part of the word name for " { $snippet "call(" } " and " { $snippet "execute(" } "; they are parsing words, and they read a stack effect until the corresponding closing parenthesis. The underlying words are a bit more verbose, but they can be given non-constant stack effects:"
 { $subsections call-effect execute-effect }
-"The combinator variants that do not take an effect declaration can only be used if the compiler is able to infer the stack effect by other means. See " { $link "inference-combinators" } "."
+{ $heading "Unchecked combinators" }
 { $subsections "call-unsafe" }
 { $see-also "effects" "inference" } ;
 
@@ -344,7 +288,7 @@ HELP: spread
 { $values { "objs..." "objects" } { "seq" "a sequence of quotations with stack effect " { $snippet "( x -- ... )" } } }
 { $description "Applies each quotation to the object in turn." }
 { $examples
-    "The " { $link bi* } " combinator takes two values and two quotations; the " { $link tri* } " combinator takes three values and three quotations. The " { $link spread } " combinator takes " { $snippet "n" } " values and " { $snippet "n" } " quotations, where " { $snippet "n" } " is the length of the input sequence, and is essentially equivalent to series of retain stack manipulations:"
+    "The " { $link bi* } " combinator takes two values and two quotations; the " { $link tri* } " combinator takes three values and three quotations. The " { $link spread } " combinator takes " { $snippet "n" } " values and " { $snippet "n" } " quotations, where " { $snippet "n" } " is the length of the input sequence, and is essentially equivalent to a nested series of " { $link dip } "s:"
     { $code
         "! Equivalent"
         "{ [ p ] [ q ] [ r ] [ s ] } spread"
@@ -438,7 +382,7 @@ $nl
 { $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
-{ $values { "assoc" "a sequence of pairs of quotations" } { "default" quotation } { "quot" quotation } }
+{ $values { "default" quotation } { "assoc" "a sequence of pairs of quotations" } { "quot" quotation } }
 { $description "Creates a quotation that when called, has the same effect as applying " { $link case } " to " { $snippet "assoc" } "."
 $nl
 "This word uses three strategies:"
index 8dce12f4114b5042df7ec93aa059cc3de0b0b5fb..eccc292f26b94155a9b89b87d9b31ce7efa5b2fe 100644 (file)
@@ -5,16 +5,9 @@ IN: compiler.units.tests
 [ [ [ ] define-temp ] with-compilation-unit ] must-infer
 [ [ [ ] define-temp ] with-nested-compilation-unit ] must-infer
 
-[ flushed-dependency ] [ f flushed-dependency strongest-dependency ] unit-test
-[ flushed-dependency ] [ flushed-dependency f strongest-dependency ] unit-test
-[ inlined-dependency ] [ flushed-dependency inlined-dependency strongest-dependency ] unit-test
-[ inlined-dependency ] [ called-dependency inlined-dependency strongest-dependency ] unit-test
-[ flushed-dependency ] [ called-dependency flushed-dependency strongest-dependency ] unit-test
-[ called-dependency ] [ called-dependency f strongest-dependency ] unit-test
-
 ! Non-optimizing compiler bugs
 [ 1 1 ] [
-    "A" "B" <word> [ [ [ 1 ] dip ] 2array 1array modify-code-heap ] keep
+    "A" <uninterned-word> [ [ [ 1 ] dip ] 2array 1array modify-code-heap ] keep
     1 swap execute
 ] unit-test
 
index ac1c9627acf8cf245ecafa5673e8df7c293c335e..bc372d8d90c9df66b873e7b4a5d7e3217dfa6dec 100644 (file)
@@ -3,7 +3,8 @@
 USING: accessors arrays kernel continuations assocs namespaces
 sequences words vocabs definitions hashtables init sets
 math math.order classes classes.algebra classes.tuple
-classes.tuple.private generic source-files.errors ;
+classes.tuple.private generic source-files.errors
+kernel.private ;
 IN: compiler.units
 
 SYMBOL: old-definitions
@@ -15,12 +16,16 @@ TUPLE: redefine-error def ;
     \ redefine-error boa
     { { "Continue" t } } throw-restarts drop ;
 
+<PRIVATE
+
 : add-once ( key assoc -- )
     2dup key? [ over redefine-error ] when conjoin ;
 
 : (remember-definition) ( definition loc assoc -- )
     [ over set-where ] dip add-once ;
 
+PRIVATE>
+
 : remember-definition ( definition loc -- )
     new-definitions get first (remember-definition) ;
 
@@ -40,8 +45,21 @@ SYMBOL: compiler-impl
 
 HOOK: recompile compiler-impl ( words -- alist )
 
+HOOK: to-recompile compiler-impl ( -- words )
+
+HOOK: process-forgotten-words compiler-impl ( words -- )
+
+: compile ( words -- ) recompile modify-code-heap ;
+
 ! Non-optimizing compiler
-M: f recompile [ dup def>> ] { } map>assoc ;
+M: f recompile
+    [ dup def>> ] { } map>assoc ;
+
+M: f to-recompile
+    changed-definitions get [ drop word? ] assoc-filter
+    changed-generics get assoc-union keys ;
+
+M: f process-forgotten-words drop ;
 
 : without-optimizer ( quot -- )
     [ f compiler-impl ] dip with-variable ; inline
@@ -50,8 +68,12 @@ M: f recompile [ dup def>> ] { } map>assoc ;
 ! during stage1 bootstrap, it would just waste time.
 SINGLETON: dummy-compiler
 
+M: dummy-compiler to-recompile f ;
+
 M: dummy-compiler recompile drop { } ;
 
+M: dummy-compiler process-forgotten-words drop ;
+
 : <definitions> ( -- pair ) { H{ } H{ } } [ clone ] map ;
 
 SYMBOL: definition-observers
@@ -69,12 +91,23 @@ GENERIC: definitions-changed ( assoc obj -- )
     definition-observers get push ;
 
 : remove-definition-observer ( obj -- )
-    definition-observers get delq ;
+    definition-observers get remove-eq! drop ;
 
 : notify-definition-observers ( assoc -- )
     definition-observers get
     [ definitions-changed ] with each ;
 
+! Incremented each time stack effects potentially changed, used
+! by compiler.tree.propagation.call-effect for call( and execute(
+! inline caching
+: effect-counter ( -- n ) 46 getenv ; inline
+
+GENERIC: bump-effect-counter* ( defspec -- ? )
+
+M: object bump-effect-counter* drop f ;
+
+<PRIVATE
+
 : changed-vocabs ( assoc -- vocabs )
     [ drop word? ] assoc-filter
     [ drop vocabulary>> dup [ vocab ] when dup ] assoc-map ;
@@ -87,72 +120,34 @@ GENERIC: definitions-changed ( assoc obj -- )
     dup changed-definitions get update
     dup dup changed-vocabs update ;
 
-: compile ( words -- ) recompile modify-code-heap ;
-
-: index>= ( obj1 obj2 seq -- ? )
-    [ index ] curry bi@ >= ;
-
-: dependency>= ( how1 how2 -- ? )
-    { called-dependency flushed-dependency inlined-dependency }
-    index>= ;
-
-: strongest-dependency ( how1 how2 -- how )
-    [ called-dependency or ] bi@ [ dependency>= ] most ;
-
-: weakest-dependency ( how1 how2 -- how )
-    [ inlined-dependency or ] bi@ [ dependency>= not ] most ;
-
-: compiled-usage ( word -- assoc )
-    compiled-crossref get at ;
-
-: (compiled-usages) ( word -- assoc )
-    #! If the word is not flushable anymore, we have to recompile
-    #! all words which flushable away a call (presumably when the
-    #! word was still flushable). If the word is flushable, we
-    #! don't have to recompile words that folded this away.
-    [ compiled-usage ]
-    [ "flushable" word-prop inlined-dependency flushed-dependency ? ] bi
-    [ dependency>= nip ] curry assoc-filter ;
-
-: compiled-usages ( assoc -- assocs )
-    [ drop word? ] assoc-filter
-    [ [ drop (compiled-usages) ] { } assoc>map ] keep suffix ;
-
-: compiled-generic-usage ( word -- assoc )
-    compiled-generic-crossref get at ;
-
-: (compiled-generic-usages) ( generic class -- assoc )
-    [ compiled-generic-usage ] dip
-    [
-        2dup [ valid-class? ] both?
-        [ classes-intersect? ] [ 2drop f ] if nip
-    ] curry assoc-filter ;
-
-: compiled-generic-usages ( assoc -- assocs )
-    [ (compiled-generic-usages) ] { } assoc>map ;
-
-: words-only ( assoc -- assoc' )
-    [ drop word? ] assoc-filter ;
-
-: to-recompile ( -- seq )
-    changed-definitions get compiled-usages
-    changed-generics get compiled-generic-usages
-    append assoc-combine keys ;
-
 : process-forgotten-definitions ( -- )
     forgotten-definitions get keys
-    [ [ word? ] filter [ delete-compiled-xref ] each ]
+    [ [ word? ] filter process-forgotten-words ]
     [ [ delete-definition-errors ] each ]
     bi ;
 
+: bump-effect-counter? ( -- ? )
+    changed-effects get new-words get assoc-diff assoc-empty? not
+    changed-definitions get [ drop bump-effect-counter* ] assoc-any?
+    or ;
+
+: bump-effect-counter ( -- )
+    bump-effect-counter? [ 46 getenv 0 or 1 + 46 setenv ] when ;
+
+: notify-observers ( -- )
+    updated-definitions dup assoc-empty?
+    [ drop ] [ notify-definition-observers notify-error-observers ] if ;
+
 : finish-compilation-unit ( -- )
     remake-generics
     to-recompile recompile
     update-tuples
     process-forgotten-definitions
     modify-code-heap
-    updated-definitions dup assoc-empty?
-    [ drop ] [ notify-definition-observers notify-error-observers ] if ;
+    bump-effect-counter
+    notify-observers ;
+
+PRIVATE>
 
 : with-nested-compilation-unit ( quot -- )
     [
@@ -161,6 +156,7 @@ GENERIC: definitions-changed ( assoc obj -- )
         H{ } clone changed-effects set
         H{ } clone outdated-generics set
         H{ } clone outdated-tuples set
+        H{ } clone new-words set
         H{ } clone new-classes set
         [ finish-compilation-unit ] [ ] cleanup
     ] with-scope ; inline
@@ -173,6 +169,7 @@ GENERIC: definitions-changed ( assoc obj -- )
         H{ } clone outdated-generics set
         H{ } clone forgotten-definitions set
         H{ } clone outdated-tuples set
+        H{ } clone new-words set
         H{ } clone new-classes set
         <definitions> new-definitions set
         <definitions> old-definitions set
index 5fb5a38af2e6de6e75a5886863de22a8ffd93cc3..84da26a0821a46e6c36b67769a51b53da492ce00 100644 (file)
@@ -122,7 +122,7 @@ HELP: continuation
 { $description "Reifies the current continuation from the point immediately after which the caller returns." } ;
 
 HELP: >continuation<
-{ $values { "continuation" continuation } { "data" vector } { "retain" vector } { "call" vector } { "name" vector } { "catch" vector } }
+{ $values { "continuation" continuation } { "data" vector } { "call" vector } { "retain" vector } { "name" vector } { "catch" vector } }
 { $description "Takes a continuation apart into its constituents." } ;
 
 HELP: ifcc
@@ -271,4 +271,4 @@ HELP: with-return
 HELP: restart
 { $values { "restart" restart } }
 { $description "Invokes a restart." }
-{ $class-description "The class of restarts." } ;
\ No newline at end of file
+{ $class-description "The class of restarts." } ;
index f40769ae395ecd4a34becc9d986792dcd1ec207b..0d207d9cc670dea1c1313c0a3c99a5f730e49f7e 100644 (file)
@@ -20,7 +20,7 @@ $nl
 { $see-also "see" } ;
 
 ARTICLE: "definition-checking" "Definition sanity checking"
-"When a source file is reloaded, the parser compares the previous list of definitions with the current list; any definitions which are no longer present in the file are removed by a call to " { $link forget } ". A warning message is printed if any other definitions still depend on the removed definitions."
+"When a source file is reloaded, the parser compares the previous list of definitions with the current list; any definitions which are no longer present in the file are removed by a call to " { $link forget } "."
 $nl
 "The parser also catches forward references when reloading source files. This is best illustrated with an example. Suppose we load a source file " { $snippet "a.factor" } ":"
 { $code
index e2fb4b8161395867af8767dbb9f274e15e5aeb5e..597b195c36036475e6f8f52e43536b7eeda504c7 100644 (file)
@@ -7,15 +7,13 @@ MIXIN: definition
 
 ERROR: no-compilation-unit definition ;
 
-SYMBOLS: inlined-dependency flushed-dependency called-dependency ;
-
 : set-in-unit ( value key assoc -- )
     [ set-at ] [ no-compilation-unit ] if* ;
 
 SYMBOL: changed-definitions
 
 : changed-definition ( defspec -- )
-    inlined-dependency swap changed-definitions get set-in-unit ;
+    dup changed-definitions get set-in-unit ;
 
 SYMBOL: changed-effects
 
@@ -23,8 +21,16 @@ SYMBOL: changed-generics
 
 SYMBOL: outdated-generics
 
+SYMBOL: new-words
+
 SYMBOL: new-classes
 
+: new-word ( word -- )
+    dup new-words get set-in-unit ;
+
+: new-word? ( word -- ? )
+    new-words get key? ;
+
 : new-class ( word -- )
     dup new-classes get set-in-unit ;
 
index 1f640beddb20daeac46434a7b818a25708036f46..577da7c4eb778ea2f566ebf6c91a496284c6161d 100644 (file)
@@ -26,15 +26,11 @@ SLOT: continuation
 PRIVATE>
 
 TUPLE: disposable < identity-tuple
-{ id integer }
 { disposed boolean }
 continuation ;
 
-M: disposable hashcode* nip id>> ;
-
 : new-disposable ( class -- disposable )
-    new \ disposable counter >>id
-    dup register-disposable ; inline
+    new dup register-disposable ; inline
 
 GENERIC: dispose* ( disposable -- )
 
index da27dc28b459763fa3be83ec06e3174b7d906db8..a77ea34c30c8d9230e5ca8de30b881499cff9168 100644 (file)
@@ -25,7 +25,7 @@ ERROR: bad-effect ;
 : parse-effect-tokens ( end -- tokens )
     [ parse-effect-token dup ] curry [ ] produce nip ;
 
-ERROR: stack-effect-omits-dashes effect ;
+ERROR: stack-effect-omits-dashes tokens ;
 
 : parse-effect ( end -- effect )
     parse-effect-tokens { "--" } split1 dup
@@ -35,4 +35,4 @@ ERROR: stack-effect-omits-dashes effect ;
     "(" expect ")" parse-effect ;
 
 : parse-call( ( accum word -- accum )
-    [ ")" parse-effect ] dip 2array over push-all ;
+    [ ")" parse-effect ] dip 2array append! ;
index 0f80aac2f32993479225f09386442d75da2bbbc9..dea523538eec6384d9b51179269d4c2e22d3581b 100644 (file)
@@ -124,7 +124,7 @@ HELP: make-generic
 $low-level-note ;
 
 HELP: define-generic
-{ $values { "word" word } { "effect" effect } { "combination" "a method combination" } }
+{ $values { "word" word } { "combination" "a method combination" } { "effect" effect } }
 { $description "Defines a generic word. A method combination is an object which responds to the " { $link perform-combination } " generic word." }
 { $contract "The method combination quotation is called each time the generic word has to be updated (for example, when a method is added), and thus must be side-effect free." } ;
 
index f5c2018e60ef6f64fa22efc612b04e3a61a21c64..5a98173a89fc43858b171a7627794c8757725098 100755 (executable)
@@ -3,7 +3,8 @@ classes.tuple classes.union compiler.units continuations
 definitions eval generic generic.math generic.standard
 hashtables io io.streams.string kernel layouts math math.order
 namespaces parser prettyprint quotations sequences sorting
-strings tools.test vectors words generic.single ;
+strings tools.test vectors words generic.single
+compiler.crossref ;
 IN: generic.tests
 
 GENERIC: foobar ( x -- y )
index 9e773fe700c3eae88017b082e1e9110fb08329c0..d0bc4e1600941e65a56bd7c807af700af76f5d26 100644 (file)
@@ -63,19 +63,18 @@ TUPLE: predicate-engine class methods ;
 
 C: <predicate-engine> predicate-engine
 
-: push-method ( method specializer atomic assoc -- )
+: push-method ( method class atomic assoc -- )
     dupd [
         [ ] [ H{ } clone <predicate-engine> ] ?if
         [ methods>> set-at ] keep
     ] change-at ;
 
-: flatten-method ( class method assoc -- )
-    [ [ flatten-class keys ] keep ] 2dip [
-        [ spin ] dip push-method
-    ] 3curry each ;
+: flatten-method ( method class assoc -- )
+    over flatten-class keys
+    [ swap push-method ] with with with each ;
 
 : flatten-methods ( assoc -- assoc' )
-    H{ } clone [ [ flatten-method ] curry assoc-each ] keep ;
+    H{ } clone [ [ swapd flatten-method ] curry assoc-each ] keep ;
 
 ! 2. Convert methods
 : split-methods ( assoc class -- first second )
@@ -112,15 +111,6 @@ TUPLE: tuple-dispatch-engine echelons ;
     tuple bootstrap-word
     \ <tuple-dispatch-engine> convert-methods ;
 
-! 2.2 Convert hi-tag methods
-TUPLE: hi-tag-dispatch-engine methods ;
-
-C: <hi-tag-dispatch-engine> hi-tag-dispatch-engine
-
-: convert-hi-tag-methods ( assoc -- assoc' )
-    \ hi-tag bootstrap-word
-    \ <hi-tag-dispatch-engine> convert-methods ;
-
 ! 3 Tag methods
 TUPLE: tag-dispatch-engine methods ;
 
@@ -129,7 +119,6 @@ C: <tag-dispatch-engine> tag-dispatch-engine
 : <engine> ( assoc -- engine )
     flatten-methods
     convert-tuple-methods
-    convert-hi-tag-methods
     <tag-dispatch-engine> ;
 
 ! ! ! Compile engine ! ! !
@@ -144,23 +133,12 @@ GENERIC: compile-engine ( engine -- obj )
 : direct-dispatch-table ( assoc n -- table )
     default get <array> [ <enum> swap update ] keep ;
 
-: lo-tag-number ( class -- n )
-    "type" word-prop dup num-tags get iota member?
-    [ drop object tag-number ] unless ;
+: tag-number ( class -- n ) "type" word-prop ;
 
 M: tag-dispatch-engine compile-engine
     methods>> compile-engines*
-    [ [ lo-tag-number ] dip ] assoc-map
-    num-tags get direct-dispatch-table ;
-
-: num-hi-tags ( -- n ) num-types get num-tags get - ;
-
-: hi-tag-number ( class -- n ) "type" word-prop ;
-
-M: hi-tag-dispatch-engine compile-engine
-    methods>> compile-engines*
-    [ [ hi-tag-number num-tags get - ] dip ] assoc-map
-    num-hi-tags direct-dispatch-table ;
+    [ [ tag-number ] dip ] assoc-map
+    num-types get direct-dispatch-table ;
 
 : build-fast-hash ( methods -- buckets )
     >alist V{ } clone [ hashcode 1array ] distribute-buckets
index 68a8de3d43072c0913164aa78de6912da4a4490d..3d5f16d7f14bf34e03eb33d5b10c22707a3e180c 100644 (file)
@@ -23,7 +23,7 @@ GENERIC: contract ( len seq -- )
 M: growable contract ( len seq -- )
     [ length ] keep
     [ [ 0 ] 2dip set-nth-unsafe ] curry
-    (each-integer) ;
+    (each-integer) ; inline
 
 : growable-check ( n seq -- n seq )
     over 0 < [ bounds-error ] when ; inline
@@ -66,4 +66,6 @@ M: growable shorten ( n seq -- )
         2dup (>>length)
     ] when 2drop ; inline
 
+M: growable new-resizable new-sequence 0 over set-length ; inline
+
 INSTANCE: growable sequence
index 37d6de0a76d37e8db1f7ec8fcc2185d714eccbfb..f2394583551aacc8a68442fd77e528240cf503f5 100755 (executable)
@@ -46,7 +46,8 @@ $nl
 $nl
 "In certain advanced applications, this cannot be avoided and the best design involves mutating hashtable keys. In this case, a custom " { $link hashcode* } " method must be defined which only depends on immutable slots."
 $nl
-"In addition, the " { $link equal? } " and " { $link hashcode* } " methods must be congruent, and if one is defined the other should be defined also. This is documented in detail in the documentation for these respective words." ;
+"In addition, the " { $link equal? } " and " { $link hashcode* } " methods must be congruent, and if one is defined the other should be defined also. This is documented in detail in the documentation for these respective words."
+{ $subsections hashcode hashcode* identity-hashcode } ;
 
 ARTICLE: "hashtables.utilities" "Hashtable utilities"
 "Utility words to create a new hashtable from a single key/value pair:"
index 54e58c0282729653e990cf8052d7fab3c3bcd66f..05cc27f5e8bfc0e48e61ba4336de65717e7cd81f 100644 (file)
@@ -155,11 +155,6 @@ H{ } "x" set
     ] { } make
 ] unit-test
 
-[ { "one" "two" 3 } ] [
-    { 1 2 3 } clone dup
-    H{ { 1 "one" } { 2 "two" } } substitute-here
-] unit-test
-
 [ { "one" "two" 3 } ] [
     { 1 2 3 } H{ { 1 "one" } { 2 "two" } } substitute
 ] unit-test
index 8547f53a0efb7c2a7e186dc1ab98b508a26e2063..e31ed925d15e55672974c115833368181f52c73f 100644 (file)
@@ -101,7 +101,7 @@ M: hashtable at* ( key hash -- value ? )
     key@ [ 3 fixnum+fast slot t ] [ 2drop f f ] if ;
 
 M: hashtable clear-assoc ( hash -- )
-    [ init-hash ] [ array>> [ drop ((empty)) ] change-each ] bi ;
+    [ init-hash ] [ array>> [ drop ((empty)) ] map! drop ] bi ;
 
 M: hashtable delete-at ( key hash -- )
     [ nip ] [ key@ ] 2bi [
@@ -115,9 +115,7 @@ M: hashtable assoc-size ( hash -- n )
     [ count>> ] [ deleted>> ] bi - ; inline
 
 : rehash ( hash -- )
-    dup >alist [
-    dup clear-assoc
-    ] dip (rehash) ;
+    dup >alist [ dup clear-assoc ] dip (rehash) ;
 
 M: hashtable set-at ( value key hash -- )
     dup ?grow-hash
index f5467daea6bc1b053584319d1bdbd98ed88051bc..1275248613a1dd0b43ee6a1dbb7a27a96ecf4517 100644 (file)
@@ -11,7 +11,7 @@ IN: io.binary
 : nth-byte ( x n -- b ) -8 * shift mask-byte ; inline
 
 : >le ( x n -- byte-array ) iota [ nth-byte ] with B{ } map-as ;
-: >be ( x n -- byte-array ) >le dup reverse-here ;
+: >be ( x n -- byte-array ) >le reverse! ;
 
 : d>w/w ( d -- w1 w2 )
     [ HEX: ffffffff bitand ]
index 6387e47dfc3bb97d4db856a2ceceb07a6110be6e..23d974254de1255bb82d8f6cc0a38e6b83e0a2c6 100644 (file)
@@ -1,7 +1,8 @@
 USING: arrays debugger.threads destructors io io.directories
-io.encodings.8-bit io.encodings.ascii io.encodings.binary
+io.encodings.ascii io.encodings.binary
 io.files io.files.private io.files.temp io.files.unique kernel
-make math sequences system threads tools.test generic.single ;
+make math sequences system threads tools.test generic.single
+io.encodings.8-bit.latin1 ;
 IN: io.files.tests
 
 [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
@@ -158,4 +159,4 @@ USE: debugger.threads
 [ ] [
     "closing-twice" unique-file ascii <file-writer>
     [ dispose ] [ dispose ] bi
-] unit-test
\ No newline at end of file
+] unit-test
index e240467c073a3efd968f09326a4fac622111951b..ca36bc3b364a0dea34a540e641390f8a152ccf75 100644 (file)
@@ -87,42 +87,51 @@ SYMBOL: error-stream
 
 : bl ( -- ) " " write ;
 
-<PRIVATE
-
 : each-morsel ( handler: ( data -- ) reader: ( -- data ) -- )
     [ dup ] compose swap while drop ; inline
 
-: stream-element-exemplar ( type -- exemplar )
+<PRIVATE
+
+: (stream-element-exemplar) ( type -- exemplar )
     {
         { +byte+ [ B{ } ] }
         { +character+ [ "" ] }
-    } case ;
+    } case ; inline
+
+: stream-element-exemplar ( stream -- exemplar )
+    stream-element-type (stream-element-exemplar) ;
 
 : element-exemplar ( -- exemplar )
-    input-stream get
-    stream-element-type
-    stream-element-exemplar ;
+    input-stream get stream-element-exemplar ; inline
 
 PRIVATE>
 
+: each-stream-line ( stream quot -- )
+    swap [ stream-readln ] curry each-morsel ; inline
+
 : each-line ( quot -- )
-    [ readln ] each-morsel ; inline
+    input-stream get swap each-stream-line ; inline
+
+: stream-lines ( stream -- seq )
+    [ [ ] accumulator [ each-stream-line ] dip { } like ] with-disposal ;
 
 : lines ( -- seq )
-    [ ] accumulator [ each-line ] dip { } like ;
+    input-stream get stream-lines ; inline
 
-: stream-lines ( stream -- seq )
-    [ lines ] with-input-stream ;
+: stream-contents ( stream -- seq )
+    [
+        [ [ 65536 swap stream-read-partial dup ] curry [ ] produce nip ]
+        [ stream-element-exemplar concat-as ] bi
+    ] with-disposal ;
 
 : contents ( -- seq )
-    [ 65536 read-partial dup ] [ ] produce nip
-    element-exemplar concat-as ;
+    input-stream get stream-contents ; inline
 
-: stream-contents ( stream -- seq )
-    [ contents ] with-input-stream ;
+: each-stream-block ( stream quot: ( block -- ) -- )
+    swap [ 8192 swap stream-read-partial ] curry each-morsel ; inline
 
 : each-block ( quot: ( block -- ) -- )
-    [ 8192 read-partial ] each-morsel ; inline
+    input-stream get swap each-stream-block ; inline
 
 : stream-copy ( in out -- )
     [ [ [ write ] each-block ] with-output-stream ]
index 889f2262a82136a1d08bebcd7ea51ea13b0e4c0d..8dacef6f8c5699f0277281a0312da233f104761b 100644 (file)
@@ -1,5 +1,5 @@
-USING: help.markup help.syntax io.backend io.files io.directories strings
-sequences io.pathnames.private ;
+USING: help.markup help.syntax io.backend io.files
+io.directories strings system sequences io.pathnames.private ;
 IN: io.pathnames
 
 HELP: path-separator?
@@ -90,7 +90,7 @@ HELP: pathname
 
 HELP: normalize-path
 { $values { "path" "a pathname string" } { "path'" "a new pathname string" } }
-{ $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " or " { $snippet "voacb:" } " prefix, if present, and performs any platform-specific pathname normalization." }
+{ $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " or " { $snippet "vocab:" } " prefix, if present (see " { $link "io.pathnames.special" } "). Also converts the path into a UNC path on Windows." }
 { $notes "High-level words, such as " { $link <file-reader> } " and " { $link delete-file } " call this word for you. It only needs to be called directly when passing pathnames to C functions or external processes. This is because Factor does not use the operating system's notion of a current directory, and instead maintains its own dynamically-scoped " { $link current-directory } " variable." }
 { $notes "On Windows NT platforms, this word does prepends the Unicode path prefix." }
 { $examples
@@ -101,15 +101,15 @@ HELP: normalize-path
   }
 } ;
 
-HELP: (normalize-path)
+HELP: absolute-path
 { $values
     { "path" "a pathname string" }
     { "path'" "a pathname string" }
 }
-{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " prefix, if present." }
-{ $notes "On Windows NT platforms, this word does not prepend the Unicode path prefix." } ;
+{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " or " { $snippet "voacb:" } " prefix, if present (see " { $link "io.pathnames.special" } ")." }
+{ $notes "This word is exaclty the same as " { $link normalize-path } ", except on Windows NT platforms, where it does not prepend the Unicode path prefix. Most code should call " { $link normalize-path } " instead." } ;
 
-HELP: canonicalize-path
+HELP: resolve-symlinks
 { $values { "path" "a pathname string" } { "path'" "a new pathname string" } }
 { $description "Outputs a path where none of the path components are symlinks. This word is useful for determining the actual path on disk where a file is stored; the root of this absolute path is a mount point in the file-system." }
 { $notes "Most code should not need to call this word except in very special circumstances. One use case is finding the actual file-system on which a file is stored." } ;
@@ -128,8 +128,24 @@ HELP: home
     }
 } ;
 
+ARTICLE: "io.pathnames.special" "Special pathnames"
+"If a pathname begins with " { $snippet "resource:" } ", it is resolved relative to the directory containing the current image (see " { $link image } ")."
+$nl
+"If a pathname begins with " { $snippet "vocab:" } ", then it will be searched for in all current vocabulary roots (see " { $link "add-vocab-roots" } ")." ;
+
+ARTICLE: "io.pathnames.presentations" "Pathname presentations"
+"Pathname presentations are objects that wrap a pathname string. Clicking a pathname presentation in the UI brings up the file in one of the supported editors. See " { $link "editor" } " for more details."
+{ $subsections
+    pathname
+    <pathname>
+}
+"Literal pathname presentations:"
+{ $subsections POSTPONE: P" }
+"Many words that accept pathname strings can also work on pathname presentations." ;
+    
 ARTICLE: "io.pathnames" "Pathnames"
-"Pathnames are objects that contain a string representing the path to a file on disk. Pathnames are cross-platform; Windows accepts both forward and backward slashes as directory separators and new separators are added as a forward slash on all platforms. Clicking a pathname object in the UI brings up the file in one of the supported editors, but otherwise, pathnames and strings are interchangeable. See " { $link "editor" } " for more details." $nl
+"Pathnames are strings that refer to a file on disk. Pathname semantics are platform-specific, and Factor makes no attempt to abstract away the differences. Note that on Windows, both forward and backward slashes are accepted as directory separators."
+$nl
 "Pathname introspection:"
 { $subsections
     parent-directory
@@ -143,18 +159,9 @@ ARTICLE: "io.pathnames" "Pathnames"
     prepend-path
     append-path
 }
-"Pathname presentations:"
-{ $subsections
-    pathname
-    <pathname>
-}
-"Literal pathnames:"
-{ $subsections POSTPONE: P" }
-"Low-level words:"
-{ $subsections
-    normalize-path
-    (normalize-path)
-    canonicalize-path
-} ;
+"Normalizing pathnames:"
+{ $subsections normalize-path absolute-path resolve-symlinks }
+"Additional topics:"
+{ $subsections "io.pathnames.presentations" "io.pathnames.special" } ;
 
 ABOUT: "io.pathnames"
index 7a98a47f42ab3b1b6e424eb263237071347148dc..f23a1ac1f4f9856ea876d6b59baeae8aee8a6f76 100644 (file)
@@ -61,7 +61,7 @@ IN: io.pathnames.tests
     "." current-directory set
     ".." "resource-path" set
     [ "../core/bootstrap/stage2.factor" ]
-    [ "resource:core/bootstrap/stage2.factor" (normalize-path) ]
+    [ "resource:core/bootstrap/stage2.factor" absolute-path ]
     unit-test
 ] with-scope
 
index e8672e6771e68101d0c0fb81ca4ba87ecf546818..b307128efb2287bbd60d9a36ffa7866aac42ab9b 100644 (file)
@@ -102,8 +102,8 @@ PRIVATE>
             [ 2 head ] dip append
         ] }
         [
-            [ trim-tail-separators "/" ] dip
-            trim-head-separators 3append
+            [ trim-tail-separators ]
+            [ trim-head-separators ] bi* "/" glue
         ]
     } cond ;
 
@@ -127,38 +127,38 @@ PRIVATE>
 : path-components ( path -- seq )
     normalize-path path-separator split harvest ;
 
-HOOK: canonicalize-path os ( path -- path' )
+HOOK: resolve-symlinks os ( path -- path' )
 
-M: object canonicalize-path normalize-path ;
+M: object resolve-symlinks normalize-path ;
 
 : resource-path ( path -- newpath )
     "resource-path" get prepend-path ;
 
 GENERIC: vocab-path ( path -- newpath )
 
-GENERIC: (normalize-path) ( path -- path' )
+GENERIC: absolute-path ( path -- path' )
 
-M: string (normalize-path)
+M: string absolute-path
     "resource:" ?head [
         trim-head-separators resource-path
-        (normalize-path)
+        absolute-path
     ] [
         "vocab:" ?head [
             trim-head-separators vocab-path
-            (normalize-path)
+            absolute-path
         ] [
             current-directory get prepend-path
         ] if
     ] if ;
 
 M: object normalize-path ( path -- path' )
-    (normalize-path) ;
+    absolute-path ;
 
 TUPLE: pathname string ;
 
 C: <pathname> pathname
 
-M: pathname (normalize-path) string>> (normalize-path) ;
+M: pathname absolute-path string>> absolute-path ;
 
 M: pathname <=> [ string>> ] compare ;
 
index 1bc09429dc93e6d4caa8f8433e3a4bec2e597ea9..eeada8d0c9bbbf7a3875974a91a82069f0ecbc34 100644 (file)
@@ -27,8 +27,9 @@ HELP: <byte-writer>
 { $description "Creates an output stream writing data to a byte array using an encoding." } ;
 
 HELP: with-byte-reader
-{ $values { "encoding" "an encoding descriptor" }
-    { "quot" quotation } { "byte-array" byte-array } }
+{ $values { "byte-array" byte-array }
+    { "encoding" "an encoding descriptor" }
+    { "quot" quotation } }
 { $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream for reading from a byte array using an encoding." } ;
 
 HELP: with-byte-writer
index 6ff1a4b35c9be1e037f37c83f72aab8e15a9db69..1da30fe922c3e12e49004a6660090b5f65194c13 100755 (executable)
@@ -49,7 +49,7 @@ M: c-reader stream-read1 dup check-disposed handle>> fgetc ;
 
 : read-until-loop ( stream delim -- ch )
     over stream-read1 dup [
-        dup pick memq? [ 2nip ] [ , read-until-loop ] if
+        dup pick member-eq? [ 2nip ] [ , read-until-loop ] if
     ] [
         2nip
     ] if ;
index 036bab22135bd8c124b1b39f6584cc108a51c438..5ecbc321ce26715cbcdc97e2aa46318953165927 100644 (file)
@@ -32,7 +32,7 @@ SLOT: i
 
 : find-sep ( seps stream -- sep/f n )
     swap [ >sequence-stream< swap tail-slice ] dip
-    [ memq? ] curry find swap ; inline
+    [ member-eq? ] curry find swap ; inline
 
 : sequence-read-until ( separators stream -- seq sep/f )
     [ find-sep ] keep
index 3f1e7154484c1c040f5cb8004fb3684838843792..0e8c3368ff55a34b047adcae73c3a150f9af1b3b 100644 (file)
@@ -14,20 +14,17 @@ HELP: 3drop ( x y z -- )             $shuffle ;
 HELP: dup   ( x -- x x )             $shuffle ;
 HELP: 2dup  ( x y -- x y x y )       $shuffle ;
 HELP: 3dup  ( x y z -- x y z x y z ) $shuffle ;
-HELP: rot   ( x y z -- y z x )       $shuffle ;
-HELP: -rot  ( x y z -- z x y )       $shuffle ;
-HELP: dupd  ( x y -- x x y )         $shuffle ;
-HELP: swapd ( x y z -- y x z )       $shuffle ;
 HELP: nip   ( x y -- y )             $shuffle ;
 HELP: 2nip  ( x y z -- z )           $shuffle ;
-HELP: tuck  ( x y -- y x y )         $shuffle ;
 HELP: over  ( x y -- x y x )         $shuffle ;
 HELP: 2over                          $shuffle ;
 HELP: pick  ( x y z -- x y z x )     $shuffle ;
 HELP: swap  ( x y -- y x )           $shuffle ;
-HELP: spin                           $shuffle ;
-HELP: roll                           $shuffle ;
-HELP: -roll                          $shuffle ;
+
+HELP: rot   ( x y z -- y z x ) $complex-shuffle ;
+HELP: -rot  ( x y z -- z x y ) $complex-shuffle ;
+HELP: dupd  ( x y -- x x y )   $complex-shuffle ;
+HELP: swapd ( x y z -- y x z ) $complex-shuffle ;
 
 HELP: datastack ( -- ds )
 { $values { "ds" array } }
@@ -75,7 +72,11 @@ HELP: hashcode
 { $values { "obj" object } { "code" fixnum } }
 { $description "Computes the hashcode of an object with a default hashing depth. See " { $link hashcode* } " for the hashcode contract." } ;
 
-{ hashcode hashcode* } related-words
+HELP: identity-hashcode
+{ $values { "obj" object } { "code" fixnum } }
+{ $description "Outputs the identity hashcode of an object. The identity hashcode is not guaranteed to be unique, however it will not change during the object's lifetime." } ;
+
+{ hashcode hashcode* identity-hashcode } related-words
 
 HELP: =
 { $values { "obj1" object } { "obj2" object } { "?" "a boolean" } }
@@ -168,7 +169,7 @@ HELP: xor
 { $notes "This word implements boolean exclusive or, so applying it to integers will not yield useful results (all integers have a true value). Bitwise exclusive or is the " { $link bitxor } " word." } ;
 
 HELP: both?
-{ $values { "quot" { $quotation "( obj -- ? )" } } { "x" object } { "y" object } { "?" "a boolean" } }
+{ $values { "x" object } { "y" object } { "quot" { $quotation "( obj -- ? )" } } { "?" "a boolean" } }
 { $description "Tests if the quotation yields a true value when applied to both " { $snippet "x" } " and " { $snippet "y" } "." }
 { $examples
     { $example "USING: kernel math prettyprint ;" "3 5 [ odd? ] both? ." "t" }
@@ -176,7 +177,7 @@ HELP: both?
 } ;
 
 HELP: either?
-{ $values { "quot" { $quotation "( obj -- ? )" } } { "x" object } { "y" object } { "?" "a boolean" } }
+{ $values { "x" object } { "y" object } { "quot" { $quotation "( obj -- ? )" } } { "?" "a boolean" } }
 { $description "Tests if the quotation yields a true value when applied to either " { $snippet "x" } " or " { $snippet "y" } "." }
 { $examples
     { $example "USING: kernel math prettyprint ;" "3 6 [ odd? ] either? ." "t" }
@@ -213,18 +214,18 @@ HELP: call-clear ( quot -- )
 { $notes "Used to implement " { $link "threads" } "." } ;
 
 HELP: keep
-{ $values { "quot" { $quotation "( x -- ... )" } } { "x" object } }
+{ $values { "x" object } { "quot" { $quotation "( x -- ... )" } } }
 { $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." }
 { $examples
     { $example "USING: arrays kernel prettyprint ;" "2 \"greetings\" [ <array> ] keep 2array ." "{ { \"greetings\" \"greetings\" } \"greetings\" }" }
 } ;
 
 HELP: 2keep
-{ $values { "quot" { $quotation "( x y -- ... )" } } { "x" object } { "y" object } }
+{ $values { "x" object } { "y" object } { "quot" { $quotation "( x y -- ... )" } } }
 { $description "Call a quotation with two values on the stack, restoring the values when the quotation returns." } ;
 
 HELP: 3keep
-{ $values { "quot" { $quotation "( x y z -- ... )" } } { "x" object } { "y" object } { "z" object } }
+{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( x y z -- ... )" } } }
 { $description "Call a quotation with three values on the stack, restoring the values when the quotation returns." } ;
 
 HELP: bi
@@ -279,11 +280,6 @@ HELP: 3bi
         "[ p ] [ q ] 3bi"
         "3dup p q"
     }
-    "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x y z -- w )" } ", then the following two lines are equivalent:"
-    { $code
-        "[ p ] [ q ] 3bi"
-        "3dup p -roll q"
-    }
     "In general, the following two lines are equivalent:"
     { $code
         "[ p ] [ q ] 3bi"
@@ -657,14 +653,14 @@ HELP: declare
 
 HELP: tag ( object -- n )
 { $values { "object" object } { "n" "a tag number" } }
-{ $description "Outputs an object's tag number, between zero and one less than " { $link num-tags } ". This is implementation detail and user code should call " { $link class } " instead." } ;
+{ $description "Outputs an object's tag number, between zero and one less than " { $link num-types } ". This is implementation detail and user code should call " { $link class } " instead." } ;
 
 HELP: getenv ( n -- obj )
 { $values { "n" "a non-negative integer" } { "obj" object } }
 { $description "Reads an object from the Factor VM's environment table. User code never has to read the environment table directly; instead, use one of the callers of this word." } ;
 
 HELP: setenv ( obj n -- )
-{ $values { "n" "a non-negative integer" } { "obj" object } }
+{ $values { "obj" object } { "n" "a non-negative integer" } }
 { $description "Writes an object to the Factor VM's environment table. User code never has to write to the environment table directly; instead, use one of the callers of this word." } ;
 
 HELP: object
@@ -821,10 +817,22 @@ HELP: assert=
 { $values { "a" object } { "b" object } }
 { $description "Throws an " { $link assert } " error if " { $snippet "a" } " does not equal " { $snippet "b" } "." } ;
 
-ARTICLE: "shuffle-words" "Shuffle words"
-"Shuffle words rearrange items at the top of the data stack. They control the flow of data between words that perform actions."
+ARTICLE: "shuffle-words-complex" "Complex shuffle words"
+"These shuffle words tend to make code difficult to read and to reason about. Code that uses them should almost always be rewritten using " { $link "locals" } " or " { $link "dataflow-combinators" } "."
 $nl
-"The " { $link "cleave-combinators" } ", " { $link "spread-combinators" } " and " { $link "apply-combinators" } " are closely related to shuffle words and should be used instead where possible because they can result in clearer code; also, see the advice in " { $link "cookbook-philosophy" } "."
+"Duplicating stack elements deep in the stack:"
+{ $subsections
+    dupd
+}
+"Permuting stack elements deep in the stack:"
+{ $subsections
+    swapd
+    rot
+    -rot
+} ;
+
+ARTICLE: "shuffle-words" "Shuffle words"
+"Shuffle words rearrange items at the top of the data stack as indicated by their stack effects. They provide simple data flow control between words. More complex data flow control is available with the " { $link "dataflow-combinators" } " and with " { $link "locals" } "."
 $nl
 "Removing stack elements:"
 { $subsections
@@ -839,21 +847,17 @@ $nl
     dup
     2dup
     3dup
-    dupd
     over
     2over
     pick
-    tuck
 }
 "Permuting stack elements:"
 { $subsections
     swap
-    swapd
-    rot
-    -rot
-    spin
-    roll
-    -roll
+}
+"There are additional, more complex stack shuffling words whose use is not recommended."
+{ $subsections
+    "shuffle-words-complex"
 } ;
 
 ARTICLE: "equality" "Equality"
index c8e0fcd2a98c7e2355ca12a4ec4645ec092963a0..ded2ee970294496376f419b42a1963ab2c716426 100644 (file)
@@ -13,11 +13,11 @@ IN: kernel.tests
 [ ] [ 10000 [ [ -1 f <array> ] ignore-errors ] times ] unit-test
 
 ! Make sure we report the correct error on stack underflow
-[ clear drop ] [ { "kernel-error" 11 f f } = ] must-fail-with
+[ clear drop ] [ { "kernel-error" 10 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
-[ 3 [ { } set-retainstack ] dip ] [ { "kernel-error" 13 f f } = ] must-fail-with
+[ 3 [ { } set-retainstack ] dip ] [ { "kernel-error" 12 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
@@ -34,23 +34,20 @@ IN: kernel.tests
 [ t "no-compile" set-word-prop ] each
 >>
 
-[ overflow-d ] [ { "kernel-error" 12 f f } = ] must-fail-with
+[ overflow-d ] [ { "kernel-error" 11 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
-[ overflow-d-alt ] [ { "kernel-error" 12 f f } = ] must-fail-with
+[ overflow-d-alt ] [ { "kernel-error" 11 f f } = ] must-fail-with
 
 [ ] [ [ :c ] with-string-writer drop ] unit-test
 
-[ overflow-r ] [ { "kernel-error" 14 f f } = ] must-fail-with
+[ overflow-r ] [ { "kernel-error" 13 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
 [ -7 <byte-array> ] must-fail
 
-[ 2 3 4 1 ] [ 1 2 3 4 roll ] unit-test
-[ 1 2 3 4 ] [ 2 3 4 1 -roll ] unit-test
-
 [ 3 ] [ t 3 and ] unit-test
 [ f ] [ f 3 and ] unit-test
 [ f ] [ 3 f and ] unit-test
@@ -113,7 +110,7 @@ IN: kernel.tests
     < [ [ 1 + ] 3dip (loop) ] [ 2drop 2drop ] if ; inline recursive
 
 : loop ( obj -- )
-    H{ } values swap [ dup length swap ] dip 0 -roll (loop) ;
+    H{ } values swap [ dup length swap ] dip [ 0 ] 3dip (loop) ;
 
 [ loop ] must-fail
 
@@ -172,3 +169,7 @@ IN: kernel.tests
 [ 3 -1 5/6 ] [ 1 2 3 4 5 6 [ + ] [ - ] [ / ] 2tri* ] unit-test
 
 [ { 1 2 } { 3 4 } { 5 6 } ] [ 1 2 3 4 5 6 [ 2array ] 2tri@ ] unit-test
+
+[ t ] [ { } identity-hashcode fixnum? ] unit-test
+[ 123 ] [ 123 identity-hashcode ] unit-test
+[ t ] [ f identity-hashcode fixnum? ] unit-test
index 838d877a40e71403264fcbe5a130206d4322203b..69d082ed2f954f32fa9076059a520093af440c30 100644 (file)
@@ -8,12 +8,6 @@ DEFER: 2dip
 DEFER: 3dip
 
 ! Stack stuff
-: spin ( x y z -- z y x ) swap rot ; inline
-
-: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline
-
-: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline
-
 : 2over ( x y z -- x y z x y ) pick pick ; inline
 
 : clear ( -- ) { } set-datastack ;
@@ -63,9 +57,9 @@ DEFER: if
 
 : dip ( x quot -- x ) swap [ call ] dip ;
 
-: 2dip ( x y quot -- x y ) -rot [ call ] 2dip ;
+: 2dip ( x y quot -- x y ) swap [ dip ] dip ;
 
-: 3dip ( x y z quot -- x y z ) -roll [ call ] 3dip ;
+: 3dip ( x y z quot -- x y z ) swap [ 2dip ] dip ;
 
 : 4dip ( w x y z quot -- w x y z ) swap [ 3dip ] dip ; inline
 
@@ -122,7 +116,7 @@ DEFER: if
 : 2bi@ ( w x y z quot -- )
     dup 2bi* ; inline
 
-: 2tri@ ( u v w y x z quot -- )
+: 2tri@ ( u v w x y z quot -- )
     dup dup 2tri* ; inline
 
 ! Quotation building
@@ -198,6 +192,16 @@ M: f hashcode* 2drop 31337 ; inline
 
 : hashcode ( obj -- code ) 3 swap hashcode* ; inline
 
+: identity-hashcode ( obj -- code )
+    dup tag 0 eq? [
+        dup tag 1 eq? [ drop 0 ] [
+            dup (identity-hashcode) dup 0 eq? [
+                drop dup compute-identity-hashcode
+                (identity-hashcode)
+            ] [ nip ] if
+        ] if
+    ] unless ; inline
+
 GENERIC: equal? ( obj1 obj2 -- ? )
 
 M: object equal? 2drop f ; inline
@@ -206,6 +210,8 @@ TUPLE: identity-tuple ;
 
 M: identity-tuple equal? 2drop f ; inline
 
+M: identity-tuple hashcode* nip identity-hashcode ; inline
+
 : = ( obj1 obj2 -- ? )
     2dup eq? [ 2drop t ] [
         2dup both-fixnums? [ 2drop f ] [ equal? ] if
@@ -234,8 +240,6 @@ ERROR: assert got expect ;
 
 : declare ( spec -- ) drop ;
 
-: hi-tag ( obj -- n ) { hi-tag } declare 0 slot ; inline
-
 : do-primitive ( number -- ) "Improper primitive call" throw ;
 
 PRIVATE>
index 8dd1e6901f88f320a5d7fa473275fba5e67fbb26..efea1ffb4e008401a36c35210d766132b3a6f95a 100644 (file)
@@ -7,18 +7,11 @@ HELP: tag-bits
 { $var-description "Number of least significant bits reserved for a type tag in a tagged pointer." }
 { $see-also tag } ;
 
-HELP: num-tags
-{ $var-description "Number of distinct pointer tags. This is one more than the maximum value from the " { $link tag } " primitive." } ;
-
 HELP: tag-mask
 { $var-description "Taking the bitwise and of a tagged pointer with this mask leaves the tag." } ;
 
 HELP: num-types
-{ $var-description "Number of distinct built-in types. This is one more than the maximum value from the " { $link hi-tag } " primitive." } ;
-
-HELP: tag-number
-{ $values { "class" class } { "n" "an integer or " { $link f } } }
-{ $description "Outputs the pointer tag for pointers to instances of " { $link class } ". Will output " { $link f } " if instances of this class are not identified by a distinct pointer tag." } ;
+{ $var-description "Number of distinct built-in types. This is one more than the maximum value from the " { $link tag } " primitive." } ;
 
 HELP: type-number
 { $values { "class" class } { "n" "an integer or " { $link f } } }
@@ -76,7 +69,7 @@ HELP: bootstrap-cell-bits
 
 ARTICLE: "layouts-types" "Type numbers"
 "Corresponding to every built-in class is a built-in type number. An object can be asked for its built-in type number:"
-{ $subsections hi-tag }
+{ $subsections tag }
 "Built-in type numbers can be converted to classes, and vice versa:"
 { $subsections
     type>class
@@ -88,14 +81,10 @@ ARTICLE: "layouts-types" "Type numbers"
 ARTICLE: "layouts-tags" "Tagged pointers"
 "Every pointer stored on the stack or in the heap has a " { $emphasis "tag" } ", which is a small integer identifying the type of the pointer. If the tag is not equal to one of the two special tags, the remaining bits contain the memory address of a heap-allocated object. The two special tags are the " { $link fixnum } " tag and the " { $link f } " tag."
 $nl
-"Getting the tag of an object:"
-{ $link tag }
 "Words for working with tagged pointers:"
 { $subsections
     tag-bits
-    num-tags
     tag-mask
-    tag-number
 }
 "The Factor VM does not actually expose any words for working with tagged pointers directly. The above words operate on integers; they are used in the bootstrap image generator and the optimizing compiler." ;
 
index be6276a6841f12658d4ac07d67df999f443fb1a4..05fe03315cc0ea603c396d384c38ed458d4555a7 100644 (file)
@@ -4,32 +4,35 @@ USING: namespaces math words kernel assocs classes
 math.order kernel.private ;
 IN: layouts
 
-SYMBOL: tag-mask
+SYMBOL: data-alignment
 
-SYMBOL: num-tags
+SYMBOL: tag-mask
 
 SYMBOL: tag-bits
 
 SYMBOL: num-types
 
-SYMBOL: tag-numbers
-
 SYMBOL: type-numbers
 
 SYMBOL: mega-cache-size
 
+SYMBOL: header-bits
+
 : type-number ( class -- n )
     type-numbers get at ;
 
-: tag-number ( class -- n )
-    type-number dup num-tags get >= [ drop object tag-number ] when ;
-
 : tag-fixnum ( n -- tagged )
     tag-bits get shift ;
 
+: tag-header ( n -- tagged )
+    header-bits get shift ;
+
 : untag-fixnum ( n -- tagged )
     tag-bits get neg shift ;
 
+: hashcode-shift ( -- n )
+    tag-bits get header-bits get + ;
+
 ! We do this in its own compilation unit so that they can be
 ! folded below
 <<
@@ -58,7 +61,7 @@ SYMBOL: mega-cache-size
     first-bignum neg >fixnum ; inline
 
 : (max-array-capacity) ( b -- n )
-    5 - 2^ 1 - ; inline
+    6 - 2^ 1 - ; inline
 
 : max-array-capacity ( -- n )
     cell-bits (max-array-capacity) ; inline
index c09f2950e4a2f555467a493fe9c94004cbd4d112..e25bbf13e2ba420062465342e95dbf85d55b1cae 100644 (file)
@@ -4,7 +4,7 @@ IN: math.integers
 ARTICLE: "integers" "Integers"
 { $subsections integer }
 "Integers come in two varieties -- fixnums and bignums. Fixnums fit in a machine word and are faster to manipulate; if the result of a fixnum operation is too large to fit in a fixnum, the result is upgraded to a bignum. Here is an example where two fixnums are multiplied yielding a bignum:"
-{ $example "USE: classes" "134217728 class ." "fixnum" }
+{ $example "USE: classes" "67108864 class ." "fixnum" }
 { $example "USE: classes" "128 class ." "fixnum" }
 { $example "134217728 128 * ." "17179869184" }
 { $example "USE: classes" "1 128 shift class ." "bignum" }
index a9469ae91a83c9dafb7606d05765d8b9fae631b3..30d1254082017b9fb539cc141ba8fc4daa1e062a 100644 (file)
@@ -23,8 +23,8 @@ IN: math.integers.tests
 
 [ -1 ] [ 1 neg ] unit-test
 [ -1 ] [ 1 >bignum neg ] unit-test
-[ 268435456 ] [ -268435456 >fixnum -1 * ] unit-test
-[ 268435456 ] [ -268435456 >fixnum neg ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 * ] unit-test
+[ 134217728 ] [ -134217728 >fixnum neg ] unit-test
 
 [ 9 3 ] [ 93 10 /mod ] unit-test
 [ 9 3 ] [ 93 >bignum 10 /mod ] unit-test
@@ -100,12 +100,12 @@ unit-test
 [ 16 ] [ 13 next-power-of-2 ] unit-test
 [ 16 ] [ 16 next-power-of-2 ] unit-test
 
-[ 268435456 ] [ -268435456 >fixnum -1 /i ] unit-test
-[ 268435456 0 ] [ -268435456 >fixnum -1 /mod ] unit-test
-[ 0 ] [ -1 -268435456 >fixnum /i ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 /i ] unit-test
+[ 134217728 0 ] [ -134217728 >fixnum -1 /mod ] unit-test
+[ 0 ] [ -1 -134217728 >fixnum /i ] unit-test
 [ 4420880996869850977 ] [ 13262642990609552931 3 /i ] unit-test
-[ 0 -1 ] [ -1 -268435456 >fixnum /mod ] unit-test
-[ 0 -1 ] [ -1 -268435456 >bignum /mod ] unit-test
+[ 0 -1 ] [ -1 -134217728 >fixnum /mod ] unit-test
+[ 0 -1 ] [ -1 -134217728 >bignum /mod ] unit-test
 [ 14355 ] [ 1591517158873146351817850880000000 32769 mod ] unit-test
 [ 8 530505719624382123 ] [ 13262642990609552931 1591517158873146351 /mod ] unit-test
 [ 8 ] [ 13262642990609552931 1591517158873146351 /i ] unit-test
@@ -117,7 +117,7 @@ unit-test
 [ f ] [ 30 zero? ] unit-test
 [ t ] [ 0 >bignum zero? ] unit-test
 
-[ 4294967280 ] [ 268435455 >fixnum 16 fixnum* ] unit-test
+[ 2147483632 ] [ 134217727 >fixnum 16 fixnum* ] unit-test
 
 [ 23603949310011464311086123800853779733506160743636399259558684142844552151041 ]
 [
@@ -156,7 +156,7 @@ unit-test
 [ 4294967296 ] [ 1 32 shift ] unit-test
 [ 1267650600228229401496703205376 ] [ 1 100 shift ] unit-test
 
-[ t ] [ 1 27 shift fixnum? ] unit-test
+[ t ] [ 1 26 shift fixnum? ] unit-test
 
 [ t ] [
     t
@@ -226,3 +226,7 @@ unit-test
         [ >float / ] [ /f ] 2bi 0.1 ~
     ] all?
 ] unit-test
+
+! Ensure that /f is accurate for fixnums > 2^53 on 64-bit platforms
+[ HEX: 1.758bec11492f9p-54 ] [ 1 12345678901234567 /f ] unit-test
+[ HEX: -1.758bec11492f9p-54 ] [ 1 -12345678901234567 /f ] unit-test
index e684b8edfb479cf4c480f26d299eeee4f6a761f2..eb94597160c68026ab6b7e8ae204715ecea16b39 100644 (file)
@@ -33,7 +33,16 @@ M: fixnum + fixnum+ ; inline
 M: fixnum - fixnum- ; inline
 M: fixnum * fixnum* ; inline
 M: fixnum /i fixnum/i ; inline
-M: fixnum /f [ >float ] dip >float float/f ; inline
+
+DEFER: bignum/f
+CONSTANT: bignum/f-threshold HEX: 20,0000,0000,0000
+
+: fixnum/f ( m n -- m/n )
+    [ >float ] bi@ float/f ; inline
+
+M: fixnum /f
+    2dup [ abs bignum/f-threshold >= ] either?
+    [ bignum/f ] [ fixnum/f ] if ; inline
 
 M: fixnum mod fixnum-mod ; inline
 
@@ -144,5 +153,8 @@ M: bignum (log2) bignum-log2 ; inline
         ] if-zero
     ] if ; inline
 
-M: bignum /f ( m n -- f )
+: bignum/f ( m n -- f )
     [ [ abs ] bi@ /f-abs ] [ [ 0 < ] bi@ xor ] 2bi [ neg ] when ;
+
+M: bignum /f ( m n -- f )
+    bignum/f ;
index 8ef4f38f9aeac470ed8f69aac54d00092b4730c8..c1a8ba32f7c86ada75c686ceea9330f8ae933bfc 100755 (executable)
@@ -147,14 +147,16 @@ PRIVATE>
 
 : (find-integer) ( i n quot: ( i -- ? ) -- i )
     [
-        iterate-step roll
-        [ 2drop ] [ iterate-next (find-integer) ] if
+        iterate-step
+        [ [ ] ] 2dip
+        [ iterate-next (find-integer) ] 2curry bi-curry if
     ] [ 3drop f ] if-iterate? ; inline recursive
 
 : (all-integers?) ( i n quot: ( i -- ? ) -- ? )
     [
-        iterate-step roll
-        [ iterate-next (all-integers?) ] [ 3drop f ] if
+        iterate-step
+        [ iterate-next (all-integers?) ] 3curry
+        [ f ] if
     ] [ 3drop t ] if-iterate? ; inline recursive
 
 : each-integer ( n quot -- )
index a53604ddf92fbfb6947a5aacf46d076110de615f..f04c0104a5aa366c0ed6642cc92214c41676815c 100644 (file)
@@ -5,39 +5,18 @@ strings arrays combinators splitting math assocs byte-arrays make ;
 IN: math.parser
 
 : digit> ( ch -- n )
-    H{
-        { CHAR: 0 0 }
-        { CHAR: 1 1 }
-        { CHAR: 2 2 }
-        { CHAR: 3 3 }
-        { CHAR: 4 4 }
-        { CHAR: 5 5 }
-        { CHAR: 6 6 }
-        { CHAR: 7 7 }
-        { CHAR: 8 8 }
-        { CHAR: 9 9 }
-        { CHAR: A 10 }
-        { CHAR: B 11 }
-        { CHAR: C 12 }
-        { CHAR: D 13 }
-        { CHAR: E 14 }
-        { CHAR: F 15 }
-        { CHAR: a 10 }
-        { CHAR: b 11 }
-        { CHAR: c 12 }
-        { CHAR: d 13 }
-        { CHAR: e 14 }
-        { CHAR: f 15 }
-        { CHAR: , f }
-    } at* [ drop 255 ] unless ; inline
+    127 bitand {
+        { [ dup CHAR: 9 <= ] [ CHAR: 0 - ] }
+        { [ dup CHAR: a <  ] [ CHAR: A 10 - - ] }
+        [ CHAR: a 10 - - ]
+    } cond
+    dup 0 < [ drop 255 ] [ dup 16 >= [ drop 255 ] when ] if ; inline
 
 : string>digits ( str -- digits )
     [ digit> ] B{ } map-as ; inline
 
 : (digits>integer) ( valid? accum digit radix -- valid? accum )
-    over [
-        2dup < [ swapd * + ] [ 2drop 2drop f 0 ] if
-    ] [ 2drop ] if ; inline
+    2dup < [ swapd * + ] [ 2drop 2drop f 0 ] if ; inline
 
 : each-digit ( seq radix quot -- n/f )
     [ t 0 ] 3dip curry each swap [ drop f ] unless ; inline
@@ -54,8 +33,8 @@ SYMBOL: negative?
 
 : string>natural ( seq radix -- n/f )
     over empty? [ 2drop f ] [
-        [ [ digit> ] dip (digits>integer) ] each-digit
-    ] if ; inline
+        [ over CHAR: , eq? [ 2drop ] [ [ digit> ] dip (digits>integer) ] if ] each-digit
+    ] if ;
 
 : sign ( -- str ) negative? get "-" "+" ? ;
 
@@ -83,14 +62,14 @@ SYMBOL: negative?
     ] if ; inline
 
 : dec>float ( str -- n/f )
-    [ CHAR: , eq? not ] filter
-    >byte-array 0 suffix (string>float) ;
+    [ CHAR: , eq? not ] BV{ } filter-as
+    0 over push B{ } like (string>float) ;
 
 : hex>float-parts ( str -- neg? mantissa-str expt )
-    "-" ?head swap "p" split1 [ 10 base> ] [ 0 ] if* ;
+    "-" ?head swap "p" split1 [ 10 base> ] [ 0 ] if* ; inline
 
 : make-mantissa ( str -- bits )
-    16 base> dup log2 52 swap - shift ;
+    16 base> dup log2 52 swap - shift ; inline
 
 : combine-hex-float-parts ( neg? mantissa expt -- float )
     dup 2046 > [ 2drop -1/0. 1/0. ? ] [
@@ -99,7 +78,7 @@ SYMBOL: negative?
         [ 52 2^ 1 - bitand ]
         [ 52 shift ] tri* bitor bitor
         bits>double 
-    ] if ;
+    ] if ; inline
 
 : hex>float ( str -- n/f )
     hex>float-parts
@@ -111,23 +90,33 @@ SYMBOL: negative?
     {
         { 16 [ hex>float ] }
         [ drop dec>float ]
-    } case ;
+    } case ; inline
 
 : number-char? ( char -- ? )
-    "0123456789ABCDEFabcdef." member? ;
+    "0123456789ABCDEFabcdef." member? ; inline
+
+: last-unsafe ( seq -- elt )
+    [ length 1 - ] [ nth-unsafe ] bi ; inline
 
 : numeric-looking? ( str -- ? )
-    "-" ?head drop
     dup empty? [ drop f ] [
-        dup first number-char? [
-            last number-char?
-        ] [ drop f ] if
-    ] if ;
+        dup first-unsafe number-char? [
+            last-unsafe number-char?
+        ] [
+            dup first-unsafe CHAR: - eq? [
+                dup length 1 eq? [ drop f ] [
+                    1 over nth-unsafe number-char? [
+                        last-unsafe number-char?
+                    ] [ drop f ] if
+                ] if
+            ] [ drop f ] if
+        ] if
+    ] if ; inline
 
 PRIVATE>
 
 : string>float ( str -- n/f )
-    10 base>float ;
+    10 base>float ; inline
 
 : base> ( str radix -- n/f )
     over numeric-looking? [
@@ -138,20 +127,18 @@ PRIVATE>
         } case
     ] [ 2drop f ] if ;
 
-: string>number ( str -- n/f ) 10 base> ;
-: bin> ( str -- n/f ) 2 base> ;
-: oct> ( str -- n/f ) 8 base> ;
-: hex> ( str -- n/f ) 16 base> ;
+: string>number ( str -- n/f ) 10 base> ; inline
+: bin> ( str -- n/f ) 2 base> ; inline
+: oct> ( str -- n/f ) 8 base> ; inline
+: hex> ( str -- n/f ) 16 base> ; inline
 
 : >digit ( n -- ch )
-    dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] if ;
+    dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] if ; inline
 
 : positive>base ( num radix -- str )
     dup 1 <= [ "Invalid radix" throw ] when
     [ dup 0 > ] swap [ /mod >digit ] curry "" produce-as nip
-    dup reverse-here ; inline
-
-PRIVATE>
+    reverse! ; inline
 
 GENERIC# >base 1 ( n radix -- str )
 
@@ -234,12 +221,12 @@ M: ratio >base
     {
         { 16 [ float>hex ] }
         [ drop float>decimal ]
-    } case ;
+    } case ; inline
 
 PRIVATE>
 
 : float>string ( n -- str )
-    10 float>base ;
+    10 float>base ; inline
 
 M: float >base
     {
@@ -251,9 +238,9 @@ M: float >base
         [ float>base ]
     } cond ;
 
-: number>string ( n -- str ) 10 >base ;
-: >bin ( n -- str ) 2 >base ;
-: >oct ( n -- str ) 8 >base ;
-: >hex ( n -- str ) 16 >base ;
+: number>string ( n -- str ) 10 >base ; inline
+: >bin ( n -- str ) 2 >base ; inline
+: >oct ( n -- str ) 8 >base ; inline
+: >hex ( n -- str ) 16 >base ; inline
 
-: # ( n -- ) number>string % ;
+: # ( n -- ) number>string % ; inline
index d40705a53176b0f2eb4c3c725e13462e9cad89bb..acf187a33ab499fde0f98a8791b555abb2693fad 100644 (file)
@@ -2,42 +2,20 @@ USING: help.markup help.syntax debugger sequences kernel
 quotations math ;
 IN: memory
 
-HELP: begin-scan ( -- )
-{ $description "Disables the garbage collector and resets the heap scan pointer to point at the first object in the heap. The " { $link next-object } " word can then be called to advance the heap scan pointer and return successive objects."
-$nl
-"This word must always be paired with a call to " { $link end-scan } "." }
-{ $notes "This is a low-level facility and can be dangerous. Use the " { $link each-object } " combinator instead." } ;
-
-HELP: next-object ( -- obj )
-{ $values { "obj" object } }
-{ $description "Outputs the object at the heap scan pointer, and then advances the heap scan pointer. If the end of the heap has been reached, outputs " { $link f } ". This is unambiguous since the " { $link f } " object is tagged immediate and not actually stored in the heap." }
-{ $errors "Throws a " { $link heap-scan-error. } " if called outside a " { $link begin-scan } "/" { $link end-scan } " pair." }
-{ $notes "This is a low-level facility and can be dangerous. Use the " { $link each-object } " combinator instead." } ;
-
-HELP: end-scan ( -- )
-{ $description "Finishes a heap iteration by re-enabling the garbage collector. This word must always be paired with a call to " { $link begin-scan } "." }
-{ $notes "This is a low-level facility and can be dangerous. Use the " { $link each-object } " combinator instead." } ;
-
-HELP: each-object
-{ $values { "quot" { $quotation "( obj -- )" } } }
-{ $description "Applies a quotation to each object in the heap. The garbage collector is switched off while this combinator runs, so the given quotation must not allocate too much memory." }
-{ $notes "This word is the low-level facility used to implement the " { $link instances } " word." } ;
-
 HELP: instances
 { $values { "quot" { $quotation "( obj -- ? )" } } { "seq" "a fresh sequence" } }
-{ $description "Outputs a sequence of all objects in the heap which satisfy the quotation." }
-{ $notes "This word relies on " { $link each-object } ", so in particular the garbage collector is switched off while it runs and the given quotation must not allocate too much memory." } ;
+{ $description "Outputs a sequence of all objects in the heap which satisfy the quotation." } ;
 
 HELP: gc ( -- )
 { $description "Performs a full garbage collection." } ;
 
-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: data-room ( -- data-room )
+{ $values { "data-room" data-room } }
+{ $description "Queries the VM for memory usage information." } ;
 
-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: code-room ( -- code-room )
+{ $values { "code-room" code-room } }
+{ $description "Queries the VM for memory usage information." } ;
 
 HELP: size ( obj -- n )
 { $values { "obj" "an object" } { "n" "a size in bytes" } }
@@ -56,17 +34,6 @@ HELP: save-image-and-exit ( path -- )
 HELP: save
 { $description "Saves a snapshot of the heap to the current image file." } ;
 
-HELP: count-instances
-{ $values
-     { "quot" quotation }
-     { "n" integer } }
-{ $description "Applies the predicate quotation to each object in the heap and returns the number of objects that match. Since this word uses " { $link each-object } " with the garbage collector switched off, avoid allocating too much memory in the quotation." }
-{ $examples { $unchecked-example
-    "USING: memory words prettyprint ;"
-    "[ word? ] count-instances ."
-    "24210"
-} } ;
-
 ARTICLE: "images" "Images"
 "Factor has the ability to save the entire state of the system into an " { $emphasis "image file" } ". The image contains a complete dump of all data and code in the current Factor instance."
 { $subsections
index 8ecf673b8a70ee8b8eb0d72a898415f6c0788ed9..45e6090e773877981357c1bcae3ed312b3ab3ac3 100755 (executable)
@@ -31,4 +31,4 @@ TUPLE: testing x y z ;
 2 [ [ [ 3 throw ] instances ] must-fail ] times
 
 ! Bug found on Windows build box, having too many words in the image breaks 'become'
-[ ] [ 100000 [ f f <word> ] replicate { } { } become drop ] unit-test
+[ ] [ 100000 [ f <uninterned-word> ] replicate { } { } become drop ] unit-test
index 1c61e33d83542a8eb27a604b3ed6d404a67a2be3..4ab68a1ef1f81d7858bf1e23e464cc3cfa48f537 100644 (file)
@@ -1,26 +1,11 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel continuations sequences vectors arrays system math
+USING: kernel continuations sequences system
 io.backend alien.strings memory.private ;
 IN: memory
 
-: (each-object) ( quot: ( obj -- ) -- )
-    next-object dup [
-        swap [ call ] keep (each-object)
-    ] [ 2drop ] if ; inline recursive
-
-: each-object ( quot -- )
-    gc begin-scan [ (each-object) ] [ end-scan ] [ ] cleanup ; inline
-
-: count-instances ( quot -- n )
-    0 swap [ 1 0 ? + ] compose each-object ; inline
-
 : instances ( quot -- seq )
-    #! To ensure we don't need to grow the vector while scanning
-    #! the heap, we do two scans, the first one just counts the
-    #! number of objects that satisfy the predicate.
-    [ count-instances 100 + <vector> ] keep swap
-    [ [ push-if ] 2curry each-object ] keep >array ; inline
+    [ all-instances ] dip filter ; inline
 
 : save-image ( path -- )
     normalize-path native-string>alien (save-image) ;
index 9fc4695e66e7dc27ed730f2388f97fe82c141b81..05a72c602583ba669031d83b98100d7c0215d5ac 100755 (executable)
@@ -43,24 +43,24 @@ ARTICLE: "namespaces.private" "Namespace implementation details"
     ndrop
 } ;
 
-ARTICLE: "namespaces" "Dynamic variables and namespaces"
-"The " { $vocab-link "namespaces" } " vocabulary implements simple dynamically-scoped variables."
+ARTICLE: "namespaces" "Dynamic variables"
+"The " { $vocab-link "namespaces" } " vocabulary implements dynamically-scoped variables."
 $nl
-"A variable is an entry in an assoc of bindings, where the assoc is implicit rather than passed on the stack. These assocs are termed " { $emphasis "namespaces" } ". Nesting of scopes is implemented with a search order on namespaces, defined by a " { $emphasis "namestack" } ". Since namespaces are just assoc, any object can be used as a variable, however by convention, variables are keyed by symbols (see " { $link "words.symbol" } ")."
+"A dynamic variable is an entry in an assoc of bindings, where the assoc is implicit rather than passed on the stack. These assocs are termed " { $emphasis "namespaces" } ". Nesting of scopes is implemented with a search order on namespaces, defined by a " { $emphasis "namestack" } ". Since namespaces are just assocs, any object can be used as a variable. By convention, variables are keyed by " { $link "words.symbol" } "."
 $nl
-"The " { $link get } " and " { $link set } " words read and write variable values. The " { $link get } " word searches up the chain of nested namespaces, while " { $link set } " always sets variable values in the current namespace only. Namespaces are dynamically scoped; when a quotation is called from a nested scope, any words called by the quotation also execute in that scope."
+"The " { $link get } " and " { $link set } " words read and write variable values. The " { $link get } " word searches the chain of nested namespaces, while " { $link set } " always sets variable values in the current namespace only. Namespaces are dynamically scoped; when a quotation is called from a nested scope, any words called by the quotation also execute in that scope."
 { $subsections
     get
     set
 }
-"Various utility words abstract away common variable access patterns:"
+"Various utility words provide common variable access patterns:"
 { $subsections
     "namespaces-change"
     "namespaces-combinators"
 }
 "Implementation details your code probably does not care about:"
 { $subsections "namespaces.private" }
-"An alternative to dynamic scope is lexical scope. Lexically-scoped values and closures are implemented in the " { $vocab-link "locals" } " vocabulary." ;
+"Dynamic variables complement " { $link "locals" } "." ;
 
 ABOUT: "namespaces"
 
index 7e94d71c29af99c6b6d8f48409377b264a30f29c..97dbab384e5ec1ed9d052e44849e7d144f3d9606 100644 (file)
@@ -66,7 +66,7 @@ $nl
 $nl
 "Parsing words can read input, add word definitions to the dictionary, and do anything an ordinary word can."
 $nl
-"Because of the stack restriction, parsing words cannot pass data to other words by leaving values on the stack; instead, use " { $link parsed } " to add the data to the parse tree so that it can be evaluated later."
+"Because of the stack restriction, parsing words cannot pass data to other words by leaving values on the stack; instead, use " { $link suffix! } " to add the data to the parse tree so that it can be evaluated later."
 $nl
 "Parsing words cannot be called from the same source file where they are defined, because new definitions are only compiled at the end of the source file. An attempt to use a parsing word in its own source file raises an error:"
 { $subsections staging-violation }
@@ -172,11 +172,6 @@ $parsing-note ;
 
 { parse-tokens (parse-until) parse-until } related-words
 
-HELP: parsed
-{ $values { "accum" vector } { "obj" object } }
-{ $description "Convenience word for parsing words. It behaves exactly the same as " { $link push } ", except the accumulator remains on the stack." }
-$parsing-note ;
-
 HELP: (parse-lines)
 { $values { "lexer" lexer } { "quot" "a new " { $link quotation } } }
 { $description "Parses Factor source code using a custom lexer. The vocabulary search path is taken from the current scope." }
@@ -188,7 +183,7 @@ HELP: parse-lines
 { $errors "Throws a " { $link lexer-error } " if the input is malformed." } ;
 
 HELP: parse-base
-{ $values { "base" "an integer between 2 and 36" } { "parsed" integer } }
+{ $values { "parsed" integer } { "base" "an integer between 2 and 36" } { "parsed" integer } }
 { $description "Reads an integer in a specific numerical base from the parser input." }
 $parsing-note ;
 
@@ -221,7 +216,7 @@ HELP: filter-moved
 { $description "Removes all definitions from " { $snippet "assoc2" } " which are in " { $snippet "assoc1" } " or are are no longer present in the current " { $link file } "." } ;
 
 HELP: forget-smudged
-{ $description "Forgets removed definitions and prints a warning message if any of them are still referenced from other source files." } ;
+{ $description "Forgets removed definitions." } ;
 
 HELP: finish-parsing
 { $values { "lines" "the lines of text just parsed" } { "quot" "the quotation just parsed" } }
index 791fe1fa36e056cf9bf82e1aa43bbc40af653eec..f30eb686840470841b32f7c3fafe09003af957b2 100644 (file)
@@ -141,15 +141,15 @@ IN: parser.tests
     ] unit-test
     
     [ t ] [
-        array "smudge-me" "parser.tests" lookup order memq?
+        array "smudge-me" "parser.tests" lookup order member-eq?
     ] unit-test
     
     [ t ] [
-        integer "smudge-me" "parser.tests" lookup order memq?
+        integer "smudge-me" "parser.tests" lookup order member-eq?
     ] unit-test
     
     [ f ] [
-        string "smudge-me" "parser.tests" lookup order memq?
+        string "smudge-me" "parser.tests" lookup order member-eq?
     ] unit-test
 
     [ ] [
index 3152afc0933855b698c18957e220b2b14611474f..d920e1fc734767adfc95c518d4688a8c59478fd8 100644 (file)
@@ -79,8 +79,6 @@ HOOK: parse-quotation quotation-parser ( -- quot )
 
 M: f parse-quotation \ ] parse-until >quotation ;
 
-: parsed ( accum obj -- accum ) over push ;
-
 : (parse-lines) ( lexer -- quot )
     [ f parse-until >quotation ] with-lexer ;
 
@@ -88,7 +86,7 @@ M: f parse-quotation \ ] parse-until >quotation ;
     lexer-factory get call( lines -- lexer ) (parse-lines) ;
 
 : parse-literal ( accum end quot -- accum )
-    [ parse-until ] dip call parsed ; inline
+    [ parse-until ] dip call suffix! ; inline
 
 : parse-definition ( -- quot )
     \ ; parse-until >quotation ;
@@ -104,7 +102,7 @@ ERROR: bad-number ;
     scan swap base> [ bad-number ] unless* ;
 
 : parse-base ( parsed base -- parsed )
-    scan-base parsed ;
+    scan-base suffix! ;
 
 SYMBOL: bootstrap-syntax
 
index 983ddbaf9ad3e7b8297c0f1844d326210ee4acbb..b6be8d36f33c731c5747a2f4028f555fd0778d1e 100644 (file)
@@ -3,29 +3,28 @@ vectors kernel combinators ;
 IN: quotations
 
 ARTICLE: "quotations" "Quotations"
-"Conceptually, a quotation is an anonymous function (a value denoting a snippet of code) which can be passed around and called."
+"A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called. Quotations are delimited by square brackets (" { $snippet "[ ]" } "); see " { $link "syntax-quots" } " for details on their syntax."
 $nl
-"Concretely, a quotation is an immutable sequence of objects, some of which may be words, together with a block of machine code which may be executed to achieve the effect of evaluating the quotation. The machine code is generated by a fast non-optimizing quotation compiler which is always running and is transparent to the developer."
-$nl
-"Quotations form a class of objects, however in most cases, methods should dispatch on " { $link callable } " instead, so that " { $link curry } " and " { $link compose } " values can participate."
+"Quotations form a class of objects:"
 { $subsections
     quotation
     quotation?
 }
-"Quotations evaluate sequentially from beginning to end. Literals are pushed on the stack and words are executed. Details can be found in " { $link "evaluator" } "."
-$nl
-"Quotation literal syntax is documented in " { $link "syntax-quots" } "."
-$nl
+"A more general class is provided for methods to dispatch on that includes quotations, " { $link curry } ", and " { $link compose } " objects:"
+{ $subsections
+    callable
+}
+"Quotations evaluate sequentially from beginning to end. Literals are pushed on the stack and words are executed. Details can be found in " { $link "evaluator" } ". Words can be placed in wrappers to suppress execution:"
+{ $subsections "wrappers" }
 "Quotations implement the " { $link "sequence-protocol" } ", and existing sequences can be converted into quotations:"
 { $subsections
     >quotation
     1quotation
 }
-"Wrappers:"
-{ $subsections "wrappers" } ;
+"Although quotations can be treated as sequences, the compiler will be unable to reason about quotations manipulated as sequences at runtime. " { $link "compositional-combinators" } " are provided for runtime partial application and composition of quotations." ;
 
 ARTICLE: "wrappers" "Wrappers"
-"Wrappers are used to push words on the data stack; they evaluate to the object being wrapped:"
+"Wrappers evaluate to the object being wrapped when encountered in code. They are are used to suppress the execution of " { $link "words" } " so that they can be used as values."
 { $subsections
     wrapper
     literalize
index f2b17b3f9da989da2b5e86d88a3a387401979072..2af94159f831ddb598a183ee0000e889187a9c87 100644 (file)
@@ -61,7 +61,7 @@ INSTANCE: curry immutable-sequence
 M: compose length
     [ first>> length ] [ second>> length ] bi + ;
 
-M: compose virtual-seq first>> ;
+M: compose virtual-exemplar first>> ;
 
 M: compose virtual@
     2dup first>> length < [
index 49b6ec137406cccc9901231e0bcdcc914f4b47a0..db2649142d7b408203d7d3dad35ee1e20aecd10a 100644 (file)
@@ -23,13 +23,13 @@ M: sbuf like
         dup string? [ dup length sbuf boa ] [ >sbuf ] if
     ] unless ; inline
 
-M: sbuf new-resizable drop <sbuf> ; inline
-
 M: sbuf equal?
     over sbuf? [ sequence= ] [ 2drop f ] if ;
 
 M: string new-resizable drop <sbuf> ; inline
 
+M: sbuf new-resizable drop <sbuf> ; inline
+
 M: string like
     #! If we have a string, we're done.
     #! If we have an sbuf, and it's at full capacity, we're done.
index ef02754a6049b59e64fe716f39ff0aa3a4dd3a98..6d7ff241eff198c5c55541f374745741804d7203 100755 (executable)
@@ -44,7 +44,7 @@ HELP: nths
 { $values
      { "indices" sequence } { "seq" sequence }
      { "seq'" sequence } }
-{ $description "Ouptuts a sequence of elements from the input sequence indexed by the indices." }
+{ $description "Outputs a sequence of elements from the input sequence indexed by the indices." }
 { $examples 
     { $example "USING: prettyprint sequences ;"
                "{ 0 2 } { \"a\" \"b\" \"c\" } nths ."
@@ -218,7 +218,7 @@ HELP: 3sequence
 { $description "Creates a three-element sequence of the same type as " { $snippet "exemplar" } "." } ;
 
 HELP: 4sequence
-{ $values { "obj1" object } { "obj2" object } { "exemplar" sequence } { "obj3" object } { "obj4" object } { "seq" sequence } }
+{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "obj4" object } { "exemplar" sequence } { "seq" sequence } }
 { $description "Creates a four-element sequence of the same type as " { $snippet "exemplar" } "." } ;
 
 HELP: first2
@@ -277,7 +277,7 @@ HELP: reduce-index
 } } ;
 
 HELP: accumulate-as
-{ $values { "identity" object } { "seq" sequence } { "quot" { $quotation "( prev elt -- next )" } } { "exemplar" sequence } { "final" "the final result" } { "newseq" "a new sequence" } }
+{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "exemplar" sequence } { "final" "the final result" } { "newseq" "a new sequence" } }
 { $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of the same type as " { $snippet "exemplar" } " containing intermediate results, together with the final result."
 $nl
 "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence."
@@ -285,7 +285,7 @@ $nl
 "When given the empty sequence, outputs an empty sequence together with the " { $snippet "identity" } "." } ;
 
 HELP: accumulate
-{ $values { "identity" object } { "seq" sequence } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } { "newseq" "a new array" } }
+{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } { "newseq" "a new array" } }
 { $description "Combines successive elements of the sequence using a binary operation, and outputs an array of intermediate results, together with the final result."
 $nl
 "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence."
@@ -295,12 +295,23 @@ $nl
     { $example "USING: math prettyprint sequences ;" "{ 2 2 2 2 2 } 0 [ + ] accumulate . ." "{ 0 2 4 6 8 }\n10" }
 } ;
 
+HELP: accumulate!
+{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } { "seq" sequence } }
+{ $description "Combines successive elements of the sequence using a binary operation, and outputs the original sequence of intermediate results, together with the final result."
+$nl
+"The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence."
+$nl
+"When given the empty sequence, outputs an empty sequence together with the " { $snippet "identity" } "." }
+{ $examples
+    { $example "USING: math prettyprint sequences ;" "{ 2 2 2 2 2 } 0 [ + ] accumulate! . ." "{ 0 2 4 6 8 }\n10" }
+} ;
+
 HELP: map
 { $values { "seq" sequence } { "quot" { $quotation "( old -- new )" } } { "newseq" "a new sequence" } }
 { $description "Applies the quotation to each element of the sequence in order. The new elements are collected into a sequence of the same class as the input sequence." } ;
 
 HELP: map-as
-{ $values { "seq" sequence } { "quot" { $quotation "( old -- new )" } } { "newseq" "a new sequence" } { "exemplar" sequence } }
+{ $values { "seq" sequence } { "quot" { $quotation "( old -- new )" } } { "exemplar" sequence } { "newseq" "a new sequence" } }
 { $description "Applies the quotation to each element of the sequence in order. The new elements are collected into a sequence of the same class as " { $snippet "exemplar" } "." }
 { $examples
     "The following example converts a string into an array of one-element strings:"
@@ -332,9 +343,9 @@ HELP: change-nth
 { $errors "Throws an error if the sequence is immutable, if the index is out of bounds, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." }
 { $side-effects "seq" } ;
 
-HELP: change-each
-{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( old -- new )" } } }
-{ $description "Applies the quotation to each element yielding a new element, storing the new elements back in the original sequence." }
+HELP: map!
+{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( old -- new )" } } { "seq" "a mutable sequence" } }
+{ $description "Applies the quotation to each element yielding a new element, storing the new elements back in the original sequence. Returns the original sequence." }
 { $errors "Throws an error if the sequence is immutable, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." }
 { $side-effects "seq" } ;
 
@@ -426,8 +437,12 @@ HELP: filter
 { $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "subseq" "a new sequence" } }
 { $description "Applies the quotation to each element in turn, and outputs a new sequence containing the elements of the original sequence for which the quotation output a true value." } ;
 
-HELP: filter-here
-{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } }
+HELP: filter-as
+{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "exemplar" sequence } { "subseq" "a new sequence" } }
+{ $description "Applies the quotation to each element in turn, and outputs a new sequence of the same type as " { $snippet "exemplar" } " containing the elements of the original sequence for which the quotation output a true value." } ;
+
+HELP: filter!
+{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } { "seq" "a resizable mutable sequence" } }
 { $description "Applies the quotation to each element in turn, and removes elements for which the quotation outputs a false value." }
 { $side-effects "seq" } ;
 
@@ -457,7 +472,7 @@ HELP: member?
 { $description "Tests if the sequence contains an element equal to the object." }
 { $notes "This word uses equality comparison (" { $link = } ")." } ;
 
-HELP: memq?
+HELP: member-eq?
 { $values { "elt" object } { "seq" sequence } { "?" "a boolean" } }
 { $description "Tests if the sequence contains the object." }
 { $notes "This word uses identity comparison (" { $link eq? } ")." } ;
@@ -467,7 +482,7 @@ HELP: remove
 { $description "Outputs a new sequence containing all elements of the input sequence except for given element." }
 { $notes "This word uses equality comparison (" { $link = } ")." } ;
 
-HELP: remq
+HELP: remove-eq
 { $values { "elt" object } { "seq" sequence } { "newseq" "a new sequence" } }
 { $description "Outputs a new sequence containing all elements of the input sequence except those equal to the given element." }
 { $notes "This word uses identity comparison (" { $link eq? } ")." } ;
@@ -483,24 +498,24 @@ HELP: remove-nth
 } } ;
 
 HELP: move
-{ $values { "from" "an index in " { $snippet "seq" } } { "to" "an index in " { $snippet "seq" } } { "seq" "a mutable sequence" } }
+{ $values { "to" "an index in " { $snippet "seq" } } { "from" "an index in " { $snippet "seq" } } { "seq" "a mutable sequence" } }
 { $description "Sets the element with index " { $snippet "m" } " to the element with index " { $snippet "n" } "." }
 { $side-effects "seq" } ;
 
-HELP: delete
-{ $values { "elt" object } { "seq" "a resizable mutable sequence" } }
-{ $description "Removes all elements equal to " { $snippet "elt" } " from " { $snippet "seq" } "." }
+HELP: remove!
+{ $values { "elt" object } { "seq" "a resizable mutable sequence" } { "elt" object } }
+{ $description "Removes all elements equal to " { $snippet "elt" } " from " { $snippet "seq" } " and returns " { $snippet "seq" } "." }
 { $notes "This word uses equality comparison (" { $link = } ")." }
 { $side-effects "seq" } ;
 
-HELP: delq
-{ $values { "elt" object } { "seq" "a resizable mutable sequence" } }
+HELP: remove-eq!
+{ $values { "elt" object } { "seq" "a resizable mutable sequence" } { "seq" "a resizable mutable sequence" } }
 { $description "Outputs a new sequence containing all elements of the input sequence except the given element." }
 { $notes "This word uses identity comparison (" { $link eq? } ")." }
 { $side-effects "seq" } ;
 
-HELP: delete-nth
-{ $values { "n" "a non-negative integer" } { "seq" "a resizable mutable sequence" } }
+HELP: remove-nth!
+{ $values { "n" "a non-negative integer" } { "seq" "a resizable mutable sequence" } { "seq" "a resizable mutable sequence" } }
 { $description "Removes the " { $snippet "n" } "th element from the sequence, shifting all other elements down and reducing its length by one." }
 { $side-effects "seq" } ;
 
@@ -510,7 +525,7 @@ HELP: delete-slice
 { $side-effects "seq" } ;
 
 HELP: replace-slice
-{ $values { "new" sequence } { "seq" sequence } { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "seq'" sequence } }
+{ $values { "new" sequence } { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "seq" sequence } { "seq'" sequence } }
 { $description "Replaces a range of elements beginning at index " { $snippet "from" } " and ending before index " { $snippet "to" } " with a new sequence." }
 { $errors "Throws an error if " { $snippet "new" } " contains elements whose types are not permissible in " { $snippet "seq" } "." } ;
 
@@ -524,6 +539,21 @@ HELP: suffix
     { $example "USING: prettyprint sequences ;" "{ 1 2 3 } 4 suffix ." "{ 1 2 3 4 }" }
 } ;
 
+HELP: suffix!
+{ $values { "seq" sequence } { "elt" object } { "seq" sequence } }
+{ $description "Modifiers a sequence in-place by adding " { $snippet "elt" } " to the end of " { $snippet "seq" } ". Outputs " { $snippet "seq" } "." }
+{ $errors "Throws an error if the type of " { $snippet "elt" } " is not permitted in sequences of the same class as " { $snippet "seq" } "." }
+{ $examples
+    { $example "USING: prettyprint sequences ;" "V{ 1 2 3 } 4 suffix! ." "V{ 1 2 3 4 }" }
+} ;
+
+HELP: append!
+{ $values { "seq1" sequence } { "seq2" sequence } { "seq1" sequence } }
+{ $description "Modifiers " { $snippet "seq1" } " in-place by adding the elements from " { $snippet "seq2" } " to the end and outputs " { $snippet "seq1" } "." }
+{ $examples
+    { $example "USING: prettyprint sequences ;" "V{ 1 2 3 } { 4 5 6 } append! ." "V{ 1 2 3 4 5 6 }" }
+} ;
+
 HELP: prefix
 { $values { "seq" sequence } { "elt" object } { "newseq" sequence } }
 { $description "Outputs a new sequence obtained by adding " { $snippet "elt" } " at the beginning of " { $snippet "seq" } "." }
@@ -586,9 +616,9 @@ HELP: exchange
 { $values { "m" "a non-negative integer" } { "n" "a non-negative integer" } { "seq" "a mutable sequence" } }
 { $description "Exchanges the " { $snippet "m" } "th and " { $snippet "n" } "th elements of " { $snippet "seq" } "." } ;
 
-HELP: reverse-here
+HELP: reverse!
 { $values { "seq" "a mutable sequence" } }
-{ $description "Reverses a sequence in-place." }
+{ $description "Reverses a sequence in-place and outputs that sequence." }
 { $side-effects "seq" } ;
 
 HELP: padding
@@ -616,7 +646,7 @@ HELP: reverse
 { $values { "seq" sequence } { "newseq" "a new sequence" } }
 { $description "Outputs a new sequence having the same elements as " { $snippet "seq" } " but in reverse order." } ;
 
-{ reverse <reversed> reverse-here } related-words
+{ reverse <reversed> reverse! } related-words
 
 HELP: <reversed>
 { $values { "seq" sequence } { "reversed" "a new sequence" } }
@@ -857,7 +887,7 @@ HELP: tail?
 { $values { "seq" sequence } { "end" sequence } { "?" "a boolean" } }
 { $description "Tests if " { $snippet "seq" } " ends with " { $snippet "end" } ". If " { $snippet "end" } " is longer than " { $snippet "seq" } ", this word outputs " { $link f } "." } ;
 
-{ remove remove-nth remq delq delete delete-nth } related-words
+{ remove remove-nth remove-eq remove-eq! remove! remove-nth! } related-words
 
 HELP: cut-slice
 { $values { "seq" sequence } { "n" "a non-negative integer" } { "before-slice" sequence } { "after-slice" "a slice" } }
@@ -945,13 +975,12 @@ HELP: produce-as
 { $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence of type " { $snippet "exemplar" } " at the end." }
 { $examples "See " { $link produce } " for examples." } ;
 
-HELP: sigma
+HELP: map-sum
 { $values { "seq" sequence } { "quot" quotation } { "n" number } }
 { $description "Like map sum, but without creating an intermediate sequence." }
 { $example
-    "! Find the sum of the squares [0,99]"
     "USING: math math.ranges sequences prettyprint ;"
-    "100 [1,b] [ sq ] sigma ."
+    "100 [1,b] [ sq ] map-sum ."
     "338350"
 } ;
 
@@ -1061,7 +1090,7 @@ HELP: harvest
     }
 } ;
 
-{ filter filter-here sift harvest } related-words
+{ filter filter! sift harvest } related-words
 
 HELP: set-first
 { $values
@@ -1146,17 +1175,17 @@ HELP: partition
     }
 } ;
 
-HELP: virtual-seq
+HELP: virtual-exemplar
 { $values
      { "seq" sequence }
      { "seq'" sequence } }
-{ $description "Part of the virtual sequence protocol, this word is used to return an underlying array from which to look up a value at an index given by " { $link virtual@ } "." } ;
+{ $description "Part of the virtual sequence protocol, this word is used to return an exemplar of the underlying storage. This is used in words like " { $link new-sequence } "." } ;
 
 HELP: virtual@
 { $values
      { "n" integer } { "seq" sequence }
      { "n'" integer } { "seq'" sequence } }
-{ $description "Part of the sequence protocol, this word translates the input index " { $snippet "n" } " into an index into the underlying storage returned by " { $link virtual-seq } "." } ;
+{ $description "Part of the sequence protocol, this word translates the input index " { $snippet "n" } " into an index and the underlying storage this index points into." } ;
 
 HELP: 2map-reduce
 { $values
@@ -1368,9 +1397,9 @@ $nl
 ARTICLE: "virtual-sequences-protocol" "Virtual sequence protocol"
 "Virtual sequences must know their length:"
 { $subsections length }
-"The underlying sequence to look up a value in:"
-{ $subsections virtual-seq }
-"The index of the value in the underlying sequence:"
+"An exemplar of the underlying storage:"
+{ $subsections virtual-exemplar }
+"The index and the underlying storage where the value is located:"
 { $subsections virtual@ } ;
 
 ARTICLE: "virtual-sequences" "Virtual sequences"
@@ -1412,7 +1441,7 @@ ARTICLE: "sequences-add-remove" "Adding and removing sequence elements"
 "Adding elements:"
 { $subsections prefix suffix insert-nth }
 "Removing elements:"
-{ $subsections remove remq remove-nth } ;
+{ $subsections remove remove-eq remove-nth } ;
 
 ARTICLE: "sequences-reshape" "Reshaping sequences"
 "A " { $emphasis "repetition" } " is a virtual sequence consisting of a single element repeated multiple times:"
@@ -1506,12 +1535,14 @@ ARTICLE: "sequences-combinators" "Sequence combinators"
     map-reduce
     accumulate
     accumulate-as
+    accumulate!
     produce
     produce-as
 }
 "Filtering:"
 { $subsections
     filter
+    filter-as
     partition
 }
 "Testing if a sequence contains elements satisfying a predicate:"
@@ -1546,7 +1577,7 @@ ARTICLE: "sequences-tests" "Testing sequences"
 "Testing indices:"
 { $subsections bounds-check? }
 "Testing if a sequence contains an object:"
-{ $subsections member? memq? }
+{ $subsections member? member-eq? }
 "Testing if a sequence contains a subsequence:"
 { $subsections head? tail? subseq? } ;
 
@@ -1576,57 +1607,55 @@ ARTICLE: "sequences-trimming" "Trimming sequences"
 { $subsections trim-slice trim-head-slice trim-tail-slice } ;
 
 ARTICLE: "sequences-destructive-discussion" "When to use destructive operations"
-"Constructive (non-destructive) operations should be preferred where possible because code without side-effects is usually more re-usable and easier to reason about. There are two main reasons to use destructive operations:"
+"Constructive (non-destructive) operations should be preferred where possible because code without side-effects is usually more reusable and easier to reason about. There are two main reasons to use destructive operations:"
 { $list
     "For the side-effect. Some code is simpler to express with destructive operations; constructive operations return new objects, and sometimes ``threading'' the objects through the program manually complicates stack shuffling."
-    { "As an optimization. Some code can be written to use constructive operations, however would suffer from worse performance. An example is a loop which adds an element to a sequence on each iteration; one could use either " { $link suffix } " or " { $link push } ", however the former copies the entire sequence first, which would cause the loop to run in quadratic time." }
+    { "As an optimization. Some code written to use constructive operations suffers from worse performance. An example is a loop which adds an element to a sequence on each iteration. Either " { $link suffix } " or " { $link suffix! } " could be used; however, the former copies the entire sequence each time, which would cause the loop to run in quadratic time." }
 }
 "The second reason is much weaker than the first one. In particular, many combinators (see " { $link map } ", " { $link produce } " and " { $link "namespaces-make" } ") as well as more advanced data structures (such as " { $vocab-link "persistent.vectors" } ") alleviate the need for explicit use of side effects." ;
 
 ARTICLE: "sequences-destructive" "Destructive operations"
+"Many operations have constructive and destructive variants:"
+{ $table
+    { "Constructive" "Destructive" }
+    { { $link suffix } { $link suffix! } }
+    { { $link remove } { $link remove! } }
+    { { $link remove-eq } { $link remove-eq! } }
+    { { $link remove-nth } { $link remove-nth! } }
+    { { $link reverse } { $link reverse! } }
+    { { $link append } { $link append! } }
+    { { $link map } { $link map! } }
+    { { $link filter } { $link filter! } }
+}
 "Changing elements:"
-{ $subsections change-each change-nth }
+{ $subsections map! change-nth }
 "Deleting elements:"
 { $subsections
-    delete
-    delq
-    delete-nth
+    remove!
+    remove-eq!
+    remove-nth!
     delete-slice
     delete-all
-    filter-here
+    filter!
 }
 "Other destructive words:"
 { $subsections
-    reverse-here
-    push-all
+    reverse!
+    append!
     move
     exchange
     copy
 }
-"Many operations have constructive and destructive variants:"
-{ $table
-    { "Constructive" "Destructive" }
-    { { $link suffix } { $link push } }
-    { { $link but-last } { $link pop* } }
-    { { $link unclip-last } { $link pop } }
-    { { $link remove } { $link delete } }
-    { { $link remq } { $link delq } }
-    { { $link remove-nth } { $link delete-nth } }
-    { { $link reverse } { $link reverse-here } }
-    { { $link append } { $link push-all } }
-    { { $link map } { $link change-each } }
-    { { $link filter } { $link filter-here } }
-}
 { $heading "Related Articles" }
 { $subsections
     "sequences-destructive-discussion"
     "sequences-stacks"
 }
-{ $see-also set-nth push pop } ;
+{ $see-also set-nth push push-all pop pop* } ;
 
 ARTICLE: "sequences-stacks" "Treating sequences as stacks"
 "The classical stack operations, modifying a sequence in place:"
-{ $subsections push pop pop* }
+{ $subsections push push-all pop pop* }
 { $see-also empty? } ;
 
 ARTICLE: "sequences-comparing" "Comparing sequences"
index e36bfaf9d24e4d92063a958e3da2453491cafade..c82caec3f9769772d61069f7a01fba6b122e7f23 100644 (file)
@@ -24,6 +24,12 @@ IN: sequences.tests
 [ 5040 { 1 1 2 6 24 120 720 } ]
 [ { 1 2 3 4 5 6 7 } 1 [ * ] accumulate ] unit-test
 
+[ 5040 { 1 1 2 6 24 120 720 } ]
+[ { 1 2 3 4 5 6 7 } 1 [ * ] accumulate! ] unit-test
+
+[ t ]
+[ { 1 2 3 4 5 6 7 } dup 1 [ * ] accumulate! nip eq? ] unit-test
+
 [ f f ] [ [ ] [ ] find ] unit-test
 [ 0 1 ] [ [ 1 ] [ ] find ] unit-test
 [ 1 "world" ] [ [ "hello" "world" ] [ "world" = ] find ] unit-test
@@ -42,7 +48,7 @@ IN: sequences.tests
 [ t ] [ 2 [ 1 2 ] member? ] unit-test
 
 [ t ]
-[ [ "hello" "world" ] [ second ] keep memq? ] unit-test
+[ [ "hello" "world" ] [ second ] keep member-eq? ] unit-test
 
 [ 4 ] [ CHAR: x "tuvwxyz" >vector index ] unit-test 
 
@@ -59,10 +65,10 @@ IN: sequences.tests
 
 [ [ 3 ] ] [ [ 1 2 3 ] 2 [ swap < ] curry filter ] unit-test
 
-[ V{ 1 2 3 } ] [ V{ 1 4 2 5 3 6 } clone [ [ 4 < ] filter-here ] keep ] unit-test
-[ V{ 4 2 6 } ] [ V{ 1 4 2 5 3 6 } clone [ [ 2 mod 0 = ] filter-here ] keep ] unit-test
+[ V{ 1 2 3 } ] [ V{ 1 4 2 5 3 6 } clone [ 4 < ] filter! ] unit-test
+[ V{ 4 2 6 } ] [ V{ 1 4 2 5 3 6 } clone [ 2 mod 0 = ] filter! ] unit-test
 
-[ V{ 3 } ] [ V{ 1 2 3 } clone [ 2 [ swap < ] curry filter-here ] keep ] unit-test
+[ V{ 3 } ] [ V{ 1 2 3 } clone 2 [ swap < ] curry filter! ] unit-test
 
 [ "hello world how are you" ]
 [ { "hello" "world" "how" "are" "you" } " " join ]
@@ -126,11 +132,11 @@ unit-test
 [ 4 [ CHAR: a <string> ] map ]
 unit-test
 
-[ V{ } ] [ "f" V{ } clone [ delete ] keep ] unit-test
-[ V{ } ] [ "f" V{ "f" } clone [ delete ] keep ] unit-test
-[ V{ } ] [ "f" V{ "f" "f" } clone [ delete ] keep ] unit-test
-[ V{ "x" } ] [ "f" V{ "f" "x" "f" } clone [ delete ] keep ] unit-test
-[ V{ "y" "x" } ] [ "f" V{ "y" "f" "x" "f" } clone [ delete ] keep ] unit-test
+[ V{ } ] [ "f" V{ } clone remove! ] unit-test
+[ V{ } ] [ "f" V{ "f" } clone remove! ] unit-test
+[ V{ } ] [ "f" V{ "f" "f" } clone remove! ] unit-test
+[ V{ "x" } ] [ "f" V{ "f" "x" "f" } clone remove! ] unit-test
+[ V{ "y" "x" } ] [ "f" V{ "y" "f" "x" "f" } clone remove! ] unit-test
 
 [ V{ 0 1 4 5 } ] [ 6 >vector 2 4 pick delete-slice ] unit-test
 
@@ -162,7 +168,7 @@ unit-test
     { "a" } 0 2 { 1 2 3 } replace-slice
 ] unit-test
 
-[ { 1 4 9 } ] [ { 1 2 3 } clone dup [ sq ] change-each ] unit-test
+[ { 1 4 9 } ] [ { 1 2 3 } clone [ sq ] map! ] unit-test
 
 [ 5 ] [ 1 >bignum { 1 5 7 } nth-unsafe ] unit-test
 [ 5 ] [ 1 >bignum { 1 5 7 } nth-unsafe ] unit-test
@@ -207,7 +213,7 @@ unit-test
 [ 10 "hi" "bye" copy ] must-fail
 
 [ V{ 1 2 3 5 6 } ] [
-    3 V{ 1 2 3 4 5 6 } clone [ delete-nth ] keep
+    3 V{ 1 2 3 4 5 6 } clone remove-nth!
 ] unit-test
 
 ! erg's random tester found this one
@@ -227,7 +233,7 @@ unit-test
 [ -3 10 nth ] must-fail
 [ 11 10 nth ] must-fail
 
-[ -1/0. 0 delete-nth ] must-fail
+[ -1/0. 0 remove-nth! ] must-fail
 [ "" ] [ "" [ CHAR: \s = ] trim ] unit-test
 [ "" ] [ "" [ CHAR: \s = ] trim-head ] unit-test
 [ "" ] [ "" [ CHAR: \s = ] trim-tail ] unit-test
@@ -237,7 +243,7 @@ unit-test
 [ "asdf " ] [ " asdf " [ CHAR: \s = ] trim-head ] unit-test
 [ " asdf" ] [ " asdf " [ CHAR: \s = ] trim-tail ] unit-test
 
-[ 328350 ] [ 100 [ sq ] sigma ] unit-test
+[ 328350 ] [ 100 [ sq ] map-sum ] unit-test
 
 [ 50 ] [ 100 [ even? ] count ] unit-test
 [ 50 ] [ 100 [ odd?  ] count ] unit-test
index c64095cb736231d7edfe01e5b571302b33ff0cc3..5017e52ce577fa6c49297b9545c9cc94b3f9ea34 100755 (executable)
@@ -170,27 +170,27 @@ PRIVATE>
     4 swap [ (4sequence) ] new-like ; inline
 
 : first2 ( seq -- first second )
-    1 swap bounds-check nip first2-unsafe ; flushable
+    1 swap bounds-check nip first2-unsafe ; inline
 
 : first3 ( seq -- first second third )
-    2 swap bounds-check nip first3-unsafe ; flushable
+    2 swap bounds-check nip first3-unsafe ; inline
 
 : first4 ( seq -- first second third fourth )
-    3 swap bounds-check nip first4-unsafe ; flushable
+    3 swap bounds-check nip first4-unsafe ; inline
 
 : ?nth ( n seq -- elt/f )
     2dup bounds-check? [ nth-unsafe ] [ 2drop f ] if ; inline
 
 MIXIN: virtual-sequence
-GENERIC: virtual-seq ( seq -- seq' )
+GENERIC: virtual-exemplar ( seq -- seq' )
 GENERIC: virtual@ ( n seq -- n' seq' )
 
 M: virtual-sequence nth virtual@ nth ; inline
 M: virtual-sequence set-nth virtual@ set-nth ; inline
 M: virtual-sequence nth-unsafe virtual@ nth-unsafe ; inline
 M: virtual-sequence set-nth-unsafe virtual@ set-nth-unsafe ; inline
-M: virtual-sequence like virtual-seq like ; inline
-M: virtual-sequence new-sequence virtual-seq new-sequence ; inline
+M: virtual-sequence like virtual-exemplar like ; inline
+M: virtual-sequence new-sequence virtual-exemplar new-sequence ; inline
 
 INSTANCE: virtual-sequence sequence
 
@@ -199,7 +199,7 @@ TUPLE: reversed { seq read-only } ;
 
 C: <reversed> reversed
 
-M: reversed virtual-seq seq>> ; inline
+M: reversed virtual-exemplar seq>> ; inline
 M: reversed virtual@ seq>> [ length swap - 1 - ] keep ; inline
 M: reversed length seq>> length ; inline
 
@@ -231,7 +231,7 @@ TUPLE: slice-error from to seq reason ;
     check-slice
     slice boa ; inline
 
-M: slice virtual-seq seq>> ; inline
+M: slice virtual-exemplar seq>> ; inline
 
 M: slice virtual@ [ from>> + ] [ seq>> ] bi ; inline
 
@@ -268,33 +268,36 @@ INSTANCE: repetition immutable-sequence
 ERROR: integer-length-expected obj ;
 
 : check-length ( n -- n )
-    #! Ricing.
     dup integer? [ integer-length-expected ] unless ; inline
 
-: ((copy)) ( dst i src j n -- dst i src j n )
-    dup -roll [
-        + swap nth-unsafe -roll [
-            + swap set-nth-unsafe
-        ] 3keep drop
-    ] 3keep ; inline
+TUPLE: copy-state
+    { src-i read-only }
+    { src read-only }
+    { dst-i read-only }
+    { dst read-only } ;
 
-: (copy) ( dst i src j n -- dst )
-    dup 0 <= [ 2drop 2drop ] [ 1 - ((copy)) (copy) ] if ;
+C: <copy> copy-state
+
+: ((copy)) ( n copy -- )
+    [ [ src-i>> + ] [ src>> ] bi nth-unsafe ]
+    [ [ dst-i>> + ] [ dst>> ] bi set-nth-unsafe ] 2bi ; inline
+
+: (copy) ( n copy -- dst )
+    over 0 <= [ nip dst>> ] [ [ 1 - ] dip [ ((copy)) ] [ (copy) ] 2bi ] if ;
     inline recursive
 
-: prepare-subseq ( from to seq -- dst i src j n )
-    #! The check-length call forces partial dispatch
-    [ [ swap - ] dip new-sequence dup 0 ] 3keep
-    -rot drop roll length check-length ; inline
+: subseq>copy ( from to seq -- n copy )
+    [ over - check-length swap ] dip
+    3dup nip new-sequence 0 swap <copy> ; inline
 
-: check-copy ( src n dst -- )
-    over 0 < [ bounds-error ] when
+: check-copy ( src n dst -- src n dst )
+    3dup over 0 < [ bounds-error ] when
     [ swap length + ] dip lengthen ; inline
 
 PRIVATE>
 
 : subseq ( from to seq -- subseq )
-    [ check-slice prepare-subseq (copy) ] keep like ;
+    [ check-slice subseq>copy (copy) ] keep like ;
 
 : head ( seq n -- headseq ) (head) subseq ;
 
@@ -310,8 +313,8 @@ PRIVATE>
 
 : copy ( src i dst -- )
     #! The check-length call forces partial dispatch
-    pick length check-length [ 3dup check-copy spin 0 ] dip
-    (copy) drop ; inline
+    [ [ length check-length 0 ] keep ] 2dip
+    check-copy <copy> (copy) drop ; inline
 
 M: sequence clone-like
     [ dup length ] dip new-sequence [ 0 swap copy ] keep ; inline
@@ -429,15 +432,21 @@ PRIVATE>
 : replicate-as ( seq quot exemplar -- newseq )
     [ [ drop ] prepose ] dip map-as ; inline
 
-: change-each ( seq quot -- )
-    over map-into ; inline
+: map! ( seq quot -- seq )
+    over [ map-into ] keep ; inline
+
+: (accumulate) ( seq identity quot -- seq identity quot )
+    [ swap ] dip [ curry keep ] curry ; inline
 
 : accumulate-as ( seq identity quot exemplar -- final newseq )
-    [ [ swap ] dip [ curry keep ] curry ] dip map-as ; inline
+    [ (accumulate) ] dip map-as ; inline
 
 : accumulate ( seq identity quot -- final newseq )
     { } accumulate-as ; inline
 
+: accumulate! ( seq identity quot -- final seq )
+    (accumulate) map! ; inline
+
 : 2each ( seq1 seq2 quot -- )
     (2each) each-integer ; inline
 
@@ -483,11 +492,17 @@ PRIVATE>
 : push-if ( elt quot accum -- )
     [ keep ] dip rot [ push ] [ 2drop ] if ; inline
 
+: pusher-for ( quot exemplar -- quot accum )
+    [ length ] keep new-resizable [ [ push-if ] 2curry ] keep ; inline
+
 : pusher ( quot -- quot accum )
-    V{ } clone [ [ push-if ] 2curry ] keep ; inline
+    V{ } pusher-for ; inline
+
+: filter-as ( seq quot exemplar -- subseq )
+    dup [ pusher-for [ each ] dip ] curry dip like ; inline
 
 : filter ( seq quot -- subseq )
-    over [ pusher [ each ] dip ] dip like ; inline
+    over filter-as ; inline
 
 : push-either ( elt quot accum1 accum2 -- )
     [ keep swap ] 2dip ? push ; inline
@@ -498,11 +513,14 @@ PRIVATE>
 : partition ( seq quot -- trueseq falseseq )
     over [ 2pusher [ each ] 2dip ] dip [ like ] curry bi@ ; inline
 
+: accumulator-for ( quot exemplar -- quot' vec )
+    [ length ] keep new-resizable [ [ push ] curry compose ] keep ; inline
+
 : accumulator ( quot -- quot' vec )
-    V{ } clone [ [ push ] curry compose ] keep ; inline
+    V{ } accumulator-for ; inline
 
 : produce-as ( pred quot exemplar -- seq )
-    [ accumulator [ while ] dip ] dip like ; inline
+    dup [ accumulator-for [ while ] dip ] curry dip like ; inline
 
 : produce ( pred quot -- seq )
     { } produce-as ; inline
@@ -558,13 +576,13 @@ PRIVATE>
 : member? ( elt seq -- ? )
     [ = ] with any? ;
 
-: memq? ( elt seq -- ? )
+: member-eq? ( elt seq -- ? )
     [ eq? ] with any? ;
 
 : remove ( elt seq -- newseq )
     [ = not ] with filter ;
 
-: remq ( elt seq -- newseq )
+: remove-eq ( elt seq -- newseq )
     [ eq? not ] with filter ;
 
 : sift ( seq -- newseq )
@@ -610,24 +628,24 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ;
 
 <PRIVATE
 
-: (filter-here) ( quot: ( elt -- ? ) store scan seq -- )
+: (filter!) ( quot: ( elt -- ? ) store scan seq -- )
     2dup length < [
         [ move ] 3keep
         [ nth-unsafe pick call [ 1 + ] when ] 2keep
         [ 1 + ] dip
-        (filter-here)
+        (filter!)
     ] [ nip set-length drop ] if ; inline recursive
 
 PRIVATE>
 
-: filter-here ( seq quot -- )
-    swap [ 0 0 ] dip (filter-here) ; inline
+: filter! ( seq quot -- seq )
+    swap [ [ 0 0 ] dip (filter!) ] keep ; inline
 
-: delete ( elt seq -- )
-    [ = not ] with filter-here ;
+: remove! ( elt seq -- seq )
+    [ = not ] with filter! ;
 
-: delq ( elt seq -- )
-    [ eq? not ] with filter-here ;
+: remove-eq! ( elt seq -- seq )
+    [ eq? not ] with filter! ;
 
 : prefix ( seq elt -- newseq )
     over [ over length 1 + ] dip [
@@ -641,6 +659,10 @@ PRIVATE>
         [ 0 swap copy ] keep
     ] new-like ;
 
+: suffix! ( seq elt -- seq ) over push ; inline
+
+: append! ( seq1 seq2 -- seq1 ) over push-all ; inline
+
 : last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
 
 : set-last ( elt seq -- ) [ length 1 - ] keep set-nth ;
@@ -686,8 +708,8 @@ PRIVATE>
 : delete-slice ( from to seq -- )
     check-slice [ over [ - ] dip ] dip open-slice ;
 
-: delete-nth ( n seq -- )
-    [ dup 1 + ] dip delete-slice ;
+: remove-nth! ( n seq -- seq )
+    [ [ dup 1 + ] dip delete-slice ] keep ;
 
 : snip ( from to seq -- head tail )
     [ swap head ] [ swap tail ] bi-curry bi* ; inline
@@ -710,15 +732,16 @@ PRIVATE>
     [ exchange-unsafe ]
     3tri ;
 
-: reverse-here ( seq -- )
-    [ length 2/ iota ] [ length ] [ ] tri
-    [ [ over - 1 - ] dip exchange-unsafe ] 2curry each ;
+: reverse! ( seq -- seq )
+    [
+        [ length 2/ iota ] [ length ] [ ] tri
+        [ [ over - 1 - ] dip exchange-unsafe ] 2curry each
+    ] keep ;
 
 : reverse ( seq -- newseq )
     [
         dup [ length ] keep new-sequence
-        [ 0 swap copy ] keep
-        [ reverse-here ] keep
+        [ 0 swap copy ] keep reverse!
     ] keep like ;
 
 : sum-lengths ( seq -- n )
@@ -727,7 +750,7 @@ PRIVATE>
 : concat-as ( seq exemplar -- newseq )
     swap [ { } ] [
         [ sum-lengths over new-resizable ] keep
-        [ over push-all ] each
+        [ append! ] each
     ] if-empty swap like ;
 
 : concat ( seq -- newseq )
@@ -914,10 +937,10 @@ PRIVATE>
 
 : supremum ( seq -- n ) [ ] [ max ] map-reduce ;
 
-: sigma ( seq quot -- n )
+: map-sum ( seq quot -- n )
     [ 0 ] 2dip [ dip + ] curry [ swap ] prepose each ; inline
 
-: count ( seq quot -- n ) [ 1 0 ? ] compose sigma ; inline
+: count ( seq quot -- n ) [ 1 0 ? ] compose map-sum ; inline
 
 ! We hand-optimize flip to such a degree because type hints
 ! cannot express that an array is an array of arrays yet, and
index 26bfc140fbe2e29332bbd274892313a6ca2b305e..999e963f36d9fdb2eacf40ca4682f13c56066f25 100755 (executable)
@@ -32,7 +32,7 @@ $nl
     conjoin
     conjoin-at
 }
-{ $see-also member? memq? any? all? "assocs-sets" } ;
+{ $see-also member? member-eq? any? all? "assocs-sets" } ;
 
 ABOUT: "sets"
 
index c7b834297adab9ebce2bf0e973bfea68fc4dc29d..38c1f73bb372eca032898c05a90349bbfea3d00e 100755 (executable)
@@ -3,7 +3,7 @@
 USING: assocs hashtables kernel sequences vectors ;
 IN: sets
 
-: adjoin ( elt seq -- ) [ delete ] [ push ] 2bi ;
+: adjoin ( elt seq -- ) [ remove! drop ] [ push ] 2bi ;
 
 : conjoin ( elt assoc -- ) dupd set-at ;
 
index ce29c14b01260d899558787d438b993dd477b2f4..92b34db6ecaf9da714257751e3ac1025563bd342 100644 (file)
@@ -71,7 +71,7 @@ $nl
     { { { $link float } } { $snippet "0.0" } }
     { { { $link string } } { $snippet "\"\"" } }
     { { { $link byte-array } } { $snippet "B{ }" } }
-    { { { $link simple-alien } } { $snippet "BAD-ALIEN" } }
+    { { { $link pinned-alien } } { $snippet "BAD-ALIEN" } }
 }
 "All other classes are handled with one of two cases:"
 { $list
index 95a854f4936fdaea90f636b6f6ed41ec5bf86728..0422478884d9de0d51f056fa24f00c6596a31284 100755 (executable)
@@ -173,7 +173,7 @@ M: class initial-value* no-initial-value ;
         { [ string bootstrap-word over class<= ] [ "" ] }
         { [ array bootstrap-word over class<= ] [ { } ] }
         { [ byte-array bootstrap-word over class<= ] [ B{ } ] }
-        { [ simple-alien bootstrap-word over class<= ] [ <bad-alien> ] }
+        { [ pinned-alien bootstrap-word over class<= ] [ <bad-alien> ] }
         { [ quotation bootstrap-word over class<= ] [ [ ] ] }
         [ dup initial-value* ]
     } cond nip ;
index f5c41285ee31c504c912749d24524fe4e1a094d9..4f5473ce9de921869ee2e94e7245102c19d90943 100644 (file)
@@ -17,6 +17,7 @@ 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 ;
+M: source-file-error compute-restarts error>> compute-restarts ;
 
 : sort-errors ( errors -- alist )
     [ [ line#>> ] sort-with ] { } assoc-map-as sort-keys ;
@@ -71,7 +72,7 @@ SYMBOL: error-observers
 
 : add-error-observer ( observer -- ) error-observers get push ;
 
-: remove-error-observer ( observer -- ) error-observers get delq ;
+: remove-error-observer ( observer -- ) error-observers get remove-eq! drop ;
 
 : notify-error-observers ( -- ) error-observers get [ errors-changed ] each ;
 
@@ -79,7 +80,7 @@ SYMBOL: error-observers
     [
         [ swap file>> = ] [ swap error-type = ]
         bi-curry* bi and not
-    ] 2curry filter-here
+    ] 2curry filter! drop
     notify-error-observers ;
 
 : delete-definition-errors ( definition -- )
index ef19d1635179f73fb6d943e87fa930167b5183e0..cb1e5e601708bde181a255f6d134f01d3c654c0c 100644 (file)
@@ -38,7 +38,7 @@ HELP: source-file
 } ;
 
 HELP: record-checksum
-{ $values { "source-file" source-file } { "lines" "a sequence of strings" } }
+{ $values { "lines" "a sequence of strings" } { "source-file" source-file } }
 { $description "Records the CRC32 checksm of the source file's contents." } 
 $low-level-note ;
 
index 558018a147d404fef479c267564c1c1319fbfa65..4991a0860a6fde24f9fd88e58c6ba375bafc1479 100644 (file)
@@ -3,7 +3,7 @@
 USING: arrays definitions generic assocs kernel math namespaces
 sequences strings vectors words quotations io io.files
 io.pathnames combinators sorting splitting math.parser effects
-continuations checksums checksums.crc32 vocabs hashtables graphs
+continuations checksums checksums.crc32 vocabs hashtables
 compiler.units io.encodings.utf8 accessors source-files.errors ;
 IN: source-files
 
index 10fea15a6499bf082571d87bb2ead8401919d3e3..50855713121181367d318f1c2bb49efafce9ce1c 100644 (file)
@@ -13,6 +13,7 @@ ARTICLE: "sequences-split" "Splitting sequences"
     split1-last
     split1-last-slice
     split
+    split-when
 }
 "Splitting a string into lines:"
 { $subsections string-lines } ;
@@ -37,9 +38,14 @@ HELP: split1-last-slice
 
 { split1 split1-slice split1-last split1-last-slice } related-words
 
+HELP: split-when
+{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- ? )" } } { "pieces" "a new array" } }
+{ $description "Splits " { $snippet "seq" } " at each occurrence of an element for which " { $snippet "quot" } " gives a true output and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
+{ $examples { $example "USING: ascii kernel prettyprint splitting ;" "\"hello,world-how.are:you\" [ letter? not ] split-when ." "{ \"hello\" \"world\" \"how\" \"are\" \"you\" }" } } ;
+
 HELP: split
 { $values { "seq" "a sequence" } { "separators" "a sequence" } { "pieces" "a new array" } }
-{ $description "Splits " { $snippet "seq" } " at each occurrence of an element of " { $snippet "separators" } ", and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
+{ $description "Splits " { $snippet "seq" } " at each occurrence of an element of " { $snippet "separators" } " and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
 { $examples { $example "USING: prettyprint splitting ;" "\"hello world-how are you?\" \" -\" split ." "{ \"hello\" \"world\" \"how\" \"are\" \"you?\" }" } } ;
 
 HELP: ?head
index ed68038fa6ddc5579c48fc0c93cda31cec0772ac..e672624d9677363893a7704648b205b431f761c6 100644 (file)
@@ -1,4 +1,4 @@
-USING: splitting tools.test kernel sequences arrays strings ;
+USING: splitting tools.test kernel sequences arrays strings ascii ;
 IN: splitting.tests
 
 [ "hello" "world ." ] [ "hello world ." " " split1 ] unit-test
@@ -57,3 +57,6 @@ unit-test
 [ { "hello" "hi" } ] [ "hello\nhi" string-lines ] unit-test
 [ { "hello" "hi" } ] [ "hello\rhi" string-lines ] unit-test
 [ { "hello" "hi" } ] [ "hello\r\nhi" string-lines ] unit-test
+
+[ { "hey" "world" "what's" "happening" } ]
+[ "heyAworldBwhat'sChappening" [ LETTER? ] split-when ] unit-test
index 7aae30f20b356667fab9f1ef25ee456ff7ecc93d..7b805dffe55a2b169b87821c5329e4ae2a36eb2d 100644 (file)
@@ -55,17 +55,21 @@ PRIVATE>
 
 <PRIVATE
 
-: (split) ( separators n seq -- )
-    3dup rot [ member? ] curry find-from drop
-    [ [ swap subseq , ] 2keep 1 + swap (split) ]
-    [ swap [ tail ] unless-zero , drop ] if* ; inline recursive
+: (split) ( n seq quot: ( elt -- ? ) -- )
+    [ find-from drop ]
+    [ [ [ 3dup swapd subseq , ] dip [ drop 1 + ] 2dip (split) ] 3curry ]
+    [ drop [ swap [ tail ] unless-zero , ] 2curry ]
+    3tri if* ; inline recursive
 
-: split, ( seq separators -- ) 0 rot (split) ;
+: split, ( seq quot -- ) [ 0 ] 2dip (split) ; inline
 
 PRIVATE>
 
 : split ( seq separators -- pieces )
-    [ split, ] { } make ;
+    [ [ member? ] curry split, ] { } make ;
+
+: split-when ( seq quot -- pieces )
+    [ split, ] { } make ; inline
 
 GENERIC: string-lines ( str -- seq )
 
index 22bf7bb821ba26dcd87cd47873724f786a14fc91..689d88be7156cc2c1b60ad09df47e4cf5456f3ce 100644 (file)
@@ -86,7 +86,7 @@ unit-test
 ] unit-test
 
 ! Make sure we clear aux vector when storing octets
-[ "\u123456hi" ] [ "ih\u123456" clone dup reverse-here ] unit-test
+[ "\u123456hi" ] [ "ih\u123456" clone reverse! ] unit-test
 
 ! Make sure aux vector is not shared
 [ "\udeadbe" ] [
index 2a8bf53e64bfbf23e092d08d3ddbf827a6513f67..e0b6c1acb9afc4ab53597bb11fb8cddc7d1864eb 100644 (file)
@@ -106,7 +106,7 @@ ARTICLE: "syntax-numbers" "Number syntax"
 } ;
 
 ARTICLE: "syntax-words" "Word syntax"
-"A word occurring inside a quotation is executed when the quotation is called. Sometimes a word needs to be pushed on the data stack instead. The canonical use-case for this is passing the word to the " { $link execute } " combinator, or alternatively, reflectively accessing word properties (" { $link "word-props" } ")."
+"A word occurring inside a quotation is executed when the quotation is called. Sometimes a word needs to be pushed on the data stack instead. The canonical use case for this is passing the word to the " { $link execute } " combinator, or alternatively, reflectively accessing word properties (" { $link "word-props" } ")."
 { $subsections
     POSTPONE: \
     POSTPONE: POSTPONE:
index 80c7a42f30534d32a933ac01c02246072282d457..dfb3e0bc1054b93e981a7770b0bdfb462b56e615 100644 (file)
@@ -73,9 +73,9 @@ IN: bootstrap.syntax
     "OCT:" [ 8 parse-base ] define-core-syntax
     "BIN:" [ 2 parse-base ] define-core-syntax
 
-    "NAN:" [ 16 scan-base <fp-nan> parsed ] define-core-syntax
+    "NAN:" [ 16 scan-base <fp-nan> suffix! ] define-core-syntax
 
-    "f" [ f parsed ] define-core-syntax
+    "f" [ f suffix! ] define-core-syntax
     "t" "syntax" lookup define-singleton-class
 
     "CHAR:" [
@@ -83,31 +83,31 @@ IN: bootstrap.syntax
             { [ dup length 1 = ] [ first ] }
             { [ "\\" ?head ] [ next-escape >string "" assert= ] }
             [ name>char-hook get call( name -- char ) ]
-        } cond parsed
+        } cond suffix!
     ] define-core-syntax
 
-    "\"" [ parse-multiline-string parsed ] define-core-syntax
+    "\"" [ parse-multiline-string suffix! ] define-core-syntax
 
     "SBUF\"" [
-        lexer get skip-blank parse-string >sbuf parsed
+        lexer get skip-blank parse-string >sbuf suffix!
     ] define-core-syntax
 
     "P\"" [
-        lexer get skip-blank parse-string <pathname> parsed
+        lexer get skip-blank parse-string <pathname> suffix!
     ] define-core-syntax
 
-    "[" [ parse-quotation parsed ] define-core-syntax
+    "[" [ parse-quotation suffix! ] define-core-syntax
     "{" [ \ } [ >array ] parse-literal ] define-core-syntax
     "V{" [ \ } [ >vector ] parse-literal ] define-core-syntax
     "B{" [ \ } [ >byte-array ] parse-literal ] define-core-syntax
     "BV{" [ \ } [ >byte-vector ] parse-literal ] define-core-syntax
     "H{" [ \ } [ >hashtable ] parse-literal ] define-core-syntax
-    "T{" [ parse-tuple-literal parsed ] define-core-syntax
+    "T{" [ parse-tuple-literal suffix! ] define-core-syntax
     "W{" [ \ } [ first <wrapper> ] parse-literal ] define-core-syntax
 
-    "POSTPONE:" [ scan-word parsed ] define-core-syntax
-    "\\" [ scan-word <wrapper> parsed ] define-core-syntax
-    "M\\" [ scan-word scan-word method <wrapper> parsed ] define-core-syntax
+    "POSTPONE:" [ scan-word suffix! ] define-core-syntax
+    "\\" [ scan-word <wrapper> suffix! ] define-core-syntax
+    "M\\" [ scan-word scan-word method <wrapper> suffix! ] define-core-syntax
     "inline" [ word make-inline ] define-core-syntax
     "recursive" [ word make-recursive ] define-core-syntax
     "foldable" [ word make-foldable ] define-core-syntax
@@ -227,7 +227,7 @@ IN: bootstrap.syntax
     ] define-core-syntax
 
     "((" [
-        "))" parse-effect parsed
+        "))" parse-effect suffix!
     ] define-core-syntax
 
     "MAIN:" [ scan-word current-vocab (>>main) ] define-core-syntax
@@ -240,8 +240,8 @@ IN: bootstrap.syntax
 
     "call-next-method" [
         current-method get [
-            literalize parsed
-            \ (call-next-method) parsed
+            literalize suffix!
+            \ (call-next-method) suffix!
         ] [
             not-in-a-method-error
         ] if*
index 352ccdebd45fa2d864265aabc59819aec54cafbe..02a604ac320cdc9bc8c3610386f1ea390e2c65d6 100644 (file)
@@ -102,7 +102,7 @@ HELP: load-docs
 
 HELP: reload
 { $values { "name" "a vocabulary name" } }
-{ $description "Loads it's source code and documentation." }
+{ $description "Reloads the source code and documentation for a vocabulary." }
 { $errors "Throws a " { $link no-vocab } " error if the vocabulary does not exist on disk." } ;
 
 HELP: require
index 2fc9d05d79e13a5910c49e8f4c427311492ae2b1..7ca2027ec2a7af9d5cd3fe1670fefab1a5cd976f 100755 (executable)
@@ -129,7 +129,7 @@ TUPLE: no-current-vocab ;
 : unuse-vocab ( vocab -- )
     dup using-vocab? [
         manifest get
-        [ [ load-vocab ] dip search-vocabs>> delq ]
+        [ [ load-vocab ] dip search-vocabs>> remove-eq! drop ]
         [ [ vocab-name ] dip search-vocab-names>> delete-at ]
         2bi
     ] [ drop ] if ;
@@ -172,7 +172,7 @@ TUPLE: rename word vocab words ;
 
 : use-words ( assoc -- ) (use-words) push ;
 
-: unuse-words ( assoc -- ) (use-words) delete ;
+: unuse-words ( assoc -- ) (use-words) remove! drop ;
 
 TUPLE: ambiguous-use-error words ;
 
index 671d1f82d2f0db37fe5c5c89b11c6ac8a4754e83..1c65e627d543e930b69291319e8b456b10956a84 100644 (file)
@@ -2,7 +2,7 @@ USING: help.markup help.syntax strings words compiler.units ;
 IN: vocabs
 
 ARTICLE: "vocabularies" "Vocabularies"
-"A " { $emphasis "vocabulary" } " is a named collection of words. Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
+"A " { $emphasis "vocabulary" } " is a named collection of " { $link "words" } ". Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
 $nl
 "Vocabularies are stored in a global hashtable:"
 { $subsections dictionary }
@@ -108,4 +108,4 @@ HELP: >vocab-link
 { $description "If the vocabulary is loaded, outputs the corresponding " { $link vocab } " instance, otherwise creates a new " { $link vocab-link } "." } ;
 
 HELP: runnable-vocab
-{ $class-description "The class of vocabularies with a " { $slot "main" } " word." } ;
\ No newline at end of file
+{ $class-description "The class of vocabularies with a " { $slot "main" } " word." } ;
index 914f1cd601c4d9bf1dcf3bf5236d5228ed2d34ba..239b88a2e80b6030285b0390602445a292072f7c 100644 (file)
@@ -73,7 +73,7 @@ GENERIC: vocabs-changed ( obj -- )
     vocab-observers get push ;
 
 : remove-vocab-observer ( obj -- )
-    vocab-observers get delq ;
+    vocab-observers get remove-eq! drop ;
 
 : notify-vocab-observers ( -- )
     vocab-observers get [ vocabs-changed ] each ;
@@ -131,4 +131,4 @@ SYMBOL: load-vocab-hook ! ( name -- vocab )
 PREDICATE: runnable-vocab < vocab
     vocab-main >boolean ;
 
-INSTANCE: vocab-spec definition
\ No newline at end of file
+INSTANCE: vocab-spec definition
index 19913f2ff7d51982b53a85c1da1bbcc79393fd64..a13bfb0740015a37f6949f5987de5f875446b213 100644 (file)
@@ -26,7 +26,7 @@ $nl
 } ;
 
 ARTICLE: "colon-definition" "Colon definitions"
-"Every word has an associated quotation definition that is called when the word is executed. A " { $emphasis "colon definition" } " is a word where this quotation is supplied directly by the user. This is the simplest and most common type of word definition."
+"All words have associated definition " { $link "quotations" } ". A word's definition quotation is called when the word is executed. A " { $emphasis "colon definition" } " is a word where this quotation is supplied directly by the user. This is the simplest and most common type of word definition."
 $nl
 "Defining words at parse time:"
 { $subsections
@@ -160,7 +160,7 @@ $nl
 } ;
 
 ARTICLE: "words" "Words"
-"Words are the Factor equivalent of functions or procedures; a word is essentially a named quotation."
+"Words are the Factor equivalent of functions or procedures in other languages. Words are essentially named " { $link "quotations" } "."
 $nl
 "There are two ways of creating word definitions:"
 { $list
@@ -238,7 +238,8 @@ $low-level-note
 
 HELP: <word> ( name vocab -- word )
 { $values { "name" string } { "vocab" string } { "word" word } }
-{ $description "Allocates an uninterned word with the specified name and vocabulary, and a blank word property hashtable. User code should call " { $link gensym } " to create uninterned words and " { $link create } " to create interned words." } ;
+{ $description "Allocates an uninterned word with the specified name and vocabulary, and a blank word property hashtable. User code should call " { $link gensym } " to create uninterned words and " { $link create } " to create interned words." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
 
 HELP: gensym
 { $values { "word" word } }
@@ -279,12 +280,14 @@ HELP: check-create
 
 HELP: create
 { $values { "name" string } { "vocab" string } { "word" word } }
-{ $description "Creates a new word. If the vocabulary already contains a word with the requested name, outputs the existing word. The vocabulary must exist already; if it does not, you must call " { $link create-vocab } " first." } ;
+{ $description "Creates a new word. If the vocabulary already contains a word with the requested name, outputs the existing word. The vocabulary must exist already; if it does not, you must call " { $link create-vocab } " first." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } ". Parsing words should call " { $link create-in } " instead of this word." } ;
 
 HELP: constructor-word
 { $values { "name" string } { "vocab" string } { "word" word } }
 { $description "Creates a new word, surrounding " { $snippet "name" } " in angle brackets." }
-{ $examples { $example "USING: prettyprint words ;" "\"salmon\" \"scratchpad\" constructor-word ." "<salmon>" } } ;
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
+{ $examples { $example "USING: compiler.units prettyprint words ;" "[ \"salmon\" \"scratchpad\" constructor-word ] with-compilation-unit ." "<salmon>" } } ;
 
 { POSTPONE: FORGET: forget forget* forget-vocab } related-words
 
index b9d6e80630af59151923deea6d7010afa573ddf3..cb4ecb1e06b7f523aaf7d14086556fffaf5f2473 100755 (executable)
@@ -1,7 +1,7 @@
 USING: arrays generic assocs kernel math namespaces
 sequences tools.test words definitions parser quotations
 vocabs continuations classes.tuple compiler.units
-io.streams.string accessors eval words.symbol ;
+io.streams.string accessors eval words.symbol grouping ;
 IN: words.tests
 
 [ 4 ] [
@@ -25,7 +25,8 @@ DEFER: plist-test
     \ plist-test "sample-property" word-prop
 ] unit-test
 
-"create-test" "scratchpad" create { 1 2 } "testing" set-word-prop
+[ ] [ [ "create-test" "scratchpad" create { 1 2 } "testing" set-word-prop ] with-compilation-unit ] unit-test
+
 [ { 1 2 } ] [
     "create-test" "scratchpad" lookup "testing" word-prop
 ] unit-test
@@ -33,7 +34,7 @@ DEFER: plist-test
 [
     [ t ] [ \ array? "array?" "arrays" lookup = ] unit-test
 
-    [ ] [ "test-scope" "scratchpad" create drop ] unit-test
+    [ ] [ [ "test-scope" "scratchpad" create drop ] with-compilation-unit ] unit-test
 ] with-scope
 
 [ "test-scope" ] [
@@ -67,7 +68,7 @@ FORGET: another-forgotten
 DEFER: x
 [ x ] [ undefined? ] must-fail-with
 
-[ ] [ "no-loc" "words.tests" create drop ] unit-test
+[ ] [ [ "no-loc" "words.tests" create drop ] with-compilation-unit ] unit-test
 [ f ] [ "no-loc" "words.tests" lookup where ] unit-test
 
 [ ] [ "IN: words.tests : no-loc-2 ( -- ) ;" eval( -- ) ] unit-test
@@ -121,7 +122,7 @@ DEFER: x
 [ { } ]
 [
     all-words [
-        "compiled-uses" word-prop
+        "compiled-uses" word-prop 2 <groups>
         keys [ "forgotten" word-prop ] filter
     ] map harvest
 ] unit-test
index 45e014f6be67f8720639a42820c495f68671f4fd..3dbfb3c864e776fdcdf1f0e0625df640a19fe39b 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays definitions graphs kernel
-kernel.private slots.private math namespaces sequences
-strings vectors sbufs quotations assocs hashtables sorting vocabs
-math.order sets words.private ;
+USING: accessors arrays definitions kernel kernel.private
+slots.private math namespaces sequences strings vectors sbufs
+quotations assocs hashtables sorting vocabs math.order sets
+words.private ;
 IN: words
 
 : word ( -- word ) \ word get-global ;
@@ -64,41 +64,6 @@ GENERIC: crossref? ( word -- ? )
 M: word crossref?
     dup "forgotten" word-prop [ drop f ] [ vocabulary>> >boolean ] if ;
 
-SYMBOL: compiled-crossref
-
-compiled-crossref [ H{ } clone ] initialize
-
-SYMBOL: compiled-generic-crossref
-
-compiled-generic-crossref [ H{ } clone ] initialize
-
-: (compiled-xref) ( word dependencies word-prop variable -- )
-    [ [ set-word-prop ] curry ]
-    [ [ get add-vertex* ] curry ]
-    bi* 2bi ;
-
-: compiled-xref ( word dependencies generic-dependencies -- )
-    [ [ drop crossref? ] { } assoc-filter-as f like ] bi@
-    [ "compiled-uses" compiled-crossref (compiled-xref) ]
-    [ "compiled-generic-uses" compiled-generic-crossref (compiled-xref) ]
-    bi-curry* bi ;
-
-: (compiled-unxref) ( word word-prop variable -- )
-    [ [ [ dupd word-prop ] dip get remove-vertex* ] 2curry ]
-    [ drop [ remove-word-prop ] curry ]
-    2bi bi ;
-
-: compiled-unxref ( word -- )
-    [ "compiled-uses" compiled-crossref (compiled-unxref) ]
-    [ "compiled-generic-uses" compiled-generic-crossref (compiled-unxref) ]
-    bi ;
-
-: delete-compiled-xref ( word -- )
-    [ compiled-unxref ]
-    [ compiled-crossref get delete-at ]
-    [ compiled-generic-crossref get delete-at ]
-    tri ;
-
 : inline? ( word -- ? ) "inline" word-prop ; inline
 
 GENERIC: subwords ( word -- seq )
@@ -170,10 +135,13 @@ M: word reset-word
     ] tri ;
 
 : <word> ( name vocab -- word )
-    2dup [ hashcode ] bi@ bitxor >fixnum (word) ;
+    2dup [ hashcode ] bi@ bitxor >fixnum (word) dup new-word ;
+
+: <uninterned-word> ( name -- word )
+    f \ <uninterned-word> counter >fixnum (word) ;
 
 : gensym ( -- word )
-    "( gensym )" f \ gensym counter >fixnum (word) ;
+    "( gensym )" <uninterned-word> ;
 
 : define-temp ( quot effect -- word )
     [ gensym dup ] 2dip define-declared ;
diff --git a/extra/4DNav/4DNav-docs.factor b/extra/4DNav/4DNav-docs.factor
deleted file mode 100755 (executable)
index 6f63f2e..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-! Copyright (C) 2008 Jean-François Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel quotations strings ;
-IN: 4DNav
-
-
-HELP: menu-3D
-{ $values
-     { "gadget" "gadget" }
-}
-{ $description "The menu dedicated to 3D movements of the camera" } ;
-
-HELP: menu-4D
-{ $values
-    
-     { "gadget" "gadget" }
-}
-{ $description "The menu dedicated to 4D movements of space" } ;
-
-HELP: menu-bar
-{ $values
-    
-     { "gadget" "gadget" }
-}
-{ $description "return gadget containing menu buttons" } ;
-
-HELP: model-projection
-{ $values
-     { "x" "interger" }
-     { "space" "space" }
-}
-{ $description "Project space following coordinate x" } ;
-
-HELP: mvt-3D-1
-{ $values
-    
-     { "quot" "quotation" }
-}
-{ $description "return a quotation to orientate space to see it from first point of view" } ;
-
-HELP: mvt-3D-2
-{ $values
-    
-     { "quot" "quotation" }
-}
-{ $description "return a quotation to orientate space to see it from second point of view" } ;
-
-HELP: mvt-3D-3
-{ $values
-    
-     { "quot" "quotation" }
-}
-{ $description "return a quotation to orientate space to see it from third point of view" } ;
-
-HELP: mvt-3D-4
-{ $values
-    
-     { "quot" "quotation" }
-}
-{ $description "return a quotation to orientate space to see it from first point of view" } ;
-
-HELP: load-model-file
-{ $description "load space from file" } ;
-
-HELP: rotation-4D
-{ $values
-     { "m" "a rotation matrix" }
-}
-{ $description "Apply a 4D rotation matrix" } ;
-
-HELP: translation-4D
-{ $values
-     { "v" "vector" }
-}
-{ $description "Apply a 4D translation" } ;
-
-
-ARTICLE: "implementation details" "How 4DNav is done"
-"4DNav is build using :"
-
-{ $subsections
-    "4DNav.camera"
-    "adsoda-main-page"
-}
-;
-
-ARTICLE: "Space file" "Create a new space file"
-"To build a new space, create an XML file using " { $vocab-link "adsoda" } " model description. A solid is not caracterized by its corners but is defined as the intersection of hyperplanes."
-
-$nl
-"An example is:"
-{ $code """
-<model>
-<space>
- <dimension>4</dimension>
- <solid>
-     <name>4cube1</name>
-     <dimension>4</dimension>
-     <face>1,0,0,0,100</face>
-     <face>-1,0,0,0,-150</face>
-     <face>0,1,0,0,100</face>
-     <face>0,-1,0,0,-150</face>
-     <face>0,0,1,0,100</face>
-     <face>0,0,-1,0,-150</face>
-     <face>0,0,0,1,100</face>
-     <face>0,0,0,-1,-150</face>
-     <color>1,0,0</color>
- </solid>
- <solid>
-     <name>4triancube</name>
-     <dimension>4</dimension>
-     <face>1,0,0,0,160</face>
-     <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>
-     <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>
-     <face>0,0,1,0,140</face>
-     <face>0,0,-1,0,-180</face>
-     <face>0,0,0,1,110</face>
-     <face>0,0,0,-1,-180</face>
-     <color>0,1,0</color>
- </solid>
- <solid>
-     <name>triangone</name>
-     <dimension>4</dimension>
-     <face>1,0,0,0,60</face>
-     <face>0.5,0.8660254037844386,0,0,60</face>
-     <face>-0.5,0.8660254037844387,0,0,-20</face>
-     <face>-1.0,0,0,0,-100</face>
-     <face>-0.5,-0.8660254037844384,0,0,-100</face>
-     <face>0.5,-0.8660254037844387,0,0,-20</face>
-     <face>0,0,1,0,120</face>
-     <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>
-     <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>
-     <color>0,1,1</color>
- </solid>
- <light>
-     <direction>1,1,1,1</direction>
-     <color>0.2,0.2,0.6</color>
- </light>
- <color>0.8,0.9,0.9</color>
-</space>
-</model>""" } ;
-
-ARTICLE: "TODO" "Todo"
-{ $list 
-    "A vocab to initialize parameters"
-    "an editor mode" 
-        { $list "add a face to a solid"
-                "add a solid to the space"
-                "move a face"
-                "move a solid"
-                "select a solid in a list"
-                "select a face"
-                "display selected face"
-                "edit a solid color"
-                "add a light"
-                "edit a light color"
-                "move a light"
-                }
-    "add a tool wich give an hyperplane normal vector with enought points. Will use adsoda.intersect-hyperplanes with { { 0 } { 0 } { 1 } } "
-    "decorrelate 3D camera and activate them with select buttons"
-
-} ;
-
-
-ARTICLE: "4DNav" "The 4DNav app"
-{ $vocab-link "4DNav" }
-$nl
-{ $heading "4D Navigator" }
-"4DNav is a simple tool to visualize 4 dimensionnal objects."
-$nl
-"It uses " { $vocab-link "adsoda" } " library to display a 4D space and navigate thru it."
-$nl
-"It will display:"
-{ $list
-    { "a menu window" }
-    {  "4 visualization windows" }
-}
-"Each visualization window represents the projection of the 4D space on a particular 3D space."
-
-{ $heading "Start" }
-"type:" { $code "\"4DNav\" run" } 
-
-{ $heading "Navigation" }
-"Menu window is divided in 4 areas"
-{ $list
-    { "a space-file chooser to select the file to display" }
-    { "a parametrization area to select the projection mode" }
-    { "4D submenu to translate and rotate the 4D space" }
-    { "3D submenu to move the camera in 3D space. Cameras in every 3D spaces are manipulated as a single one" }
-    }
-
-{ $heading "Links" }
-{ $subsections
-    "Space file"
-    "TODO"
-    "implementation details"
-}
-
-;
-
-ABOUT: "4DNav"
diff --git a/extra/4DNav/4DNav.factor b/extra/4DNav/4DNav.factor
deleted file mode 100755 (executable)
index b9679ec..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel \r
-namespaces\r
-accessors\r
-assocs\r
-make\r
-math\r
-math.functions\r
-math.trig\r
-math.parser\r
-hashtables\r
-sequences\r
-combinators\r
-continuations\r
-colors\r
-colors.constants\r
-prettyprint\r
-vars\r
-quotations\r
-io\r
-io.directories\r
-io.pathnames\r
-help.markup\r
-io.files\r
-ui.gadgets.panes\r
- ui\r
-       ui.gadgets\r
-       ui.traverse\r
-       ui.gadgets.borders\r
-       ui.gadgets.frames\r
-       ui.gadgets.tracks\r
-       ui.gadgets.labels\r
-       ui.gadgets.labeled       \r
-       ui.gadgets.lists\r
-       ui.gadgets.buttons\r
-       ui.gadgets.packs\r
-       ui.gadgets.grids\r
-       ui.gadgets.corners\r
-       ui.gestures\r
-       ui.gadgets.scrollers\r
-splitting\r
-vectors\r
-math.vectors\r
-values\r
-4DNav.turtle\r
-4DNav.window3D\r
-4DNav.deep\r
-4DNav.space-file-decoder\r
-models\r
-fry\r
-adsoda\r
-adsoda.tools\r
-;\r
-QUALIFIED-WITH: ui.pens.solid s\r
-QUALIFIED-WITH: ui.gadgets.wrappers w\r
-\r
-\r
-IN: 4DNav\r
-VALUE: selected-file\r
-VALUE: translation-step\r
-VALUE: rotation-step\r
-\r
-3 to: translation-step \r
-5 to: rotation-step\r
-\r
-VAR: selected-file-model\r
-VAR: observer3d \r
-VAR: view1 \r
-VAR: view2\r
-VAR: view3\r
-VAR: view4\r
-VAR: present-space\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-! namespace utilities\r
-\r
-: closed-quot ( quot -- quot )\r
-  namestack swap '[ namestack [ _ set-namestack @ ] dip set-namestack ] ;\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-! waiting for deep-cleave-quots\r
-\r
-: 4D-Rxy ( angle -- Rx ) deg>rad\r
-[ 1.0 , 0.0 , 0.0       , 0.0 ,\r
-  0.0 , 1.0 , 0.0       , 0.0 ,\r
-  0.0 , 0.0 , dup cos  , dup sin neg  ,\r
-  0.0 , 0.0 , dup sin  , dup cos  ,  ] 4 make-matrix nip ;\r
-\r
-: 4D-Rxz ( angle -- Ry ) deg>rad\r
-[ 1.0 , 0.0       , 0.0 , 0.0 ,\r
-  0.0 , dup cos  , 0.0 , dup sin neg  ,\r
-  0.0 , 0.0       , 1.0 , 0.0 ,\r
-  0.0 , dup sin  , 0.0 , dup cos  ,  ] 4 make-matrix nip ;\r
-\r
-: 4D-Rxw ( angle -- Rz ) deg>rad\r
-[ 1.0 , 0.0       , 0.0           , 0.0 ,\r
-  0.0 , dup cos  , dup sin neg  , 0.0 ,\r
-  0.0 , dup sin  , dup cos     , 0.0 ,\r
-  0.0 , 0.0       , 0.0           , 1.0 , ] 4 make-matrix nip ;\r
-\r
-: 4D-Ryz ( angle -- Rx ) deg>rad\r
-[ dup cos  , 0.0 , 0.0 , dup sin neg  ,\r
-  0.0       , 1.0 , 0.0 , 0.0 ,\r
-  0.0       , 0.0 , 1.0 , 0.0 ,\r
-  dup sin  , 0.0 , 0.0 , dup cos  ,   ] 4 make-matrix nip ;\r
-\r
-: 4D-Ryw ( angle -- Ry ) deg>rad\r
-[ dup cos  , 0.0 , dup sin neg  , 0.0 ,\r
-  0.0       , 1.0 , 0.0           , 0.0 ,\r
-  dup sin  , 0.0 , dup cos     , 0.0 ,\r
-  0.0       , 0.0 , 0.0        , 1.0 ,  ] 4 make-matrix nip ;\r
-\r
-: 4D-Rzw ( angle -- Rz ) deg>rad\r
-[ dup cos  , dup sin neg  , 0.0 , 0.0 ,\r
-  dup sin  , dup cos     , 0.0 , 0.0 ,\r
-  0.0       , 0.0           , 1.0 , 0.0 ,\r
-  0.0       , 0.0          , 0.0 , 1.0 ,  ] 4 make-matrix nip ;\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-! UI\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-: button* ( string quot -- button ) \r
-    closed-quot <repeat-button>  ;\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-! \r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-: model-projection-chooser ( -- gadget )\r
-   observer3d> projection-mode>>\r
-   { { 1 "perspective" } { 0 "orthogonal" } } \r
-   <radio-buttons> ;\r
-\r
-: collision-detection-chooser ( -- gadget )\r
-   observer3d> collision-mode>>\r
-   { { t "on" } { f "off" }  } <radio-buttons> ;\r
-\r
-: model-projection ( x -- space ) \r
-    present-space>  swap space-project ;\r
-\r
-: update-observer-projections (  -- )\r
-    view1> relayout-1 \r
-    view2> relayout-1 \r
-    view3> relayout-1 \r
-    view4> relayout-1 ;\r
-\r
-: update-model-projections (  -- )\r
-    0 model-projection <model> view1> (>>model)\r
-    1 model-projection <model> view2> (>>model)\r
-    2 model-projection <model> view3> (>>model)\r
-    3 model-projection <model> view4> (>>model) ;\r
-\r
-: camera-action ( quot -- quot ) \r
-    '[ drop _ observer3d>  \r
-    with-self update-observer-projections ] \r
-    closed-quot ;\r
-\r
-: win3D ( text gadget -- ) \r
-    "navigateur 4D : " rot append open-window ;\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-! 4D object manipulation\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-: (mvt-4D) ( quot -- )   \r
-    present-space>  \r
-        swap call space-ensure-solids \r
-    >present-space \r
-    update-model-projections \r
-    update-observer-projections ; inline\r
-\r
-: rotation-4D ( m -- ) \r
-    '[ _ [ [ middle-of-space dup vneg ] keep \r
-        swap space-translate ] dip\r
-         space-transform \r
-         swap space-translate\r
-    ] (mvt-4D) ;\r
-\r
-: translation-4D ( v -- ) '[ _ space-translate ] (mvt-4D) ;\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-! menu\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-: menu-rotations-4D ( -- gadget )\r
-    3 3 <frame>\r
-        { 1 1 } >>filled-cell\r
-         <pile> 1 >>fill\r
-          "XY +" [ drop rotation-step 4D-Rxy rotation-4D ] \r
-                button* add-gadget\r
-          "XY -" [ drop rotation-step neg 4D-Rxy rotation-4D ] \r
-                button* add-gadget \r
-       @top-left grid-add    \r
-        <pile> 1 >>fill\r
-          "XZ +" [ drop rotation-step 4D-Rxz rotation-4D ] \r
-                button* add-gadget\r
-          "XZ -" [ drop rotation-step neg 4D-Rxz rotation-4D ] \r
-                button* add-gadget \r
-       @top grid-add    \r
-        <pile> 1 >>fill\r
-          "YZ +" [ drop rotation-step 4D-Ryz rotation-4D ] \r
-                button* add-gadget\r
-          "YZ -" [ drop rotation-step neg 4D-Ryz rotation-4D ] \r
-                button* add-gadget \r
-        @center grid-add\r
-         <pile> 1 >>fill\r
-          "XW +" [ drop rotation-step 4D-Rxw rotation-4D ] \r
-                button* add-gadget\r
-          "XW -" [ drop rotation-step neg 4D-Rxw rotation-4D ] \r
-                button* add-gadget \r
-        @top-right grid-add   \r
-         <pile> 1 >>fill\r
-          "YW +" [ drop rotation-step 4D-Ryw rotation-4D ] \r
-                button* add-gadget\r
-          "YW -" [ drop rotation-step neg 4D-Ryw rotation-4D ] \r
-                button* add-gadget \r
-       @right grid-add    \r
-         <pile> 1 >>fill\r
-          "ZW +" [ drop rotation-step 4D-Rzw rotation-4D ] \r
-                button* add-gadget\r
-          "ZW -" [ drop rotation-step neg 4D-Rzw rotation-4D ] \r
-                button* add-gadget \r
-       @bottom-right grid-add    \r
-;\r
-\r
-: menu-translations-4D ( -- gadget )\r
-    3 3 <frame> \r
-        { 1 1 } >>filled-cell\r
-        <pile> 1 >>fill\r
-            <shelf> 1 >>fill  \r
-                "X+" [ drop {  1 0 0 0 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget\r
-                "X-" [ drop { -1 0 0 0 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget \r
-            add-gadget\r
-            "YZW" <label> add-gadget\r
-         @bottom-right grid-add\r
-         <pile> 1 >>fill\r
-            "XZW" <label> add-gadget\r
-            <shelf> 1 >>fill\r
-                "Y+" [ drop  { 0  1 0 0 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget\r
-                "Y-" [ drop  { 0 -1 0 0 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget \r
-                add-gadget\r
-         @top-right grid-add\r
-         <pile> 1 >>fill\r
-            "XYW" <label> add-gadget\r
-            <shelf> 1 >>fill\r
-                "Z+" [ drop { 0 0  1 0 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget\r
-                "Z-" [ drop { 0 0 -1 0 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget \r
-                add-gadget                 \r
-        @top-left grid-add     \r
-        <pile> 1 >>fill\r
-            <shelf> 1 >>fill\r
-                "W+" [ drop { 0 0 0 1  } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget\r
-                "W-" [ drop { 0 0 0 -1 } translation-step v*n \r
-                    translation-4D ] \r
-                    button* add-gadget \r
-                add-gadget\r
-            "XYZ" <label> add-gadget\r
-        @bottom-left grid-add \r
-        "X" <label> @center grid-add\r
-;\r
-\r
-: menu-4D ( -- gadget )  \r
-    <shelf> \r
-        "rotations" <label>     add-gadget\r
-        menu-rotations-4D       add-gadget\r
-        "translations" <label>  add-gadget\r
-        menu-translations-4D    add-gadget\r
-        0.5 >>align\r
-        { 0 10 } >>gap\r
-;\r
-\r
-\r
-! ------------------------------------------------------\r
-\r
-: redraw-model ( space -- )\r
-    >present-space \r
-    update-model-projections \r
-    update-observer-projections ;\r
-\r
-: load-model-file ( -- )\r
-  selected-file dup selected-file-model> set-model \r
-  read-model-file \r
-  redraw-model ;\r
-\r
-: mvt-3D-X ( turn pitch -- quot )\r
-    '[ turtle-pos> norm neg reset-turtle \r
-        _ turn-left \r
-        _ pitch-up \r
-        step-turtle ] ;\r
-\r
-: mvt-3D-1 ( -- quot )      90  0 mvt-3D-X ; inline\r
-: mvt-3D-2 ( -- quot )      0  90 mvt-3D-X ; inline\r
-: mvt-3D-3 ( -- quot )      0   0 mvt-3D-X ; inline\r
-: mvt-3D-4 ( -- quot )      45 45 mvt-3D-X ; inline\r
-\r
-: camera-button ( string quot -- button ) \r
-    [ <label>  ] dip camera-action <repeat-button> ;\r
-\r
-! ----------------------------------------------------------\r
-! file chooser\r
-! ----------------------------------------------------------\r
-: <run-file-button> ( file-name -- button )\r
-  dup '[ drop  _  \ selected-file set-value load-model-file \r
-   ] \r
- closed-quot  <roll-button> { 0 0 } >>align ;\r
-\r
-: <list-runner> ( -- gadget )\r
-    "resource:extra/4DNav" \r
-  <pile> 1 >>fill \r
-    over dup directory-files  \r
-    [ ".xml" tail? ] filter \r
-    [ append-path ] with map\r
-    [ <run-file-button> add-gadget ] each\r
-    swap <labeled-gadget> ;\r
-\r
-! -----------------------------------------------------\r
-\r
-: menu-rotations-3D ( -- gadget )\r
-    3 3 <frame>\r
-        { 1 1 } >>filled-cell\r
-        "Turn\n left"  [ rotation-step  turn-left  ] \r
-            camera-button   @left grid-add     \r
-        "Turn\n right" [ rotation-step turn-right ] \r
-            camera-button   @right grid-add     \r
-        "Pitch down"   [ rotation-step  pitch-down ] \r
-            camera-button   @bottom grid-add     \r
-        "Pitch up"     [ rotation-step  pitch-up   ] \r
-            camera-button   @top grid-add     \r
-        <shelf>  1 >>fill\r
-            "Roll left\n (ctl)"  [ rotation-step  roll-left  ] \r
-                camera-button   add-gadget  \r
-            "Roll right\n(ctl)"  [ rotation-step  roll-right ] \r
-                camera-button   add-gadget  \r
-        @center grid-add \r
-;\r
-\r
-: menu-translations-3D ( -- gadget )\r
-    3 3 <frame>\r
-        { 1 1 } >>filled-cell\r
-        "left\n(alt)"        [ translation-step  strafe-left  ]\r
-            camera-button @left grid-add  \r
-        "right\n(alt)"       [ translation-step  strafe-right ]\r
-            camera-button @right grid-add     \r
-        "Strafe up \n (alt)" [ translation-step strafe-up    ] \r
-            camera-button @top grid-add\r
-        "Strafe down\n (alt)" [ translation-step strafe-down  ]\r
-            camera-button @bottom grid-add    \r
-        <pile>  1 >>fill\r
-            "Forward (ctl)"  [  translation-step step-turtle ] \r
-                camera-button add-gadget\r
-            "Backward (ctl)" \r
-                [ translation-step neg step-turtle ] \r
-                camera-button   add-gadget\r
-        @center grid-add\r
-;\r
-\r
-: menu-quick-views ( -- gadget )\r
-    <shelf>\r
-        "View 1 (1)" mvt-3D-1 camera-button   add-gadget\r
-        "View 2 (2)" mvt-3D-2 camera-button   add-gadget\r
-        "View 3 (3)" mvt-3D-3 camera-button   add-gadget \r
-        "View 4 (4)" mvt-3D-4 camera-button   add-gadget \r
-;\r
-\r
-: menu-3D ( -- gadget ) \r
-    <pile>\r
-        <shelf>   \r
-            menu-rotations-3D    add-gadget\r
-            menu-translations-3D add-gadget\r
-            0.5 >>align\r
-            { 0 10 } >>gap\r
-        add-gadget\r
-        menu-quick-views add-gadget ; \r
-\r
-TUPLE: handler < w:wrapper table ;\r
-\r
-: <handler> ( child -- handler ) handler w:new-wrapper ;\r
-\r
-M: handler handle-gesture ( gesture gadget -- ? )\r
-   tuck table>> at dup [ call( gadget -- ) f ] [ 2drop t ] if ;\r
-\r
-: add-keyboard-delegate ( obj -- obj )\r
- <handler>\r
-H{\r
-        { T{ key-down f f "LEFT" }  \r
-            [ [ rotation-step turn-left ] camera-action ] }\r
-        { T{ key-down f f "RIGHT" } \r
-            [ [ rotation-step turn-right ] camera-action ] }\r
-        { T{ key-down f f "UP" }    \r
-            [ [ rotation-step pitch-down ] camera-action ] }\r
-        { T{ key-down f f "DOWN" }  \r
-            [ [ rotation-step pitch-up ] camera-action ] }\r
-\r
-        { T{ key-down f { C+ } "UP" } \r
-           [ [ translation-step step-turtle ] camera-action ] }\r
-        { T{ key-down f { C+ } "DOWN" } \r
-            [ [ translation-step neg step-turtle ] \r
-                    camera-action ] }\r
-        { T{ key-down f { C+ } "LEFT" } \r
-            [ [ rotation-step roll-left ] camera-action ] }\r
-        { T{ key-down f { C+ } "RIGHT" } \r
-            [ [ rotation-step roll-right ] camera-action ] }\r
-\r
-        { T{ key-down f { A+ } "LEFT" }  \r
-           [ [ translation-step strafe-left ] camera-action ] }\r
-        { T{ key-down f { A+ } "RIGHT" } \r
-          [ [ translation-step strafe-right ] camera-action ] }\r
-        { T{ key-down f { A+ } "UP" }    \r
-            [ [ translation-step strafe-up ] camera-action ] }\r
-        { T{ key-down f { A+ } "DOWN" }  \r
-           [ [ translation-step strafe-down ] camera-action ] }\r
-\r
-\r
-        { T{ key-down f f "1" } [ mvt-3D-1 camera-action ] }\r
-        { T{ key-down f f "2" } [ mvt-3D-2 camera-action ] }\r
-        { T{ key-down f f "3" } [ mvt-3D-3  camera-action ] }\r
-        { T{ key-down f f "4" } [ mvt-3D-4  camera-action ] }\r
-\r
-    } >>table\r
-    ;    \r
-\r
-! --------------------------------------------\r
-! print elements \r
-! --------------------------------------------\r
-! print-content\r
-\r
-GENERIC: adsoda-display-model ( x -- ) \r
-\r
-M: light adsoda-display-model \r
-"\n light : " .\r
-     { \r
-        [ direction>> "direction : " pprint . ] \r
-        [ color>> "color : " pprint . ]\r
-    }   cleave\r
-    ;\r
-\r
-M: face adsoda-display-model \r
-     {\r
-        [ halfspace>> "halfspace : " pprint . ] \r
-        [ touching-corners>> "touching corners : " pprint . ]\r
-    }   cleave\r
-    ;\r
-M: solid adsoda-display-model \r
-     {\r
-        [ name>> "solid called : " pprint . ] \r
-        [ color>> "color : " pprint . ]\r
-        [ dimension>> "dimension : " pprint . ]\r
-        [ faces>> "composed of faces : " pprint \r
-            [ adsoda-display-model ] each ]\r
-    }   cleave\r
-    ;\r
-M: space adsoda-display-model \r
-     {\r
-        [ dimension>> "dimension : " pprint . ] \r
-        [ ambient-color>> "ambient-color : " pprint . ]\r
-        [ solids>> "composed of solids : " pprint \r
-            [ adsoda-display-model ] each ]\r
-        [ lights>> "composed of lights : " pprint \r
-            [ adsoda-display-model ] each ] \r
-    }   cleave\r
-    ;\r
-\r
-! ----------------------------------------------\r
-: menu-bar ( -- gadget )\r
-       <shelf>\r
-          "reinit" [ drop load-model-file ] button* add-gadget\r
-          selected-file-model> <label-control> add-gadget\r
-    ;\r
-\r
-\r
-: controller-window* ( -- gadget )\r
-    { 0 1 } <track>\r
-        menu-bar f track-add\r
-        <list-runner>  \r
-            <scroller>\r
-        f track-add\r
-        <shelf>\r
-            "Projection mode : " <label> add-gadget\r
-            model-projection-chooser add-gadget\r
-        f track-add\r
-        <shelf>\r
-            "Collision detection (slow and buggy ) : " \r
-                <label> add-gadget\r
-            collision-detection-chooser add-gadget\r
-        f track-add\r
-        <pile>\r
-            0.5 >>align    \r
-            menu-4D add-gadget \r
-            COLOR: purple s:<solid> >>interior\r
-            "4D movements" <labeled-gadget>\r
-        f track-add\r
-        <pile>\r
-            0.5 >>align\r
-            { 2 2 } >>gap\r
-            menu-3D add-gadget\r
-            COLOR: purple s:<solid> >>interior\r
-            "Camera 3D" <labeled-gadget>\r
-        f track-add      \r
-        COLOR: gray s:<solid> >>interior\r
- ;\r
\r
-: viewer-windows* ( --  )\r
-    "YZW" view1> win3D \r
-    "XZW" view2> win3D \r
-    "XYW" view3> win3D \r
-    "XYZ" view4> win3D   \r
-;\r
-\r
-: navigator-window* ( -- )\r
-    controller-window*\r
-    viewer-windows*   \r
-    add-keyboard-delegate\r
-    "navigateur 4D" open-window\r
-;\r
-\r
-: windows ( -- ) [ [ navigator-window* ] with-scope ] with-ui ;\r
-\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-: init-variables ( -- )\r
-    "choose a file" <model> >selected-file-model  \r
-    <observer> >observer3d\r
-    [ observer3d> >self\r
-      reset-turtle \r
-      45 turn-left \r
-      45 pitch-up \r
-      -300 step-turtle \r
-    ] with-scope\r
-    \r
-;\r
-\r
-\r
-: init-models ( -- )\r
-    0 model-projection observer3d> <window3D> >view1\r
-    1 model-projection observer3d> <window3D> >view2\r
-    2 model-projection observer3d> <window3D> >view3\r
-    3 model-projection observer3d> <window3D> >view4\r
-;\r
-\r
-: 4DNav ( -- ) \r
-    init-variables\r
-    selected-file read-model-file >present-space\r
-    init-models\r
-    windows\r
-;\r
-\r
-MAIN: 4DNav\r
-\r
-\r
diff --git a/extra/4DNav/authors.txt b/extra/4DNav/authors.txt
deleted file mode 100755 (executable)
index a6a9693..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Jeff Bigot
\ No newline at end of file
diff --git a/extra/4DNav/camera/authors.txt b/extra/4DNav/camera/authors.txt
deleted file mode 100755 (executable)
index bbc876e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Adam Wendt
diff --git a/extra/4DNav/camera/camera-docs.factor b/extra/4DNav/camera/camera-docs.factor
deleted file mode 100755 (executable)
index 65afafc..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-! Copyright (C) 2008 Jean-François Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel ;
-IN: 4DNav.camera
-
-HELP: camera-eye
-{ $values
-    
-     { "point" "position" }
-}
-{ $description "return the position of the camera" } ;
-
-HELP: camera-focus
-{ $values
-    
-     { "point" "position" }
-}
-{ $description "return the point the camera looks at" } ;
-
-HELP: camera-up
-{ $values
-    
-     { "dirvec" "upside direction" }
-}
-{ $description "In order to precise the roling position of camera give an upward vector" } ;
-
-HELP: do-look-at
-{ $values
-     { "camera" "direction" }
-}
-{ $description "Word to use in replacement of gl-look-at when using a camera" } ;
-
-ARTICLE: "4DNav.camera" "Camera"
-{ $vocab-link "4DNav.camera" }
-$nl
-"A camera is defined by:"
-{ $list
-{ "a position (" { $link camera-eye } ")" }
-{ "a focus direction (" { $link camera-focus } ")" }
-{ "an attitude information (" { $link camera-up } ")" }
-}
-"Use " { $link do-look-at } " in opengl statement in placement of gl-look-at"
-$nl
-"A camera is a " { $vocab-link "4DNav.turtle" } " object. Its a special vocab to handle mouvements of a 3D object:"
-{ $list
-{ "To define a camera"
-{
-    $unchecked-example
-    
-"VAR: my-camera"
-": init-my-camera ( -- )"
-"    <turtle> >my-camera"
-"    [ my-camera> >self"
-"      reset-turtle "
-"    ] with-scope ;"
-} }
-{ "To move it"
-{
-    $unchecked-example
-
-"    [ my-camera> >self"
-"      45 pitch-up "
-"      5 step-turtle" 
-"    ] with-scope "
-} }
-{ "or"
-{
-    $unchecked-example
-
-"    [ my-camera> >self"
-"      5 strafe-left"
-"    ] with-scope "
-}
-}
-{
-"to use it in an opengl statement"
-{
-    $unchecked-example
-  "my-camera> do-look-at"
-
-}
-}
-}
-
-
-;
-
-ABOUT: "4DNav.camera"
diff --git a/extra/4DNav/camera/camera.factor b/extra/4DNav/camera/camera.factor
deleted file mode 100755 (executable)
index 0d46d73..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-USING: kernel namespaces math.vectors opengl opengl.glu 4DNav.turtle  ;
-
-IN: 4DNav.camera
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: camera-eye ( -- point ) turtle-pos> ;
-
-: camera-focus ( -- point ) 
-    [ 1 step-turtle turtle-pos> ] save-self ;
-
-: camera-up ( -- dirvec )
-[ 90 pitch-up turtle-pos> 1 step-turtle turtle-pos> swap v- ] 
-    save-self ;
-
-: do-look-at ( camera -- )
-[ >self camera-eye camera-focus camera-up gl-look-at ] 
-    with-scope ;
diff --git a/extra/4DNav/deep/deep-docs.factor b/extra/4DNav/deep/deep-docs.factor
deleted file mode 100755 (executable)
index 78439c6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-! Copyright (C) 2008 Jean-François Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel quotations sequences ;
-IN: 4DNav.deep
-
-! HELP: deep-cleave-quots
-! { $values
-!     { "seq" sequence }
-!     { "quot" quotation }
-! }
-! { $description "A word to build a soquence from a sequence of quotation" }
-! 
-! { $examples
-! "It is useful to build matrix"
-! { $example "USING: math math.trig ; "
-!     " 30 deg>rad "
-!    "  {  { [ cos ] [ sin neg ]   0 } "
-!    "     { [ sin ] [ cos ]       0 } "
-!    "     {   0       0           1 } "
-!    "  } deep-cleave-quots " 
-!     " "
-! 
-! 
-! } }
-! ;
-
-ARTICLE: "4DNav.deep" "Deep"
-{ $vocab-link "4DNav.deep" }
-;
-
-ABOUT: "4DNav.deep"
diff --git a/extra/4DNav/deep/deep.factor b/extra/4DNav/deep/deep.factor
deleted file mode 100755 (executable)
index b18000a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-USING: macros quotations math math.functions math.trig \r
-sequences.deep kernel make fry combinators grouping ;\r
-IN: 4DNav.deep\r
-\r
-! USING: bake ;\r
-! MACRO: deep-cleave-quots ( seq -- quot )\r
-!    [ [ quotation? ] deep-filter ]\r
-!    [ [ dup quotation? [ drop , ] when ] deep-map ]\r
-!    bi '[ _ cleave _ bake ] ;\r
-\r
-: make-matrix ( quot width -- matrix ) \r
-    [ { } make ] dip group ; inline\r
-\r
diff --git a/extra/4DNav/deploy.factor b/extra/4DNav/deploy.factor
deleted file mode 100755 (executable)
index 44481f4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-USING: tools.deploy.config ;
-H{
-    { deploy-c-types? t }
-    { deploy-word-props? t }
-    { deploy-name "4DNav" }
-    { deploy-ui? t }
-    { deploy-math? t }
-    { deploy-threads? t }
-    { deploy-reflection 3 }
-    { deploy-unicode? t }
-    { deploy-io 3 }
-    { "stop-after-last-window?" t }
-    { deploy-word-defs? t }
-}
diff --git a/extra/4DNav/file-chooser/authors.txt b/extra/4DNav/file-chooser/authors.txt
deleted file mode 100755 (executable)
index a6a9693..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Jeff Bigot
\ No newline at end of file
diff --git a/extra/4DNav/file-chooser/file-chooser.factor b/extra/4DNav/file-chooser/file-chooser.factor
deleted file mode 100755 (executable)
index 51bebc3..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING:\r
-kernel\r
-io.files\r
-io.backend\r
-io.directories\r
-io.files.info\r
-io.pathnames\r
-sequences\r
-models\r
-strings\r
-ui\r
-ui.operations\r
-ui.commands\r
-ui.gestures\r
-ui.gadgets\r
-ui.gadgets.buttons\r
-ui.gadgets.lists\r
-ui.gadgets.labels\r
-ui.gadgets.tracks\r
-ui.gadgets.packs\r
-ui.gadgets.panes\r
-ui.gadgets.scrollers\r
-prettyprint\r
-combinators\r
-accessors\r
-values\r
-tools.walker\r
-fry\r
-;\r
-IN: 4DNav.file-chooser\r
-\r
-TUPLE: file-chooser < track \r
-    path\r
-    extension \r
-    selected-file\r
-    presenter\r
-    hook  \r
-    list\r
-    ;\r
-\r
-: find-file-list ( gadget -- list )\r
-    [ file-chooser? ] find-parent list>> ;\r
-\r
-file-chooser H{\r
-    { T{ key-down f f "UP" } \r
-        [ find-file-list select-previous ] }\r
-    { T{ key-down f f "DOWN" } \r
-        [ find-file-list select-next ] }\r
-    { T{ key-down f f "PAGE_UP" } \r
-        [ find-file-list list-page-up ] }\r
-    { T{ key-down f f "PAGE_DOWN" } \r
-        [ find-file-list list-page-down ] }\r
-    { T{ key-down f f "RET" } \r
-        [ find-file-list invoke-value-action ] }\r
-    { T{ button-down } \r
-        request-focus }\r
-    { T{ button-down f 1 } \r
-        [ find-file-list invoke-value-action ]  }\r
-} set-gestures\r
-\r
-: list-of-files ( file-chooser -- seq )\r
-     [ path>> value>> directory-entries ] [ extension>> ] bi\r
-     '[ [ name>> _ [ tail? ] with any? ] \r
-     [ directory? ] bi or ]  filter\r
-;\r
-\r
-: update-filelist-model ( file-chooser -- )\r
-    [ list-of-files ] [ model>> ] bi set-model ;\r
-\r
-: init-filelist-model ( file-chooser -- file-chooser )\r
-    dup list-of-files <model> >>model ; \r
-\r
-: (fc-go) ( file-chooser button quot -- )\r
-    [ [ file-chooser? ] find-parent dup path>> ] dip\r
-    call\r
-    normalize-path swap set-model\r
-    update-filelist-model\r
-    drop ; inline\r
-\r
-: fc-go-parent ( file-chooser button -- )\r
-    [ dup value>> parent-directory ] (fc-go) ;\r
-\r
-: fc-go-home ( file-chooser button -- )\r
-    [ home ] (fc-go) ;\r
-\r
-: fc-change-directory ( file-chooser file -- )\r
-    dupd [ path>> value>> normalize-path ] [ name>> ] bi* \r
-    append-path over path>> set-model    \r
-    update-filelist-model\r
-;\r
-\r
-: fc-load-file ( file-chooser file -- )\r
-  over [ name>> ] [ selected-file>> ] bi* set-model \r
-  [ [ path>> value>> ] [ selected-file>> value>> ] bi append ] [ hook>> ] bi\r
-  call( path -- )\r
-; inline\r
-\r
-! : fc-ok-action ( file-chooser -- quot )\r
-!  dup selected-file>> value>>  "" =\r
-!    [ drop [ drop ] ] [    \r
-!            [ path>> value>> ] \r
-!            [ selected-file>> value>> append ] \r
-!            [ hook>> prefix ] tri\r
-!        [ drop ] prepend\r
-!    ]  if ; \r
-\r
-: line-selected-action ( file-chooser -- )\r
-     dup list>> list-value\r
-     dup directory? \r
-     [ fc-change-directory ] [ fc-load-file ] if ;\r
-\r
-: present-dir-element ( element -- string )\r
-    [ name>> ] [ directory? ] bi   [ "-> " prepend ] when ;\r
-\r
-: <file-list> ( file-chooser -- list )\r
-  dup [ nip line-selected-action ] curry \r
-  [ present-dir-element ] rot model>> <list> ;\r
-\r
-: <file-chooser> ( hook path extension -- gadget )\r
-    { 0 1 } file-chooser new-track\r
-    swap >>extension\r
-    swap <model> >>path\r
-    "" <model> >>selected-file\r
-    swap >>hook\r
-    init-filelist-model\r
-    dup <file-list> >>list\r
-    "choose a file in directory " <label> f track-add\r
-    dup path>> <label-control> f track-add\r
-    dup extension>> ", " join "limited to : " prepend \r
-        <label> f track-add\r
-    <shelf> \r
-        "selected file : " <label> add-gadget\r
-        over selected-file>> <label-control> add-gadget\r
-    f track-add\r
-    <shelf> \r
-        over [  swap fc-go-parent ] curry  "go up" \r
-            swap <border-button> add-gadget\r
-        over [  swap fc-go-home ] curry  "go home" \r
-            swap <border-button> add-gadget\r
-    !    over [ swap fc-ok-action ] curry "OK" \r
-    !    swap <bevel-button> add-gadget\r
-    !    [ drop ]  "Cancel" swap <bevel-button> add-gadget\r
-    f track-add\r
-    dup list>> <scroller> 1 track-add\r
-;\r
-\r
-M: file-chooser pref-dim* drop { 400 200 } ;\r
-\r
-: file-chooser-window ( -- )\r
-    [ . ] home { "xml" "txt" }   <file-chooser> \r
-    "Choose a file" open-window ;\r
-\r
diff --git a/extra/4DNav/hypercube.xml b/extra/4DNav/hypercube.xml
deleted file mode 100755 (executable)
index 0d46e3b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<model>\r
-<space>\r
-       <name>hypercube</name>\r
-       <dimension>4</dimension>\r
-       <solid>\r
-               <name>4cube1</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,100</face>\r
-               <face>-1,0,0,0,-150</face>\r
-               <face>0,1,0,0,100</face>\r
-               <face>0,-1,0,0,-150</face>\r
-               <face>0,0,1,0,100</face>\r
-               <face>0,0,-1,0,-150</face>\r
-               <face>0,0,0,1,100</face>\r
-               <face>0,0,0,-1,-150</face>\r
-               <color>1,0,0</color>\r
-       </solid>\r
-       <solid>\r
-               <name>4cube1</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,100</face>\r
-               <face>-1,0,0,0,-150</face>\r
-               <face>0,1,0,0,100</face>\r
-               <face>0,-1,0,0,-150</face>\r
-               <face>0,0,1,0,100</face>\r
-               <face>0,0,-1,0,-150</face>\r
-               <face>0,0,0,1,100</face>\r
-               <face>0,0,0,-1,-150</face>\r
-               <color>1,0,0</color>\r
-       </solid>\r
-       <light>\r
-               <direction>1,1,1,1</direction>\r
-               <color>0.2,0.2,0.6</color>\r
-       </light>\r
-       <color>0.8,0.9,0.9</color>\r
-</space>\r
-</model>\r
diff --git a/extra/4DNav/light_test.xml b/extra/4DNav/light_test.xml
deleted file mode 100755 (executable)
index b7d750d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<model>\r
-<space>\r
-       <name>multi solids</name>\r
-       <dimension>4</dimension>\r
-       <solid>\r
-               <name>4cube1</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,100</face>\r
-               <face>-1,0,0,0,-150</face>\r
-               <face>0,1,0,0,100</face>\r
-               <face>0,-1,0,0,-150</face>\r
-               <face>0,0,1,0,100</face>\r
-               <face>0,0,-1,0,-150</face>\r
-               <face>0,0,0,1,100</face>\r
-               <face>0,0,0,-1,-150</face>\r
-               <color>1,1,1</color>\r
-       </solid>\r
-       <solid>\r
-               <name>4triancube</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,160</face>\r
-               <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>\r
-               <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>\r
-               <face>0,0,1,0,140</face>\r
-               <face>0,0,-1,0,-180</face>\r
-               <face>0,0,0,1,110</face>\r
-               <face>0,0,0,-1,-180</face>\r
-               <color>1,1,1</color>\r
-       </solid>\r
-       <solid>\r
-               <name>triangone</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,60</face>\r
-               <face>0.5,0.8660254037844386,0,0,60</face>\r
-               <face>-0.5,0.8660254037844387,0,0,-20</face>\r
-               <face>-1.0,0,0,0,-100</face>\r
-               <face>-0.5,-0.8660254037844384,0,0,-100</face>\r
-               <face>0.5,-0.8660254037844387,0,0,-20</face>\r
-               <face>0,0,1,0,120</face>\r
-               <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>\r
-               <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>\r
-               <color>1,1,1</color>\r
-       </solid>\r
-       <light>\r
-               <direction>1,0,0,0</direction>\r
-               <color>0,0,0,0.6</color>\r
-       </light>\r
-       <light>\r
-               <direction>0,1,0,0</direction>\r
-               <color>0,0.6,0,0</color>\r
-       </light>\r
-       <light>\r
-               <direction>0,0,1,0</direction>\r
-               <color>0,0,0.6,0</color>\r
-       </light>\r
-       <light>\r
-               <direction>0,0,0,1</direction>\r
-               <color>0.6,0.6,0.6</color>\r
-       </light>\r
-       <color>0.99,0.99,0.99</color>\r
-</space>\r
-</model>\r
diff --git a/extra/4DNav/multi solids.xml b/extra/4DNav/multi solids.xml
deleted file mode 100755 (executable)
index b401e98..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<model>\r
-<space>\r
-       <name>multi solids</name>\r
-       <dimension>4</dimension>\r
-       <solid>\r
-               <name>4cube1</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,100</face>\r
-               <face>-1,0,0,0,-150</face>\r
-               <face>0,1,0,0,100</face>\r
-               <face>0,-1,0,0,-150</face>\r
-               <face>0,0,1,0,100</face>\r
-               <face>0,0,-1,0,-150</face>\r
-               <face>0,0,0,1,100</face>\r
-               <face>0,0,0,-1,-150</face>\r
-               <color>1,0,0</color>\r
-       </solid>\r
-       <solid>\r
-               <name>4triancube</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,160</face>\r
-               <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>\r
-               <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>\r
-               <face>0,0,1,0,140</face>\r
-               <face>0,0,-1,0,-180</face>\r
-               <face>0,0,0,1,110</face>\r
-               <face>0,0,0,-1,-180</face>\r
-               <color>0,1,0</color>\r
-       </solid>\r
-       <solid>\r
-               <name>triangone</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,60</face>\r
-               <face>0.5,0.8660254037844386,0,0,60</face>\r
-               <face>-0.5,0.8660254037844387,0,0,-20</face>\r
-               <face>-1.0,0,0,0,-100</face>\r
-               <face>-0.5,-0.8660254037844384,0,0,-100</face>\r
-               <face>0.5,-0.8660254037844387,0,0,-20</face>\r
-               <face>0,0,1,0,120</face>\r
-               <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>\r
-               <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>\r
-               <color>0,1,1</color>\r
-       </solid>\r
-       <light>\r
-               <direction>1,1,1,1</direction>\r
-               <color>0.2,0.2,0.6</color>\r
-       </light>\r
-       <color>0.8,0.9,0.9</color>\r
-</space>\r
-</model>\r
diff --git a/extra/4DNav/prismetriagone.xml b/extra/4DNav/prismetriagone.xml
deleted file mode 100755 (executable)
index cbdc071..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<model>\r
-<space>\r
-       <name>Prismetragone</name>              \r
-       <dimension>4</dimension>\r
-       <solid>\r
-               <name>triangone</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,60</face>\r
-               <face>0.5,0.8660254037844386,0,0,60</face>\r
-               <face>-0.5,0.8660254037844387,0,0,-20</face>\r
-               <face>-1.0,0,0,0,-100</face>\r
-               <face>-0.5,-0.8660254037844384,0,0,-100</face>\r
-               <face>0.5,-0.8660254037844387,0,0,-20</face>\r
-               <face>0,0,1,0,120</face>\r
-               <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>\r
-               <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>\r
-               <color>0,1,1</color>\r
-       </solid>\r
-       <light>\r
-               <direction>1,1,1,1</direction>\r
-               <color>0.2,0.2,0.6</color>\r
-       </light>\r
-       <color>0.8,0.9,0.9</color>\r
-</space>\r
-</model>\r
diff --git a/extra/4DNav/space-file-decoder/authors.txt b/extra/4DNav/space-file-decoder/authors.txt
deleted file mode 100755 (executable)
index a6a9693..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Jeff Bigot
\ No newline at end of file
diff --git a/extra/4DNav/space-file-decoder/space-file-decoder-docs.factor b/extra/4DNav/space-file-decoder/space-file-decoder-docs.factor
deleted file mode 100755 (executable)
index 0a78166..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-! Copyright (C) 2008 Jean-François Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel ;
-IN: 4DNav.space-file-decoder
-
-
-
-HELP: read-model-file
-{ $values
-    
-     { "path" "path to the file to read" }
-     { "x" "value" }
-}
-{ $description "Read a file containing the xml description of the model" } ;
-
-ARTICLE: "4DNav.space-file-decoder" "Space XMLfile decoder"
-{ $vocab-link "4DNav.space-file-decoder" }
-;
-
-ABOUT: "4DNav.space-file-decoder"
diff --git a/extra/4DNav/space-file-decoder/space-file-decoder.factor b/extra/4DNav/space-file-decoder/space-file-decoder.factor
deleted file mode 100755 (executable)
index e85830d..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: adsoda xml xml.traversal xml.syntax accessors \r
-combinators sequences math.parser kernel splitting values \r
-continuations ;\r
-IN: 4DNav.space-file-decoder\r
-\r
-: decode-number-array ( x -- y )  \r
-    "," split [ string>number ] map ;\r
-\r
-TAGS: adsoda-read-model ( tag -- model )\r
-\r
-TAG: dimension adsoda-read-model \r
-    children>> first string>number ;\r
-TAG: direction adsoda-read-model \r
-    children>> first decode-number-array ;\r
-TAG: color     adsoda-read-model \r
-    children>> first decode-number-array ;\r
-TAG: name      adsoda-read-model \r
-    children>> first ;\r
-TAG: face      adsoda-read-model \r
-    children>> first decode-number-array ;\r
-\r
-TAG: solid adsoda-read-model \r
-    <solid> swap  \r
-    { \r
-        [ "dimension" tag-named adsoda-read-model >>dimension ]\r
-        [ "name"      tag-named adsoda-read-model >>name ] \r
-        [ "color"     tag-named adsoda-read-model >>color ] \r
-        [ "face"      \r
-            tags-named [ adsoda-read-model cut-solid ] each ] \r
-    } cleave\r
-    ensure-adjacencies\r
-;\r
-\r
-TAG: light adsoda-read-model \r
-   <light> swap  \r
-    { \r
-        [ "direction" tag-named adsoda-read-model >>direction ]\r
-        [ "color"     tag-named adsoda-read-model >>color ] \r
-    } cleave\r
-;\r
-\r
-TAG: space adsoda-read-model \r
-    <space> swap  \r
-    { \r
-        [ "dimension" tag-named adsoda-read-model >>dimension ]\r
-        [ "name"      tag-named adsoda-read-model >>name ] \r
-        [ "color"     tag-named \r
-            adsoda-read-model >>ambient-color ] \r
-        [ "solid"     tags-named \r
-            [ adsoda-read-model suffix-solids ] each ] \r
-        [ "light"     tags-named \r
-            [ adsoda-read-model suffix-lights ] each ]\r
-    } cleave\r
-;\r
-\r
-: read-model-file ( path -- x )\r
-    [\r
-        [ file>xml "space" tag-named adsoda-read-model ] \r
-        [ 2drop <space> ] recover \r
-    ] [ <space> ] if*\r
-;\r
-\r
diff --git a/extra/4DNav/summary.txt b/extra/4DNav/summary.txt
deleted file mode 100755 (executable)
index 2598a14..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Simple tool to navigate through a 4D space with projections on 4 3D spaces
diff --git a/extra/4DNav/tags.txt b/extra/4DNav/tags.txt
deleted file mode 100755 (executable)
index 0c63a72..0000000
+++ /dev/null
@@ -1 +0,0 @@
-4D viewer
\ No newline at end of file
diff --git a/extra/4DNav/triancube.xml b/extra/4DNav/triancube.xml
deleted file mode 100755 (executable)
index 8551bed..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<model>\r
-<space>\r
-       <name>triancube</name>          \r
-       <dimension>4</dimension>\r
-       <solid>\r
-               <name>triancube</name>\r
-               <dimension>4</dimension>\r
-               <face>1,0,0,0,160</face>\r
-               <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>\r
-               <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>\r
-               <face>0,0,1,0,140</face>\r
-               <face>0,0,-1,0,-180</face>\r
-               <face>0,0,0,1,110</face>\r
-               <face>0,0,0,-1,-180</face>\r
-               <color>0,1,0</color>\r
-       </solid>\r
-       <light>\r
-               <direction>1,1,1,1</direction>\r
-               <color>0.2,0.2,0.6</color>\r
-       </light>\r
-       <color>0.8,0.9,0.9</color>\r
-</space>\r
-</model>\r
diff --git a/extra/4DNav/turtle/authors.txt b/extra/4DNav/turtle/authors.txt
deleted file mode 100755 (executable)
index 6cfd5da..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Eduardo Cavazos
diff --git a/extra/4DNav/turtle/turtle-docs.factor b/extra/4DNav/turtle/turtle-docs.factor
deleted file mode 100755 (executable)
index b94ed99..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-! Copyright (C) 2008 Jean-François Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays help.markup help.syntax kernel sequences ;
-IN: 4DNav.turtle
-
-
-ARTICLE: "4DNav.turtle" "Turtle"
-{ $vocab-link "4DNav.turtle" }
-;
-
-ABOUT: "4DNav.turtle"
diff --git a/extra/4DNav/turtle/turtle.factor b/extra/4DNav/turtle/turtle.factor
deleted file mode 100755 (executable)
index 71f7f26..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-USING: kernel math arrays math.vectors math.matrices namespaces make
-math.constants math.functions splitting grouping math.trig sequences
-accessors 4DNav.deep models vars ;
-IN: 4DNav.turtle
-
-! replacement of self
-
-VAR: self
-
-: with-self ( quot obj -- ) [ >self call ] with-scope ; inline
-
-: save-self ( quot -- ) self> [ self> clone >self call ] dip >self ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-TUPLE: turtle pos ori ;
-
-: <turtle> ( -- turtle )
-    turtle new
-    { 0 0 0 } clone >>pos
-    3 identity-matrix >>ori
-;
-
-
-TUPLE: observer < turtle projection-mode collision-mode ;
-
-: <observer> ( -- object ) 
-     observer new
-    0 <model> >>projection-mode 
-    f <model> >>collision-mode
-    ;
-
-
-: turtle-pos> ( -- val ) self> pos>> ;
-: >turtle-pos ( val -- ) self> (>>pos) ;
-
-: turtle-ori> ( -- val ) self> ori>> ;
-: >turtle-ori ( val -- ) self> (>>ori) ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! These rotation matrices are from
-! `Computer Graphics: Principles and Practice'
-
-
-! waiting for deep-cleave-quots  
-
-! : Rz ( angle -- Rx ) deg>rad
-!    {   { [ cos ] [ sin neg ]   0 }
-!        { [ sin ] [ cos ]      0  }
-!        {   0       0           1 } 
-!    } deep-cleave-quots  ;
-
-! : Ry ( angle -- Ry ) deg>rad
-!    {   { [ cos ]      0 [ sin ] }
-!        {   0          1 0       }
-!        { [  sin neg ] 0 [ cos ] }
-!    } deep-cleave-quots  ;
-  
-! : Rx ( angle -- Rz ) deg>rad
-!   {   { 1     0        0        }
-!        { 0   [ cos ] [ sin neg ] }
-!        { 0   [ sin ] [ cos ]     }
-!    } deep-cleave-quots ;
-
-: Rz ( angle -- Rx ) deg>rad
-[ dup cos ,     dup sin neg ,   0 ,
-  dup sin ,     dup cos ,       0 ,
-  0 ,           0 ,             1 , ] 3 make-matrix nip ;
-
-: Ry ( angle -- Ry ) deg>rad
-[ dup cos ,     0 ,             dup sin ,
-  0 ,           1 ,             0 ,
-  dup sin neg , 0 ,             dup cos , ] 3 make-matrix nip ;
-
-: Rx ( angle -- Rz ) deg>rad
-[ 1 ,           0 ,             0 ,
-  0 ,           dup cos ,       dup sin neg ,
-  0 ,           dup sin ,       dup cos , ] 3 make-matrix nip ;
-
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: apply-rotation ( rotation -- ) 
-    turtle-ori> swap m. >turtle-ori ;
-: rotate-x ( angle -- ) Rx apply-rotation ;
-: rotate-y ( angle -- ) Ry apply-rotation ;
-: rotate-z ( angle -- ) Rz apply-rotation ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: pitch-up   ( angle -- ) neg rotate-x ;
-: pitch-down ( angle -- )     rotate-x ;
-
-: turn-left ( angle -- )      rotate-y ;
-: turn-right ( angle -- ) neg rotate-y ;
-
-: roll-left  ( angle -- ) neg rotate-z ;
-: roll-right ( angle -- )     rotate-z ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! roll-until-horizontal
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: V ( -- V ) { 0 1 0 } ;
-
-: X ( -- 3array ) turtle-ori> [ first  ] map ;
-: Y ( -- 3array ) turtle-ori> [ second ] map ;
-: Z ( -- 3array ) turtle-ori> [ third  ] map ;
-
-: set-X ( seq -- ) turtle-ori> [ set-first ] 2each ;
-: set-Y ( seq -- ) turtle-ori> [ set-second ] 2each ;
-: set-Z ( seq -- ) turtle-ori> [ set-third ] 2each ;
-
-: roll-until-horizontal ( -- )
-    V Z cross normalize set-X
-    Z X cross normalize set-Y ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: distance ( turtle turtle -- n ) 
-    pos>> swap pos>> v- [ sq ] map sum sqrt ;
-
-: move-by ( point -- ) turtle-pos> v+ >turtle-pos ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: reset-turtle ( -- ) 
-    { 0 0 0 } clone >turtle-pos 3 identity-matrix >turtle-ori ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: step-vector ( length -- array ) { 0 0 1 } n*v ;
-
-: step-turtle ( length -- ) 
-    step-vector turtle-ori> swap m.v 
-    turtle-pos> v+ >turtle-pos ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: strafe-up ( length -- )
-    90 pitch-up
-    step-turtle
-    90 pitch-down ;
-
-: strafe-down ( length -- )
-    90 pitch-down
-    step-turtle
-    90 pitch-up ;
-
-: strafe-left ( length -- )
-    90 turn-left
-    step-turtle
-    90 turn-right ;
-
-: strafe-right ( length -- )
-    90 turn-right
-    step-turtle
-    90 turn-left ;
diff --git a/extra/4DNav/window3D/authors.txt b/extra/4DNav/window3D/authors.txt
deleted file mode 100755 (executable)
index a6a9693..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Jeff Bigot
\ No newline at end of file
diff --git a/extra/4DNav/window3D/window3D-docs.factor b/extra/4DNav/window3D/window3D-docs.factor
deleted file mode 100755 (executable)
index a534d2e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-! Copyright (C) 2008 Jean-François Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel ;
-IN: 4DNav.window3D
-
-
-
-ARTICLE: "4DNav.window3D" "Window3D"
-{ $vocab-link "4DNav.window3D" }
-;
-
-ABOUT: "4DNav.window3D"
diff --git a/extra/4DNav/window3D/window3D.factor b/extra/4DNav/window3D/window3D.factor
deleted file mode 100755 (executable)
index e83e884..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel \r
-ui.gadgets\r
-ui.render\r
-opengl\r
-opengl.gl\r
-opengl.glu\r
-4DNav.camera\r
-4DNav.turtle\r
-math\r
-values\r
-alien.c-types\r
-accessors\r
-namespaces\r
-adsoda \r
-models\r
-prettyprint\r
-;\r
-\r
-IN: 4DNav.window3D\r
-\r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-! drawing functions \r
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
-\r
-TUPLE: window3D  < gadget observer ; \r
-\r
-: <window3D>  ( model observer -- gadget )\r
-    window3D  new\r
-    swap 2dup \r
-    projection-mode>> add-connection\r
-    2dup \r
-    collision-mode>> add-connection\r
-    >>observer \r
-    swap <model> >>model \r
-    t >>root?\r
-;\r
-\r
-M: window3D pref-dim* ( gadget -- dim )  drop { 300 300 } ;\r
-\r
-M: window3D draw-gadget* ( gadget -- )\r
-\r
-    GL_PROJECTION glMatrixMode\r
-        glLoadIdentity\r
-        0.6 0.6 0.6 .9 glClearColor\r
-        dup observer>> projection-mode>> value>> 1 =    \r
-        [ 60.0 1.0 0.1 3000.0 gluPerspective ]\r
-        [ -400.0 400.0 -400.0 400.0 0.0 4000.0 glOrtho ] if\r
-        dup observer>> collision-mode>> value>> \r
-        \ remove-hidden-solids?   \r
-        set-value\r
-        dup  observer>> do-look-at\r
-        GL_MODELVIEW glMatrixMode\r
-            glLoadIdentity  \r
-            0.9 0.9 0.9 1.0 glClearColor\r
-            1.0 glClearDepth\r
-            GL_LINE_SMOOTH glEnable\r
-            GL_BLEND glEnable\r
-            GL_DEPTH_TEST glEnable       \r
-            GL_LEQUAL glDepthFunc\r
-            GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc\r
-            GL_LINE_SMOOTH_HINT GL_NICEST glHint\r
-            1.25 glLineWidth\r
-            GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor \r
-                glClear\r
-            glLoadIdentity\r
-            GL_LIGHTING glEnable\r
-            GL_LIGHT0 glEnable\r
-            GL_COLOR_MATERIAL glEnable\r
-            GL_FRONT GL_AMBIENT_AND_DIFFUSE glColorMaterial\r
-            ! *************************\r
-            \r
-            model>> value>> \r
-            [ space->GL ] when*\r
-\r
-            ! *************************\r
-;\r
-\r
-M: window3D graft* drop ;\r
-\r
-M: window3D model-changed nip relayout ; \r
diff --git a/extra/adsoda/adsoda-docs.factor b/extra/adsoda/adsoda-docs.factor
deleted file mode 100755 (executable)
index 9536826..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: help.markup help.syntax ;\r
-IN: adsoda\r
-\r
-! --------------------------------------------------------------\r
-! faces\r
-! --------------------------------------------------------------\r
-ARTICLE: "face-page" "Face in ADSODA"\r
-"explanation of faces"\r
-$nl\r
-"link to functions" $nl\r
-"what is an halfspace" $nl\r
-"halfspace touching-corners adjacent-faces" $nl\r
-"touching-corners list of pointers to the corners which touch this face" $nl\r
-"adjacent-faces list of pointers to the faces which touch this face"\r
-{ $subsections\r
-    face\r
-    <face>\r
-}\r
-"test relative position"\r
-{ $subsections\r
-    point-inside-or-on-face?\r
-    point-inside-face?\r
-}\r
-"handling face"\r
-{ $subsections\r
-    flip-face\r
-    face-translate\r
-    face-transform\r
-}\r
-\r
-;\r
-\r
-HELP: face\r
-{ $class-description "a face is defined by"\r
-{ $list "halfspace equation" }\r
-{ $list "list of touching corners" }\r
-{ $list "list of adjacent faces" }\r
-$nl\r
-"Touching corners and adjacent faces are defined by algorithm thanks to other faces of the solid"\r
-}\r
-\r
-\r
-;\r
-HELP: <face> \r
-{ $values { "v" "an halfspace equation" } { "tuple" "a face" }  }   ;\r
-HELP: flip-face \r
-{ $values { "face" "a face" } { "face" "flipped face" } }\r
-{ $description "change the orientation of a face" }\r
-;\r
-\r
-HELP: face-translate \r
-{ $values { "face" "a face" } { "v" "a vector" } }\r
-{ $description \r
-"translate a face following a vector"\r
-$nl\r
-"a translation of an halfspace doesn't change the normal vector. this word just compute the new constant term" }\r
-\r
\r
- ;\r
-HELP: face-transform \r
-{ $values { "face" "a face" } { "m" "a transformation matrix" } }\r
-{ $description  "compute the transformation of a face using a transformation matrix" }\r
\r
- ;\r
-! --------------------------------\r
-! solid\r
-! --------------------------------------------------------------\r
-ARTICLE: "solid-page" "Solid in ADSODA"\r
-"explanation of solids"\r
-$nl\r
-"link to functions"\r
-{ $subsections\r
-    solid\r
-    <solid>\r
-}\r
-"test relative position"\r
-{ $subsections\r
-    point-inside-solid?\r
-    point-inside-or-on-solid?\r
-}\r
-"playing with faces and solids"\r
-{ $subsections\r
-    add-face\r
-    cut-solid\r
-    slice-solid\r
-}\r
-"solid handling"\r
-{ $subsections\r
-    solid-project\r
-    solid-translate\r
-    solid-transform\r
-    subtract\r
-    get-silhouette \r
-    solid=\r
-}\r
-;\r
-\r
-HELP: solid \r
-{ $class-description "dimension" $nl "silhouettes" $nl "faces" $nl "corners" $nl "adjacencies-valid" $nl "color" $nl "name" \r
-}\r
-;\r
-\r
-HELP: add-face \r
-{ $values { "solid" "a solid" } { "face" "a face" } }\r
-{ $description "reshape a solid with a face. The face truncate the solid." } ;\r
-\r
-HELP: cut-solid\r
-{ $values { "solid" "a solid" } { "halfspace" "an halfspace" } }\r
-{ $description "like add-face but just with halfspace equation" } ;\r
-\r
-HELP: slice-solid\r
-{ $values { "solid" "a solid" } { "face" "a face" } { "solid1" "the outer part of the former solid" } { "solid2" "the inner part of the former solid" } }\r
-{ $description "cut a solid into two parts. The face acts like a knife"\r
-}  ;\r
-\r
-\r
-HELP: solid-project\r
-{ $values { "lights" "lights" } { "ambient" "ambient" } { "solid" "solid" } { "solids" "projection of solid" } }\r
-{ $description "Project the solid using pv vector" \r
-$nl\r
-"TODO: explain how to use lights"\r
-} ;\r
-\r
-HELP: solid-translate \r
-{ $values { "solid" "a solid" } { "v" "translating vector" } }\r
-{ $description "Translate a solid using a vector" \r
-$nl\r
-"v and solid must have the same dimension "\r
-} ;\r
-\r
-HELP: solid-transform \r
-{ $values { "solid" "a solid" } { "m" "transformation matrix" } }\r
-{ $description "Transform a solid using a matrix"\r
-$nl\r
-"v and solid must have the same dimension "\r
-} ;\r
-\r
-HELP: subtract \r
-{ $values { "solid1" "initial shape" } { "solid2" "shape to remove" } { "solids" "resulting shape" } }\r
-{ $description  "Substract solid2 from solid1" } ;\r
-\r
-\r
-! --------------------------------------------------------------\r
-! space \r
-! --------------------------------------------------------------\r
-ARTICLE: "space-page" "Space in ADSODA"\r
-"A space is a collection of solids and lights."\r
-$nl\r
-"link to functions"\r
-$nl\r
-"Defining words"\r
-{ $subsections\r
-    space\r
-    <space>\r
-    suffix-solids \r
-    suffix-lights\r
-    clear-space-solids \r
-    describe-space\r
-}\r
-\r
-\r
-"Handling space"\r
-{ $subsections\r
-    space-ensure-solids\r
-    eliminate-empty-solids\r
-    space-transform\r
-    space-translate\r
-    remove-hidden-solids\r
-    space-project\r
-}\r
-\r
-\r
-;\r
-\r
-HELP: space \r
-{ $class-description \r
-"dimension" $nl " solids" $nl " ambient-color" $nl "lights" \r
-}\r
-;\r
-\r
-HELP: suffix-solids \r
-"( space solid -- space )"\r
-{ $values { "space" "a space" } { "solid" "a solid to add" } }\r
-{ $description "Add solid to space definition" } ;\r
-\r
-HELP: suffix-lights \r
-"( space light -- space ) "\r
-{ $values { "space" "a space" } { "light" "a light to add" } }\r
-{ $description "Add a light to space definition" } ;\r
-\r
-HELP: clear-space-solids \r
-"( space -- space )"   \r
-{ $values { "space" "a space" } }\r
-{ $description "remove all solids in space" } ;\r
-\r
-HELP: space-ensure-solids \r
-{ $values { "space" "a space" } }\r
-{ $description "rebuild corners of all solids in space" } ;\r
-\r
-\r
-\r
-HELP: space-transform \r
-" ( space m -- space )" \r
-{ $values { "space" "a space" } { "m" "a matrix" } }\r
-{ $description "Transform a space using a matrix" } ;\r
-\r
-HELP: space-translate \r
-{ $values { "space" "a space" } { "v" "a vector" } }\r
-{ $description "Translate a space following a vector" } ;\r
-\r
-HELP: describe-space " ( space -- )"\r
-{ $values { "space" "a space" } }\r
-{ $description "return a description of space" } ;\r
-\r
-HELP: space-project \r
-{ $values { "space" "a space" } { "i" "an integer" } }\r
-{ $description "Project a space along ith coordinate" } ;\r
-\r
-! --------------------------------------------------------------\r
-! 3D rendering\r
-! --------------------------------------------------------------\r
-ARTICLE: "3D-rendering-page" "The 3D rendering in ADSODA"\r
-"explanation of 3D rendering"\r
-$nl\r
-"link to functions"\r
-{ $subsections\r
-    face->GL\r
-    solid->GL\r
-    space->GL\r
-}\r
-\r
-;\r
-\r
-HELP: face->GL \r
-{ $values { "face" "a face" } { "color" "3 3 values array" } }\r
-{ $description "display a face" } ;\r
-\r
-HELP: solid->GL \r
-{ $values { "solid" "a solid" } }\r
-{ $description "display a solid" } ;\r
-\r
-HELP: space->GL \r
-{ $values { "space" "a space" } }\r
-{ $description "display a space" } ;\r
-\r
-! --------------------------------------------------------------\r
-! light\r
-! --------------------------------------------------------------\r
-\r
-ARTICLE: "light-page" "Light in ADSODA"\r
-"explanation of light"\r
-$nl\r
-"link to functions"\r
-;\r
-\r
-ARTICLE: { "adsoda" "light" } "ADSODA : lights"\r
-{ $code """\r
-! HELP: light position color\r
-! <light> ( -- tuple ) light new ;\r
-! light est un vecteur avec 3 variables pour les couleurs\n\r
- void Light::Apply(Vector& normal, double &cRed, double &cGreen, double &cBlue)\n\r
- { \n\r
-   // Dot the light direction with the normalized normal of Face.\r
-   register double intensity = -(normal * (*this));\r
-   // Face is a backface, from light's perspective\r
-   if (intensity < 0)\r
-     return;\r
-   \r
-   // Add the intensity componentwise\r
-   cRed += red * intensity;\r
-   cGreen += green * intensity;\r
-   cBlue += blue * intensity;\r
-   // Clip to unit range\r
-  if (cRed > 1.0) cRed = 1.0;\r
-   if (cGreen > 1.0) cGreen = 1.0;\r
-   if (cBlue > 1.0) cBlue = 1.0;\r
-""" }\r
-;\r
-\r
-\r
-\r
-ARTICLE: { "adsoda" "halfspace" } "ADSODA : halfspace"\r
-" defined by the concatenation of the normal vector and a constant"  \r
- ;\r
-\r
-\r
-\r
-ARTICLE:  "adsoda-main-page"  "ADSODA : Arbitrary-Dimensional Solid Object Display Algorithm"\r
-"multidimensional handler :" \r
-$nl\r
-"design a solid using face delimitations. Only works on convex shapes"\r
-$nl\r
-{ $emphasis "written in C++ by Greg Ferrar" }\r
-$nl\r
-"full explanation on adsoda page at " { $url "http://www.flowerfire.com/ADSODA/" }\r
-$nl\r
-"Useful words are describe on the following pages: "\r
-{ $subsections\r
-    "face-page"\r
-    "solid-page"\r
-    "space-page"\r
-    "light-page"\r
-    "3D-rendering-page"\r
-} ;\r
-\r
-ABOUT: "adsoda-main-page"\r
diff --git a/extra/adsoda/adsoda-tests.factor b/extra/adsoda/adsoda-tests.factor
deleted file mode 100755 (executable)
index f8881df..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-USING: adsoda\r
-kernel\r
-math\r
-accessors\r
-sequences\r
-    adsoda.solution2\r
-    fry\r
-    tools.test \r
-    arrays ;\r
-\r
-IN: adsoda.tests\r
-\r
-\r
-\r
-: s1 ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    "s1" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 -1 -5 } cut-solid \r
-    { -1 -1 -21 } cut-solid \r
-    { -1 0 -12 } cut-solid \r
-    { 1 2 16 } cut-solid\r
-;\r
-: solid1 ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    "solid1" >>name\r
-    { 1 -1 -5 } cut-solid \r
-    { -1 -1 -21 } cut-solid \r
-    { -1 0 -12 } cut-solid \r
-    { 1 2 16 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-;\r
-: solid2 ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    "solid2" >>name\r
-    { -1 1 -10 } cut-solid \r
-    { -1 -1 -28 } cut-solid \r
-    { 1 0 13 } cut-solid \r
- !   { 1 2 16 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid3 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid3" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 16 } cut-solid \r
-    { -1 0 -36 } cut-solid \r
-    { 0 1 1 } cut-solid \r
-    { 0 -1  -17 } cut-solid \r
- !   { 1 2 16 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-\r
-;\r
-\r
-: solid4 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid4" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 21 } cut-solid \r
-    { -1 0 -36 } cut-solid \r
-    { 0 1 1 } cut-solid \r
-    { 0 -1  -17 } cut-solid \r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid5 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid5" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 6 } cut-solid \r
-    { -1 0 -17 } cut-solid \r
-    { 0 1 17 } cut-solid \r
-    { 0 -1  -19 } cut-solid \r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid7 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid7" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 38 } cut-solid \r
-    { 1 -5 -66 } cut-solid \r
-    { -2 1 -75 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid6s ( -- seq )\r
-  solid3 clone solid2 clone subtract\r
-;\r
-\r
-: space1 ( -- space )\r
-    <space>\r
-        2 >>dimension\r
-     !    solid3 suffix-solids\r
-        solid1 suffix-solids\r
-        solid2 suffix-solids\r
-    !   solid6s [ suffix-solids ] each \r
-        solid4 suffix-solids\r
-     !   solid5 suffix-solids\r
-        solid7 suffix-solids\r
-        { 1 1 1 } >>ambient-color\r
-            <light>\r
-        { -100 -100 } >>position\r
-        { 0.2 0.7 0.1 } >>color\r
-        suffix-lights\r
-;\r
-\r
-: space2 ( -- space )\r
-    <space>\r
-        4 >>dimension\r
-       ! 4cube suffix-solids\r
-        { 1 1 1 } >>ambient-color\r
-            <light>\r
-        { -100 -100 } >>position\r
-        { 0.2 0.7 0.1 } >>color\r
-        suffix-lights\r
-\r
-       ;\r
-\r
-\r
-\r
-! {\r
-!        { 1 0 0 0 }\r
-!        { 0 1 0 0 }\r
-!        { 0 0 0.984807753012208 -0.1736481776669303 }\r
-!        { 0 0 0.1736481776669303 0.984807753012208 }\r
-!    }\r
-\r
-! ------------------------------------------------------------\r
-! constant+\r
-[ { 1 2 5 } ] [ { 1 2 3 } 2 constant+ ] unit-test\r
-\r
-! ------------------------------------------------------------\r
-! translate\r
-[ { 1 -1 0 } ] [ { 1 -1 -5 } { 3 -2 } translate ] unit-test\r
-\r
-! ------------------------------------------------------------\r
-! transform\r
-[ { -1 -1 -5 21.0 } ] [ { -1 -1 -5 21 }\r
-  { { 1 0 0 }\r
-    { 0 1 0 }\r
-    { 0 0 1 }\r
-    } transform  \r
-] unit-test\r
-\r
-! ------------------------------------------------------------\r
-! compare-nleft-to-identity-matrix\r
-[ t ] [ \r
-    { \r
-        { 1 0 0 1232 } \r
-        { 0 1 0 0 321 } \r
-        { 0 0 1 0 } } \r
-        3 compare-nleft-to-identity-matrix \r
-]  unit-test\r
-\r
-[ f ] [ \r
-    { { 1 0 0 } { 0 1 0 } { 0 0 0 } } \r
-    3 compare-nleft-to-identity-matrix \r
-] unit-test\r
-\r
-[ f ] [ \r
-    { { 2 0 0 } { 0 1 0 } { 0 0 1 } } \r
-    3 compare-nleft-to-identity-matrix \r
-] unit-test\r
-! ------------------------------------------------------------\r
-[ t ] [ \r
-  { { 1 0 0 }\r
-    { 0 1 0 }\r
-    { 0 0 1 } } 3 valid-solution? \r
-] unit-test\r
-\r
-[ f ] [ \r
-  { { 1 0 0 1 }\r
-    { 0 0 0 1 }\r
-    { 0 0 1 0 } } 3 valid-solution? \r
-] unit-test\r
-\r
-[ f ] [ \r
-  { { 1 0 0 1 }\r
-    { 0 0 0 1 } } 3 valid-solution? \r
-] unit-test\r
-\r
-[ f ] [ \r
-  { { 1 0 0 1 }\r
-    { 0 0 0 1 }\r
-    { 0 0 1 0 } } 2 valid-solution? \r
-] unit-test\r
-\r
-! ------------------------------------------------------------\r
-[ 3 ] [ { 1 2 3 } last ] unit-test \r
-\r
-[ { 1 2 5 } ] [ { 1 2 3 } dup [ 2 + ] change-last ] unit-test \r
-\r
-! ------------------------------------------------------------\r
-! position-point \r
-[ 0 ] [ \r
-    { 1 -1 -5 } { 2 7 } position-point \r
-] unit-test\r
-\r
-! ------------------------------------------------------------\r
-\r
-! transform\r
-! TODO construire un exemple\r
-\r
-\r
-! ------------------------------------------------------------\r
-! slice-solid \r
-\r
-! ------------------------------------------------------------\r
-! solve-equation \r
-! deux cas de tests, avec solution et sans solution\r
-\r
-[ { 2 7 } ] \r
-[ { { 1 -1 -5 } { 1 2 16 } } intersect-hyperplanes ] \r
-unit-test\r
-\r
-[ f ] \r
-[ { { 1 -1 -5 } { 1 2 16 } { -1 -1 -21 } } intersect-hyperplanes  ]\r
-unit-test\r
-\r
-[ f ] \r
-[ { { 1 0 -5 } { 1 0 16 }  } intersect-hyperplanes  ]\r
-unit-test\r
-\r
-! ------------------------------------------------------------\r
-! point-inside-halfspace\r
-[ t ] [ { 1 -1 -5 } { 0 0 }  point-inside-halfspace? ] \r
-unit-test\r
-[ f ] [ { 1 -1 -5 } { 8 13 }  point-inside-halfspace? ] \r
-unit-test\r
-[ t ] [ { 1 -1 -5 } { 8 13 }  point-inside-or-on-halfspace? ] \r
-unit-test\r
-\r
-\r
-! ------------------------------\r
-! order solid\r
-\r
-[  1 ] [ 0 >pv solid1 solid2 order-solid ] unit-test\r
-[ -1 ] [ 0 >pv solid2 solid1 order-solid ] unit-test\r
-[  f ] [ 1 >pv solid1 solid2 order-solid ] unit-test\r
-[  f ] [ 1 >pv solid2 solid1 order-solid ] unit-test\r
-\r
-\r
-! clip-solid\r
-[ { { 13 15 } { 15 13 } { 13 13 } } ]\r
-    [ 0 >pv solid2 solid1 clip-solid first corners>> ] unit-test\r
-\r
-solid1 corners>> '[ _ ]\r
-    [ 0 >pv solid1 solid1 clip-solid first corners>> ] unit-test\r
-\r
-solid1 corners>> '[ _ ]\r
-    [ 0 >pv solid1 solid2 clip-solid first corners>> ] unit-test\r
-\r
-solid1 corners>> '[ _ ]\r
-    [ 1 >pv solid1 solid2 clip-solid first corners>> ] unit-test\r
-solid2 corners>> '[ _ ]\r
-    [ 1 >pv solid2 solid1 clip-solid first corners>> ] unit-test\r
-\r
-!\r
-[\r
-    {\r
-        { { 13 15 } { 15 13 } { 13 13 } }\r
-        { { 16 17 } { 16 13 } { 36 17 } { 36 13 } }\r
-        { { 16 1 } { 16 2 } { 36 1 } { 36 2 } }\r
-    }\r
-] [     0 >pv solid2 solid3  2array \r
-        solid1 (solids-silhouette-subtract) \r
-        [ corners>> ] map\r
-  ] unit-test\r
-\r
-\r
-[\r
-{\r
-    { { 8 13 } { 2 7 } { 12 9 } { 12 2 } }\r
-    { { 13 15 } { 15 13 } { 13 13 } }\r
-    { { 16 17 } { 16 15 } { 36 17 } { 36 15 } }\r
-    { { 16 1 } { 16 2 } { 36 1 } { 36 2 } }\r
-}\r
-] [ \r
-    0 >pv  <space> solid1 suffix-solids \r
-        solid2 suffix-solids \r
-        solid3 suffix-solids\r
-     remove-hidden-solids\r
-    solids>> [ corners>> ] map\r
-] unit-test\r
-\r
-! { }\r
-! { }\r
-! <light> { 0.2 0.3 0.4 } >>color { 1 -1 1 } >>direction     suffix\r
-! <light> { 0.4 0.3 0.1 } >>color { -1 -1 -1 } >>direction   suffix\r
-! suffix \r
-! { 0.1 0.1 0.1 } suffix ! ambient color\r
-! { 0.23 0.32 0.17 } suffix ! solid color\r
-! solid3 faces>> first \r
-\r
-! enlight-projection\r
diff --git a/extra/adsoda/adsoda.factor b/extra/adsoda/adsoda.factor
deleted file mode 100755 (executable)
index cc09ad5..0000000
+++ /dev/null
@@ -1,569 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: accessors\r
-arrays \r
-assocs\r
-combinators\r
-kernel \r
-fry\r
-math \r
-math.constants\r
-math.functions\r
-math.libm\r
-math.order\r
-math.vectors \r
-math.matrices \r
-math.parser\r
-namespaces\r
-prettyprint\r
-sequences\r
-sequences.deep\r
-sets\r
-slots\r
-sorting\r
-tools.time\r
-vars\r
-continuations\r
-words\r
-opengl\r
-opengl.gl\r
-colors\r
-adsoda.solution2\r
-adsoda.combinators\r
-opengl.demo-support\r
-values\r
-tools.walker\r
-;\r
-\r
-IN: adsoda\r
-\r
-DEFER: combinations\r
-VAR: pv\r
-\r
-\r
-! -------------------------------------------------------------\r
-! global values\r
-VALUE: remove-hidden-solids?\r
-VALUE: VERY-SMALL-NUM\r
-VALUE: ZERO-VALUE\r
-VALUE: MAX-FACE-PER-CORNER\r
-\r
-t to: remove-hidden-solids?\r
-0.0000001 to: VERY-SMALL-NUM\r
-0.0000001 to: ZERO-VALUE\r
-4 to: MAX-FACE-PER-CORNER\r
-! -------------------------------------------------------------\r
-! sequence complement\r
-\r
-: with-pv ( i quot -- ) [ swap >pv call ] with-scope  ; inline\r
-\r
-: dimension ( array -- x )      length 1 - ; inline \r
-: change-last ( seq quot -- ) \r
-    [ [ dimension ] keep ] dip change-nth  ; inline\r
-\r
-! -------------------------------------------------------------\r
-! light\r
-! -------------------------------------------------------------\r
-\r
-TUPLE: light name { direction array } color ;\r
-: <light> ( -- tuple ) light new ;\r
-\r
-! -------------------------------------------------------------\r
-! halfspace manipulation\r
-! -------------------------------------------------------------\r
-\r
-: constant+ ( v x -- w )  '[ [ _ + ] change-last ] keep ;\r
-: translate ( u v -- w )   dupd     v* sum     constant+ ; \r
-\r
-: transform ( u matrix -- w )\r
-    [ swap m.v ] 2keep ! compute new normal vector    \r
-    [\r
-        [ [ abs ZERO-VALUE > ] find ] keep \r
-        ! find a point on the frontier\r
-        ! be sure it's not null vector\r
-        last ! get constant\r
-        swap /f neg swap ! intercept value\r
-    ] dip  \r
-    flip \r
-    nth\r
-    [ * ] with map ! apply intercep value\r
-    over v*\r
-    sum  neg\r
-    suffix ! add value as constant at the end of equation\r
-;\r
-\r
-: position-point ( halfspace v -- x ) \r
-    -1 suffix v* sum  ; inline\r
-: point-inside-halfspace? ( halfspace v -- ? )       \r
-    position-point VERY-SMALL-NUM  > ; \r
-: 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
-: get-intersection ( matrice -- seq )     \r
-    [ 1 tail* ] map     flip first ;\r
-\r
-: islenght=? ( seq n -- seq n ? ) 2dup [ length ] [ = ] bi*  ;\r
-\r
-: compare-nleft-to-identity-matrix ( seq n -- ? ) \r
-    [ [ head ] curry map ] keep  identity-matrix m- \r
-    flatten\r
-    [ abs ZERO-VALUE < ] all?\r
-;\r
-\r
-: valid-solution? ( matrice n -- ? )\r
-    islenght=?\r
-    [ compare-nleft-to-identity-matrix ]  \r
-    [ 2drop f ] if ; inline\r
-\r
-: intersect-hyperplanes ( matrice -- seq )\r
-    [ solution dup ] [ first dimension ] bi\r
-    valid-solution?     [ get-intersection ] [ drop f ] if ;\r
-\r
-! -------------------------------------------------------------\r
-! faces\r
-! -------------------------------------------------------------\r
-\r
-TUPLE: face { halfspace array } \r
-    touching-corners adjacent-faces ;\r
-: <face> ( v -- tuple )       face new swap >>halfspace ;\r
-: flip-face ( face -- face ) [ vneg ] change-halfspace ;\r
-: erase-face-touching-corners ( face -- face ) \r
-    f >>touching-corners ;\r
-: erase-face-adjacent-faces ( face -- face )   \r
-    f >>adjacent-faces ;\r
-: faces-intersection ( faces -- v )  \r
-    [ halfspace>> ] map intersect-hyperplanes ;\r
-: face-translate ( face v -- face ) \r
-    [ translate ] curry change-halfspace ; inline\r
-: face-transform ( face m -- face )\r
-    [ transform ] curry change-halfspace ; inline\r
-: face-orientation ( face -- x ) pv> swap halfspace>> nth sgn ;\r
-: backface? ( face -- face ? )      dup face-orientation 0 <= ;\r
-: pv-factor ( face -- f face )     \r
-    halfspace>> [ pv> swap nth [ * ] curry ] keep ; inline\r
-: suffix-touching-corner ( face corner -- face ) \r
-    [ suffix ] curry   change-touching-corners ; inline\r
-: real-face? ( face -- ? )\r
-    [ touching-corners>> length ] \r
-    [ halfspace>> dimension ] bi >= ;\r
-\r
-: (add-to-adjacent-faces) ( face face -- face )\r
-    over adjacent-faces>> 2dup member?\r
-    [ 2drop ] [ swap suffix >>adjacent-faces ] if ;\r
-\r
-: add-to-adjacent-faces ( face face -- face )\r
-    2dup =   [ drop ] [ (add-to-adjacent-faces) ] if ;\r
-\r
-: update-adjacent-faces ( faces corner -- )\r
-   '[ [ _ suffix-touching-corner drop ] each ] keep \r
-    2 among [ \r
-        [ first ] keep second  \r
-        [ add-to-adjacent-faces drop ] 2keep \r
-        swap add-to-adjacent-faces drop  \r
-    ] each ; inline\r
-\r
-: face-project-dim ( face -- x )  halfspace>> length 2 -  ;\r
-\r
-: apply-light ( color light normal -- u )\r
-    over direction>>  v. \r
-    neg dup 0 > \r
-    [ \r
-        [ color>> swap ] dip \r
-        [ * ] curry map v+ \r
-        [ 1 min ] map \r
-    ] \r
-    [ 2drop ] \r
-    if\r
-;\r
-\r
-: enlight-projection ( array face -- color )\r
-    ! array = lights + ambient color\r
-    [ [ third ] [ second ] [ first ] tri ]\r
-    [ halfspace>> project-vector normalize ] bi*\r
-    [ apply-light ] curry each\r
-    v*\r
-;\r
-\r
-: (intersection-into-face) ( face-init face-adja quot -- face )\r
-    [\r
-    [  [ pv-factor ] bi@ \r
-        roll \r
-        [ map ] 2bi@\r
-        v-\r
-    ] 2keep\r
-    [ touching-corners>> ] bi@\r
-    [ swap  [ = ] curry find  nip f = ] curry find nip\r
-    ] dip  over\r
-     [\r
-        call\r
-        dupd\r
-        point-inside-halfspace? [ vneg ] unless \r
-        <face> \r
-     ] [ 3drop f ] if \r
-    ; inline\r
-\r
-: intersection-into-face ( face-init face-adja -- face )\r
-    [ [ project-vector ] bi@ ]     (intersection-into-face) ;\r
-\r
-: intersection-into-silhouette-face ( face-init face-adja -- face )\r
-    [ ] (intersection-into-face) ;\r
-\r
-: intersections-into-faces ( face -- faces )\r
-    clone dup  \r
-    adjacent-faces>> [ intersection-into-face ] with map \r
-    [ ] filter ;\r
-\r
-: (face-silhouette) ( face -- faces )\r
-    clone dup adjacent-faces>>\r
-    [   backface?\r
-        [ intersection-into-silhouette-face ] [ 2drop f ]  if  \r
-    ] with map \r
-    [ ] filter\r
-; inline\r
-\r
-: face-silhouette ( face -- faces )     \r
-    backface? [ drop f ] [ (face-silhouette) ] if ;\r
-\r
-! --------------------------------\r
-! solid\r
-! -------------------------------------------------------------\r
-TUPLE: solid dimension silhouettes \r
-    faces corners adjacencies-valid color name ;\r
-\r
-: <solid> ( -- tuple ) solid new ;\r
-\r
-: suffix-silhouettes ( solid silhouette -- solid )  \r
-    [ suffix ] curry change-silhouettes ;\r
-\r
-: suffix-face ( solid face -- solid )     \r
-    [ suffix ] curry change-faces ;\r
-: suffix-corner ( solid corner -- solid ) \r
-    [ suffix ] curry change-corners ; \r
-: erase-solid-corners ( solid -- solid )  f >>corners ;\r
-\r
-: erase-silhouettes ( solid -- solid ) \r
-    dup dimension>> f <array> >>silhouettes ;\r
-: filter-real-faces ( solid -- solid ) \r
-    [ [ real-face? ] filter ] change-faces ;\r
-: initiate-solid-from-face ( face -- solid ) \r
-    face-project-dim  <solid> swap >>dimension ;\r
-\r
-: erase-old-adjacencies ( solid -- solid )\r
-    erase-solid-corners\r
-    [ dup [ erase-face-touching-corners \r
-        erase-face-adjacent-faces drop ] each ]\r
-    change-faces ;\r
-\r
-: point-inside-or-on-face? ( face v -- ? ) \r
-    [ halfspace>> ] dip point-inside-or-on-halfspace?  ;\r
-\r
-: point-inside-face? ( face v -- ? ) \r
-    [ halfspace>> ] dip  point-inside-halfspace? ;\r
-\r
-: point-inside-solid? ( solid point -- ? )\r
-    [ faces>> ] dip [ point-inside-face? ] curry all? ; inline\r
-\r
-: point-inside-or-on-solid? ( solid point -- ? )\r
-    [ faces>> ] dip \r
-    [ point-inside-or-on-face? ] curry  all?   ; inline\r
-\r
-: unvalid-adjacencies ( solid -- solid )  \r
-    erase-old-adjacencies f >>adjacencies-valid \r
-    erase-silhouettes ;\r
-\r
-: add-face ( solid face -- solid ) \r
-    suffix-face unvalid-adjacencies ; \r
-\r
-: cut-solid ( solid halfspace -- solid )    <face> add-face ; \r
-\r
-: slice-solid ( solid face  -- solid1 solid2 )\r
-    [ [ clone ] bi@ flip-face add-face \r
-    [ "/outer/" append ] change-name  ] 2keep\r
-    add-face [ "/inner/" append ] change-name ;\r
-\r
-! -------------\r
-\r
-\r
-: add-silhouette ( solid  -- solid )\r
-   dup \r
-   ! find-adjacencies \r
-   faces>> { } \r
-   [ face-silhouette append ] reduce\r
-   [ ] filter \r
-   <solid> \r
-        swap >>faces\r
-        over dimension>> >>dimension \r
-        over name>> " silhouette " append \r
-                 pv> number>string append \r
-        >>name\r
-     !   ensure-adjacencies\r
-   suffix-silhouettes ; inline\r
-\r
-: find-silhouettes ( solid -- solid )\r
-    { } >>silhouettes \r
-    dup dimension>> [ [ add-silhouette ] with-pv ] each ;\r
-\r
-: ensure-silhouettes ( solid  -- solid )\r
-    dup  silhouettes>>  [ f = ] all?\r
-    [ find-silhouettes  ]  when ; \r
-\r
-! ------------\r
-\r
-: corner-added? ( solid corner -- ? ) \r
-    ! add corner to solid if it is inside solid\r
-    [ ] \r
-    [ point-inside-or-on-solid? ] \r
-    [ swap corners>> member? not ] \r
-    2tri and\r
-    [ suffix-corner drop t ] [ 2drop f ] if ;\r
-\r
-: process-corner ( solid faces corner -- )\r
-    swapd \r
-    [ corner-added? ] keep swap ! test if corner is inside solid\r
-    [ update-adjacent-faces ] \r
-    [ 2drop ]\r
-    if ;\r
-\r
-: compute-intersection ( solid faces -- )\r
-    dup faces-intersection\r
-    dup f = [ 3drop ] [ process-corner ]  if ;\r
-\r
-: test-faces-combinaisons ( solid n -- )\r
-    [ dup faces>> ] dip among   \r
-    [ compute-intersection ] with each ;\r
-\r
-: 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
-\r
-: find-adjacencies ( solid -- solid ) \r
-    erase-old-adjacencies   \r
-    compute-adjacencies\r
-    filter-real-faces \r
-    t >>adjacencies-valid ;\r
-\r
-: ensure-adjacencies ( solid -- solid ) \r
-    dup adjacencies-valid>> \r
-    [ find-adjacencies ] unless \r
-    ensure-silhouettes\r
-    ;\r
-\r
-: (non-empty-solid?) ( solid -- ? ) \r
-    [ dimension>> ] [ corners>> length ] bi < ;\r
-: non-empty-solid? ( solid -- ? )   \r
-    ensure-adjacencies (non-empty-solid?) ;\r
-\r
-: compare-corners-roughly ( corner corner -- ? )\r
-    2drop t ;\r
-! : remove-inner-faces ( -- ) ;\r
-: face-project ( array face -- seq )\r
-    backface? \r
-  [ 2drop f ]\r
-    [   [ enlight-projection ] \r
-        [ initiate-solid-from-face ]\r
-        [ intersections-into-faces ]  tri\r
-        >>faces\r
-        swap >>color        \r
-    ]    if ;\r
-\r
-: solid-project ( lights ambient solid -- solids )\r
-  ensure-adjacencies\r
-    [ color>> ] [ faces>> ] bi [ 3array  ] dip\r
-    [ face-project ] with map \r
-    [ ] filter \r
-    [ ensure-adjacencies ] map\r
-;\r
-\r
-: (solid-move) ( solid v move -- solid ) \r
-   curry [ map ] curry \r
-   [ dup faces>> ] dip call drop  \r
-   unvalid-adjacencies ; inline\r
-\r
-: solid-translate ( solid v -- solid ) \r
-    [ face-translate ] (solid-move) ; \r
-: solid-transform ( solid m -- solid ) \r
-    [ face-transform ] (solid-move) ; \r
-\r
-: find-corner-in-silhouette ( s1 s2 -- elt bool )\r
-    pv> swap silhouettes>> nth     \r
-    swap corners>>\r
-    [ point-inside-solid? ] with find swap ;\r
-\r
-: valid-face-for-order ( solid point -- face )\r
-    [ point-inside-face? not ] \r
-    [ drop face-orientation  0 = not ] 2bi and ;\r
-\r
-: check-orientation ( s1 s2 pt -- int )\r
-    [ nip faces>> ] dip\r
-    [ valid-face-for-order ] curry find swap\r
-    [ face-orientation ] [ drop f ] if ;\r
-\r
-: (order-solid) ( s1 s2 -- int )\r
-    2dup find-corner-in-silhouette\r
-    [ check-orientation ] [ 3drop f ] if ;\r
-\r
-: order-solid ( solid solid  -- i ) \r
-    2dup (order-solid)\r
-    [ 2nip ]\r
-    [   swap (order-solid)\r
-        [ neg ] [ f ] if*\r
-    ] if* ;\r
-\r
-: subtract ( solid1 solid2 -- solids )\r
-    faces>> swap clone ensure-adjacencies ensure-silhouettes  \r
-    [ swap slice-solid drop ]  curry map\r
-    [ non-empty-solid? ] filter\r
-    [ ensure-adjacencies ] map\r
-; inline\r
-\r
-! -------------------------------------------------------------\r
-! space \r
-! -------------------------------------------------------------\r
-TUPLE: space name dimension solids ambient-color lights ;\r
-: <space> ( -- space )      space new ;\r
-: suffix-solids ( space solid -- space ) \r
-    [ suffix ] curry change-solids ; inline\r
-: suffix-lights ( space light -- space ) \r
-    [ suffix ] curry change-lights ; inline\r
-: clear-space-solids ( space -- space )     f >>solids ;\r
-\r
-: space-ensure-solids ( space -- space ) \r
-    [ [ ensure-adjacencies ] map ] change-solids ;\r
-: eliminate-empty-solids ( space -- space ) \r
-    [ [ non-empty-solid? ] filter ] change-solids ;\r
-\r
-: projected-space ( space solids -- space ) \r
-   swap dimension>> 1 -  <space>    \r
-   swap >>dimension    swap  >>solids ;\r
-\r
-: get-silhouette ( solid -- silhouette )    \r
-    silhouettes>> pv> swap nth ;\r
-: solid= ( solid solid -- ? )            [ corners>> ]  bi@ = ;\r
-\r
-: space-apply ( space m quot -- space ) \r
-        curry [ map ] curry [ dup solids>> ] dip\r
-        [ call ] [ 2drop ] recover drop ; inline\r
-: space-transform ( space m -- space ) \r
-    [ solid-transform ] space-apply ;\r
-: space-translate ( space v -- space ) \r
-    [ solid-translate ] space-apply ; \r
-\r
-: describe-space ( space -- ) \r
-    solids>>  \r
-    [  [ corners>>  [ pprint ] each ] [ name>> . ] bi ] each ;\r
-\r
-: clip-solid ( solid solid -- solids )\r
-    [ ]\r
-    [ solid= not ]\r
-    [ order-solid -1 = ] 2tri \r
-    and\r
-    [ get-silhouette subtract ] \r
-    [  drop 1array ] \r
-    if \r
-    \r
-    ;\r
-\r
-: (solids-silhouette-subtract) ( solids solid -- solids ) \r
-     [  clip-solid append ] curry { } -rot each ; inline\r
-\r
-: solids-silhouette-subtract ( solids i solid -- solids )\r
-! solids is an array of 1 solid arrays\r
-      [ (solids-silhouette-subtract) ] curry map-but \r
-; inline \r
-\r
-: remove-hidden-solids ( space -- space ) \r
-! We must include each solid in a sequence because \r
-! during substration \r
-! a solid can be divided in more than on solid\r
-    [ \r
-        [ [ 1array ] map ] \r
-        [ length ] \r
-        [ ] \r
-        tri     \r
-        [ solids-silhouette-subtract ] 2each\r
-        { } [ append ] reduce \r
-    ] change-solids\r
-    eliminate-empty-solids ! TODO include into change-solids\r
-;\r
-\r
-: space-project ( space i -- space )\r
-  [\r
-  [ clone  \r
-    remove-hidden-solids? [ remove-hidden-solids ] when\r
-    dup \r
-        [ solids>> ] \r
-        [ lights>> ] \r
-        [ ambient-color>> ]  tri \r
-        [ rot solid-project ] 2curry \r
-        map \r
-        [ append ] { } -rot each \r
-        ! TODO project lights\r
-        projected-space \r
-      ! remove-inner-faces \r
-      ! \r
-      eliminate-empty-solids\r
-    ] with-pv \r
-    ] [ 3drop <space> ] recover\r
-    ; inline\r
-\r
-: middle-of-space ( space -- point )\r
-    solids>> [ corners>> ] map concat\r
-    [ [ ] [ v+ ] map-reduce ] [ length ] bi v/n\r
-;\r
-\r
-! -------------------------------------------------------------\r
-! 3D rendering\r
-! -------------------------------------------------------------\r
-\r
-: face-reference ( face -- halfspace point vect )\r
-       [ halfspace>> ] \r
-       [ touching-corners>> first ] \r
-       [ touching-corners>> second ] tri \r
-       over v-\r
-;\r
-\r
-: theta ( v halfspace point vect -- v x )\r
-   [ [ over ] dip v- ] dip    \r
-   [ cross dup norm >float ]\r
-   [ v. >float ]  \r
-   2bi \r
-   fatan2\r
-   -rot v. \r
-   0 < [ neg ] when\r
-;\r
-\r
-: ordered-face-points ( face -- corners )  \r
-    [ touching-corners>> 1 head ] \r
-    [ touching-corners>> 1 tail ] \r
-    [ face-reference [ theta ] 3curry ]         tri\r
-    { } map>assoc    sort-values keys \r
-    append\r
-    ; inline\r
-\r
-: point->GL  ( point -- )   gl-vertex ;\r
-: points->GL ( array -- )   do-cycle [ point->GL ] each ;\r
-\r
-: face->GL ( face color -- )\r
-   [ ordered-face-points ] dip\r
-   [ first3 1.0 glColor4d GL_POLYGON \r
-        [ [ point->GL  ] each ] do-state ] curry\r
-   [  0 0 0 1 glColor4d GL_LINE_LOOP \r
-        [ [ point->GL  ] each ] do-state ]\r
-   bi\r
-   ; inline\r
-\r
-: solid->GL ( solid -- )    \r
-    [ faces>> ]    \r
-    [ color>> ] bi\r
-    [ face->GL ] curry each ; inline\r
-\r
-: space->GL ( space -- )\r
-    solids>>\r
-    [ solid->GL ] each ;\r
-\r
-\r
-\r
-\r
-\r
diff --git a/extra/adsoda/adsoda.tests b/extra/adsoda/adsoda.tests
deleted file mode 100755 (executable)
index f0b0c54..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-! : init-4D-demo ( -- space )\r
-! OK\r
-! espace de dimension 4 et de couleur 0,3 0.3 0.3\r
-<space> \r
-    4 >>dimension\r
-    { 0.3 0.3 0.3 } >>ambient-color\r
-    { 100 150 100  150 100 150 100 150 } "4cube1" 4cube suffix-solids\r
-   { 160 180  160 180 160 180 160 180 } "4cube2" 4cube suffix-solids\r
-    <light>\r
-        { -100 -100 -100 -100 } >>position\r
-        { 0.2 0.7 0.1 } >>color\r
-        suffix-lights\r
-! ;\r
-! : init-3D-demo ( -- space )\r
-! OK\r
-! espace de dimension 4 et de couleur 0,3 0.3 0.3\r
-<space> \r
-    3 >>dimension\r
-    { 0.3 0.3 0.3 } >>ambient-color\r
-    { 100 150 100  150 100 150 } "3cube1" 3cube suffix-solids\r
-  !  { -150 -10  -150 -10 -150 -10 -150 -10 } "4cube2" 4cube suffix-solids\r
-    <light>\r
-        { -100 -100 -100 -100 } >>position\r
-        { 0.2 0.7 0.1 } >>color\r
-        suffix-lights\r
-! ;\r
-\r
-\r
-: s1 ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    "s1" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 -1 -5 } cut-solid \r
-    { -1 -1 -21 } cut-solid \r
-    { -1 0 -12 } cut-solid \r
-    { 1 2 16 } cut-solid\r
-;\r
-: solid1 ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    "solid1" >>name\r
-    { 1 -1 -5 } cut-solid \r
-    { -1 -1 -21 } cut-solid \r
-    { -1 0 -12 } cut-solid \r
-    { 1 2 16 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-;\r
-: solid2 ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    "solid2" >>name\r
-    { -1 1 -10 } cut-solid \r
-    { -1 -1 -28 } cut-solid \r
-    { 1 0 13 } cut-solid \r
- !   { 1 2 16 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid3 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid3" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 16 } cut-solid \r
-    { -1 0 -36 } cut-solid \r
-    { 0 1 1 } cut-solid \r
-    { 0 -1  -17 } cut-solid \r
- !   { 1 2 16 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-\r
-;\r
-\r
-: solid4 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid4" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 21 } cut-solid \r
-    { -1 0 -36 } cut-solid \r
-    { 0 1 1 } cut-solid \r
-    { 0 -1  -17 } cut-solid \r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid5 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid5" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 6 } cut-solid \r
-    { -1 0 -17 } cut-solid \r
-    { 0 1 17 } cut-solid \r
-    { 0 -1  -19 } cut-solid \r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid7 ( -- solid )\r
-      <solid> \r
-    2 >>dimension\r
-    "solid7" >>name\r
-    { 1 1 1 } >>color\r
-    { 1 0 38 } cut-solid \r
-    { 1 -5 -66 } cut-solid \r
-    { -2 1 -75 } cut-solid\r
-    ensure-adjacencies\r
-    \r
-;\r
-\r
-: solid6s ( -- seq )\r
-  solid3 clone solid2 clone subtract\r
-;\r
-\r
-: space1 ( -- space )\r
-    <space>\r
-        2 >>dimension\r
-     !    solid3 suffix-solids\r
-        solid1 suffix-solids\r
-        solid2 suffix-solids\r
-    !   solid6s [ suffix-solids ] each \r
-        solid4 suffix-solids\r
-     !   solid5 suffix-solids\r
-        solid7 suffix-solids\r
-        { 1 1 1 } >>ambient-color\r
-            <light>\r
-        { -100 -100 } >>position\r
-        { 0.2 0.7 0.1 } >>color\r
-        suffix-lights\r
-;\r
-\r
-: space2 ( -- space )\r
-    <space>\r
-        4 >>dimension\r
-       ! 4cube suffix-solids\r
-        { 1 1 1 } >>ambient-color\r
-            <light>\r
-        { -100 -100 } >>position\r
-        { 0.2 0.7 0.1 } >>color\r
-        suffix-lights\r
-\r
-       ;\r
-\r
diff --git a/extra/adsoda/authors.txt b/extra/adsoda/authors.txt
deleted file mode 100755 (executable)
index 856f3b0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Jeff Bigot\r
-Greg Ferrar
\ No newline at end of file
diff --git a/extra/adsoda/combinators/authors.txt b/extra/adsoda/combinators/authors.txt
deleted file mode 100755 (executable)
index e7f4cde..0000000
+++ /dev/null
@@ -1 +0,0 @@
-JF Bigot, after Greg Ferrar
\ No newline at end of file
diff --git a/extra/adsoda/combinators/combinators-docs.factor b/extra/adsoda/combinators/combinators-docs.factor
deleted file mode 100755 (executable)
index 5b540e7..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays help.markup help.syntax kernel sequences ;
-IN: adsoda.combinators
-
-HELP: among
-{ $values
-     { "array" array } { "n" "number of value to select" }
-     { "array" array }
-}
-{ $description "returns an array containings every possibilities of n choices among a given sequence" } ;
-
-HELP: columnize
-{ $values
-     { "array" array }
-     { "array" array }
-}
-{ $description "flip a sequence into a sequence of 1 element sequences" } ;
-
-HELP: concat-nth
-{ $values
-     { "seq1" sequence } { "seq2" sequence }
-     { "seq" sequence }
-}
-{ $description "merges 2 sequences of sequences appending corresponding elements" } ;
-
-HELP: do-cycle
-{ $values
-     { "array" array }
-     { "array" array }
-}
-{ $description "Copy the first element at the end of the sequence in order to close the cycle." } ;
-
-
-ARTICLE: "adsoda.combinators" "Combinators"
-{ $vocab-link "adsoda.combinators" }
-;
-
-ABOUT: "adsoda.combinators"
diff --git a/extra/adsoda/combinators/combinators-tests.factor b/extra/adsoda/combinators/combinators-tests.factor
deleted file mode 100755 (executable)
index 6796929..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-USING: adsoda.combinators\r
-sequences\r
-    tools.test \r
- ;\r
-\r
-IN: adsoda.combinators.tests\r
-\r
-\r
-[ { "atoto" "b" "ctoto" } ] [ { "a" "b" "c" } 1 [ "toto" append ] map-but ] \r
-    unit-test\r
-\r
diff --git a/extra/adsoda/combinators/combinators.factor b/extra/adsoda/combinators/combinators.factor
deleted file mode 100755 (executable)
index d00eebc..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel arrays sequences fry math combinators ;\r
-\r
-IN: adsoda.combinators\r
-\r
-! : (combinations) ( seq -- seq ) [ 1 tail ] dip combinations ;\r
-\r
-! : prefix-each [ prefix ] curry map ; inline\r
-\r
-! : combinations ( seq n -- seqs )\r
-!    {\r
-!        { [ dup 0 = ] [ 2drop { { } } ] }\r
-!        { [ over empty? ] [ 2drop { } ] }\r
-!        { [ t ] [ \r
-!            [ [ 1 - (combinations) ] [ drop first ] 2bi prefix-each ]\r
-!            [ (combinations) ] 2bi append\r
-!        ] }\r
-!    } cond ;\r
-\r
-: columnize ( array -- array ) [ 1array ] map ; inline\r
-\r
-: among ( array n -- array )\r
-    2dup swap length \r
-    {\r
-        { [ over 1 = ] [ 3drop columnize ] }\r
-        { [ over 0 = ] [ 2drop 2drop { } ] }\r
-        { [ 2dup < ] [ 2drop [ 1 cut ] dip  \r
-                         [ 1 - among [ append ] with map  ] \r
-                         [ among append ] 2bi\r
-                       ] }\r
-        { [ 2dup = ] [ 3drop 1array ] }\r
-        { [ 2dup > ] [ 2drop 2drop {  } ] } \r
-    } cond\r
-;\r
-\r
-: concat-nth ( seq1 seq2 -- seq )  \r
-    [ nth append ] curry map-index ;\r
-\r
-: do-cycle   ( array -- array )   dup first suffix ;\r
-\r
-: map-but ( seq i quot -- seq )\r
-    ! quot : ( seq x -- seq )\r
-    '[ _ = [ @ ] unless ] map-index ; inline\r
-\r
diff --git a/extra/adsoda/solution2/solution2.factor b/extra/adsoda/solution2/solution2.factor
deleted file mode 100755 (executable)
index fa73120..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-USING: kernel\r
-sequences\r
-namespaces\r
-\r
-math\r
-math.vectors\r
-math.matrices\r
-;\r
-IN: adsoda.solution2\r
-\r
-! -------------------\r
-! correctif solution\r
-! ---------------\r
-SYMBOL: matrix\r
-: MIN-VAL-adsoda ( -- x ) 0.00000001\r
-! 0.000000000001 \r
-;\r
-\r
-: zero? ( x -- ? ) \r
-    abs MIN-VAL-adsoda <\r
-;\r
-\r
-! [ number>string string>number ] map \r
-\r
-: with-matrix ( matrix quot -- )\r
-    [ swap matrix set call matrix get ] with-scope ; inline\r
-\r
-: nth-row ( row# -- seq ) matrix get nth ;\r
-\r
-: change-row ( row# quot -- seq ) ! row# quot -- | quot: seq -- seq )\r
-    matrix get swap change-nth ; inline\r
-\r
-: exchange-rows ( row# row# -- ) matrix get exchange ;\r
-\r
-: rows ( -- n ) matrix get length ;\r
-\r
-: cols ( -- n ) 0 nth-row length ;\r
-\r
-: skip ( i seq quot -- n )\r
-    over [ find-from drop ] dip length or ; inline\r
-\r
-: first-col ( row# -- n )\r
-    #! First non-zero column\r
-    0 swap nth-row [ zero? not ] skip ;\r
-\r
-: clear-scale ( col# pivot-row i-row -- n )\r
-    [ over ] dip nth dup zero? [\r
-        3drop 0\r
-    ] [\r
-        [ nth dup zero? ] dip swap [\r
-            2drop 0\r
-        ] [\r
-            swap / neg\r
-        ] if\r
-    ] if ;\r
-\r
-: (clear-col) ( col# pivot-row i -- )\r
-    [ [ clear-scale ] 2keep [ n*v ] dip v+ ] change-row ;\r
-\r
-: rows-from ( row# -- slice )\r
-    rows dup <slice> ;\r
-\r
-: clear-col ( col# row# rows -- )\r
-    [ nth-row ] dip [ [ 2dup ] dip (clear-col) ] each 2drop ;\r
-\r
-: do-row ( exchange-with row# -- )\r
-    [ exchange-rows ] keep\r
-    [ first-col ] keep\r
-    dup 1 + rows-from clear-col ;\r
-\r
-: find-row ( row# quot -- i elt )\r
-    [ rows-from ] dip find ; inline\r
-\r
-: pivot-row ( col# row# -- n )\r
-    [ dupd nth-row nth zero? not ] find-row 2nip ;\r
-\r
-: (echelon) ( col# row# -- )\r
-    over cols < over rows < and [\r
-        2dup pivot-row [ over do-row 1 + ] when*\r
-        [ 1 + ] dip (echelon)\r
-    ] [\r
-        2drop\r
-    ] if ;\r
-\r
-: echelon ( matrix -- matrix' )\r
-    [ 0 0 (echelon) ] with-matrix ;\r
-\r
-: nonzero-rows ( matrix -- matrix' )\r
-    [ [ zero? ] all? not ] filter ;\r
-\r
-: null/rank ( matrix -- null rank )\r
-    echelon dup length swap nonzero-rows length [ - ] keep ;\r
-\r
-: leading ( seq -- n elt ) [ zero? not ] find ;\r
-\r
-: reduced ( matrix' -- matrix'' )\r
-    [\r
-        rows <reversed> [\r
-            dup nth-row leading drop\r
-            dup [ swap dup clear-col ] [ 2drop ] if\r
-        ] each\r
-    ] with-matrix ;\r
-\r
-: basis-vector ( row col# -- )\r
-    [ clone ] dip\r
-    [ swap nth neg recip ] 2keep\r
-    [ 0 spin set-nth ] 2keep\r
-    [ n*v ] dip\r
-    matrix get set-nth ;\r
-\r
-: nullspace ( matrix -- seq )\r
-    echelon reduced dup empty? [\r
-        dup first length identity-matrix [\r
-            [\r
-                dup leading drop\r
-                dup [ basis-vector ] [ 2drop ] if\r
-            ] each\r
-        ] with-matrix flip nonzero-rows\r
-    ] unless ;\r
-\r
-: 1-pivots ( matrix -- matrix )\r
-    [ dup leading nip [ recip v*n ] when* ] map ;\r
-\r
-: solution ( matrix -- matrix )\r
-    echelon nonzero-rows reduced 1-pivots ;\r
-\r
diff --git a/extra/adsoda/solution2/summary.txt b/extra/adsoda/solution2/summary.txt
deleted file mode 100755 (executable)
index a25a451..0000000
+++ /dev/null
@@ -1 +0,0 @@
-A modification of solution to approximate solutions
\ No newline at end of file
diff --git a/extra/adsoda/summary.txt b/extra/adsoda/summary.txt
deleted file mode 100755 (executable)
index ee666bc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ADSODA : Arbitrary-Dimensional Solid Object Display Algorithm
\ No newline at end of file
diff --git a/extra/adsoda/tags.txt b/extra/adsoda/tags.txt
deleted file mode 100755 (executable)
index 6e25b2f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-adsoda 4D viewer
\ No newline at end of file
diff --git a/extra/adsoda/tools/authors.txt b/extra/adsoda/tools/authors.txt
deleted file mode 100755 (executable)
index a6a9693..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Jeff Bigot
\ No newline at end of file
diff --git a/extra/adsoda/tools/tools-docs.factor b/extra/adsoda/tools/tools-docs.factor
deleted file mode 100755 (executable)
index 1d952e3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays help.markup help.syntax kernel sequences ;
-IN: adsoda.tools
-
-HELP: 3cube
-{ $values 
-    { "array" "array" } { "name" "name" } 
-    { "solid" "solid" } 
-}
-{ $description "array : xmin xmax ymin ymax zmin zmax" 
-"returns a 3D solid with given limits"
-} ;
-
-HELP: 4cube
-{ $values 
-    { "array" "array" } { "name" "name" } 
-    { "solid" "solid" } 
-}
-{ $description "array : xmin xmax ymin ymax zmin zmax wmin wmax"  
-"returns a 4D solid with given limits"
-} ;
-
-
-HELP: equation-system-for-normal
-{ $values
-     { "points" "a list of n points" }
-     { "matrix" "matrix" }
-}
-{ $description "From a list of points, return the matrix" 
-"to solve in order to find the vector normal to the plan defined by the points" } 
-;
-
-HELP: normal-vector
-{ $values
-     { "points" "a list of n points" }
-     { "v" "a vector" }
-}
-{ $description "From a list of points, returns the vector normal to the plan defined by the points" 
-"With n points, creates n-1 vectors and then find a vector orthogonal to every others"
-"returns { f } if a normal vector can not be found" } 
-;
-
-HELP: points-to-hyperplane
-{ $values
-     { "points" "a list of n points" }
-     { "hyperplane" "an hyperplane equation" }
-}
-{ $description "From a list of points, returns the equation of the hyperplan"
-"Finds a normal vector and then translate it so that it includes one of the points"
-
-} 
-;
-
-ARTICLE: "adsoda.tools" "Tools"
-{ $vocab-link "adsoda.tools" }
-"Tools to help in building an " { $vocab-link "adsoda" } "-space"
-;
-
-ABOUT: "adsoda.tools"
-
-
diff --git a/extra/adsoda/tools/tools-tests.factor b/extra/adsoda/tools/tools-tests.factor
deleted file mode 100755 (executable)
index bb54194..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: \r
-adsoda.tools\r
-tools.test\r
-;\r
-\r
-IN: adsoda.tools.tests\r
-\r
-\r
- [ { 1 0 } ] [ { { 0 0 } { 0 1 } }  normal-vector    ] unit-test\r
- [ f ] [ { { 0 0 } { 0 0 } }  normal-vector    ] unit-test\r
-\r
- [  { 1/2 1/2 1+1/2 }  ] [ { { 1 2 } { 2 1 } }  points-to-hyperplane ] unit-test\r
diff --git a/extra/adsoda/tools/tools.factor b/extra/adsoda/tools/tools.factor
deleted file mode 100755 (executable)
index 6c4f4c3..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: \r
-kernel\r
-sequences\r
-math\r
-accessors\r
-adsoda\r
-math.vectors \r
-math.matrices\r
-bunny.model\r
-io.encodings.ascii\r
-io.files\r
-sequences.deep\r
-combinators\r
-adsoda.combinators\r
-fry\r
-io.files.temp\r
-grouping\r
-;\r
-\r
-IN: adsoda.tools\r
-\r
-\r
-\r
-\r
-\r
-! ---------------------------------\r
-: coord-min ( x array -- array )  swap suffix  ;\r
-: coord-max ( x array -- array )  swap neg suffix ;\r
-\r
-: 4cube ( array name -- solid )\r
-! array : xmin xmax ymin ymax zmin zmax wmin wmax\r
-    <solid> \r
-    4 >>dimension\r
-    swap >>name\r
-    swap\r
-    { \r
-       [ { 1 0 0 0 } coord-min ] [ { -1 0 0 0 } coord-max ] \r
-       [ { 0 1 0 0 } coord-min ] [ { 0 -1 0 0 } coord-max ]\r
-       [ { 0 0 1 0 } coord-min ] [ { 0 0 -1 0 } coord-max ] \r
-       [ { 0 0 0 1 } coord-min ] [ { 0 0 0 -1 } coord-max ]\r
-    }\r
-    [ curry call ] 2map \r
-    [ cut-solid ] each \r
-    ensure-adjacencies\r
-    \r
-; inline\r
-\r
-: 3cube ( array name -- solid )\r
-! array : xmin xmax ymin ymax zmin zmax wmin wmax\r
-    <solid> \r
-    3 >>dimension\r
-    swap >>name\r
-    swap\r
-    { \r
-       [ { 1 0 0 } coord-min ] [ { -1 0 0 } coord-max ] \r
-       [ { 0 1 0 } coord-min ] [ { 0 -1 0 } coord-max ]\r
-       [ { 0 0 1 } coord-min ] [ { 0 0 -1 } coord-max ] \r
-    }\r
-    [ curry call ] 2map \r
-    [ cut-solid ] each \r
-    ensure-adjacencies\r
-    \r
-; inline\r
-\r
-\r
-: equation-system-for-normal ( points -- matrix )\r
-    unclip [ v- 0 suffix ] curry map\r
-    dup first [ drop 1 ] map     suffix\r
-;\r
-\r
-: normal-vector ( points -- v ) \r
-    equation-system-for-normal\r
-    intersect-hyperplanes ;\r
-\r
-: points-to-hyperplane ( points -- hyperplane )\r
-    [ normal-vector 0 suffix ] [ first ] bi\r
-    translate ;\r
-\r
-: refs-to-points ( points faces -- faces )\r
-   [ swap [ nth 10 v*n { 100 100 100 } v+ ] curry map ] \r
-   with map\r
-;\r
-! V{ { 0.1 0.2 } { 1.1 1.3 } } V{ { 1 0 } { 0 1 } }\r
-! V{ { { 1.1 1.3 } { 0.1 0.2 } } { { 0.1 0.2 } { 1.1 1.3 } } }\r
-\r
-: ply-model-path ( -- path )\r
-\r
-! "bun_zipper.ply" \r
-"screw2.ply"\r
-temp-file \r
-;\r
-\r
-: read-bunny-model ( -- v )\r
-ply-model-path ascii [  parse-model ] with-file-reader\r
-\r
-refs-to-points\r
-;\r
-\r
-: 3points-to-normal ( seq -- v )\r
-    unclip [ v- ] curry map first2 cross normalize\r
-;\r
-: 2-faces-to-prism ( seq seq -- seq )\r
-  2dup\r
-    [ do-cycle 2 clump ] bi@ concat-nth  \r
-    !  3 faces rectangulaires\r
-    swap prefix\r
-    swap prefix\r
-;    \r
-\r
-: Xpoints-to-prisme ( seq height -- cube )\r
-    ! from 3 points gives a list of faces representing \r
-    ! a cube of height "height"\r
-    ! and of based on the three points\r
-    ! a face is a group of 3 or mode points.   \r
-    [ dup dup  3points-to-normal ] dip \r
-    v*n [ v+ ] curry map ! 2 eme face triangulaire \r
-    2-faces-to-prism  \r
-\r
-! [ dup number? [ 1 + ] when ] deep-map\r
-! dup keep \r
-;\r
-\r
-\r
-: Xpoints-to-plane4D ( seq x y -- 4Dplane )\r
-    ! from 3 points gives a list of faces representing \r
-    ! a cube in 4th dim\r
-    ! from x to y (height = y-x)\r
-    ! and of based on the X points\r
-    ! a face is a group of 3 or mode points.   \r
-    '[ [ [ _ suffix ] map ] [ [ _ suffix ] map ] bi ] call\r
-    2-faces-to-prism\r
-;\r
-\r
-: 3pointsfaces-to-3Dsolidfaces ( seq -- seq )\r
-    [ 1 Xpoints-to-prisme [ 100 \r
-        110 Xpoints-to-plane4D ] map concat ] map \r
-\r
-;\r
-\r
-: test-figure ( -- solid )\r
-    <solid> \r
-    2 >>dimension\r
-    { 1 -1 -5 } cut-solid \r
-    { -1 -1 -21 } cut-solid \r
-    { -1 0 -12 } cut-solid \r
-    { 1 2 16 } cut-solid\r
-;\r
-\r
index 72f5cb5517ecf55cb46e3a5c6bae83655fc4888f..6c93e8f4b633d400df3f52ce4cceb0704e010440 100644 (file)
@@ -1,7 +1,8 @@
 ! (c)Joe Groff bsd license
 USING: accessors alien alien.c-types alien.data alien.parser arrays
 byte-arrays combinators effects.parser fry generalizations grouping kernel
-lexer locals macros make math math.ranges parser sequences sequences.private ;
+lexer locals macros make math math.ranges parser sequences
+sequences.generalizations sequences.private ;
 FROM: alien.arrays => array-length ;
 IN: alien.data.map
 
@@ -117,14 +118,14 @@ MACRO: data-map! ( ins outs -- )
 
 : parse-data-map-effect ( accum -- accum )
     ")" parse-effect
-    [ in>>  [ (parse-c-type) ] map parsed ]
-    [ out>> [ (parse-c-type) ] map parsed ] bi ;
+    [ in>>  [ (parse-c-type) ] map suffix! ]
+    [ out>> [ (parse-c-type) ] map suffix! ] bi ;
 
 PRIVATE>
 
 SYNTAX: data-map(
-    parse-data-map-effect \ data-map parsed ;
+    parse-data-map-effect \ data-map suffix! ;
 
 SYNTAX: data-map!(
-    parse-data-map-effect \ data-map! parsed ;
+    parse-data-map-effect \ data-map! suffix! ;
 
index 48fd281c6cdf8c37b670c1fd8be2d772f1ae794b..b03494ce015e793ee8a7bd2403d6aba79b7e0b56 100644 (file)
@@ -23,5 +23,8 @@ IN: annotations.tests
     } 1&&
 ] unit-test
 
-[ { four three } ] [ BROKENs natural-sort ] unit-test
-[ { five } ] [ TODOs ] unit-test
+[ t ] [
+    BROKENs { [ \ four swap member? ] [ \ three swap member? ] } 1&&
+] unit-test
+
+[ t ] [ TODOs \ five swap member? ] unit-test
index 387c73abe4807e0f2eb4ede82d245b91f4bf4ecf..e463206e4fee99be771bc19e54d7c8714aecd973 100644 (file)
@@ -7,7 +7,7 @@ IN: annotations
 <<
 
 : (parse-annotation) ( accum -- accum )
-    lexer get [ line-text>> parsed ] [ next-line ] bi ;
+    lexer get [ line-text>> suffix! ] [ next-line ] bi ;
 
 : (non-annotation-usage) ( word -- usages )
     smart-usage
@@ -24,7 +24,7 @@ NAMEs. DEFINES ${NAME}s.
 WHERE
 
 : (NAME) ( str -- ) drop ; inline
-SYNTAX: !NAME (parse-annotation) \ (NAME) parsed ;
+SYNTAX: !NAME (parse-annotation) \ (NAME) suffix! ;
 
 : NAMEs ( -- usages )
     \ (NAME) (non-annotation-usage) ;
index 31a4b75eb2e985bddb92e7b55d992bd2671c0f92..a379a03828a227d7269b5befdda8e5ce050e4b22 100644 (file)
@@ -63,7 +63,7 @@ C: <transaction> transaction
 
 : process-to-date ( account date -- account )
     over interest-last-paid>> 1 days time+
-    [ dupd process-day ] spin each-day ;
+    [ [ dupd process-day ] ] 2dip swap each-day ;
 
 : inserting-transactions ( account transactions -- account )
     [ [ date>> process-to-date ] keep >>transaction ] each ;
index 27040edac3e5909afc5d852916f78b5ba93a8ba2..856fd8e25d07bc6ac27533f8d95d892f552e9f1b 100755 (executable)
@@ -38,9 +38,9 @@ MEMO: 24-from-4 ( a b c d -- ? )
                 1 10 [a,b] [| d |
                     a b c d 24-from-4
                 ] count
-            ] sigma
-        ] sigma
-    ] sigma ;
+            ] map-sum
+        ] map-sum
+    ] map-sum ;
 
 CONSTANT: words { 24-from-1 24-from-2 24-from-3 24-from-4 }
 
index 14ebcb1c5b4e50bfbda653b63b6928af992f14a5..92715dc9c727eacafda7400228b8c49bc42cf6ce 100755 (executable)
@@ -7,25 +7,24 @@ IN: benchmark.beust2
 
 :: (count-numbers) ( remaining first value used max listener: ( -- ) -- ? )
     10 first - iota [| i |
-        [let* | digit [ i first + ]
-                mask [ digit 2^ ]
-                value' [ i value + ] |
-            used mask bitand zero? [
-                value max > [ t ] [
-                    remaining 1 <= [
-                        listener call f
-                    ] [
-                        remaining 1 -
-                        0
-                        value' 10 *
-                        used mask bitor
-                        max
-                        listener
-                        (count-numbers)
-                    ] if
+        i first + :> digit
+        digit 2^ :> mask
+        i value + :> value'
+        used mask bitand zero? [
+            value max > [ t ] [
+                remaining 1 <= [
+                    listener call f
+                ] [
+                    remaining 1 -
+                    0
+                    value' 10 *
+                    used mask bitor
+                    max
+                    listener
+                    (count-numbers)
                 ] if
-            ] [ f ] if
-        ]
+            ] if
+        ] [ f ] if
     ] any? ; inline recursive
 
 :: count-numbers ( max listener -- )
@@ -33,9 +32,8 @@ IN: benchmark.beust2
     inline
 
 :: beust ( -- )
-    [let | i! [ 0 ] |
-        5000000000 [ i 1 + i! ] count-numbers
-        i number>string " unique numbers." append print
-    ] ;
+    0 :> i!
+    5000000000 [ i 1 + i! ] count-numbers
+    i number>string " unique numbers." append print ;
 
 MAIN: beust
index 4957822b5e85bf57f02b474842c7bb1e22c705a4..a909602f8c5d4b482a986be6cc0e366180c90c53 100644 (file)
@@ -4,7 +4,7 @@ USING: kernel math math.combinatorics math.ranges sequences ;
 IN: benchmark.e-ratios
 
 : calculate-e-ratios ( n -- e )
-    iota [ factorial recip ] sigma ;
+    iota [ factorial recip ] map-sum ;
 
 : calculate-e-ratios-benchmark ( -- )
     5 [ 300 calculate-e-ratios drop ] times ;
index 63e635f3de4ccbe8444d173203dcf8a2d403c356..f3a41ca4a98dcc38e694dd9d789b76a0f74956fc 100644 (file)
@@ -12,7 +12,7 @@ IN: benchmark.fannkuch
 : count-flips ( perm -- flip# )
     '[
         _ dup first dup 1 =
-        [ 2drop f ] [ head-slice reverse-here t ] if
+        [ 2drop f ] [ head-slice reverse! drop t ] if
     ] count ; inline
 
 : write-permutation ( perm -- )
@@ -24,7 +24,7 @@ IN: benchmark.fannkuch
 
 : fannkuch ( n -- )
     [
-        [ 0 0 ] dip [ 1 + ] B{ } map-as
+        [ 0 0 ] dip iota [ 1 + ] B{ } map-as
         [ fannkuch-step ] each-permutation nip
     ] keep
     "Pfannkuchen(" write pprint ") = " write . ;
index 1ad769173bb8c4c5291c46cad2212fd79dfb4879..5ba285dbb18343441d63a89938a359b913571ace 100755 (executable)
@@ -71,37 +71,35 @@ CONSTANT: homo-sapiens
     [ make-random-fasta ] 2curry split-lines ; inline
 
 :: make-repeat-fasta ( k len alu -- k' )
-    [let | kn [ alu length ] |
-        len [ k + kn mod alu nth-unsafe ] "" map-as print
-        k len +
-    ] ; inline
+    alu length :> kn
+    len [ k + kn mod alu nth-unsafe ] "" map-as print
+    k len + ; inline
 
 : write-repeat-fasta ( n alu desc id -- )
     write-description
-    [let | k! [ 0 ] alu [ ] |
+    [let
+        :> alu
+        0 :> k!
         [| len | k len alu make-repeat-fasta k! ] split-lines
     ] ; inline
 
 : fasta ( n out -- )
     homo-sapiens make-cumulative
     IUB make-cumulative
-    [let | homo-sapiens-floats [ ]
-           homo-sapiens-chars [ ]
-           IUB-floats [ ]
-           IUB-chars [ ]
-           out [ ]
-           n [ ]
-           seed [ initial-seed ] |
+    [let
+        :> ( n out IUB-chars IUB-floats homo-sapiens-chars homo-sapiens-floats )
+        initial-seed :> seed
 
         out ascii [
             n 2 * ALU "Homo sapiens alu" "ONE" write-repeat-fasta
 
             initial-seed
-            n 3 * homo-sapiens-chars homo-sapiens-floats "IUB ambiguity codes" "TWO" write-random-fasta
-            n 5 * IUB-chars IUB-floats "Homo sapiens frequency" "THREE" write-random-fasta
+            n 3 * homo-sapiens-chars homo-sapiens-floats
+            "IUB ambiguity codes" "TWO" write-random-fasta
+            n 5 * IUB-chars IUB-floats
+            "Homo sapiens frequency" "THREE" write-random-fasta
             drop
         ] with-file-writer
-
     ] ;
 
 : run-fasta ( -- ) 2500000 reverse-complement-in fasta ;
index 7ddd58468abc87015d89059498146c34a864d084..561110d941d0624760c000a1a22e4f9cd8695008 100755 (executable)
@@ -1,13 +1,13 @@
-USING: math kernel alien ;\r
+USING: math kernel alien alien.c-types ;\r
 IN: benchmark.fib6\r
 \r
 : fib ( x -- y )\r
-    "int" { "int" } "cdecl" [\r
+    int { int } "cdecl" [\r
         dup 1 <= [ drop 1 ] [\r
             1 - dup fib swap 1 - fib +\r
         ] if\r
     ] alien-callback\r
-    "int" { "int" } "cdecl" alien-indirect ;\r
+    int { int } "cdecl" alien-indirect ;\r
 \r
 : fib-main ( -- ) 32 fib drop ;\r
 \r
index fb4f17cca5c768615975aa03451108ebf4bea86a..a28a676b904b72957dae0aed314e03c24d747317 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel io io.files splitting strings io.encodings.ascii
+USING: kernel locals io io.files splitting strings io.encodings.ascii
        hashtables sequences assocs math namespaces prettyprint
        math.parser combinators arrays sorting unicode.case ;
 
@@ -21,10 +21,7 @@ IN: benchmark.knucleotide
     CHAR: \n swap remove >upper ;
 
 : tally ( x exemplar -- b )
-    clone tuck
-    [
-      [ [ 1 + ] [ 1 ] if* ] change-at
-    ] curry each ;
+    clone [ [ inc-at ] curry each ] keep ;
 
 : small-groups ( x n -- b )
     swap
@@ -42,10 +39,10 @@ IN: benchmark.knucleotide
     ] each
     drop ;
 
-: handle-n ( inputs x -- )
-    tuck length
-    small-groups H{ } tally
-    at [ 0 ] unless*
+:: handle-n ( inputs x -- )
+    inputs x length small-groups :> groups
+    groups H{ } tally :> b
+    x b at [ 0 ] unless*
     number>string 8 CHAR: \s pad-tail write ;
 
 : process-input ( input -- )
index 15c0f9ee0b1dc0670c933152d1a5274fcef9759b..e27d5159fdaa720a9ee0df31c4ca49f3c6a15363 100644 (file)
@@ -20,7 +20,7 @@ byte-arrays make io ;
     ] if ; inline recursive
 
 : nsieve ( m -- count )
-    0 2 rot 1 + <byte-array> dup [ drop 1 ] change-each (nsieve) ;
+    0 2 rot 1 + <byte-array> [ drop 1 ] map! (nsieve) ;
 
 : nsieve. ( m -- )
     [ "Primes up to " % dup # " " % nsieve # ] "" make print ;
index 4147ffabdfa06657cd07c125cb56ac1ee1c111cc..95035e6cd8dff2babc1a89aaf2310e7dde5511da 100755 (executable)
@@ -9,13 +9,13 @@ IN: benchmark.reverse-complement
 TR: trans-map ch>upper "ACGTUMRYKVHDB" "TGCAAKYRMBDHV" ;
 
 : translate-seq ( seq -- str )
-    concat dup reverse-here dup trans-map-fast ;
+    concat reverse! dup trans-map-fast ;
 
 : show-seq ( seq -- )
     translate-seq 60 <groups> [ print ] each ;
 
 : do-line ( seq line -- seq )
-    dup first ">;" memq?
+    dup first ">;" member-eq?
     [ over show-seq print dup delete-all ] [ over push ] if ;
 
 HINTS: do-line vector string ;
index 4b3c4a5b9f43211ad972cd3a67590eaf991e4c0e..ff0cb98a0096171c35569313c5c11450e7a7004c 100644 (file)
@@ -15,7 +15,7 @@ IN: benchmark.simd-1
     iota [ <point> ] float-4-array{ } map-as ; inline
 
 : normalize-points ( points -- )
-    [ normalize ] change-each ; inline
+    [ normalize ] map! drop ; inline
 
 : max-points ( points -- point )
     [ ] [ vmax ] map-reduce ; inline
index bd9a7139b3c3511214088df988538e4e61a6d289..38ce0087a2c209d74f61cd97848bf320c23b86ae 100644 (file)
@@ -14,7 +14,7 @@ TUPLE-ARRAY: point
             [ 1 + ] change-x
             [ 1 - ] change-y
             [ 1 + 2 / ] change-z
-        ] map [ z>> ] sigma
-    ] sigma . ;
+        ] map [ z>> ] map-sum
+    ] map-sum . ;
 
 MAIN: tuple-array-benchmark
index bd13de32c744f8a6aeba3bc9cb6339d923ed4c48..024887991e9af4a12865846bd3cafecc2b994a84 100644 (file)
@@ -17,20 +17,19 @@ STRUCT: yuv_buffer
     { v void* } ;
 
 :: fake-data ( -- rgb yuv )
-    [let* | w [ 1600 ]
-            h [ 1200 ]
-            buffer [ yuv_buffer <struct> ]
-            rgb [ w h * 3 * <byte-array> ] |
-        rgb buffer
-            w >>y_width
-            h >>y_height
-            h >>uv_height
-            w >>y_stride
-            w >>uv_stride
-            w h * [ dup * ] B{ } map-as malloc-byte-array &free >>y
-            w h * 2/ [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
-            w h * 2/ [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v
-    ] ;
+    1600 :> w
+    1200 :> h
+    yuv_buffer <struct> :> buffer
+    w h * 3 * <byte-array> :> rgb
+    rgb buffer
+        w >>y_width
+        h >>y_height
+        h >>uv_height
+        w >>y_stride
+        w >>uv_stride
+        w h * [ dup * ] B{ } map-as malloc-byte-array &free >>y
+        w h * 2/ [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
+        w h * 2/ [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
 
 : clamp ( n -- n )
     255 min 0 max ; inline
index d80f3aa98aa6f00f2d5461c7b86a72d7a0f2a337..b9923d5976cf74149eb920d749bb79cf11b4b842 100755 (executable)
@@ -1,6 +1,6 @@
 USING: accessors alien.c-types arrays combinators destructors
 http.client io io.encodings.ascii io.files io.files.temp kernel
-math math.matrices math.parser math.vectors opengl
+locals math math.matrices math.parser math.vectors opengl
 opengl.capabilities opengl.gl opengl.demo-support sequences
 splitting vectors words specialized-arrays ;
 QUALIFIED-WITH: alien.c-types c
@@ -51,8 +51,11 @@ IN: bunny.model
         over download-to
     ] unless ;
 
-: (draw-triangle) ( ns vs triple -- )
-    [ dup roll nth gl-normal swap nth gl-vertex ] with with each ;
+:: (draw-triangle) ( ns vs triple -- )
+    triple [| elt |
+        elt ns nth gl-normal
+        elt vs nth gl-vertex
+    ] each ;
 
 : draw-triangles ( ns vs is -- )
     GL_TRIANGLES [ [ (draw-triangle) ] with with each ] do-state ;
index c972b8816cd55fa94eaa6b3aa2402d89ad0e5487..082827353de2677b78a4636b56ede642397ccc51 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors c.lexer kernel sequence-parser tools.test ;
+USING: accessors c.lexer kernel sequences.parser tools.test ;
 IN: c.lexer.tests
 
 [ 36 ]
index 962407e6ec84f33b77ad4d6fb67eb10a436e1aa6..57894217bd17f6cc5e4e47af7eee79d268975c61 100644 (file)
@@ -2,7 +2,7 @@
 ! 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
+sequences.parser sequences sorting.functor sorting.slots
 unicode.categories ;
 IN: c.lexer
 
index 3018fa7a2469d400d9ffd5930bea8b5fa646778f..d69583e12447c3b397c332f1e40c05468af18f00 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequence-parser io io.encodings.utf8 io.files
+USING: sequences.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
@@ -93,11 +93,11 @@ ERROR: header-file-missing path ;
     skip-whitespace/comments
     [ current { [ blank? ] [ CHAR: ( = ] } 1|| ] take-until ;
 
-: handle-define ( preprocessor-state sequence-parser -- )
-    [ take-define-identifier ]
-    [ skip-whitespace/comments take-rest ] bi 
-    "\\" ?tail [ readlns append ] when
-    spin symbol-table>> set-at ;
+:: handle-define ( preprocessor-state sequence-parser -- )
+    sequence-parser take-define-identifier :> ident
+    sequence-parser skip-whitespace/comments take-rest :> def
+    def "\\" ?tail [ readlns append ] when :> def
+    def ident preprocessor-state symbol-table>> set-at ;
 
 : handle-undef ( preprocessor-state sequence-parser -- )
     take-token swap symbol-table>> delete-at ;
diff --git a/extra/calendar/holidays/authors.txt b/extra/calendar/holidays/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/calendar/holidays/canada/authors.txt b/extra/calendar/holidays/canada/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/calendar/holidays/canada/canada-tests.factor b/extra/calendar/holidays/canada/canada-tests.factor
new file mode 100644 (file)
index 0000000..916f5ee
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: calendar.holidays calendar.holidays.canada kernel
+tools.test ;
+IN: calendar.holidays.canada.tests
+
+[ ] [ 2009 canada holidays drop ] unit-test
diff --git a/extra/calendar/holidays/canada/canada.factor b/extra/calendar/holidays/canada/canada.factor
new file mode 100644 (file)
index 0000000..304388f
--- /dev/null
@@ -0,0 +1,11 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: calendar calendar.holidays ;
+IN: calendar.holidays.canada
+
+SINGLETONS: canada canadian-federal ;
+
+HOLIDAY: canadian-thanksgiving-day october 2 monday-of-month ;
+HOLIDAY-NAME: canadian-thanksgiving-day canadian-federal "Thanksgiving Day"
+
+HOLIDAY-NAME: armistice-day commonwealth-of-nations "Remembrance Day"
diff --git a/extra/calendar/holidays/holidays.factor b/extra/calendar/holidays/holidays.factor
new file mode 100644 (file)
index 0000000..0b8a1bb
--- /dev/null
@@ -0,0 +1,55 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs calendar fry kernel parser sequences
+shuffle vocabs words memoize ;
+IN: calendar.holidays
+
+SINGLETONS: all world commonwealth-of-nations ;
+
+<<
+SYNTAX: HOLIDAY:
+    CREATE-WORD
+    dup "holiday" word-prop [
+        dup H{ } clone "holiday" set-word-prop
+    ] unless
+    parse-definition (( timestamp/n -- timestamp )) define-declared ;
+
+SYNTAX: HOLIDAY-NAME:
+    scan-word "holiday" word-prop scan-word scan-object spin set-at ;
+>>
+
+GENERIC: holidays ( n singleton -- seq )
+
+<PRIVATE
+
+: (holidays) ( singleton -- seq )
+    all-words swap '[ "holiday" word-prop _ swap key? ] filter ;
+
+M: object holidays
+    (holidays) [ execute( timestamp -- timestamp' ) ] with map ;
+
+PRIVATE>
+
+M: all holidays
+    drop
+    all-words [ "holiday" word-prop key? ] with filter ;
+
+: holiday? ( timestamp/n singleton -- ? )
+    [ holidays ] [ drop ] 2bi '[ _ same-day? ] any? ;
+
+: holiday-assoc ( timestamp singleton -- assoc )
+    (holidays) swap
+    '[ [ _ swap execute( ts -- ts' ) >gmt midnight ] keep ] { } map>assoc ;
+
+: holiday-name ( singleton word -- string/f )
+    "holiday" word-prop at ;
+
+: holiday-names ( timestamp/n singleton -- seq )
+    [
+        [ >gmt midnight ] dip
+        [ drop ] [ holiday-assoc ] 2bi swap
+        '[ drop _ same-day? ] assoc-filter values
+    ] keep '[ _ swap "holiday" word-prop at ] map ;
+
+HOLIDAY: armistice-day november 11 >>day ;
+HOLIDAY-NAME: armistice-day world "Armistice Day"
diff --git a/extra/calendar/holidays/us/authors.txt b/extra/calendar/holidays/us/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/calendar/holidays/us/us-tests.factor b/extra/calendar/holidays/us/us-tests.factor
new file mode 100644 (file)
index 0000000..23ab535
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: calendar.holidays calendar.holidays.us kernel sequences
+tools.test ;
+IN: calendar.holidays.us.tests
+
+[ 10 ] [ 2009 us-federal holidays length ] unit-test
diff --git a/extra/calendar/holidays/us/us.factor b/extra/calendar/holidays/us/us.factor
new file mode 100644 (file)
index 0000000..a4fb19c
--- /dev/null
@@ -0,0 +1,117 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs calendar calendar.holidays
+calendar.holidays.private combinators combinators.short-circuit
+fry kernel lexer math namespaces parser sequences shuffle
+vocabs words ;
+IN: calendar.holidays.us
+
+SINGLETONS: us us-federal ;
+
+<PRIVATE
+
+: adjust-federal-holiday ( timestamp -- timestamp' )
+    {
+        { [ dup saturday? ] [ 1 days time- ] }
+        { [ dup sunday? ] [ 1 days time+ ] }
+        [ ]
+    } cond ;
+
+PRIVATE>
+
+M: us-federal holidays
+    (holidays)
+    [ execute( timestamp -- timestamp' ) adjust-federal-holiday ] with map ;
+
+: us-post-office-open? ( timestamp -- ? )
+    { [ sunday? not ] [ us-federal holiday? not ] } 1&& ;
+
+HOLIDAY: new-years-day january 1 >>day ;
+HOLIDAY-NAME: new-years-day world "New Year's Day"
+HOLIDAY-NAME: new-years-day us-federal "New Year's Day"
+
+HOLIDAY: martin-luther-king-day january 3 monday-of-month ;
+HOLIDAY-NAME: martin-luther-king-day us-federal "Martin Luther King Day"
+
+HOLIDAY: inauguration-day year dup 4 neg rem + january 20 >>day ;
+HOLIDAY-NAME: inauguration-day us "Inauguration Day"
+
+HOLIDAY: washingtons-birthday february 3 monday-of-month ;
+HOLIDAY-NAME: washingtons-birthday us-federal "Washington's Birthday"
+
+HOLIDAY: memorial-day may last-monday-of-month ;
+HOLIDAY-NAME: memorial-day us-federal "Memorial Day"
+
+HOLIDAY: independence-day july 4 >>day ;
+HOLIDAY-NAME: independence-day us-federal "Independence Day"
+
+HOLIDAY: labor-day september 1 monday-of-month ;
+HOLIDAY-NAME: labor-day us-federal "Labor Day"
+
+HOLIDAY: columbus-day october 2 monday-of-month ;
+HOLIDAY-NAME: columbus-day us-federal "Columbus Day"
+
+HOLIDAY-NAME: armistice-day us-federal "Veterans Day"
+
+HOLIDAY: thanksgiving-day november 4 thursday-of-month ;
+HOLIDAY-NAME: thanksgiving-day us-federal "Thanksgiving Day"
+
+HOLIDAY: christmas-day december 25 >>day ;
+HOLIDAY-NAME: christmas-day world "Christmas Day"
+HOLIDAY-NAME: christmas-day us-federal "Christmas Day"
+
+HOLIDAY: belly-laugh-day january 24 >>day ;
+
+HOLIDAY: groundhog-day february 2 >>day ;
+
+HOLIDAY: lincolns-birthday february 12 >>day ;
+
+HOLIDAY: valentines-day february 14 >>day ;
+
+HOLIDAY: st-patricks-day march 17 >>day ;
+
+HOLIDAY: ash-wednesday easter 46 days time- ;
+
+ALIAS: first-day-of-lent ash-wednesday
+
+HOLIDAY: fat-tuesday ash-wednesday 1 days time- ;
+
+HOLIDAY: good-friday easter 2 days time- ;
+
+HOLIDAY: tax-day april 15 >>day ;
+
+HOLIDAY: earth-day april 22 >>day ;
+
+HOLIDAY: administrative-professionals-day april last-saturday-of-month wednesday ;
+
+HOLIDAY: cinco-de-mayo may 5 >>day ;
+
+HOLIDAY: mothers-day may 2 sunday-of-month ;
+
+HOLIDAY: armed-forces-day may 3 saturday-of-month ;
+
+HOLIDAY: flag-day june 14 >>day ;
+
+HOLIDAY: parents-day july 4 sunday-of-month ;
+
+HOLIDAY: grandparents-day labor-day 1 weeks time+ ;
+
+HOLIDAY: patriot-day september 11 >>day ;
+
+HOLIDAY: stepfamily-day september 16 >>day ;
+
+HOLIDAY: citizenship-day september 17 >>day ;
+
+HOLIDAY: bosss-day october 16 >>day ;
+
+HOLIDAY: sweetest-day october 3 saturday-of-month ;
+
+HOLIDAY: halloween october 31 >>day ;
+
+HOLIDAY: election-day november 1 monday-of-month 1 days time+ ;
+
+HOLIDAY: black-friday thanksgiving-day 1 days time+ ;
+
+HOLIDAY: pearl-harbor-remembrance-day december 7 >>day ;
+
+HOLIDAY: new-years-eve december 31 >>day ;
index 79fcf7564ee5e84a4a6fb05688a263552896c432..faa8ec07eeca63760f251398efbe6a15a5ff162b 100644 (file)
@@ -4,10 +4,10 @@ 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 ;
+SYNTAX: C[ | parse-until parse-quotation delayed-bind-with append! ;
 ! Common ones
-SYNTAX: DIR[ parse-quotation { current-directory } swap delayed-bind-with over push-all ;
+SYNTAX: DIR[ parse-quotation { current-directory } swap delayed-bind-with append! ;
 
 ! 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
+SYNTAX: NS[ parse-quotation bind-to-namespace append! ;
index da71acb07408a94b9446bfcaadaa8cca948ded10..ed5dd1268fa9042a445a176879a9e454a6dbad04 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs continuations debugger hashtables http
 http.client io io.encodings.string io.encodings.utf8 json.reader
-json.writer kernel make math math.parser namespaces sequences strings
-urls urls.encoding vectors ;
+json.writer kernel locals make math math.parser namespaces sequences
+strings urls urls.encoding vectors ;
 IN: couchdb
 
 ! NOTE: This code only works with the latest couchdb (0.9.*), because old
@@ -136,8 +136,9 @@ C: <db> db
 : attachments> ( assoc -- attachments ) "_attachments" swap at ;
 : >attachments ( assoc attachments -- assoc ) "_attachments" pick set-at ;
 
-: copy-key ( to from to-key from-key -- )
-    rot at spin set-at ;
+:: copy-key ( to from to-key from-key -- )
+    from-key from at
+    to-key to set-at ;
 
 : copy-id ( to from -- )
     "_id" "id" copy-key ;
index 0807420266dd2ace7573f7688c7306907fe40452..a5a6709c6d61c2d555ecbf68560cc3a1ca208fd4 100644 (file)
@@ -61,37 +61,33 @@ CONSTANT: AES_BLOCK_SIZE 16
     bitor bitor bitor 32 bits ;
 
 :: set-t ( T i -- )
-    [let* |
-        a1 [ i sbox nth ]
-        a2 [ a1 xtime ]
-        a3 [ a1 a2 bitxor ] |
-            a2 a1 a1 a3 ui32 i T set-nth
-            a3 a2 a1 a1 ui32 i HEX: 100 + T set-nth
-            a1 a3 a2 a1 ui32 i HEX: 200 + T set-nth
-            a1 a1 a3 a2 ui32 i HEX: 300 + T set-nth
-        ] ;
+    i sbox nth :> a1
+    a1 xtime :> a2
+    a1 a2 bitxor :> a3
 
+    a2 a1 a1 a3 ui32 i T set-nth
+    a3 a2 a1 a1 ui32 i HEX: 100 + T set-nth
+    a1 a3 a2 a1 ui32 i HEX: 200 + T set-nth
+    a1 a1 a3 a2 ui32 i HEX: 300 + T set-nth ;
 
 MEMO:: t-table ( -- array )
     1024 0 <array>
     dup 256 [ set-t ] with each ;
 
 :: set-d ( D i -- )
-    [let* |
-        a1 [ i inv-sbox nth ]
-        a2 [ a1 xtime ]
-        a4 [ a2 xtime ]
-        a8 [ a4 xtime ]
-        a9 [ a8 a1 bitxor ]
-        ab [ a9 a2 bitxor ]
-        ad [ a9 a4 bitxor ]
-        ae [ a8 a4 a2 bitxor bitxor ]
-        |
-            ae a9 ad ab ui32 i D set-nth
-            ab ae a9 ad ui32 i HEX: 100 + D set-nth
-            ad ab ae a9 ui32 i HEX: 200 + D set-nth
-            a9 ad ab ae ui32 i HEX: 300 + D set-nth
-        ] ;
+    i inv-sbox nth :> a1
+    a1 xtime :> a2
+    a2 xtime :> a4
+    a4 xtime :> a8
+    a8 a1 bitxor :> a9
+    a9 a2 bitxor :> ab
+    a9 a4 bitxor :> ad
+    a8 a4 a2 bitxor bitxor :> ae
+
+    ae a9 ad ab ui32 i D set-nth
+    ab ae a9 ad ui32 i HEX: 100 + D set-nth
+    ad ab ae a9 ui32 i HEX: 200 + D set-nth
+    a9 ad ab ae ui32 i HEX: 300 + D set-nth ;
     
 MEMO:: d-table ( -- array )
     1024 0 <array>
index 30650c1e401daa806ef75eeb5e84cf6631359f9c..a8706a75316ee9f1f95830107a252f55f707dad5 100644 (file)
@@ -17,31 +17,32 @@ IN: crypto.passwd-md5
 PRIVATE>
 
 :: passwd-md5 ( magic salt password -- bytes )
-    [let* | final! [ password magic salt 3append
-                salt password tuck 3append md5 checksum-bytes
-                password length
-                [ 16 / ceiling swap <repetition> concat ] keep
-                head-slice append
-                password [ length make-bits ] [ first ] bi
-                '[ CHAR: \0 _ ? ] "" map-as append
-                md5 checksum-bytes ] |
-        1000 [
-            "" swap
-            {
-                [ 0 bit? password final ? append ]
-                [ 3 mod 0 > [ salt append ] when ]
-                [ 7 mod 0 > [ password append ] when ]
-                [ 0 bit? final password ? append ]
-            } cleave md5 checksum-bytes final!
-        ] each
+    password magic salt 3append
+    salt password dup surround md5 checksum-bytes
+    password length
+    [ 16 / ceiling swap <repetition> concat ] keep
+    head-slice append
+    password [ length make-bits ] [ first ] bi
+    '[ CHAR: \0 _ ? ] "" map-as append
+    md5 checksum-bytes :> final!
 
-        magic salt "$" 3append
-        { 12 0 6 13 1 7 14 2 8 15 3 9 5 4 10 } final nths 3 group
-        [ first3 [ 16 shift ] [ 8 shift ] bi* + + 4 to64 ] map concat
-        11 final nth 2 to64 3append ] ;
+    1000 iota [
+        "" swap
+        {
+            [ 0 bit? password final ? append ]
+            [ 3 mod 0 > [ salt append ] when ]
+            [ 7 mod 0 > [ password append ] when ]
+            [ 0 bit? final password ? append ]
+        } cleave md5 checksum-bytes final!
+    ] each
+
+    magic salt "$" 3append
+    { 12 0 6 13 1 7 14 2 8 15 3 9 5 4 10 } final nths 3 group
+    [ first3 [ 16 shift ] [ 8 shift ] bi* + + 4 to64 ] map concat
+    11 final nth 2 to64 3append ;
         
 : parse-shadow-password ( string -- magic salt password )
-    "$" split harvest first3 [ "$" tuck 3append ] 2dip ;
+    "$" split harvest first3 [ "$" dup surround ] 2dip ;
     
 : authenticate-password ( shadow password -- ? )
     '[ parse-shadow-password drop _ passwd-md5 ] keep = ;
index 4d6c77fd23c03388961911fd8ed27ecd5c0af8d0..69c6503aa282346657e3e6b760591b55ea658a37 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.strings assocs byte-arrays
 combinators continuations destructors fry io.encodings.8-bit
-io io.encodings.string io.encodings.utf8 kernel math
+io io.encodings.string io.encodings.utf8 kernel locals math
 namespaces prettyprint sequences classes.struct
 strings threads curses.ffi ;
 IN: curses
@@ -123,8 +123,10 @@ PRIVATE>
 : curses-writef ( window string -- )
     [ window-ptr dup ] dip (curses-wprint) (curses-window-refresh) ;
 
-: (curses-read) ( window-ptr n encoding -- string )
-    [ [ <byte-array> tuck ] keep wgetnstr curses-error ] dip alien>string ;
+:: (curses-read) ( window-ptr n encoding -- string )
+    n <byte-array> :> buf
+    window-ptr buf n wgetnstr curses-error
+    buf encoding alien>string ;
 
 : curses-read ( window n -- string )
     utf8 [ window-ptr ] 2dip (curses-read) ;
index 66409f283418235db896f07ac2d742af75e52071..4d17b6bf10542182ad0ad3a03c5e4258a3bb522e 100644 (file)
@@ -10,6 +10,6 @@ SYNTAX: get-psql-info <postgresql-db> get-info 5 firstn
         [ >>username ]
         [ [ f ] [ ] if-empty >>password ]
         [ >>database ]
-    } spread parsed ;
+    } spread suffix! ;
 
-SYNTAX: get-sqlite-info get-info first <sqlite-db> parsed ;
\ No newline at end of file
+SYNTAX: get-sqlite-info get-info first <sqlite-db> suffix! ;
index bb9e60cfc1914730fc6d4a5e7478082f3861fb90..29b9d98b38548e4fa8489ceeb13ddb40558d2a07 100644 (file)
@@ -49,3 +49,4 @@ ERROR: decimal-test-failure D1 D2 quot ;
 [ f ] [ D: -1 D: -2 before? ] unit-test
 [ f ] [ D: -2 D: -2 before? ] unit-test
 [ t ] [ D: -3 D: -2 before? ] unit-test
+[ t ] [ D: .5 D: 0 D: 1.0 between? ] unit-test
index d9bafd43d05e86a634079e005c4aa384c1ca720f..d5c62fee5e3d0d4fa4f87ff2f78b2aa18a1d11af 100644 (file)
@@ -20,7 +20,7 @@ TUPLE: decimal { mantissa read-only } { exponent read-only } ;
 
 : parse-decimal ( -- decimal ) scan string>decimal ;
 
-SYNTAX: D: parse-decimal parsed ;
+SYNTAX: D: parse-decimal suffix! ;
 
 : decimal>ratio ( decimal -- ratio ) >decimal< 10^ * ;
 : decimal>float ( decimal -- ratio ) decimal>ratio >float ;
@@ -37,8 +37,7 @@ SYNTAX: D: parse-decimal parsed ;
     ] 2bi ;
 
 : scale-decimals ( D1 D2 -- D1' D2' )
-    [ drop ]
-    [ scale-mantissas <decimal> nip ] 2bi ;
+    scale-mantissas [ <decimal> ] curry bi@ ;
 
 ERROR: decimal-types-expected d1 d2 ;
 
@@ -76,10 +75,13 @@ M: decimal before?
 
 :: D/ ( D1 D2 a -- D3 )
     D1 D2 guard-decimals 2drop
-    D1 >decimal< :> e1 :> m1
-    D2 >decimal< :> e2 :> m2
+    D1 >decimal< :> ( m1 e1 )
+    D2 >decimal< :> ( m2 e2 )
     m1 a 10^ *
     m2 /i
     
     e1
     e2 a + - <decimal> ;
+
+M: decimal <=>
+    2dup before? [ 2drop +lt+ ] [ equal? +eq+ +gt+ ? ] if ; inline
index 5ccc0d5a607653692df57529226e3ef4ed425563..ccbe90fb3c40ddbecd2d600605b2c37e3dc8f0d8 100755 (executable)
@@ -21,10 +21,10 @@ TUPLE: vertex value edges ;
 
 : @edges ( from to digraph -- to edges ) swapd at edges>> ;
 : add-edge ( from to digraph -- ) @edges push ;
-: delete-edge ( from to digraph -- ) @edges delete ;
+: delete-edge ( from to digraph -- ) @edges remove! drop ;
 
 : delete-to-edges ( to digraph -- )
-    [ nip dupd edges>> delete ] assoc-each drop ;
+    [ nip dupd edges>> remove! drop ] assoc-each drop ;
 
 : delete-vertex ( key digraph -- )
     2dup delete-at delete-to-edges ;
@@ -44,7 +44,7 @@ DEFER: (topological-sort)
     ] if ;
 
 : topological-sort ( digraph -- seq )
-    dup clone V{ } clone spin
+    [ V{ } clone ] dip [ clone ] keep
     [ drop (topological-sort) ] assoc-each drop reverse ;
 
 : topological-sorted-values ( digraph -- seq )
diff --git a/extra/dns/cache/nx/nx.factor b/extra/dns/cache/nx/nx.factor
deleted file mode 100644 (file)
index 9904f85..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-
-USING: kernel assocs locals combinators
-       math math.functions system unicode.case ;
-
-IN: dns.cache.nx
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: nx-cache ( -- table ) H{ } ;
-
-: nx-cache-at        (      name -- time ) >lower nx-cache at        ;
-: nx-cache-delete-at (      name --      ) >lower nx-cache delete-at ;
-: nx-cache-set-at    ( time name --      ) >lower nx-cache set-at    ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: now ( -- seconds ) millis 1000.0 / round >integer ;
-
-:: non-existent-name? ( NAME -- ? )
-   [let | TIME [ NAME nx-cache-at ] |
-     {
-       { [ TIME f    = ] [                         f ] }
-       { [ TIME now <= ] [ NAME nx-cache-delete-at f ] }
-       { [ t           ] [                         t ] }
-     }
-     cond
-   ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: cache-non-existent-name ( NAME TTL -- )
-   [let | TIME [ TTL now + ] | TIME NAME nx-cache-set-at ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
diff --git a/extra/dns/cache/rr/rr.factor b/extra/dns/cache/rr/rr.factor
deleted file mode 100644 (file)
index cb80190..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-
-USING: kernel sequences assocs sets locals combinators
-       accessors system math math.functions unicode.case prettyprint
-       combinators.smart dns ;
-
-IN: dns.cache.rr
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-TUPLE: <entry> time data ;
-
-: now ( -- seconds ) millis 1000.0 / round >integer ;
-
-: expired? ( <entry> -- ? ) time>> now <= ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: make-cache-key ( obj -- key )
-  [ [ name>> >lower ] [ type>> ] [ class>> ] tri ] output>array ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: cache ( -- table ) H{ } ;
-
-: cache-at     (     obj -- ent ) make-cache-key cache at ;
-: cache-delete (     obj --     ) make-cache-key cache delete-at ;
-: cache-set-at ( ent obj --     ) make-cache-key cache set-at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: cache-get ( OBJ -- rrs/f )
-   [let | ENT [ OBJ cache-at ] |
-     {
-       { [ ENT f =      ] [                  f ] }
-       { [ ENT expired? ] [ OBJ cache-delete f ] }
-       {
-         [ t ]
-         [
-           [let | NAME  [ OBJ name>>       ]
-                  TYPE  [ OBJ type>>       ]
-                  CLASS [ OBJ class>>      ]
-                  TTL   [ ENT time>> now - ] |
-             ENT data>>
-               [| RDATA | T{ rr f NAME TYPE CLASS TTL RDATA } ]
-             map
-           ]
-         ]
-       }
-     }
-     cond
-   ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: cache-add ( RR -- )
-   [let | ENT   [ RR cache-at    ]
-          TIME  [ RR ttl>> now + ]
-          RDATA [ RR rdata>>     ] |
-     {
-       { [ ENT f =      ] [ T{ <entry> f TIME V{ RDATA } } RR cache-set-at ] }
-       { [ ENT expired? ] [ RR cache-delete RR cache-add                   ] }
-       { [ t            ] [ TIME ENT (>>time) RDATA ENT data>> adjoin      ] }
-     }
-     cond
-   ] ;
\ No newline at end of file
diff --git a/extra/dns/dns.factor b/extra/dns/dns.factor
deleted file mode 100644 (file)
index f16664f..0000000
+++ /dev/null
@@ -1,501 +0,0 @@
-
-USING: kernel byte-arrays combinators strings arrays sequences splitting
-       grouping
-       math math.functions math.parser random
-       destructors
-       io io.binary io.sockets io.encodings.binary
-       accessors
-       combinators.smart
-       assocs
-       ;
-
-IN: dns
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-TUPLE: query name type class ;
-
-TUPLE: rr name type class ttl rdata ;
-
-TUPLE: hinfo cpu os ;
-
-TUPLE: mx preference exchange ;
-
-TUPLE: soa mname rname serial refresh retry expire minimum ;
-
-TUPLE: message
-       id qr opcode aa tc rd ra z rcode
-       question-section
-       answer-section
-       authority-section
-       additional-section ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: random-id ( -- id ) 2 16 ^ random ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! TYPE
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SYMBOLS: A NS MD MF CNAME SOA MB MG MR NULL WKS PTR HINFO MINFO MX TXT AAAA ;
-
-: type-table ( -- table )
-  {
-    { A     1 }
-    { NS    2 }
-    { MD    3 }
-    { MF    4 }
-    { CNAME 5 }
-    { SOA   6 }
-    { MB    7 }
-    { MG    8 }
-    { MR    9 }
-    { NULL  10 }
-    { WKS   11 }
-    { PTR   12 }
-    { HINFO 13 }
-    { MINFO 14 }
-    { MX    15 }
-    { TXT   16 }
-    { AAAA  28 }
-  } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! CLASS
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SYMBOLS: IN CS CH HS ;
-
-: class-table ( -- table )
-  {
-    { IN 1 }
-    { CS 2 }
-    { CH 3 }
-    { HS 4 }
-  } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! OPCODE
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SYMBOLS: QUERY IQUERY STATUS ;
-
-: opcode-table ( -- table )
-  {
-    { QUERY  0 }
-    { IQUERY 1 }
-    { STATUS 2 }
-  } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! RCODE
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED
-         REFUSED ;
-
-: rcode-table ( -- table )
-  {
-    { NO-ERROR        0 }
-    { FORMAT-ERROR    1 }
-    { SERVER-FAILURE  2 }
-    { NAME-ERROR      3 }
-    { NOT-IMPLEMENTED 4 }
-    { REFUSED         5 }
-  } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: <message> ( -- message )
-  message new
-    random-id >>id
-    0         >>qr
-    QUERY     >>opcode
-    0         >>aa
-    0         >>tc
-    1         >>rd
-    0         >>ra
-    0         >>z
-    NO-ERROR  >>rcode
-    { }       >>question-section
-    { }       >>answer-section
-    { }       >>authority-section
-    { }       >>additional-section ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: ip->ba ( ip -- ba ) "." split [ string>number ] map >byte-array ;
-
-: ipv6->ba ( ip -- ba ) ":" split [ 16 base> ] map [ 2 >be ] map concat ;
-
-: label->ba ( label -- ba ) [ >byte-array ] [ length ] bi prefix ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: uint8->ba  ( n -- ba ) 1 >be ;
-: uint16->ba ( n -- ba ) 2 >be ;
-: uint32->ba ( n -- ba ) 4 >be ;
-: uint64->ba ( n -- ba ) 8 >be ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: dn->ba ( dn -- ba ) "." split [ label->ba ] map concat ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: query->ba ( query -- ba )
-  [
-    {
-      [ name>>                 dn->ba ]
-      [ type>>  type-table  at uint16->ba ]
-      [ class>> class-table at uint16->ba ]
-    } cleave
-  ] output>array concat ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: hinfo->ba ( rdata -- ba )
-    [ cpu>> label->ba ]
-    [ os>>  label->ba ]
-  bi append ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: mx->ba ( rdata -- ba )
-    [ preference>> uint16->ba ]
-    [ exchange>>   dn->ba ]
-  bi append ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: soa->ba ( rdata -- ba )
-  [
-    {
-      [ mname>>   dn->ba ]
-      [ rname>>   dn->ba ]
-      [ serial>>  uint32->ba ]
-      [ refresh>> uint32->ba ]
-      [ retry>>   uint32->ba ]
-      [ expire>>  uint32->ba ]
-      [ minimum>> uint32->ba ]
-    } cleave
-  ] output>array concat ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: rdata->ba ( type rdata -- ba )
-  swap
-    {
-      { CNAME [ dn->ba ] }
-      { HINFO [ hinfo->ba ] }
-      { MX    [ mx->ba ] }
-      { NS    [ dn->ba ] }
-      { PTR   [ dn->ba ] }
-      { SOA   [ soa->ba ] }
-      { A     [ ip->ba ] }
-    }
-  case ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: rr->ba ( rr -- ba )
-  [
-    {
-      [ name>>                 dn->ba     ]
-      [ type>>  type-table  at uint16->ba ]
-      [ class>> class-table at uint16->ba ]
-      [ ttl>>   uint32->ba ]
-      [
-        [ type>>            ] [ rdata>> ] bi rdata->ba
-        [ length uint16->ba ] [         ] bi append
-      ]
-    } cleave
-  ] output>array concat ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: header-bits-ba ( message -- ba )
-  [
-    {
-      [ qr>>                     15 shift ]
-      [ opcode>> opcode-table at 11 shift ]
-      [ aa>>                     10 shift ]
-      [ tc>>                      9 shift ]
-      [ rd>>                      8 shift ]
-      [ ra>>                      7 shift ]
-      [ z>>                       4 shift ]
-      [ rcode>>  rcode-table at   0 shift ]
-    } cleave
-  ] sum-outputs uint16->ba ;
-
-: message->ba ( message -- ba )
-  [
-    {
-      [ id>> uint16->ba ]
-      [ header-bits-ba ]
-      [ question-section>>   length uint16->ba ]
-      [ answer-section>>     length uint16->ba ]
-      [ authority-section>>  length uint16->ba ]
-      [ additional-section>> length uint16->ba ]
-      [ question-section>>   [ query->ba ] map concat ]
-      [ answer-section>>     [ rr->ba    ] map concat ]
-      [ authority-section>>  [ rr->ba    ] map concat ]
-      [ additional-section>> [ rr->ba    ] map concat ]
-    } cleave
-  ] output>array concat ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-single ( ba i -- n ) at ;
-: get-double ( ba i -- n ) dup 2 + subseq be> ;
-: get-quad   ( ba i -- n ) dup 4 + subseq be> ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: label-length ( ba i -- length ) get-single ;
-
-: skip-label ( ba i -- ba i ) 2dup label-length + 1 + ;
-
-: null-label? ( ba i -- ? ) get-single 0 = ;
-
-: get-label ( ba i -- label ) [ 1 + ] [ skip-label nip ] 2bi subseq >string ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: bit-test ( a b -- ? ) bitand 0 = not ;
-
-: pointer? ( ba i -- ? ) get-single BIN: 11000000 bit-test ;
-
-: pointer ( ba i -- val ) get-double BIN: 0011111111111111 bitand ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: skip-name ( ba i -- ba i )
-    {
-      { [ 2dup null-label? ] [ 1 + ] }
-      { [ 2dup pointer?    ] [ 2 + ] }
-      { [ t ] [ skip-label skip-name ] }
-    }
-  cond ;
-
-: get-name ( ba i -- name )
-    {
-      { [ 2dup null-label? ] [ 2drop "" ] }
-      { [ 2dup pointer?    ] [ dupd pointer get-name ] }
-      {
-        [ t ]
-        [
-          [ get-label ]
-          [ skip-label get-name ]
-          2bi
-          "." glue 
-        ]
-      }
-    }
-  cond ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-query ( ba i -- query )
-    [ get-name ]
-    [
-      skip-name
-      [ 0 + get-double type-table  value-at ]
-      [ 2 + get-double class-table value-at ]
-      2bi
-    ]
-  2bi query boa ;
-
-: skip-query ( ba i -- ba i ) skip-name 4 + ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-mx ( ba i -- mx ) [ get-double ] [ 2 + get-double ] 2bi mx boa ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-soa ( ba i -- soa )
-    {
-      [           get-name ]
-      [ skip-name get-name ]
-      [
-        skip-name
-        skip-name
-        {
-          [  0 + get-quad ]
-          [  4 + get-quad ]
-          [  8 + get-quad ]
-          [ 12 + get-quad ]
-          [ 16 + get-quad ]
-        }
-          2cleave
-      ]
-    }
-  2cleave soa boa ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-ip ( ba i -- ip ) dup 4 + subseq >array [ number>string ] map "." join ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-ipv6 ( ba i -- ip )
-  dup 16 + subseq 2 group [ be> 16 >base ] map ":" join ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-rdata ( ba i type -- rdata )
-    {
-      { CNAME [ get-name ] }
-      { NS    [ get-name ] }
-      { PTR   [ get-name ] }
-      { MX    [ get-mx   ] }
-      { SOA   [ get-soa  ] }
-      { A     [ get-ip   ] }
-      { AAAA  [ get-ipv6 ] }
-    }
-  case ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-rr ( ba i -- rr )
-  [ get-name ]
-  [
-    skip-name
-      {
-        [ 0 + get-double type-table  value-at ]
-        [ 2 + get-double class-table value-at ]
-        [ 4 + get-quad   ]
-        [ [ 10 + ] [ get-double type-table value-at ] 2bi get-rdata ]
-      }
-    2cleave
-  ]
-    2bi rr boa ;
-
-: skip-rr ( ba i -- ba i ) skip-name 8 + 2dup get-double + 2 + ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-question-section ( ba i count -- seq ba i )
-  [ drop [ skip-query ] [ get-query ] 2bi ] map -rot ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: get-rr-section ( ba i count -- seq ba i )
-  [ drop [ skip-rr ] [ get-rr ] 2bi ] map -rot ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: >> ( x n -- y ) neg shift ;
-
-: get-header-bits ( ba i -- qr opcode aa tc rd ra z rcode )
-    get-double
-    {
-      [ 15 >> BIN:    1 bitand ]
-      [ 11 >> BIN:  111 bitand opcode-table value-at ]
-      [ 10 >> BIN:    1 bitand ]
-      [  9 >> BIN:    1 bitand ]
-      [  8 >> BIN:    1 bitand ]
-      [  7 >> BIN:    1 bitand ]
-      [  4 >> BIN:  111 bitand ]
-      [       BIN: 1111 bitand rcode-table value-at ]
-    }
-  cleave ;
-
-: parse-message ( ba -- message )
-  0
-  {
-    [ get-double ]
-    [ 2 + get-header-bits ]
-    [
-      4 +
-      {
-        [ 8 +            ]
-        [ 0 + get-double ]
-        [ 2 + get-double ]
-        [ 4 + get-double ]
-        [ 6 + get-double ]
-      }
-        2cleave
-      {
-        [ get-question-section ]
-        [ get-rr-section ]
-        [ get-rr-section ]
-        [ get-rr-section ]
-      } spread
-      2drop
-    ]
-  }
-    2cleave message boa ;
-
-: ba->message ( ba -- message ) parse-message ;
-
-: with-message-bytes ( ba quot -- ) [ ba->message ] dip call message->ba ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: send-receive-udp ( ba server -- ba )
-  f 0 <inet4> <datagram>
-    [
-      [ send ] [ receive drop ] bi
-    ]
-  with-disposal ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: send-receive-tcp ( ba server -- ba )
-  [ dup length 2 >be prepend ] [ ] bi*
-  binary
-    [
-      write flush
-      2 read be> read
-    ]
-  with-client ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: >dns-inet4 ( obj -- inet4 )
-  dup string?
-    [ 53 <inet4> ]
-    [            ]
-  if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: ask-server ( message server -- message )
-  [ message->ba ] [ >dns-inet4 ] bi*
-  2dup
-  send-receive-udp parse-message
-  dup tc>> 1 =
-    [ drop send-receive-tcp parse-message ]
-    [ nip nip                             ]
-  if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: dns-servers ( -- seq ) V{ } ;
-
-: dns-server ( -- server ) dns-servers random ;
-
-: ask ( message -- message ) dns-server ask-server ;
-
-: query->message ( query -- message ) <message> swap 1array >>question-section ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: message-query ( message -- query ) question-section>> first ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-ERROR: name-error name ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: fully-qualified ( name -- name )
-    {
-      { [ dup empty?         ] [ "." append ] }
-      { [ dup last CHAR: . = ] [            ] }
-      { [ t                  ] [ "." append ] }
-    }
-  cond ;
diff --git a/extra/dns/forwarding/forwarding.factor b/extra/dns/forwarding/forwarding.factor
deleted file mode 100644 (file)
index 4b7db30..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-
-USING: kernel sequences combinators accessors locals random
-       combinators.short-circuit
-       io.sockets
-       dns dns.util dns.cache.rr dns.cache.nx
-       dns.resolver ;
-
-IN: dns.forwarding
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: query->rrs ( QUERY -- rrs/f )
-   [let | RRS [ QUERY cache-get ] |
-     RRS
-       [ RRS ]
-       [
-         [let | NAME  [ QUERY name>>  ]
-                TYPE  [ QUERY type>>  ]
-                CLASS [ QUERY class>> ] |
-               
-           [let | RRS/CNAME [ T{ query f NAME CNAME CLASS } cache-get ] |
-
-             RRS/CNAME f =
-               [ f ]
-               [
-                 [let | RR/CNAME [ RRS/CNAME first ] |
-            
-                   [let | REAL-NAME [ RR/CNAME rdata>> ] |
-              
-                     [let | RRS [
-                                  T{ query f REAL-NAME TYPE CLASS } query->rrs
-                                ] |
-
-                       RRS
-                         [ RRS/CNAME RRS append ]
-                         [ f ]
-                       if
-                     ] ] ]
-               ]
-             if
-           ] ]
-       ]
-     if
-   ] ;
-
-:: answer-from-cache ( MSG -- msg/f )
-   [let | QUERY [ MSG message-query ] |
-
-     [let | NX  [ QUERY name>> non-existent-name? ]
-            RRS [ QUERY query->rrs                ] |
-
-       {
-         { [ NX  ] [ MSG NAME-ERROR >>rcode          ] }
-         { [ RRS ] [ MSG RRS        >>answer-section ] }
-         { [ t   ] [ f                               ] }
-       }
-       cond
-     ]
-   ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: message-soa ( message -- rr/soa )
-  authority-section>> [ type>> SOA = ] filter first ;
-
-! :: cache-message ( MSG -- msg )
-!    MSG rcode>> NAME-ERROR =
-!      [
-!        [let | NAME [ MSG message-query name>> ]
-!               TTL  [ MSG message-soa   ttl>>  ] |
-!          NAME TTL cache-non-existent-name
-!        ]
-!      ]
-!    when
-!    MSG answer-section>>     [ cache-add ] each
-!    MSG authority-section>>  [ cache-add ] each
-!    MSG additional-section>> [ cache-add ] each
-!    MSG ;
-
-:: cache-message ( MSG -- msg )
-   MSG rcode>> NAME-ERROR =
-     [
-       [let | RR/SOA [ MSG
-                         authority-section>>
-                         [ type>> SOA = ] filter
-                       dup empty? [ drop f ] [ first ] if ] |
-         RR/SOA
-           [
-             [let | NAME [ MSG message-query name>> ]
-                    TTL  [ MSG message-soa   ttl>>  ] |
-               NAME TTL cache-non-existent-name
-             ]
-           ]
-         when
-       ]
-     ]
-   when
-   MSG answer-section>>     [ cache-add ] each
-   MSG authority-section>>  [ cache-add ] each
-   MSG additional-section>> [ cache-add ] each
-   MSG ;
-
-! : answer-from-server ( msg servers -- msg ) random ask-server cache-message ;
-
-: answer-from-server ( msg servers -- msg ) ask-servers cache-message ;
-
-:: find-answer ( MSG SERVERS -- msg )
-   { [ MSG answer-from-cache ] [ MSG SERVERS answer-from-server ] } 0|| ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: start-server ( ADDR-SPEC SERVERS -- )
-
-  [let | SOCKET [ ADDR-SPEC <datagram> ] |
-
-    [
-      SOCKET receive-packet
-        [ parse-message SERVERS find-answer message->ba ]
-      change-data
-      respond
-    ]
-    forever
-
-  ] ;
diff --git a/extra/dns/misc/misc.factor b/extra/dns/misc/misc.factor
deleted file mode 100644 (file)
index 72f553c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-
-USING: kernel combinators sequences splitting math 
-       io.files io.encodings.utf8 random dns.util ;
-
-IN: dns.misc
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: resolv-conf-servers ( -- seq )
-  "/etc/resolv.conf" utf8 file-lines
-  [ " " split ] map
-  [ first "nameserver" = ] filter
-  [ second ] map ;
-
-: resolv-conf-server ( -- ip ) resolv-conf-servers random ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: cdr-name ( name -- name ) dup CHAR: . index 1 + tail ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: domain-has-name? ( domain name -- ? )
-    {
-      { [ 2dup =       ] [ 2drop t ] }
-      { [ 2dup longer? ] [ 2drop f ] }
-      { [ t            ] [ cdr-name domain-has-name? ] }
-    }
-  cond ;
-
-: name-in-domain? ( name domain -- ? ) swap domain-has-name? ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
diff --git a/extra/dns/resolver/resolver.factor b/extra/dns/resolver/resolver.factor
deleted file mode 100644 (file)
index 32ad236..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-
-USING: kernel accessors namespaces continuations
-       io io.sockets io.binary io.timeouts io.encodings.binary
-       destructors
-       locals strings sequences random prettyprint calendar dns dns.misc ;
-
-IN: dns.resolver
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: send-receive-udp ( BA SERVER -- ba )
-   T{ inet4 f f 0 } <datagram>
-   T{ duration { second 3 } } over set-timeout
-     [| SOCKET | BA SERVER SOCKET send SOCKET receive drop ]
-   with-disposal ;
-
-:: send-receive-tcp ( BA SERVER -- ba )
-   [let | BA [ BA length 2 >be BA append ] |
-     SERVER binary
-       [
-         T{ duration { second 3 } } input-stream get set-timeout
-         BA write flush 2 read be> read
-       ]
-     with-client                                        ] ;
-
-:: send-receive-server ( BA SERVER -- msg )
-   [let | RESULT [ BA SERVER send-receive-udp parse-message ] |
-     RESULT tc>> 1 =
-       [ BA SERVER send-receive-tcp parse-message ]
-       [ RESULT                                   ]
-     if                                                 ] ;
-
-: >dns-inet4 ( obj -- inet4 ) dup string? [ 53 <inet4> ] [ ] if ;
-
-:: send-receive-servers ( BA SERVERS -- msg )
-   SERVERS empty? [ "send-receive-servers: servers list empty" throw ] when
-   [let | SERVER [ SERVERS random >dns-inet4 ] |
-     ! if this throws an error ...
-     [ BA SERVER send-receive-server ]
-     ! we try with the other servers...
-     [ drop BA SERVER SERVERS remove send-receive-servers ]
-     recover                                            ] ;
-
-:: ask-servers ( MSG SERVERS -- msg )
-   MSG message->ba SERVERS send-receive-servers ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: fully-qualified ( name -- name ) dup "." tail? [ ] [ "." append ] if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: dns-servers ( -- seq )
-  \ dns-servers get
-    [ ]
-    [ resolv-conf-servers \ dns-servers set dns-servers ]
-  if* ;
-
-! : dns-server ( -- server ) dns-servers random ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: dns-ip4 ( name -- ips )
-  fully-qualified
-  [let | MSG [ A IN query boa query->message dns-servers ask-servers ] |
-    MSG rcode>> NO-ERROR =
-      [ MSG answer-section>> [ type>> A = ] filter [ rdata>> ] map ]
-      [ "dns-ip: rcode = " MSG rcode>> unparse append throw        ]
-    if ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
diff --git a/extra/dns/server/server.factor b/extra/dns/server/server.factor
deleted file mode 100644 (file)
index 773fe31..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-
-USING: kernel combinators sequences sets math threads namespaces continuations
-       debugger io io.sockets unicode.case accessors destructors
-       combinators.short-circuit combinators.smart
-       fry arrays
-       dns dns.util dns.misc ;
-
-IN: dns.server
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SYMBOL: records-var
-
-: records ( -- records ) records-var get ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: {name-type-class} ( obj -- array )
-  [ [ name>> >lower ] [ type>> ] [ class>> ] tri ] output>array ; 
-
-: rr=query? ( obj obj -- ? ) [ {name-type-class} ] bi@ = ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: matching-rrs  ( query -- rrs ) records [ rr=query? ] with filter ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! zones
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: zones    ( -- names ) records [ type>> NS  = ] filter [ name>> ] map prune ;
-: my-zones ( -- names ) records [ type>> SOA = ] filter [ name>> ] map ;
-
-: delegated-zones ( -- names ) zones my-zones diff ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! name->zone
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: name->zone ( name -- zone/f )
-  zones sort-largest-first [ name-in-domain? ] with find nip ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! name->authority
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: name->authority ( name -- rrs-ns ) name->zone NS IN query boa matching-rrs ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! extract-names
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: rr->rdata-names ( rr -- names/f )
-    {
-      { [ dup type>> NS    = ] [ rdata>>            1array ] }
-      { [ dup type>> MX    = ] [ rdata>> exchange>> 1array ] }
-      { [ dup type>> CNAME = ] [ rdata>>            1array ] }
-      { [ t ]                  [ drop f ] }
-    }
-  cond ;
-
-: extract-rdata-names ( message -- names )
-  [ answer-section>> ] [ authority-section>> ] bi append
-  [ rr->rdata-names ] map concat ;
-
-: extract-names ( message -- names )
-  [ message-query name>> ] [ extract-rdata-names ] bi swap prefix ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! fill-authority
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: fill-authority ( message -- message )
-  dup
-    extract-names [ name->authority ] map concat prune
-    over answer-section>> diff
-  >>authority-section ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! fill-additional
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: name->rrs-a ( name -- rrs-a ) A IN query boa matching-rrs ;
-
-: fill-additional ( message -- message )
-  dup
-    extract-rdata-names [ name->rrs-a ] map concat prune
-    over answer-section>> diff
-  >>additional-section ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! query->rrs
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-DEFER: query->rrs
-
-: matching-rrs? ( query -- rrs/f ) matching-rrs [ empty? ] [ drop f ] [ ] 1if ;
-
-: matching-cname? ( query -- rrs/f )
-  [ ] [ clone CNAME >>type matching-rrs ] bi ! query rrs
-  [ empty? not ]
-    [ first swap clone over rdata>> >>name query->rrs swap prefix ]
-    [ 2drop f ]
-  1if ;
-
-: query->rrs ( query -- rrs/f ) { [ matching-rrs? ] [ matching-cname? ] } 1|| ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! have-answers
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: have-answers ( message -- message/f )
-  dup message-query query->rrs
-  [ empty? ]
-    [ 2drop f ]
-    [ >>answer-section fill-authority fill-additional ]
-  1if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! have-delegates?
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: cdr-name ( name -- name ) dup CHAR: . index 1 + tail ;
-
-: is-soa? ( name -- ? ) SOA IN query boa matching-rrs empty? not ;
-
-: have-ns? ( name -- rrs/f )
-  NS IN query boa matching-rrs [ empty? ] [ drop f ] [ ] 1if ;
-
-: name->delegates ( name -- rrs-ns )
-    {
-      [ "" =    { } and ]
-      [ is-soa? { } and ]
-      [ have-ns? ]
-      [ cdr-name name->delegates ]
-    }
-  1|| ;
-
-: have-delegates ( message -- message/f )
-  dup message-query name>> name->delegates ! message rrs-ns
-  [ empty? ]
-    [ 2drop f ]
-    [
-      dup [ rdata>> A IN query boa matching-rrs ] map concat
-                                           ! message rrs-ns rrs-a
-      [ >>authority-section ]
-      [ >>additional-section ]
-      bi*
-    ]
-  1if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! outsize-zones
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: outside-zones ( message -- message/f )
-  dup message-query name>> name->zone f =
-    [ ]
-    [ drop f ]
-  if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! is-nx
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: is-nx ( message -- message/f )
-  [ message-query name>> records [ name>> = ] with filter empty? ]
-    [
-      NAME-ERROR >>rcode
-      dup
-        message-query name>> name->zone SOA IN query boa matching-rrs
-      >>authority-section
-    ]
-    [ drop f ]
-  1if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: none-of-type ( message -- message )
-  dup
-    message-query name>> name->zone SOA IN query boa matching-rrs
-  >>authority-section ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: find-answer ( message -- message )
-    {
-      [ have-answers   ]
-      [ have-delegates ]
-      [ outside-zones  ]
-      [ is-nx          ]
-      [ none-of-type   ]
-    }
-  1|| ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: (handle-request) ( packet -- )
-  [ [ find-answer ] with-message-bytes ] change-data respond ;
-
-: handle-request ( packet -- ) [ (handle-request) ] curry in-thread ;
-
-: receive-loop ( socket -- )
-  [ receive-packet handle-request ] [ receive-loop ] bi ;
-
-: loop ( addr-spec -- )
-  [ <datagram> '[ _ [ receive-loop ] with-disposal ] try ] [ loop ] bi ;
-
diff --git a/extra/dns/stub/stub.factor b/extra/dns/stub/stub.factor
deleted file mode 100644 (file)
index a15feb5..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-
-USING: kernel sequences random accessors dns ;
-
-IN: dns.stub
-
-! Stub resolver
-! 
-! Generally useful, but particularly when running a forwarding,
-! caching, nameserver on localhost with multiple Factor instances
-! querying it.
-
-: name->ip ( name -- ip )
-  A IN query boa
-  query->message
-  ask
-  dup rcode>> NAME-ERROR =
-    [ message-query name>> name-error ]
-    [ answer-section>> [ type>> A = ] filter random rdata>> ]
-  if ;
-
diff --git a/extra/dns/util/util.factor b/extra/dns/util/util.factor
deleted file mode 100644 (file)
index 6934d3b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-
-USING: kernel sequences sorting math math.order macros fry ;
-
-IN: dns.util
-
-: tri-chain ( obj p q r -- x y z )
-  [ [ call dup ] dip call dup ] dip call ; inline
-
-MACRO: 1if ( test then else -- ) '[ dup @ _ _ if ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: sort-largest-first ( seq -- seq ) [ length ] sort-with reverse ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: longer? ( seq seq -- ? ) [ length ] bi@ > ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-USING: io.sockets accessors ;
-
-TUPLE: packet data addr socket ;
-
-: receive-packet ( socket -- packet ) [ receive ] keep packet boa ;
-
-: respond ( packet -- ) [ data>> ] [ addr>> ] [ socket>> ] tri send ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: forever ( quot: ( -- ) -- ) [ call ] [ forever ] bi ; inline recursive
\ No newline at end of file
diff --git a/extra/drills/deployed/deploy.factor b/extra/drills/deployed/deploy.factor
deleted file mode 100644 (file)
index c1e9307..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-USING: tools.deploy.config ;
-H{
-    { 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-ui? t }
-    { deploy-word-props? t }
-    { deploy-io 3 }
-}
diff --git a/extra/drills/deployed/deployed.factor b/extra/drills/deployed/deployed.factor
deleted file mode 100644 (file)
index 5681c73..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-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 ;
-: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
-: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
-
-: show ( model -- gadget ) dup it set-global [ random ] <arrow>
-   { [ [ first ] card ]
-     [ [ second ] card ]
-     [ '[ |<< it get _ model-changed ] "No" op ]
-          [ '[ |<< [ it get [
-        _ value>> swap remove
-        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
-     ] change-model ] with-return ] "Yes" op ]
-   } cleave
-2array { 1 0 } <track> swap [ 0.5 track-add ] each
-3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
-it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
-
-: drill ( -- ) [
-   open-panel [
-         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
-            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
-         "Got it?" open-window
-   ] [ 0 exit ] if*
-] with-ui ;
-
-MAIN: drill
\ No newline at end of file
diff --git a/extra/drills/deployed/tags.txt b/extra/drills/deployed/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/drills/drills.factor b/extra/drills/drills.factor
deleted file mode 100644 (file)
index 1da1fca..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-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-border-btn> ;
-
-: show ( model -- gadget ) dup it set-global [ random ] <arrow>
-   { [ [ first ] card ]
-     [ [ second ] card ]
-     [ '[ |<< it get _ model-changed ] "No" op ]
-          [ '[ |<< [ it get [
-        _ value>> swap remove
-        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
-     ] change-model ] with-return ] "Yes" op ]
-   } cleave
-2array { 1 0 } <track> swap [ 0.5 track-add ] each
-3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
-it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
-
-: drill ( -- ) [
-   open-panel [
-         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
-            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
-         "Got it?" open-window
-   ] when*
-] with-ui ;
-
-MAIN: drill
\ No newline at end of file
diff --git a/extra/drills/tags.txt b/extra/drills/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
index c4d889991edf25be4e0b5184ee42dd9f9412a4d0..8e285a0904a35625acb1a1e31237aaae582895a3 100644 (file)
@@ -50,7 +50,7 @@ PRIVATE>
 
 : get-private-key ( -- bin/f )
     ec-key-handle EC_KEY_get0_private_key
-    dup [ dup BN_num_bits bits>bytes <byte-array> tuck BN_bn2bin drop ] when ;
+    dup [ dup BN_num_bits bits>bytes <byte-array> [ BN_bn2bin drop ] keep ] when ;
 
 :: get-public-key ( -- bin/f )
     ec-key-handle :> KEY
index c296dfb3df42c952b1b70152c6eddff28d59510b..34ccbc8aa8f1d8864a9c0dd53bfb43f441df5c86 100644 (file)
@@ -13,4 +13,4 @@ SYNTAX: FONT: \ ; parse-until {
     [ [ italic = ] find nip [ >>italic? ] install ]
     [ [ bold = ] find nip [ >>bold? ] install ]
     [ [ fontname? ] find nip [ >>name* ] install ]
-} cleave 4array concat '[ dup font>> @ drop ] over push-all ;
+} cleave 4array concat '[ dup font>> @ drop ] append! ;
index f67d0d7cd3ebc28358fcf82df5220aa11416fbb5..3f970a86bfa91554c10bb2f823e9f7c64f6a9e48 100644 (file)
@@ -1,13 +1,17 @@
 USING: arrays vectors combinators effects kernel math sequences splitting
 strings.parser parser fry sequences.extras ;
+
+! a b c glue => acb
+! c b a [ append ] dip prepend
+
 IN: fries
 : str-fry ( str on -- quot ) split
-    [ unclip-last [ [ spin glue ] reduce-r ] 2curry ]
+    [ unclip-last [ [ [ append ] [ prepend ] bi* ] 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 ]
+    [ unclip-last [ [ [ 1array ] [ append ] [ prepend ] tri* ] 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 ;
+SYNTAX: i" parse-string rest "_" str-fry append! ;
+SYNTAX: i{ \ } parse-until >array { _ } gen-fry append! ;
+SYNTAX: iV{ \ } parse-until >vector V{ _ } gen-fry append! ;
index ded10b66cbb936361b15649815f0125b31c47dea..d64ef41f8c590003eab71e68bcfc273242463f5e 100644 (file)
@@ -139,11 +139,11 @@ PRIVATE>
 
 : fuel-scaffold-vocab ( root name devname -- )
     [ fuel-scaffold-name dup [ scaffold-vocab ] dip ] with-scope
-    dup require vocab-source-path (normalize-path) fuel-eval-set-result ;
+    dup require vocab-source-path absolute-path fuel-eval-set-result ;
 
 : fuel-scaffold-help ( name devname -- )
     [ fuel-scaffold-name dup require dup scaffold-help ] with-scope
-    vocab-docs-path (normalize-path) fuel-eval-set-result ;
+    vocab-docs-path absolute-path fuel-eval-set-result ;
 
 : fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;
 
index c228901afbefea40326aa38cc2e6e1c08b776f9b..39ba3bd2b3c286d45c8f4e0a19e4d56bcb286f46 100644 (file)
@@ -11,7 +11,7 @@ IN: fuel.xref
 <PRIVATE
 
 : normalize-loc ( seq -- path line )
-    [ dup length 0 > [ first (normalize-path) ] [ drop f ] if ]
+    [ dup length 0 > [ first absolute-path ] [ drop f ] if ]
     [ dup length 1 > [ second ] [ drop 1 ] if ] bi ;
 
 : get-loc ( object -- loc ) normalize-loc 2array ;
index 0d2a5a73d8ae49fe6bd110486325fb2010a69d44..4c9c04ba8d2c28adfb761617b27fe2589b5f80e0 100644 (file)
@@ -189,7 +189,7 @@ CONSTANT: galois-slides
     }
     { $slide "Locals and lexical scope"
         { "Define lambda words with " { $link POSTPONE: :: } }
-        { "Establish bindings with " { $link POSTPONE: [let } " and " { $link POSTPONE: [let* } }
+        { "Establish bindings with " { $link POSTPONE: [let } " and " { $snippet "[let*" } }
         "Mutable bindings with correct semantics"
         { "Named inputs for quotations with " { $link POSTPONE: [| } }
         "Full closures"
index d07ed4b69c703feabc7c0d8e6c30edbe785c8e1c..f23848ce301a4738a8ebe4961ca69983adf0d366 100644 (file)
@@ -14,7 +14,7 @@ CONSTANT: db-url "http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=down
 : download-db ( -- path )
     db-path dup exists? [
         db-url over ".gz" append download-to
-        { "gunzip" } over ".gz" append (normalize-path) suffix try-process
+        { "gunzip" } over ".gz" append absolute-path suffix try-process
     ] unless ;
 
 TUPLE: ip-entry from to registry assigned city cntry country ;
index bbd16b7ff47ffd51a95d1af271445210f4061b8a..c398bdde7aae956df300231a05e2da432d152182 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators combinators.smart csv io.encodings.8-bit
-math.parser memoize sequences kernel unicode.categories money ;
+math.parser memoize sequences kernel unicode.categories money
+io.encodings.8-bit.latin1 ;
 IN: geobytes
 
 ! GeoBytes is not free software.
index 5f33af04fec51daa9cd455876bcf7f398a61f64a..02d0bedb2cb6738eeaf2754161ce6154dab662ee 100644 (file)
@@ -272,7 +272,7 @@ CONSTANT: google-slides
     }
     { $slide "Locals and lexical scope"
         { "Define lambda words with " { $link POSTPONE: :: } }
-        { "Establish bindings with " { $link POSTPONE: [let } " and " { $link POSTPONE: [let* } }
+        { "Establish bindings with " { $link POSTPONE: [let } " and " { $snippet "[let*" } }
         "Mutable bindings with correct semantics"
         { "Named inputs for quotations with " { $link POSTPONE: [| } }
         "Full closures"
index 3de5a03d3502cb7e0de117713c862c62b3b9e8e4..351a8b39b0c9432e8082cedeb3a4deef19ac3451 100644 (file)
@@ -124,7 +124,7 @@ UNION: gpu-data-ptr buffer-ptr c-ptr ;
 
     quot call
 
-    target glUnmapBuffer ; inline
+    target glUnmapBuffer drop ; inline
 
 :: with-bound-buffer ( buffer target quot: ( -- ) -- )
     target gl-target buffer glBindBuffer
index 2e292f014123b5e8c8a03fed7296c81d06498452..09853263ce58a8ce882e6a9b34ec9fd8e2891cca 100755 (executable)
@@ -3,13 +3,15 @@ USING: accessors alien.c-types arrays classes.struct combinators
 combinators.short-circuit game.worlds gpu gpu.buffers
 gpu.util.wasd gpu.framebuffers gpu.render gpu.shaders gpu.state
 gpu.textures gpu.util grouping http.client images images.loader
-io io.encodings.ascii io.files io.files.temp kernel math
-math.matrices math.parser math.vectors method-chains sequences
-splitting threads ui ui.gadgets ui.gadgets.worlds
-ui.pixel-formats specialized-arrays specialized-vectors ;
+io io.encodings.ascii io.files io.files.temp kernel locals math
+math.matrices math.vectors.simd math.parser math.vectors
+method-chains namespaces sequences splitting threads ui ui.gadgets
+ui.gadgets.worlds ui.pixel-formats specialized-arrays
+specialized-vectors ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 SPECIALIZED-VECTOR: uint
+SIMD: float
 IN: gpu.demos.bunny
 
 GLSL-SHADER-FILE: bunny-vertex-shader vertex-shader "bunny.v.glsl"
@@ -52,7 +54,10 @@ VERTEX-FORMAT: bunny-vertex
     { f        float-components 1 f }
     { "normal" float-components 3 f }
     { f        float-components 1 f } ;
-VERTEX-STRUCT: bunny-vertex-struct bunny-vertex
+
+STRUCT: bunny-vertex-struct
+    { vertex float-4 }
+    { normal float-4 } ;
 
 SPECIALIZED-VECTOR: bunny-vertex-struct
 
@@ -74,43 +79,58 @@ UNIFORM-TUPLE: loading-uniforms
     { "texcoord-scale"  vec2-uniform    f }
     { "loading-texture" texture-uniform f } ;
 
-: numbers ( str -- seq )
-    " " split [ string>number ] map sift ;
+: numbers ( tokens -- seq )
+    [ string>number ] map ; inline
 
 : <bunny-vertex> ( vertex -- struct )
     bunny-vertex-struct <struct>
-        swap >float-array >>vertex ; inline
+        swap first3 0.0 float-4-boa >>vertex ; inline
+
+: (read-line-tokens) ( seq stream -- seq )
+    " \n" over stream-read-until
+    [ [ pick push ] unless-empty ]
+    [
+        {
+            { CHAR: \s [ (read-line-tokens) ] }
+            { CHAR: \n [ drop ] }
+            [ 2drop [ f ] when-empty ]
+        } case
+    ] bi* ; inline recursive
+
+: stream-read-line-tokens ( stream -- seq )
+    V{ } clone swap (read-line-tokens) ;
+
+: each-line-tokens ( quot -- )
+    input-stream get [ stream-read-line-tokens ] curry each-morsel ; inline
 
 : (parse-bunny-model) ( vs is -- vs is )
-    readln [
+    [
         numbers {
-            { [ dup length 5 = ] [ 3 head <bunny-vertex> pick push ] }
-            { [ dup first 3 = ] [ rest over push-all ] }
+            { [ dup length 5 = ] [ <bunny-vertex> pick push ] }
+            { [ dup first 3 = ] [ rest append! ] }
             [ drop ]
-        } cond (parse-bunny-model)
-    ] when* ;
+        } cond
+    ] each-line-tokens ; inline
 
 : parse-bunny-model ( -- vertexes indexes )
     100000 <bunny-vertex-struct-vector>
     100000 <uint-vector>
-    (parse-bunny-model) ;
+    (parse-bunny-model) ; inline
 
-: normal ( vertexes -- normal )
-    [ [ second ] [ first ] bi v- ]
-    [ [ third  ] [ first ] bi v- ] bi cross
-    vneg normalize ; inline
+:: normal ( a b c -- normal )
+    c a v-
+    b a v- cross normalize ; inline
 
-: calc-bunny-normal ( vertexes indexes -- )
-    swap
-    [ [ nth vertex>> ] curry { } map-as normal ]
-    [ [ nth [ v+ ] change-normal drop ] curry with each ] 2bi ;
+:: calc-bunny-normal ( a b c vertexes -- )
+    a b c [ vertexes nth vertex>> ] tri@ normal :> n
+    a b c [ vertexes nth [ n v+ ] change-normal drop ] tri@ ; inline
 
 : calc-bunny-normals ( vertexes indexes -- )
-    3 <groups>
-    [ calc-bunny-normal ] with each ;
+    3 <sliced-groups> swap
+    [ [ first3 ] dip calc-bunny-normal ] curry each ; inline
 
 : normalize-bunny-normals ( vertexes -- )
-    [ [ normalize ] change-normal drop ] each ;
+    [ [ normalize ] change-normal drop ] each ; inline
 
 : bunny-data ( filename -- vertexes indexes )
     ascii [ parse-bunny-model ] with-file-reader
index efd71782d01550e353d9c22e94f0b27231d94a2a..bea72961e4f6729f074e01a3294af398823c8f90 100755 (executable)
@@ -157,10 +157,13 @@ M: renderbuffer framebuffer-attachment-dim
     [ swap depth-attachment>>   [ swap call ] [ drop ] if* ]
     [ swap stencil-attachment>> [ swap call ] [ drop ] if* ] 2tri ; inline
 
-: each-attachment-target ( framebuffer quot: ( attachment-target attachment -- ) -- )
-    [ [ color-attachments>> ] dip [ GL_COLOR_ATTACHMENT0 + swap ] prepose each-index ]
-    [ swap depth-attachment>>   [ GL_DEPTH_ATTACHMENT   spin call ] [ drop ] if* ]
-    [ swap stencil-attachment>> [ GL_STENCIL_ATTACHMENT spin call ] [ drop ] if* ] 2tri ; inline
+:: each-attachment-target ( framebuffer quot: ( attachment-target attachment -- ) -- )
+    framebuffer color-attachments>>
+    [| attachment n | n GL_COLOR_ATTACHMENT0 + attachment quot call ] each-index
+    framebuffer depth-attachment>>
+    [| attachment | GL_DEPTH_ATTACHMENT attachment quot call ] when*
+    framebuffer stencil-attachment>>
+    [| attachment | GL_STENCIL_ATTACHMENT attachment quot call ] when* ; inline
 
 GENERIC: bind-framebuffer-attachment ( attachment-target attachment -- )
 
index 5f92cf3dbf3d4ac70bb0f8769b8b99bcc1361650..1a13d3e55630cf73c72b142e5d418dd603eb337c 100644 (file)
@@ -332,13 +332,13 @@ DEFER: [bind-uniform-tuple]
     ] [
         { [ ] }
         name "." append 1array
-    ] if* :> name-prefixes :> quot-prefixes
+    ] if* :> ( quot-prefixes name-prefixes )
     type all-uniform-tuple-slots :> uniforms
 
     texture-unit quot-prefixes name-prefixes [| quot-prefix name-prefix |
         uniforms name-prefix [bind-uniform-tuple]
         quot-prefix prepend
-    ] 2map :> value-cleave :> texture-unit'
+    ] 2map :> ( texture-unit' value-cleave )
 
     texture-unit' 
     value>>-quot { value-cleave 2cleave } append ;
@@ -356,7 +356,7 @@ DEFER: [bind-uniform-tuple]
     } cond ;
 
 :: [bind-uniform-tuple] ( texture-unit uniforms prefix -- texture-unit' quot )
-    texture-unit uniforms [ prefix [bind-uniform] ] map :> uniforms-cleave :> texture-unit'
+    texture-unit uniforms [ prefix [bind-uniform] ] map :> ( texture-unit' uniforms-cleave )
 
     texture-unit'
     { uniforms-cleave 2cleave } >quotation ;
index aece1b40d671c40358d2733db9ef26327ebbddee..fc6d495dff27933c7474e9199a9e6d9cb9cc4623 100755 (executable)
@@ -277,7 +277,7 @@ padding-no [ 0 ] initialize
     ] [ nip ] if ":" join ;
 
 : replace-log-line-numbers ( object log -- log' )
-    "\n" split [ empty? not ] filter
+    "\n" split harvest
     [ replace-log-line-number ] with map
     "\n" join ;
 
index bee05463afd1f37feda7f4a30afc9d8e6d205871..b5ed28cc3d8947152a2cf7bb0a779eaf5fe52f66 100644 (file)
@@ -49,6 +49,9 @@ M: wasd-world wasd-fly-vertically? drop t ;
 : wasd-p-matrix ( world -- matrix )
     p-matrix>> ;
 
+: <mvp-uniforms> ( world -- uniforms )
+    [ wasd-mv-matrix ] [ wasd-p-matrix ] bi mvp-uniforms boa ;
+
 CONSTANT: fov 0.7
 
 :: generate-p-matrix ( world -- matrix )
@@ -107,12 +110,12 @@ CONSTANT: fov 0.7
 
 :: wasd-keyboard-input ( world -- )
     read-keyboard keys>> :> keys
-    key-w keys nth key-, keys nth or [ world walk-forward   ] when 
-    key-s keys nth key-o keys nth or [ world walk-backward  ] when 
-    key-a keys nth                   [ world walk-leftward  ] when 
-    key-d keys nth key-e keys nth or [ world walk-rightward ] when 
+    key-w keys nth [ world walk-forward   ] when 
+    key-s keys nth [ world walk-backward  ] when 
+    key-a keys nth [ world walk-leftward  ] when 
+    key-d keys nth [ world walk-rightward ] when 
     key-space keys nth [ world walk-upward ] when 
-    key-c keys nth key-j keys nth or [ world walk-downward ] when 
+    key-c keys nth [ world walk-downward ] when 
     key-escape keys nth [ world close-window ] when ;
 
 : wasd-mouse-input ( world -- )
diff --git a/extra/half-floats/authors.txt b/extra/half-floats/authors.txt
deleted file mode 100644 (file)
index f13c9c1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Joe Groff
diff --git a/extra/half-floats/half-floats-tests.factor b/extra/half-floats/half-floats-tests.factor
deleted file mode 100644 (file)
index d6b26cb..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-USING: accessors alien.c-types alien.syntax half-floats kernel
-math tools.test specialized-arrays alien.data classes.struct ;
-SPECIALIZED-ARRAY: half
-IN: half-floats.tests
-
-[ HEX: 0000 ] [  0.0  half>bits ] unit-test
-[ HEX: 8000 ] [ -0.0  half>bits ] unit-test
-[ HEX: 3e00 ] [  1.5  half>bits ] unit-test
-[ HEX: be00 ] [ -1.5  half>bits ] unit-test
-[ HEX: 7c00 ] [  1/0. half>bits ] unit-test
-[ HEX: fc00 ] [ -1/0. half>bits ] unit-test
-[ HEX: 7eaa ] [ NAN: aaaaaaaaaaaaa half>bits ] unit-test
-
-! too-big floats overflow to infinity
-[ HEX: 7c00 ] [   65536.0 half>bits ] unit-test
-[ HEX: fc00 ] [  -65536.0 half>bits ] unit-test
-[ HEX: 7c00 ] [  131072.0 half>bits ] unit-test
-[ HEX: fc00 ] [ -131072.0 half>bits ] unit-test
-
-! too-small floats flush to zero
-[ HEX: 0000 ] [  1.0e-9 half>bits ] unit-test
-[ HEX: 8000 ] [ -1.0e-9 half>bits ] unit-test
-
-[  0.0  ] [ HEX: 0000 bits>half ] unit-test
-[ -0.0  ] [ HEX: 8000 bits>half ] unit-test
-[  1.5  ] [ HEX: 3e00 bits>half ] unit-test
-[ -1.5  ] [ HEX: be00 bits>half ] unit-test
-[  1/0. ] [ HEX: 7c00 bits>half ] unit-test
-[ -1/0. ] [ HEX: fc00 bits>half ] unit-test
-[  3.0  ] [ HEX: 4200 bits>half ] unit-test
-[    t  ] [ HEX: 7e00 bits>half fp-nan? ] unit-test
-
-STRUCT: halves
-    { tom half }
-    { dick half }
-    { harry half }
-    { harry-jr half } ;
-
-[ 8 ] [ halves heap-size ] unit-test
-
-[ 3.0 ] [
-    halves <struct>
-        3.0 >>dick
-    dick>>
-] unit-test
-
-[ half-array{ 1.0 2.0 3.0 1/0. -1/0. } ]
-[ { 1.0 2.0 3.0 1/0. -1/0. } >half-array ] unit-test
-
diff --git a/extra/half-floats/half-floats.factor b/extra/half-floats/half-floats.factor
deleted file mode 100755 (executable)
index d0f6a09..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-! (c)2009 Joe Groff bsd license
-USING: accessors alien.accessors alien.c-types alien.data
-alien.syntax kernel math math.order ;
-FROM: math => float ;
-IN: half-floats
-
-: half>bits ( float -- bits )
-    float>bits
-    [ -31 shift 15 shift ] [
-        HEX: 7fffffff bitand
-        dup zero? [
-            dup HEX: 7f800000 >= [ -13 shift HEX: 7fff bitand ] [
-                -13 shift
-                112 10 shift -
-                0 HEX: 7c00 clamp
-            ] if
-        ] unless
-    ] bi bitor ;
-
-: bits>half ( bits -- float )
-    [ -15 shift 31 shift ] [
-        HEX: 7fff bitand
-        dup zero? [
-            dup HEX: 7c00 >= [ 13 shift HEX: 7f800000 bitor ] [
-                13 shift
-                112 23 shift + 
-            ] if
-        ] unless
-    ] bi bitor bits>float ;
-
-SYMBOL: half
-
-<<
-
-<c-type>
-    float >>class
-    float >>boxed-class
-    [ alien-unsigned-2 bits>half ] >>getter
-    [ [ >float half>bits ] 2dip set-alien-unsigned-2 ] >>setter
-    2 >>size
-    2 >>align
-    [ >float ] >>unboxer-quot
-\ half define-primitive-type
-
->>
diff --git a/extra/half-floats/summary.txt b/extra/half-floats/summary.txt
deleted file mode 100644 (file)
index b22448f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Half-precision float support for FFI
diff --git a/extra/histogram/histogram-docs.factor b/extra/histogram/histogram-docs.factor
deleted file mode 100755 (executable)
index fc463ca..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-IN: histogram\r
-USING: help.markup help.syntax sequences hashtables quotations assocs ;\r
-\r
-HELP: histogram\r
-{ $values\r
-    { "seq" sequence }\r
-    { "hashtable" hashtable }\r
-}\r
-{ $examples \r
-    { $example "! Count the number of times an element appears in a sequence."\r
-               "USING: prettyprint histogram ;"\r
-               "\"aaabc\" histogram ."\r
-               "H{ { 97 3 } { 98 1 } { 99 1 } }"\r
-    }\r
-}\r
-{ $description "Returns a hashtable where the keys are the elements of the sequence and the values are the number of times they appeared in that sequence." } ;\r
-\r
-HELP: histogram*\r
-{ $values\r
-    { "hashtable" hashtable } { "seq" sequence }\r
-    { "hashtable" hashtable }\r
-}\r
-{ $examples \r
-    { $example "! Count the number of times the elements of two sequences appear."\r
-               "USING: prettyprint histogram ;"\r
-               "\"aaabc\" histogram \"aaaaaabc\" histogram* ."\r
-               "H{ { 97 9 } { 98 2 } { 99 2 } }"\r
-    }\r
-}\r
-{ $description "Takes an existing hashtable and uses " { $link histogram } " to continue counting the number of occurences of each element." } ;\r
-\r
-HELP: sequence>assoc\r
-{ $values\r
-    { "seq" sequence } { "quot" quotation } { "exemplar" "an exemplar assoc" }\r
-    { "assoc" assoc }\r
-}\r
-{ $examples \r
-    { $example "! Iterate over a sequence and increment the count at each element"\r
-               "USING: assocs prettyprint histogram ;"\r
-               "\"aaabc\" [ inc-at ] H{ } sequence>assoc ."\r
-               "H{ { 97 3 } { 98 1 } { 99 1 } }"\r
-    }\r
-}\r
-{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a newly created " { $snippet "assoc" } " according to the passed quotation." } ;\r
-\r
-HELP: sequence>assoc*\r
-{ $values\r
-    { "assoc" assoc } { "seq" sequence } { "quot" quotation }\r
-    { "assoc" assoc }\r
-}\r
-{ $examples \r
-    { $example "! Iterate over a sequence and add the counts to an existing assoc"\r
-               "USING: assocs prettyprint histogram kernel ;"\r
-               "H{ { 97 2 } { 98 1 } } clone \"aaabc\" [ inc-at ] sequence>assoc* ."\r
-               "H{ { 97 5 } { 98 2 } { 99 1 } }"\r
-    }\r
-}\r
-{ $description "Iterates over a sequence, allowing elements of the sequence to be added to an existing " { $snippet "assoc" } " according to the passed quotation." } ;\r
-\r
-HELP: sequence>hashtable\r
-{ $values\r
-    { "seq" sequence } { "quot" quotation }\r
-    { "hashtable" hashtable }\r
-}\r
-{ $examples \r
-    { $example "! Count the number of times an element occurs in a sequence"\r
-               "USING: assocs prettyprint histogram ;"\r
-               "\"aaabc\" [ inc-at ] sequence>hashtable ."\r
-               "H{ { 97 3 } { 98 1 } { 99 1 } }"\r
-    }\r
-}\r
-{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a hashtable according to the passed quotation." } ;\r
-\r
-ARTICLE: "histogram" "Computing histograms"\r
-"Counting elements in a sequence:"\r
-{ $subsections\r
-    histogram\r
-    histogram*\r
-}\r
-"Combinators for implementing histogram:"\r
-{ $subsections\r
-    sequence>assoc\r
-    sequence>assoc*\r
-    sequence>hashtable\r
-} ;\r
-\r
-ABOUT: "histogram"\r
diff --git a/extra/histogram/histogram-tests.factor b/extra/histogram/histogram-tests.factor
deleted file mode 100755 (executable)
index f0e7b3e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-IN: histogram.tests\r
-USING: help.markup help.syntax tools.test histogram ;\r
-\r
-[\r
-    H{\r
-        { 97 2 }\r
-        { 98 2 }\r
-        { 99 2 }\r
-    }\r
-] [\r
-    "aabbcc" histogram\r
-] unit-test\r
diff --git a/extra/histogram/histogram.factor b/extra/histogram/histogram.factor
deleted file mode 100755 (executable)
index d5c6ab3..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-! Copyright (C) 2009 Doug Coleman.\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel sequences assocs fry ;\r
-IN: histogram\r
-\r
-<PRIVATE\r
-\r
-: (sequence>assoc) ( seq quot assoc -- assoc )\r
-    [ swap curry each ] keep ; inline\r
-\r
-PRIVATE>\r
-\r
-: sequence>assoc* ( assoc seq quot: ( obj assoc -- ) -- assoc )\r
-    rot (sequence>assoc) ; inline\r
-\r
-: sequence>assoc ( seq quot: ( obj assoc -- ) exemplar -- assoc )\r
-    clone (sequence>assoc) ; inline\r
-\r
-: sequence>hashtable ( seq quot: ( obj hashtable -- ) -- hashtable )\r
-    H{ } sequence>assoc ; inline\r
-\r
-: histogram* ( hashtable seq -- hashtable )\r
-    [ inc-at ] sequence>assoc* ;\r
-\r
-: histogram ( seq -- hashtable )\r
-    [ inc-at ] sequence>hashtable ;\r
-\r
-: collect-values ( seq quot: ( obj hashtable -- ) -- hash )\r
-    '[ [ dup @ ] dip push-at ] sequence>hashtable ; inline\r
index 9fcbffd0db31daa220a9e18a125bb3c324cb70be..8d506cda28539a3b3efc098c5c7e8baa1fc7668a 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hashtables sequence-parser
+USING: accessors arrays hashtables sequences.parser
 html.parser.utils kernel namespaces sequences math
 unicode.case unicode.categories combinators.short-circuit
 quoting fry ;
diff --git a/extra/images/normalization/authors.txt b/extra/images/normalization/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/images/normalization/normalization-docs.factor b/extra/images/normalization/normalization-docs.factor
deleted file mode 100644 (file)
index 8ed4b65..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-! Copyright (C) 2009 Keith Lazuka.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel images ;
-IN: images.normalization
-
-HELP: normalize-image
-{ $values
-    { "image" image }
-    { "image" image }
-}
-{ $description "Converts the image to RGBA with ubyte-components. If the image is upside-down, it will be flipped right side up such that the 1st byte in the bitmap slot's byte array corresponds to the first color component of the pixel in the upper-left corner of the image." } ;
-
-HELP: reorder-components
-{ $values
-    { "image" image } { "component-order" component-order }
-    { "image" image }
-}
-{ $description "Convert the bitmap in " { $snippet "image" } " such that the pixel sample layout corresponds to " { $snippet "component-order" } ". If the destination layout cannot find a corresponding value from the source layout, the value " { $snippet "255" } " will be substituted for that byte." }
-{ $warning "The image's " { $snippet "component-type" } " will be changed to " { $snippet "ubyte-components" } " if it is not already in that format."
-$nl
-"You cannot use this word to reorder " { $link DEPTH } ", " { $link DEPTH-STENCIL } " or " { $link INTENSITY } " component orders." } ;
-
-ARTICLE: "images.normalization" "Image normalization"
-"The " { $vocab-link "images.normalization" } " vocab can be used to convert between " { $link image } " representations."
-$nl
-"You can normalize any image to a RGBA with ubyte-components representation:"
-{ $subsections normalize-image }
-"Convert an image's pixel layout to match an arbitrary " { $link component-order } ":"
-{ $subsections reorder-components } ;
-
-ABOUT: "images.normalization"
diff --git a/extra/images/normalization/normalization-tests.factor b/extra/images/normalization/normalization-tests.factor
deleted file mode 100644 (file)
index c85aed4..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-! Copyright (C) 2009 Keith Lazuka.
-! See http://factorcode.org/license.txt for BSD license.
-USING: images images.normalization images.normalization.private
-sequences tools.test ;
-IN: images.normalization.tests
-
-! 1>x
-
-[ B{ 255 255 } ]
-[ B{ 0 1 } A L permute ] unit-test
-
-[ B{ 255 255 255 255 } ]
-[ B{ 0 1 } A RG permute ] unit-test
-
-[ B{ 255 255 255 255 255 255 } ]
-[ B{ 0 1 } A BGR permute ] unit-test
-
-[ B{ 0 255 255 255 1 255 255 255 } ]
-[ B{ 0 1 } A ABGR permute ] unit-test
-
-! 2>x
-
-[ B{ 0 2 } ]
-[ B{ 0 1 2 3 } LA L permute ] unit-test
-
-[ B{ 255 255 255 255 } ]
-[ B{ 0 1 2 3 } LA RG permute ] unit-test
-
-[ B{ 255 255 255 255 255 255 } ]
-[ B{ 0 1 2 3 } LA BGR permute ] unit-test
-
-[ B{ 1 255 255 255 3 255 255 255 } ]
-[ B{ 0 1 2 3 } LA ABGR permute ] unit-test
-
-! 3>x
-
-[ B{ 255 255 } ]
-[ B{ 0 1 2 3 4 5 } RGB L permute ] unit-test
-
-[ B{ 0 1 3 4 } ]
-[ B{ 0 1 2 3 4 5 } RGB RG permute ] unit-test
-
-[ B{ 2 1 0 5 4 3 } ]
-[ B{ 0 1 2 3 4 5 } RGB BGR permute ] unit-test
-
-[ B{ 255 2 1 0 255 5 4 3 } ]
-[ B{ 0 1 2 3 4 5 } RGB ABGR permute ] unit-test
-
-! 4>x
-
-[ B{ 255 255 } ]
-[ B{ 0 1 2 3 4 5 6 7 } RGBA L permute ] unit-test
-
-[ B{ 0 1 4 5 } ]
-[ B{ 0 1 2 3 4 5 6 7 } RGBA RG permute ] unit-test
-
-[ B{ 2 1 0 6 5 4 } ]
-[ B{ 0 1 2 3 4 5 6 7 } RGBA BGR permute ] unit-test
-
-[ B{ 3 2 1 0 7 6 5 4 } ]
-[ B{ 0 1 2 3 4 5 6 7 } RGBA ABGR permute ] unit-test
-
-! Edge cases
-
-[ B{ 0 4 } ]
-[ B{ 0 1 2 3 4 5 6 7 } RGBA R permute ] unit-test
-
-[ B{ 255 0 1 2 255 4 5 6 } ]
-[ B{ 0 1 2 3 4 5 6 7 } RGBA XRGB permute ] unit-test
-
-[ B{ 1 2 3 255 5 6 7 255 } ]
-[ B{ 0 1 2 3 4 5 6 7 } XRGB RGBA permute ] unit-test
-
-[ B{ 255 255 255 255 255 255 255 255 } ]
-[ B{ 0 1 } L RGBA permute ] unit-test
-
-! Invalid inputs
-
-[
-    T{ image f { 1 1 } DEPTH ubyte-components f B{ 0 } }
-    RGB reorder-components
-] must-fail
-
-[
-    T{ image f { 1 1 } DEPTH-STENCIL ubyte-components f B{ 0 } }
-    RGB reorder-components
-] must-fail
-
-[
-    T{ image f { 1 1 } INTENSITY ubyte-components f B{ 0 } }
-    RGB reorder-components
-] must-fail
-
-[
-    T{ image f { 1 1 } RGB ubyte-components f B{ 0 0 0 } }
-    DEPTH reorder-components
-] must-fail
-
-[
-    T{ image f { 1 1 } RGB ubyte-components f B{ 0 0 0 } }
-    DEPTH-STENCIL reorder-components
-] must-fail
-
-[
-    T{ image f { 1 1 } RGB ubyte-components f B{ 0 0 0 } }
-    INTENSITY reorder-components
-] must-fail
-
diff --git a/extra/images/normalization/normalization.factor b/extra/images/normalization/normalization.factor
deleted file mode 100755 (executable)
index 0beaa1d..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-! Copyright (C) 2009 Doug Coleman, Keith Lazuka
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types byte-arrays combinators fry
-grouping images kernel locals math math.vectors
-sequences specialized-arrays half-floats ;
-FROM: alien.c-types => float ;
-SPECIALIZED-ARRAY: half
-SPECIALIZED-ARRAY: float
-SPECIALIZED-ARRAY: ushort
-IN: images.normalization
-
-<PRIVATE
-
-CONSTANT: don't-care 127
-CONSTANT: fill-value 255
-
-: permutation ( src dst -- seq )
-    swap '[ _ index [ don't-care ] unless* ] { } map-as
-    4 don't-care pad-tail ;
-
-: pad4 ( seq -- newseq ) 4 fill-value pad-tail ;
-
-: shuffle ( seq permutation -- newseq )
-    swap '[
-        dup 4 >= [ drop fill-value ] [ _ nth ] if
-    ] B{ } map-as ;
-
-:: permute ( bytes src-order dst-order -- new-bytes )
-    [let | src [ src-order name>> ]
-           dst [ dst-order name>> ] |
-        bytes src length group
-        [ pad4 src dst permutation shuffle dst length head ]
-        map concat ] ;
-
-: (reorder-components) ( image src-order dest-order -- image )
-    [ permute ] 2curry change-bitmap ;
-
-GENERIC: normalize-component-type* ( image component-type -- image )
-
-: normalize-floats ( float-array -- byte-array )
-    [ 255.0 * >integer ] B{ } map-as ;
-
-M: float-components normalize-component-type*
-    drop byte-array>float-array normalize-floats ;
-
-M: half-components normalize-component-type*
-    drop byte-array>half-array normalize-floats ;
-
-: ushorts>ubytes ( bitmap -- bitmap' )
-    byte-array>ushort-array [ -8 shift ] B{ } map-as ; inline
-
-M: ushort-components normalize-component-type*
-    drop ushorts>ubytes ;
-
-M: ubyte-components normalize-component-type*
-    drop ;
-
-: normalize-scan-line-order ( image -- image )
-    dup upside-down?>> [
-        dup dim>> first 4 * '[
-            _ <groups> reverse concat
-        ] change-bitmap
-        f >>upside-down?
-    ] when ;
-
-: validate-request ( src-order dst-order -- src-order dst-order )
-    [
-        [ { DEPTH DEPTH-STENCIL INTENSITY } member? ] bi@
-        or [ "Invalid component-order" throw ] when
-    ] 2keep ;
-
-PRIVATE>
-
-: reorder-components ( image component-order -- image )
-    [
-        dup component-type>> '[ _ normalize-component-type* ] change-bitmap
-        dup component-order>>
-    ] dip
-    validate-request [ (reorder-components) ] keep >>component-order ;
-
-: normalize-image ( image -- image )
-    [ >byte-array ] change-bitmap
-    RGBA reorder-components
-    normalize-scan-line-order ;
-
diff --git a/extra/images/testing/bmp/1bit.bmp b/extra/images/testing/bmp/1bit.bmp
new file mode 100644 (file)
index 0000000..2f244c1
Binary files /dev/null and b/extra/images/testing/bmp/1bit.bmp differ
diff --git a/extra/images/testing/bmp/42red_24bit.bmp b/extra/images/testing/bmp/42red_24bit.bmp
new file mode 100644 (file)
index 0000000..e95a4f7
Binary files /dev/null and b/extra/images/testing/bmp/42red_24bit.bmp differ
diff --git a/extra/images/testing/bmp/42red_24bit.fig b/extra/images/testing/bmp/42red_24bit.fig
new file mode 100644 (file)
index 0000000..9c2ce17
Binary files /dev/null and b/extra/images/testing/bmp/42red_24bit.fig differ
diff --git a/extra/images/testing/bmp/rgb_4bit.bmp b/extra/images/testing/bmp/rgb_4bit.bmp
new file mode 100644 (file)
index 0000000..0c6f00d
Binary files /dev/null and b/extra/images/testing/bmp/rgb_4bit.bmp differ
diff --git a/extra/images/testing/bmp/rgb_8bit.bmp b/extra/images/testing/bmp/rgb_8bit.bmp
new file mode 100644 (file)
index 0000000..bc95c0f
Binary files /dev/null and b/extra/images/testing/bmp/rgb_8bit.bmp differ
diff --git a/extra/images/testing/bmp/rgb_8bit.fig b/extra/images/testing/bmp/rgb_8bit.fig
new file mode 100644 (file)
index 0000000..4b75a10
Binary files /dev/null and b/extra/images/testing/bmp/rgb_8bit.fig differ
diff --git a/extra/images/testing/gif/alpha.fig b/extra/images/testing/gif/alpha.fig
new file mode 100644 (file)
index 0000000..b36a8f6
Binary files /dev/null and b/extra/images/testing/gif/alpha.fig differ
diff --git a/extra/images/testing/gif/alpha.gif b/extra/images/testing/gif/alpha.gif
new file mode 100644 (file)
index 0000000..c4c38bd
Binary files /dev/null and b/extra/images/testing/gif/alpha.gif differ
diff --git a/extra/images/testing/gif/astronaut_animation.fig b/extra/images/testing/gif/astronaut_animation.fig
new file mode 100644 (file)
index 0000000..905da6d
Binary files /dev/null and b/extra/images/testing/gif/astronaut_animation.fig differ
diff --git a/extra/images/testing/gif/astronaut_animation.gif b/extra/images/testing/gif/astronaut_animation.gif
new file mode 100644 (file)
index 0000000..8c76848
Binary files /dev/null and b/extra/images/testing/gif/astronaut_animation.gif differ
diff --git a/extra/images/testing/gif/checkmark.fig b/extra/images/testing/gif/checkmark.fig
new file mode 100644 (file)
index 0000000..c177d89
Binary files /dev/null and b/extra/images/testing/gif/checkmark.fig differ
diff --git a/extra/images/testing/gif/checkmark.gif b/extra/images/testing/gif/checkmark.gif
new file mode 100644 (file)
index 0000000..df83efa
Binary files /dev/null and b/extra/images/testing/gif/checkmark.gif differ
diff --git a/extra/images/testing/gif/circle.fig b/extra/images/testing/gif/circle.fig
new file mode 100644 (file)
index 0000000..330397f
Binary files /dev/null and b/extra/images/testing/gif/circle.fig differ
diff --git a/extra/images/testing/gif/circle.gif b/extra/images/testing/gif/circle.gif
new file mode 100644 (file)
index 0000000..101a48a
Binary files /dev/null and b/extra/images/testing/gif/circle.gif differ
diff --git a/extra/images/testing/gif/monochrome.fig b/extra/images/testing/gif/monochrome.fig
new file mode 100644 (file)
index 0000000..69de845
Binary files /dev/null and b/extra/images/testing/gif/monochrome.fig differ
diff --git a/extra/images/testing/gif/monochrome.gif b/extra/images/testing/gif/monochrome.gif
new file mode 100644 (file)
index 0000000..b0875fa
Binary files /dev/null and b/extra/images/testing/gif/monochrome.gif differ
diff --git a/extra/images/testing/gif/noise.fig b/extra/images/testing/gif/noise.fig
new file mode 100644 (file)
index 0000000..a2650e9
Binary files /dev/null and b/extra/images/testing/gif/noise.fig differ
diff --git a/extra/images/testing/gif/noise.gif b/extra/images/testing/gif/noise.gif
new file mode 100644 (file)
index 0000000..31dffae
Binary files /dev/null and b/extra/images/testing/gif/noise.gif differ
diff --git a/extra/images/testing/png/basn2c08.fig b/extra/images/testing/png/basn2c08.fig
new file mode 100644 (file)
index 0000000..84f8c97
Binary files /dev/null and b/extra/images/testing/png/basn2c08.fig differ
diff --git a/extra/images/testing/png/basn2c08.png b/extra/images/testing/png/basn2c08.png
new file mode 100644 (file)
index 0000000..db5ad15
Binary files /dev/null and b/extra/images/testing/png/basn2c08.png differ
diff --git a/extra/images/testing/png/basn6a08.fig b/extra/images/testing/png/basn6a08.fig
new file mode 100644 (file)
index 0000000..f188879
Binary files /dev/null and b/extra/images/testing/png/basn6a08.fig differ
diff --git a/extra/images/testing/png/basn6a08.png b/extra/images/testing/png/basn6a08.png
new file mode 100644 (file)
index 0000000..e608738
Binary files /dev/null and b/extra/images/testing/png/basn6a08.png differ
diff --git a/extra/images/testing/png/f00n2c08.fig b/extra/images/testing/png/f00n2c08.fig
new file mode 100644 (file)
index 0000000..6a6aef9
Binary files /dev/null and b/extra/images/testing/png/f00n2c08.fig differ
diff --git a/extra/images/testing/png/f00n2c08.png b/extra/images/testing/png/f00n2c08.png
new file mode 100644 (file)
index 0000000..d6a1fff
Binary files /dev/null and b/extra/images/testing/png/f00n2c08.png differ
diff --git a/extra/images/testing/png/f01n2c08.fig b/extra/images/testing/png/f01n2c08.fig
new file mode 100644 (file)
index 0000000..f08c0bb
Binary files /dev/null and b/extra/images/testing/png/f01n2c08.fig differ
diff --git a/extra/images/testing/png/f01n2c08.png b/extra/images/testing/png/f01n2c08.png
new file mode 100644 (file)
index 0000000..26fee95
Binary files /dev/null and b/extra/images/testing/png/f01n2c08.png differ
diff --git a/extra/images/testing/png/f02n2c08.fig b/extra/images/testing/png/f02n2c08.fig
new file mode 100644 (file)
index 0000000..722f02a
Binary files /dev/null and b/extra/images/testing/png/f02n2c08.fig differ
diff --git a/extra/images/testing/png/f02n2c08.png b/extra/images/testing/png/f02n2c08.png
new file mode 100644 (file)
index 0000000..e590f12
Binary files /dev/null and b/extra/images/testing/png/f02n2c08.png differ
diff --git a/extra/images/testing/png/f03n2c08.fig b/extra/images/testing/png/f03n2c08.fig
new file mode 100644 (file)
index 0000000..2a37fe6
Binary files /dev/null and b/extra/images/testing/png/f03n2c08.fig differ
diff --git a/extra/images/testing/png/f03n2c08.png b/extra/images/testing/png/f03n2c08.png
new file mode 100644 (file)
index 0000000..7581150
Binary files /dev/null and b/extra/images/testing/png/f03n2c08.png differ
diff --git a/extra/images/testing/png/f04n2c08.fig b/extra/images/testing/png/f04n2c08.fig
new file mode 100644 (file)
index 0000000..c0db771
Binary files /dev/null and b/extra/images/testing/png/f04n2c08.fig differ
diff --git a/extra/images/testing/png/f04n2c08.png b/extra/images/testing/png/f04n2c08.png
new file mode 100644 (file)
index 0000000..3c8b511
Binary files /dev/null and b/extra/images/testing/png/f04n2c08.png differ
diff --git a/extra/images/testing/png/suite/basi0g01.png b/extra/images/testing/png/suite/basi0g01.png
new file mode 100644 (file)
index 0000000..556fa72
Binary files /dev/null and b/extra/images/testing/png/suite/basi0g01.png differ
diff --git a/extra/images/testing/png/suite/basi0g02.png b/extra/images/testing/png/suite/basi0g02.png
new file mode 100644 (file)
index 0000000..ce09821
Binary files /dev/null and b/extra/images/testing/png/suite/basi0g02.png differ
diff --git a/extra/images/testing/png/suite/basi0g04.png b/extra/images/testing/png/suite/basi0g04.png
new file mode 100644 (file)
index 0000000..3853273
Binary files /dev/null and b/extra/images/testing/png/suite/basi0g04.png differ
diff --git a/extra/images/testing/png/suite/basi0g08.png b/extra/images/testing/png/suite/basi0g08.png
new file mode 100644 (file)
index 0000000..faed8be
Binary files /dev/null and b/extra/images/testing/png/suite/basi0g08.png differ
diff --git a/extra/images/testing/png/suite/basi0g16.png b/extra/images/testing/png/suite/basi0g16.png
new file mode 100644 (file)
index 0000000..a9f2816
Binary files /dev/null and b/extra/images/testing/png/suite/basi0g16.png differ
diff --git a/extra/images/testing/png/suite/basi2c08.png b/extra/images/testing/png/suite/basi2c08.png
new file mode 100644 (file)
index 0000000..2aab44d
Binary files /dev/null and b/extra/images/testing/png/suite/basi2c08.png differ
diff --git a/extra/images/testing/png/suite/basi2c16.png b/extra/images/testing/png/suite/basi2c16.png
new file mode 100644 (file)
index 0000000..cd7e50f
Binary files /dev/null and b/extra/images/testing/png/suite/basi2c16.png differ
diff --git a/extra/images/testing/png/suite/basi3p01.png b/extra/images/testing/png/suite/basi3p01.png
new file mode 100644 (file)
index 0000000..00a7cea
Binary files /dev/null and b/extra/images/testing/png/suite/basi3p01.png differ
diff --git a/extra/images/testing/png/suite/basi3p02.png b/extra/images/testing/png/suite/basi3p02.png
new file mode 100644 (file)
index 0000000..bb16b44
Binary files /dev/null and b/extra/images/testing/png/suite/basi3p02.png differ
diff --git a/extra/images/testing/png/suite/basi3p04.png b/extra/images/testing/png/suite/basi3p04.png
new file mode 100644 (file)
index 0000000..b4e888e
Binary files /dev/null and b/extra/images/testing/png/suite/basi3p04.png differ
diff --git a/extra/images/testing/png/suite/basi3p08.png b/extra/images/testing/png/suite/basi3p08.png
new file mode 100644 (file)
index 0000000..50a6d1c
Binary files /dev/null and b/extra/images/testing/png/suite/basi3p08.png differ
diff --git a/extra/images/testing/png/suite/basi4a08.png b/extra/images/testing/png/suite/basi4a08.png
new file mode 100644 (file)
index 0000000..398132b
Binary files /dev/null and b/extra/images/testing/png/suite/basi4a08.png differ
diff --git a/extra/images/testing/png/suite/basi4a16.png b/extra/images/testing/png/suite/basi4a16.png
new file mode 100644 (file)
index 0000000..51192e7
Binary files /dev/null and b/extra/images/testing/png/suite/basi4a16.png differ
diff --git a/extra/images/testing/png/suite/basi6a08.png b/extra/images/testing/png/suite/basi6a08.png
new file mode 100644 (file)
index 0000000..aecb32e
Binary files /dev/null and b/extra/images/testing/png/suite/basi6a08.png differ
diff --git a/extra/images/testing/png/suite/basi6a16.png b/extra/images/testing/png/suite/basi6a16.png
new file mode 100644 (file)
index 0000000..4181533
Binary files /dev/null and b/extra/images/testing/png/suite/basi6a16.png differ
diff --git a/extra/images/testing/png/suite/basn0g01.png b/extra/images/testing/png/suite/basn0g01.png
new file mode 100644 (file)
index 0000000..1d72242
Binary files /dev/null and b/extra/images/testing/png/suite/basn0g01.png differ
diff --git a/extra/images/testing/png/suite/basn0g02.png b/extra/images/testing/png/suite/basn0g02.png
new file mode 100644 (file)
index 0000000..5083324
Binary files /dev/null and b/extra/images/testing/png/suite/basn0g02.png differ
diff --git a/extra/images/testing/png/suite/basn0g04.png b/extra/images/testing/png/suite/basn0g04.png
new file mode 100644 (file)
index 0000000..0bf3687
Binary files /dev/null and b/extra/images/testing/png/suite/basn0g04.png differ
diff --git a/extra/images/testing/png/suite/basn0g08.png b/extra/images/testing/png/suite/basn0g08.png
new file mode 100644 (file)
index 0000000..23c8237
Binary files /dev/null and b/extra/images/testing/png/suite/basn0g08.png differ
diff --git a/extra/images/testing/png/suite/basn0g16.png b/extra/images/testing/png/suite/basn0g16.png
new file mode 100644 (file)
index 0000000..e7c82f7
Binary files /dev/null and b/extra/images/testing/png/suite/basn0g16.png differ
diff --git a/extra/images/testing/png/suite/basn2c08.png b/extra/images/testing/png/suite/basn2c08.png
new file mode 100644 (file)
index 0000000..db5ad15
Binary files /dev/null and b/extra/images/testing/png/suite/basn2c08.png differ
diff --git a/extra/images/testing/png/suite/basn2c16.png b/extra/images/testing/png/suite/basn2c16.png
new file mode 100644 (file)
index 0000000..50c1cb9
Binary files /dev/null and b/extra/images/testing/png/suite/basn2c16.png differ
diff --git a/extra/images/testing/png/suite/basn3p01.png b/extra/images/testing/png/suite/basn3p01.png
new file mode 100644 (file)
index 0000000..b145c2b
Binary files /dev/null and b/extra/images/testing/png/suite/basn3p01.png differ
diff --git a/extra/images/testing/png/suite/basn3p02.png b/extra/images/testing/png/suite/basn3p02.png
new file mode 100644 (file)
index 0000000..8985b3d
Binary files /dev/null and b/extra/images/testing/png/suite/basn3p02.png differ
diff --git a/extra/images/testing/png/suite/basn3p04.png b/extra/images/testing/png/suite/basn3p04.png
new file mode 100644 (file)
index 0000000..0fbf9e8
Binary files /dev/null and b/extra/images/testing/png/suite/basn3p04.png differ
diff --git a/extra/images/testing/png/suite/basn3p08.png b/extra/images/testing/png/suite/basn3p08.png
new file mode 100644 (file)
index 0000000..0ddad07
Binary files /dev/null and b/extra/images/testing/png/suite/basn3p08.png differ
diff --git a/extra/images/testing/png/suite/basn4a08.png b/extra/images/testing/png/suite/basn4a08.png
new file mode 100644 (file)
index 0000000..3e13052
Binary files /dev/null and b/extra/images/testing/png/suite/basn4a08.png differ
diff --git a/extra/images/testing/png/suite/basn4a16.png b/extra/images/testing/png/suite/basn4a16.png
new file mode 100644 (file)
index 0000000..8243644
Binary files /dev/null and b/extra/images/testing/png/suite/basn4a16.png differ
diff --git a/extra/images/testing/png/suite/basn6a08.png b/extra/images/testing/png/suite/basn6a08.png
new file mode 100644 (file)
index 0000000..e608738
Binary files /dev/null and b/extra/images/testing/png/suite/basn6a08.png differ
diff --git a/extra/images/testing/png/suite/basn6a16.png b/extra/images/testing/png/suite/basn6a16.png
new file mode 100644 (file)
index 0000000..984a995
Binary files /dev/null and b/extra/images/testing/png/suite/basn6a16.png differ
diff --git a/extra/images/testing/png/suite/bgai4a08.png b/extra/images/testing/png/suite/bgai4a08.png
new file mode 100644 (file)
index 0000000..398132b
Binary files /dev/null and b/extra/images/testing/png/suite/bgai4a08.png differ
diff --git a/extra/images/testing/png/suite/bgai4a16.png b/extra/images/testing/png/suite/bgai4a16.png
new file mode 100644 (file)
index 0000000..51192e7
Binary files /dev/null and b/extra/images/testing/png/suite/bgai4a16.png differ
diff --git a/extra/images/testing/png/suite/bgan6a08.png b/extra/images/testing/png/suite/bgan6a08.png
new file mode 100644 (file)
index 0000000..e608738
Binary files /dev/null and b/extra/images/testing/png/suite/bgan6a08.png differ
diff --git a/extra/images/testing/png/suite/bgan6a16.png b/extra/images/testing/png/suite/bgan6a16.png
new file mode 100644 (file)
index 0000000..984a995
Binary files /dev/null and b/extra/images/testing/png/suite/bgan6a16.png differ
diff --git a/extra/images/testing/png/suite/bgbn4a08.png b/extra/images/testing/png/suite/bgbn4a08.png
new file mode 100644 (file)
index 0000000..7cbefc3
Binary files /dev/null and b/extra/images/testing/png/suite/bgbn4a08.png differ
diff --git a/extra/images/testing/png/suite/bggn4a16.png b/extra/images/testing/png/suite/bggn4a16.png
new file mode 100644 (file)
index 0000000..13fd85b
Binary files /dev/null and b/extra/images/testing/png/suite/bggn4a16.png differ
diff --git a/extra/images/testing/png/suite/bgwn6a08.png b/extra/images/testing/png/suite/bgwn6a08.png
new file mode 100644 (file)
index 0000000..a67ff20
Binary files /dev/null and b/extra/images/testing/png/suite/bgwn6a08.png differ
diff --git a/extra/images/testing/png/suite/bgyn6a16.png b/extra/images/testing/png/suite/bgyn6a16.png
new file mode 100644 (file)
index 0000000..ae3e9be
Binary files /dev/null and b/extra/images/testing/png/suite/bgyn6a16.png differ
diff --git a/extra/images/testing/png/suite/ccwn2c08.png b/extra/images/testing/png/suite/ccwn2c08.png
new file mode 100644 (file)
index 0000000..47c2481
Binary files /dev/null and b/extra/images/testing/png/suite/ccwn2c08.png differ
diff --git a/extra/images/testing/png/suite/ccwn3p08.png b/extra/images/testing/png/suite/ccwn3p08.png
new file mode 100644 (file)
index 0000000..8bb2c10
Binary files /dev/null and b/extra/images/testing/png/suite/ccwn3p08.png differ
diff --git a/extra/images/testing/png/suite/cdfn2c08.png b/extra/images/testing/png/suite/cdfn2c08.png
new file mode 100644 (file)
index 0000000..559e526
Binary files /dev/null and b/extra/images/testing/png/suite/cdfn2c08.png differ
diff --git a/extra/images/testing/png/suite/cdhn2c08.png b/extra/images/testing/png/suite/cdhn2c08.png
new file mode 100644 (file)
index 0000000..3e07e8e
Binary files /dev/null and b/extra/images/testing/png/suite/cdhn2c08.png differ
diff --git a/extra/images/testing/png/suite/cdsn2c08.png b/extra/images/testing/png/suite/cdsn2c08.png
new file mode 100644 (file)
index 0000000..076c32c
Binary files /dev/null and b/extra/images/testing/png/suite/cdsn2c08.png differ
diff --git a/extra/images/testing/png/suite/cdun2c08.png b/extra/images/testing/png/suite/cdun2c08.png
new file mode 100644 (file)
index 0000000..846033b
Binary files /dev/null and b/extra/images/testing/png/suite/cdun2c08.png differ
diff --git a/extra/images/testing/png/suite/ch1n3p04.png b/extra/images/testing/png/suite/ch1n3p04.png
new file mode 100644 (file)
index 0000000..17cd12d
Binary files /dev/null and b/extra/images/testing/png/suite/ch1n3p04.png differ
diff --git a/extra/images/testing/png/suite/ch2n3p08.png b/extra/images/testing/png/suite/ch2n3p08.png
new file mode 100644 (file)
index 0000000..25c1798
Binary files /dev/null and b/extra/images/testing/png/suite/ch2n3p08.png differ
diff --git a/extra/images/testing/png/suite/cm0n0g04.png b/extra/images/testing/png/suite/cm0n0g04.png
new file mode 100644 (file)
index 0000000..9fba5db
Binary files /dev/null and b/extra/images/testing/png/suite/cm0n0g04.png differ
diff --git a/extra/images/testing/png/suite/cm7n0g04.png b/extra/images/testing/png/suite/cm7n0g04.png
new file mode 100644 (file)
index 0000000..f7dc46e
Binary files /dev/null and b/extra/images/testing/png/suite/cm7n0g04.png differ
diff --git a/extra/images/testing/png/suite/cm9n0g04.png b/extra/images/testing/png/suite/cm9n0g04.png
new file mode 100644 (file)
index 0000000..dd70911
Binary files /dev/null and b/extra/images/testing/png/suite/cm9n0g04.png differ
diff --git a/extra/images/testing/png/suite/cs3n2c16.png b/extra/images/testing/png/suite/cs3n2c16.png
new file mode 100644 (file)
index 0000000..bf5fd20
Binary files /dev/null and b/extra/images/testing/png/suite/cs3n2c16.png differ
diff --git a/extra/images/testing/png/suite/cs3n3p08.png b/extra/images/testing/png/suite/cs3n3p08.png
new file mode 100644 (file)
index 0000000..f4a6623
Binary files /dev/null and b/extra/images/testing/png/suite/cs3n3p08.png differ
diff --git a/extra/images/testing/png/suite/cs5n2c08.png b/extra/images/testing/png/suite/cs5n2c08.png
new file mode 100644 (file)
index 0000000..40f947c
Binary files /dev/null and b/extra/images/testing/png/suite/cs5n2c08.png differ
diff --git a/extra/images/testing/png/suite/cs5n3p08.png b/extra/images/testing/png/suite/cs5n3p08.png
new file mode 100644 (file)
index 0000000..dfd6e6e
Binary files /dev/null and b/extra/images/testing/png/suite/cs5n3p08.png differ
diff --git a/extra/images/testing/png/suite/cs8n2c08.png b/extra/images/testing/png/suite/cs8n2c08.png
new file mode 100644 (file)
index 0000000..8e01d32
Binary files /dev/null and b/extra/images/testing/png/suite/cs8n2c08.png differ
diff --git a/extra/images/testing/png/suite/cs8n3p08.png b/extra/images/testing/png/suite/cs8n3p08.png
new file mode 100644 (file)
index 0000000..a44066e
Binary files /dev/null and b/extra/images/testing/png/suite/cs8n3p08.png differ
diff --git a/extra/images/testing/png/suite/ct0n0g04.png b/extra/images/testing/png/suite/ct0n0g04.png
new file mode 100644 (file)
index 0000000..40d1e06
Binary files /dev/null and b/extra/images/testing/png/suite/ct0n0g04.png differ
diff --git a/extra/images/testing/png/suite/ct1n0g04.png b/extra/images/testing/png/suite/ct1n0g04.png
new file mode 100644 (file)
index 0000000..3ba110a
Binary files /dev/null and b/extra/images/testing/png/suite/ct1n0g04.png differ
diff --git a/extra/images/testing/png/suite/ctzn0g04.png b/extra/images/testing/png/suite/ctzn0g04.png
new file mode 100644 (file)
index 0000000..b4401c9
Binary files /dev/null and b/extra/images/testing/png/suite/ctzn0g04.png differ
diff --git a/extra/images/testing/png/suite/f00n0g08.png b/extra/images/testing/png/suite/f00n0g08.png
new file mode 100644 (file)
index 0000000..45a0075
Binary files /dev/null and b/extra/images/testing/png/suite/f00n0g08.png differ
diff --git a/extra/images/testing/png/suite/f00n2c08.png b/extra/images/testing/png/suite/f00n2c08.png
new file mode 100644 (file)
index 0000000..d6a1fff
Binary files /dev/null and b/extra/images/testing/png/suite/f00n2c08.png differ
diff --git a/extra/images/testing/png/suite/f01n0g08.png b/extra/images/testing/png/suite/f01n0g08.png
new file mode 100644 (file)
index 0000000..4a1107b
Binary files /dev/null and b/extra/images/testing/png/suite/f01n0g08.png differ
diff --git a/extra/images/testing/png/suite/f01n2c08.png b/extra/images/testing/png/suite/f01n2c08.png
new file mode 100644 (file)
index 0000000..26fee95
Binary files /dev/null and b/extra/images/testing/png/suite/f01n2c08.png differ
diff --git a/extra/images/testing/png/suite/f02n0g08.png b/extra/images/testing/png/suite/f02n0g08.png
new file mode 100644 (file)
index 0000000..bfe410c
Binary files /dev/null and b/extra/images/testing/png/suite/f02n0g08.png differ
diff --git a/extra/images/testing/png/suite/f02n2c08.png b/extra/images/testing/png/suite/f02n2c08.png
new file mode 100644 (file)
index 0000000..e590f12
Binary files /dev/null and b/extra/images/testing/png/suite/f02n2c08.png differ
diff --git a/extra/images/testing/png/suite/f03n0g08.png b/extra/images/testing/png/suite/f03n0g08.png
new file mode 100644 (file)
index 0000000..ed01e29
Binary files /dev/null and b/extra/images/testing/png/suite/f03n0g08.png differ
diff --git a/extra/images/testing/png/suite/f03n2c08.png b/extra/images/testing/png/suite/f03n2c08.png
new file mode 100644 (file)
index 0000000..7581150
Binary files /dev/null and b/extra/images/testing/png/suite/f03n2c08.png differ
diff --git a/extra/images/testing/png/suite/f04n0g08.png b/extra/images/testing/png/suite/f04n0g08.png
new file mode 100644 (file)
index 0000000..663fdae
Binary files /dev/null and b/extra/images/testing/png/suite/f04n0g08.png differ
diff --git a/extra/images/testing/png/suite/f04n2c08.png b/extra/images/testing/png/suite/f04n2c08.png
new file mode 100644 (file)
index 0000000..3c8b511
Binary files /dev/null and b/extra/images/testing/png/suite/f04n2c08.png differ
diff --git a/extra/images/testing/png/suite/g03n0g16.png b/extra/images/testing/png/suite/g03n0g16.png
new file mode 100644 (file)
index 0000000..41083ca
Binary files /dev/null and b/extra/images/testing/png/suite/g03n0g16.png differ
diff --git a/extra/images/testing/png/suite/g03n2c08.png b/extra/images/testing/png/suite/g03n2c08.png
new file mode 100644 (file)
index 0000000..a9354db
Binary files /dev/null and b/extra/images/testing/png/suite/g03n2c08.png differ
diff --git a/extra/images/testing/png/suite/g03n3p04.png b/extra/images/testing/png/suite/g03n3p04.png
new file mode 100644 (file)
index 0000000..60396c9
Binary files /dev/null and b/extra/images/testing/png/suite/g03n3p04.png differ
diff --git a/extra/images/testing/png/suite/g04n0g16.png b/extra/images/testing/png/suite/g04n0g16.png
new file mode 100644 (file)
index 0000000..32395b7
Binary files /dev/null and b/extra/images/testing/png/suite/g04n0g16.png differ
diff --git a/extra/images/testing/png/suite/g04n2c08.png b/extra/images/testing/png/suite/g04n2c08.png
new file mode 100644 (file)
index 0000000..a652b0c
Binary files /dev/null and b/extra/images/testing/png/suite/g04n2c08.png differ
diff --git a/extra/images/testing/png/suite/g04n3p04.png b/extra/images/testing/png/suite/g04n3p04.png
new file mode 100644 (file)
index 0000000..5661cc3
Binary files /dev/null and b/extra/images/testing/png/suite/g04n3p04.png differ
diff --git a/extra/images/testing/png/suite/g05n0g16.png b/extra/images/testing/png/suite/g05n0g16.png
new file mode 100644 (file)
index 0000000..70b37f0
Binary files /dev/null and b/extra/images/testing/png/suite/g05n0g16.png differ
diff --git a/extra/images/testing/png/suite/g05n2c08.png b/extra/images/testing/png/suite/g05n2c08.png
new file mode 100644 (file)
index 0000000..932c136
Binary files /dev/null and b/extra/images/testing/png/suite/g05n2c08.png differ
diff --git a/extra/images/testing/png/suite/g05n3p04.png b/extra/images/testing/png/suite/g05n3p04.png
new file mode 100644 (file)
index 0000000..9619930
Binary files /dev/null and b/extra/images/testing/png/suite/g05n3p04.png differ
diff --git a/extra/images/testing/png/suite/g07n0g16.png b/extra/images/testing/png/suite/g07n0g16.png
new file mode 100644 (file)
index 0000000..d6a47c2
Binary files /dev/null and b/extra/images/testing/png/suite/g07n0g16.png differ
diff --git a/extra/images/testing/png/suite/g07n2c08.png b/extra/images/testing/png/suite/g07n2c08.png
new file mode 100644 (file)
index 0000000..5973464
Binary files /dev/null and b/extra/images/testing/png/suite/g07n2c08.png differ
diff --git a/extra/images/testing/png/suite/g07n3p04.png b/extra/images/testing/png/suite/g07n3p04.png
new file mode 100644 (file)
index 0000000..c73fb61
Binary files /dev/null and b/extra/images/testing/png/suite/g07n3p04.png differ
diff --git a/extra/images/testing/png/suite/g10n0g16.png b/extra/images/testing/png/suite/g10n0g16.png
new file mode 100644 (file)
index 0000000..85f2c95
Binary files /dev/null and b/extra/images/testing/png/suite/g10n0g16.png differ
diff --git a/extra/images/testing/png/suite/g10n2c08.png b/extra/images/testing/png/suite/g10n2c08.png
new file mode 100644 (file)
index 0000000..b303997
Binary files /dev/null and b/extra/images/testing/png/suite/g10n2c08.png differ
diff --git a/extra/images/testing/png/suite/g10n3p04.png b/extra/images/testing/png/suite/g10n3p04.png
new file mode 100644 (file)
index 0000000..1b6a6be
Binary files /dev/null and b/extra/images/testing/png/suite/g10n3p04.png differ
diff --git a/extra/images/testing/png/suite/g25n0g16.png b/extra/images/testing/png/suite/g25n0g16.png
new file mode 100644 (file)
index 0000000..a9f6787
Binary files /dev/null and b/extra/images/testing/png/suite/g25n0g16.png differ
diff --git a/extra/images/testing/png/suite/g25n2c08.png b/extra/images/testing/png/suite/g25n2c08.png
new file mode 100644 (file)
index 0000000..03f505a
Binary files /dev/null and b/extra/images/testing/png/suite/g25n2c08.png differ
diff --git a/extra/images/testing/png/suite/g25n3p04.png b/extra/images/testing/png/suite/g25n3p04.png
new file mode 100644 (file)
index 0000000..4f943c6
Binary files /dev/null and b/extra/images/testing/png/suite/g25n3p04.png differ
diff --git a/extra/images/testing/png/suite/oi1n0g16.png b/extra/images/testing/png/suite/oi1n0g16.png
new file mode 100644 (file)
index 0000000..e7c82f7
Binary files /dev/null and b/extra/images/testing/png/suite/oi1n0g16.png differ
diff --git a/extra/images/testing/png/suite/oi1n2c16.png b/extra/images/testing/png/suite/oi1n2c16.png
new file mode 100644 (file)
index 0000000..50c1cb9
Binary files /dev/null and b/extra/images/testing/png/suite/oi1n2c16.png differ
diff --git a/extra/images/testing/png/suite/oi2n0g16.png b/extra/images/testing/png/suite/oi2n0g16.png
new file mode 100644 (file)
index 0000000..14d64c5
Binary files /dev/null and b/extra/images/testing/png/suite/oi2n0g16.png differ
diff --git a/extra/images/testing/png/suite/oi2n2c16.png b/extra/images/testing/png/suite/oi2n2c16.png
new file mode 100644 (file)
index 0000000..4c2e3e3
Binary files /dev/null and b/extra/images/testing/png/suite/oi2n2c16.png differ
diff --git a/extra/images/testing/png/suite/oi4n0g16.png b/extra/images/testing/png/suite/oi4n0g16.png
new file mode 100644 (file)
index 0000000..69e73ed
Binary files /dev/null and b/extra/images/testing/png/suite/oi4n0g16.png differ
diff --git a/extra/images/testing/png/suite/oi4n2c16.png b/extra/images/testing/png/suite/oi4n2c16.png
new file mode 100644 (file)
index 0000000..93691e3
Binary files /dev/null and b/extra/images/testing/png/suite/oi4n2c16.png differ
diff --git a/extra/images/testing/png/suite/oi9n0g16.png b/extra/images/testing/png/suite/oi9n0g16.png
new file mode 100644 (file)
index 0000000..9248413
Binary files /dev/null and b/extra/images/testing/png/suite/oi9n0g16.png differ
diff --git a/extra/images/testing/png/suite/oi9n2c16.png b/extra/images/testing/png/suite/oi9n2c16.png
new file mode 100644 (file)
index 0000000..f0512e4
Binary files /dev/null and b/extra/images/testing/png/suite/oi9n2c16.png differ
diff --git a/extra/images/testing/png/suite/pngsuite.doc b/extra/images/testing/png/suite/pngsuite.doc
new file mode 100644 (file)
index 0000000..7da918b
--- /dev/null
@@ -0,0 +1,520 @@
+        PNGSUITE
+----------------
+
+        testset for PNG-(de)coders
+        created by Willem van Schaik
+------------------------------------
+
+This is a collection of graphics images created to test the png applications
+like viewers, converters and editors. All (as far as that is possible)
+formats supported by the PNG standard are represented.
+
+
+1.      INTRODUCTION
+--------------------
+
+1.1     PNG capabilities
+------------------------
+
+Supported color-types are:
+
+        -   grayscale
+        -   grayscale + alpha-channel
+        -   color palettes
+        -   rgb
+        -   rgb + alpha-channel
+
+Allowed bitdepths are depending on the color-type, but are in the range
+of 1-bit (grayscale, which is b&w) upto 16-bits.
+
+Special features are:
+
+        -   interlacing (Adam-7)
+        -   gamma-support
+        -   transparency (a poor-man's alpha solution)
+
+
+1.2     File naming
+-------------------
+
+Where possible, the testfiles are 32x32 bits icons. This results in a still
+reasonable size of the suite even with a large number of tests. The name
+of each test-file reflects thetype in the following way:
+
+        g04i2c08.png
+        || |||+---- bit-depth
+        || ||+----- color-type (descriptive)
+        || |+------ color-type (numerical)
+        || +------- interlaced or non-interlaced
+        |+--------- parameter of test (in this case gamma-value)
+        +---------- test feature (in this case gamma)
+
+
+1.3     PNG formats
+-------------------
+
+color-type:
+        0g          -   grayscale
+        2c          -   rgb color
+        3p          -   paletted
+        4a          -   grayscale + alpha channel
+        6a          -   rgb color + alpha channel
+
+bit-depth:
+        01          -   with color-type 0, 3
+        02          -   with color-type 0, 3
+        04          -   with color-type 0, 3
+        08          -   with color-type 0, 2, 3, 4, 6
+        16          -   with color-type 0, 2, 4, 6
+
+interlacing:
+        n           -   non-interlaced
+        i           -   interlaced
+
+
+2.      THE TESTS
+-----------------
+
+2.1     Sizes
+-------------
+
+These tests are there to check if your software handles pictures well, with
+picture sizes that are not a multiple of 8. This is particularly important
+with Adam-7 type interlacing. In the same way these tests check if pictures
+size 1x1 and similar are ok.
+
+        s01         -   1x1 pixel picture
+        s02         -   2x2 pixel picture
+        s03         -   3x3 pixel picture
+        s04         -   4x4 pixel picture
+        s05         -   5x5 pixel picture
+        s06         -   6x6 pixel picture
+        s07         -   7x7 pixel picture
+        s08         -   8x8 pixel picture
+        s09         -   9x9 pixel picture
+        s32         -   32x32 pixel picture
+        s33         -   33x33 pixel picture
+        s34         -   34x34 pixel picture
+        s35         -   35x35 pixel picture
+        s36         -   36x36 pixel picture
+        s37         -   37x37 pixel picture
+        s38         -   38x38 pixel picture
+        s39         -   39x39 pixel picture
+        s40         -   40x40 pixel picture
+
+
+2.2     Background
+------------------
+
+When the PNG file contains a background chunck, this should be used for
+pictures with alpha-channel or pictures with a transparency chunck. For
+pictures without this background-chunk, but with alpha, this testset
+assumes a black background.
+
+For the images in this test, the left-side should be 100% the background
+color, where moving to the right the color should gradually become the
+image pattern.
+
+        bga         -   alpha + no background
+        bgw         -   alpha + white background
+        bgg         -   alpha + gray background
+        bgb         -   alpha + black background
+        bgy         -   alpha + yellow background
+
+
+2.3     Transparency
+--------------------
+
+Transparency should be used together with a background chunk. To test the
+combination of the two the latter 4 tests are there. How to handle pictures
+with transparancy, but without a background, opinions can differ. Here we
+use black, but especially in the case of paletted images, the normal color
+would maybe even be better.
+
+        tp0         -   not transparent for reference
+        tp1         -   transparent, but no background chunk
+        tbw         -   transparent + white background
+        tbg         -   transparent + gray background
+        tbb         -   transparent + black background
+        tby         -   transparent + yellow background
+
+
+2.4     Gamma
+-------------
+
+To test if your viewer handles gamma-correction, 6 testfiles are available.
+They contain corrected color-ramps and a corresponding gamma-chunk with the
+file-gamma value. These are created in such a way that when the viewer does
+the gamma correction right, all 6 should be displayed identical.
+
+If they are different, probably the gamma correction is omitted. In that
+case, have a look at the two right coloumns in the 6 pictures. The image
+where those two look the same (when looked from far) reflects the gamma of
+your system. However, because of the limited size of the image, you should
+do more elaborate tests to determine your display gamma.
+
+        g03         -   file-gamma = 0.35, for display with gamma = 2.8
+        g04         -   file-gamma = 0.45, for display with gamma = 2.2 (PC)
+        g05         -   file-gamma = 0.55, for display with gamma = 1.8 (Mac)
+        g07         -   file-gamma = 0.70, for display with gamma = 1.4
+        g10         -   file-gamma = 1.00, for display with gamma = 1.0 (NeXT)
+        g25         -   file-gamma = 2.50, for display with gamma = 0.4
+
+
+2.5     Filtering
+-----------------
+
+PNG uses file-filtering, for optimal compression. Normally the type is of
+filtering is adjusted to the contents of the picture, but here each file
+has the same picture, with a different filtering.
+
+        f0          -   no filtering
+        f1          -   sub filtering
+        f2          -   up filtering
+        f3          -   average filtering
+        f4          -   paeth filtering
+
+
+2.6     Additional palettes
+---------------------------
+
+Besides the normal use of paletted images, palette chunks can in combination
+with true-color (and other) images also be used to select color lookup-tables
+when the video system is of limited capabilities. The suggested palette chunk
+is specially created for this purpose.
+
+        pp          -   normal palette chunk
+        ps          -   suggested palette chunk
+
+
+2.7     Ancillary chunks (under construction)
+------------------------
+
+To test the correct decoding of ancillary chunks, these test-files contain
+one or more examples of these chunkcs. Depending on the type of chunk, a
+number of typical values are selected to test. Unluckily, the testset can
+not contain all combinations, because that would be an endless set.
+
+The significant bits are used in files with the next higher bit-depth. They
+indicate howmany bits are valid.
+
+        cs3         -   3 significant bits
+        cs5         -   5 significant bits
+        cs8         -   8 significant bits (reference)
+        cs3         -   13 significant bits
+
+For the physical pixel dimensions, the result of each decoding should be
+a sqare picture. The first (cdf) image is an example of flat (horizontal)
+pixels, where the pHYS chunk (x is 1 per unit, y = 4 per unit) must take
+care of the correction. The second is just the other way round. The last
+example uses the unit specifier, for 1000 pixels per meter. This should
+result in a picture of 3.2 cm square.
+
+        cdf         -   physical pixel dimensions, 8x32 flat pixels
+        cdh         -   physical pixel dimensions, 32x8 high pixels
+        cds         -   physical pixel dimensions, 8x8 square pixels
+        cdu         -   physical pixel dimensions, with unit-specifier
+
+        ccw         -   primary chromaticities and white point
+
+        ch1         -   histogram 15 colors
+        ch2         -   histogram 256 colors
+
+        cm7         -   modification time, 01-jan-1970
+        cm9         -   modification time, 31-dec-1999
+        cm0         -   modification time, 01-jan-2000
+
+In the textual chunk, a number of the standard, and some non-standard
+text items are included.
+
+        ct0         -   no textual data
+        ct1         -   with textual data
+        ctz         -   with compressed textual data
+
+
+2.8     Chunk ordering (still under construction)
+----------------------
+
+These testfiles will test the obligatory ordering relations between various
+chunk types (not yet) as well as the number of data chunks used for the image.
+
+        oi1         -   mother image with 1 idat-chunk
+        oi2         -   image with 2 idat-chunks
+        oi4         -   image with 4 unequal sized idat-chunks
+        oi9         -   all idat-chunks of length one
+
+
+2.9     Compression level
+-------------------------
+
+Here you will find a set of images compressed by zlib, ranging from level 0 
+for no compression at maximum speed upto level 9 for maximum compression.
+
+        z00         -   zlib compression level 0 - none
+        z03         -   zlib compression level 3
+        z06         -   zlib compression level 6 - default
+        z09         -   zlib compression level 9 - maximum
+
+
+2.10     Corrupted files (under construction)
+-----------------------
+
+All these files are illegal. When decoding they should generate appropriate
+error-messages.
+
+        x00         -   empty IDAT chunk
+        xcr         -   added cr bytes
+        xlf         -   added lf bytes
+        xc0         -   color type 0
+        xc9         -   color type 9
+        xd0         -   bit-depth 0
+        xd3         -   bit-depth 3
+        xd9         -   bit-depth 99
+        xcs         -   incorrect IDAT checksum
+
+
+3.      TEST FILES
+------------------
+
+For each of the tests listed above, one or more test-files are created. A
+selection is made (for each test) for the color-type and bitdepth to be used
+for the tests. Further for a number of tests, both a non-interlaced as well
+as an interlaced version is available.
+
+
+3.1     Basic format test files (non-interlaced)
+------------------------------------------------
+
+        basn0g01    -   black & white
+        basn0g02    -   2 bit (4 level) grayscale
+        basn0g04    -   4 bit (16 level) grayscale
+        basn0g08    -   8 bit (256 level) grayscale
+        basn0g16    -   16 bit (64k level) grayscale
+        basn2c08    -   3x8 bits rgb color
+        basn2c16    -   3x16 bits rgb color
+        basn3p01    -   1 bit (2 color) paletted
+        basn3p02    -   2 bit (4 color) paletted
+        basn3p04    -   4 bit (16 color) paletted
+        basn3p08    -   8 bit (256 color) paletted
+        basn4a08    -   8 bit grayscale + 8 bit alpha-channel
+        basn4a16    -   16 bit grayscale + 16 bit alpha-channel
+        basn6a08    -   3x8 bits rgb color + 8 bit alpha-channel
+        basn6a16    -   3x16 bits rgb color + 16 bit alpha-channel
+
+
+3.2     Basic format test files (Adam-7 interlaced)
+---------------------------------------------------
+
+        basi0g01    -   black & white
+        basi0g02    -   2 bit (4 level) grayscale
+        basi0g04    -   4 bit (16 level) grayscale
+        basi0g08    -   8 bit (256 level) grayscale
+        basi0g16    -   16 bit (64k level) grayscale
+        basi2c08    -   3x8 bits rgb color
+        basi2c16    -   3x16 bits rgb color
+        basi3p01    -   1 bit (2 color) paletted
+        basi3p02    -   2 bit (4 color) paletted
+        basi3p04    -   4 bit (16 color) paletted
+        basi3p08    -   8 bit (256 color) paletted
+        basi4a08    -   8 bit grayscale + 8 bit alpha-channel
+        basi4a16    -   16 bit grayscale + 16 bit alpha-channel
+        basi6a08    -   3x8 bits rgb color + 8 bit alpha-channel
+        basi6a16    -   3x16 bits rgb color + 16 bit alpha-channel
+
+
+3.3     Sizes test files
+-----------------------
+
+        s01n3p01    -   1x1 paletted file, no interlacing
+        s02n3p01    -   2x2 paletted file, no interlacing
+        s03n3p01    -   3x3 paletted file, no interlacing
+        s04n3p01    -   4x4 paletted file, no interlacing
+        s05n3p02    -   5x5 paletted file, no interlacing
+        s06n3p02    -   6x6 paletted file, no interlacing
+        s07n3p02    -   7x7 paletted file, no interlacing
+        s08n3p02    -   8x8 paletted file, no interlacing
+        s09n3p02    -   9x9 paletted file, no interlacing
+        s32n3p04    -   32x32 paletted file, no interlacing
+        s33n3p04    -   33x33 paletted file, no interlacing
+        s34n3p04    -   34x34 paletted file, no interlacing
+        s35n3p04    -   35x35 paletted file, no interlacing
+        s36n3p04    -   36x36 paletted file, no interlacing
+        s37n3p04    -   37x37 paletted file, no interlacing
+        s38n3p04    -   38x38 paletted file, no interlacing
+        s39n3p04    -   39x39 paletted file, no interlacing
+        s40n3p04    -   40x40 paletted file, no interlacing
+
+        s01i3p01    -   1x1 paletted file, interlaced
+        s02i3p01    -   2x2 paletted file, interlaced
+        s03i3p01    -   3x3 paletted file, interlaced
+        s04i3p01    -   4x4 paletted file, interlaced
+        s05i3p02    -   5x5 paletted file, interlaced
+        s06i3p02    -   6x6 paletted file, interlaced
+        s07i3p02    -   7x7 paletted file, interlaced
+        s08i3p02    -   8x8 paletted file, interlaced
+        s09i3p02    -   9x9 paletted file, interlaced
+        s32i3p04    -   32x32 paletted file, interlaced
+        s33i3p04    -   33x33 paletted file, interlaced
+        s34i3p04    -   34x34 paletted file, interlaced
+        s35i3p04    -   35x35 paletted file, interlaced
+        s36i3p04    -   36x36 paletted file, interlaced
+        s37i3p04    -   37x37 paletted file, interlaced
+        s38i3p04    -   38x38 paletted file, interlaced
+        s39i3p04    -   39x39 paletted file, interlaced
+        s40i3p04    -   40x40 paletted file, interlaced
+
+
+3.4     Background test files (with alpha)
+------------------------------------------
+
+        bgai4a08    -   8 bit grayscale, alpha, no background chunk, interlaced
+        bgai4a16    -   16 bit grayscale, alpha, no background chunk, interlaced
+        bgan6a08    -   3x8 bits rgb color, alpha, no background chunk
+        bgan6a16    -   3x16 bits rgb color, alpha, no background chunk
+
+        bgbn4a08    -   8 bit grayscale, alpha, black background chunk
+        bggn4a16    -   16 bit grayscale, alpha, gray background chunk
+        bgwn6a08    -   3x8 bits rgb color, alpha, white background chunk
+        bgyn6a16    -   3x16 bits rgb color, alpha, yellow background chunk
+
+
+3.5     Transparency (and background) test files
+------------------------------------------------
+
+        tp0n1g08    -   not transparent for reference (logo on gray)
+        tbbn1g04    -   transparent, black background chunk
+        tbwn1g16    -   transparent, white background chunk
+        tp0n2c08    -   not transparent for reference (logo on gray)
+        tbrn2c08    -   transparent, red background chunk
+        tbgn2c16    -   transparent, green background chunk
+        tbbn2c16    -   transparent, blue background chunk
+        tp0n3p08    -   not transparent for reference (logo on gray)
+        tp1n3p08    -   transparent, but no background chunk
+        tbbn3p08    -   transparent, black background chunk
+        tbgn3p08    -   transparent, light-gray background chunk
+        tbwn3p08    -   transparent, white background chunk
+        tbyn3p08    -   transparent, yellow background chunk
+
+
+3.6     Gamma test files
+------------------------
+
+        g03n0g16    -   grayscale, file-gamma = 0.35
+        g04n0g16    -   grayscale, file-gamma = 0.45
+        g05n0g16    -   grayscale, file-gamma = 0.55
+        g07n0g16    -   grayscale, file-gamma = 0.70
+        g10n0g16    -   grayscale, file-gamma = 1.00
+        g25n0g16    -   grayscale, file-gamma = 2.50
+        g03n2c08    -   color, file-gamma = 0.35
+        g04n2c08    -   color, file-gamma = 0.45
+        g05n2c08    -   color, file-gamma = 0.55
+        g07n2c08    -   color, file-gamma = 0.70
+        g10n2c08    -   color, file-gamma = 1.00
+        g25n2c08    -   color, file-gamma = 2.50
+        g03n3p04    -   paletted, file-gamma = 0.35
+        g04n3p04    -   paletted, file-gamma = 0.45
+        g05n3p04    -   paletted, file-gamma = 0.55
+        g07n3p04    -   paletted, file-gamma = 0.70
+        g10n3p04    -   paletted, file-gamma = 1.00
+        g25n3p04    -   paletted, file-gamma = 2.50
+
+
+3.7     Filtering test files
+----------------------------
+
+        f00n0g08    -   grayscale, no interlacing, filter-type 0
+        f01n0g08    -   grayscale, no interlacing, filter-type 1
+        f02n0g08    -   grayscale, no interlacing, filter-type 2
+        f03n0g08    -   grayscale, no interlacing, filter-type 3
+        f04n0g08    -   grayscale, no interlacing, filter-type 4
+        f00n2c08    -   color, no interlacing, filter-type 0
+        f01n2c08    -   color, no interlacing, filter-type 1
+        f02n2c08    -   color, no interlacing, filter-type 2
+        f03n2c08    -   color, no interlacing, filter-type 3
+        f04n2c08    -   color, no interlacing, filter-type 4
+
+
+3.8     Additional palette chunk test files
+-------------------------------------------
+
+        pp0n2c16    -   six-cube palette-chunk in true-color image
+        pp0n6a08    -   six-cube palette-chunk in true-color+alpha image
+        ps1n0g08    -   six-cube suggested palette (1 byte) in grayscale image
+        ps1n2c16    -   six-cube suggested palette (1 byte) in true-color image
+        ps2n0g08    -   six-cube suggested palette (2 bytes) in grayscale image
+        ps2n2c16    -   six-cube suggested palette (2 bytes) in true-color image
+
+
+3.9     Ancillary chunks test files
+-----------------------------------
+
+        cs5n2c08    -   color, 5 significant bits
+        cs8n2c08    -   color, 8 significant bits (reference)
+        cs3n2c16    -   color, 13 significant bits
+        cs3n3p08    -   paletted, 3 significant bits
+        cs5n3p08    -   paletted, 5 significant bits
+        cs8n3p08    -   paletted, 8 significant bits (reference)
+
+        cdfn2c08    -   physical pixel dimensions, 8x32 flat pixels
+        cdhn2c08    -   physical pixel dimensions, 32x8 high pixels
+        cdsn2c08    -   physical pixel dimensions, 8x8 square pixels
+        cdun2c08    -   physical pixel dimensions, 1000 pixels per 1 meter
+
+        ccwn2c08    -   chroma chunk w:0.3127,0.3290 r:0.64,0.33 g:0.30,0.60 b:0.15,0.06
+        ccwn3p08    -   chroma chunk w:0.3127,0.3290 r:0.64,0.33 g:0.30,0.60 b:0.15,0.06
+
+        ch1n3p04    -   histogram 15 colors
+        ch2n3p08    -   histogram 256 colors
+
+        cm7n0g04    -   modification time, 01-jan-1970 00:00:00
+        cm9n0g04    -   modification time, 31-dec-1999 23:59:59
+        cm0n0g04    -   modification time, 01-jan-2000 12:34:56
+
+        ct0n0g04    -   no textual data
+        ct1n0g04    -   with textual data
+        ctzn0g04    -   with compressed textual data
+
+
+
+3.10    Chunk ordering
+----------------------
+
+        oi1n0g16    -   grayscale mother image with 1 idat-chunk
+        oi2n0g16    -   grayscale image with 2 idat-chunks
+        oi4n0g16    -   grayscale image with 4 unequal sized idat-chunks
+        oi9n0g16    -   grayscale image with all idat-chunks length one
+        oi1n2c16    -   color mother image with 1 idat-chunk
+        oi2n2c16    -   color image with 2 idat-chunks
+        oi4n2c16    -   color image with 4 unequal sized idat-chunks
+        oi9n2c16    -   color image with all idat-chunks length one
+
+
+
+3.11    Compression level
+-------------------------
+
+        z00n2c08    -   color, no interlacing, compression level 0 (none)
+        z03n2c08    -   color, no interlacing, compression level 3
+        z06n2c08    -   color, no interlacing, compression level 6 (default)
+        z09n2c08    -   color, no interlacing, compression level 9 (maximum)
+
+
+
+3.12     Currupted files
+-----------------------
+
+        x00n0g01    -   empty 0x0 grayscale file
+        xcrn0g04    -   added cr bytes
+        xlfn0g04    -   added lf bytes
+        xc0n0c08    -   color type 0
+        xc9n0c08    -   color type 9
+        xd0n2c00    -   bit-depth 0
+        xd3n2c03    -   bit-depth 3
+        xd9n2c99    -   bit-depth 99
+        xcsn2c08    -   incorrect IDAT checksum
+
+
+--------
+    (c) Willem van Schaik
+        willem@schaik.com
+        Singapore, October 1996
diff --git a/extra/images/testing/png/suite/pngsuite_logo.png b/extra/images/testing/png/suite/pngsuite_logo.png
new file mode 100644 (file)
index 0000000..205460d
Binary files /dev/null and b/extra/images/testing/png/suite/pngsuite_logo.png differ
diff --git a/extra/images/testing/png/suite/pp0n2c16.png b/extra/images/testing/png/suite/pp0n2c16.png
new file mode 100644 (file)
index 0000000..8f2aad7
Binary files /dev/null and b/extra/images/testing/png/suite/pp0n2c16.png differ
diff --git a/extra/images/testing/png/suite/pp0n6a08.png b/extra/images/testing/png/suite/pp0n6a08.png
new file mode 100644 (file)
index 0000000..4ed7a30
Binary files /dev/null and b/extra/images/testing/png/suite/pp0n6a08.png differ
diff --git a/extra/images/testing/png/suite/ps1n0g08.png b/extra/images/testing/png/suite/ps1n0g08.png
new file mode 100644 (file)
index 0000000..2053df2
Binary files /dev/null and b/extra/images/testing/png/suite/ps1n0g08.png differ
diff --git a/extra/images/testing/png/suite/ps1n2c16.png b/extra/images/testing/png/suite/ps1n2c16.png
new file mode 100644 (file)
index 0000000..b03ecfc
Binary files /dev/null and b/extra/images/testing/png/suite/ps1n2c16.png differ
diff --git a/extra/images/testing/png/suite/ps2n0g08.png b/extra/images/testing/png/suite/ps2n0g08.png
new file mode 100644 (file)
index 0000000..beeab8f
Binary files /dev/null and b/extra/images/testing/png/suite/ps2n0g08.png differ
diff --git a/extra/images/testing/png/suite/ps2n2c16.png b/extra/images/testing/png/suite/ps2n2c16.png
new file mode 100644 (file)
index 0000000..c256f90
Binary files /dev/null and b/extra/images/testing/png/suite/ps2n2c16.png differ
diff --git a/extra/images/testing/png/suite/s01i3p01.png b/extra/images/testing/png/suite/s01i3p01.png
new file mode 100644 (file)
index 0000000..6c0fad1
Binary files /dev/null and b/extra/images/testing/png/suite/s01i3p01.png differ
diff --git a/extra/images/testing/png/suite/s01n3p01.png b/extra/images/testing/png/suite/s01n3p01.png
new file mode 100644 (file)
index 0000000..cb2c8c7
Binary files /dev/null and b/extra/images/testing/png/suite/s01n3p01.png differ
diff --git a/extra/images/testing/png/suite/s02i3p01.png b/extra/images/testing/png/suite/s02i3p01.png
new file mode 100644 (file)
index 0000000..2defaed
Binary files /dev/null and b/extra/images/testing/png/suite/s02i3p01.png differ
diff --git a/extra/images/testing/png/suite/s02n3p01.png b/extra/images/testing/png/suite/s02n3p01.png
new file mode 100644 (file)
index 0000000..2b1b669
Binary files /dev/null and b/extra/images/testing/png/suite/s02n3p01.png differ
diff --git a/extra/images/testing/png/suite/s03i3p01.png b/extra/images/testing/png/suite/s03i3p01.png
new file mode 100644 (file)
index 0000000..c23fdc4
Binary files /dev/null and b/extra/images/testing/png/suite/s03i3p01.png differ
diff --git a/extra/images/testing/png/suite/s03n3p01.png b/extra/images/testing/png/suite/s03n3p01.png
new file mode 100644 (file)
index 0000000..6d96ee4
Binary files /dev/null and b/extra/images/testing/png/suite/s03n3p01.png differ
diff --git a/extra/images/testing/png/suite/s04i3p01.png b/extra/images/testing/png/suite/s04i3p01.png
new file mode 100644 (file)
index 0000000..0e710c2
Binary files /dev/null and b/extra/images/testing/png/suite/s04i3p01.png differ
diff --git a/extra/images/testing/png/suite/s04n3p01.png b/extra/images/testing/png/suite/s04n3p01.png
new file mode 100644 (file)
index 0000000..956396c
Binary files /dev/null and b/extra/images/testing/png/suite/s04n3p01.png differ
diff --git a/extra/images/testing/png/suite/s05i3p02.png b/extra/images/testing/png/suite/s05i3p02.png
new file mode 100644 (file)
index 0000000..d14cbd3
Binary files /dev/null and b/extra/images/testing/png/suite/s05i3p02.png differ
diff --git a/extra/images/testing/png/suite/s05n3p02.png b/extra/images/testing/png/suite/s05n3p02.png
new file mode 100644 (file)
index 0000000..bf940f0
Binary files /dev/null and b/extra/images/testing/png/suite/s05n3p02.png differ
diff --git a/extra/images/testing/png/suite/s06i3p02.png b/extra/images/testing/png/suite/s06i3p02.png
new file mode 100644 (file)
index 0000000..456ada3
Binary files /dev/null and b/extra/images/testing/png/suite/s06i3p02.png differ
diff --git a/extra/images/testing/png/suite/s06n3p02.png b/extra/images/testing/png/suite/s06n3p02.png
new file mode 100644 (file)
index 0000000..501064d
Binary files /dev/null and b/extra/images/testing/png/suite/s06n3p02.png differ
diff --git a/extra/images/testing/png/suite/s07i3p02.png b/extra/images/testing/png/suite/s07i3p02.png
new file mode 100644 (file)
index 0000000..44b66ba
Binary files /dev/null and b/extra/images/testing/png/suite/s07i3p02.png differ
diff --git a/extra/images/testing/png/suite/s07n3p02.png b/extra/images/testing/png/suite/s07n3p02.png
new file mode 100644 (file)
index 0000000..6a58259
Binary files /dev/null and b/extra/images/testing/png/suite/s07n3p02.png differ
diff --git a/extra/images/testing/png/suite/s08i3p02.png b/extra/images/testing/png/suite/s08i3p02.png
new file mode 100644 (file)
index 0000000..acf74f3
Binary files /dev/null and b/extra/images/testing/png/suite/s08i3p02.png differ
diff --git a/extra/images/testing/png/suite/s08n3p02.png b/extra/images/testing/png/suite/s08n3p02.png
new file mode 100644 (file)
index 0000000..b7094e1
Binary files /dev/null and b/extra/images/testing/png/suite/s08n3p02.png differ
diff --git a/extra/images/testing/png/suite/s09i3p02.png b/extra/images/testing/png/suite/s09i3p02.png
new file mode 100644 (file)
index 0000000..0bfae8e
Binary files /dev/null and b/extra/images/testing/png/suite/s09i3p02.png differ
diff --git a/extra/images/testing/png/suite/s09n3p02.png b/extra/images/testing/png/suite/s09n3p02.png
new file mode 100644 (file)
index 0000000..711ab82
Binary files /dev/null and b/extra/images/testing/png/suite/s09n3p02.png differ
diff --git a/extra/images/testing/png/suite/s32i3p04.png b/extra/images/testing/png/suite/s32i3p04.png
new file mode 100644 (file)
index 0000000..0841910
Binary files /dev/null and b/extra/images/testing/png/suite/s32i3p04.png differ
diff --git a/extra/images/testing/png/suite/s32n3p04.png b/extra/images/testing/png/suite/s32n3p04.png
new file mode 100644 (file)
index 0000000..fa58e3e
Binary files /dev/null and b/extra/images/testing/png/suite/s32n3p04.png differ
diff --git a/extra/images/testing/png/suite/s33i3p04.png b/extra/images/testing/png/suite/s33i3p04.png
new file mode 100644 (file)
index 0000000..ab0dc14
Binary files /dev/null and b/extra/images/testing/png/suite/s33i3p04.png differ
diff --git a/extra/images/testing/png/suite/s33n3p04.png b/extra/images/testing/png/suite/s33n3p04.png
new file mode 100644 (file)
index 0000000..764f1a3
Binary files /dev/null and b/extra/images/testing/png/suite/s33n3p04.png differ
diff --git a/extra/images/testing/png/suite/s34i3p04.png b/extra/images/testing/png/suite/s34i3p04.png
new file mode 100644 (file)
index 0000000..bd99039
Binary files /dev/null and b/extra/images/testing/png/suite/s34i3p04.png differ
diff --git a/extra/images/testing/png/suite/s34n3p04.png b/extra/images/testing/png/suite/s34n3p04.png
new file mode 100644 (file)
index 0000000..9cbc68b
Binary files /dev/null and b/extra/images/testing/png/suite/s34n3p04.png differ
diff --git a/extra/images/testing/png/suite/s35i3p04.png b/extra/images/testing/png/suite/s35i3p04.png
new file mode 100644 (file)
index 0000000..e2a5e0a
Binary files /dev/null and b/extra/images/testing/png/suite/s35i3p04.png differ
diff --git a/extra/images/testing/png/suite/s35n3p04.png b/extra/images/testing/png/suite/s35n3p04.png
new file mode 100644 (file)
index 0000000..90b892e
Binary files /dev/null and b/extra/images/testing/png/suite/s35n3p04.png differ
diff --git a/extra/images/testing/png/suite/s36i3p04.png b/extra/images/testing/png/suite/s36i3p04.png
new file mode 100644 (file)
index 0000000..eb61b6f
Binary files /dev/null and b/extra/images/testing/png/suite/s36i3p04.png differ
diff --git a/extra/images/testing/png/suite/s36n3p04.png b/extra/images/testing/png/suite/s36n3p04.png
new file mode 100644 (file)
index 0000000..b38d179
Binary files /dev/null and b/extra/images/testing/png/suite/s36n3p04.png differ
diff --git a/extra/images/testing/png/suite/s37i3p04.png b/extra/images/testing/png/suite/s37i3p04.png
new file mode 100644 (file)
index 0000000..6e2b1e9
Binary files /dev/null and b/extra/images/testing/png/suite/s37i3p04.png differ
diff --git a/extra/images/testing/png/suite/s37n3p04.png b/extra/images/testing/png/suite/s37n3p04.png
new file mode 100644 (file)
index 0000000..4d3054d
Binary files /dev/null and b/extra/images/testing/png/suite/s37n3p04.png differ
diff --git a/extra/images/testing/png/suite/s38i3p04.png b/extra/images/testing/png/suite/s38i3p04.png
new file mode 100644 (file)
index 0000000..a0a8a14
Binary files /dev/null and b/extra/images/testing/png/suite/s38i3p04.png differ
diff --git a/extra/images/testing/png/suite/s38n3p04.png b/extra/images/testing/png/suite/s38n3p04.png
new file mode 100644 (file)
index 0000000..1233ed0
Binary files /dev/null and b/extra/images/testing/png/suite/s38n3p04.png differ
diff --git a/extra/images/testing/png/suite/s39i3p04.png b/extra/images/testing/png/suite/s39i3p04.png
new file mode 100644 (file)
index 0000000..04fee93
Binary files /dev/null and b/extra/images/testing/png/suite/s39i3p04.png differ
diff --git a/extra/images/testing/png/suite/s39n3p04.png b/extra/images/testing/png/suite/s39n3p04.png
new file mode 100644 (file)
index 0000000..c750100
Binary files /dev/null and b/extra/images/testing/png/suite/s39n3p04.png differ
diff --git a/extra/images/testing/png/suite/s40i3p04.png b/extra/images/testing/png/suite/s40i3p04.png
new file mode 100644 (file)
index 0000000..68f358b
Binary files /dev/null and b/extra/images/testing/png/suite/s40i3p04.png differ
diff --git a/extra/images/testing/png/suite/s40n3p04.png b/extra/images/testing/png/suite/s40n3p04.png
new file mode 100644 (file)
index 0000000..864b6b9
Binary files /dev/null and b/extra/images/testing/png/suite/s40n3p04.png differ
diff --git a/extra/images/testing/png/suite/tbbn1g04.png b/extra/images/testing/png/suite/tbbn1g04.png
new file mode 100644 (file)
index 0000000..fc80020
Binary files /dev/null and b/extra/images/testing/png/suite/tbbn1g04.png differ
diff --git a/extra/images/testing/png/suite/tbbn2c16.png b/extra/images/testing/png/suite/tbbn2c16.png
new file mode 100644 (file)
index 0000000..5abfbbb
Binary files /dev/null and b/extra/images/testing/png/suite/tbbn2c16.png differ
diff --git a/extra/images/testing/png/suite/tbbn3p08.png b/extra/images/testing/png/suite/tbbn3p08.png
new file mode 100644 (file)
index 0000000..4210d16
Binary files /dev/null and b/extra/images/testing/png/suite/tbbn3p08.png differ
diff --git a/extra/images/testing/png/suite/tbgn2c16.png b/extra/images/testing/png/suite/tbgn2c16.png
new file mode 100644 (file)
index 0000000..236c81d
Binary files /dev/null and b/extra/images/testing/png/suite/tbgn2c16.png differ
diff --git a/extra/images/testing/png/suite/tbgn3p08.png b/extra/images/testing/png/suite/tbgn3p08.png
new file mode 100644 (file)
index 0000000..42db232
Binary files /dev/null and b/extra/images/testing/png/suite/tbgn3p08.png differ
diff --git a/extra/images/testing/png/suite/tbrn2c08.png b/extra/images/testing/png/suite/tbrn2c08.png
new file mode 100644 (file)
index 0000000..8c21474
Binary files /dev/null and b/extra/images/testing/png/suite/tbrn2c08.png differ
diff --git a/extra/images/testing/png/suite/tbwn1g16.png b/extra/images/testing/png/suite/tbwn1g16.png
new file mode 100644 (file)
index 0000000..dba2cbb
Binary files /dev/null and b/extra/images/testing/png/suite/tbwn1g16.png differ
diff --git a/extra/images/testing/png/suite/tbwn3p08.png b/extra/images/testing/png/suite/tbwn3p08.png
new file mode 100644 (file)
index 0000000..7922135
Binary files /dev/null and b/extra/images/testing/png/suite/tbwn3p08.png differ
diff --git a/extra/images/testing/png/suite/tbyn3p08.png b/extra/images/testing/png/suite/tbyn3p08.png
new file mode 100644 (file)
index 0000000..5b2c6cb
Binary files /dev/null and b/extra/images/testing/png/suite/tbyn3p08.png differ
diff --git a/extra/images/testing/png/suite/tp0n1g08.png b/extra/images/testing/png/suite/tp0n1g08.png
new file mode 100644 (file)
index 0000000..caad31d
Binary files /dev/null and b/extra/images/testing/png/suite/tp0n1g08.png differ
diff --git a/extra/images/testing/png/suite/tp0n2c08.png b/extra/images/testing/png/suite/tp0n2c08.png
new file mode 100644 (file)
index 0000000..f26be44
Binary files /dev/null and b/extra/images/testing/png/suite/tp0n2c08.png differ
diff --git a/extra/images/testing/png/suite/tp0n3p08.png b/extra/images/testing/png/suite/tp0n3p08.png
new file mode 100644 (file)
index 0000000..4d6cf9e
Binary files /dev/null and b/extra/images/testing/png/suite/tp0n3p08.png differ
diff --git a/extra/images/testing/png/suite/tp1n3p08.png b/extra/images/testing/png/suite/tp1n3p08.png
new file mode 100644 (file)
index 0000000..6c5fd6e
Binary files /dev/null and b/extra/images/testing/png/suite/tp1n3p08.png differ
diff --git a/extra/images/testing/png/suite/x00n0g01.png b/extra/images/testing/png/suite/x00n0g01.png
new file mode 100644 (file)
index 0000000..db3a5fd
Binary files /dev/null and b/extra/images/testing/png/suite/x00n0g01.png differ
diff --git a/extra/images/testing/png/suite/xcrn0g04.png b/extra/images/testing/png/suite/xcrn0g04.png
new file mode 100644 (file)
index 0000000..5bce9f3
Binary files /dev/null and b/extra/images/testing/png/suite/xcrn0g04.png differ
diff --git a/extra/images/testing/png/suite/xlfn0g04.png b/extra/images/testing/png/suite/xlfn0g04.png
new file mode 100644 (file)
index 0000000..1fd104b
--- /dev/null
@@ -0,0 +1,13 @@
+\89PNG
+
+
+\1a
+
+
+IHDR  \ 4\93áÈ)ÈIDATx\9c]ÑÁ
+Â0\f\ 5P\1f*@\bð\b\1d¡#°
+
+#TâÈ\ 51\ 1\e0\ 2lPF`\ 3Ø F=\95\ 2\9fÄIQâ\1c*çÅuí\94`\16%qk\81
+H\9eñ\9a\88©ñ´\80m\ 2÷\7fÍ\büµàß\9f   Ñ\8d=,\14¸fìOK
+
\a Ðt\8eÀ(Èï\ 5ä\92×\1e¦íF\v;èPº\80¯¾{xpç]\ 39\87/\ap\8f*$(ì*éyìÕ\83 ×þ\1eÚéçè@÷C¼ \12 cÔq\16\9e\8bNÛU#\84)11·.\8d\81\15r\10äðf\ 3\17ä0°\81ägh(¥\81\1eÙÂEøÿ\89kIEND®B`\82
\ No newline at end of file
diff --git a/extra/images/testing/png/suite/z00n2c08.png b/extra/images/testing/png/suite/z00n2c08.png
new file mode 100644 (file)
index 0000000..7669eb8
Binary files /dev/null and b/extra/images/testing/png/suite/z00n2c08.png differ
diff --git a/extra/images/testing/png/suite/z03n2c08.png b/extra/images/testing/png/suite/z03n2c08.png
new file mode 100644 (file)
index 0000000..bfb10de
Binary files /dev/null and b/extra/images/testing/png/suite/z03n2c08.png differ
diff --git a/extra/images/testing/png/suite/z06n2c08.png b/extra/images/testing/png/suite/z06n2c08.png
new file mode 100644 (file)
index 0000000..b90ebc1
Binary files /dev/null and b/extra/images/testing/png/suite/z06n2c08.png differ
diff --git a/extra/images/testing/png/suite/z09n2c08.png b/extra/images/testing/png/suite/z09n2c08.png
new file mode 100644 (file)
index 0000000..5f191a7
Binary files /dev/null and b/extra/images/testing/png/suite/z09n2c08.png differ
diff --git a/extra/images/testing/png/z00n2c08.fig b/extra/images/testing/png/z00n2c08.fig
new file mode 100644 (file)
index 0000000..9d171e6
Binary files /dev/null and b/extra/images/testing/png/z00n2c08.fig differ
diff --git a/extra/images/testing/png/z00n2c08.png b/extra/images/testing/png/z00n2c08.png
new file mode 100644 (file)
index 0000000..7669eb8
Binary files /dev/null and b/extra/images/testing/png/z00n2c08.png differ
diff --git a/extra/images/testing/png/z03n2c08.fig b/extra/images/testing/png/z03n2c08.fig
new file mode 100644 (file)
index 0000000..9d171e6
Binary files /dev/null and b/extra/images/testing/png/z03n2c08.fig differ
diff --git a/extra/images/testing/png/z03n2c08.png b/extra/images/testing/png/z03n2c08.png
new file mode 100644 (file)
index 0000000..bfb10de
Binary files /dev/null and b/extra/images/testing/png/z03n2c08.png differ
diff --git a/extra/images/testing/png/z06n2c08.fig b/extra/images/testing/png/z06n2c08.fig
new file mode 100644 (file)
index 0000000..9d171e6
Binary files /dev/null and b/extra/images/testing/png/z06n2c08.fig differ
diff --git a/extra/images/testing/png/z06n2c08.png b/extra/images/testing/png/z06n2c08.png
new file mode 100644 (file)
index 0000000..b90ebc1
Binary files /dev/null and b/extra/images/testing/png/z06n2c08.png differ
diff --git a/extra/images/testing/png/z09n2c08.fig b/extra/images/testing/png/z09n2c08.fig
new file mode 100644 (file)
index 0000000..9d171e6
Binary files /dev/null and b/extra/images/testing/png/z09n2c08.fig differ
diff --git a/extra/images/testing/png/z09n2c08.png b/extra/images/testing/png/z09n2c08.png
new file mode 100644 (file)
index 0000000..5f191a7
Binary files /dev/null and b/extra/images/testing/png/z09n2c08.png differ
diff --git a/extra/images/testing/testing-docs.factor b/extra/images/testing/testing-docs.factor
new file mode 100644 (file)
index 0000000..6b90b63
--- /dev/null
@@ -0,0 +1,98 @@
+! Copyright (C) 2009 Keith Lazuka.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax images images.viewer kernel
+quotations strings ;
+IN: images.testing
+
+HELP: decode-test
+{ $values
+    { "path" "a pathname string" }
+}
+{ $description "Runs a unit-test on the image at " { $snippet "path" } " to test the image decoder. The image is decoded and compared against its corresponding " { $link { "images" "testing" "reference" } } "." } ;
+
+HELP: encode-test
+{ $values
+    { "path" "a pathname string" } { "image-class" object }
+}
+{ $description "Runs a unit-test on the image at " { $snippet "path" } " to test the image encoder. The image is decoded, encoded, and then decoded again to verify that the final decoded output matches the original decoded output. Before comparison for equality, the images are normalized in order to accomodate differences in representation between the two potential encoders." }
+{ $warning "This test assumes that the image decoder is working correctly. If the image fails both the " { $link decode-test } " and the " { $link encode-test } ", then you should first debug the decoder. Once the decoder is working correctly, proceed with testing the encoder." } ;
+
+HELP: images.
+{ $values
+    { "dirpath" "a pathname string" } { "extension" string }
+}
+{ $description "Renders each image at " { $snippet "dirpath" } " directly to the Listener tool." } ;
+{ images. image. } related-words
+
+HELP: load-reference-image
+{ $values
+    { "path" "a pathname string" }
+    { "image" image }
+}
+{ $description "Loads the " { $link { "images" "testing" "reference" } } " that corresponds to the original image at " { $snippet "path" } " into memory."  } ;
+
+HELP: ls
+{ $values
+    { "dirpath" "a pathname string" } { "extension" object }
+}
+{ $description "Prints out the name of each file surrounded in double quotes so that you can easily copy and paste into your unit test." } ;
+
+HELP: save-all-as-reference-images
+{ $values
+    { "dirpath" "a pathname string" } { "extension" object }
+}
+{ $description "Saves a " { $link { "images" "testing" "reference" } } " for each image in " { $snippet "dirpath" } " with file extension " { $snippet "extension" } "." }
+{ $warning "You should only call this word after you have manually verified that every image in " { $snippet "dirpath" } " decodes and renders correctly!" } ;
+
+HELP: save-as-reference-image
+{ $values
+    { "path" "a pathname string" }
+}
+{ $description "Saves a " { $link { "images" "testing" "reference" } } " for the image at " { $snippet "path" } "." }
+{ $warning "You should only call this word after you have manually verified that the image at " { $snippet "path" } " decodes and renders correctly!" } ;
+
+HELP: with-matching-files
+{ $values
+    { "dirpath" "a pathname string" } { "extension" string } { "quot" quotation }
+}
+{ $description "Perform an operation on each file in " { $snippet "dirpath" } " with file extension " { $snippet "extension" } "." } ;
+
+ARTICLE: { "images" "testing" "reference" } "Reference image"
+"For the purposes of the " { $vocab-link "images.testing" } " vocab, a reference image is an " { $link image } " which has been serialized to disk by the " { $vocab-link "serialize" } " vocab. The file on disk has a " { $snippet ".fig" } " extension."
+$nl
+"Reference images are used by " { $link decode-test } " to compare the decoder's output against a saved image that is known to be correct."
+$nl
+"You can create your own reference image after you verify that the image has been correctly decoded:"
+{ $subsections
+    save-as-reference-image
+    save-all-as-reference-images
+}
+"A reference image can be loaded by the path of the original image:"
+{ $subsections load-reference-image }
+;
+
+ARTICLE: "images.testing" "Testing image encoders and decoders"
+"The " { $vocab-link "images.testing" } " vocab facilitates writing unit tests for image encoders and decoders by providing common functionality"
+$nl
+"Creating a unit test:"
+{ $subsections
+    decode-test
+    encode-test
+}
+"Establishing a " { $link { "images" "testing" "reference" } } ":"
+{ $subsections save-as-reference-image }
+"You should only create a reference image after you manually verify that your decoder is generating a valid " { $link image } " object and that it renders correctly to the screen. The following words are useful for manual verification:"
+{ $subsections
+    image.
+    images.
+}
+"Helpful words for writing potentially tedious unit tests for each image file under test:"
+{ $subsections
+    save-all-as-reference-images
+    ls
+    with-matching-files
+}
+{ $notes "This vocabulary is only intended for implementors of image encoders and image decoders. If you are an end-user, you are in the wrong place :-)" }
+;
+
+ABOUT: "images.testing"
diff --git a/extra/images/testing/testing.factor b/extra/images/testing/testing.factor
new file mode 100644 (file)
index 0000000..a6644ed
--- /dev/null
@@ -0,0 +1,55 @@
+! Copyright (C) 2009 Keith Lazuka.
+! See http://factorcode.org/license.txt for BSD license.
+USING: fry images.loader images.normalization images.viewer io
+io.directories io.encodings.binary io.files io.pathnames
+io.streams.byte-array kernel locals namespaces quotations
+sequences serialize tools.test io.backend ;
+IN: images.testing
+
+<PRIVATE
+
+: fig-name ( path -- newpath )
+    [ parent-directory normalize-path ]
+    [ file-stem ".fig" append ] bi
+    append-path ;
+
+PRIVATE>
+
+:: with-matching-files ( dirpath extension quot -- )
+    dirpath [
+        [
+            dup file-extension extension = quot [ drop ] if
+        ] each
+    ] with-directory-files ; inline
+
+: images. ( dirpath extension -- )
+    [ image. ] with-matching-files ;
+
+: ls ( dirpath extension -- )
+    [ "\"" dup surround print ] with-matching-files ;
+
+: save-as-reference-image ( path -- )
+    [ load-image ] [ fig-name ] bi
+    binary [ serialize ] with-file-writer ;
+
+: save-all-as-reference-images ( dirpath extension -- )
+    [ save-as-reference-image ] with-matching-files ;
+
+: load-reference-image ( path -- image )
+    fig-name binary [ deserialize ] with-file-reader ;
+
+:: encode-test ( path image-class -- )
+    f verbose-tests? [
+        path load-image dup clone normalize-image 1quotation swap
+        '[
+            binary [ _ image-class image>stream ] with-byte-writer
+            image-class load-image* normalize-image
+        ] unit-test
+    ] with-variable ;
+
+: decode-test ( path -- )
+    f verbose-tests? [
+        [ load-image 1quotation ]
+        [ '[ _ load-reference-image ] ] bi
+        unit-test
+    ] with-variable ;
diff --git a/extra/images/testing/tiff/alpha.fig b/extra/images/testing/tiff/alpha.fig
new file mode 100644 (file)
index 0000000..b36a8f6
Binary files /dev/null and b/extra/images/testing/tiff/alpha.fig differ
diff --git a/extra/images/testing/tiff/alpha.tiff b/extra/images/testing/tiff/alpha.tiff
new file mode 100644 (file)
index 0000000..27215d6
Binary files /dev/null and b/extra/images/testing/tiff/alpha.tiff differ
diff --git a/extra/images/testing/tiff/color_spectrum.fig b/extra/images/testing/tiff/color_spectrum.fig
new file mode 100644 (file)
index 0000000..7050c13
Binary files /dev/null and b/extra/images/testing/tiff/color_spectrum.fig differ
diff --git a/extra/images/testing/tiff/color_spectrum.tiff b/extra/images/testing/tiff/color_spectrum.tiff
new file mode 100644 (file)
index 0000000..f596deb
Binary files /dev/null and b/extra/images/testing/tiff/color_spectrum.tiff differ
diff --git a/extra/images/testing/tiff/elephants.tiff b/extra/images/testing/tiff/elephants.tiff
new file mode 100644 (file)
index 0000000..f462a0c
Binary files /dev/null and b/extra/images/testing/tiff/elephants.tiff differ
diff --git a/extra/images/testing/tiff/noise.fig b/extra/images/testing/tiff/noise.fig
new file mode 100644 (file)
index 0000000..dd582aa
Binary files /dev/null and b/extra/images/testing/tiff/noise.fig differ
diff --git a/extra/images/testing/tiff/noise.tiff b/extra/images/testing/tiff/noise.tiff
new file mode 100644 (file)
index 0000000..2958b0b
Binary files /dev/null and b/extra/images/testing/tiff/noise.tiff differ
diff --git a/extra/images/testing/tiff/octagon.fig b/extra/images/testing/tiff/octagon.fig
new file mode 100644 (file)
index 0000000..0b66c62
Binary files /dev/null and b/extra/images/testing/tiff/octagon.fig differ
diff --git a/extra/images/testing/tiff/octagon.tiff b/extra/images/testing/tiff/octagon.tiff
new file mode 100644 (file)
index 0000000..2b4ba39
Binary files /dev/null and b/extra/images/testing/tiff/octagon.tiff differ
diff --git a/extra/images/testing/tiff/rgb.fig b/extra/images/testing/tiff/rgb.fig
new file mode 100644 (file)
index 0000000..c09b1cd
Binary files /dev/null and b/extra/images/testing/tiff/rgb.fig differ
diff --git a/extra/images/testing/tiff/rgb.tiff b/extra/images/testing/tiff/rgb.tiff
new file mode 100755 (executable)
index 0000000..71cbaa9
Binary files /dev/null and b/extra/images/testing/tiff/rgb.tiff differ
index d99116424fd6b2f41ed839843294eb956edadc74..917480dd3ffe89a276158b4857c4f31fcf2aaf82 100644 (file)
@@ -25,25 +25,10 @@ HELP: [infix
     }
 } ;
 
-HELP: [infix|
-{ $syntax "[infix| binding1 [ value1... ]\n        binding2 [ value2... ]\n        ... |\n    infix-expression infix]" }
-{ $description "Introduces a set of lexical bindings and evaluates the body as a snippet of infix code. The values are evaluated in parallel, and may not refer to other bindings within the same " { $link POSTPONE: [infix| } " form, as it is based on " { $link POSTPONE: [let } "." }
-{ $examples
-    { $example
-        "USING: infix prettyprint ;"
-        "IN: scratchpad"
-        "[infix| pi [ 3.14 ] r [ 12 ] | r*r*pi infix] ."
-        "452.16"
-    }
-} ;
-
-{ POSTPONE: [infix POSTPONE: [infix| } related-words
-
 ARTICLE: "infix" "Infix notation"
 "The " { $vocab-link "infix" } " vocabulary implements support for infix notation in Factor source code."
 { $subsections
     POSTPONE: [infix
-    POSTPONE: [infix|
 }
 $nl
 "The usual infix math operators are supported:"
@@ -76,8 +61,8 @@ $nl
 $nl
 "You can access " { $vocab-link "sequences" } " inside infix expressions with the familiar " { $snippet "arr[index]" } " notation."
 { $example
-    "USING: arrays infix ;"
-    "[infix| myarr [ { 1 2 3 4 } ] | myarr[4/2]*3 infix] ."
+    "USING: arrays locals infix ;"
+    "[let { 1 2 3 4 } :> myarr [infix myarr[4/2]*3 infix] ] ."
     "9"
 }
 "Please note: in Factor " { $emphasis "fixnums are sequences too." } " If you are not careful with sequence accesses you may introduce subtle bugs:"
index 5e3d5d67cb6eb913c7469f60106154690258e84c..c2b0d9d7b4474b357a8d03820942bb4879d144fb 100644 (file)
@@ -13,17 +13,6 @@ IN: infix.tests
      -5*
      0 infix] ] unit-test
 
-[ 452.16 ] [ [infix| r [ 12 ] pi [ 3.14 ] |
-    r*r*pi infix] ] unit-test
-[ 0 ] [ [infix| a [ 3 ] | 0 infix] ] unit-test
-[ 4/5 ] [ [infix| x [ 3 ] f [ 12 ] | f/(f+x) infix] ] unit-test
-[ 144 ] [ [infix| a [ 0 ] b [ 12 ] | b*b-a infix] ] unit-test
-
-[ 0 ] [ [infix| a [ { 0 1 2 3 } ] | a[0] infix] ] unit-test
-[ 0 ] [ [infix| a [ { 0 1 2 3 } ] | 3*a[0]*2*a[1] infix] ] unit-test
-[ 6 ] [ [infix| a [ { 0 1 2 3 } ] | a[0]+a[10%3]+a[3-1]+a[18/6] infix] ] unit-test
-[ -1 ] [ [infix| a [ { 0 1 2 3 } ] | -a[+1] infix] ] unit-test
-
 [ 0.0 ] [ [infix sin(0) infix] ] unit-test
 [ 10 ] [ [infix lcm(2,5) infix] ] unit-test
 [ 1.0 ] [ [infix +cos(-0*+3) infix] ] unit-test
@@ -42,4 +31,4 @@ IN: infix.tests
 [ t ] [ 5 \ stupid_function check-word ] unit-test
 [ 10 ] [ [infix stupid_function (0, 1, 2, 3, 4) infix] ] unit-test
 
-[ -1 ] [ [let | a [ 1 ] | [infix -a infix] ] ] unit-test
+[ -1 ] [ [let 1 :> a [infix -a infix] ] ] unit-test
index ce197800583f5f0231581d6425ddba57e5468172..48ac35264b2081eb302d5c9624a20e1304a57537 100644 (file)
@@ -82,15 +82,4 @@ M: ast-function infix-codegen
 PRIVATE>
 
 SYNTAX: [infix
-    "infix]" [infix-parse parsed \ call parsed ;
-
-<PRIVATE
-
-: parse-infix-locals ( assoc end -- quot )
-    '[ _ [infix-parse prepare-operand ] ((parse-lambda)) ;
-
-PRIVATE>
-
-SYNTAX: [infix|
-    "|" parse-bindings "infix]" parse-infix-locals <let>
-    ?rewrite-closures over push-all ;
+    "infix]" [infix-parse suffix! \ call suffix! ;
index 551fd16b33e27ea0c5952d5d9c623580fc623fa0..645e4939de0d3416425507932c9ce00da3837dde 100755 (executable)
@@ -11,8 +11,7 @@ IN: io.serial.windows
 
 : get-comm-state ( duplex -- dcb )
     in>> handle>>
-    DCB <struct> tuck
-    GetCommState win32-error=0/f ;
+    DCB <struct> [ GetCommState win32-error=0/f ] keep ;
 
 : set-comm-state ( duplex dcb -- )
     [ in>> handle>> ] dip
index 3f6cf4945d8df49402d5b558584383c92bd46895..8a87c1a6132b9151b0ace18ebb4bf4a5f1110fd7 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Bruno Deferrari
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors concurrency.mailboxes kernel calendar io.sockets io.encodings.8-bit
-destructors arrays sequences ;
+USING: accessors concurrency.mailboxes kernel calendar io.sockets
+destructors arrays sequences io.encodings.8-bit.latin1 ;
 IN: irc.client.chats
 
 CONSTANT: irc-port 6667 ! Default irc port
index ef1695f5634ed6a588a645f4c59dd8a2aa53a8c9..f2030e87b018bab93d3c9059668ee4638e8eaa84 100644 (file)
@@ -26,7 +26,7 @@ IN: irc.client.internals
     irc> [ connect>> ] [ reconnect-attempts>> ] bi do-connect ;
 
 : /JOIN ( channel password -- )
-    [ " :" swap 3append ] when* "JOIN " prepend irc-print ;
+    [ " :" glue ] when* "JOIN " prepend irc-print ;
 
 : try-connect ( -- stream/f )
     irc> profile>> [ server>> ] [ port>> ] bi /CONNECT ;
index 161a81d555cca122d66373cedcd1941b82246e5d..0963765482275ba61681a2b3411f9df6a4000579 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry irc.client irc.client.chats kernel namespaces
-sequences threads io.encodings.8-bit io.launcher io splitting
-make mason.common mason.updates calendar math alarms ;
+sequences threads io.launcher io splitting
+make mason.common mason.updates calendar math alarms
+io.encodings.8-bit.latin1 ;
 IN: irc.gitbot
 
 : bot-profile ( -- obj )
index 976a3832f47fdbe0b210bafe651e1c345357f8e1..0bc4d71707c3aa9084a2fda6ac5d6d5fc5d718dc 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors calendar calendar.format destructors fry io io.encodings.8-bit
 io.files io.pathnames irc.client irc.client.chats irc.messages
 irc.messages.base kernel make namespaces sequences threads
-irc.logbot.log-line ;
+irc.logbot.log-line io.encodings.8-bit.latin1 ;
 IN: irc.logbot
 
 CONSTANT: bot-channel "#concatenative"
index 60e9e39d9f5abf8d3611841355eedb5e683b3a24..48bf2b693a8c463c74cdc247e5689dc2488fd1b6 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors alien.c-types jamshred.game jamshred.oint
 jamshred.player jamshred.tunnel kernel math math.constants
 math.functions math.vectors opengl opengl.gl opengl.glu
-opengl.demo-support sequences specialized-arrays ;
+opengl.demo-support sequences specialized-arrays locals ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 IN: jamshred.gl
@@ -50,8 +50,9 @@ CONSTANT: wall-drawing-offset 0.15
     over color>> gl-color segment-vertex-and-normal
     gl-normal gl-vertex ;
 
-: draw-vertex-pair ( theta next-segment segment -- )
-    rot tuck draw-segment-vertex draw-segment-vertex ;
+:: draw-vertex-pair ( theta next-segment segment -- )
+    segment theta draw-segment-vertex
+    next-segment theta draw-segment-vertex ;
 
 : draw-segment ( next-segment segment -- )
     GL_QUAD_STRIP [
index ae72bd847cadfe687b14df90116817641ba89321..b1644ef443a5f308963e79c2510070935350d2c2 100644 (file)
@@ -53,13 +53,13 @@ C: <oint> oint
 
 : scalar-projection ( v1 v2 -- n )
     #! the scalar projection of v1 onto v2
-    tuck v. swap norm / ;
+    [ v. ] [ norm ] bi / ;
 
 : proj-perp ( u v -- w )
     dupd proj v- ;
 
 : perpendicular-distance ( oint oint -- distance )
-    tuck distance-vector swap 2dup left>> scalar-projection abs
+    [ distance-vector ] keep 2dup left>> scalar-projection abs
     -rot up>> scalar-projection abs + ;
 
 :: reflect ( v n -- v' )
index e4c954d793d04f2b33fbd5a9971c2dbab67eb498..6982af63f6f2415172897b28a4270505d128b9f1 100644 (file)
@@ -31,16 +31,13 @@ CONSTANT: max-speed 30.0
     forward-pivot ;
 
 : to-tunnel-start ( player -- )
-    [ tunnel>> first dup location>> ]
-    [ tuck (>>location) (>>nearest-segment) ] bi ;
+    dup tunnel>> first
+    [ >>nearest-segment ]
+    [ location>> >>location ] bi drop ;
 
 : play-in-tunnel ( player segments -- )
     >>tunnel to-tunnel-start ;
 
-: update-nearest-segment ( player -- )
-    [ tunnel>> ] [ dup nearest-segment>> nearest-segment ]
-    [ (>>nearest-segment) ] tri ;
-
 : update-time ( player -- seconds-passed )
     millis swap [ last-move>> - 1000 / ] [ (>>last-move) ] 2bi ;
 
@@ -101,11 +98,12 @@ CONSTANT: max-speed 30.0
     ] if ;
 
 :: move-player-on-heading ( d-left player distance heading -- d-left' player )
-    [let* | d-to-move [ d-left distance min ]
-            move-v [ d-to-move heading n*v ] |
-        move-v player location+
-        heading player update-nearest-segment2
-        d-left d-to-move - player ] ;
+    d-left distance min :> d-to-move
+    d-to-move heading n*v :> move-v
+
+    move-v player location+
+    heading player update-nearest-segment2
+    d-left d-to-move - player ;
 
 : distance-to-move-freely ( player -- distance )
     [ almost-to-collision ]
index e2e1c2012254509d31cefa8cff5aa0912e4f32cf..ac696f54445bcaafcbb5e9481ce6e193c111e509 100644 (file)
@@ -6,19 +6,6 @@ alien.c-types ;
 SPECIALIZED-ARRAY: float
 IN: jamshred.tunnel.tests
 
-[ 0 ] [ T{ segment f { 0 0 0 } f f f 0 }
-        T{ segment f { 1 1 1 } f f f 1 }
-        T{ oint f { 0 0 0.25 } }
-        nearer-segment number>> ] unit-test
-
-[ 0 ] [ T{ oint f { 0 0 0 } } <straight-tunnel> find-nearest-segment number>> ] unit-test
-[ 1 ] [ T{ oint f { 0 0 -1 } } <straight-tunnel> find-nearest-segment number>> ] unit-test
-[ 2 ] [ T{ oint f { 0 0.1 -2.1 } } <straight-tunnel> find-nearest-segment number>> ] unit-test
-
-[ 3 ] [ <straight-tunnel> T{ oint f { 0 0 -3.25 } } 0 nearest-segment-forward number>> ] unit-test
-
-[ float-array{ 0 0 0 } ] [ <straight-tunnel> T{ oint f { 0 0 -0.25 } } over first nearest-segment location>> ] unit-test
-
 : test-segment-oint ( -- oint )
     { 0 0 0 } { 0 0 -1 } { 0 1 0 } { -1 0 0 } <oint> ;
 
index 742f8346225d379b7dd1323b8d53e354ac8fd096..f94fc979ce630961f78d8272d383763473d777f2 100644 (file)
@@ -63,32 +63,6 @@ CONSTANT: default-segment-radius 1
     #! valid values
     [ '[ _ clamp-length ] bi@ ] keep <slice> ;
 
-: nearer-segment ( segment segment oint -- segment )
-    #! return whichever of the two segments is nearer to the oint
-    [ 2dup ] dip tuck distance [ distance ] dip < -rot ? ;
-
-: (find-nearest-segment) ( nearest next oint -- nearest ? )
-    #! find the nearest of 'next' and 'nearest' to 'oint', and return
-    #! t if the nearest hasn't changed
-    pick [ nearer-segment dup ] dip = ;
-
-: find-nearest-segment ( oint segments -- segment )
-    dup first swap rest-slice rot [ (find-nearest-segment) ] curry
-    find 2drop ;
-    
-: nearest-segment-forward ( segments oint start -- segment )
-    rot dup length swap <slice> find-nearest-segment ;
-
-: nearest-segment-backward ( segments oint start -- 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.
-    #! start looking at segment 'start-segment'
-    number>> over [
-        [ nearest-segment-forward ] 3keep nearest-segment-backward
-    ] dip nearer-segment ;
-
 : get-segment ( segments n -- segment )
     over clamp-length swap nth ;
 
@@ -107,13 +81,13 @@ CONSTANT: default-segment-radius 1
     } case ;
 
 :: distance-to-next-segment ( current next location heading -- distance )
-    [let | cf [ current forward>> ] |
-        cf next location>> v. cf location v. - cf heading v. / ] ;
+    current forward>> :> cf
+    cf next location>> v. cf location v. - cf heading v. / ;
 
 :: distance-to-next-segment-area ( current next location heading -- distance )
-    [let | cf [ current forward>> ]
-           h [ next current half-way-between-oints ] |
-        cf h v. cf location v. - cf heading v. / ] ;
+    current forward>> :> cf
+    next current half-way-between-oints :> h
+    cf h v. cf location v. - cf heading v. / ;
 
 : vector-to-centre ( seg loc -- v )
     over location>> swap v- swap forward>> proj-perp ;
@@ -138,10 +112,10 @@ CONSTANT: distant 1000
     v norm 0 = [
         distant
     ] [
-        [let* | a [ v dup v. ]
-                b [ v w v. 2 * ]
-                c [ w dup v. r sq - ] |
-            c b a quadratic max-real ]
+        v dup v. :> a
+        v w v. 2 * :> b
+        w dup v. r sq - :> c
+        c b a quadratic max-real
     ] if ;
 
 : sideways-heading ( oint segment -- v )
index 90e28594e7c0d4deeb3465e262a765392487f871..6ea1dc5633b18bbba53ee3a68186434d824db77b 100755 (executable)
@@ -50,10 +50,10 @@ CONSTANT: pov-polygons
     [ [ 0.0 ] unless* ] tri@
     [ (xy>loc) ] dip (z>loc) ;
 
-: move-axis ( gadget x y z -- )
-    (xyz>loc) rot tuck
-    [ indicator>>   (>>loc) ]
-    [ z-indicator>> (>>loc) ] 2bi* ;
+:: move-axis ( gadget x y z -- )
+    x y z (xyz>loc) :> ( xy z )
+    xy gadget   indicator>> (>>loc)
+    z  gadget z-indicator>> (>>loc) ;
 
 : move-pov ( gadget pov -- )
     swap pov>> [ interior>> -rot = COLOR: gray COLOR: white ? >>color drop ]
@@ -82,10 +82,10 @@ TUPLE: joystick-demo-gadget < pack axis raxis controller buttons alarm ;
     [ >>controller ] [ product-string <label> add-gadget ] bi ;
 
 : add-axis-gadget ( gadget shelf -- gadget shelf )
-    <axis-gadget> tuck [ >>axis ] [ add-gadget-with-border ] 2bi* ;
+    <axis-gadget> [ >>axis ] [ add-gadget-with-border ] bi-curry bi* ;
 
 : add-raxis-gadget ( gadget shelf -- gadget shelf )
-    <axis-gadget> tuck [ >>raxis ] [ add-gadget-with-border ] 2bi* ;
+    <axis-gadget> [ >>raxis ] [ add-gadget-with-border ] bi-curry bi* ;
 
 :: (add-button-gadgets) ( gadget shelf -- )
     gadget controller>> read-controller buttons>> length [
index b5171bece01aac07060274a3e334365050b852d7..fafd68ca68db138d274012732a812e1a9e247ffa 100644 (file)
@@ -7,4 +7,4 @@ 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
+    [ handlers>> at ] keep swap [ call( gadget -- ) f ] [ drop t ] if* ;
index 59efec1c02302124c896aa0956fc71e538470e8b..f5b30f49da7a61dfa2659cec521e483d30195ed8 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hashtables assocs io kernel math
+USING: accessors arrays hashtables assocs io kernel locals math
 math.vectors math.matrices math.matrices.elimination namespaces
 parser prettyprint sequences words combinators math.parser
 splitting sorting shuffle sets math.order ;
@@ -191,12 +191,12 @@ DEFER: (d)
     [ ?nth ?nth ] 3keep [ [ 2 + ] dip 1 - ] dip ?nth ?nth
     dim-im/ker-d ;
 
-: bigraded-ker/im-d ( bigraded-basis -- seq )
-    dup length [
-        over first length [
-            [ 2dup ] dip spin (bigraded-ker/im-d)
-        ] map 2nip
-    ] with map ;
+:: bigraded-ker/im-d ( basis -- seq )
+    basis length iota [| z |
+         basis first length iota [| u |
+            u z basis (bigraded-ker/im-d)
+        ] map
+    ] map ;
 
 : bigraded-betti ( u-generators z-generators -- seq )
     [ basis graded ] bi@ tensor bigraded-ker/im-d
@@ -229,14 +229,12 @@ DEFER: (d)
 : laplacian-betti ( basis1 basis2 basis3 -- n )
     laplacian-matrix null/rank drop ;
 
-: laplacian-kernel ( basis1 basis2 basis3 -- basis )
-    [ tuck ] dip
-    laplacian-matrix dup empty-matrix? [
-        2drop f
-    ] [
-        nullspace [
-            [ [ wedge (alt+) ] 2each ] with-terms
-        ] with map
+:: laplacian-kernel ( basis1 basis2 basis3 -- basis )
+    basis1 basis2 basis3 laplacian-matrix :> lap
+    lap empty-matrix? [ f ] [
+        lap nullspace [| x |
+            basis2 x [ [ wedge (alt+) ] 2each ] with-terms
+        ] map
     ] if ;
 
 : graded-triple ( seq n -- triple )
@@ -270,12 +268,12 @@ DEFER: (d)
     3tri
     3array ;
 
-: bigraded-triples ( grid -- triples )
-    dup length [
-        over first length [
-            [ 2dup ] dip spin bigraded-triple
-        ] map 2nip
-    ] with map ;
+:: bigraded-triples ( grid -- triples )
+    grid length [| z |
+        grid first length [| u |
+            u z grid bigraded-triple
+        ] map
+    ] map ;
 
 : bigraded-laplacian ( u-generators z-generators quot -- seq )
     [ [ basis graded ] bi@ tensor bigraded-triples ] dip
index 426e464b1bff3640c1174dad6bae92cf226ab199..ddb54ecb2799e8b13d110494c268b4627902e585 100644 (file)
@@ -242,4 +242,4 @@ Program = Type
 
 ;EBNF
 
-SYNTAX: TYPE: ";" parse-multiline-string parse-type parsed ; 
\ No newline at end of file
+SYNTAX: TYPE: ";" parse-multiline-string parse-type suffix! ; 
index 22e37f8a8ccd0d0042bfbeb5278fbdfdba0ef410..71ac313ada7dd6942ae9d879cb6c29d8a83bb595 100755 (executable)
@@ -23,7 +23,7 @@ HOOK: really-delete-tree os ( path -- )
 M: windows really-delete-tree
     #! Workaround: Cygwin GIT creates read-only files for
     #! some reason.
-    [ { "chmod" "ug+rw" "-R" } swap (normalize-path) suffix short-running-process ]
+    [ { "chmod" "ug+rw" "-R" } swap absolute-path suffix short-running-process ]
     [ delete-tree ]
     bi ;
 
@@ -33,13 +33,12 @@ M: unix really-delete-tree delete-tree ;
     '[ drop @ f ] attempt-all drop ; inline
 
 :: upload-safely ( local username host remote -- )
-    [let* | temp [ remote ".incomplete" append ]
-            scp-remote [ { username "@" host ":" temp } concat ]
-            scp [ scp-command get ]
-            ssh [ ssh-command get ] |
-        5 [ { scp local scp-remote } short-running-process ] retry
-        5 [ { ssh host "-l" username "mv" temp remote } short-running-process ] retry
-    ] ;
+    remote ".incomplete" append :> temp
+    { username "@" host ":" temp } concat :> scp-remote
+    scp-command get :> scp
+    ssh-command get :> ssh
+    5 [ { scp local scp-remote } short-running-process ] retry
+    5 [ { ssh host "-l" username "mv" temp remote } short-running-process ] retry ;
 
 : eval-file ( file -- obj )
     dup utf8 file-lines parse-fresh
index d6be8654c5473d313eb4343e476ba2ce16fc0835..2a33c5240b572c25572daf0f31fdd0822e4d30cb 100644 (file)
@@ -17,4 +17,4 @@ IN: mason.platform
     target-os get target-cpu get arch ;
 
 : boot-image-name ( -- string )
-    "boot." boot-image-arch ".image" 3append ;
+    boot-image-arch "boot." ".image" surround ;
index 7d63bbfac8cacf88074a6f0e57fa268ccf4cb536..e8315cdf202062cfb8ef72929fc1c00c4f31bde9 100644 (file)
@@ -41,7 +41,7 @@ CONSTANT: identity-transform T{ affine-transform f { 1.0 0.0 } { 0.0 1.0 } { 0.0
     [ [ y>> second     ] [ x>> second neg ] bi 2array ]
     [ [ y>> first  neg ] [ x>> first      ] bi 2array ]
     [ |a| ] tri
-    tuck [ v/n ] 2bi@ ;
+    [ v/n ] curry bi@ ;
 
 : inverse-axes ( a -- a^-1 )
     (inverted-axes) { 0.0 0.0 } <affine-transform> ;
index a810ffc1bd844aea7f523e1a3bbdf361ab3f149f..586a6d497104f884479e501a8b006c105c87b202 100644 (file)
@@ -9,10 +9,6 @@ HELP: gammaln
 { $values { "x" number } { "gamma[x]" number } }
 { $description "An alternative to " { $link gamma } " when gamma(x)'s range varies too widely." } ;
 
-HELP: nth-root
-{ $values { "n" integer } { "x" number } { "y" number } }
-{ $description "Calculates the nth root of a number, such that " { $snippet "y^n=x" } "." } ;
-
 HELP: exp-int
 { $values { "x" number } { "y" number } }
 { $description "Exponential integral function." }
index 39d6450ba0cffc20d317b4e4608f473964bf746c..6d01744290ab9f889308788a092e11f22c6de9b3 100755 (executable)
@@ -56,9 +56,6 @@ PRIVATE>
         [ abs gammaln-lanczos6 ] keep dup 0 > [ drop ] [ gamma-neg ] if
     ] if ;
 
-: nth-root ( n x -- y )
-    swap recip ^ ;
-
 ! Forth Scientific Library Algorithm #1
 !
 ! Evaluates the Real Exponential Integral,
index 4bd1bc1b81fcc3c0022386327db20f3ead24dee7..5f1ec0c0177306b061f49ced552474fb0961fd6d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: sequences kernel arrays vectors accessors assocs sorting math math.functions ;
+USING: sequences kernel arrays vectors accessors assocs shuffle sorting locals math math.functions ;
 
 IN: math.binpack 
 
@@ -9,10 +9,12 @@ IN: math.binpack
     [ [ values sum ] map ] keep
     zip sort-keys values first push ;
 
-: binpack ( assoc n -- bins )
-    [ sort-values <reversed> dup length ] dip
-    tuck / ceiling <array> [ <vector> ] map
-    tuck [ (binpack) ] curry each ;
+:: binpack ( assoc n -- bins )
+    assoc sort-values <reversed> :> values
+    values length :> #values
+    n #values n / ceiling <array> [ <vector> ] map :> bins
+    values [ bins (binpack) ] each
+    bins ;
 
 : binpack* ( items n -- bins )
     [ dup zip ] dip binpack [ keys ] map ;
index 5954b08c9b3649331aafe2c0d666dc73c6defd7b..f1c608bad912017f37f4afce36f527952f61544c 100644 (file)
@@ -7,7 +7,7 @@ IN: math.finance
 <PRIVATE
 
 : weighted ( x y a -- z )
-    tuck [ * ] [ 1 - neg * ] 2bi* + ;
+    [ * ] [ 1 - neg * ] bi-curry bi* + ;
 
 : a ( n -- a )
     1 + 2 swap / ;
index edbe77781f7d043ffb1f050231c4e290d734bf65..97290964eb62e53029459aece396d7980bd05435 100644 (file)
@@ -20,7 +20,7 @@ M: matrix4 new-sequence 2drop matrix4 (struct) ; inline
 <PRIVATE
 
 : columns ( a -- a1 a2 a3 a4 )
-    columns>> 4 firstn ; inline
+    columns>> first4 ; inline
 
 :: set-columns ( c1 c2 c3 c4 c -- c )
     c columns>> :> columns
@@ -35,8 +35,8 @@ M: matrix4 new-sequence 2drop matrix4 (struct) ; inline
 
 :: 2map-columns ( a b quot -- c )
     [
-        a columns :> a4 :> a3 :> a2 :> a1
-        b columns :> b4 :> b3 :> b2 :> b1
+        a columns :> ( a1 a2 a3 a4 )
+        b columns :> ( b1 b2 b3 b4 )
 
         a1 b1 quot call
         a2 b2 quot call
@@ -61,8 +61,8 @@ TYPED: n/m4 ( a: float b: matrix4 -- c: matrix4 ) [ n/v ] with map-columns ;
 
 TYPED:: m4. ( a: matrix4 b: matrix4 -- c: matrix4 )
     [
-        a columns :> a4 :> a3 :> a2 :> a1
-        b columns :> b4 :> b3 :> b2 :> b1
+        a columns :> ( a1 a2 a3 a4 )
+        b columns :> ( b1 b2 b3 b4 )
 
         b1 first  a1 n*v :> c1a
         b2 first  a1 n*v :> c2a
@@ -86,7 +86,7 @@ TYPED:: m4. ( a: matrix4 b: matrix4 -- c: matrix4 )
     ] make-matrix4 ;
 
 TYPED:: m4.v ( m: matrix4 v: float-4 -- v': float-4 )
-    m columns :> m4 :> m3 :> m2 :> m1
+    m columns :> ( m1 m2 m3 m4 )
     
     v first  m1 n*v
     v second m2 n*v v+
index 60929b92cb543b63e442b291c424c4c5a669e306..892b846e9ee331bbee49fd4ebf0fb0053b0ab622 100644 (file)
@@ -1,20 +1,18 @@
 ! Copyright (C) 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions ;
+USING: kernel locals math math.functions ;
 IN: math.quadratic
 
-: monic ( c b a -- c' b' ) tuck [ / ] 2bi@ ;
+: monic ( c b a -- c' b' ) [ / ] curry bi@ ;
 
-: discriminant ( c b -- b d ) tuck sq 4 / swap - sqrt ;
+: discriminant ( c b -- b d ) [ nip ] [ sq 4 / swap - sqrt ] 2bi ;
 
 : critical ( b d -- -b/2 d ) [ -2 / ] dip ;
 
 : +- ( x y -- x+y x-y ) [ + ] [ - ] 2bi ;
 
 : quadratic ( c b a -- alpha beta )
-    #! Solve a quadratic equation ax^2 + bx + c = 0
     monic discriminant critical +- ;
 
-: qeval ( x c b a -- y )
-    #! Evaluate ax^2 + bx + c
-    [ pick * ] dip roll sq * + + ;
+:: qeval ( x c b a -- y )
+    c b x * + a x sq * + ;
diff --git a/extra/models/combinators/authors.txt b/extra/models/combinators/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/models/combinators/combinators-docs.factor b/extra/models/combinators/combinators-docs.factor
deleted file mode 100644 (file)
index 5ccfe1f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644 (file)
index c7b864d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-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
deleted file mode 100644 (file)
index 1e5347e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644 (file)
index 685ad93..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-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/illusion/authors.txt b/extra/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/extra/models/illusion/illusion.factor b/extra/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/extra/models/illusion/summary.txt b/extra/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 36dedb2a653b92e2f661317f227a2a1256ce23f0..6cafeff2895f3a90d558bce921ac62bf67846607 100644 (file)
@@ -30,4 +30,4 @@ ERROR: not-an-integer x ;
     ] keep length
     10^ / + swap [ neg ] when ;
 
-SYNTAX: DECIMAL: scan parse-decimal parsed ;
+SYNTAX: DECIMAL: scan parse-decimal suffix! ;
index 45cced5b3b98acebbc365128885909a38ead8f2b..1d38aa38d521cccf49c4a354cab4476c349ee2fa 100644 (file)
@@ -123,15 +123,16 @@ CONSTRUCTOR: mdb-connection ( instance -- mdb-connection ) ;
 PRIVATE>
 
 :: verify-nodes ( mdb -- )
-    [ [let* | acc [ V{ } clone ]
-              node1 [ mdb dup master-node [ check-node ] keep ]
-              node2 [ mdb node1 remote>>
-                      [ [ check-node ] keep ]
-                      [ drop f ] if*  ]
-              | node1 [ acc push ] when*
-                node2 [ acc push ] when*
-                mdb acc nodelist>table >>nodes drop 
-              ]
+    [
+        V{ } clone :> acc
+        mdb dup master-node [ check-node ] keep :> node1
+        mdb node1 remote>>
+        [ [ check-node ] keep ]
+        [ drop f ] if*  :> node2
+
+        node1 [ acc push ] when*
+        node2 [ acc push ] when*
+        mdb acc nodelist>table >>nodes drop 
     ] with-destructors ; 
               
 : mdb-open ( mdb -- mdb-connection )
@@ -143,4 +144,4 @@ PRIVATE>
      [ dispose f ] change-handle drop ;
 
 M: mdb-connection dispose
-     mdb-close ;
\ No newline at end of file
+     mdb-close ;
index 574724dfafa49d71d44c0d5aab6ce3c040167e80..294672523cbb6c237d2870cbcc92c4a36235cc0e 100644 (file)
@@ -151,14 +151,16 @@ M: mdb-collection create-collection
     [ "$cmd" = ] [ "system" head? ] bi or ;
 
 : check-collection ( collection -- fq-collection )
-    [let* | instance [ mdb-instance ]
-            instance-name [ instance name>> ] |        
+    [let
+        mdb-instance :> instance
+        instance name>> :> instance-name
         dup mdb-collection? [ name>> ] when
         "." split1 over instance-name =
         [ nip ] [ drop ] if
         [ ] [ reserved-namespace? ] bi
         [ instance (ensure-collection) ] unless
-        [ instance-name ] dip "." glue ] ; 
+        [ instance-name ] dip "." glue
+    ] ;
 
 : fix-query-collection ( mdb-query -- mdb-query )
     [ check-collection ] change-collection ; inline
@@ -188,9 +190,7 @@ M: mdb-query-msg skip
 : asc ( key -- spec ) 1 2array ; inline
 : desc ( key -- spec ) -1 2array ; inline
 
-GENERIC# sort 1 ( mdb-query-msg sort-quot -- mdb-query-msg )
-
-M: mdb-query-msg sort
+: sort ( mdb-query-msg sort-quot -- mdb-query-msg )
     output>array [ 1array >hashtable ] map >>orderby ; inline
 
 : key-spec ( spec-quot -- spec-assoc )
index dd8bae84386952acef313ca87245204e3bb105c0..c48634679507caa304149e9a35507b0905b70b21 100644 (file)
@@ -94,7 +94,7 @@ M: sequence <mdb-insert-msg> ( collection sequence -- mdb-insert-msg )
 M: assoc <mdb-insert-msg> ( collection assoc -- mdb-insert-msg )
     [ mdb-insert-msg new ] 2dip
     [ >>collection ] dip
-    V{ } clone tuck push
+    [ V{ } clone ] dip suffix!
     >>objects OP_Insert >>opcode ;
 
 
index d4ee789523f70d49b1569d1d614b1a996b3ac7c5..7e99c52aacf6d95085815e7ceef72565fb26f1eb 100644 (file)
@@ -105,15 +105,14 @@ USE: tools.walker
     ! [ dump-to-file ] keep
     write flush ; inline
 
-: build-query-object ( query -- selector )
-    [let | selector [ H{ } clone ] |
-        { [ orderby>> [ "orderby" selector set-at ] when* ]
-          [ explain>> [ "$explain" selector set-at ] when* ]
-          [ hint>> [ "$hint" selector set-at ] when* ] 
-          [ query>> "query" selector set-at ]
-        } cleave
-        selector
-    ] ;     
+:: build-query-object ( query -- selector )
+    H{ } clone :> selector
+    query { [ orderby>> [ "orderby" selector set-at ] when* ]
+      [ explain>> [ "$explain" selector set-at ] when* ]
+      [ hint>> [ "$hint" selector set-at ] when* ] 
+      [ query>> "query" selector set-at ]
+    } cleave
+    selector ;
 
 PRIVATE>
 
index 6c2b89a57167424429533c2a3885e60cb3ad33fc..85036c8d86ae4900214b50b4855ed2e676cbe1bf 100644 (file)
@@ -152,7 +152,7 @@ M: mdb-collection mdb-index-map
 
 : slot-option? ( tuple slot option -- ? )
     [ swap mdb-slot-map at ] dip
-    '[ _ swap memq? ] [ f ] if* ;
+    '[ _ swap member-eq? ] [ f ] if* ;
   
 PRIVATE>
 
index fc521eca3ef375378e5d846c19fe3629d29d198b..9ea66fba520b875a881b317a55a2a32971c11cba 100644 (file)
@@ -50,13 +50,13 @@ TUPLE: cond-value value quot ;
 
 CONSTRUCTOR: cond-value ( value quot -- cond-value ) ;
 
-: write-mdb-persistent ( value quot: ( tuple -- assoc ) -- value' )
+: write-mdb-persistent ( value quot -- value' )
    over [ call( tuple -- assoc ) ] dip 
    [ [ tuple-collection name>> ] [ >toid ] bi ] keep
    [ add-storable ] dip
-   [ tuple-collection name>> ] [ id>> ] bi <objref> ; inline
+   [ tuple-collection name>> ] [ id>> ] bi <objref> ;
 
-: write-field ( value quot: ( tuple -- assoc ) -- value' )
+: write-field ( value quot -- value' )
    <cond-value> {
       { [ dup value>> mdb-special-value? ] [ value>> ]  }
       { [ dup value>> mdb-persistent? ]
@@ -66,7 +66,7 @@ CONSTRUCTOR: cond-value ( value quot -- cond-value ) ;
       { [ dup value>> [ hashtable? ] [ linked-assoc? ] bi or ]
         [ [ value>> ] [ quot>> ] bi '[ _ write-field ] assoc-map ] }
       [ value>> ]
-   } cond ; inline recursive
+   } cond ;
 
 : write-tuple-fields ( mirror tuple assoc quot: ( tuple -- assoc ) -- )
    swap ! m t q q a 
index ec1b8865ab2c8be470f95872f5ae885cb34f3445..bbae2b039959c09487b95ee29de0026b7ec3b1d6 100644 (file)
@@ -10,7 +10,7 @@ CONSTANT: MDB_TUPLE_INFO       "_mfd_t_info"
 PRIVATE>
 
 : <tuple-info> ( tuple -- tuple-info )
-    class V{ } clone tuck  
+    class [ V{ } clone ] dip over
     [ [ name>> ] dip push ]
     [ [ vocabulary>> ] dip push ] 2bi ; inline
 
diff --git a/extra/monotonic-clock/authors.txt b/extra/monotonic-clock/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/monotonic-clock/monotonic-clock.factor b/extra/monotonic-clock/monotonic-clock.factor
new file mode 100755 (executable)
index 0000000..8f277fb
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: combinators system vocabs.loader ;
+IN: monotonic-clock
+
+HOOK: monotonic-count os ( -- n )
+
+{
+    { [ os unix? ] [ "monotonic-clock.unix" ] }
+    { [ os windows? ] [ "monotonic-clock.windows" ] }
+    { [ os macosx? ] [ "monotonic-clock.unix.macosx" ] }
+} cond require
diff --git a/extra/monotonic-clock/unix/authors.txt b/extra/monotonic-clock/unix/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/monotonic-clock/unix/macosx/authors.txt b/extra/monotonic-clock/unix/macosx/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/monotonic-clock/unix/macosx/macosx.factor b/extra/monotonic-clock/unix/macosx/macosx.factor
new file mode 100755 (executable)
index 0000000..5bdb8ff
--- /dev/null
@@ -0,0 +1,24 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.syntax classes.struct kernel math
+monotonic-clock system unix.types ;
+IN: monotonic-clock.unix.macosx
+
+STRUCT: mach_timebase_info
+    { numer uint32_t }
+    { denom uint32_t } ;
+
+TYPEDEF: mach_timebase_info* mach_timebase_info_t
+TYPEDEF: mach_timebase_info mach_timebase_info_data_t
+
+FUNCTION: uint64_t mach_absolute_time ( ) ;
+FUNCTION: kern_return_t mach_timebase_info ( mach_timebase_info_t info ) ;
+FUNCTION: kern_return_t mach_wait_until ( uint64_t deadline ) ;
+
+ERROR: mach-timebase-info ret ;
+
+M: macosx monotonic-count 
+    mach_absolute_time
+    \ mach_timebase_info <struct> [
+        mach_timebase_info [ mach-timebase-info ] unless-zero
+    ] keep [ numer>> ] [ denom>> ] bi / * ;
diff --git a/extra/monotonic-clock/unix/macosx/tags.txt b/extra/monotonic-clock/unix/macosx/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/monotonic-clock/unix/unix.factor b/extra/monotonic-clock/unix/unix.factor
new file mode 100644 (file)
index 0000000..d739735
--- /dev/null
@@ -0,0 +1,22 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax calendar.unix classes.struct
+kernel monotonic-clock system unix unix.time unix.types ;
+IN: monotonic-clock.unix
+
+LIBRARY: librt
+
+FUNCTION: int clock_settime ( clockid_t clock_id, timespec* tp ) ;
+FUNCTION: int clock_gettime ( clockid_t clock_id, timespec* tp ) ;
+FUNCTION: int clock_getres ( clockid_t clock_id, timespec* res ) ;
+
+CONSTANT: CLOCK_REALTIME 0
+CONSTANT: CLOCK_MONOTONIC 1
+CONSTANT: CLOCK_PROCESS_CPUTIME_ID 2
+CONSTANT: CLOCK_THREAD_CPUTIME_ID 3
+
+CONSTANT: TIMER_ABSTIME 1
+
+M: unix monotonic-count
+    CLOCK_MONOTONIC timespec <struct> [ clock_gettime io-error ] keep
+    timespec>nanoseconds ;
diff --git a/extra/monotonic-clock/windows/authors.txt b/extra/monotonic-clock/windows/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/monotonic-clock/windows/tags.txt b/extra/monotonic-clock/windows/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/monotonic-clock/windows/windows.factor b/extra/monotonic-clock/windows/windows.factor
new file mode 100755 (executable)
index 0000000..85732e3
--- /dev/null
@@ -0,0 +1,19 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.data fry kernel monotonic-clock
+system windows.errors windows.kernel32 ;
+IN: monotonic-clock.windows
+
+<PRIVATE
+
+: execute-performance-query ( word -- n )
+    [ "LARGE_INTEGER*" <c-object> ] dip
+    '[ _ execute win32-error=0/f ] keep *ulonglong ; inline
+
+PRIVATE>
+
+M: windows monotonic-count  ( -- n )
+    \ QueryPerformanceCounter execute-performance-query ;
+
+: cpu-frequency ( -- n )
+    \ QueryPerformanceFrequency execute-performance-query ;
index ddfd3c20424c98c5923d9c88db67a2bd63f68fcf..cbe3c0f2fad1dae09d95020188a957743648e5ff 100644 (file)
@@ -109,7 +109,7 @@ PRIVATE>
 : morse> ( morse -- plain )
     replace-underscores morse>sentence ;
 
-SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> parsed ; 
+SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> suffix! ; 
     
 <PRIVATE
     
index d3e1d443aab69296a7de4f1dd1f8d06ac377cb7b..de131df3c6a84b4a3217dd7f3a37934c88318063 100755 (executable)
@@ -81,7 +81,7 @@ SYMBOL: total
 
 : topological-sort ( seq quot -- newseq )
     [ >vector [ dup empty? not ] ] dip
-    [ dupd maximal-element [ over delete-nth ] dip ] curry
+    [ dupd maximal-element [ over remove-nth! drop ] dip ] curry
     produce nip ; inline
 
 : classes< ( seq1 seq2 -- lt/eq/gt )
index a483a492b3f1ed69f073ea9dca760c082318b343..b0ab2c1bc3499788995bfbd99a83eb7f83153f77 100644 (file)
@@ -6,14 +6,14 @@ DEFER: fake
 \ fake H{ } clone "multi-methods" set-word-prop
 << (( -- )) \ fake set-stack-effect >>
 
-[ "fake-{ }" ] [ { } \ fake method-word-name ] unit-test
+[
+    [ "fake-{ }" ] [ { } \ fake method-word-name ] unit-test
 
-[ H{ { "multi-method-generic" fake } { "multi-method-specializer" { } } } ]
-[ { } \ fake method-word-props ] unit-test
+    [ H{ { "multi-method-generic" fake } { "multi-method-specializer" { } } } ]
+    [ { } \ fake method-word-props ] unit-test
 
-[ t ] [ { } \ fake <method> method-body? ] unit-test
+    [ t ] [ { } \ fake <method> method-body? ] unit-test
 
-[
     [ { } [ ] ] [ \ fake methods prepare-methods [ sort-methods ] dip ] unit-test
 
     [ t ] [ { } \ fake multi-dispatch-quot callable? ] unit-test
index 1ea5b951573fb30c58b5029515676afd7657ad2b..91e040d35f28d614f9c0a46506887c94c88cbd1d 100644 (file)
@@ -56,7 +56,7 @@ ERROR: invalid-perlin-noise-table table ;
     dup { [ byte-array? ] [ length 512 >= ] } 1&&
     [ invalid-perlin-noise-table ] unless ;
 
-! XXX doesn't work for NaNs or floats > 2^31
+! XXX doesn't work when v is nan or |v| >= 2^31
 : floor-vector ( v -- v' )
     [ float-4 int-4 vconvert int-4 float-4 vconvert ]
     [ [ v> -1.0 float-4-with vand ] curry keep v+ ] bi ; inline
index 0df063e2c6dbce5558d47d8169450bef9594cfa6..38ab0c31da2e16f4efc46eadf084ada94a624a4d 100644 (file)
@@ -60,7 +60,7 @@ TUPLE: nurbs-curve
 
 :: (eval-bases) ( curve t interval values order -- values' )
     order 2 - curve (knot-constants)>> nth :> all-knot-constants
-    interval order interval + all-knot-constants clip-range :> to :> from
+    interval order interval + all-knot-constants clip-range :> ( from to )
     from to all-knot-constants subseq :> knot-constants
     values { 0.0 } { 0.0 } surround 2 <clumps> :> bases
 
index 3bd8a098f6a9e9496b8eb378153b62a1c41ae40e..299c66cc23fcd4503b3d17e76c0325adfdec3262 100644 (file)
@@ -2,5 +2,5 @@
 USING: arrays kernel parser sequences ;
 IN: pair-rocket
 
-SYNTAX: => dup pop scan-object 2array parsed ;
+SYNTAX: => dup pop scan-object 2array suffix! ;
 
index 7a73561e56fbbdfaf2c1f436ef95ce570d0c2110..c2e3e347275f80252ed74ea8702156e5d917d778 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: lists lists.lazy promises kernel sequences strings math
-arrays splitting quotations combinators namespaces
+arrays splitting quotations combinators namespaces locals
 unicode.case unicode.categories sequences.deep accessors ;
 IN: parser-combinators
 
@@ -58,9 +58,11 @@ C: <token-parser> token-parser
 
 : case-insensitive-token ( string -- parser ) t <token-parser> ;
 
-M: token-parser parse ( input parser -- list )
-    [ string>> ] [ ignore-case?>> ] bi
-    [ tuck ] dip ?string-head
+M:: token-parser parse ( input parser -- list )
+    parser string>> :> str
+    parser ignore-case?>> :> case?
+
+    str input str case? ?string-head
     [ <parse-results> ] [ 2drop nil ] if ;
 
 : 1token ( n -- parser ) 1string token ;
@@ -319,7 +321,7 @@ LAZY: <(+)> ( parser -- parser )
     <& &> ;
 
 : nonempty-list-of ( items separator -- parser )
-    [ over &> <*> <&:> ] keep <?> tuck pack ;
+    [ over &> <*> <&:> ] keep <?> [ nip ] 2keep pack ;
 
 : list-of ( items separator -- parser )
     #! Given a parser for the separator and for the
index d6fdefd1aa2b0fd474d4319ee8590c7cdb9530c5..e3d8cb7fd91036be60d2c339b8c006b60142ae54 100644 (file)
@@ -1,12 +1,12 @@
 USING: namespaces math partial-continuations tools.test
-kernel sequences ;
+kernel sequences fry ;
 IN: partial-continuations.tests
 
 SYMBOL: sum
 
 : range ( r from to -- n )
     over - 1 + rot [ 
-        -rot [ over + pick call drop ] each 2drop f  
+        '[ over + @ drop ] each drop f
     ] bshift 2nip ; inline
 
 [ 55 ] [
index f459eca7e442bf4029fb4a52e9f6efbd1e6f1ad2..db999f4c988ab13ae31a67c6d7b1f6aa8fbbab11 100644 (file)
@@ -26,5 +26,5 @@ SYNTAX: STORED-TUPLE: parse-tuple-definition [ drop persistent ] dip [ remove-ty
 : remove-tuples ( tuple -- ) [ delete-tuples ] w/db ;
     
 TUPLE: pattern value ; C: <pattern> pattern
-SYNTAX: %" parse-string <pattern> parsed ;
+SYNTAX: %" parse-string <pattern> suffix! ;
 M: pattern where value>> over column-name>> 0% " LIKE " 0% bind# ;
diff --git a/extra/pop3/authors.txt b/extra/pop3/authors.txt
new file mode 100644 (file)
index 0000000..0a11271
--- /dev/null
@@ -0,0 +1 @@
+Elie Chaftari
\ No newline at end of file
diff --git a/extra/pop3/pop3-docs.factor b/extra/pop3/pop3-docs.factor
new file mode 100644 (file)
index 0000000..aeb6d21
--- /dev/null
@@ -0,0 +1,312 @@
+! Copyright (C) 2009 Elie Chaftari.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays assocs help.markup help.syntax kernel math
+sequences strings ;
+IN: pop3
+
+HELP: <pop3-account>
+{ $values
+    
+    { "pop3-account" pop3-account }
+}
+{ $description "creates a " { $link pop3-account } " object with defaults for the port and timeout slots." } ;
+
+HELP: account
+{ $values
+    
+    { "pop3-account" pop3-account }
+}
+{ $description "You only need to call " { $link connect } " after calling this word to reconnect to the latest accessed POP3 account." }
+{ $examples
+    { $code
+    "account connect"
+    ""
+    }
+} ;
+
+HELP: >user
+{ $values
+    { "name" "userID of the account" }
+}
+{ $description "Sends the userID of the account on the POP3 server (this could be the full e-mail address)" $nl
+"This must be the first command after " { $link connect } " if username and password have not been set with " { $link <pop3-account> } "."
+} ;
+
+HELP: >pwd
+{ $values
+    { "password" "password for the userID" }
+}
+{ $description "Sends the clear-text password for the userID. The password may be case sensitive. This must be the next command after " { $link >user } "." } ;
+
+HELP: capa
+{ $values
+    
+    { "array" array }
+}
+{ $description "Queries the mail server capabilities, as described in RFC 2449. It is advised to check for command support before calling the appropriate words (e.g. TOP UIDL)." } ;
+
+HELP: connect
+{ $values
+    { "pop3-account" pop3-account }
+}
+{ $description "Opens a network connection to the pop3 mail server with the settings given in the pop3-account slots." }
+{ $examples
+    { $code "USING: accessors pop3 ;"
+    "<pop3-account>"
+    "    \"pop.yourisp.com\" >>host"
+    "    \"username@yourisp.com\" >>user"
+    "    \"pass123\" >>pwd"
+    "connect"
+    ""
+    }
+} ;
+
+HELP: consolidate
+{ $values
+    
+    { "seq" sequence }
+}
+{ $description "Builds a sequence of email tuples, iterating over each email top and consolidating its headers with its number, uidl, and size." } ;
+
+HELP: delete
+{ $values
+    { "message#" fixnum }
+}
+{ $description "This marks message number message# for deletion from the server. This is the way to get rid of a problem causing message. It is not actually deleted until the " { $link close } " word is issued. If you lose the connection to the mail server before calling the " { $link close } " word, the server should not delete any messages. Example: 3 delete" } ;
+
+HELP: headers
+{ $values
+    
+    { "assoc" assoc }
+}
+{ $description "Gathers and associates the From:, Subject:, and To: headers of each message." } ;
+
+HELP: list
+{ $values
+    
+    { "assoc" assoc }
+}
+{ $description "Lists each message with its number and size in bytes" } ;
+
+HELP: pop3-account
+{ $class-description "A POP3 account on a POP3 server. It has the following slots:"
+    { $table
+        { { $slot "#" } "The ephemeral ordinal number of the message." }
+        { { $slot "host" } "The name or IP address of the remote host to which a POP3 connection is required." }
+        { { $slot "port" } "The POP3 server port (defaults to 110)." }
+        { { $slot "timeout" } "Maximum time in minutes to wait for a response from the POP3 server (defaults to 1 minutes)." }
+        { { $slot "user" } "The userID of the account on the POP3 server." }
+        { { $slot "pwd" } { "The clear-text password for the userID." } }
+        { { $slot "stream" } { "The duplex input/output stream wrapping the POP3 session." } }
+        { { $slot "capa" } { "A list of the mail server capabilities." } }
+        { { $slot "count" } { "Number of messages in the mailbox." } }
+        { { $slot "list" } { "A list of every message with its number and size in bytes" } }
+        { { $slot "uidls" } { "The UIDL (Unique IDentification Listing) of every message in the mailbox together with its ordinal number." } }
+        { { $slot "messages" } { "A sequence of email tuples in the mailbox containing each email's headers, number, uidl, and size." } }
+    }
+"The " { $slot "host" } " is required; the rest are either set by default or optional." $nl
+"The " { $slot "user" } " and " { $slot "pwd" } " must either be set before using " { $link connect } " or immediately after it with the " { $link >user } " and  " { $link >pwd } " words."
+} ;
+
+HELP: message
+{ $class-description "An e-mail message having the following slots:"
+    { $table
+        { { $slot "#" } "The ephemeral ordinal number of the message." }
+        { { $slot "uidl" } "The POP3 UIDL (Unique IDentification Listing) of the message." }
+        { { $slot "headers" } "The From:, Subject:, and To: headers of the message." }
+        { { $slot "from" } "The sender of the message. An e-mail address." }
+        { { $slot "to" } "The recipients of the message." }
+        { { $slot "subject" } { "The subject of the message." } }
+        { { $slot "size" } { "The size of the message in octets." } }
+    }
+} ;
+
+HELP: close
+{ $description "Deletes any messages marked for deletion, and then logs you off of the mail server. This is the last command to use." } ;
+
+HELP: retrieve
+{ $values
+    { "message#" fixnum }
+    { "seq" sequence }
+}
+{ $description "Sends message number message# to you. You should prepare for some base64 decoding. You probably want to do this with a mailer." } ;
+
+HELP: reset
+{ $description "Resets the status of the remote POP3 server. This includes resetting the status of all messages to not be deleted." } ;
+
+HELP: count
+{ $values
+    
+    { "n" fixnum }
+}
+{ $description "Gets the number of messages in the mailbox." } ;
+
+HELP: top
+{ $values
+    { "message#" fixnum } { "#lines" fixnum }
+    { "seq" sequence }
+}
+{ $description "Lists the header for message# and the first #lines of the message text. For example, 1 0 top would list just the headers for message 1, where as 1 5 top would list the headers and first 5 lines of the message text." } ;
+
+HELP: uidl
+{ $values
+    { "message#" fixnum }
+    { "uidl" string }
+}
+{ $description "Gets the POP3 UIDL (Unique IDentification Listing) of the given message#." } ;
+
+HELP: uidls
+{ $values
+    
+    { "assoc" assoc }
+}
+{ $description "Gets the POP3 UIDL (Unique IDentification Listing) of every specific message in the mailbox together with its ordinal number. UIDL provides a mechanism that avoids numbering issues between POP3 sessions by assigning a permanent and unique ID for each message." } ;
+
+ARTICLE: "pop3" "POP3 client library"
+"The " { $vocab-link "pop3" } " vocab implements a client interface to the POP3 protocol, enabling a Factor application to talk to POP3 servers. It allows interactive sessions similar to telnet ones to do maintenance on your mailbox on a POP3 mail server; to look at, and possibly delete, any problem causing message (e.g. too large, improperly formatted, etc.)." $nl
+"Word names do not necessarily map directly to POP3 commands defined in RFC1081 or RFC1939, although most commands are supported." $nl
+"This article assumes that you are familiar with the POP3 protocol."
+$nl
+"Connecting to the mail server:"
+{ $subsections connect }
+"You need to construct a pop3-account tuple first, setting at least the host slot."
+{ $subsections <pop3-account> }
+{ $examples
+    { $code "USING: accessors pop3 ;"
+    "<pop3-account>"
+    "    \"pop.yourisp.com\" >>host"
+    "    \"username@yourisp.com\" >>user"
+    "    \"pass123\" >>pwd"
+    "connect"
+    ""
+    }
+}
+$nl
+"If you do not supply the username or password, you will need to call the " { $link >user } " and " { $link >pwd } " vocabs in this order after the " { $link connect } " vocab."
+{ $examples
+    { $code "USING: accessors pop3 ;"
+    "<pop3-account>"
+    "    \"pop.yourisp.com\" >>host"
+    "connect"
+    ""
+    "\"username@yourisp.com\" >user"
+    "\"pass123\" >pwd"
+    ""
+    }
+}
+$nl
+{ $notes "Subsequent calls to the " { $link pop3-account } " thus created can be done by calling the " { $link account } " word. If you needed to reconnect to the same POP3 account after having called " { $link close } ", you only need to call " { $link account } " followed by " { $link connect } "." }
+$nl
+"Querying the mail server:"
+$nl
+"For its capabilities:"
+{ $subsections capa }
+{ $examples
+    { $code
+    "capa ."
+    "{ \"CAPA\" \"TOP\" \"UIDL\" }"
+    ""
+    }
+}
+$nl
+"For the message count:"
+{ $subsections count }
+{ $examples
+    { $code
+    "count ."
+    "2"
+    ""
+    }
+}
+$nl
+"For each message's size:"
+{ $subsections list }
+{ $examples
+    { $code
+    "list ."
+    "H{ { 1 \"1006\" } { 2 \"747\" } }"
+    ""
+    }
+}
+$nl
+"For a specific message raw header, appropriate headers, or number of lines:"
+{ $subsections top }
+{ $examples
+    { $code
+    "1 0 top ."
+    "<the raw-source of the message header is retrieved>"
+    ""
+    }
+    { $code
+    "1 5 top ."
+    "<the raw-source of the message header and its first 5 lines are retrieved>"
+    ""
+    }
+    { $code
+    "1 0 top headers ."
+    "H{"
+    "    { \"From:\" \"from@mail.com\" }"
+    "    { \"Subject:\" \"Re:\" }"
+    "    { \"To:\" \"username@host.com\" }"
+    "}"
+    ""
+    }
+}
+$nl
+"To consolidate all the messages of this account into a single association:"
+{ $subsections consolidate }
+{ $examples
+    { $code
+    "consolidate ."
+"""{
+        T{ message
+            { # 1 }
+            { uidl \"000000d547ac2fc2\" }
+            { from \"from.first@mail.com\" }
+            { to \"username@host.com\" }
+            { subject \"First subject\" }
+            { size \"1006\" }
+        }
+        T{ message
+            { # 2 }
+            { uidl \"000000d647ac2fc2\" }
+            { from \"from.second@mail.com\" }
+            { to \"username@host.com\" }
+            { subject \"Second subject\" }
+            { size \"747\" }
+        }
+}"""
+    ""
+    }
+}
+$nl
+"You may want to delete message #2 but want to make sure you are deleting the right one. You can check that message #2 has the uidl from the example above."
+{ $subsections uidl }
+{ $examples
+    { $code
+    "2 uidl ."
+    "\"000000d647ac2fc2\""
+    ""
+    }
+}
+$nl
+"Now with your mind at rest, you can delete message #2. The message is marked for deletion."
+{ $subsections delete }
+{ $examples
+    { $code
+    "2 delete"
+    ""
+    }
+}
+$nl
+"The messages marked for deletion are actually deleted only when " { $link close } " is called. This should be the last command you issue. " 
+{ $subsections close }
+{ $examples
+    { $code
+    "close"
+    ""
+    }
+}
+{ $notes "If you change your mind at any point, you can call " { $link reset } " to reset the status of all messages to not be deleted." } ;
+
+ABOUT: "pop3"
diff --git a/extra/pop3/pop3-tests.factor b/extra/pop3/pop3-tests.factor
new file mode 100644 (file)
index 0000000..8efc07c
--- /dev/null
@@ -0,0 +1,68 @@
+! Copyright (C) 2009 Elie Chaftari.
+! See http://factorcode.org/license.txt for BSD license.
+USING: concurrency.promises namespaces kernel pop3 pop3.server
+sequences tools.test accessors ;
+IN: pop3.tests
+
+FROM: pop3 => count delete ;
+
+<promise> "p1" set
+
+[ ] [ "p1" get mock-pop3-server ] unit-test
+[ ] [
+        <pop3-account>
+            "127.0.0.1" >>host
+            "p1" get ?promise >>port
+        connect
+] unit-test
+[ ] [ "username@host.com" >user ] unit-test
+[ ] [ "password" >pwd ] unit-test
+[ { "CAPA" "TOP" "UIDL" } ] [ capa ] unit-test
+[ 2 ] [ count ] unit-test
+[ H{ { 1 "1006" } { 2 "747" } } ] [ list ] unit-test
+[
+    H{
+        { "From:" "from.first@mail.com" }
+        { "Subject:" "First test with mock POP3 server" }
+        { "To:" "username@host.com" }
+    }
+] [ 1 0 top drop headers ] unit-test
+[
+    {
+        T{ message
+            { # 1 }
+            { uidl "000000d547ac2fc2" }
+            { from "from.first@mail.com" }
+            { to "username@host.com" }
+            { subject "First test with mock POP3 server" }
+            { size "1006" }
+        }
+        T{ message
+            { # 2 }
+            { uidl "000000d647ac2fc2" }
+            { from "from.second@mail.com" }
+            { to "username@host.com" }
+            { subject "Second test with mock POP3 server" }
+            { size "747" }
+        }
+    }
+] [ consolidate ] unit-test
+[ "000000d547ac2fc2" ] [ 1 uidl ] unit-test
+[ ] [ 1 delete ] unit-test
+[ ] [ reset ] unit-test
+[ ] [ close ] unit-test
+
+
+<promise> "p2" set
+
+[ ] [ "p2" get mock-pop3-server ] unit-test
+[ ] [
+        <pop3-account>
+            "127.0.0.1" >>host
+            "p2" get ?promise >>port
+            "username@host.com" >>user
+            "password" >>pwd
+        connect
+] unit-test
+[ f ] [ 1 retrieve empty? ] unit-test
+[ ] [ close ] unit-test
diff --git a/extra/pop3/pop3.factor b/extra/pop3/pop3.factor
new file mode 100644 (file)
index 0000000..030d265
--- /dev/null
@@ -0,0 +1,199 @@
+! Copyright (C) 2009 Elie Chaftari.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors annotations arrays assocs calendar combinators
+fry hashtables io io.crlf io.encodings.utf8 io.sockets
+io.streams.duplex io.timeouts kernel make math math.parser
+math.ranges namespaces prettyprint sequences splitting
+strings ;
+IN: pop3
+
+TUPLE: pop3-account
+# host port timeout user pwd stream capa count list
+uidls messages ;
+
+: <pop3-account> ( -- pop3-account )
+    pop3-account new
+        110 >>port
+        1 minutes >>timeout ;
+
+: account ( -- pop3-account ) pop3-account get ;
+
+TUPLE: message # uidl headers from to subject size ;
+
+<PRIVATE
+
+: stream ( -- duplex-stream ) account stream>> ;
+
+: <message> ( -- message ) message new ; inline
+
+TUPLE: raw-source top headers content ;
+
+: <raw-source> ( -- raw-source ) raw-source new ; inline
+
+: raw ( -- raw-source ) raw-source get ;
+
+: set-read-timeout ( -- )
+    stream [
+        account timeout>> timeouts
+    ] with-stream* ;
+
+: get-ok ( -- )
+    stream [
+        readln dup "+OK" head? [ drop ] [ throw ] if
+    ] with-stream* ;
+
+: get-ok-and-total ( -- total )
+    stream [
+        readln dup "+OK" head? [
+            " " split second string>number dup account (>>count)
+        ] [ throw ] if
+    ] with-stream* ;
+
+: get-ok-and-uidl ( -- uidl )
+    stream [
+        readln dup "+OK" head? [
+            " " split last
+        ] [ throw ] if
+    ] with-stream* ;
+
+: command ( string -- ) write crlf flush get-ok ;
+
+: command-and-total ( string -- total ) write crlf flush
+    get-ok-and-total ;
+
+: command-and-uidl ( string -- uidl ) write crlf flush
+    get-ok-and-uidl ;
+
+: associate-split ( seq -- assoc )
+    [ " " split1 ] H{ } map>assoc ;
+
+: split-map ( seq -- assoc )
+    associate-split [ [ string>number ] dip ] assoc-map ;
+
+: (readlns) ( -- )
+    readln dup "." = [ , ] dip [ (readlns) ] unless ;
+
+: readlns ( -- seq ) [ (readlns) ] { } make but-last ;
+
+: (list) ( -- )
+    stream [
+        "LIST" command
+        readlns account (>>list)
+    ] with-stream* ;
+
+: (uidls) ( -- )
+    stream [
+        "UIDL" command
+        readlns account (>>uidls)
+    ] with-stream* ;
+
+PRIVATE>
+
+: >user ( name -- )
+    [ stream ] dip '[
+        "USER " _ append command
+    ] with-stream* ;
+
+: >pwd ( password -- )
+    [ stream ] dip '[
+        "PASS " _ append command
+    ] with-stream* ;
+
+: connect ( pop3-account -- )
+    [
+        [ host>> ] [ port>> ] bi
+        <inet> utf8 <client> drop
+    ] keep swap >>stream
+    {
+        [ pop3-account set ]
+        [ user>> [ >user ] when* ]
+        [ pwd>> [ >pwd ] when* ]
+    } cleave
+    set-read-timeout
+    get-ok ;
+
+: capa ( -- array )
+    stream [
+        "CAPA" command
+        readlns dup account (>>capa)
+    ] with-stream* ;
+
+: count ( -- n )
+    stream [
+        "STAT" command-and-total
+    ] with-stream* ;
+
+: list ( -- assoc )
+    (list) account list>> split-map ;
+
+: uidl ( message# -- uidl )
+    [ stream ] dip '[
+        "UIDL " _ number>string append command-and-uidl
+    ] with-stream* ;
+
+: uidls ( -- assoc )
+    (uidls) account uidls>> split-map ;
+
+: top ( message# #lines -- seq )
+    <raw-source> raw-source set
+    [ stream ] 2dip '[
+        "TOP " _ number>string append " "
+        append _ number>string append
+        command
+        readlns dup raw (>>top)
+    ] with-stream* ;
+
+: headers ( -- assoc )
+    raw top>> {
+        [
+            [ dup "From:" head?
+                [ raw [ swap suffix ] change-headers drop ]
+                [ drop ] if
+            ] each
+        ]
+        [
+            [ dup "To:" head?
+                [ raw [ swap suffix ] change-headers drop ]
+                [ drop ] if
+            ] each
+        ]
+        [
+            [ dup "Subject:" head?
+                [ raw [ swap suffix ] change-headers drop ]
+                [ drop ] if
+            ] each
+        ]
+    } cleave raw headers>> associate-split ;
+
+: retrieve ( message# -- seq )
+    [ stream ] dip '[
+        "RETR " _ number>string append command
+        readlns dup raw (>>content)
+    ] with-stream* ;
+
+: delete ( message# -- )
+    [ stream ] dip '[
+        "DELE " _ number>string append command
+    ] with-stream* ;
+
+: reset ( -- )
+    stream [ "RSET" command ] with-stream* ;
+
+: consolidate ( -- seq )
+    count zero? [ "No mail for account." ] [
+        1 account count>> [a,b] [
+            {
+                [ 0 top drop ]
+                [ <message> swap >># ]
+                [ uidls at >>uidl ]
+                [ list at >>size ]
+            } cleave
+            "From:" headers at >>from
+            "To:" headers at >>to
+            "Subject:" headers at >>subject
+            account [ swap suffix ] change-messages drop
+        ] each account messages>>
+    ] if ;
+
+: close ( -- )
+    stream [ "QUIT" command ] with-stream ;
diff --git a/extra/pop3/server/server.factor b/extra/pop3/server/server.factor
new file mode 100644 (file)
index 0000000..775a457
--- /dev/null
@@ -0,0 +1,266 @@
+! Copyright (C) 2009 Elie Chaftari.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors calendar combinators concurrency.promises
+destructors fry io io.crlf io.encodings.utf8 io.sockets
+io.sockets.secure.unix.debug io.streams.duplex io.timeouts
+kernel locals math.parser namespaces prettyprint sequences
+splitting threads ;
+IN: pop3.server
+
+! Mock POP3 server for testing purposes.
+
+! $ telnet 127.0.0.1 (start-pop3-server outputs listening port)
+! Trying 127.0.0.1...
+! Connected to localhost.
+! Escape character is '^]'.
+! +OK POP3 server ready
+! USER username@host.com
+! +OK Password required
+! PASS password
+! +OK Logged in
+! STAT  
+! +OK 2 1753
+! LIST
+! +OK 2 messages:
+! 1 1006
+! 2 747
+! .
+! UIDL 1
+! +OK 1 000000d547ac2fc2
+! TOP 1 0
+! +OK
+! Return-Path: <from.first@mail.com>
+! Delivered-To: username@host.com
+! Received: from User.local ([66.249.71.201])
+!      by mail.isp.com  with ESMTP id n95BgmJg012655
+!      for <username@host.com>; Mon, 5 Oct 2009 14:42:59 +0300
+! Date: Mon, 5 Oct 2009 14:42:31 +0300
+! Message-Id: <4273644000823950677-1254742951070701@User.local>
+! MIME-Version: 1.0
+! Content-Transfer-Encoding: base64
+! From: from.first@mail.com
+! To: username@host.com
+! Subject: First test with mock POP3 server
+! Content-Type: text/plain; charset=UTF-8
+! 
+! .
+! DELE 1
+! +OK Marked for deletion
+! QUIT
+! +OK POP3 server closing connection
+! Connection closed by foreign host.
+
+: process ( -- )
+    read-crlf {
+        {
+            [ dup "USER" head? ]
+            [
+                 
+                "+OK Password required\r\n"
+                write flush t
+            ]
+        }
+        {
+            [ dup "PASS" head? ]
+            [
+                "+OK Logged in\r\n"
+                write flush t
+            ]
+        }
+        {
+            [ dup "CAPA" = ]
+            [
+                "+OK\r\nCAPA\r\nTOP\r\nUIDL\r\n.\r\n"
+                write flush t
+            ]
+        }
+        {
+            [ dup "STAT" = ]
+            [
+                "+OK 2 1753\r\n"
+                write flush t
+            ]
+        }       
+        {
+            [ dup "LIST" = ]
+            [
+                "+OK 2 messages:\r\n1 1006\r\n2 747\r\n.\r\n"
+                write flush t
+            ]
+        }
+        {
+            [ dup "UIDL" head? ]
+            [
+                {
+                    {
+                        [ dup "UIDL 1" = ]
+                        [
+                            "+OK 1 000000d547ac2fc2\r\n"
+                            write flush t
+                        ]
+                    }
+                    {
+                        [ dup "UIDL 2" = ]
+                        [
+                            "+OK 2 000000d647ac2fc2\r\n"
+                            write flush t
+                        ]
+                    }
+                        [
+                            "+OK\r\n1 000000d547ac2fc2\r\n2 000000d647ac2fc2\r\n.\r\n"
+                            write flush t
+                        ]
+                } cond
+            ]
+        }
+        {
+            [ dup "TOP" head? ]
+            [
+                {
+                    {
+                        [ dup "TOP 1 0" = ]
+                        [
+"""+OK
+Return-Path: <from.first@mail.com>
+Delivered-To: username@host.com
+Received: from User.local ([66.249.71.201])
+       by mail.isp.com  with ESMTP id n95BgmJg012655
+       for <username@host.com>; Mon, 5 Oct 2009 14:42:59 +0300
+Date: Mon, 5 Oct 2009 14:42:31 +0300
+Message-Id: <4273644000823950677-1254742951070701@User.local>
+MIME-Version: 1.0
+Content-Transfer-Encoding: base64
+From: from.first@mail.com
+To: username@host.com
+Subject: First test with mock POP3 server
+Content-Type: text/plain; charset=UTF-8
+
+.
+"""
+                            write flush t
+                        ]
+                    }
+                    {
+                        [ dup "TOP 2 0" = ]
+                        [
+"""+OK
+Return-Path: <from.second@mail.com>
+Delivered-To: username@host.com
+Received: from User.local ([66.249.71.201])
+       by mail.isp.com  with ESMTP id n95BgmJg012655
+       for <username@host.com>; Mon, 5 Oct 2009 14:44:09 +0300
+Date: Mon, 5 Oct 2009 14:43:11 +0300
+Message-Id: <9783644000823934577-4563442951070856@User.local>
+MIME-Version: 1.0
+Content-Transfer-Encoding: base64
+From: from.second@mail.com
+To: username@host.com
+Subject: Second test with mock POP3 server
+Content-Type: text/plain; charset=UTF-8
+
+.
+"""
+                            write flush t
+                        ]
+                    }
+                } cond
+            ]
+        }
+        {
+            [ dup "RETR" head? ]
+            [
+                {
+                    {
+                        [ dup "RETR 1" = ]
+                        [
+"""+OK
+Return-Path: <from.first@mail.com>
+Delivered-To: username@host.com
+Received: from User.local ([66.249.71.201])
+       by mail.isp.com  with ESMTP id n95BgmJg012655
+       for <username@host.com>; Mon, 5 Oct 2009 14:42:59 +0300
+Date: Mon, 5 Oct 2009 14:42:31 +0300
+Message-Id: <4273644000823950677-1254742951070701@User.local>
+MIME-Version: 1.0
+Content-Transfer-Encoding: base64
+From: from.first@mail.com
+To: username@host.com
+Subject: First test with mock POP3 server
+Content-Type: text/plain; charset=UTF-8
+
+This is the body of the first test. 
+.
+"""
+                            write flush t
+                        ]
+                    }
+                    {
+                        [ dup "RETR 2" = ]
+                        [
+"""+OK
+Return-Path: <from.second@mail.com>
+Delivered-To: username@host.com
+Received: from User.local ([66.249.71.201])
+       by mail.isp.com  with ESMTP id n95BgmJg012655
+       for <username@host.com>; Mon, 5 Oct 2009 14:44:09 +0300
+Date: Mon, 5 Oct 2009 14:43:11 +0300
+Message-Id: <9783644000823934577-4563442951070856@User.local>
+MIME-Version: 1.0
+Content-Transfer-Encoding: base64
+From: from.second@mail.com
+To: username@host.com
+Subject: Second test with mock POP3 server
+Content-Type: text/plain; charset=UTF-8
+
+This is the body of the second test. 
+.
+"""
+                            write flush t
+                        ]
+                    }
+                } cond
+            ]
+        }
+        {
+            [ dup "DELE" head? ]
+            [
+                "+OK Marked for deletion\r\n"
+                write flush t
+            ]
+        }
+        {
+            [ dup "RSET" = ]
+            [
+                "+OK\r\n"
+                write flush t
+            ]
+        }
+        {
+            [ dup "QUIT" = ]
+            [
+                "+OK POP3 server closing connection\r\n"
+                write flush f
+            ]
+        }
+    } cond nip [ process ] when ;
+
+:: mock-pop3-server ( promise -- )
+    #! Store the port we are running on in the promise.
+    [
+        [
+            "127.0.0.1" 0 <inet4> utf8 <server> [
+            dup addr>> port>> promise fulfill
+                accept drop [
+                    1 minutes timeouts
+                    "+OK POP3 server ready\r\n" write flush
+                    process
+                    global [ flush ] bind
+                ] with-stream
+            ] with-disposal
+        ] with-test-context
+    ] in-thread ;
+
+: start-pop3-server ( -- )
+    <promise> [ mock-pop3-server ] keep ?promise
+    number>string "POP3 server started on port "
+    prepend print ;
diff --git a/extra/pop3/server/summary.txt b/extra/pop3/server/summary.txt
new file mode 100644 (file)
index 0000000..56d261e
--- /dev/null
@@ -0,0 +1 @@
+POP3 server for testing purposes
diff --git a/extra/pop3/summary.txt b/extra/pop3/summary.txt
new file mode 100644 (file)
index 0000000..387a099
--- /dev/null
@@ -0,0 +1 @@
+Retrieve mail via POP3
diff --git a/extra/pop3/tags.txt b/extra/pop3/tags.txt
new file mode 100644 (file)
index 0000000..80d57bb
--- /dev/null
@@ -0,0 +1,2 @@
+enterprise
+network
index 9995e434e7cec04337409aa2c633f36f757e71b3..63d6eac8b438bf59879faacbc440492f8e61183c 100644 (file)
@@ -31,7 +31,7 @@ PRIVATE>
     V{ 0 } clone 1 rot (fib-upto) ;
 
 : euler002 ( -- answer )
-    4000000 fib-upto [ even? ] filter sum ;
+    4,000,000 fib-upto [ even? ] filter sum ;
 
 ! [ euler002 ] 100 ave-time
 ! 0 ms ave run time - 0.22 SD (100 trials)
@@ -41,11 +41,11 @@ PRIVATE>
 ! -------------------
 
 : fib-upto* ( n -- seq )
-    0 1 [ pick over >= ] [ tuck + dup ] produce [ 3drop ] dip
+    0 1 [ pick over >= ] [ [ nip ] 2keep + dup ] produce [ 3drop ] dip
     but-last-slice { 0 1 } prepend ;
 
 : euler002a ( -- answer )
-    4000000 fib-upto* [ even? ] filter sum ;
+    4,000,000 fib-upto* [ even? ] filter sum ;
 
 ! [ euler002a ] 100 ave-time
 ! 0 ms ave run time - 0.2 SD (100 trials)
@@ -54,7 +54,7 @@ PRIVATE>
 <PRIVATE
 
 : next-fibs ( x y -- y x+y )
-    tuck + ;
+    [ nip ] [ + ] 2bi ;
 
 : ?retotal ( total fib- fib+ -- retotal fib- fib+ )
     dup even? [ [ nip + ] 2keep ] when ;
index 53513691ff795147030153c9568818e9042a7d0e..827e478da02bfa14e4c79557cc51e24b2cb1d9a2 100644 (file)
@@ -24,7 +24,7 @@ IN: project-euler.017
 ! --------
 
 : euler017 ( -- answer )
-    1000 [1,b] SBUF" " clone [ number>text over push-all ] reduce [ Letter? ] count ;
+    1000 [1,b] SBUF" " clone [ number>text append! ] reduce [ Letter? ] count ;
 
 ! [ euler017 ] 100 ave-time
 ! 15 ms ave run time - 1.71 SD (100 trials)
index 0401aad9be97579003073d1cf2887543989869ef..165d463a46f8d342c6cf9652ce3f70051ca89ffc 100644 (file)
@@ -30,7 +30,7 @@ IN: project-euler.021
     { [ = not ] [ sum-proper-divisors = ] } 2&& ;
 
 : euler021 ( -- answer )
-    10000 [1,b] [ dup amicable? [ drop 0 ] unless ] sigma ;
+    10000 [1,b] [ dup amicable? [ drop 0 ] unless ] map-sum ;
 
 ! [ euler021 ] 100 ave-time
 ! 335 ms ave run time - 18.63 SD (100 trials)
index 6dc284f802150b8dac480874ef51592b4fc1bb23..b134d369de13febc5ad1d172967aa0ee72eef53e 100644 (file)
@@ -33,7 +33,7 @@ IN: project-euler.028
     dup 1 = [ [ sq 4 * ] [ 6 * ] bi - 6 + ] unless ;
 
 : sum-diags ( n -- sum )
-    1 swap 2 <range> [ sum-corners ] sigma ;
+    1 swap 2 <range> [ sum-corners ] map-sum ;
 
 PRIVATE>
 
index b689df50bbd9e2d1c2979c3bd534885fcb9e867f..25d78d9465f58b533dcffe60980e7cdd6151b89a 100644 (file)
@@ -33,7 +33,7 @@ IN: project-euler.030
 <PRIVATE
 
 : sum-fifth-powers ( n -- sum )
-    number>digits [ 5 ^ ] sigma ;
+    number>digits [ 5 ^ ] map-sum ;
 
 PRIVATE>
 
index f7a4865da7aea861aa52fed58245a3b040498add..959c66fea4b0feed5b5a311ecb9ad849d7b8ee0d 100644 (file)
@@ -34,7 +34,7 @@ IN: project-euler.034
     { 1 1 2 6 24 120 720 5040 40320 362880 } nth ;
 
 : factorion? ( n -- ? )
-    dup number>digits [ digit-factorial ] sigma = ;
+    dup number>digits [ digit-factorial ] map-sum = ;
 
 PRIVATE>
 
index dd700510824ab3afd782d663a73accaf6e116a10..34b4cd91faa5d42dfdcd55fc07250d5c4d9df7b0 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 append! ] 2keep 1 + (concat-product)
     ] if ;
 
 : concat-product ( n -- m )
index a60714357ea2578dc36f4b460ebfda2cfcfb9b3a..09185e9a64609100394d39fccef02c9d087cc677 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 append! [ 1 + ] 2dip (concat-upto)
     ] [
         2nip
     ] if ;
index bea7313abd214ede4d5c55c6761f8d97464620f6..cf4955750636a769bdb4ba2e88086991ae5109e9 100644 (file)
@@ -92,7 +92,7 @@ PRIVATE>
 PRIVATE>
 
 : euler043a ( -- answer )
-    interesting-pandigitals [ 10 digits>integer ] sigma ;
+    interesting-pandigitals [ 10 digits>integer ] map-sum ;
 
 ! [ euler043a ] 100 ave-time
 ! 10 ms ave run time - 1.37 SD (100 trials)
index fde3fa6026af4a0adbfad6d9e50c53025d9b69e0..d0e267f73c834c98b7a428f172b637e4e8f90c40 100644 (file)
@@ -18,7 +18,7 @@ IN: project-euler.048
 ! --------
 
 : euler048 ( -- answer )
-    1000 [1,b] [ dup ^ ] sigma 10 10^ mod ;
+    1000 [1,b] [ dup ^ ] map-sum 10 10^ mod ;
 
 ! [ euler048 ] 100 ave-time
 ! 276 ms run / 1 ms GC ave time - 100 trials
index 111b8147fb59807cb18c03ec2e8234b92891e0e8..faca6a8ad56ce5c372767e0683282937ffb4f226 100644 (file)
@@ -27,7 +27,7 @@ IN: project-euler.053
 ! --------
 
 : euler053 ( -- answer )
-    23 100 [a,b] [ dup [ nCk 1000000 > ] with count ] sigma ;
+    23 100 [a,b] [ dup [ nCk 1000000 > ] with count ] map-sum ;
 
 ! [ euler053 ] 100 ave-time
 ! 52 ms ave run time - 4.44 SD (100 trials)
diff --git a/extra/project-euler/062/062-tests.factor b/extra/project-euler/062/062-tests.factor
new file mode 100644 (file)
index 0000000..d8e0b96
--- /dev/null
@@ -0,0 +1,4 @@
+USING: project-euler.062 tools.test ;
+IN: project-euler.062.tests
+
+[ 127035954683 ] [ euler062 ] unit-test
diff --git a/extra/project-euler/062/062.factor b/extra/project-euler/062/062.factor
new file mode 100644 (file)
index 0000000..037cdc1
--- /dev/null
@@ -0,0 +1,54 @@
+! Copyright (c) 2009 Guillaume Nargeot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays assocs hashtables kernel math math.functions
+project-euler.common sequences sorting ;
+IN: project-euler.062
+
+! http://projecteuler.net/index.php?section=problems&id=062
+
+! DESCRIPTION
+! -----------
+
+! The cube, 41063625 (345^3), can be permuted to produce two
+! other cubes: 56623104 (384^3) and 66430125 (405^3). In
+! fact, 41063625 is the smallest cube which has exactly three
+! permutations of its digits which are also cube.
+
+! Find the smallest cube for which exactly five permutations of
+! its digits are cube.
+
+
+! SOLUTION
+! --------
+
+<PRIVATE
+
+: cube ( n -- n^3 ) 3 ^ ; inline
+: >key ( n -- k ) cube number>digits natural-sort ; inline
+: has-entry? ( n assoc -- ? ) [ >key ] dip key? ; inline
+
+: (euler062) ( n assoc -- n )
+    2dup has-entry? [
+        2dup [ >key ] dip
+        [ dup 0 swap [ 1 + ] change-nth ] change-at
+        2dup [ >key ] dip at first 5 =
+        [ 
+            [ >key ] dip at second
+        ] [
+            [ 1 + ] dip (euler062)
+        ] if
+    ] [
+        2dup 1 pick cube 2array -rot
+        [ >key ] dip set-at [ 1 + ] dip
+        (euler062)
+    ] if ;
+
+PRIVATE>
+
+: euler062 ( -- answer )
+    1 1 <hashtable> (euler062) ;
+
+! [ euler062 ] 100 ave-time
+! 78 ms ave run time - 0.9 SD (100 trials)
+
+SOLUTION: euler062
diff --git a/extra/project-euler/062/authors.txt b/extra/project-euler/062/authors.txt
new file mode 100644 (file)
index 0000000..6eb6698
--- /dev/null
@@ -0,0 +1 @@
+Guillaume Nargeot
index 80e3990a2484bea2dedc95a52ae717aad046b925..59552db882cd75a9ee01ea24126577d55ba7fc42 100644 (file)
@@ -29,7 +29,7 @@ IN: project-euler.063
 ! Round down since we already know that particular value of n is no good.
 
 : euler063 ( -- answer )
-    9 [1,b] [ log [ 10 log dup ] dip - /i ] sigma ;
+    9 [1,b] [ log [ 10 log dup ] dip - /i ] map-sum ;
 
 ! [ euler063 ] 100 ave-time
 ! 0 ms ave run time - 0.0 SD (100 trials)
index 9fab6788bdb42687c359394ad06a8a8daac9c099..cdd11bb55c892b4fb6d71bce91948302f09d62cc 100644 (file)
@@ -30,7 +30,7 @@ IN: project-euler.072
 ! The answer can be found by adding totient(n) for 2 ≤ n ≤ 1e6
 
 : euler072 ( -- answer )
-    2 1000000 [a,b] [ totient ] sigma ;
+    2 1000000 [a,b] [ totient ] map-sum ;
 
 ! [ euler072 ] 100 ave-time
 ! 5274 ms ave run time - 102.7 SD (100 trials)
index 8ab0b171904a2018028cca711e23847fe9fca93b..b63a71946e8503ab1b33899dce33f638b98d2f7c 100644 (file)
@@ -33,13 +33,12 @@ IN: project-euler.073
 <PRIVATE
 
 :: (euler073) ( counter limit lo hi -- counter' )
-    [let | m [ lo hi mediant ] |
-        m denominator limit <= [
-            counter 1 +
-            limit lo m (euler073)
-            limit m hi (euler073)
-        ] [ counter ] if
-    ] ;
+    lo hi mediant :> m
+    m denominator limit <= [
+        counter 1 +
+        limit lo m (euler073)
+        limit m hi (euler073)
+    ] [ counter ] if ;
 
 PRIVATE>
 
index 7f0a54a43cf951d08a86725b1387df149c5873a8..1fff789cf74af879d63cc0e41353395e93c51f09 100644 (file)
@@ -48,7 +48,7 @@ IN: project-euler.074
     { 1 1 2 6 24 120 720 5040 40320 362880 } nth ;
 
 : digits-factorial-sum ( n -- n )
-    number>digits [ digit-factorial ] sigma ;
+    number>digits [ digit-factorial ] map-sum ;
 
 : chain-length ( n -- n )
     61 <hashtable>
diff --git a/extra/project-euler/089/089-tests.factor b/extra/project-euler/089/089-tests.factor
new file mode 100644 (file)
index 0000000..9b26b34
--- /dev/null
@@ -0,0 +1,4 @@
+USING: project-euler.089 tools.test ;
+IN: project-euler.089.tests
+
+[ 743 ] [ euler089 ] unit-test
diff --git a/extra/project-euler/089/089.factor b/extra/project-euler/089/089.factor
new file mode 100644 (file)
index 0000000..34b40a7
--- /dev/null
@@ -0,0 +1,48 @@
+! Copyright (c) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.ascii io.files kernel math
+project-euler.common roman sequences ;
+IN: project-euler.089
+
+! http://projecteuler.net/index.php?section=problems&id=089
+
+! DESCRIPTION
+! -----------
+
+! The rules for writing Roman numerals allow for many ways of writing
+! each number (see FAQ: Roman Numerals). However, there is always a
+! "best" way of writing a particular number.
+
+! For example, the following represent all of the legitimate ways of
+! writing the number sixteen:
+
+! IIIIIIIIIIIIIIII
+! VIIIIIIIIIII
+! VVIIIIII
+! XIIIIII
+! VVVI
+! XVI
+
+! The last example being considered the most efficient, as it uses
+! the least number of numerals.
+
+! The 11K text file, roman.txt (right click and 'Save Link/Target As...'),
+! contains one thousand numbers written in valid, but not necessarily
+! minimal, Roman numerals; that is, they are arranged in descending units
+! and obey the subtractive pair rule (see FAQ for the definitive rules
+! for this problem).
+
+! Find the number of characters saved by writing each of these in their minimal form.
+
+! SOLUTION
+! --------
+
+: euler089 ( -- n )
+    "resource:extra/project-euler/089/roman.txt" ascii file-lines
+    [ ] [ [ roman> >roman ] map ] bi
+    [ [ length ] map-sum ] bi@ - ;
+
+! [ euler089 ] 100 ave-time
+! 14 ms ave run time - 0.27 SD (100 trials)
+
+SOLUTION: euler089
diff --git a/extra/project-euler/089/authors.txt b/extra/project-euler/089/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/project-euler/089/roman.txt b/extra/project-euler/089/roman.txt
new file mode 100644 (file)
index 0000000..721ab99
--- /dev/null
@@ -0,0 +1,1000 @@
+MMMMDCLXXII\r
+MMDCCCLXXXIII\r
+MMMDLXVIIII\r
+MMMMDXCV\r
+DCCCLXXII\r
+MMCCCVI\r
+MMMCDLXXXVII\r
+MMMMCCXXI\r
+MMMCCXX\r
+MMMMDCCCLXXIII\r
+MMMCCXXXVII\r
+MMCCCLXXXXIX\r
+MDCCCXXIIII\r
+MMCXCVI\r
+CCXCVIII\r
+MMMCCCXXXII\r
+MDCCXXX\r
+MMMDCCCL\r
+MMMMCCLXXXVI\r
+MMDCCCXCVI\r
+MMMDCII\r
+MMMCCXII\r
+MMMMDCCCCI\r
+MMDCCCXCII\r
+MDCXX\r
+CMLXXXVII\r
+MMMXXI\r
+MMMMCCCXIV\r
+MLXXII\r
+MCCLXXVIIII\r
+MMMMCCXXXXI\r
+MMDCCCLXXII\r
+MMMMXXXI\r
+MMMDCCLXXX\r
+MMDCCCLXXIX\r
+MMMMLXXXV\r
+MCXXI\r
+MDCCCXXXVII\r
+MMCCCLXVII\r
+MCDXXXV\r
+CCXXXIII\r
+CMXX\r
+MMMCLXIV\r
+MCCCLXXXVI\r
+DCCCXCVIII\r
+MMMDCCCCXXXIV\r
+CDXVIIII\r
+MMCCXXXV\r
+MDCCCXXXII\r
+MMMMD\r
+MMDCCLXIX\r
+MMMMCCCLXXXXVI\r
+MMDCCXLII\r
+MMMDCCCVIIII\r
+DCCLXXXIIII\r
+MDCCCCXXXII\r
+MMCXXVII\r
+DCCCXXX\r
+CCLXIX\r
+MMMXI\r
+MMMMCMLXXXXVIII\r
+MMMMDLXXXVII\r
+MMMMDCCCLX\r
+MMCCLIV\r
+CMIX\r
+MMDCCCLXXXIIII\r
+CLXXXII\r
+MMCCCCXXXXV\r
+MMMMDLXXXVIIII\r
+MMMDCCCXXI\r
+MMDCCCCLXXVI\r
+MCCCCLXX\r
+MMCDLVIIII\r
+MMMDCCCLIX\r
+MMMMCCCCXIX\r
+MMMDCCCLXXV\r
+XXXI\r
+CDLXXXIII\r
+MMMCXV\r
+MMDCCLXIII\r
+MMDXXX\r
+MMMMCCCLVII\r
+MMMDCI\r
+MMMMCDLXXXIIII\r
+MMMMCCCXVI\r
+CCCLXXXVIII\r
+MMMMCML\r
+MMMMXXIV\r
+MMMCCCCXXX\r
+DCCX\r
+MMMCCLX\r
+MMDXXXIII\r
+CCCLXIII\r
+MMDCCXIII\r
+MMMCCCXLIV\r
+CLXXXXI\r
+CXVI\r
+MMMMCXXXIII\r
+CLXX\r
+DCCCXVIII\r
+MLXVII\r
+DLXXXX\r
+MMDXXI\r
+MMMMDLXXXXVIII\r
+MXXII\r
+LXI\r
+DCCCCXLIII\r
+MMMMDV\r
+MMMMXXXIV\r
+MDCCCLVIII\r
+MMMCCLXXII\r
+MMMMDCCXXXVI\r
+MMMMLXXXIX\r
+MDCCCLXXXI\r
+MMMMDCCCXV\r
+MMMMCCCCXI\r
+MMMMCCCLIII\r
+MDCCCLXXI\r
+MMCCCCXI\r
+MLXV\r
+MMCDLXII\r
+MMMMDXXXXII\r
+MMMMDCCCXL\r
+MMMMCMLVI\r
+CCLXXXIV\r
+MMMDCCLXXXVI\r
+MMCLII\r
+MMMCCCCXV\r
+MMLXXXIII\r
+MMMV\r
+MMMV\r
+DCCLXII\r
+MMDCCCCXVI\r
+MMDCXLVIII\r
+CCLIIII\r
+CCCXXV\r
+MMDCCLXXXVIIII\r
+MMMMDCLXXVIII\r
+MMMMDCCCXCI\r
+MMMMCCCXX\r
+MMCCXLV\r
+MMMDCCCLXIX\r
+MMCCLXIIII\r
+MMMDCCCXLIX\r
+MMMMCCCLXIX\r
+CMLXXXXI\r
+MCMLXXXIX\r
+MMCDLXI\r
+MMDCLXXVIII\r
+MMMMDCCLXI\r
+MCDXXV\r
+DL\r
+CCCLXXII\r
+MXVIIII\r
+MCCCCLXVIII\r
+CIII\r
+MMMDCCLXXIIII\r
+MMMDVIII\r
+MMMMCCCLXXXXVII\r
+MMDXXVII\r
+MMDCCLXXXXV\r
+MMMMCXLVI\r
+MMMDCCLXXXII\r
+MMMDXXXVI\r
+MCXXII\r
+CLI\r
+DCLXXXIX\r
+MMMCLI\r
+MDCLXIII\r
+MMMMDCCXCVII\r
+MMCCCLXXXV\r
+MMMDCXXVIII\r
+MMMCDLX\r
+MMMCMLII\r
+MMMIV\r
+MMMMDCCCLVIII\r
+MMMDLXXXVIII\r
+MCXXIV\r
+MMMMLXXVI\r
+CLXXIX\r
+MMMCCCCXXVIIII\r
+DCCLXXXV\r
+MMMDCCCVI\r
+LI\r
+CLXXXVI\r
+MMMMCCCLXXVI\r
+MCCCLXVI\r
+CCXXXIX\r
+MMDXXXXI\r
+MMDCCCXLI\r
+DCCCLXXXVIII\r
+MMMMDCCCIV\r
+MDCCCCXV\r
+MMCMVI\r
+MMMMCMLXXXXV\r
+MMDCCLVI\r
+MMMMCCXLVIII\r
+DCCCCIIII\r
+MMCCCCIII\r
+MMMDCCLXXXVIIII\r
+MDCCCLXXXXV\r
+DVII\r
+MMMV\r
+DCXXV\r
+MMDCCCXCV\r
+DCVIII\r
+MMCDLXVI\r
+MCXXVIII\r
+MDCCXCVIII\r
+MMDCLX\r
+MMMDCCLXIV\r
+MMCDLXXVII\r
+MMDLXXXIIII\r
+MMMMCCCXXII\r
+MMMDCCCXLIIII\r
+DCCCCLXVII\r
+MMMCLXXXXIII\r
+MCCXV\r
+MMMMDCXI\r
+MMMMDCLXXXXV\r
+MMMCCCLII\r
+MMCMIX\r
+MMDCCXXV\r
+MMDLXXXVI\r
+MMMMDCXXVIIII\r
+DCCCCXXXVIIII\r
+MMCCXXXIIII\r
+MMDCCLXXVIII\r
+MDCCLXVIIII\r
+MMCCLXXXV\r
+MMMMDCCCLXXXVIII\r
+MMCMXCI\r
+MDXLII\r
+MMMMDCCXIV\r
+MMMMLI\r
+DXXXXIII\r
+MMDCCXI\r
+MMMMCCLXXXIII\r
+MMMDCCCLXXIII\r
+MDCLVII\r
+MMCD\r
+MCCCXXVII\r
+MMMMDCCIIII\r
+MMMDCCXLVI\r
+MMMCLXXXVII\r
+MMMCCVIIII\r
+MCCCCLXXIX\r
+DL\r
+DCCCLXXVI\r
+MMDXCI\r
+MMMMDCCCCXXXVI\r
+MMCII\r
+MMMDCCCXXXXV\r
+MMMCDXLV\r
+MMDCXXXXIV\r
+MMD\r
+MDCCCLXXXX\r
+MMDCXLIII\r
+MMCCXXXII\r
+MMDCXXXXVIIII\r
+DCCCLXXI\r
+MDXCVIIII\r
+MMMMCCLXXVIII\r
+MDCLVIIII\r
+MMMCCCLXXXIX\r
+MDCLXXXV\r
+MDLVIII\r
+MMMMCCVII\r
+MMMMDCXIV\r
+MMMCCCLXIIII\r
+MMIIII\r
+MMMMCCCLXXIII\r
+CCIII\r
+MMMCCLV\r
+MMMDXIII\r
+MMMCCCXC\r
+MMMDCCCXXI\r
+MMMMCCCCXXXII\r
+CCCLVI\r
+MMMCCCLXXXVI\r
+MXVIIII\r
+MMMCCCCXIIII\r
+CLXVII\r
+MMMCCLXX\r
+CCCCLXIV\r
+MMXXXXII\r
+MMMMCCLXXXX\r
+MXL\r
+CCXVI\r
+CCCCLVIIII\r
+MMCCCII\r
+MCCCLVIII\r
+MMMMCCCX\r
+MCDLXXXXIV\r
+MDCCCXIII\r
+MMDCCCXL\r
+MMMMCCCXXIII\r
+DXXXIV\r
+CVI\r
+MMMMDCLXXX\r
+DCCCVII\r
+MMCMLXIIII\r
+MMMDCCCXXXIII\r
+DCCC\r
+MDIII\r
+MMCCCLXVI\r
+MMMCCCCLXXI\r
+MMDCCCCXVIII\r
+CCXXXVII\r
+CCCXXV\r
+MDCCCXII\r
+MMMCMV\r
+MMMMCMXV\r
+MMMMDCXCI\r
+DXXI\r
+MMCCXLVIIII\r
+MMMMCMLII\r
+MDLXXX\r
+MMDCLXVI\r
+CXXI\r
+MMMDCCCLIIII\r
+MMMCXXI\r
+MCCIII\r
+MMDCXXXXI\r
+CCXCII\r
+MMMMDXXXV\r
+MMMCCCLXV\r
+MMMMDLXV\r
+MMMCCCCXXXII\r
+MMMCCCVIII\r
+DCCCCLXXXXII\r
+MMCLXIV\r
+MMMMCXI\r
+MLXXXXVII\r
+MMMCDXXXVIII\r
+MDXXII\r
+MLV\r
+MMMMDLXVI\r
+MMMCXII\r
+XXXIII\r
+MMMMDCCCXXVI\r
+MMMLXVIIII\r
+MMMLX\r
+MMMCDLXVII\r
+MDCCCLVII\r
+MMCXXXVII\r
+MDCCCCXXX\r
+MMDCCCLXIII\r
+MMMMDCXLIX\r
+MMMMCMXLVIII\r
+DCCCLXXVIIII\r
+MDCCCLIII\r
+MMMCMLXI\r
+MMMMCCLXI\r
+MMDCCCLIII\r
+MMMDCCCVI\r
+MMDXXXXIX\r
+MMCLXXXXV\r
+MMDXXX\r
+MMMXIII\r
+DCLXXIX\r
+DCCLXII\r
+MMMMDCCLXVIII\r
+MDCCXXXXIII\r
+CCXXXII\r
+MMMMDCXXV\r
+MMMCCCXXVIII\r
+MDCVIII\r
+MMMCLXXXXIIII\r
+CLXXXI\r
+MDCCCCXXXIII\r
+MMMMDCXXX\r
+MMMDCXXIV\r
+MMMCCXXXVII\r
+MCCCXXXXIIII\r
+CXVIII\r
+MMDCCCCIV\r
+MMMMCDLXXV\r
+MMMDLXIV\r
+MDXCIII\r
+MCCLXXXI\r
+MMMDCCCXXIV\r
+MCXLIII\r
+MMMDCCCI\r
+MCCLXXX\r
+CCXV\r
+MMDCCLXXI\r
+MMDLXXXIII\r
+MMMMDCXVII\r
+MMMCMLXV\r
+MCLXVIII\r
+MMMMCCLXXVI\r
+MMMDCCLXVIIII\r
+MMMMDCCCIX\r
+DLXXXXIX\r
+DCCCXXII\r
+MMMMIII\r
+MMMMCCCLXXVI\r
+DCCCXCIII\r
+DXXXI\r
+MXXXIIII\r
+CCXII\r
+MMMDCCLXXXIIII\r
+MMMCXX\r
+MMMCMXXVII\r
+DCCCXXXX\r
+MMCDXXXVIIII\r
+MMMMDCCXVIII\r
+LV\r
+MMMDCCCCVI\r
+MCCCII\r
+MMCMLXVIIII\r
+MDCCXI\r
+MMMMDLXVII\r
+MMCCCCLXI\r
+MMDCCV\r
+MMMCCCXXXIIII\r
+MMMMDI\r
+MMMDCCCXCV\r
+MMDCCLXXXXI\r
+MMMDXXVI\r
+MMMDCCCLVI\r
+MMDCXXX\r
+MCCCVII\r
+MMMMCCCLXII\r
+MMMMXXV\r
+MMCMXXV\r
+MMLVI\r
+MMDXXX\r
+MMMMCVII\r
+MDC\r
+MCCIII\r
+MMMMDCC\r
+MMCCLXXV\r
+MMDCCCXXXXVI\r
+MMMMCCCLXV\r
+CDXIIII\r
+MLXIIII\r
+CCV\r
+MMMCMXXXI\r
+CCCCLXVI\r
+MDXXXII\r
+MMMMCCCLVIII\r
+MMV\r
+MMMCLII\r
+MCMLI\r
+MMDCCXX\r
+MMMMCCCCXXXVI\r
+MCCLXXXI\r
+MMMCMVI\r
+DCCXXX\r
+MMMMCCCLXV\r
+DCCCXI\r
+MMMMDCCCXIV\r
+CCCXXI\r
+MMDLXXV\r
+CCCCLXXXX\r
+MCCCLXXXXII\r
+MMDCIX\r
+DCCXLIIII\r
+DXIV\r
+MMMMCLII\r
+CDLXI\r
+MMMCXXVII\r
+MMMMDCCCCLXIII\r
+MMMDCLIIII\r
+MCCCCXXXXII\r
+MMCCCLX\r
+CCCCLIII\r
+MDCCLXXVI\r
+MCMXXIII\r
+MMMMDLXXVIII\r
+MMDCCCCLX\r
+MMMCCCLXXXX\r
+MMMCDXXVI\r
+MMMDLVIII\r
+CCCLXI\r
+MMMMDCXXII\r
+MMDCCCXXI\r
+MMDCCXIII\r
+MMMMCLXXXVI\r
+MDCCCCXXVI\r
+MDV\r
+MMDCCCCLXXVI\r
+MMMMCCXXXVII\r
+MMMDCCLXXVIIII\r
+MMMCCCCLXVII\r
+DCCXLI\r
+MMCLXXXVIII\r
+MCCXXXVI\r
+MMDCXLVIII\r
+MMMMCXXXII\r
+MMMMDCCLXVI\r
+MMMMCMLI\r
+MMMMCLXV\r
+MMMMDCCCXCIV\r
+MCCLXXVII\r
+LXXVIIII\r
+DCCLII\r
+MMMCCCXCVI\r
+MMMCLV\r
+MMDCCCXXXXVIII\r
+DCCCXV\r
+MXC\r
+MMDCCLXXXXVII\r
+MMMMCML\r
+MMDCCCLXXVIII\r
+DXXI\r
+MCCCXLI\r
+DCLXXXXI\r
+MMCCCLXXXXVIII\r
+MDCCCCLXXVIII\r
+MMMMDXXV\r
+MMMDCXXXVI\r
+MMMCMXCVII\r
+MMXVIIII\r
+MMMDCCLXXIV\r
+MMMCXXV\r
+DXXXVIII\r
+MMMMCLXVI\r
+MDXII\r
+MMCCCLXX\r
+CCLXXI\r
+DXIV\r
+MMMCLIII\r
+DLII\r
+MMMCCCXLIX\r
+MMCCCCXXVI\r
+MMDCXLIII\r
+MXXXXII\r
+CCCLXXXV\r
+MDCLXXVI\r
+MDCXII\r
+MMMCCCLXXXIII\r
+MMDCCCCLXXXII\r
+MMMMCCCLXXXV\r
+MMDCXXI\r
+DCCCXXX\r
+MMMDCCCCLII\r
+MMMDCCXXII\r
+MMMMCDXCVIII\r
+MMMCCLXVIIII\r
+MMXXV\r
+MMMMCDXIX\r
+MMMMCCCX\r
+MMMCCCCLXVI\r
+MMMMDCLXXVIIII\r
+MMMMDCXXXXIV\r
+MMMCMXII\r
+MMMMXXXIII\r
+MMMMDLXXXII\r
+DCCCLIV\r
+MDXVIIII\r
+MMMCLXXXXV\r
+CCCCXX\r
+MMDIX\r
+MMCMLXXXVIII\r
+DCCXLIII\r
+DCCLX\r
+D\r
+MCCCVII\r
+MMMMCCCLXXXIII\r
+MDCCCLXXIIII\r
+MMMDCCCCLXXXVII\r
+MMMMCCCVII\r
+MMMDCCLXXXXVI\r
+CDXXXIV\r
+MCCLXVIII\r
+MMMMDLX\r
+MMMMDXII\r
+MMMMCCCCLIIII\r
+MCMLXXXXIII\r
+MMMMDCCCIII\r
+MMDCLXXXIII\r
+MDCCCXXXXIV\r
+XXXXVII\r
+MMMDCCCXXXII\r
+MMMDCCCXLII\r
+MCXXXV\r
+MDCXXVIIII\r
+MMMCXXXXIIII\r
+MMMMCDXVII\r
+MMMDXXIII\r
+MMMMCCCCLXI\r
+DCLXXXXVIIII\r
+LXXXXI\r
+CXXXIII\r
+MCDX\r
+MCCLVII\r
+MDCXXXXII\r
+MMMCXXIV\r
+MMMMLXXXX\r
+MMDCCCCXLV\r
+MLXXX\r
+MMDCCCCLX\r
+MCDLIII\r
+MMMCCCLXVII\r
+MMMMCCCLXXIV\r
+MMMDCVIII\r
+DCCCCXXIII\r
+MMXCI\r
+MMDCCIV\r
+MMMMDCCCXXXIV\r
+CCCLXXI\r
+MCCLXXXII\r
+MCMIII\r
+CCXXXI\r
+DCCXXXVIII\r
+MMMMDCCXLVIIII\r
+MMMMCMXXXV\r
+DCCCLXXV\r
+DCCXCI\r
+MMMMDVII\r
+MMMMDCCCLXVIIII\r
+CCCXCV\r
+MMMMDCCXX\r
+MCCCCII\r
+MMMCCCXC\r
+MMMCCCII\r
+MMDCCLXXVII\r
+MMDCLIIII\r
+CCXLIII\r
+MMMDCXVIII\r
+MMMCCCIX\r
+MCXV\r
+MMCCXXV\r
+MLXXIIII\r
+MDCCXXVI\r
+MMMCCCXX\r
+MMDLXX\r
+MMCCCCVI\r
+MMDCCXX\r
+MMMMDCCCCXCV\r
+MDCCCXXXII\r
+MMMMDCCCCXXXX\r
+XCIV\r
+MMCCCCLX\r
+MMXVII\r
+MLXXI\r
+MMMDXXVIII\r
+MDCCCCII\r
+MMMCMLVII\r
+MMCLXXXXVIII\r
+MDCCCCLV\r
+MCCCCLXXIIII\r
+MCCCLII\r
+MCDXLVI\r
+MMMMDXVIII\r
+DCCLXXXIX\r
+MMMDCCLXIV\r
+MDCCCCXLIII\r
+CLXXXXV\r
+MMMMCCXXXVI\r
+MMMDCCCXXI\r
+MMMMCDLXXVII\r
+MCDLIII\r
+MMCCXLVI\r
+DCCCLV\r
+MCDLXX\r
+DCLXXVIII\r
+MMDCXXXIX\r
+MMMMDCLX\r
+MMDCCLI\r
+MMCXXXV\r
+MMMCCXII\r
+MMMMCMLXII\r
+MMMMCCV\r
+MCCCCLXIX\r
+MMMMCCIII\r
+CLXVII\r
+MCCCLXXXXIIII\r
+MMMMDCVIII\r
+MMDCCCLXI\r
+MMLXXIX\r
+CMLXIX\r
+MMDCCCXLVIIII\r
+DCLXII\r
+MMMCCCXLVII\r
+MDCCCXXXV\r
+MMMMDCCXCVI\r
+DCXXX\r
+XXVI\r
+MMLXIX\r
+MMCXI\r
+DCXXXVII\r
+MMMMCCCXXXXVIII\r
+MMMMDCLXI\r
+MMMMDCLXXIIII\r
+MMMMVIII\r
+MMMMDCCCLXII\r
+MDCXCI\r
+MMCCCXXIIII\r
+CCCCXXXXV\r
+MMDCCCXXI\r
+MCVI\r
+MMDCCLXVIII\r
+MMMMCXL\r
+MLXVIII\r
+CMXXVII\r
+CCCLV\r
+MDCCLXXXIX\r
+MMMCCCCLXV\r
+MMDCCLXII\r
+MDLXVI\r
+MMMCCCXVIII\r
+MMMMCCLXXXI\r
+MMCXXVII\r
+MMDCCCLXVIII\r
+MMMCXCII\r
+MMMMDCLVIII\r
+MMMMDCCCXXXXII\r
+MMDCCCCLXXXXVI\r
+MDCCXL\r
+MDCCLVII\r
+MMMMDCCCLXXXVI\r
+DCCXXXIII\r
+MMMMDCCCCLXXXV\r
+MMCCXXXXVIII\r
+MMMCCLXXVIII\r
+MMMDCLXXVIII\r
+DCCCI\r
+MMMMLXXXXVIIII\r
+MMMCCCCLXXII\r
+MMCLXXXVII\r
+CCLXVI\r
+MCDXLIII\r
+MMCXXVIII\r
+MDXIV\r
+CCCXCVIII\r
+CLXXVIII\r
+MMCXXXXVIIII\r
+MMMDCLXXXIV\r
+CMLVIII\r
+MCDLIX\r
+MMMMDCCCXXXII\r
+MMMMDCXXXIIII\r
+MDCXXI\r
+MMMDCXLV\r
+MCLXXVIII\r
+MCDXXII\r
+IV\r
+MCDLXXXXIII\r
+MMMMDCCLXV\r
+CCLI\r
+MMMMDCCCXXXVIII\r
+DCLXII\r
+MCCCLXVII\r
+MMMMDCCCXXXVI\r
+MMDCCXLI\r
+MLXI\r
+MMMCDLXVIII\r
+MCCCCXCIII\r
+XXXIII\r
+MMMDCLXIII\r
+MMMMDCL\r
+DCCCXXXXIIII\r
+MMDLVII\r
+DXXXVII\r
+MCCCCXXIIII\r
+MCVII\r
+MMMMDCCXL\r
+MMMMCXXXXIIII\r
+MCCCCXXIV\r
+MMCLXVIII\r
+MMXCIII\r
+MDCCLXXX\r
+MCCCLIIII\r
+MMDCLXXI\r
+MXI\r
+MCMLIV\r
+MMMCCIIII\r
+DCCLXXXVIIII\r
+MDCLIV\r
+MMMDCXIX\r
+CMLXXXI\r
+DCCLXXXVII\r
+XXV\r
+MMMXXXVI\r
+MDVIIII\r
+CLXIII\r
+MMMCDLVIIII\r
+MMCCCCVII\r
+MMMLXX\r
+MXXXXII\r
+MMMMCCCLXVIII\r
+MMDCCCXXVIII\r
+MMMMDCXXXXI\r
+MMMMDCCCXXXXV\r
+MMMXV\r
+MMMMCCXVIIII\r
+MMDCCXIIII\r
+MMMXXVII\r
+MDCCLVIIII\r
+MMCXXIIII\r
+MCCCLXXIV\r
+DCLVIII\r
+MMMLVII\r
+MMMCXLV\r
+MMXCVII\r
+MMMCCCLXXXVII\r
+MMMMCCXXII\r
+DXII\r
+MMMDLV\r
+MCCCLXXVIII\r
+MMMCLIIII\r
+MMMMCLXXXX\r
+MMMCLXXXIIII\r
+MDCXXIII\r
+MMMMCCXVI\r
+MMMMDLXXXIII\r
+MMMDXXXXIII\r
+MMMMCCCCLV\r
+MMMDLXXXI\r
+MMMCCLXXVI\r
+MMMMXX\r
+MMMMDLVI\r
+MCCCCLXXX\r
+MMMXXII\r
+MMXXII\r
+MMDCCCCXXXI\r
+MMMDXXV\r
+MMMDCLXXXVIIII\r
+MMMDLXXXXVII\r
+MDLXIIII\r
+CMXC\r
+MMMXXXVIII\r
+MDLXXXVIII\r
+MCCCLXXVI\r
+MMCDLIX\r
+MMDCCCXVIII\r
+MDCCCXXXXVI\r
+MMMMCMIV\r
+MMMMDCIIII\r
+MMCCXXXV\r
+XXXXVI\r
+MMMMCCXVII\r
+MMCCXXIV\r
+MCMLVIIII\r
+MLXXXIX\r
+MMMMLXXXIX\r
+CLXXXXIX\r
+MMMDCCCCLVIII\r
+MMMMCCLXXIII\r
+MCCCC\r
+DCCCLIX\r
+MMMCCCLXXXII\r
+MMMCCLXVIIII\r
+MCLXXXV\r
+CDLXXXVII\r
+DCVI\r
+MMX\r
+MMCCXIII\r
+MMMMDCXX\r
+MMMMXXVIII\r
+DCCCLXII\r
+MMMMCCCXLIII\r
+MMMMCLXV\r
+DXCI\r
+MMMMCLXXX\r
+MMMDCCXXXXI\r
+MMMMXXXXVI\r
+DCLX\r
+MMMCCCXI\r
+MCCLXXX\r
+MMCDLXXII\r
+DCCLXXI\r
+MMMCCCXXXVI\r
+MCCCCLXXXVIIII\r
+CDLVIII\r
+DCCLVI\r
+MMMMDCXXXVIII\r
+MMCCCLXXXIII\r
+MMMMDCCLXXV\r
+MMMXXXVI\r
+CCCLXXXXIX\r
+CV\r
+CCCCXIII\r
+CCCCXVI\r
+MDCCCLXXXIIII\r
+MMDCCLXXXII\r
+MMMMCCCCLXXXI\r
+MXXV\r
+MMCCCLXXVIIII\r
+MMMCCXII\r
+MMMMCCXXXIII\r
+MMCCCLXXXVI\r
+MMMDCCCLVIIII\r
+MCCXXXVII\r
+MDCLXXV\r
+XXXV\r
+MMDLI\r
+MMMCCXXX\r
+MMMMCXXXXV\r
+CCCCLIX\r
+MMMMDCCCLXXIII\r
+MMCCCXVII\r
+DCCCXVI\r
+MMMCCCXXXXV\r
+MDCCCCXCV\r
+CLXXXI\r
+MMMMDCCLXX\r
+MMMDCCCIII\r
+MMCLXXVII\r
+MMMDCCXXIX\r
+MMDCCCXCIIII\r
+MMMCDXXIIII\r
+MMMMXXVIII\r
+MMMMDCCCCLXVIII\r
+MDCCCXX\r
+MMMMCDXXI\r
+MMMMDLXXXIX\r
+CCXVI\r
+MDVIII\r
+MMCCLXXI\r
+MMMDCCCLXXI\r
+MMMCCCLXXVI\r
+MMCCLXI\r
+MMMMDCCCXXXIV\r
+DLXXXVI\r
+MMMMDXXXII\r
+MMMXXIIII\r
+MMMMCDIV\r
+MMMMCCCXLVIII\r
+MMMMCXXXVIII\r
+MMMCCCLXVI\r
+MDCCXVIII\r
+MMCXX\r
+CCCLIX\r
+MMMMDCCLXXII\r
+MDCCCLXXV\r
+MMMMDCCCXXIV\r
+DCCCXXXXVIII\r
+MMMDCCCCXXXVIIII\r
+MMMMCCXXXV\r
+MDCLXXXIII\r
+MMCCLXXXIV\r
+MCLXXXXIIII\r
+DXXXXIII\r
+MCCCXXXXVIII\r
+MMCLXXIX\r
+MMMMCCLXIV\r
+MXXII\r
+MMMCXIX\r
+MDCXXXVII\r
+MMDCCVI\r
+MCLXXXXVIII\r
+MMMCXVI\r
+MCCCLX\r
+MMMCDX\r
+CCLXVIIII\r
+MMMCCLX\r
+MCXXVIII\r
+LXXXII\r
+MCCCCLXXXI\r
+MMMI\r
+MMMCCCLXIV\r
+MMMCCCXXVIIII\r
+CXXXVIII\r
+MMCCCXX\r
+MMMCCXXVIIII\r
+MCCLXVI\r
+MMMCCCCXXXXVI\r
+MMDCCXCIX\r
+MCMLXXI\r
+MMCCLXVIII\r
+CDLXXXXIII\r
+MMMMDCCXXII\r
+MMMMDCCLXXXVII\r
+MMMDCCLIV\r
+MMCCLXIII\r
+MDXXXVII\r
+DCCXXXIIII\r
+MCII\r
+MMMDCCCLXXI\r
+MMMLXXIII\r
+MDCCCLIII\r
+MMXXXVIII\r
+MDCCXVIIII\r
+MDCCCCXXXVII\r
+MMCCCXVI\r
+MCMXXII\r
+MMMCCCLVIII\r
+MMMMDCCCXX\r
+MCXXIII\r
+MMMDLXI\r
+MMMMDXXII\r
+MDCCCX\r
+MMDXCVIIII\r
+MMMDCCCCVIII\r
+MMMMDCCCCXXXXVI\r
+MMDCCCXXXV\r
+MMCXCIV\r
+MCMLXXXXIII\r
+MMMCCCLXXVI\r
+MMMMDCLXXXV\r
+CMLXIX\r
+DCXCII\r
+MMXXVIII\r
+MMMMCCCXXX\r
+XXXXVIIII
\ No newline at end of file
index 9f22460b3cb69cf34eb392e53490f9e2a033ece9..973572572d9383d52d20a29f49a35ce9865f4045 100644 (file)
@@ -29,7 +29,7 @@ IN: project-euler.092
 <PRIVATE
 
 : next-link ( n -- m )
-    number>digits [ sq ] sigma ;
+    number>digits [ sq ] map-sum ;
 
 : chain-ending ( n -- m )
     dup [ 1 = ] [ 89 = ] bi or [ next-link chain-ending ] unless ;
index 72584d833ec842bc4eca1d5e7ea344ba224e2981..55a108aa68f29b8521d8b9120b9939b58e7ad727 100644 (file)
@@ -5,19 +5,18 @@ IN: project-euler.100
 
 ! http://projecteuler.net/index.php?section=problems&id=100
 
-! DESCRIPTION
-! -----------
+! DESCRIPTION ! -----------
 
 ! If a box contains twenty-one coloured discs, composed of fifteen blue discs
-! and six red discs, and two discs were taken at random, it can be seen that
-! the probability of taking two blue discs, P(BB) = (15/21)*(14/20) = 1/2.
+!  and six red discs, and two discs were taken at random, it can be seen that
+!  the probability of taking two blue discs, P(BB) = (15/21)*(14/20) = 1/2.
 
 ! The next such arrangement, for which there is exactly 50% chance of taking
-! two blue discs at random, is a box containing eighty-five blue discs and
-! thirty-five red discs.
+!  two blue discs at random, is a box containing eighty-five blue discs and
+!  thirty-five red discs.
 
 ! By finding the first arrangement to contain over 10^12 = 1,000,000,000,000
-! discs in total, determine the number of blue discs that the box would contain.
+!  discs in total, determine the number of blue discs that the box would contain.
 
 
 ! SOLUTION
@@ -26,7 +25,7 @@ IN: project-euler.100
 : euler100 ( -- answer )
     1 1
     [ dup dup 1 - * 2 * 10 24 ^ <= ]
-    [ tuck 6 * swap - 2 - ] while nip ;
+    [ [ 6 * swap - 2 - ] keep swap ] while nip ;
 
 ! TODO: solution needs generalization
 
index 43eb30c9f691490721c17c3bf37004d4c69b1c29..50252582fa95dc9ef08c52061c648896d5ce585b 100644 (file)
@@ -47,7 +47,7 @@ IN: project-euler.116
     V{ 1 } clone [ [ next ] 2curry times ] keep last 1 - ;
 
 : (euler116) ( length -- permutations )
-    3 [1,b] [ ways ] with sigma ;
+    3 [1,b] [ ways ] with map-sum ;
 
 PRIVATE>
 
index 0d4ec782269f4b1d4777da7e7dd8045c06ccc1ff..60daa7224e8634827c6df8ffa983656a2a60b7bb 100644 (file)
@@ -31,7 +31,7 @@ IN: project-euler.117
     [ 4 short tail* sum ] keep push ;
 
 : (euler117) ( n -- m )
-    V{ 1 } clone tuck [ next ] curry times last ;
+    [ V{ 1 } clone ] dip over [ next ] curry times last ;
 
 PRIVATE>
 
index a54b7d1db0faa147fd98c6b2a82ba21efaa163b8..e6278a1e172297e77e4b7105274340352138ddb9 100644 (file)
@@ -54,17 +54,16 @@ IN: project-euler.150
     0 1000 [1,b] [ [ next ] replicate partial-sums ] map nip ;
 
 :: (euler150) ( m -- n )
-    [let | table [ sums-triangle ] |
-        m [| x |
-            x 1 + [| y |
-                m x - [0,b) [| z |
-                    x z + table nth-unsafe
-                    [ y z + 1 + swap nth-unsafe ]
-                    [ y        swap nth-unsafe ] bi -
-                ] map partial-sum-infimum
-            ] map-infimum
+    sums-triangle :> table
+    m [| x |
+        x 1 + [| y |
+            m x - [0,b) [| z |
+                x z + table nth-unsafe
+                [ y z + 1 + swap nth-unsafe ]
+                [ y        swap nth-unsafe ] bi -
+            ] map partial-sum-infimum
         ] map-infimum
-    ] ;
+    ] map-infimum ;
 
 HINTS: (euler150) fixnum ;
 
index 19ff2c253ca6f5520454d3c523507d116a981950..460580c7c01542ea1a288d37094554312a119b35 100644 (file)
@@ -46,7 +46,7 @@ PRIVATE>
     m [1,b] [| i | 2 i * m 1 + / i ^ ] PI ;
 
 : euler190 ( -- answer )
-    2 15 [a,b] [ P_m truncate ] sigma ;
+    2 15 [a,b] [ P_m truncate ] map-sum ;
 
 ! [ euler150 ] 100 ave-time
 ! 5 ms ave run time - 1.01 SD (100 trials)
index f2d6b89afcb1c215768cc7bdf3ca7e35aa4d3df0..1fb41b61c0d799f135b1d522fc7c2fb65908bbe3 100644 (file)
@@ -9,14 +9,6 @@ HELP: collect-benchmarks
     $nl
     "A nicer word for interactive use is " { $link ave-time } "." } ;
 
-HELP: nth-place
-{ $values { "x" float } { "n" integer } { "y" float } }
-{ $description "Rounds a floating point number to " { $snippet "n" } " decimal places." }
-{ $examples
-    "This word is useful for display purposes when showing 15 decimal places is not desired:"
-    { $unchecked-example "3.141592653589793 3 nth-place number>string" "\"3.142\"" }
-} ;
-
 HELP: ave-time
 { $values { "quot" quotation } { "n" integer } }
 { $description "Runs a quotation " { $snippet "n" } " times, then prints the average run time and standard deviation." }
diff --git a/extra/project-euler/ave-time/ave-time-tests.factor b/extra/project-euler/ave-time/ave-time-tests.factor
new file mode 100644 (file)
index 0000000..86b0048
--- /dev/null
@@ -0,0 +1,5 @@
+IN: project-euler.ave-time.tests
+USING: tools.test math arrays project-euler.ave-time ;
+
+{ 0 3 } [ 1 2 [ + ] 10 collect-benchmarks ] must-infer-as
+[ 1 2 t ] [ 1 2 [ + ] 10 collect-benchmarks array? ] unit-test
index dc521d4d70f0bd2520877b2f3c684439ace125f0..ec190fed187da15b7c51c00c970a1b1cc855f3c2 100644 (file)
@@ -1,24 +1,16 @@
 ! 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: combinators.smart formatting fry io kernel macros math
+math.functions math.statistics memory sequences tools.time ;
 IN: project-euler.ave-time
 
-: nth-place ( x n -- y )
-    10^ [ * round >integer ] keep /f ;
-
-: collect-benchmarks ( quot n -- seq )
-    [
-        [ datastack ]
-        [
-            '[ _ gc benchmark 1000 / , ] tuck
-            '[ _ _ with-datastack drop ]
-        ]
-        [ 1 - ] tri* swap times call
-    ] { } make ; inline
+MACRO: collect-benchmarks ( quot n -- seq )
+    swap '[ _ [ [ [ _ nullary ] preserving ] gc benchmark 1000 / ] replicate ] ;
 
 : ave-time ( quot n -- )
-    [ collect-benchmarks ] keep swap
-    [ std 2 nth-place ] [ mean round >integer ] bi [
-        # " ms ave run time - " % # " SD (" % # " trials)" %
-    ] "" make print flush ; inline
+    [
+        collect-benchmarks
+        [ mean round >integer ]
+        [ std ] bi
+    ] keep
+    "%d ms ave run time - %.2f SD (%d trials)\n" printf flush ; inline
index 3d320fad62f03679cfc2d626b4b6e20f50f76603..9eb9e968ca161c60b1f679206b873d88bf2772a4 100644 (file)
@@ -57,7 +57,7 @@ IN: project-euler.common
 PRIVATE>
 
 : alpha-value ( str -- n )
-    >lower [ CHAR: a - 1 + ] sigma ;
+    >lower [ CHAR: a - 1 + ] map-sum ;
 
 : cartesian-product ( seq1 seq2 -- seq1xseq2 )
     [ [ 2array ] with map ] curry map concat ;
index e64bd618522f3b2c8b541134e5b1f4fe318a3916..66f42968273d3fd6466e88cbf088d04efa9e9cdd 100644 (file)
@@ -16,16 +16,16 @@ USING: definitions io io.files io.pathnames kernel math math.parser
     project-euler.045 project-euler.046 project-euler.047 project-euler.048
     project-euler.049 project-euler.051 project-euler.052 project-euler.053
     project-euler.054 project-euler.055 project-euler.056 project-euler.057
-    project-euler.058 project-euler.059 project-euler.063 project-euler.065
-    project-euler.067 project-euler.069 project-euler.071 project-euler.072
-    project-euler.073 project-euler.074 project-euler.075 project-euler.076
-    project-euler.079 project-euler.081 project-euler.085 project-euler.092
-    project-euler.097 project-euler.099 project-euler.100 project-euler.102
-    project-euler.112 project-euler.116 project-euler.117 project-euler.124
-    project-euler.134 project-euler.148 project-euler.150 project-euler.151
-    project-euler.164 project-euler.169 project-euler.173 project-euler.175
-    project-euler.186 project-euler.188 project-euler.190 project-euler.203
-    project-euler.215 ;
+    project-euler.058 project-euler.059 project-euler.062 project-euler.063
+    project-euler.065 project-euler.067 project-euler.069 project-euler.071
+    project-euler.072 project-euler.073 project-euler.074 project-euler.075
+    project-euler.076 project-euler.079 project-euler.081 project-euler.085
+    project-euler.092 project-euler.097 project-euler.099 project-euler.100
+    project-euler.102 project-euler.112 project-euler.116 project-euler.117
+    project-euler.124 project-euler.134 project-euler.148 project-euler.150
+    project-euler.151 project-euler.164 project-euler.169 project-euler.173
+    project-euler.175 project-euler.186 project-euler.188 project-euler.190
+    project-euler.203 project-euler.215 ;
 IN: project-euler
 
 <PRIVATE
index 6fe361b556c565ae6a39052a925fde8243909f57..7c2bdd0d28007546253a9b696c72f5651ae1da9e 100644 (file)
@@ -1,5 +1,5 @@
 ! (c) 2009 Joe Groff, see BSD license
-USING: assocs kernel math.rectangles combinators accessors
+USING: assocs kernel math.rectangles combinators accessors locals
 math.vectors vectors sequences math combinators.short-circuit arrays fry ;
 IN: quadtrees
 
@@ -89,8 +89,9 @@ DEFER: in-rect*
 : insert ( value point tree -- )
     dup leaf?>> [ leaf-insert ] [ node-insert ] if ;
 
-: leaf-at-point ( point leaf -- value/f ? )
-    tuck point>> = [ value>> t ] [ drop f f ] if ;
+:: leaf-at-point ( point leaf -- value/f ? )
+    point leaf point>> =
+    [ leaf value>> t ] [ f f ] if ;
 
 : node-at-point ( point node -- value/f ? )
     descend at-point ;
@@ -103,15 +104,15 @@ DEFER: in-rect*
 : node-in-rect* ( values rect node -- values )
     [ (node-in-rect*) ] with each-quadrant ;
 
-: leaf-in-rect* ( values rect leaf -- values ) 
-    tuck { [ nip point>> ] [ point>> swap contains-point? ] } 2&&
-    [ value>> over push ] [ drop ] if ;
+:: leaf-in-rect* ( values rect leaf -- values ) 
+    { [ leaf point>> ] [ leaf point>> rect contains-point? ] } 0&&
+    [ values leaf value>> suffix! ] [ values ] if ;
 
 : in-rect* ( values rect tree -- values )
     dup leaf?>> [ leaf-in-rect* ] [ node-in-rect* ] if ;
 
-: leaf-erase ( point leaf -- )
-    tuck point>> = [ f >>point f >>value ] when drop ;
+:: leaf-erase ( point leaf -- )
+    point leaf point>> = [ leaf f >>point f >>value drop ] when ;
 
 : node-erase ( point node -- )
     descend erase ;
index ce96587c92997e2b0187627d2d7baa1aa6f89803..e0ad6e0a749366a74c25aa727dc7435dcade21c6 100644 (file)
@@ -1,5 +1,5 @@
 ! (c)2009 Joe Groff bsd license
-USING: lexer parser ;
+USING: lexer sequences parser ;
 IN: qw
 
-SYNTAX: qw{ "}" parse-tokens parsed ;
+SYNTAX: qw{ "}" parse-tokens suffix! ;
index 4b0dee642e7e9d7c4314c3a5a6b0da460a41af0b..0a397ddc6ddec7e18350400f5fcbc55bb35da97e 100644 (file)
@@ -22,7 +22,7 @@ IN: blum-blum-shub.tests
 
 [ 3716213681 ]
 [
-    100 T{ blum-blum-shub f 200352954495 846054538649 } clone tuck [
+    T{ blum-blum-shub f 200352954495 846054538649 } clone 100 over [
         random-32* drop
     ] curry times
     random-32*
index c31620dd6c273c4746f59448cc3106a6e83547b0..7905c575bdf1e32bd789cf66e9b0df645718c549 100644 (file)
@@ -48,7 +48,7 @@ M:: lagged-fibonacci seed-random ( lagged-fibonacci seed! -- lagged-fibonacci )
             t 0.5 * t!
         ] times
         s
-    ] change-each
+    ] map! drop
     lagged-fibonacci p-r >>pt0
         q-r >>pt1 ; inline
 
diff --git a/extra/recipes/authors.txt b/extra/recipes/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/recipes/icons/back.tiff b/extra/recipes/icons/back.tiff
deleted file mode 100644 (file)
index 27b8112..0000000
Binary files a/extra/recipes/icons/back.tiff and /dev/null differ
diff --git a/extra/recipes/icons/hate.tiff b/extra/recipes/icons/hate.tiff
deleted file mode 100644 (file)
index d7d5f8e..0000000
Binary files a/extra/recipes/icons/hate.tiff and /dev/null differ
diff --git a/extra/recipes/icons/love.tiff b/extra/recipes/icons/love.tiff
deleted file mode 100644 (file)
index ae2fa7b..0000000
Binary files a/extra/recipes/icons/love.tiff and /dev/null differ
diff --git a/extra/recipes/icons/more.tiff b/extra/recipes/icons/more.tiff
deleted file mode 100644 (file)
index b4ec27b..0000000
Binary files a/extra/recipes/icons/more.tiff and /dev/null differ
diff --git a/extra/recipes/icons/submit.tiff b/extra/recipes/icons/submit.tiff
deleted file mode 100644 (file)
index 7c98267..0000000
Binary files a/extra/recipes/icons/submit.tiff and /dev/null differ
diff --git a/extra/recipes/recipes.factor b/extra/recipes/recipes.factor
deleted file mode 100644 (file)
index d546859..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-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
deleted file mode 100644 (file)
index 98b1ece..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Database backed recipe sharing
\ No newline at end of file
index 466fdc9937ae709f2ee2f7f3992ac40e86a0a8bb..51d0c21a94e3fed17204af2e2d4368cad9bef631 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Bruno Deferrari
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors io io.encodings.8-bit io.sockets
-io.streams.duplex kernel redis.command-writer
-redis.response-parser splitting ;
+USING: accessors io io.sockets io.streams.duplex kernel
+redis.command-writer redis.response-parser splitting
+io.encodings.8-bit.latin1 ;
 IN: redis
 
 #! Connection
index f5c2ea9811b0b25eb4d00fba5e83e48bed9e14b0..cc6c9ee33f174d94c75883efefaaf9d633dee566 100755 (executable)
@@ -10,7 +10,6 @@ IN: reports.noise
 : badness ( word -- n )\r
     H{\r
         { -nrot 5 }\r
-        { -roll 4 }\r
         { -rot 3 }\r
         { bi@ 1 }\r
         { 2curry 1 }\r
@@ -50,16 +49,12 @@ IN: reports.noise
         { nkeep 5 }\r
         { npick 6 }\r
         { nrot 5 }\r
-        { ntuck 6 }\r
         { nwith 4 }\r
         { over 2 }\r
         { pick 4 }\r
-        { roll 4 }\r
         { rot 3 }\r
-        { spin 3 }\r
         { swap 1 }\r
         { swapd 3 }\r
-        { tuck 2 }\r
         { with 1/2 }\r
 \r
         { bi 1/2 }\r
@@ -81,8 +76,6 @@ M: wrapper noise wrapped>> noise ;
 \r
 M: let noise body>> noise ;\r
 \r
-M: wlet noise body>> noise ;\r
-\r
 M: lambda noise body>> noise ;\r
 \r
 M: object noise drop { 0 0 } ;\r
index 6663381522aeb2fbcde56cd4f2b526184c1cd0f7..c8f08bcf30a1cfbcba5804c21a1f2895ac640e24 100644 (file)
@@ -3,7 +3,7 @@
 USING: kernel math sequences strings io combinators ascii ;
 IN: rot13
 
-: rotate ( ch base -- ch ) tuck - 13 + 26 mod + ;
+: rotate ( ch base -- ch ) [ - 13 + 26 mod ] [ + ] bi ;
 
 : rot-letter ( ch -- ch )
     {
diff --git a/extra/sequence-parser/sequence-parser-tests.factor b/extra/sequence-parser/sequence-parser-tests.factor
deleted file mode 100644 (file)
index af13e5b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-USING: tools.test sequence-parser unicode.categories kernel
-accessors ;
-IN: sequence-parser.tests
-
-[ "hello" ]
-[ "hello" [ take-rest ] parse-sequence ] unit-test
-
-[ "hi" " how are you?" ]
-[
-    "hi how are you?"
-    [ [ [ current blank? ] take-until ] [ take-rest ] bi ] parse-sequence
-] unit-test
-
-[ "foo" ";bar" ]
-[
-    "foo;bar" [
-        [ CHAR: ; take-until-object ] [ take-rest ] bi
-    ] parse-sequence
-] unit-test
-
-[ "foo " "and bar" ]
-[
-    "foo and bar" [
-        [ "and" take-until-sequence ] [ take-rest ] bi 
-    ] parse-sequence
-] unit-test
-
-[ "foo " " bar" ]
-[
-    "foo and bar" [
-        [ "and" take-until-sequence ]
-        [ "and" take-sequence drop ]
-        [ take-rest ] tri
-    ] parse-sequence
-] unit-test
-
-[ "foo " " bar" ]
-[
-    "foo and bar" [
-        [ "and" take-until-sequence* ]
-        [ take-rest ] bi
-    ] parse-sequence
-] unit-test
-
-[ { 1 2 } ]
-[ { 1 2 3 4 } <sequence-parser> { 3 4 } take-until-sequence ] unit-test
-
-[ f "aaaa" ]
-[
-    "aaaa" <sequence-parser>
-    [ "b" take-until-sequence ] [ take-rest ] bi
-] unit-test
-
-[ 6 ]
-[
-    "      foo   " [ skip-whitespace n>> ] parse-sequence
-] unit-test
-
-[ { 1 2 } ]
-[ { 1 2 3 } <sequence-parser> [ current 3 = ] take-until ] unit-test
-
-[ "ab" ]
-[ "abcd" <sequence-parser> "ab" take-sequence ] unit-test
-
-[ f ]
-[ "abcd" <sequence-parser> "lol" take-sequence ] unit-test
-
-[ "ab" ]
-[
-    "abcd" <sequence-parser>
-    [ "lol" take-sequence drop ] [ "ab" take-sequence ] bi
-] unit-test
-
-[ "" ]
-[ "abcd" <sequence-parser> "" take-sequence ] unit-test
-
-[ "cd" ]
-[ "abcd" <sequence-parser> [ "ab" take-sequence drop ] [ "cd" take-sequence ] bi ] unit-test
-
-[ f ]
-[ "" <sequence-parser> take-rest ] unit-test
-
-[ f ]
-[ "abc" <sequence-parser> dup "abc" take-sequence drop take-rest ] unit-test
-
-[ f ]
-[ "abc" <sequence-parser> "abcdefg" take-sequence ] unit-test
-
-[ "1234" ]
-[ "1234f" <sequence-parser> take-integer ] unit-test
-
-[ "yes" ]
-[
-    "yes1234f" <sequence-parser>
-    [ take-integer drop ] [ "yes" take-sequence ] bi 
-] unit-test
-
-[ f ] [ "" <sequence-parser> 4 take-n ] unit-test
-[ "abcd" ] [ "abcd" <sequence-parser> 4 take-n ] unit-test
-[ "abcd" "efg" ] [ "abcdefg" <sequence-parser> [ 4 take-n ] [ take-rest ] bi ] unit-test
-
-[ f ]
-[ "\n" <sequence-parser> take-integer ] unit-test
-
-[ "\n" ] [ "\n" <sequence-parser> [ ] take-while ] unit-test
-[ f ] [ "\n" <sequence-parser> [ not ] take-while ] unit-test
diff --git a/extra/sequence-parser/sequence-parser.factor b/extra/sequence-parser/sequence-parser.factor
deleted file mode 100644 (file)
index d14a770..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-! Copyright (C) 2005, 2009 Daniel Ehrenberg, Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-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 ;
-
-: <sequence-parser> ( sequence -- sequence-parser )
-    sequence-parser new
-        swap >>sequence
-        0 >>n ;
-
-:: with-sequence-parser ( sequence-parser quot -- seq/f )
-    sequence-parser n>> :> n
-    sequence-parser quot call [
-        n sequence-parser (>>n) f
-    ] unless* ; inline
-
-: offset  ( sequence-parser offset -- char/f )
-    swap
-    [ n>> + ] [ sequence>> ?nth ] bi ; inline
-
-: current ( sequence-parser -- char/f ) 0 offset ; inline
-
-: previous ( sequence-parser -- char/f ) -1 offset ; inline
-
-: peek-next ( sequence-parser -- char/f ) 1 offset ; inline
-
-: advance ( sequence-parser -- sequence-parser )
-    [ 1 + ] change-n ; inline
-
-: advance* ( sequence-parser -- )
-    advance drop ; inline
-
-: next ( sequence-parser -- obj ) [ current ] [ advance* ] bi ;
-
-: get+increment ( sequence-parser -- char/f )
-    [ current ] [ advance drop ] bi ; inline
-
-:: skip-until ( sequence-parser quot: ( obj -- ? ) -- )
-    sequence-parser current [
-        sequence-parser quot call
-        [ sequence-parser advance quot skip-until ] unless
-    ] when ; inline recursive
-
-: sequence-parse-end? ( sequence-parser -- ? ) current not ;
-
-: take-until ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
-    over sequence-parse-end? [
-        2drop f
-    ] [
-        [ drop n>> ]
-        [ skip-until ]
-        [ drop [ n>> ] [ sequence>> ] bi ] 2tri subseq f like
-    ] if ; inline
-
-: take-while ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
-    [ not ] compose take-until ; inline
-
-: <safe-slice> ( from to seq -- slice/f )
-    3dup {
-        [ 2drop 0 < ]
-        [ [ drop ] 2dip length > ]
-        [ drop > ]
-    } 3|| [ 3drop f ] [ slice boa ] if ; inline
-
-:: take-sequence ( sequence-parser sequence -- obj/f )
-    sequence-parser [ n>> dup sequence length + ] [ sequence>> ] bi
-    <safe-slice> sequence sequence= [
-        sequence
-        sequence-parser [ sequence length + ] change-n drop
-    ] [
-        f
-    ] if ;
-
-: take-sequence* ( sequence-parser sequence -- )
-    take-sequence drop ;
-
-:: take-until-sequence ( sequence-parser sequence -- sequence'/f )
-    sequence-parser n>> :> saved
-    sequence length <growing-circular> :> growing
-    sequence-parser
-    [
-        current growing push-growing-circular
-        sequence growing sequence=
-    ] take-until :> found
-    growing sequence sequence= [
-        found dup length
-        growing length 1 - - head
-        sequence-parser [ growing length - 1 + ] change-n drop
-        ! sequence-parser advance drop
-    ] [
-        saved sequence-parser (>>n)
-        f
-    ] if ;
-
-:: take-until-sequence* ( sequence-parser sequence -- sequence'/f )
-    sequence-parser sequence take-until-sequence :> out
-    out [
-        sequence-parser [ sequence length + ] change-n drop
-    ] when out ;
-
-: skip-whitespace ( sequence-parser -- sequence-parser )
-    [ [ current blank? not ] take-until drop ] keep ;
-
-: skip-whitespace-eol ( sequence-parser -- sequence-parser )
-    [ [ current " \t\r" member? not ] take-until drop ] keep ;
-
-: take-rest-slice ( sequence-parser -- sequence/f )
-    [ sequence>> ] [ n>> ] bi
-    2dup [ length ] dip < [ 2drop f ] [ tail-slice ] if ; inline
-
-: take-rest ( sequence-parser -- sequence )
-    [ take-rest-slice ] [ sequence>> like ] bi f like ;
-
-: take-until-object ( sequence-parser obj -- sequence )
-    '[ current _ = ] take-until ;
-
-: parse-sequence ( sequence quot -- )
-    [ <sequence-parser> ] dip call ; inline
-
-: take-integer ( sequence-parser -- n/f )
-    [ current digit? ] take-while ;
-
-:: take-n ( sequence-parser n -- seq/f )
-    n sequence-parser [ n>> + ] [ sequence>> length ] bi > [
-        sequence-parser take-rest
-    ] [
-        sequence-parser n>> dup n + sequence-parser sequence>> subseq
-        sequence-parser [ n + ] change-n drop
-    ] if ;
-
-<< "length" [ length ] define-sorting >>
-
-: sort-tokens ( seq -- seq' )
-    { length>=< <=> } sort-by ;
-
-: take-first-matching ( sequence-parser seq -- seq )
-    swap
-    '[ _ [ swap take-sequence ] with-sequence-parser ] find nip ;
-
-: take-longest ( sequence-parser seq -- seq )
-    sort-tokens take-first-matching ;
-
-: write-full ( sequence-parser -- ) sequence>> write ;
-: write-rest ( sequence-parser -- ) take-rest write ;
index 6770a48a3a835c98e98157a306f1f4d89ec9d995..2dc22477838594feadc25add3c85cfe4ad39741a 100644 (file)
@@ -12,7 +12,7 @@ IN: sequences.abbrev
     [ prefixes ] keep 1array '[ _ ] H{ } map>assoc ;
 
 : assoc-merge ( assoc1 assoc2 -- assoc3 )
-    tuck '[ over _ at dup [ append ] [ drop ] if ] assoc-map assoc-union ;
+    [ '[ over _ at dup [ append ] [ drop ] if ] assoc-map ] keep swap assoc-union ;
 
 PRIVATE>
 
diff --git a/extra/sequences/merged/authors.txt b/extra/sequences/merged/authors.txt
deleted file mode 100644 (file)
index e9c193b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Alex Chapman
diff --git a/extra/sequences/merged/merged-docs.factor b/extra/sequences/merged/merged-docs.factor
deleted file mode 100644 (file)
index da0d340..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-USING: help.markup help.syntax sequences ;
-IN: sequences.merged
-
-ARTICLE: "sequences-merge" "Merging sequences"
-"When multiple sequences are merged into one sequence, the new sequence takes an element from each input sequence in turn. For example, if we merge " { $code "{ 1 2 3 }" } "and" { $code "{ \"a\" \"b\" \"c\" }" } "we get:" { $code "{ 1 \"a\" 2 \"b\" 3 \"c\" }" } "."
-{ $subsections
-    merge
-    2merge
-    3merge
-    <merged>
-    <2merged>
-    <3merged>
-} ;
-
-ABOUT: "sequences-merge"
-
-HELP: merged
-{ $class-description "A virtual sequence which presents a merged view of its underlying elements. New instances are created by calling one of " { $link <merged> } ", " { $link <2merged> } ", or " { $link <3merged> } "." }
-{ $see-also merge } ;
-
-HELP: <merged> ( seqs -- merged )
-{ $values { "seqs" "a sequence of sequences to merge" } { "merged" "a virtual sequence" } }
-{ $description "Creates an instance of the " { $link merged } " virtual sequence." }
-{ $see-also <2merged> <3merged> merge } ;
-
-HELP: <2merged> ( seq1 seq2 -- merged )
-{ $values { "seq1" sequence } { "seq2" sequence } { "merged" "a virtual sequence" } }
-{ $description "Creates an instance of the " { $link merged } " virtual sequence which merges the two input sequences." }
-{ $see-also <merged> <3merged> 2merge } ;
-
-HELP: <3merged> ( seq1 seq2 seq3 -- merged )
-{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "merged" "a virtual sequence" } }
-{ $description "Creates an instance of the " { $link merged } " virtual sequence which merges the three input sequences." }
-{ $see-also <merged> <2merged> 3merge } ;
-
-HELP: merge ( seqs -- seq )
-{ $values { "seqs" "a sequence of sequences to merge" } { "seq" "a new sequence" } }
-{ $description "Outputs a new sequence which merges the elements of each sequence in " { $snippet "seqs" } "." }
-{ $examples
-    { $example "USING: prettyprint sequences.merged ;" "{ { 1 2 } { 3 4 } { 5 6 } } merge ." "{ 1 3 5 2 4 6 }" }
-    { $example "USING: prettyprint sequences.merged ;" "{ \"abc\" \"def\" } merge ." "\"adbecf\"" }
-}
-{ $see-also 2merge 3merge <merged> } ;
-
-HELP: 2merge ( seq1 seq2 -- seq )
-{ $values { "seq1" sequence } { "seq2" sequence } { "seq" "a new sequence" } }
-{ $description "Creates a new sequence of the same type as " { $snippet "seq1" } " which merges the elements of " { $snippet "seq1" } " and " { $snippet "seq2" } }
-{ $see-also merge 3merge <2merged> } ;
-
-HELP: 3merge ( seq1 seq2 seq3 -- seq )
-{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "seq" "a new sequence" } }
-{ $description "Creates a new sequence of the same type as " { $snippet "seq1" } " which merges the elements of all three sequences" }
-{ $see-also merge 2merge <3merged> } ;
diff --git a/extra/sequences/merged/merged-tests.factor b/extra/sequences/merged/merged-tests.factor
deleted file mode 100644 (file)
index 13a46f0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-USING: sequences sequences.merged tools.test ;
-IN: sequences.merged.tests
-
-[ 0 { 1 2 } ] [ 0 T{ merged f { { 1 2 } { 3 4 } } } virtual@ ] unit-test
-[ 0 { 3 4 } ] [ 1 T{ merged f { { 1 2 } { 3 4 } } } virtual@ ] unit-test
-[ 1 { 1 2 } ] [ 2 T{ merged f { { 1 2 } { 3 4 } } } virtual@ ] unit-test
-[ 4 ] [ 3 { { 1 2 3 4 } } <merged> nth ] unit-test
-[ 4 { { 1 2 3 4 } } <merged> nth ] must-fail
-
-[ 1 ] [ 0 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
-[ 4 ] [ 1 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
-[ 2 ] [ 2 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
-[ 5 ] [ 3 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
-[ 3 ] [ 4 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
-[ 6 ] [ 5 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
-
-[ 4 ] [ 4 { 1 2 } { 3 4 } { 5 6 } 3merge nth ] unit-test
diff --git a/extra/sequences/merged/merged.factor b/extra/sequences/merged/merged.factor
deleted file mode 100644 (file)
index d64da6e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-! Copyright (C) 2008 Alex Chapman
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math sequences ;
-IN: sequences.merged
-
-TUPLE: merged seqs ;
-C: <merged> merged
-
-: <2merged> ( seq1 seq2 -- merged ) 2array <merged> ;
-: <3merged> ( seq1 seq2 seq3 -- merged ) 3array <merged> ;
-
-: merge ( seqs -- seq )
-    dup <merged> swap first like ;
-
-: 2merge ( seq1 seq2 -- seq )
-    dupd <2merged> swap like ;
-
-: 3merge ( seq1 seq2 seq3 -- seq )
-    pick [ <3merged> ] dip like ;
-
-M: merged length seqs>> [ length ] map sum ;
-
-M: merged virtual@ ( n seq -- n' seq' )
-    seqs>> [ length /mod ] [ nth ] bi ;
-
-M: merged virtual-seq ( merged -- seq ) [ ] { } map-as ;
-
-INSTANCE: merged virtual-sequence
diff --git a/extra/sequences/merged/summary.txt b/extra/sequences/merged/summary.txt
deleted file mode 100644 (file)
index 1a514df..0000000
+++ /dev/null
@@ -1 +0,0 @@
-A virtual sequence which merges (interleaves) other sequences.
diff --git a/extra/sequences/merged/tags.txt b/extra/sequences/merged/tags.txt
deleted file mode 100644 (file)
index 42d711b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-collections
index d552f2dc77a9ede9af6930d911df60a5a9146eb4..73fcc651bda4ef2de50b06751743de0de069c421 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math math.order
+USING: accessors arrays kernel locals math math.order
 sequences sequences.private shuffle ;
 IN: sequences.modified
 
@@ -21,7 +21,7 @@ TUPLE: 1modified < modified seq ;
 M: modified length seq>> length ;
 M: modified set-length seq>> set-length ;
 
-M: 1modified virtual-seq seq>> ;
+M: 1modified virtual-exemplar seq>> ;
 
 TUPLE: scaled < 1modified c ;
 C: <scaled> scaled
@@ -32,9 +32,9 @@ C: <scaled> scaled
 M: scaled modified-nth ( n seq -- elt )
     [ seq>> nth ] [ c>> * ] bi ;
 
-M: scaled modified-set-nth ( elt n seq -- elt )
+M:: scaled modified-set-nth ( elt n seq -- elt )
     ! don't set c to 0!
-    tuck [ c>> / ] 2dip seq>> set-nth ;
+    elt seq c>> / n seq seq>> set-nth ;
 
 TUPLE: offset < 1modified n ;
 C: <offset> offset
@@ -45,8 +45,8 @@ C: <offset> offset
 M: offset modified-nth ( n seq -- elt )
     [ seq>> nth ] [ n>> + ] bi ;
 
-M: offset modified-set-nth ( elt n seq -- )
-    tuck [ n>> - ] 2dip seq>> set-nth ;
+M:: offset modified-set-nth ( elt n seq -- )
+    elt seq n>> - n seq seq>> set-nth ;
 
 TUPLE: summed < modified seqs ;
 C: <summed> summed
@@ -71,7 +71,8 @@ M: summed modified-set-nth ( elt n seq -- ) immutable ;
 M: summed set-length ( n seq -- )
     seqs>> [ set-length ] with each ;
 
-M: summed virtual-seq ( summed -- seq ) [ ] { } map-as ;
+M: summed virtual-exemplar ( summed -- seq )
+    seqs>> [ f ] [ first ] if-empty ;
 
 : <2summed> ( seq seq -- summed-seq ) 2array <summed> ;
 : <3summed> ( seq seq seq -- summed-seq ) 3array <summed> ;
diff --git a/extra/sequences/product/authors.txt b/extra/sequences/product/authors.txt
deleted file mode 100644 (file)
index f13c9c1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Joe Groff
diff --git a/extra/sequences/product/product-docs.factor b/extra/sequences/product/product-docs.factor
deleted file mode 100644 (file)
index 0b6805e..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-! (c)2009 Joe Groff bsd license
-USING: help.markup help.syntax quotations sequences ;
-IN: sequences.product
-
-HELP: product-sequence
-{ $class-description "A class of virtual sequences that present the cartesian product of their underlying set of sequences. Product sequences are constructed with the " { $link <product-sequence> } " word." }
-{ $examples
-{ $example """USING: arrays prettyprint sequences.product ;
-{ { 1 2 3 } { "a" "b" "c" } } <product-sequence> >array .
-""" """{
-    { 1 "a" }
-    { 2 "a" }
-    { 3 "a" }
-    { 1 "b" }
-    { 2 "b" }
-    { 3 "b" }
-    { 1 "c" }
-    { 2 "c" }
-    { 3 "c" }
-}""" } } ;
-
-HELP: <product-sequence>
-{ $values { "sequences" sequence } { "product-sequence" product-sequence } }
-{ $description "Constructs a " { $link product-sequence } " over " { $snippet "sequences" } "." }
-{ $examples
-{ $example """USING: arrays prettyprint sequences.product ;
-{ { 1 2 3 } { "a" "b" "c" } } <product-sequence> >array ."""
-"""{
-    { 1 "a" }
-    { 2 "a" }
-    { 3 "a" }
-    { 1 "b" }
-    { 2 "b" }
-    { 3 "b" }
-    { 1 "c" }
-    { 2 "c" }
-    { 3 "c" }
-}""" } } ;
-
-{ product-sequence <product-sequence> } related-words
-
-HELP: product-map
-{ $values { "sequences" sequence } { "quot" { $quotation "( sequence -- value )" } } { "sequence" sequence } }
-{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output sequence." }
-{ $notes { $snippet "[ ... ] product-map" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] map" } "." } ;
-
-HELP: product-each
-{ $values { "sequences" sequence } { "quot" { $quotation "( sequence -- )" } } }
-{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } "." }
-{ $notes { $snippet "[ ... ] product-each" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] each" } "." } ;
-
-{ product-map product-each } related-words
-
-ARTICLE: "sequences.product" "Product sequences"
-"The " { $vocab-link "sequences.product" } " vocabulary provides a virtual sequence and combinators for manipulating the cartesian product of a set of sequences."
-{ $subsections
-    product-sequence
-    <product-sequence>
-    product-map
-    product-each
-} ;
-
-ABOUT: "sequences.product"
diff --git a/extra/sequences/product/product-tests.factor b/extra/sequences/product/product-tests.factor
deleted file mode 100644 (file)
index 9f93129..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-! (c)2009 Joe Groff bsd license
-USING: arrays kernel make sequences sequences.product tools.test ;
-IN: sequences.product.tests
-
-
-[ { { 0 "a" } { 1 "a" } { 2 "a" } { 0 "b" } { 1 "b" } { 2 "b" } } ]
-[ { { 0 1 2 } { "a" "b" } } <product-sequence> >array ] unit-test
-
-: x ( n s -- sss ) <repetition> concat ;
-
-[ { "a" "aa" "aaa" "b" "bb" "bbb" } ]
-[ { { 1 2 3 } { "a" "b" } } [ first2 x ] product-map ] unit-test
-
-[
-    {
-        { 0 "a" t } { 1 "a" t } { 2 "a" t } { 0 "b" t } { 1 "b" t } { 2 "b" t }
-        { 0 "a" f } { 1 "a" f } { 2 "a" f } { 0 "b" f } { 1 "b" f } { 2 "b" f }
-    }
-] [ { { 0 1 2 } { "a" "b" } { t f } } [ ] product-map ] unit-test
-
-[ "a1b1c1a2b2c2" ] [
-    [
-        { { "a" "b" "c" } { "1" "2" } }
-        [ [ % ] each ] product-each
-    ] "" make
-] unit-test
-
-[ { } ] [ { { } { 1 } } [ ] product-map ] unit-test
-[ ] [ { { } { 1 } } [ drop ] product-each ] unit-test
diff --git a/extra/sequences/product/product.factor b/extra/sequences/product/product.factor
deleted file mode 100644 (file)
index c94e13a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-! (c)2009 Joe Groff bsd license
-USING: accessors arrays kernel locals math sequences ;
-IN: sequences.product
-
-TUPLE: product-sequence { sequences array read-only } { lengths array read-only } ;
-
-: <product-sequence> ( sequences -- product-sequence )
-    >array dup [ length ] map product-sequence boa ;
-
-INSTANCE: product-sequence sequence
-
-M: product-sequence length lengths>> product ;
-
-<PRIVATE
-
-: ns ( n lengths -- ns )
-    [ V{ } clone ] 2dip [ /mod swap [ over push ] dip ] each drop ;
-
-: nths ( ns seqs -- nths )
-    [ nth ] { } 2map-as ;
-
-: product@ ( n product-sequence -- ns seqs )
-    [ lengths>> ns ] [ nip sequences>> ] 2bi ;
-
-:: (carry-n) ( ns lengths i -- )
-    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)
-        ] when
-    ] unless ;
-
-: carry-ns ( ns lengths -- )
-    0 (carry-n) ;
-    
-: product-iter ( ns lengths -- )
-    [ 0 over [ 1 + ] change-nth ] dip carry-ns ;
-
-: start-product-iter ( sequences -- ns lengths )
-    [ [ drop 0 ] map ] [ [ length ] map ] bi ;
-
-: end-product-iter? ( ns lengths -- ? )
-    [ 1 tail* first ] bi@ = ;
-
-PRIVATE>
-
-M: product-sequence nth 
-    product@ nths ;
-
-:: product-each ( sequences quot -- )
-    sequences start-product-iter :> lengths :> ns
-    lengths [ 0 = ] any? [
-        [ ns lengths end-product-iter? ]
-        [ ns sequences nths quot call ns lengths product-iter ] until
-    ] unless ; inline
-
-:: product-map ( sequences quot -- sequence )
-    0 :> i!
-    sequences [ length ] [ * ] map-reduce sequences
-    [| result |
-        sequences [ quot call i result set-nth i 1 + i! ] product-each
-        result
-    ] new-like ; inline
-
diff --git a/extra/sequences/product/summary.txt b/extra/sequences/product/summary.txt
deleted file mode 100644 (file)
index c234c84..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Cartesian products of sequences
index 77fddd551021305a9e52eebca18dc040d3422609..7157e3f025a059f1cc51f3de1061ac838bf43d12 100644 (file)
@@ -16,6 +16,6 @@ M: repeating set-length (>>len) ;
 
 M: repeating virtual@ ( n seq -- n' seq' ) circular>> ;
 
-M: repeating virtual-seq circular>> ;
+M: repeating virtual-exemplar circular>> ;
 
 INSTANCE: repeating virtual-sequence
index 04731b0e27d6210833b4c500a029090ba7d2a4a1..80d8bf224695914714862a7264ed4d225ff0cef7 100644 (file)
@@ -1,9 +1,9 @@
-USING: accessors assocs fry generalizations kernel math
-namespaces parser sequences words ;
+USING: accessors assocs fry generalizations kernel locals math
+namespaces parser sequences shuffle 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
+SYNTAX: :| (:) dup in>> dup length [ spin '[ _ narray _ swap zip _ bind ] ] 2curry dip define-declared ;
index af37580ff268863b815b3beac23141b3751c9b9b..19b0dead484fc094396d936dae56544eac9b4747 100755 (executable)
@@ -99,7 +99,7 @@ TUPLE: slides < book ;
     ] with map ;
 
 SYNTAX: STRIP-TEASE:
-    parse-definition strip-tease [ parsed ] each ;
+    parse-definition strip-tease [ suffix! ] each ;
 
 \ slides H{
     { T{ button-down } [ request-focus ] }
index cbe224160437c284a74678bc9379bae3ec800ce9..3d0369128740fb471c3a19a5dcdfaafcc6171c84 100755 (executable)
@@ -14,7 +14,9 @@ USING:
     io.files
     io.pathnames
     kernel 
+    locals
     math
+    math.order
     openal
     opengl.gl
     sequences
@@ -40,12 +42,11 @@ CONSTANT: game-height 256
   #! Point is a {x y}.
   first2 game-width 3 * * swap 3 * + ;
 
-: set-bitmap-pixel ( color point array -- )
-  #! 'color' is a {r g b}. Point is {x y}.
-  [ bitmap-index ] dip ! color index array
-  [ [ first ] 2dip set-nth ] 3keep
-  [ [ second ] 2dip [ 1 + ] dip set-nth ] 3keep
-  [ third ] 2dip [ 2 + ] dip set-nth ;
+:: set-bitmap-pixel ( bitmap point color -- )
+    point bitmap-index :> index
+    color first  index     bitmap set-nth
+    color second index 1 + bitmap set-nth
+    color third  index 2 + bitmap set-nth ;
 
 : get-bitmap-pixel ( point array -- color )
   #! Point is a {x y}. color is a {r g b} 
@@ -65,7 +66,7 @@ CONSTANT: SOUND-WALK4        7
 CONSTANT: SOUND-UFO-HIT      8 
 
 : init-sound ( index cpu filename  -- )
-  canonicalize-path swapd [ sounds>> nth AL_BUFFER ] dip
+  absolute-path swapd [ sounds>> nth AL_BUFFER ] dip
   create-buffer-from-wav set-source-param ; 
 
 : init-sounds ( cpu -- )
@@ -139,8 +140,8 @@ M: space-invaders read-port ( port cpu -- byte )
   #! Setting this value affects the value read from port 3
   (>>port2o) ;
 
-: bit-newly-set? ( old-value new-value bit -- bool )
-  tuck bit? [ bit? not ] dip and ;
+:: bit-newly-set? ( old-value new-value bit -- bool )
+  new-value bit bit? [ old-value bit bit? not ] dip and ;
 
 : port3-newly-set? ( new-value cpu bit -- bool )
   [ port3o>> swap ] dip bit-newly-set? ;
@@ -317,19 +318,15 @@ CONSTANT: red   { 255 0 0 }
 
 : plot-bitmap-pixel ( bitmap point color -- )
   #! point is a {x y}. color is a {r g b}.
-  spin set-bitmap-pixel ;
-
-: within ( n a b -- bool )
-  #! n >= a and n <= b
-  rot tuck swap <= [ swap >= ] dip and ;
+  set-bitmap-pixel ;
 
 : get-point-color ( point -- color )
   #! Return the color to use for the given x/y position.
   first2
   {
-    { [ dup 184 238 within pick 0 223 within and ] [ 2drop green ] }
-    { [ dup 240 247 within pick 16 133 within and ] [ 2drop green ] }
-    { [ dup 247 215 - 247 184 - within pick 0 223 within and ] [ 2drop red ] }
+    { [ dup 184 238 between? pick 0 223 between? and ] [ 2drop green ] }
+    { [ dup 240 247 between? pick 16 133 between? and ] [ 2drop green ] }
+    { [ dup 247 215 - 247 184 - between? pick 0 223 between? and ] [ 2drop red ] }
     [ 2drop white ]
   } cond ;
 
index 9d3aa6c65127d81da8138263dfac7d04770777b4..c8ea4734d28a79294a182ecd33c04d9bcc57f2e7 100644 (file)
@@ -57,7 +57,7 @@ fetched-in parsed-html links processed-in fetched-at ;
     [ filter-base-links ] 2keep
     depth>> 1 + swap
     [ add-nonmatching ]
-    [ tuck [ apply-filters ] 2dip add-todo ] 2bi ;
+    [ dup '[ _ apply-filters ] curry 2dip add-todo ] 2bi ;
 
 : normalize-hrefs ( base links -- links' )
     [ derive-url ] with map ;
@@ -69,12 +69,12 @@ fetched-in parsed-html links processed-in fetched-at ;
 
 :: fill-spidered-result ( spider spider-result -- )
     f spider-result url>> spider spidered>> set-at
-    [ spider-result url>> http-get ] benchmark :> fetched-in :> html :> headers
+    [ spider-result url>> http-get ] benchmark :> ( headers html fetched-in )
     [
         html parse-html
         spider currently-spidering>>
         over find-all-links normalize-hrefs
-    ] benchmark :> processed-in :> links :> parsed-html
+    ] benchmark :> ( parsed-html links processed-in )
     spider-result
         headers >>headers
         fetched-in >>fetched-in
index b4bbc9fbf8a5f5566f30189420940803bd0220ba..f660674b63c7232fda7797fe6c732f7d5605d78e 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs deques dlists kernel ;
+USING: accessors assocs deques dlists kernel locals ;
 IN: spider.unique-deque
 
 TUPLE: todo-url url depth ;
@@ -30,8 +30,9 @@ TUPLE: unique-deque assoc deque ;
 
 : peek-url ( unique-deque -- todo-url ) deque>> peek-front ;
 
-: slurp-deque-when ( deque quot1 quot2: ( value -- ) -- )
-    pick deque-empty? [ 3drop ] [
-        [ [ pop-front dup ] 2dip [ call ] dip [ t ] compose [ drop f ] if ]
-        [ roll [ slurp-deque-when ] [ 3drop ] if ] 3bi
-    ] if ; inline recursive
+:: slurp-deque-when ( deque quot1: ( value -- ) quot2: ( value -- ) -- )
+    deque deque-empty? [
+        deque pop-front dup quot1 call
+        [ quot2 call t ] [ drop f ] if
+        [ deque quot1 quot2 slurp-deque-when ] when
+    ] unless ; inline recursive
diff --git a/extra/sudokus/authors.txt b/extra/sudokus/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/sudokus/sudokus.factor b/extra/sudokus/sudokus.factor
deleted file mode 100644 (file)
index 9de9a6f..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-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
deleted file mode 100644 (file)
index d66e7be..0000000
+++ /dev/null
@@ -1 +0,0 @@
-graphical sudoku solver
\ No newline at end of file
index be1e5943afc7dbf7f025cf06ffb1de5c2d37b25d..def610d356527d1d795470b0be2256b4a13a0c34 100644 (file)
@@ -16,7 +16,7 @@ MEMO: single-sine-wave ( samples/wave -- seq )
     [ sample-freq>> -rot sine-wave ] keep swap >>data ;
 
 : >silent-buffer ( seconds buffer -- buffer )
-    tuck sample-freq>> * >integer 0 <repetition> >>data ;
+    [ sample-freq>> * >integer 0 <repetition> ] [ (>>data) ] [ ] tri ;
 
 TUPLE: harmonic n amplitude ;
 C: <harmonic> harmonic
@@ -32,5 +32,5 @@ C: <note> note
     harmonic amplitude>> <scaled> ;
 
 : >note ( harmonics note buffer -- buffer )
-    dup -roll [ note-harmonic-data ] 2curry map <summed> >>data ;
+    [ [ note-harmonic-data ] 2curry map <summed> ] [ (>>data) ] [ ] tri ;
 
index e1b5867f64ed684ae5095036171bd144b60da824..c9e235ff7953ef71350d8b78cf2e4608d842c39d 100644 (file)
@@ -38,7 +38,7 @@ CONSTANT: default-height 20
     level>> 1 - 60 * 1000 swap - ;
 
 : add-block ( tetris block -- )
-    over board>> spin current-piece tetromino>> colour>> set-block ;
+    over [ board>> ] 2dip current-piece tetromino>> colour>> set-block ;
 
 : game-over? ( tetris -- ? )
     [ board>> ] [ next-piece ] bi piece-valid? not ;
index 2ebbfc07d68480b1a1e95cc3cf1e4474fdd3a097..0a24b2033c30163ef122242d49d044c10edd4f83 100644 (file)
@@ -37,7 +37,7 @@ TUPLE: piece
 
 : modulo ( n m -- n )
   #! -2 7 mod => -2, -2 7 modulo =>  5
-  tuck mod over + swap mod ;
+  [ mod ] [ + ] [ mod ] tri ;
 
 : (rotate-piece) ( rotation inc n-states -- rotation' )
     [ + ] dip modulo ;
index 1df1325eefa61a2ad308628a910969c5a8b6c580..de160f5598ea3ddbb590489c834e098a0bac4c4f 100644 (file)
@@ -42,10 +42,10 @@ M: TYPE assoc-size ( db -- size ) handle>> DBRNUM ;
     ] while 3drop ;
 
 M: TYPE >alist ( db -- alist )
-    [ DBKEYS dup ] keep '[ dup _ at 2array ] change-each ;
+    [ DBKEYS dup ] keep '[ dup _ at 2array ] map! drop ;
 
 M: TYPE set-at ( value key db -- )
-    handle>> spin [ object>bytes dup length ] bi@ DBPUT drop ;
+    handle>> swap rot [ object>bytes dup length ] bi@ DBPUT drop ;
 
 M: TYPE delete-at ( key db -- )
     handle>> swap object>bytes dup length DBOUT drop ;
@@ -56,4 +56,4 @@ M: TYPE equal? assoc= ;
 
 M: TYPE hashcode* assoc-hashcode ;
 
-;FUNCTOR
\ No newline at end of file
+;FUNCTOR
index 04c7022077c0c4bb0914c5ded36c66e595b7e935..4903307af1698a5a9bf3f6cdf28b7713c347c6cc 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators kernel generic math math.functions
-math.parser namespaces io sequences trees
+math.parser namespaces io sequences trees shuffle
 assocs parser accessors math.order prettyprint.custom ;
 IN: trees.avl
 
index 66ef154b63c726faf70f6e5bc586ecda2026e108..67b2f6b62456aeca32e71650a0bcd67f6ba783f2 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2005 Mackenzie Straight.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays kernel math namespaces sequences assocs parser
-trees generic math.order accessors prettyprint.custom ;
+trees generic math.order accessors prettyprint.custom shuffle ;
 IN: trees.splay
 
 TUPLE: splay < tree ;
index 62f4d8fce4ba9367bd7af9c1018e8e0a7be9ed37..77e5e5bdc066ab7cecbd99b6f3ea86ad57df0ba9 100755 (executable)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel generic math sequences arrays io namespaces
 prettyprint.private kernel.private assocs random combinators
-parser math.order accessors deques make prettyprint.custom ;
+parser math.order accessors deques make prettyprint.custom 
+shuffle ;
 IN: trees
 
 TUPLE: tree root count ;
diff --git a/extra/ui/gadgets/alerts/alerts.factor b/extra/ui/gadgets/alerts/alerts.factor
deleted file mode 100644 (file)
index 254e282..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-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 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
diff --git a/extra/ui/gadgets/alerts/authors.txt b/extra/ui/gadgets/alerts/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/ui/gadgets/alerts/summary.txt b/extra/ui/gadgets/alerts/summary.txt
deleted file mode 100644 (file)
index f1cd420..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Really simple dialog boxes
\ No newline at end of file
diff --git a/extra/ui/gadgets/comboboxes/authors.txt b/extra/ui/gadgets/comboboxes/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/ui/gadgets/comboboxes/comboboxes.factor b/extra/ui/gadgets/comboboxes/comboboxes.factor
deleted file mode 100644 (file)
index 3eb1180..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-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 drop ] 2keep swap
-   T{ button-up } = [
-      [ spawner>> ]
-      [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
-      [ hide-glass ] tri
-   ] [ drop ] if t ;
-
-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 <basic> >>model ] keep
-    <basic> combo-table new-table [ 1array ] >>quot >>table ;
\ No newline at end of file
diff --git a/extra/ui/gadgets/comboboxes/summary.txt b/extra/ui/gadgets/comboboxes/summary.txt
deleted file mode 100644 (file)
index 0f2ce2b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Combo boxes have a model choosen from a list of options
\ No newline at end of file
diff --git a/extra/ui/gadgets/controls/authors.txt b/extra/ui/gadgets/controls/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/ui/gadgets/controls/controls-docs.factor b/extra/ui/gadgets/controls/controls-docs.factor
deleted file mode 100644 (file)
index 1df6005..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644 (file)
index 0c7841b..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-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 ui.gadgets.editors.private
-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
deleted file mode 100644 (file)
index eeef94d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/ui/gadgets/layout/layout-docs.factor b/extra/ui/gadgets/layout/layout-docs.factor
deleted file mode 100644 (file)
index cd8f62b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644 (file)
index bd3ab1d..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-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
deleted file mode 100644 (file)
index 30b5ef5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Syntax for easily building GUIs and using templates
\ No newline at end of file
index 8730c0acc48330bd553edc4d7a93b3f2125c7dd1..06f1de6bc8c05d4c2ba0ae7ef21f95ad28f1501e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors math.vectors classes.tuple math.rectangles colors
-kernel sequences models opengl math math.order namespaces
+kernel locals sequences models opengl math math.order namespaces
 ui.commands ui.gestures ui.render ui.gadgets ui.gadgets.labels
 ui.gadgets.scrollers ui.gadgets.presentations ui.gadgets.viewports
 ui.gadgets.packs ;
@@ -78,7 +78,7 @@ M: list focusable-child* drop t ;
     dup list-empty? [
         2drop
     ] [
-        tuck control-value length rem >>index
+        [ control-value length rem ] [ (>>index) ] [ ] tri
         [ relayout-1 ] [ scroll>selected ] bi
     ] if ;
 
@@ -95,9 +95,9 @@ M: list focusable-child* drop t ;
         [ index>> ] keep nth-gadget invoke-secondary
     ] if ;
 
-: select-gadget ( gadget list -- )
-    tuck children>> index
-    [ swap select-index ] [ drop ] if* ;
+:: select-gadget ( gadget list -- )
+    gadget list children>> index
+    [ list select-index ] when* ;
 
 : clamp-loc ( point max -- point )
     vmin { 0 0 } vmax ;
diff --git a/extra/ui/gadgets/poppers/authors.txt b/extra/ui/gadgets/poppers/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/ui/gadgets/poppers/poppers.factor b/extra/ui/gadgets/poppers/poppers.factor
deleted file mode 100644 (file)
index 1c815d5..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-! 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 96497b8bbc5c0cc8c2a992f3bc7af8a5c78ff2f7..5d0fa1cf1e848380e5b791c31d5415e43071956b 100755 (executable)
@@ -10,7 +10,7 @@ IN: units.tests
 [ t ] [ 5 m 1 m d- 4 m = ] unit-test
 [ t ] [ 5 m 2 m d* 10 m^2 = ] unit-test
 [ t ] [ 5 m 2 m d/ 5/2 { } { } <dimensioned> = ] unit-test
-[ t ] [ 5 m 2 m tuck d/ drop 2 m = ] unit-test
+[ t ] [ 2 m 5 m 2 m d/ drop 2 m = ] unit-test
 
 [ t ] [ 1 m 2 m 3 m 3array d-product 6 m^3 = ] unit-test
 [ t ] [ 3 m d-recip 1/3 { } { m } <dimensioned> = ] unit-test
index b8e3f45a16eca370ff3ed7c63f1689c5dcd0252f..a293d79f78cc3c962e7cbc85e508bb3699da35f5 100755 (executable)
@@ -28,9 +28,9 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     dimensioned boa ;
 
 : >dimensioned< ( d -- n top bot )
-    [ value>> ] [ top>> ] [ bot>> ] tri ;
+    [ bot>> ] [ top>> ] [ value>> ] tri ;
 
-\ <dimensioned> [ >dimensioned< ] define-inverse
+\ <dimensioned> [ [ dimensioned boa ] undo ] define-inverse
 
 : dimensions ( dimensioned -- top bot )
     [ top>> ] [ bot>> ] bi ;
@@ -65,7 +65,7 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
 : d-sq ( d -- d ) dup d* ;
 
 : d-recip ( d -- d' )
-    >dimensioned< spin recip dimension-op> ;
+    >dimensioned< recip dimension-op> ;
 
 : d/ ( d d -- d ) d-recip d* ;
 
index 0ee2a114dd7b486702f1bb3d08a7f3bafc868a1f..29f710061c4b02ecfad9120d63f4a0fa83aa7baa 100644 (file)
@@ -48,7 +48,7 @@ MEMO: cities-named ( name -- cities )
 
 MEMO: cities-named-in ( name state -- cities )
     cities [
-        tuck [ name>> = ] [ state>> = ] 2bi* and
+        [ name>> = ] [ state>> = ] bi-curry bi* and
     ] with with filter ;
 
 : find-zip-code ( code -- city )
diff --git a/extra/vocabs/git/authors.txt b/extra/vocabs/git/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/vocabs/git/git.factor b/extra/vocabs/git/git.factor
new file mode 100644 (file)
index 0000000..eb945b5
--- /dev/null
@@ -0,0 +1,28 @@
+! (c)2009 Joe Groff bsd license
+USING: fry io io.directories io.encodings.ascii
+io.encodings.utf8 io.launcher io.pathnames kernel lexer
+namespaces parser sequences splitting vocabs vocabs.loader ;
+IN: vocabs.git
+
+<PRIVATE
+: git-object-id ( filename rev -- id/f )
+    [ [ parent-directory ] [ file-name ] bi ] dip swap '[
+        { "git" "ls-tree" } _ suffix _ suffix ascii [
+            readln
+            [ " " split1 nip " " split1 nip "\t" split1 drop ]
+            [ f ] if*
+        ] with-process-reader
+    ] with-directory ;
+
+: with-git-object-stream ( id quot -- )
+    [ { "git" "cat-file" "-p" } swap suffix utf8 ] dip with-process-reader ; inline
+PRIVATE>
+
+ERROR: git-revision-not-found path ;
+
+: use-vocab-rev ( vocab-name rev -- )
+    [ create-vocab vocab-source-path dup ] dip git-object-id 
+    [ [ input-stream get swap parse-stream call( -- ) ] with-git-object-stream ]
+    [ git-revision-not-found ] if* ;
+
+SYNTAX: USE-REV: scan scan use-vocab-rev ;
index 518462d7bb26e9338c67ee65bdad6f550807eb23..b0a4b146d49d97604da27ab6309d030d090a254a 100644 (file)
@@ -209,7 +209,7 @@ CONSTANT: vpri-slides
     }
     { $slide "Locals and lexical scope"
         { "Define lambda words with " { $link POSTPONE: :: } }
-        { "Establish bindings with " { $link POSTPONE: [let } " and " { $link POSTPONE: [let* } }
+        { "Establish bindings with " { $link POSTPONE: [let } " and " { $snippet "[let*" } }
         "Mutable bindings with correct semantics"
         { "Named inputs for quotations with " { $link POSTPONE: [| } }
         "Full closures"
index f1e8a388f73e23eef5ea4d98e52e1957991a3a64..54b392d77563fa1fb0b264db11709e0e99b1fa9f 100644 (file)
@@ -3,10 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>content</key>
-       <string>
-   [let | $1 [ $2 ] $3|
-      $0
-   ]</string>
+       <string>[let $0 ]</string>
        <key>name</key>
        <string>let</string>
        <key>scope</key>
index cee2d3ac7709b3ac59ed53a0c6deea567fb54f2a..f6d4e174c43fda52182051b76521c254a62eb669 100755 (executable)
@@ -3,7 +3,7 @@
 # change directories to a factor module
 function cdfactor { 
     code=$(printf "USING: io io.pathnames vocabs vocabs.loader ; "
-           printf "\"%s\" <vocab> vocab-source-path (normalize-path) print" $1)
+           printf "\"%s\" <vocab> vocab-source-path absolute-path print" $1)
     echo $code > $HOME/.cdfactor
     fn=$(factor $HOME/.cdfactor)
     dn=$(dirname $fn)
index 73d6781313909d150b3913b47046c56e199e5c15..8c4dbc4f8c362fa02772fee884a35972774fab06 100644 (file)
     ("\\(\n\\| \\);\\_>" (1 ">b"))
     ;; Let and lambda:
     ("\\_<\\(!(\\) .* \\()\\)" (1 "<") (2 ">"))
-    ("\\(\\[\\)\\(let\\|wlet\\|let\\*\\)\\( \\|$\\)" (1 "(]"))
+    ("\\(\\[\\)\\(let\\|let\\*\\)\\( \\|$\\)" (1 "(]"))
     ("\\(\\[\\)\\(|\\) +[^|]* \\(|\\)" (1 "(]") (2 "(|") (3 ")|"))
     (" \\(|\\) " (1 "(|"))
     (" \\(|\\)$" (1 ")"))
index c1b614b786b09747afc22cf1d1e573f1e833e403..340cdff032d65cbf8dcf4fafcd459a1e11febf01 100644 (file)
@@ -50,10 +50,10 @@ syn keyword factorCompileDirective inline foldable recursive
 
 syn keyword factorKeyword boolean
 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 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 ?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* assoc-map-as >alist assoc-filter-as 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 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 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 append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter! last-index-from reversed index-from cut* pad-tail (indices) concat-as remove-eq 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 remove-eq! drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift remove! map-sum new-sequence follow like remove-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! 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 member-eq? pop set-nth ?nth <flat-slice> second map! 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
index 0604f3cb475955edc1c24b7d14c591d0ca309686..4c04c59cd5f68c1d4a48e912d5ae027b9a8f31ea 100644 (file)
@@ -20,9 +20,9 @@ package, or checked out Factor sources from the GIT repository.</p>
 <ul>
 <li>Windows: Double-click <code>factor.exe</code>, or run
 <code>.\factor.com</code> in a command prompt</li>
-<li>Mac OS X: Double-click <code>Factor.app</code>code> or run <code>open
+<li>Mac OS X: Double-click <code>Factor.app</code> or run <code>open
 Factor.app</code> in a Terminal</li>
-<li>Unix: Run <code>./factor</code>code> in a shell</li>
+<li>Unix: Run <code>./factor</code> in a shell</li>
 </ul>
 
 <h2>Documentation</h2>
diff --git a/unmaintained/4DNav/4DNav-docs.factor b/unmaintained/4DNav/4DNav-docs.factor
new file mode 100755 (executable)
index 0000000..6f63f2e
--- /dev/null
@@ -0,0 +1,201 @@
+! Copyright (C) 2008 Jean-François Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel quotations strings ;
+IN: 4DNav
+
+
+HELP: menu-3D
+{ $values
+     { "gadget" "gadget" }
+}
+{ $description "The menu dedicated to 3D movements of the camera" } ;
+
+HELP: menu-4D
+{ $values
+    
+     { "gadget" "gadget" }
+}
+{ $description "The menu dedicated to 4D movements of space" } ;
+
+HELP: menu-bar
+{ $values
+    
+     { "gadget" "gadget" }
+}
+{ $description "return gadget containing menu buttons" } ;
+
+HELP: model-projection
+{ $values
+     { "x" "interger" }
+     { "space" "space" }
+}
+{ $description "Project space following coordinate x" } ;
+
+HELP: mvt-3D-1
+{ $values
+    
+     { "quot" "quotation" }
+}
+{ $description "return a quotation to orientate space to see it from first point of view" } ;
+
+HELP: mvt-3D-2
+{ $values
+    
+     { "quot" "quotation" }
+}
+{ $description "return a quotation to orientate space to see it from second point of view" } ;
+
+HELP: mvt-3D-3
+{ $values
+    
+     { "quot" "quotation" }
+}
+{ $description "return a quotation to orientate space to see it from third point of view" } ;
+
+HELP: mvt-3D-4
+{ $values
+    
+     { "quot" "quotation" }
+}
+{ $description "return a quotation to orientate space to see it from first point of view" } ;
+
+HELP: load-model-file
+{ $description "load space from file" } ;
+
+HELP: rotation-4D
+{ $values
+     { "m" "a rotation matrix" }
+}
+{ $description "Apply a 4D rotation matrix" } ;
+
+HELP: translation-4D
+{ $values
+     { "v" "vector" }
+}
+{ $description "Apply a 4D translation" } ;
+
+
+ARTICLE: "implementation details" "How 4DNav is done"
+"4DNav is build using :"
+
+{ $subsections
+    "4DNav.camera"
+    "adsoda-main-page"
+}
+;
+
+ARTICLE: "Space file" "Create a new space file"
+"To build a new space, create an XML file using " { $vocab-link "adsoda" } " model description. A solid is not caracterized by its corners but is defined as the intersection of hyperplanes."
+
+$nl
+"An example is:"
+{ $code """
+<model>
+<space>
+ <dimension>4</dimension>
+ <solid>
+     <name>4cube1</name>
+     <dimension>4</dimension>
+     <face>1,0,0,0,100</face>
+     <face>-1,0,0,0,-150</face>
+     <face>0,1,0,0,100</face>
+     <face>0,-1,0,0,-150</face>
+     <face>0,0,1,0,100</face>
+     <face>0,0,-1,0,-150</face>
+     <face>0,0,0,1,100</face>
+     <face>0,0,0,-1,-150</face>
+     <color>1,0,0</color>
+ </solid>
+ <solid>
+     <name>4triancube</name>
+     <dimension>4</dimension>
+     <face>1,0,0,0,160</face>
+     <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>
+     <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>
+     <face>0,0,1,0,140</face>
+     <face>0,0,-1,0,-180</face>
+     <face>0,0,0,1,110</face>
+     <face>0,0,0,-1,-180</face>
+     <color>0,1,0</color>
+ </solid>
+ <solid>
+     <name>triangone</name>
+     <dimension>4</dimension>
+     <face>1,0,0,0,60</face>
+     <face>0.5,0.8660254037844386,0,0,60</face>
+     <face>-0.5,0.8660254037844387,0,0,-20</face>
+     <face>-1.0,0,0,0,-100</face>
+     <face>-0.5,-0.8660254037844384,0,0,-100</face>
+     <face>0.5,-0.8660254037844387,0,0,-20</face>
+     <face>0,0,1,0,120</face>
+     <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>
+     <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>
+     <color>0,1,1</color>
+ </solid>
+ <light>
+     <direction>1,1,1,1</direction>
+     <color>0.2,0.2,0.6</color>
+ </light>
+ <color>0.8,0.9,0.9</color>
+</space>
+</model>""" } ;
+
+ARTICLE: "TODO" "Todo"
+{ $list 
+    "A vocab to initialize parameters"
+    "an editor mode" 
+        { $list "add a face to a solid"
+                "add a solid to the space"
+                "move a face"
+                "move a solid"
+                "select a solid in a list"
+                "select a face"
+                "display selected face"
+                "edit a solid color"
+                "add a light"
+                "edit a light color"
+                "move a light"
+                }
+    "add a tool wich give an hyperplane normal vector with enought points. Will use adsoda.intersect-hyperplanes with { { 0 } { 0 } { 1 } } "
+    "decorrelate 3D camera and activate them with select buttons"
+
+} ;
+
+
+ARTICLE: "4DNav" "The 4DNav app"
+{ $vocab-link "4DNav" }
+$nl
+{ $heading "4D Navigator" }
+"4DNav is a simple tool to visualize 4 dimensionnal objects."
+$nl
+"It uses " { $vocab-link "adsoda" } " library to display a 4D space and navigate thru it."
+$nl
+"It will display:"
+{ $list
+    { "a menu window" }
+    {  "4 visualization windows" }
+}
+"Each visualization window represents the projection of the 4D space on a particular 3D space."
+
+{ $heading "Start" }
+"type:" { $code "\"4DNav\" run" } 
+
+{ $heading "Navigation" }
+"Menu window is divided in 4 areas"
+{ $list
+    { "a space-file chooser to select the file to display" }
+    { "a parametrization area to select the projection mode" }
+    { "4D submenu to translate and rotate the 4D space" }
+    { "3D submenu to move the camera in 3D space. Cameras in every 3D spaces are manipulated as a single one" }
+    }
+
+{ $heading "Links" }
+{ $subsections
+    "Space file"
+    "TODO"
+    "implementation details"
+}
+
+;
+
+ABOUT: "4DNav"
diff --git a/unmaintained/4DNav/4DNav.factor b/unmaintained/4DNav/4DNav.factor
new file mode 100755 (executable)
index 0000000..b9679ec
--- /dev/null
@@ -0,0 +1,567 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: kernel \r
+namespaces\r
+accessors\r
+assocs\r
+make\r
+math\r
+math.functions\r
+math.trig\r
+math.parser\r
+hashtables\r
+sequences\r
+combinators\r
+continuations\r
+colors\r
+colors.constants\r
+prettyprint\r
+vars\r
+quotations\r
+io\r
+io.directories\r
+io.pathnames\r
+help.markup\r
+io.files\r
+ui.gadgets.panes\r
+ ui\r
+       ui.gadgets\r
+       ui.traverse\r
+       ui.gadgets.borders\r
+       ui.gadgets.frames\r
+       ui.gadgets.tracks\r
+       ui.gadgets.labels\r
+       ui.gadgets.labeled       \r
+       ui.gadgets.lists\r
+       ui.gadgets.buttons\r
+       ui.gadgets.packs\r
+       ui.gadgets.grids\r
+       ui.gadgets.corners\r
+       ui.gestures\r
+       ui.gadgets.scrollers\r
+splitting\r
+vectors\r
+math.vectors\r
+values\r
+4DNav.turtle\r
+4DNav.window3D\r
+4DNav.deep\r
+4DNav.space-file-decoder\r
+models\r
+fry\r
+adsoda\r
+adsoda.tools\r
+;\r
+QUALIFIED-WITH: ui.pens.solid s\r
+QUALIFIED-WITH: ui.gadgets.wrappers w\r
+\r
+\r
+IN: 4DNav\r
+VALUE: selected-file\r
+VALUE: translation-step\r
+VALUE: rotation-step\r
+\r
+3 to: translation-step \r
+5 to: rotation-step\r
+\r
+VAR: selected-file-model\r
+VAR: observer3d \r
+VAR: view1 \r
+VAR: view2\r
+VAR: view3\r
+VAR: view4\r
+VAR: present-space\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+! namespace utilities\r
+\r
+: closed-quot ( quot -- quot )\r
+  namestack swap '[ namestack [ _ set-namestack @ ] dip set-namestack ] ;\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+! waiting for deep-cleave-quots\r
+\r
+: 4D-Rxy ( angle -- Rx ) deg>rad\r
+[ 1.0 , 0.0 , 0.0       , 0.0 ,\r
+  0.0 , 1.0 , 0.0       , 0.0 ,\r
+  0.0 , 0.0 , dup cos  , dup sin neg  ,\r
+  0.0 , 0.0 , dup sin  , dup cos  ,  ] 4 make-matrix nip ;\r
+\r
+: 4D-Rxz ( angle -- Ry ) deg>rad\r
+[ 1.0 , 0.0       , 0.0 , 0.0 ,\r
+  0.0 , dup cos  , 0.0 , dup sin neg  ,\r
+  0.0 , 0.0       , 1.0 , 0.0 ,\r
+  0.0 , dup sin  , 0.0 , dup cos  ,  ] 4 make-matrix nip ;\r
+\r
+: 4D-Rxw ( angle -- Rz ) deg>rad\r
+[ 1.0 , 0.0       , 0.0           , 0.0 ,\r
+  0.0 , dup cos  , dup sin neg  , 0.0 ,\r
+  0.0 , dup sin  , dup cos     , 0.0 ,\r
+  0.0 , 0.0       , 0.0           , 1.0 , ] 4 make-matrix nip ;\r
+\r
+: 4D-Ryz ( angle -- Rx ) deg>rad\r
+[ dup cos  , 0.0 , 0.0 , dup sin neg  ,\r
+  0.0       , 1.0 , 0.0 , 0.0 ,\r
+  0.0       , 0.0 , 1.0 , 0.0 ,\r
+  dup sin  , 0.0 , 0.0 , dup cos  ,   ] 4 make-matrix nip ;\r
+\r
+: 4D-Ryw ( angle -- Ry ) deg>rad\r
+[ dup cos  , 0.0 , dup sin neg  , 0.0 ,\r
+  0.0       , 1.0 , 0.0           , 0.0 ,\r
+  dup sin  , 0.0 , dup cos     , 0.0 ,\r
+  0.0       , 0.0 , 0.0        , 1.0 ,  ] 4 make-matrix nip ;\r
+\r
+: 4D-Rzw ( angle -- Rz ) deg>rad\r
+[ dup cos  , dup sin neg  , 0.0 , 0.0 ,\r
+  dup sin  , dup cos     , 0.0 , 0.0 ,\r
+  0.0       , 0.0           , 1.0 , 0.0 ,\r
+  0.0       , 0.0          , 0.0 , 1.0 ,  ] 4 make-matrix nip ;\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+! UI\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+: button* ( string quot -- button ) \r
+    closed-quot <repeat-button>  ;\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+! \r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+: model-projection-chooser ( -- gadget )\r
+   observer3d> projection-mode>>\r
+   { { 1 "perspective" } { 0 "orthogonal" } } \r
+   <radio-buttons> ;\r
+\r
+: collision-detection-chooser ( -- gadget )\r
+   observer3d> collision-mode>>\r
+   { { t "on" } { f "off" }  } <radio-buttons> ;\r
+\r
+: model-projection ( x -- space ) \r
+    present-space>  swap space-project ;\r
+\r
+: update-observer-projections (  -- )\r
+    view1> relayout-1 \r
+    view2> relayout-1 \r
+    view3> relayout-1 \r
+    view4> relayout-1 ;\r
+\r
+: update-model-projections (  -- )\r
+    0 model-projection <model> view1> (>>model)\r
+    1 model-projection <model> view2> (>>model)\r
+    2 model-projection <model> view3> (>>model)\r
+    3 model-projection <model> view4> (>>model) ;\r
+\r
+: camera-action ( quot -- quot ) \r
+    '[ drop _ observer3d>  \r
+    with-self update-observer-projections ] \r
+    closed-quot ;\r
+\r
+: win3D ( text gadget -- ) \r
+    "navigateur 4D : " rot append open-window ;\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+! 4D object manipulation\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+: (mvt-4D) ( quot -- )   \r
+    present-space>  \r
+        swap call space-ensure-solids \r
+    >present-space \r
+    update-model-projections \r
+    update-observer-projections ; inline\r
+\r
+: rotation-4D ( m -- ) \r
+    '[ _ [ [ middle-of-space dup vneg ] keep \r
+        swap space-translate ] dip\r
+         space-transform \r
+         swap space-translate\r
+    ] (mvt-4D) ;\r
+\r
+: translation-4D ( v -- ) '[ _ space-translate ] (mvt-4D) ;\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+! menu\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+: menu-rotations-4D ( -- gadget )\r
+    3 3 <frame>\r
+        { 1 1 } >>filled-cell\r
+         <pile> 1 >>fill\r
+          "XY +" [ drop rotation-step 4D-Rxy rotation-4D ] \r
+                button* add-gadget\r
+          "XY -" [ drop rotation-step neg 4D-Rxy rotation-4D ] \r
+                button* add-gadget \r
+       @top-left grid-add    \r
+        <pile> 1 >>fill\r
+          "XZ +" [ drop rotation-step 4D-Rxz rotation-4D ] \r
+                button* add-gadget\r
+          "XZ -" [ drop rotation-step neg 4D-Rxz rotation-4D ] \r
+                button* add-gadget \r
+       @top grid-add    \r
+        <pile> 1 >>fill\r
+          "YZ +" [ drop rotation-step 4D-Ryz rotation-4D ] \r
+                button* add-gadget\r
+          "YZ -" [ drop rotation-step neg 4D-Ryz rotation-4D ] \r
+                button* add-gadget \r
+        @center grid-add\r
+         <pile> 1 >>fill\r
+          "XW +" [ drop rotation-step 4D-Rxw rotation-4D ] \r
+                button* add-gadget\r
+          "XW -" [ drop rotation-step neg 4D-Rxw rotation-4D ] \r
+                button* add-gadget \r
+        @top-right grid-add   \r
+         <pile> 1 >>fill\r
+          "YW +" [ drop rotation-step 4D-Ryw rotation-4D ] \r
+                button* add-gadget\r
+          "YW -" [ drop rotation-step neg 4D-Ryw rotation-4D ] \r
+                button* add-gadget \r
+       @right grid-add    \r
+         <pile> 1 >>fill\r
+          "ZW +" [ drop rotation-step 4D-Rzw rotation-4D ] \r
+                button* add-gadget\r
+          "ZW -" [ drop rotation-step neg 4D-Rzw rotation-4D ] \r
+                button* add-gadget \r
+       @bottom-right grid-add    \r
+;\r
+\r
+: menu-translations-4D ( -- gadget )\r
+    3 3 <frame> \r
+        { 1 1 } >>filled-cell\r
+        <pile> 1 >>fill\r
+            <shelf> 1 >>fill  \r
+                "X+" [ drop {  1 0 0 0 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget\r
+                "X-" [ drop { -1 0 0 0 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget \r
+            add-gadget\r
+            "YZW" <label> add-gadget\r
+         @bottom-right grid-add\r
+         <pile> 1 >>fill\r
+            "XZW" <label> add-gadget\r
+            <shelf> 1 >>fill\r
+                "Y+" [ drop  { 0  1 0 0 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget\r
+                "Y-" [ drop  { 0 -1 0 0 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget \r
+                add-gadget\r
+         @top-right grid-add\r
+         <pile> 1 >>fill\r
+            "XYW" <label> add-gadget\r
+            <shelf> 1 >>fill\r
+                "Z+" [ drop { 0 0  1 0 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget\r
+                "Z-" [ drop { 0 0 -1 0 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget \r
+                add-gadget                 \r
+        @top-left grid-add     \r
+        <pile> 1 >>fill\r
+            <shelf> 1 >>fill\r
+                "W+" [ drop { 0 0 0 1  } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget\r
+                "W-" [ drop { 0 0 0 -1 } translation-step v*n \r
+                    translation-4D ] \r
+                    button* add-gadget \r
+                add-gadget\r
+            "XYZ" <label> add-gadget\r
+        @bottom-left grid-add \r
+        "X" <label> @center grid-add\r
+;\r
+\r
+: menu-4D ( -- gadget )  \r
+    <shelf> \r
+        "rotations" <label>     add-gadget\r
+        menu-rotations-4D       add-gadget\r
+        "translations" <label>  add-gadget\r
+        menu-translations-4D    add-gadget\r
+        0.5 >>align\r
+        { 0 10 } >>gap\r
+;\r
+\r
+\r
+! ------------------------------------------------------\r
+\r
+: redraw-model ( space -- )\r
+    >present-space \r
+    update-model-projections \r
+    update-observer-projections ;\r
+\r
+: load-model-file ( -- )\r
+  selected-file dup selected-file-model> set-model \r
+  read-model-file \r
+  redraw-model ;\r
+\r
+: mvt-3D-X ( turn pitch -- quot )\r
+    '[ turtle-pos> norm neg reset-turtle \r
+        _ turn-left \r
+        _ pitch-up \r
+        step-turtle ] ;\r
+\r
+: mvt-3D-1 ( -- quot )      90  0 mvt-3D-X ; inline\r
+: mvt-3D-2 ( -- quot )      0  90 mvt-3D-X ; inline\r
+: mvt-3D-3 ( -- quot )      0   0 mvt-3D-X ; inline\r
+: mvt-3D-4 ( -- quot )      45 45 mvt-3D-X ; inline\r
+\r
+: camera-button ( string quot -- button ) \r
+    [ <label>  ] dip camera-action <repeat-button> ;\r
+\r
+! ----------------------------------------------------------\r
+! file chooser\r
+! ----------------------------------------------------------\r
+: <run-file-button> ( file-name -- button )\r
+  dup '[ drop  _  \ selected-file set-value load-model-file \r
+   ] \r
+ closed-quot  <roll-button> { 0 0 } >>align ;\r
+\r
+: <list-runner> ( -- gadget )\r
+    "resource:extra/4DNav" \r
+  <pile> 1 >>fill \r
+    over dup directory-files  \r
+    [ ".xml" tail? ] filter \r
+    [ append-path ] with map\r
+    [ <run-file-button> add-gadget ] each\r
+    swap <labeled-gadget> ;\r
+\r
+! -----------------------------------------------------\r
+\r
+: menu-rotations-3D ( -- gadget )\r
+    3 3 <frame>\r
+        { 1 1 } >>filled-cell\r
+        "Turn\n left"  [ rotation-step  turn-left  ] \r
+            camera-button   @left grid-add     \r
+        "Turn\n right" [ rotation-step turn-right ] \r
+            camera-button   @right grid-add     \r
+        "Pitch down"   [ rotation-step  pitch-down ] \r
+            camera-button   @bottom grid-add     \r
+        "Pitch up"     [ rotation-step  pitch-up   ] \r
+            camera-button   @top grid-add     \r
+        <shelf>  1 >>fill\r
+            "Roll left\n (ctl)"  [ rotation-step  roll-left  ] \r
+                camera-button   add-gadget  \r
+            "Roll right\n(ctl)"  [ rotation-step  roll-right ] \r
+                camera-button   add-gadget  \r
+        @center grid-add \r
+;\r
+\r
+: menu-translations-3D ( -- gadget )\r
+    3 3 <frame>\r
+        { 1 1 } >>filled-cell\r
+        "left\n(alt)"        [ translation-step  strafe-left  ]\r
+            camera-button @left grid-add  \r
+        "right\n(alt)"       [ translation-step  strafe-right ]\r
+            camera-button @right grid-add     \r
+        "Strafe up \n (alt)" [ translation-step strafe-up    ] \r
+            camera-button @top grid-add\r
+        "Strafe down\n (alt)" [ translation-step strafe-down  ]\r
+            camera-button @bottom grid-add    \r
+        <pile>  1 >>fill\r
+            "Forward (ctl)"  [  translation-step step-turtle ] \r
+                camera-button add-gadget\r
+            "Backward (ctl)" \r
+                [ translation-step neg step-turtle ] \r
+                camera-button   add-gadget\r
+        @center grid-add\r
+;\r
+\r
+: menu-quick-views ( -- gadget )\r
+    <shelf>\r
+        "View 1 (1)" mvt-3D-1 camera-button   add-gadget\r
+        "View 2 (2)" mvt-3D-2 camera-button   add-gadget\r
+        "View 3 (3)" mvt-3D-3 camera-button   add-gadget \r
+        "View 4 (4)" mvt-3D-4 camera-button   add-gadget \r
+;\r
+\r
+: menu-3D ( -- gadget ) \r
+    <pile>\r
+        <shelf>   \r
+            menu-rotations-3D    add-gadget\r
+            menu-translations-3D add-gadget\r
+            0.5 >>align\r
+            { 0 10 } >>gap\r
+        add-gadget\r
+        menu-quick-views add-gadget ; \r
+\r
+TUPLE: handler < w:wrapper table ;\r
+\r
+: <handler> ( child -- handler ) handler w:new-wrapper ;\r
+\r
+M: handler handle-gesture ( gesture gadget -- ? )\r
+   tuck table>> at dup [ call( gadget -- ) f ] [ 2drop t ] if ;\r
+\r
+: add-keyboard-delegate ( obj -- obj )\r
+ <handler>\r
+H{\r
+        { T{ key-down f f "LEFT" }  \r
+            [ [ rotation-step turn-left ] camera-action ] }\r
+        { T{ key-down f f "RIGHT" } \r
+            [ [ rotation-step turn-right ] camera-action ] }\r
+        { T{ key-down f f "UP" }    \r
+            [ [ rotation-step pitch-down ] camera-action ] }\r
+        { T{ key-down f f "DOWN" }  \r
+            [ [ rotation-step pitch-up ] camera-action ] }\r
+\r
+        { T{ key-down f { C+ } "UP" } \r
+           [ [ translation-step step-turtle ] camera-action ] }\r
+        { T{ key-down f { C+ } "DOWN" } \r
+            [ [ translation-step neg step-turtle ] \r
+                    camera-action ] }\r
+        { T{ key-down f { C+ } "LEFT" } \r
+            [ [ rotation-step roll-left ] camera-action ] }\r
+        { T{ key-down f { C+ } "RIGHT" } \r
+            [ [ rotation-step roll-right ] camera-action ] }\r
+\r
+        { T{ key-down f { A+ } "LEFT" }  \r
+           [ [ translation-step strafe-left ] camera-action ] }\r
+        { T{ key-down f { A+ } "RIGHT" } \r
+          [ [ translation-step strafe-right ] camera-action ] }\r
+        { T{ key-down f { A+ } "UP" }    \r
+            [ [ translation-step strafe-up ] camera-action ] }\r
+        { T{ key-down f { A+ } "DOWN" }  \r
+           [ [ translation-step strafe-down ] camera-action ] }\r
+\r
+\r
+        { T{ key-down f f "1" } [ mvt-3D-1 camera-action ] }\r
+        { T{ key-down f f "2" } [ mvt-3D-2 camera-action ] }\r
+        { T{ key-down f f "3" } [ mvt-3D-3  camera-action ] }\r
+        { T{ key-down f f "4" } [ mvt-3D-4  camera-action ] }\r
+\r
+    } >>table\r
+    ;    \r
+\r
+! --------------------------------------------\r
+! print elements \r
+! --------------------------------------------\r
+! print-content\r
+\r
+GENERIC: adsoda-display-model ( x -- ) \r
+\r
+M: light adsoda-display-model \r
+"\n light : " .\r
+     { \r
+        [ direction>> "direction : " pprint . ] \r
+        [ color>> "color : " pprint . ]\r
+    }   cleave\r
+    ;\r
+\r
+M: face adsoda-display-model \r
+     {\r
+        [ halfspace>> "halfspace : " pprint . ] \r
+        [ touching-corners>> "touching corners : " pprint . ]\r
+    }   cleave\r
+    ;\r
+M: solid adsoda-display-model \r
+     {\r
+        [ name>> "solid called : " pprint . ] \r
+        [ color>> "color : " pprint . ]\r
+        [ dimension>> "dimension : " pprint . ]\r
+        [ faces>> "composed of faces : " pprint \r
+            [ adsoda-display-model ] each ]\r
+    }   cleave\r
+    ;\r
+M: space adsoda-display-model \r
+     {\r
+        [ dimension>> "dimension : " pprint . ] \r
+        [ ambient-color>> "ambient-color : " pprint . ]\r
+        [ solids>> "composed of solids : " pprint \r
+            [ adsoda-display-model ] each ]\r
+        [ lights>> "composed of lights : " pprint \r
+            [ adsoda-display-model ] each ] \r
+    }   cleave\r
+    ;\r
+\r
+! ----------------------------------------------\r
+: menu-bar ( -- gadget )\r
+       <shelf>\r
+          "reinit" [ drop load-model-file ] button* add-gadget\r
+          selected-file-model> <label-control> add-gadget\r
+    ;\r
+\r
+\r
+: controller-window* ( -- gadget )\r
+    { 0 1 } <track>\r
+        menu-bar f track-add\r
+        <list-runner>  \r
+            <scroller>\r
+        f track-add\r
+        <shelf>\r
+            "Projection mode : " <label> add-gadget\r
+            model-projection-chooser add-gadget\r
+        f track-add\r
+        <shelf>\r
+            "Collision detection (slow and buggy ) : " \r
+                <label> add-gadget\r
+            collision-detection-chooser add-gadget\r
+        f track-add\r
+        <pile>\r
+            0.5 >>align    \r
+            menu-4D add-gadget \r
+            COLOR: purple s:<solid> >>interior\r
+            "4D movements" <labeled-gadget>\r
+        f track-add\r
+        <pile>\r
+            0.5 >>align\r
+            { 2 2 } >>gap\r
+            menu-3D add-gadget\r
+            COLOR: purple s:<solid> >>interior\r
+            "Camera 3D" <labeled-gadget>\r
+        f track-add      \r
+        COLOR: gray s:<solid> >>interior\r
+ ;\r
\r
+: viewer-windows* ( --  )\r
+    "YZW" view1> win3D \r
+    "XZW" view2> win3D \r
+    "XYW" view3> win3D \r
+    "XYZ" view4> win3D   \r
+;\r
+\r
+: navigator-window* ( -- )\r
+    controller-window*\r
+    viewer-windows*   \r
+    add-keyboard-delegate\r
+    "navigateur 4D" open-window\r
+;\r
+\r
+: windows ( -- ) [ [ navigator-window* ] with-scope ] with-ui ;\r
+\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+: init-variables ( -- )\r
+    "choose a file" <model> >selected-file-model  \r
+    <observer> >observer3d\r
+    [ observer3d> >self\r
+      reset-turtle \r
+      45 turn-left \r
+      45 pitch-up \r
+      -300 step-turtle \r
+    ] with-scope\r
+    \r
+;\r
+\r
+\r
+: init-models ( -- )\r
+    0 model-projection observer3d> <window3D> >view1\r
+    1 model-projection observer3d> <window3D> >view2\r
+    2 model-projection observer3d> <window3D> >view3\r
+    3 model-projection observer3d> <window3D> >view4\r
+;\r
+\r
+: 4DNav ( -- ) \r
+    init-variables\r
+    selected-file read-model-file >present-space\r
+    init-models\r
+    windows\r
+;\r
+\r
+MAIN: 4DNav\r
+\r
+\r
diff --git a/unmaintained/4DNav/authors.txt b/unmaintained/4DNav/authors.txt
new file mode 100755 (executable)
index 0000000..a6a9693
--- /dev/null
@@ -0,0 +1 @@
+Jeff Bigot
\ No newline at end of file
diff --git a/unmaintained/4DNav/camera/authors.txt b/unmaintained/4DNav/camera/authors.txt
new file mode 100755 (executable)
index 0000000..bbc876e
--- /dev/null
@@ -0,0 +1 @@
+Adam Wendt
diff --git a/unmaintained/4DNav/camera/camera-docs.factor b/unmaintained/4DNav/camera/camera-docs.factor
new file mode 100755 (executable)
index 0000000..65afafc
--- /dev/null
@@ -0,0 +1,88 @@
+! Copyright (C) 2008 Jean-François Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel ;
+IN: 4DNav.camera
+
+HELP: camera-eye
+{ $values
+    
+     { "point" "position" }
+}
+{ $description "return the position of the camera" } ;
+
+HELP: camera-focus
+{ $values
+    
+     { "point" "position" }
+}
+{ $description "return the point the camera looks at" } ;
+
+HELP: camera-up
+{ $values
+    
+     { "dirvec" "upside direction" }
+}
+{ $description "In order to precise the roling position of camera give an upward vector" } ;
+
+HELP: do-look-at
+{ $values
+     { "camera" "direction" }
+}
+{ $description "Word to use in replacement of gl-look-at when using a camera" } ;
+
+ARTICLE: "4DNav.camera" "Camera"
+{ $vocab-link "4DNav.camera" }
+$nl
+"A camera is defined by:"
+{ $list
+{ "a position (" { $link camera-eye } ")" }
+{ "a focus direction (" { $link camera-focus } ")" }
+{ "an attitude information (" { $link camera-up } ")" }
+}
+"Use " { $link do-look-at } " in opengl statement in placement of gl-look-at"
+$nl
+"A camera is a " { $vocab-link "4DNav.turtle" } " object. Its a special vocab to handle mouvements of a 3D object:"
+{ $list
+{ "To define a camera"
+{
+    $unchecked-example
+    
+"VAR: my-camera"
+": init-my-camera ( -- )"
+"    <turtle> >my-camera"
+"    [ my-camera> >self"
+"      reset-turtle "
+"    ] with-scope ;"
+} }
+{ "To move it"
+{
+    $unchecked-example
+
+"    [ my-camera> >self"
+"      45 pitch-up "
+"      5 step-turtle" 
+"    ] with-scope "
+} }
+{ "or"
+{
+    $unchecked-example
+
+"    [ my-camera> >self"
+"      5 strafe-left"
+"    ] with-scope "
+}
+}
+{
+"to use it in an opengl statement"
+{
+    $unchecked-example
+  "my-camera> do-look-at"
+
+}
+}
+}
+
+
+;
+
+ABOUT: "4DNav.camera"
diff --git a/unmaintained/4DNav/camera/camera.factor b/unmaintained/4DNav/camera/camera.factor
new file mode 100755 (executable)
index 0000000..0d46d73
--- /dev/null
@@ -0,0 +1,18 @@
+USING: kernel namespaces math.vectors opengl opengl.glu 4DNav.turtle  ;
+
+IN: 4DNav.camera
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: camera-eye ( -- point ) turtle-pos> ;
+
+: camera-focus ( -- point ) 
+    [ 1 step-turtle turtle-pos> ] save-self ;
+
+: camera-up ( -- dirvec )
+[ 90 pitch-up turtle-pos> 1 step-turtle turtle-pos> swap v- ] 
+    save-self ;
+
+: do-look-at ( camera -- )
+[ >self camera-eye camera-focus camera-up gl-look-at ] 
+    with-scope ;
diff --git a/unmaintained/4DNav/deep/deep-docs.factor b/unmaintained/4DNav/deep/deep-docs.factor
new file mode 100755 (executable)
index 0000000..78439c6
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2008 Jean-François Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel quotations sequences ;
+IN: 4DNav.deep
+
+! HELP: deep-cleave-quots
+! { $values
+!     { "seq" sequence }
+!     { "quot" quotation }
+! }
+! { $description "A word to build a soquence from a sequence of quotation" }
+! 
+! { $examples
+! "It is useful to build matrix"
+! { $example "USING: math math.trig ; "
+!     " 30 deg>rad "
+!    "  {  { [ cos ] [ sin neg ]   0 } "
+!    "     { [ sin ] [ cos ]       0 } "
+!    "     {   0       0           1 } "
+!    "  } deep-cleave-quots " 
+!     " "
+! 
+! 
+! } }
+! ;
+
+ARTICLE: "4DNav.deep" "Deep"
+{ $vocab-link "4DNav.deep" }
+;
+
+ABOUT: "4DNav.deep"
diff --git a/unmaintained/4DNav/deep/deep.factor b/unmaintained/4DNav/deep/deep.factor
new file mode 100755 (executable)
index 0000000..b18000a
--- /dev/null
@@ -0,0 +1,13 @@
+USING: macros quotations math math.functions math.trig \r
+sequences.deep kernel make fry combinators grouping ;\r
+IN: 4DNav.deep\r
+\r
+! USING: bake ;\r
+! MACRO: deep-cleave-quots ( seq -- quot )\r
+!    [ [ quotation? ] deep-filter ]\r
+!    [ [ dup quotation? [ drop , ] when ] deep-map ]\r
+!    bi '[ _ cleave _ bake ] ;\r
+\r
+: make-matrix ( quot width -- matrix ) \r
+    [ { } make ] dip group ; inline\r
+\r
diff --git a/unmaintained/4DNav/deploy.factor b/unmaintained/4DNav/deploy.factor
new file mode 100755 (executable)
index 0000000..44481f4
--- /dev/null
@@ -0,0 +1,14 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-c-types? t }
+    { deploy-word-props? t }
+    { deploy-name "4DNav" }
+    { deploy-ui? t }
+    { deploy-math? t }
+    { deploy-threads? t }
+    { deploy-reflection 3 }
+    { deploy-unicode? t }
+    { deploy-io 3 }
+    { "stop-after-last-window?" t }
+    { deploy-word-defs? t }
+}
diff --git a/unmaintained/4DNav/file-chooser/authors.txt b/unmaintained/4DNav/file-chooser/authors.txt
new file mode 100755 (executable)
index 0000000..a6a9693
--- /dev/null
@@ -0,0 +1 @@
+Jeff Bigot
\ No newline at end of file
diff --git a/unmaintained/4DNav/file-chooser/file-chooser.factor b/unmaintained/4DNav/file-chooser/file-chooser.factor
new file mode 100755 (executable)
index 0000000..51bebc3
--- /dev/null
@@ -0,0 +1,154 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING:\r
+kernel\r
+io.files\r
+io.backend\r
+io.directories\r
+io.files.info\r
+io.pathnames\r
+sequences\r
+models\r
+strings\r
+ui\r
+ui.operations\r
+ui.commands\r
+ui.gestures\r
+ui.gadgets\r
+ui.gadgets.buttons\r
+ui.gadgets.lists\r
+ui.gadgets.labels\r
+ui.gadgets.tracks\r
+ui.gadgets.packs\r
+ui.gadgets.panes\r
+ui.gadgets.scrollers\r
+prettyprint\r
+combinators\r
+accessors\r
+values\r
+tools.walker\r
+fry\r
+;\r
+IN: 4DNav.file-chooser\r
+\r
+TUPLE: file-chooser < track \r
+    path\r
+    extension \r
+    selected-file\r
+    presenter\r
+    hook  \r
+    list\r
+    ;\r
+\r
+: find-file-list ( gadget -- list )\r
+    [ file-chooser? ] find-parent list>> ;\r
+\r
+file-chooser H{\r
+    { T{ key-down f f "UP" } \r
+        [ find-file-list select-previous ] }\r
+    { T{ key-down f f "DOWN" } \r
+        [ find-file-list select-next ] }\r
+    { T{ key-down f f "PAGE_UP" } \r
+        [ find-file-list list-page-up ] }\r
+    { T{ key-down f f "PAGE_DOWN" } \r
+        [ find-file-list list-page-down ] }\r
+    { T{ key-down f f "RET" } \r
+        [ find-file-list invoke-value-action ] }\r
+    { T{ button-down } \r
+        request-focus }\r
+    { T{ button-down f 1 } \r
+        [ find-file-list invoke-value-action ]  }\r
+} set-gestures\r
+\r
+: list-of-files ( file-chooser -- seq )\r
+     [ path>> value>> directory-entries ] [ extension>> ] bi\r
+     '[ [ name>> _ [ tail? ] with any? ] \r
+     [ directory? ] bi or ]  filter\r
+;\r
+\r
+: update-filelist-model ( file-chooser -- )\r
+    [ list-of-files ] [ model>> ] bi set-model ;\r
+\r
+: init-filelist-model ( file-chooser -- file-chooser )\r
+    dup list-of-files <model> >>model ; \r
+\r
+: (fc-go) ( file-chooser button quot -- )\r
+    [ [ file-chooser? ] find-parent dup path>> ] dip\r
+    call\r
+    normalize-path swap set-model\r
+    update-filelist-model\r
+    drop ; inline\r
+\r
+: fc-go-parent ( file-chooser button -- )\r
+    [ dup value>> parent-directory ] (fc-go) ;\r
+\r
+: fc-go-home ( file-chooser button -- )\r
+    [ home ] (fc-go) ;\r
+\r
+: fc-change-directory ( file-chooser file -- )\r
+    dupd [ path>> value>> normalize-path ] [ name>> ] bi* \r
+    append-path over path>> set-model    \r
+    update-filelist-model\r
+;\r
+\r
+: fc-load-file ( file-chooser file -- )\r
+  over [ name>> ] [ selected-file>> ] bi* set-model \r
+  [ [ path>> value>> ] [ selected-file>> value>> ] bi append ] [ hook>> ] bi\r
+  call( path -- )\r
+; inline\r
+\r
+! : fc-ok-action ( file-chooser -- quot )\r
+!  dup selected-file>> value>>  "" =\r
+!    [ drop [ drop ] ] [    \r
+!            [ path>> value>> ] \r
+!            [ selected-file>> value>> append ] \r
+!            [ hook>> prefix ] tri\r
+!        [ drop ] prepend\r
+!    ]  if ; \r
+\r
+: line-selected-action ( file-chooser -- )\r
+     dup list>> list-value\r
+     dup directory? \r
+     [ fc-change-directory ] [ fc-load-file ] if ;\r
+\r
+: present-dir-element ( element -- string )\r
+    [ name>> ] [ directory? ] bi   [ "-> " prepend ] when ;\r
+\r
+: <file-list> ( file-chooser -- list )\r
+  dup [ nip line-selected-action ] curry \r
+  [ present-dir-element ] rot model>> <list> ;\r
+\r
+: <file-chooser> ( hook path extension -- gadget )\r
+    { 0 1 } file-chooser new-track\r
+    swap >>extension\r
+    swap <model> >>path\r
+    "" <model> >>selected-file\r
+    swap >>hook\r
+    init-filelist-model\r
+    dup <file-list> >>list\r
+    "choose a file in directory " <label> f track-add\r
+    dup path>> <label-control> f track-add\r
+    dup extension>> ", " join "limited to : " prepend \r
+        <label> f track-add\r
+    <shelf> \r
+        "selected file : " <label> add-gadget\r
+        over selected-file>> <label-control> add-gadget\r
+    f track-add\r
+    <shelf> \r
+        over [  swap fc-go-parent ] curry  "go up" \r
+            swap <border-button> add-gadget\r
+        over [  swap fc-go-home ] curry  "go home" \r
+            swap <border-button> add-gadget\r
+    !    over [ swap fc-ok-action ] curry "OK" \r
+    !    swap <bevel-button> add-gadget\r
+    !    [ drop ]  "Cancel" swap <bevel-button> add-gadget\r
+    f track-add\r
+    dup list>> <scroller> 1 track-add\r
+;\r
+\r
+M: file-chooser pref-dim* drop { 400 200 } ;\r
+\r
+: file-chooser-window ( -- )\r
+    [ . ] home { "xml" "txt" }   <file-chooser> \r
+    "Choose a file" open-window ;\r
+\r
diff --git a/unmaintained/4DNav/hypercube.xml b/unmaintained/4DNav/hypercube.xml
new file mode 100755 (executable)
index 0000000..0d46e3b
--- /dev/null
@@ -0,0 +1,37 @@
+<model>\r
+<space>\r
+       <name>hypercube</name>\r
+       <dimension>4</dimension>\r
+       <solid>\r
+               <name>4cube1</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,100</face>\r
+               <face>-1,0,0,0,-150</face>\r
+               <face>0,1,0,0,100</face>\r
+               <face>0,-1,0,0,-150</face>\r
+               <face>0,0,1,0,100</face>\r
+               <face>0,0,-1,0,-150</face>\r
+               <face>0,0,0,1,100</face>\r
+               <face>0,0,0,-1,-150</face>\r
+               <color>1,0,0</color>\r
+       </solid>\r
+       <solid>\r
+               <name>4cube1</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,100</face>\r
+               <face>-1,0,0,0,-150</face>\r
+               <face>0,1,0,0,100</face>\r
+               <face>0,-1,0,0,-150</face>\r
+               <face>0,0,1,0,100</face>\r
+               <face>0,0,-1,0,-150</face>\r
+               <face>0,0,0,1,100</face>\r
+               <face>0,0,0,-1,-150</face>\r
+               <color>1,0,0</color>\r
+       </solid>\r
+       <light>\r
+               <direction>1,1,1,1</direction>\r
+               <color>0.2,0.2,0.6</color>\r
+       </light>\r
+       <color>0.8,0.9,0.9</color>\r
+</space>\r
+</model>\r
diff --git a/unmaintained/4DNav/light_test.xml b/unmaintained/4DNav/light_test.xml
new file mode 100755 (executable)
index 0000000..b7d750d
--- /dev/null
@@ -0,0 +1,62 @@
+<model>\r
+<space>\r
+       <name>multi solids</name>\r
+       <dimension>4</dimension>\r
+       <solid>\r
+               <name>4cube1</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,100</face>\r
+               <face>-1,0,0,0,-150</face>\r
+               <face>0,1,0,0,100</face>\r
+               <face>0,-1,0,0,-150</face>\r
+               <face>0,0,1,0,100</face>\r
+               <face>0,0,-1,0,-150</face>\r
+               <face>0,0,0,1,100</face>\r
+               <face>0,0,0,-1,-150</face>\r
+               <color>1,1,1</color>\r
+       </solid>\r
+       <solid>\r
+               <name>4triancube</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,160</face>\r
+               <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>\r
+               <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>\r
+               <face>0,0,1,0,140</face>\r
+               <face>0,0,-1,0,-180</face>\r
+               <face>0,0,0,1,110</face>\r
+               <face>0,0,0,-1,-180</face>\r
+               <color>1,1,1</color>\r
+       </solid>\r
+       <solid>\r
+               <name>triangone</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,60</face>\r
+               <face>0.5,0.8660254037844386,0,0,60</face>\r
+               <face>-0.5,0.8660254037844387,0,0,-20</face>\r
+               <face>-1.0,0,0,0,-100</face>\r
+               <face>-0.5,-0.8660254037844384,0,0,-100</face>\r
+               <face>0.5,-0.8660254037844387,0,0,-20</face>\r
+               <face>0,0,1,0,120</face>\r
+               <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>\r
+               <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>\r
+               <color>1,1,1</color>\r
+       </solid>\r
+       <light>\r
+               <direction>1,0,0,0</direction>\r
+               <color>0,0,0,0.6</color>\r
+       </light>\r
+       <light>\r
+               <direction>0,1,0,0</direction>\r
+               <color>0,0.6,0,0</color>\r
+       </light>\r
+       <light>\r
+               <direction>0,0,1,0</direction>\r
+               <color>0,0,0.6,0</color>\r
+       </light>\r
+       <light>\r
+               <direction>0,0,0,1</direction>\r
+               <color>0.6,0.6,0.6</color>\r
+       </light>\r
+       <color>0.99,0.99,0.99</color>\r
+</space>\r
+</model>\r
diff --git a/unmaintained/4DNav/multi solids.xml b/unmaintained/4DNav/multi solids.xml
new file mode 100755 (executable)
index 0000000..b401e98
--- /dev/null
@@ -0,0 +1,50 @@
+<model>\r
+<space>\r
+       <name>multi solids</name>\r
+       <dimension>4</dimension>\r
+       <solid>\r
+               <name>4cube1</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,100</face>\r
+               <face>-1,0,0,0,-150</face>\r
+               <face>0,1,0,0,100</face>\r
+               <face>0,-1,0,0,-150</face>\r
+               <face>0,0,1,0,100</face>\r
+               <face>0,0,-1,0,-150</face>\r
+               <face>0,0,0,1,100</face>\r
+               <face>0,0,0,-1,-150</face>\r
+               <color>1,0,0</color>\r
+       </solid>\r
+       <solid>\r
+               <name>4triancube</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,160</face>\r
+               <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>\r
+               <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>\r
+               <face>0,0,1,0,140</face>\r
+               <face>0,0,-1,0,-180</face>\r
+               <face>0,0,0,1,110</face>\r
+               <face>0,0,0,-1,-180</face>\r
+               <color>0,1,0</color>\r
+       </solid>\r
+       <solid>\r
+               <name>triangone</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,60</face>\r
+               <face>0.5,0.8660254037844386,0,0,60</face>\r
+               <face>-0.5,0.8660254037844387,0,0,-20</face>\r
+               <face>-1.0,0,0,0,-100</face>\r
+               <face>-0.5,-0.8660254037844384,0,0,-100</face>\r
+               <face>0.5,-0.8660254037844387,0,0,-20</face>\r
+               <face>0,0,1,0,120</face>\r
+               <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>\r
+               <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>\r
+               <color>0,1,1</color>\r
+       </solid>\r
+       <light>\r
+               <direction>1,1,1,1</direction>\r
+               <color>0.2,0.2,0.6</color>\r
+       </light>\r
+       <color>0.8,0.9,0.9</color>\r
+</space>\r
+</model>\r
diff --git a/unmaintained/4DNav/prismetriagone.xml b/unmaintained/4DNav/prismetriagone.xml
new file mode 100755 (executable)
index 0000000..cbdc071
--- /dev/null
@@ -0,0 +1,25 @@
+<model>\r
+<space>\r
+       <name>Prismetragone</name>              \r
+       <dimension>4</dimension>\r
+       <solid>\r
+               <name>triangone</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,60</face>\r
+               <face>0.5,0.8660254037844386,0,0,60</face>\r
+               <face>-0.5,0.8660254037844387,0,0,-20</face>\r
+               <face>-1.0,0,0,0,-100</face>\r
+               <face>-0.5,-0.8660254037844384,0,0,-100</face>\r
+               <face>0.5,-0.8660254037844387,0,0,-20</face>\r
+               <face>0,0,1,0,120</face>\r
+               <face>0,0,-0.4999999999999998,-0.8660254037844387,-120</face>\r
+               <face>0,0,-0.5000000000000004,0.8660254037844384,-120</face>\r
+               <color>0,1,1</color>\r
+       </solid>\r
+       <light>\r
+               <direction>1,1,1,1</direction>\r
+               <color>0.2,0.2,0.6</color>\r
+       </light>\r
+       <color>0.8,0.9,0.9</color>\r
+</space>\r
+</model>\r
diff --git a/unmaintained/4DNav/space-file-decoder/authors.txt b/unmaintained/4DNav/space-file-decoder/authors.txt
new file mode 100755 (executable)
index 0000000..a6a9693
--- /dev/null
@@ -0,0 +1 @@
+Jeff Bigot
\ No newline at end of file
diff --git a/unmaintained/4DNav/space-file-decoder/space-file-decoder-docs.factor b/unmaintained/4DNav/space-file-decoder/space-file-decoder-docs.factor
new file mode 100755 (executable)
index 0000000..0a78166
--- /dev/null
@@ -0,0 +1,20 @@
+! Copyright (C) 2008 Jean-François Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel ;
+IN: 4DNav.space-file-decoder
+
+
+
+HELP: read-model-file
+{ $values
+    
+     { "path" "path to the file to read" }
+     { "x" "value" }
+}
+{ $description "Read a file containing the xml description of the model" } ;
+
+ARTICLE: "4DNav.space-file-decoder" "Space XMLfile decoder"
+{ $vocab-link "4DNav.space-file-decoder" }
+;
+
+ABOUT: "4DNav.space-file-decoder"
diff --git a/unmaintained/4DNav/space-file-decoder/space-file-decoder.factor b/unmaintained/4DNav/space-file-decoder/space-file-decoder.factor
new file mode 100755 (executable)
index 0000000..e85830d
--- /dev/null
@@ -0,0 +1,64 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: adsoda xml xml.traversal xml.syntax accessors \r
+combinators sequences math.parser kernel splitting values \r
+continuations ;\r
+IN: 4DNav.space-file-decoder\r
+\r
+: decode-number-array ( x -- y )  \r
+    "," split [ string>number ] map ;\r
+\r
+TAGS: adsoda-read-model ( tag -- model )\r
+\r
+TAG: dimension adsoda-read-model \r
+    children>> first string>number ;\r
+TAG: direction adsoda-read-model \r
+    children>> first decode-number-array ;\r
+TAG: color     adsoda-read-model \r
+    children>> first decode-number-array ;\r
+TAG: name      adsoda-read-model \r
+    children>> first ;\r
+TAG: face      adsoda-read-model \r
+    children>> first decode-number-array ;\r
+\r
+TAG: solid adsoda-read-model \r
+    <solid> swap  \r
+    { \r
+        [ "dimension" tag-named adsoda-read-model >>dimension ]\r
+        [ "name"      tag-named adsoda-read-model >>name ] \r
+        [ "color"     tag-named adsoda-read-model >>color ] \r
+        [ "face"      \r
+            tags-named [ adsoda-read-model cut-solid ] each ] \r
+    } cleave\r
+    ensure-adjacencies\r
+;\r
+\r
+TAG: light adsoda-read-model \r
+   <light> swap  \r
+    { \r
+        [ "direction" tag-named adsoda-read-model >>direction ]\r
+        [ "color"     tag-named adsoda-read-model >>color ] \r
+    } cleave\r
+;\r
+\r
+TAG: space adsoda-read-model \r
+    <space> swap  \r
+    { \r
+        [ "dimension" tag-named adsoda-read-model >>dimension ]\r
+        [ "name"      tag-named adsoda-read-model >>name ] \r
+        [ "color"     tag-named \r
+            adsoda-read-model >>ambient-color ] \r
+        [ "solid"     tags-named \r
+            [ adsoda-read-model suffix-solids ] each ] \r
+        [ "light"     tags-named \r
+            [ adsoda-read-model suffix-lights ] each ]\r
+    } cleave\r
+;\r
+\r
+: read-model-file ( path -- x )\r
+    [\r
+        [ file>xml "space" tag-named adsoda-read-model ] \r
+        [ 2drop <space> ] recover \r
+    ] [ <space> ] if*\r
+;\r
+\r
diff --git a/unmaintained/4DNav/summary.txt b/unmaintained/4DNav/summary.txt
new file mode 100755 (executable)
index 0000000..2598a14
--- /dev/null
@@ -0,0 +1 @@
+Simple tool to navigate through a 4D space with projections on 4 3D spaces
diff --git a/unmaintained/4DNav/tags.txt b/unmaintained/4DNav/tags.txt
new file mode 100755 (executable)
index 0000000..0c63a72
--- /dev/null
@@ -0,0 +1 @@
+4D viewer
\ No newline at end of file
diff --git a/unmaintained/4DNav/triancube.xml b/unmaintained/4DNav/triancube.xml
new file mode 100755 (executable)
index 0000000..8551bed
--- /dev/null
@@ -0,0 +1,23 @@
+<model>\r
+<space>\r
+       <name>triancube</name>          \r
+       <dimension>4</dimension>\r
+       <solid>\r
+               <name>triancube</name>\r
+               <dimension>4</dimension>\r
+               <face>1,0,0,0,160</face>\r
+               <face>-0.4999999999999998,-0.8660254037844387,0,0,-130</face>\r
+               <face>-0.5000000000000004,0.8660254037844384,0,0,-130</face>\r
+               <face>0,0,1,0,140</face>\r
+               <face>0,0,-1,0,-180</face>\r
+               <face>0,0,0,1,110</face>\r
+               <face>0,0,0,-1,-180</face>\r
+               <color>0,1,0</color>\r
+       </solid>\r
+       <light>\r
+               <direction>1,1,1,1</direction>\r
+               <color>0.2,0.2,0.6</color>\r
+       </light>\r
+       <color>0.8,0.9,0.9</color>\r
+</space>\r
+</model>\r
diff --git a/unmaintained/4DNav/turtle/authors.txt b/unmaintained/4DNav/turtle/authors.txt
new file mode 100755 (executable)
index 0000000..6cfd5da
--- /dev/null
@@ -0,0 +1 @@
+Eduardo Cavazos
diff --git a/unmaintained/4DNav/turtle/turtle-docs.factor b/unmaintained/4DNav/turtle/turtle-docs.factor
new file mode 100755 (executable)
index 0000000..b94ed99
--- /dev/null
@@ -0,0 +1,11 @@
+! Copyright (C) 2008 Jean-François Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays help.markup help.syntax kernel sequences ;
+IN: 4DNav.turtle
+
+
+ARTICLE: "4DNav.turtle" "Turtle"
+{ $vocab-link "4DNav.turtle" }
+;
+
+ABOUT: "4DNav.turtle"
diff --git a/unmaintained/4DNav/turtle/turtle.factor b/unmaintained/4DNav/turtle/turtle.factor
new file mode 100755 (executable)
index 0000000..71f7f26
--- /dev/null
@@ -0,0 +1,159 @@
+USING: kernel math arrays math.vectors math.matrices namespaces make
+math.constants math.functions splitting grouping math.trig sequences
+accessors 4DNav.deep models vars ;
+IN: 4DNav.turtle
+
+! replacement of self
+
+VAR: self
+
+: with-self ( quot obj -- ) [ >self call ] with-scope ; inline
+
+: save-self ( quot -- ) self> [ self> clone >self call ] dip >self ; inline
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+TUPLE: turtle pos ori ;
+
+: <turtle> ( -- turtle )
+    turtle new
+    { 0 0 0 } clone >>pos
+    3 identity-matrix >>ori
+;
+
+
+TUPLE: observer < turtle projection-mode collision-mode ;
+
+: <observer> ( -- object ) 
+     observer new
+    0 <model> >>projection-mode 
+    f <model> >>collision-mode
+    ;
+
+
+: turtle-pos> ( -- val ) self> pos>> ;
+: >turtle-pos ( val -- ) self> (>>pos) ;
+
+: turtle-ori> ( -- val ) self> ori>> ;
+: >turtle-ori ( val -- ) self> (>>ori) ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! These rotation matrices are from
+! `Computer Graphics: Principles and Practice'
+
+
+! waiting for deep-cleave-quots  
+
+! : Rz ( angle -- Rx ) deg>rad
+!    {   { [ cos ] [ sin neg ]   0 }
+!        { [ sin ] [ cos ]      0  }
+!        {   0       0           1 } 
+!    } deep-cleave-quots  ;
+
+! : Ry ( angle -- Ry ) deg>rad
+!    {   { [ cos ]      0 [ sin ] }
+!        {   0          1 0       }
+!        { [  sin neg ] 0 [ cos ] }
+!    } deep-cleave-quots  ;
+  
+! : Rx ( angle -- Rz ) deg>rad
+!   {   { 1     0        0        }
+!        { 0   [ cos ] [ sin neg ] }
+!        { 0   [ sin ] [ cos ]     }
+!    } deep-cleave-quots ;
+
+: Rz ( angle -- Rx ) deg>rad
+[ dup cos ,     dup sin neg ,   0 ,
+  dup sin ,     dup cos ,       0 ,
+  0 ,           0 ,             1 , ] 3 make-matrix nip ;
+
+: Ry ( angle -- Ry ) deg>rad
+[ dup cos ,     0 ,             dup sin ,
+  0 ,           1 ,             0 ,
+  dup sin neg , 0 ,             dup cos , ] 3 make-matrix nip ;
+
+: Rx ( angle -- Rz ) deg>rad
+[ 1 ,           0 ,             0 ,
+  0 ,           dup cos ,       dup sin neg ,
+  0 ,           dup sin ,       dup cos , ] 3 make-matrix nip ;
+
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: apply-rotation ( rotation -- ) 
+    turtle-ori> swap m. >turtle-ori ;
+: rotate-x ( angle -- ) Rx apply-rotation ;
+: rotate-y ( angle -- ) Ry apply-rotation ;
+: rotate-z ( angle -- ) Rz apply-rotation ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: pitch-up   ( angle -- ) neg rotate-x ;
+: pitch-down ( angle -- )     rotate-x ;
+
+: turn-left ( angle -- )      rotate-y ;
+: turn-right ( angle -- ) neg rotate-y ;
+
+: roll-left  ( angle -- ) neg rotate-z ;
+: roll-right ( angle -- )     rotate-z ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! roll-until-horizontal
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: V ( -- V ) { 0 1 0 } ;
+
+: X ( -- 3array ) turtle-ori> [ first  ] map ;
+: Y ( -- 3array ) turtle-ori> [ second ] map ;
+: Z ( -- 3array ) turtle-ori> [ third  ] map ;
+
+: set-X ( seq -- ) turtle-ori> [ set-first ] 2each ;
+: set-Y ( seq -- ) turtle-ori> [ set-second ] 2each ;
+: set-Z ( seq -- ) turtle-ori> [ set-third ] 2each ;
+
+: roll-until-horizontal ( -- )
+    V Z cross normalize set-X
+    Z X cross normalize set-Y ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: distance ( turtle turtle -- n ) 
+    pos>> swap pos>> v- [ sq ] map sum sqrt ;
+
+: move-by ( point -- ) turtle-pos> v+ >turtle-pos ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: reset-turtle ( -- ) 
+    { 0 0 0 } clone >turtle-pos 3 identity-matrix >turtle-ori ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: step-vector ( length -- array ) { 0 0 1 } n*v ;
+
+: step-turtle ( length -- ) 
+    step-vector turtle-ori> swap m.v 
+    turtle-pos> v+ >turtle-pos ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: strafe-up ( length -- )
+    90 pitch-up
+    step-turtle
+    90 pitch-down ;
+
+: strafe-down ( length -- )
+    90 pitch-down
+    step-turtle
+    90 pitch-up ;
+
+: strafe-left ( length -- )
+    90 turn-left
+    step-turtle
+    90 turn-right ;
+
+: strafe-right ( length -- )
+    90 turn-right
+    step-turtle
+    90 turn-left ;
diff --git a/unmaintained/4DNav/window3D/authors.txt b/unmaintained/4DNav/window3D/authors.txt
new file mode 100755 (executable)
index 0000000..a6a9693
--- /dev/null
@@ -0,0 +1 @@
+Jeff Bigot
\ No newline at end of file
diff --git a/unmaintained/4DNav/window3D/window3D-docs.factor b/unmaintained/4DNav/window3D/window3D-docs.factor
new file mode 100755 (executable)
index 0000000..a534d2e
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2008 Jean-François Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel ;
+IN: 4DNav.window3D
+
+
+
+ARTICLE: "4DNav.window3D" "Window3D"
+{ $vocab-link "4DNav.window3D" }
+;
+
+ABOUT: "4DNav.window3D"
diff --git a/unmaintained/4DNav/window3D/window3D.factor b/unmaintained/4DNav/window3D/window3D.factor
new file mode 100755 (executable)
index 0000000..e83e884
--- /dev/null
@@ -0,0 +1,82 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: kernel \r
+ui.gadgets\r
+ui.render\r
+opengl\r
+opengl.gl\r
+opengl.glu\r
+4DNav.camera\r
+4DNav.turtle\r
+math\r
+values\r
+alien.c-types\r
+accessors\r
+namespaces\r
+adsoda \r
+models\r
+prettyprint\r
+;\r
+\r
+IN: 4DNav.window3D\r
+\r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+! drawing functions \r
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+TUPLE: window3D  < gadget observer ; \r
+\r
+: <window3D>  ( model observer -- gadget )\r
+    window3D  new\r
+    swap 2dup \r
+    projection-mode>> add-connection\r
+    2dup \r
+    collision-mode>> add-connection\r
+    >>observer \r
+    swap <model> >>model \r
+    t >>root?\r
+;\r
+\r
+M: window3D pref-dim* ( gadget -- dim )  drop { 300 300 } ;\r
+\r
+M: window3D draw-gadget* ( gadget -- )\r
+\r
+    GL_PROJECTION glMatrixMode\r
+        glLoadIdentity\r
+        0.6 0.6 0.6 .9 glClearColor\r
+        dup observer>> projection-mode>> value>> 1 =    \r
+        [ 60.0 1.0 0.1 3000.0 gluPerspective ]\r
+        [ -400.0 400.0 -400.0 400.0 0.0 4000.0 glOrtho ] if\r
+        dup observer>> collision-mode>> value>> \r
+        \ remove-hidden-solids?   \r
+        set-value\r
+        dup  observer>> do-look-at\r
+        GL_MODELVIEW glMatrixMode\r
+            glLoadIdentity  \r
+            0.9 0.9 0.9 1.0 glClearColor\r
+            1.0 glClearDepth\r
+            GL_LINE_SMOOTH glEnable\r
+            GL_BLEND glEnable\r
+            GL_DEPTH_TEST glEnable       \r
+            GL_LEQUAL glDepthFunc\r
+            GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc\r
+            GL_LINE_SMOOTH_HINT GL_NICEST glHint\r
+            1.25 glLineWidth\r
+            GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor \r
+                glClear\r
+            glLoadIdentity\r
+            GL_LIGHTING glEnable\r
+            GL_LIGHT0 glEnable\r
+            GL_COLOR_MATERIAL glEnable\r
+            GL_FRONT GL_AMBIENT_AND_DIFFUSE glColorMaterial\r
+            ! *************************\r
+            \r
+            model>> value>> \r
+            [ space->GL ] when*\r
+\r
+            ! *************************\r
+;\r
+\r
+M: window3D graft* drop ;\r
+\r
+M: window3D model-changed nip relayout ; \r
diff --git a/unmaintained/adsoda/adsoda-docs.factor b/unmaintained/adsoda/adsoda-docs.factor
new file mode 100755 (executable)
index 0000000..9536826
--- /dev/null
@@ -0,0 +1,308 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: help.markup help.syntax ;\r
+IN: adsoda\r
+\r
+! --------------------------------------------------------------\r
+! faces\r
+! --------------------------------------------------------------\r
+ARTICLE: "face-page" "Face in ADSODA"\r
+"explanation of faces"\r
+$nl\r
+"link to functions" $nl\r
+"what is an halfspace" $nl\r
+"halfspace touching-corners adjacent-faces" $nl\r
+"touching-corners list of pointers to the corners which touch this face" $nl\r
+"adjacent-faces list of pointers to the faces which touch this face"\r
+{ $subsections\r
+    face\r
+    <face>\r
+}\r
+"test relative position"\r
+{ $subsections\r
+    point-inside-or-on-face?\r
+    point-inside-face?\r
+}\r
+"handling face"\r
+{ $subsections\r
+    flip-face\r
+    face-translate\r
+    face-transform\r
+}\r
+\r
+;\r
+\r
+HELP: face\r
+{ $class-description "a face is defined by"\r
+{ $list "halfspace equation" }\r
+{ $list "list of touching corners" }\r
+{ $list "list of adjacent faces" }\r
+$nl\r
+"Touching corners and adjacent faces are defined by algorithm thanks to other faces of the solid"\r
+}\r
+\r
+\r
+;\r
+HELP: <face> \r
+{ $values { "v" "an halfspace equation" } { "tuple" "a face" }  }   ;\r
+HELP: flip-face \r
+{ $values { "face" "a face" } { "face" "flipped face" } }\r
+{ $description "change the orientation of a face" }\r
+;\r
+\r
+HELP: face-translate \r
+{ $values { "face" "a face" } { "v" "a vector" } }\r
+{ $description \r
+"translate a face following a vector"\r
+$nl\r
+"a translation of an halfspace doesn't change the normal vector. this word just compute the new constant term" }\r
+\r
\r
+ ;\r
+HELP: face-transform \r
+{ $values { "face" "a face" } { "m" "a transformation matrix" } }\r
+{ $description  "compute the transformation of a face using a transformation matrix" }\r
\r
+ ;\r
+! --------------------------------\r
+! solid\r
+! --------------------------------------------------------------\r
+ARTICLE: "solid-page" "Solid in ADSODA"\r
+"explanation of solids"\r
+$nl\r
+"link to functions"\r
+{ $subsections\r
+    solid\r
+    <solid>\r
+}\r
+"test relative position"\r
+{ $subsections\r
+    point-inside-solid?\r
+    point-inside-or-on-solid?\r
+}\r
+"playing with faces and solids"\r
+{ $subsections\r
+    add-face\r
+    cut-solid\r
+    slice-solid\r
+}\r
+"solid handling"\r
+{ $subsections\r
+    solid-project\r
+    solid-translate\r
+    solid-transform\r
+    subtract\r
+    get-silhouette \r
+    solid=\r
+}\r
+;\r
+\r
+HELP: solid \r
+{ $class-description "dimension" $nl "silhouettes" $nl "faces" $nl "corners" $nl "adjacencies-valid" $nl "color" $nl "name" \r
+}\r
+;\r
+\r
+HELP: add-face \r
+{ $values { "solid" "a solid" } { "face" "a face" } }\r
+{ $description "reshape a solid with a face. The face truncate the solid." } ;\r
+\r
+HELP: cut-solid\r
+{ $values { "solid" "a solid" } { "halfspace" "an halfspace" } }\r
+{ $description "like add-face but just with halfspace equation" } ;\r
+\r
+HELP: slice-solid\r
+{ $values { "solid" "a solid" } { "face" "a face" } { "solid1" "the outer part of the former solid" } { "solid2" "the inner part of the former solid" } }\r
+{ $description "cut a solid into two parts. The face acts like a knife"\r
+}  ;\r
+\r
+\r
+HELP: solid-project\r
+{ $values { "lights" "lights" } { "ambient" "ambient" } { "solid" "solid" } { "solids" "projection of solid" } }\r
+{ $description "Project the solid using pv vector" \r
+$nl\r
+"TODO: explain how to use lights"\r
+} ;\r
+\r
+HELP: solid-translate \r
+{ $values { "solid" "a solid" } { "v" "translating vector" } }\r
+{ $description "Translate a solid using a vector" \r
+$nl\r
+"v and solid must have the same dimension "\r
+} ;\r
+\r
+HELP: solid-transform \r
+{ $values { "solid" "a solid" } { "m" "transformation matrix" } }\r
+{ $description "Transform a solid using a matrix"\r
+$nl\r
+"v and solid must have the same dimension "\r
+} ;\r
+\r
+HELP: subtract \r
+{ $values { "solid1" "initial shape" } { "solid2" "shape to remove" } { "solids" "resulting shape" } }\r
+{ $description  "Substract solid2 from solid1" } ;\r
+\r
+\r
+! --------------------------------------------------------------\r
+! space \r
+! --------------------------------------------------------------\r
+ARTICLE: "space-page" "Space in ADSODA"\r
+"A space is a collection of solids and lights."\r
+$nl\r
+"link to functions"\r
+$nl\r
+"Defining words"\r
+{ $subsections\r
+    space\r
+    <space>\r
+    suffix-solids \r
+    suffix-lights\r
+    clear-space-solids \r
+    describe-space\r
+}\r
+\r
+\r
+"Handling space"\r
+{ $subsections\r
+    space-ensure-solids\r
+    eliminate-empty-solids\r
+    space-transform\r
+    space-translate\r
+    remove-hidden-solids\r
+    space-project\r
+}\r
+\r
+\r
+;\r
+\r
+HELP: space \r
+{ $class-description \r
+"dimension" $nl " solids" $nl " ambient-color" $nl "lights" \r
+}\r
+;\r
+\r
+HELP: suffix-solids \r
+"( space solid -- space )"\r
+{ $values { "space" "a space" } { "solid" "a solid to add" } }\r
+{ $description "Add solid to space definition" } ;\r
+\r
+HELP: suffix-lights \r
+"( space light -- space ) "\r
+{ $values { "space" "a space" } { "light" "a light to add" } }\r
+{ $description "Add a light to space definition" } ;\r
+\r
+HELP: clear-space-solids \r
+"( space -- space )"   \r
+{ $values { "space" "a space" } }\r
+{ $description "remove all solids in space" } ;\r
+\r
+HELP: space-ensure-solids \r
+{ $values { "space" "a space" } }\r
+{ $description "rebuild corners of all solids in space" } ;\r
+\r
+\r
+\r
+HELP: space-transform \r
+" ( space m -- space )" \r
+{ $values { "space" "a space" } { "m" "a matrix" } }\r
+{ $description "Transform a space using a matrix" } ;\r
+\r
+HELP: space-translate \r
+{ $values { "space" "a space" } { "v" "a vector" } }\r
+{ $description "Translate a space following a vector" } ;\r
+\r
+HELP: describe-space " ( space -- )"\r
+{ $values { "space" "a space" } }\r
+{ $description "return a description of space" } ;\r
+\r
+HELP: space-project \r
+{ $values { "space" "a space" } { "i" "an integer" } }\r
+{ $description "Project a space along ith coordinate" } ;\r
+\r
+! --------------------------------------------------------------\r
+! 3D rendering\r
+! --------------------------------------------------------------\r
+ARTICLE: "3D-rendering-page" "The 3D rendering in ADSODA"\r
+"explanation of 3D rendering"\r
+$nl\r
+"link to functions"\r
+{ $subsections\r
+    face->GL\r
+    solid->GL\r
+    space->GL\r
+}\r
+\r
+;\r
+\r
+HELP: face->GL \r
+{ $values { "face" "a face" } { "color" "3 3 values array" } }\r
+{ $description "display a face" } ;\r
+\r
+HELP: solid->GL \r
+{ $values { "solid" "a solid" } }\r
+{ $description "display a solid" } ;\r
+\r
+HELP: space->GL \r
+{ $values { "space" "a space" } }\r
+{ $description "display a space" } ;\r
+\r
+! --------------------------------------------------------------\r
+! light\r
+! --------------------------------------------------------------\r
+\r
+ARTICLE: "light-page" "Light in ADSODA"\r
+"explanation of light"\r
+$nl\r
+"link to functions"\r
+;\r
+\r
+ARTICLE: { "adsoda" "light" } "ADSODA : lights"\r
+{ $code """\r
+! HELP: light position color\r
+! <light> ( -- tuple ) light new ;\r
+! light est un vecteur avec 3 variables pour les couleurs\n\r
+ void Light::Apply(Vector& normal, double &cRed, double &cGreen, double &cBlue)\n\r
+ { \n\r
+   // Dot the light direction with the normalized normal of Face.\r
+   register double intensity = -(normal * (*this));\r
+   // Face is a backface, from light's perspective\r
+   if (intensity < 0)\r
+     return;\r
+   \r
+   // Add the intensity componentwise\r
+   cRed += red * intensity;\r
+   cGreen += green * intensity;\r
+   cBlue += blue * intensity;\r
+   // Clip to unit range\r
+  if (cRed > 1.0) cRed = 1.0;\r
+   if (cGreen > 1.0) cGreen = 1.0;\r
+   if (cBlue > 1.0) cBlue = 1.0;\r
+""" }\r
+;\r
+\r
+\r
+\r
+ARTICLE: { "adsoda" "halfspace" } "ADSODA : halfspace"\r
+" defined by the concatenation of the normal vector and a constant"  \r
+ ;\r
+\r
+\r
+\r
+ARTICLE:  "adsoda-main-page"  "ADSODA : Arbitrary-Dimensional Solid Object Display Algorithm"\r
+"multidimensional handler :" \r
+$nl\r
+"design a solid using face delimitations. Only works on convex shapes"\r
+$nl\r
+{ $emphasis "written in C++ by Greg Ferrar" }\r
+$nl\r
+"full explanation on adsoda page at " { $url "http://www.flowerfire.com/ADSODA/" }\r
+$nl\r
+"Useful words are describe on the following pages: "\r
+{ $subsections\r
+    "face-page"\r
+    "solid-page"\r
+    "space-page"\r
+    "light-page"\r
+    "3D-rendering-page"\r
+} ;\r
+\r
+ABOUT: "adsoda-main-page"\r
diff --git a/unmaintained/adsoda/adsoda-tests.factor b/unmaintained/adsoda/adsoda-tests.factor
new file mode 100755 (executable)
index 0000000..f8881df
--- /dev/null
@@ -0,0 +1,310 @@
+USING: adsoda\r
+kernel\r
+math\r
+accessors\r
+sequences\r
+    adsoda.solution2\r
+    fry\r
+    tools.test \r
+    arrays ;\r
+\r
+IN: adsoda.tests\r
+\r
+\r
+\r
+: s1 ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    "s1" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 -1 -5 } cut-solid \r
+    { -1 -1 -21 } cut-solid \r
+    { -1 0 -12 } cut-solid \r
+    { 1 2 16 } cut-solid\r
+;\r
+: solid1 ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    "solid1" >>name\r
+    { 1 -1 -5 } cut-solid \r
+    { -1 -1 -21 } cut-solid \r
+    { -1 0 -12 } cut-solid \r
+    { 1 2 16 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+;\r
+: solid2 ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    "solid2" >>name\r
+    { -1 1 -10 } cut-solid \r
+    { -1 -1 -28 } cut-solid \r
+    { 1 0 13 } cut-solid \r
+ !   { 1 2 16 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid3 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid3" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 16 } cut-solid \r
+    { -1 0 -36 } cut-solid \r
+    { 0 1 1 } cut-solid \r
+    { 0 -1  -17 } cut-solid \r
+ !   { 1 2 16 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+\r
+;\r
+\r
+: solid4 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid4" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 21 } cut-solid \r
+    { -1 0 -36 } cut-solid \r
+    { 0 1 1 } cut-solid \r
+    { 0 -1  -17 } cut-solid \r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid5 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid5" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 6 } cut-solid \r
+    { -1 0 -17 } cut-solid \r
+    { 0 1 17 } cut-solid \r
+    { 0 -1  -19 } cut-solid \r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid7 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid7" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 38 } cut-solid \r
+    { 1 -5 -66 } cut-solid \r
+    { -2 1 -75 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid6s ( -- seq )\r
+  solid3 clone solid2 clone subtract\r
+;\r
+\r
+: space1 ( -- space )\r
+    <space>\r
+        2 >>dimension\r
+     !    solid3 suffix-solids\r
+        solid1 suffix-solids\r
+        solid2 suffix-solids\r
+    !   solid6s [ suffix-solids ] each \r
+        solid4 suffix-solids\r
+     !   solid5 suffix-solids\r
+        solid7 suffix-solids\r
+        { 1 1 1 } >>ambient-color\r
+            <light>\r
+        { -100 -100 } >>position\r
+        { 0.2 0.7 0.1 } >>color\r
+        suffix-lights\r
+;\r
+\r
+: space2 ( -- space )\r
+    <space>\r
+        4 >>dimension\r
+       ! 4cube suffix-solids\r
+        { 1 1 1 } >>ambient-color\r
+            <light>\r
+        { -100 -100 } >>position\r
+        { 0.2 0.7 0.1 } >>color\r
+        suffix-lights\r
+\r
+       ;\r
+\r
+\r
+\r
+! {\r
+!        { 1 0 0 0 }\r
+!        { 0 1 0 0 }\r
+!        { 0 0 0.984807753012208 -0.1736481776669303 }\r
+!        { 0 0 0.1736481776669303 0.984807753012208 }\r
+!    }\r
+\r
+! ------------------------------------------------------------\r
+! constant+\r
+[ { 1 2 5 } ] [ { 1 2 3 } 2 constant+ ] unit-test\r
+\r
+! ------------------------------------------------------------\r
+! translate\r
+[ { 1 -1 0 } ] [ { 1 -1 -5 } { 3 -2 } translate ] unit-test\r
+\r
+! ------------------------------------------------------------\r
+! transform\r
+[ { -1 -1 -5 21.0 } ] [ { -1 -1 -5 21 }\r
+  { { 1 0 0 }\r
+    { 0 1 0 }\r
+    { 0 0 1 }\r
+    } transform  \r
+] unit-test\r
+\r
+! ------------------------------------------------------------\r
+! compare-nleft-to-identity-matrix\r
+[ t ] [ \r
+    { \r
+        { 1 0 0 1232 } \r
+        { 0 1 0 0 321 } \r
+        { 0 0 1 0 } } \r
+        3 compare-nleft-to-identity-matrix \r
+]  unit-test\r
+\r
+[ f ] [ \r
+    { { 1 0 0 } { 0 1 0 } { 0 0 0 } } \r
+    3 compare-nleft-to-identity-matrix \r
+] unit-test\r
+\r
+[ f ] [ \r
+    { { 2 0 0 } { 0 1 0 } { 0 0 1 } } \r
+    3 compare-nleft-to-identity-matrix \r
+] unit-test\r
+! ------------------------------------------------------------\r
+[ t ] [ \r
+  { { 1 0 0 }\r
+    { 0 1 0 }\r
+    { 0 0 1 } } 3 valid-solution? \r
+] unit-test\r
+\r
+[ f ] [ \r
+  { { 1 0 0 1 }\r
+    { 0 0 0 1 }\r
+    { 0 0 1 0 } } 3 valid-solution? \r
+] unit-test\r
+\r
+[ f ] [ \r
+  { { 1 0 0 1 }\r
+    { 0 0 0 1 } } 3 valid-solution? \r
+] unit-test\r
+\r
+[ f ] [ \r
+  { { 1 0 0 1 }\r
+    { 0 0 0 1 }\r
+    { 0 0 1 0 } } 2 valid-solution? \r
+] unit-test\r
+\r
+! ------------------------------------------------------------\r
+[ 3 ] [ { 1 2 3 } last ] unit-test \r
+\r
+[ { 1 2 5 } ] [ { 1 2 3 } dup [ 2 + ] change-last ] unit-test \r
+\r
+! ------------------------------------------------------------\r
+! position-point \r
+[ 0 ] [ \r
+    { 1 -1 -5 } { 2 7 } position-point \r
+] unit-test\r
+\r
+! ------------------------------------------------------------\r
+\r
+! transform\r
+! TODO construire un exemple\r
+\r
+\r
+! ------------------------------------------------------------\r
+! slice-solid \r
+\r
+! ------------------------------------------------------------\r
+! solve-equation \r
+! deux cas de tests, avec solution et sans solution\r
+\r
+[ { 2 7 } ] \r
+[ { { 1 -1 -5 } { 1 2 16 } } intersect-hyperplanes ] \r
+unit-test\r
+\r
+[ f ] \r
+[ { { 1 -1 -5 } { 1 2 16 } { -1 -1 -21 } } intersect-hyperplanes  ]\r
+unit-test\r
+\r
+[ f ] \r
+[ { { 1 0 -5 } { 1 0 16 }  } intersect-hyperplanes  ]\r
+unit-test\r
+\r
+! ------------------------------------------------------------\r
+! point-inside-halfspace\r
+[ t ] [ { 1 -1 -5 } { 0 0 }  point-inside-halfspace? ] \r
+unit-test\r
+[ f ] [ { 1 -1 -5 } { 8 13 }  point-inside-halfspace? ] \r
+unit-test\r
+[ t ] [ { 1 -1 -5 } { 8 13 }  point-inside-or-on-halfspace? ] \r
+unit-test\r
+\r
+\r
+! ------------------------------\r
+! order solid\r
+\r
+[  1 ] [ 0 >pv solid1 solid2 order-solid ] unit-test\r
+[ -1 ] [ 0 >pv solid2 solid1 order-solid ] unit-test\r
+[  f ] [ 1 >pv solid1 solid2 order-solid ] unit-test\r
+[  f ] [ 1 >pv solid2 solid1 order-solid ] unit-test\r
+\r
+\r
+! clip-solid\r
+[ { { 13 15 } { 15 13 } { 13 13 } } ]\r
+    [ 0 >pv solid2 solid1 clip-solid first corners>> ] unit-test\r
+\r
+solid1 corners>> '[ _ ]\r
+    [ 0 >pv solid1 solid1 clip-solid first corners>> ] unit-test\r
+\r
+solid1 corners>> '[ _ ]\r
+    [ 0 >pv solid1 solid2 clip-solid first corners>> ] unit-test\r
+\r
+solid1 corners>> '[ _ ]\r
+    [ 1 >pv solid1 solid2 clip-solid first corners>> ] unit-test\r
+solid2 corners>> '[ _ ]\r
+    [ 1 >pv solid2 solid1 clip-solid first corners>> ] unit-test\r
+\r
+!\r
+[\r
+    {\r
+        { { 13 15 } { 15 13 } { 13 13 } }\r
+        { { 16 17 } { 16 13 } { 36 17 } { 36 13 } }\r
+        { { 16 1 } { 16 2 } { 36 1 } { 36 2 } }\r
+    }\r
+] [     0 >pv solid2 solid3  2array \r
+        solid1 (solids-silhouette-subtract) \r
+        [ corners>> ] map\r
+  ] unit-test\r
+\r
+\r
+[\r
+{\r
+    { { 8 13 } { 2 7 } { 12 9 } { 12 2 } }\r
+    { { 13 15 } { 15 13 } { 13 13 } }\r
+    { { 16 17 } { 16 15 } { 36 17 } { 36 15 } }\r
+    { { 16 1 } { 16 2 } { 36 1 } { 36 2 } }\r
+}\r
+] [ \r
+    0 >pv  <space> solid1 suffix-solids \r
+        solid2 suffix-solids \r
+        solid3 suffix-solids\r
+     remove-hidden-solids\r
+    solids>> [ corners>> ] map\r
+] unit-test\r
+\r
+! { }\r
+! { }\r
+! <light> { 0.2 0.3 0.4 } >>color { 1 -1 1 } >>direction     suffix\r
+! <light> { 0.4 0.3 0.1 } >>color { -1 -1 -1 } >>direction   suffix\r
+! suffix \r
+! { 0.1 0.1 0.1 } suffix ! ambient color\r
+! { 0.23 0.32 0.17 } suffix ! solid color\r
+! solid3 faces>> first \r
+\r
+! enlight-projection\r
diff --git a/unmaintained/adsoda/adsoda.factor b/unmaintained/adsoda/adsoda.factor
new file mode 100755 (executable)
index 0000000..cc09ad5
--- /dev/null
@@ -0,0 +1,569 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: accessors\r
+arrays \r
+assocs\r
+combinators\r
+kernel \r
+fry\r
+math \r
+math.constants\r
+math.functions\r
+math.libm\r
+math.order\r
+math.vectors \r
+math.matrices \r
+math.parser\r
+namespaces\r
+prettyprint\r
+sequences\r
+sequences.deep\r
+sets\r
+slots\r
+sorting\r
+tools.time\r
+vars\r
+continuations\r
+words\r
+opengl\r
+opengl.gl\r
+colors\r
+adsoda.solution2\r
+adsoda.combinators\r
+opengl.demo-support\r
+values\r
+tools.walker\r
+;\r
+\r
+IN: adsoda\r
+\r
+DEFER: combinations\r
+VAR: pv\r
+\r
+\r
+! -------------------------------------------------------------\r
+! global values\r
+VALUE: remove-hidden-solids?\r
+VALUE: VERY-SMALL-NUM\r
+VALUE: ZERO-VALUE\r
+VALUE: MAX-FACE-PER-CORNER\r
+\r
+t to: remove-hidden-solids?\r
+0.0000001 to: VERY-SMALL-NUM\r
+0.0000001 to: ZERO-VALUE\r
+4 to: MAX-FACE-PER-CORNER\r
+! -------------------------------------------------------------\r
+! sequence complement\r
+\r
+: with-pv ( i quot -- ) [ swap >pv call ] with-scope  ; inline\r
+\r
+: dimension ( array -- x )      length 1 - ; inline \r
+: change-last ( seq quot -- ) \r
+    [ [ dimension ] keep ] dip change-nth  ; inline\r
+\r
+! -------------------------------------------------------------\r
+! light\r
+! -------------------------------------------------------------\r
+\r
+TUPLE: light name { direction array } color ;\r
+: <light> ( -- tuple ) light new ;\r
+\r
+! -------------------------------------------------------------\r
+! halfspace manipulation\r
+! -------------------------------------------------------------\r
+\r
+: constant+ ( v x -- w )  '[ [ _ + ] change-last ] keep ;\r
+: translate ( u v -- w )   dupd     v* sum     constant+ ; \r
+\r
+: transform ( u matrix -- w )\r
+    [ swap m.v ] 2keep ! compute new normal vector    \r
+    [\r
+        [ [ abs ZERO-VALUE > ] find ] keep \r
+        ! find a point on the frontier\r
+        ! be sure it's not null vector\r
+        last ! get constant\r
+        swap /f neg swap ! intercept value\r
+    ] dip  \r
+    flip \r
+    nth\r
+    [ * ] with map ! apply intercep value\r
+    over v*\r
+    sum  neg\r
+    suffix ! add value as constant at the end of equation\r
+;\r
+\r
+: position-point ( halfspace v -- x ) \r
+    -1 suffix v* sum  ; inline\r
+: point-inside-halfspace? ( halfspace v -- ? )       \r
+    position-point VERY-SMALL-NUM  > ; \r
+: 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
+: get-intersection ( matrice -- seq )     \r
+    [ 1 tail* ] map     flip first ;\r
+\r
+: islenght=? ( seq n -- seq n ? ) 2dup [ length ] [ = ] bi*  ;\r
+\r
+: compare-nleft-to-identity-matrix ( seq n -- ? ) \r
+    [ [ head ] curry map ] keep  identity-matrix m- \r
+    flatten\r
+    [ abs ZERO-VALUE < ] all?\r
+;\r
+\r
+: valid-solution? ( matrice n -- ? )\r
+    islenght=?\r
+    [ compare-nleft-to-identity-matrix ]  \r
+    [ 2drop f ] if ; inline\r
+\r
+: intersect-hyperplanes ( matrice -- seq )\r
+    [ solution dup ] [ first dimension ] bi\r
+    valid-solution?     [ get-intersection ] [ drop f ] if ;\r
+\r
+! -------------------------------------------------------------\r
+! faces\r
+! -------------------------------------------------------------\r
+\r
+TUPLE: face { halfspace array } \r
+    touching-corners adjacent-faces ;\r
+: <face> ( v -- tuple )       face new swap >>halfspace ;\r
+: flip-face ( face -- face ) [ vneg ] change-halfspace ;\r
+: erase-face-touching-corners ( face -- face ) \r
+    f >>touching-corners ;\r
+: erase-face-adjacent-faces ( face -- face )   \r
+    f >>adjacent-faces ;\r
+: faces-intersection ( faces -- v )  \r
+    [ halfspace>> ] map intersect-hyperplanes ;\r
+: face-translate ( face v -- face ) \r
+    [ translate ] curry change-halfspace ; inline\r
+: face-transform ( face m -- face )\r
+    [ transform ] curry change-halfspace ; inline\r
+: face-orientation ( face -- x ) pv> swap halfspace>> nth sgn ;\r
+: backface? ( face -- face ? )      dup face-orientation 0 <= ;\r
+: pv-factor ( face -- f face )     \r
+    halfspace>> [ pv> swap nth [ * ] curry ] keep ; inline\r
+: suffix-touching-corner ( face corner -- face ) \r
+    [ suffix ] curry   change-touching-corners ; inline\r
+: real-face? ( face -- ? )\r
+    [ touching-corners>> length ] \r
+    [ halfspace>> dimension ] bi >= ;\r
+\r
+: (add-to-adjacent-faces) ( face face -- face )\r
+    over adjacent-faces>> 2dup member?\r
+    [ 2drop ] [ swap suffix >>adjacent-faces ] if ;\r
+\r
+: add-to-adjacent-faces ( face face -- face )\r
+    2dup =   [ drop ] [ (add-to-adjacent-faces) ] if ;\r
+\r
+: update-adjacent-faces ( faces corner -- )\r
+   '[ [ _ suffix-touching-corner drop ] each ] keep \r
+    2 among [ \r
+        [ first ] keep second  \r
+        [ add-to-adjacent-faces drop ] 2keep \r
+        swap add-to-adjacent-faces drop  \r
+    ] each ; inline\r
+\r
+: face-project-dim ( face -- x )  halfspace>> length 2 -  ;\r
+\r
+: apply-light ( color light normal -- u )\r
+    over direction>>  v. \r
+    neg dup 0 > \r
+    [ \r
+        [ color>> swap ] dip \r
+        [ * ] curry map v+ \r
+        [ 1 min ] map \r
+    ] \r
+    [ 2drop ] \r
+    if\r
+;\r
+\r
+: enlight-projection ( array face -- color )\r
+    ! array = lights + ambient color\r
+    [ [ third ] [ second ] [ first ] tri ]\r
+    [ halfspace>> project-vector normalize ] bi*\r
+    [ apply-light ] curry each\r
+    v*\r
+;\r
+\r
+: (intersection-into-face) ( face-init face-adja quot -- face )\r
+    [\r
+    [  [ pv-factor ] bi@ \r
+        roll \r
+        [ map ] 2bi@\r
+        v-\r
+    ] 2keep\r
+    [ touching-corners>> ] bi@\r
+    [ swap  [ = ] curry find  nip f = ] curry find nip\r
+    ] dip  over\r
+     [\r
+        call\r
+        dupd\r
+        point-inside-halfspace? [ vneg ] unless \r
+        <face> \r
+     ] [ 3drop f ] if \r
+    ; inline\r
+\r
+: intersection-into-face ( face-init face-adja -- face )\r
+    [ [ project-vector ] bi@ ]     (intersection-into-face) ;\r
+\r
+: intersection-into-silhouette-face ( face-init face-adja -- face )\r
+    [ ] (intersection-into-face) ;\r
+\r
+: intersections-into-faces ( face -- faces )\r
+    clone dup  \r
+    adjacent-faces>> [ intersection-into-face ] with map \r
+    [ ] filter ;\r
+\r
+: (face-silhouette) ( face -- faces )\r
+    clone dup adjacent-faces>>\r
+    [   backface?\r
+        [ intersection-into-silhouette-face ] [ 2drop f ]  if  \r
+    ] with map \r
+    [ ] filter\r
+; inline\r
+\r
+: face-silhouette ( face -- faces )     \r
+    backface? [ drop f ] [ (face-silhouette) ] if ;\r
+\r
+! --------------------------------\r
+! solid\r
+! -------------------------------------------------------------\r
+TUPLE: solid dimension silhouettes \r
+    faces corners adjacencies-valid color name ;\r
+\r
+: <solid> ( -- tuple ) solid new ;\r
+\r
+: suffix-silhouettes ( solid silhouette -- solid )  \r
+    [ suffix ] curry change-silhouettes ;\r
+\r
+: suffix-face ( solid face -- solid )     \r
+    [ suffix ] curry change-faces ;\r
+: suffix-corner ( solid corner -- solid ) \r
+    [ suffix ] curry change-corners ; \r
+: erase-solid-corners ( solid -- solid )  f >>corners ;\r
+\r
+: erase-silhouettes ( solid -- solid ) \r
+    dup dimension>> f <array> >>silhouettes ;\r
+: filter-real-faces ( solid -- solid ) \r
+    [ [ real-face? ] filter ] change-faces ;\r
+: initiate-solid-from-face ( face -- solid ) \r
+    face-project-dim  <solid> swap >>dimension ;\r
+\r
+: erase-old-adjacencies ( solid -- solid )\r
+    erase-solid-corners\r
+    [ dup [ erase-face-touching-corners \r
+        erase-face-adjacent-faces drop ] each ]\r
+    change-faces ;\r
+\r
+: point-inside-or-on-face? ( face v -- ? ) \r
+    [ halfspace>> ] dip point-inside-or-on-halfspace?  ;\r
+\r
+: point-inside-face? ( face v -- ? ) \r
+    [ halfspace>> ] dip  point-inside-halfspace? ;\r
+\r
+: point-inside-solid? ( solid point -- ? )\r
+    [ faces>> ] dip [ point-inside-face? ] curry all? ; inline\r
+\r
+: point-inside-or-on-solid? ( solid point -- ? )\r
+    [ faces>> ] dip \r
+    [ point-inside-or-on-face? ] curry  all?   ; inline\r
+\r
+: unvalid-adjacencies ( solid -- solid )  \r
+    erase-old-adjacencies f >>adjacencies-valid \r
+    erase-silhouettes ;\r
+\r
+: add-face ( solid face -- solid ) \r
+    suffix-face unvalid-adjacencies ; \r
+\r
+: cut-solid ( solid halfspace -- solid )    <face> add-face ; \r
+\r
+: slice-solid ( solid face  -- solid1 solid2 )\r
+    [ [ clone ] bi@ flip-face add-face \r
+    [ "/outer/" append ] change-name  ] 2keep\r
+    add-face [ "/inner/" append ] change-name ;\r
+\r
+! -------------\r
+\r
+\r
+: add-silhouette ( solid  -- solid )\r
+   dup \r
+   ! find-adjacencies \r
+   faces>> { } \r
+   [ face-silhouette append ] reduce\r
+   [ ] filter \r
+   <solid> \r
+        swap >>faces\r
+        over dimension>> >>dimension \r
+        over name>> " silhouette " append \r
+                 pv> number>string append \r
+        >>name\r
+     !   ensure-adjacencies\r
+   suffix-silhouettes ; inline\r
+\r
+: find-silhouettes ( solid -- solid )\r
+    { } >>silhouettes \r
+    dup dimension>> [ [ add-silhouette ] with-pv ] each ;\r
+\r
+: ensure-silhouettes ( solid  -- solid )\r
+    dup  silhouettes>>  [ f = ] all?\r
+    [ find-silhouettes  ]  when ; \r
+\r
+! ------------\r
+\r
+: corner-added? ( solid corner -- ? ) \r
+    ! add corner to solid if it is inside solid\r
+    [ ] \r
+    [ point-inside-or-on-solid? ] \r
+    [ swap corners>> member? not ] \r
+    2tri and\r
+    [ suffix-corner drop t ] [ 2drop f ] if ;\r
+\r
+: process-corner ( solid faces corner -- )\r
+    swapd \r
+    [ corner-added? ] keep swap ! test if corner is inside solid\r
+    [ update-adjacent-faces ] \r
+    [ 2drop ]\r
+    if ;\r
+\r
+: compute-intersection ( solid faces -- )\r
+    dup faces-intersection\r
+    dup f = [ 3drop ] [ process-corner ]  if ;\r
+\r
+: test-faces-combinaisons ( solid n -- )\r
+    [ dup faces>> ] dip among   \r
+    [ compute-intersection ] with each ;\r
+\r
+: 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
+\r
+: find-adjacencies ( solid -- solid ) \r
+    erase-old-adjacencies   \r
+    compute-adjacencies\r
+    filter-real-faces \r
+    t >>adjacencies-valid ;\r
+\r
+: ensure-adjacencies ( solid -- solid ) \r
+    dup adjacencies-valid>> \r
+    [ find-adjacencies ] unless \r
+    ensure-silhouettes\r
+    ;\r
+\r
+: (non-empty-solid?) ( solid -- ? ) \r
+    [ dimension>> ] [ corners>> length ] bi < ;\r
+: non-empty-solid? ( solid -- ? )   \r
+    ensure-adjacencies (non-empty-solid?) ;\r
+\r
+: compare-corners-roughly ( corner corner -- ? )\r
+    2drop t ;\r
+! : remove-inner-faces ( -- ) ;\r
+: face-project ( array face -- seq )\r
+    backface? \r
+  [ 2drop f ]\r
+    [   [ enlight-projection ] \r
+        [ initiate-solid-from-face ]\r
+        [ intersections-into-faces ]  tri\r
+        >>faces\r
+        swap >>color        \r
+    ]    if ;\r
+\r
+: solid-project ( lights ambient solid -- solids )\r
+  ensure-adjacencies\r
+    [ color>> ] [ faces>> ] bi [ 3array  ] dip\r
+    [ face-project ] with map \r
+    [ ] filter \r
+    [ ensure-adjacencies ] map\r
+;\r
+\r
+: (solid-move) ( solid v move -- solid ) \r
+   curry [ map ] curry \r
+   [ dup faces>> ] dip call drop  \r
+   unvalid-adjacencies ; inline\r
+\r
+: solid-translate ( solid v -- solid ) \r
+    [ face-translate ] (solid-move) ; \r
+: solid-transform ( solid m -- solid ) \r
+    [ face-transform ] (solid-move) ; \r
+\r
+: find-corner-in-silhouette ( s1 s2 -- elt bool )\r
+    pv> swap silhouettes>> nth     \r
+    swap corners>>\r
+    [ point-inside-solid? ] with find swap ;\r
+\r
+: valid-face-for-order ( solid point -- face )\r
+    [ point-inside-face? not ] \r
+    [ drop face-orientation  0 = not ] 2bi and ;\r
+\r
+: check-orientation ( s1 s2 pt -- int )\r
+    [ nip faces>> ] dip\r
+    [ valid-face-for-order ] curry find swap\r
+    [ face-orientation ] [ drop f ] if ;\r
+\r
+: (order-solid) ( s1 s2 -- int )\r
+    2dup find-corner-in-silhouette\r
+    [ check-orientation ] [ 3drop f ] if ;\r
+\r
+: order-solid ( solid solid  -- i ) \r
+    2dup (order-solid)\r
+    [ 2nip ]\r
+    [   swap (order-solid)\r
+        [ neg ] [ f ] if*\r
+    ] if* ;\r
+\r
+: subtract ( solid1 solid2 -- solids )\r
+    faces>> swap clone ensure-adjacencies ensure-silhouettes  \r
+    [ swap slice-solid drop ]  curry map\r
+    [ non-empty-solid? ] filter\r
+    [ ensure-adjacencies ] map\r
+; inline\r
+\r
+! -------------------------------------------------------------\r
+! space \r
+! -------------------------------------------------------------\r
+TUPLE: space name dimension solids ambient-color lights ;\r
+: <space> ( -- space )      space new ;\r
+: suffix-solids ( space solid -- space ) \r
+    [ suffix ] curry change-solids ; inline\r
+: suffix-lights ( space light -- space ) \r
+    [ suffix ] curry change-lights ; inline\r
+: clear-space-solids ( space -- space )     f >>solids ;\r
+\r
+: space-ensure-solids ( space -- space ) \r
+    [ [ ensure-adjacencies ] map ] change-solids ;\r
+: eliminate-empty-solids ( space -- space ) \r
+    [ [ non-empty-solid? ] filter ] change-solids ;\r
+\r
+: projected-space ( space solids -- space ) \r
+   swap dimension>> 1 -  <space>    \r
+   swap >>dimension    swap  >>solids ;\r
+\r
+: get-silhouette ( solid -- silhouette )    \r
+    silhouettes>> pv> swap nth ;\r
+: solid= ( solid solid -- ? )            [ corners>> ]  bi@ = ;\r
+\r
+: space-apply ( space m quot -- space ) \r
+        curry [ map ] curry [ dup solids>> ] dip\r
+        [ call ] [ 2drop ] recover drop ; inline\r
+: space-transform ( space m -- space ) \r
+    [ solid-transform ] space-apply ;\r
+: space-translate ( space v -- space ) \r
+    [ solid-translate ] space-apply ; \r
+\r
+: describe-space ( space -- ) \r
+    solids>>  \r
+    [  [ corners>>  [ pprint ] each ] [ name>> . ] bi ] each ;\r
+\r
+: clip-solid ( solid solid -- solids )\r
+    [ ]\r
+    [ solid= not ]\r
+    [ order-solid -1 = ] 2tri \r
+    and\r
+    [ get-silhouette subtract ] \r
+    [  drop 1array ] \r
+    if \r
+    \r
+    ;\r
+\r
+: (solids-silhouette-subtract) ( solids solid -- solids ) \r
+     [  clip-solid append ] curry { } -rot each ; inline\r
+\r
+: solids-silhouette-subtract ( solids i solid -- solids )\r
+! solids is an array of 1 solid arrays\r
+      [ (solids-silhouette-subtract) ] curry map-but \r
+; inline \r
+\r
+: remove-hidden-solids ( space -- space ) \r
+! We must include each solid in a sequence because \r
+! during substration \r
+! a solid can be divided in more than on solid\r
+    [ \r
+        [ [ 1array ] map ] \r
+        [ length ] \r
+        [ ] \r
+        tri     \r
+        [ solids-silhouette-subtract ] 2each\r
+        { } [ append ] reduce \r
+    ] change-solids\r
+    eliminate-empty-solids ! TODO include into change-solids\r
+;\r
+\r
+: space-project ( space i -- space )\r
+  [\r
+  [ clone  \r
+    remove-hidden-solids? [ remove-hidden-solids ] when\r
+    dup \r
+        [ solids>> ] \r
+        [ lights>> ] \r
+        [ ambient-color>> ]  tri \r
+        [ rot solid-project ] 2curry \r
+        map \r
+        [ append ] { } -rot each \r
+        ! TODO project lights\r
+        projected-space \r
+      ! remove-inner-faces \r
+      ! \r
+      eliminate-empty-solids\r
+    ] with-pv \r
+    ] [ 3drop <space> ] recover\r
+    ; inline\r
+\r
+: middle-of-space ( space -- point )\r
+    solids>> [ corners>> ] map concat\r
+    [ [ ] [ v+ ] map-reduce ] [ length ] bi v/n\r
+;\r
+\r
+! -------------------------------------------------------------\r
+! 3D rendering\r
+! -------------------------------------------------------------\r
+\r
+: face-reference ( face -- halfspace point vect )\r
+       [ halfspace>> ] \r
+       [ touching-corners>> first ] \r
+       [ touching-corners>> second ] tri \r
+       over v-\r
+;\r
+\r
+: theta ( v halfspace point vect -- v x )\r
+   [ [ over ] dip v- ] dip    \r
+   [ cross dup norm >float ]\r
+   [ v. >float ]  \r
+   2bi \r
+   fatan2\r
+   -rot v. \r
+   0 < [ neg ] when\r
+;\r
+\r
+: ordered-face-points ( face -- corners )  \r
+    [ touching-corners>> 1 head ] \r
+    [ touching-corners>> 1 tail ] \r
+    [ face-reference [ theta ] 3curry ]         tri\r
+    { } map>assoc    sort-values keys \r
+    append\r
+    ; inline\r
+\r
+: point->GL  ( point -- )   gl-vertex ;\r
+: points->GL ( array -- )   do-cycle [ point->GL ] each ;\r
+\r
+: face->GL ( face color -- )\r
+   [ ordered-face-points ] dip\r
+   [ first3 1.0 glColor4d GL_POLYGON \r
+        [ [ point->GL  ] each ] do-state ] curry\r
+   [  0 0 0 1 glColor4d GL_LINE_LOOP \r
+        [ [ point->GL  ] each ] do-state ]\r
+   bi\r
+   ; inline\r
+\r
+: solid->GL ( solid -- )    \r
+    [ faces>> ]    \r
+    [ color>> ] bi\r
+    [ face->GL ] curry each ; inline\r
+\r
+: space->GL ( space -- )\r
+    solids>>\r
+    [ solid->GL ] each ;\r
+\r
+\r
+\r
+\r
+\r
diff --git a/unmaintained/adsoda/adsoda.tests b/unmaintained/adsoda/adsoda.tests
new file mode 100755 (executable)
index 0000000..f0b0c54
--- /dev/null
@@ -0,0 +1,147 @@
+! : init-4D-demo ( -- space )\r
+! OK\r
+! espace de dimension 4 et de couleur 0,3 0.3 0.3\r
+<space> \r
+    4 >>dimension\r
+    { 0.3 0.3 0.3 } >>ambient-color\r
+    { 100 150 100  150 100 150 100 150 } "4cube1" 4cube suffix-solids\r
+   { 160 180  160 180 160 180 160 180 } "4cube2" 4cube suffix-solids\r
+    <light>\r
+        { -100 -100 -100 -100 } >>position\r
+        { 0.2 0.7 0.1 } >>color\r
+        suffix-lights\r
+! ;\r
+! : init-3D-demo ( -- space )\r
+! OK\r
+! espace de dimension 4 et de couleur 0,3 0.3 0.3\r
+<space> \r
+    3 >>dimension\r
+    { 0.3 0.3 0.3 } >>ambient-color\r
+    { 100 150 100  150 100 150 } "3cube1" 3cube suffix-solids\r
+  !  { -150 -10  -150 -10 -150 -10 -150 -10 } "4cube2" 4cube suffix-solids\r
+    <light>\r
+        { -100 -100 -100 -100 } >>position\r
+        { 0.2 0.7 0.1 } >>color\r
+        suffix-lights\r
+! ;\r
+\r
+\r
+: s1 ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    "s1" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 -1 -5 } cut-solid \r
+    { -1 -1 -21 } cut-solid \r
+    { -1 0 -12 } cut-solid \r
+    { 1 2 16 } cut-solid\r
+;\r
+: solid1 ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    "solid1" >>name\r
+    { 1 -1 -5 } cut-solid \r
+    { -1 -1 -21 } cut-solid \r
+    { -1 0 -12 } cut-solid \r
+    { 1 2 16 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+;\r
+: solid2 ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    "solid2" >>name\r
+    { -1 1 -10 } cut-solid \r
+    { -1 -1 -28 } cut-solid \r
+    { 1 0 13 } cut-solid \r
+ !   { 1 2 16 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid3 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid3" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 16 } cut-solid \r
+    { -1 0 -36 } cut-solid \r
+    { 0 1 1 } cut-solid \r
+    { 0 -1  -17 } cut-solid \r
+ !   { 1 2 16 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+\r
+;\r
+\r
+: solid4 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid4" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 21 } cut-solid \r
+    { -1 0 -36 } cut-solid \r
+    { 0 1 1 } cut-solid \r
+    { 0 -1  -17 } cut-solid \r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid5 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid5" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 6 } cut-solid \r
+    { -1 0 -17 } cut-solid \r
+    { 0 1 17 } cut-solid \r
+    { 0 -1  -19 } cut-solid \r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid7 ( -- solid )\r
+      <solid> \r
+    2 >>dimension\r
+    "solid7" >>name\r
+    { 1 1 1 } >>color\r
+    { 1 0 38 } cut-solid \r
+    { 1 -5 -66 } cut-solid \r
+    { -2 1 -75 } cut-solid\r
+    ensure-adjacencies\r
+    \r
+;\r
+\r
+: solid6s ( -- seq )\r
+  solid3 clone solid2 clone subtract\r
+;\r
+\r
+: space1 ( -- space )\r
+    <space>\r
+        2 >>dimension\r
+     !    solid3 suffix-solids\r
+        solid1 suffix-solids\r
+        solid2 suffix-solids\r
+    !   solid6s [ suffix-solids ] each \r
+        solid4 suffix-solids\r
+     !   solid5 suffix-solids\r
+        solid7 suffix-solids\r
+        { 1 1 1 } >>ambient-color\r
+            <light>\r
+        { -100 -100 } >>position\r
+        { 0.2 0.7 0.1 } >>color\r
+        suffix-lights\r
+;\r
+\r
+: space2 ( -- space )\r
+    <space>\r
+        4 >>dimension\r
+       ! 4cube suffix-solids\r
+        { 1 1 1 } >>ambient-color\r
+            <light>\r
+        { -100 -100 } >>position\r
+        { 0.2 0.7 0.1 } >>color\r
+        suffix-lights\r
+\r
+       ;\r
+\r
diff --git a/unmaintained/adsoda/authors.txt b/unmaintained/adsoda/authors.txt
new file mode 100755 (executable)
index 0000000..856f3b0
--- /dev/null
@@ -0,0 +1,2 @@
+Jeff Bigot\r
+Greg Ferrar
\ No newline at end of file
diff --git a/unmaintained/adsoda/combinators/authors.txt b/unmaintained/adsoda/combinators/authors.txt
new file mode 100755 (executable)
index 0000000..e7f4cde
--- /dev/null
@@ -0,0 +1 @@
+JF Bigot, after Greg Ferrar
\ No newline at end of file
diff --git a/unmaintained/adsoda/combinators/combinators-docs.factor b/unmaintained/adsoda/combinators/combinators-docs.factor
new file mode 100755 (executable)
index 0000000..5b540e7
--- /dev/null
@@ -0,0 +1,39 @@
+! Copyright (C) 2008 Jeff Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays help.markup help.syntax kernel sequences ;
+IN: adsoda.combinators
+
+HELP: among
+{ $values
+     { "array" array } { "n" "number of value to select" }
+     { "array" array }
+}
+{ $description "returns an array containings every possibilities of n choices among a given sequence" } ;
+
+HELP: columnize
+{ $values
+     { "array" array }
+     { "array" array }
+}
+{ $description "flip a sequence into a sequence of 1 element sequences" } ;
+
+HELP: concat-nth
+{ $values
+     { "seq1" sequence } { "seq2" sequence }
+     { "seq" sequence }
+}
+{ $description "merges 2 sequences of sequences appending corresponding elements" } ;
+
+HELP: do-cycle
+{ $values
+     { "array" array }
+     { "array" array }
+}
+{ $description "Copy the first element at the end of the sequence in order to close the cycle." } ;
+
+
+ARTICLE: "adsoda.combinators" "Combinators"
+{ $vocab-link "adsoda.combinators" }
+;
+
+ABOUT: "adsoda.combinators"
diff --git a/unmaintained/adsoda/combinators/combinators-tests.factor b/unmaintained/adsoda/combinators/combinators-tests.factor
new file mode 100755 (executable)
index 0000000..6796929
--- /dev/null
@@ -0,0 +1,11 @@
+USING: adsoda.combinators\r
+sequences\r
+    tools.test \r
+ ;\r
+\r
+IN: adsoda.combinators.tests\r
+\r
+\r
+[ { "atoto" "b" "ctoto" } ] [ { "a" "b" "c" } 1 [ "toto" append ] map-but ] \r
+    unit-test\r
+\r
diff --git a/unmaintained/adsoda/combinators/combinators.factor b/unmaintained/adsoda/combinators/combinators.factor
new file mode 100755 (executable)
index 0000000..d00eebc
--- /dev/null
@@ -0,0 +1,45 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: kernel arrays sequences fry math combinators ;\r
+\r
+IN: adsoda.combinators\r
+\r
+! : (combinations) ( seq -- seq ) [ 1 tail ] dip combinations ;\r
+\r
+! : prefix-each [ prefix ] curry map ; inline\r
+\r
+! : combinations ( seq n -- seqs )\r
+!    {\r
+!        { [ dup 0 = ] [ 2drop { { } } ] }\r
+!        { [ over empty? ] [ 2drop { } ] }\r
+!        { [ t ] [ \r
+!            [ [ 1 - (combinations) ] [ drop first ] 2bi prefix-each ]\r
+!            [ (combinations) ] 2bi append\r
+!        ] }\r
+!    } cond ;\r
+\r
+: columnize ( array -- array ) [ 1array ] map ; inline\r
+\r
+: among ( array n -- array )\r
+    2dup swap length \r
+    {\r
+        { [ over 1 = ] [ 3drop columnize ] }\r
+        { [ over 0 = ] [ 2drop 2drop { } ] }\r
+        { [ 2dup < ] [ 2drop [ 1 cut ] dip  \r
+                         [ 1 - among [ append ] with map  ] \r
+                         [ among append ] 2bi\r
+                       ] }\r
+        { [ 2dup = ] [ 3drop 1array ] }\r
+        { [ 2dup > ] [ 2drop 2drop {  } ] } \r
+    } cond\r
+;\r
+\r
+: concat-nth ( seq1 seq2 -- seq )  \r
+    [ nth append ] curry map-index ;\r
+\r
+: do-cycle   ( array -- array )   dup first suffix ;\r
+\r
+: map-but ( seq i quot -- seq )\r
+    ! quot : ( seq x -- seq )\r
+    '[ _ = [ @ ] unless ] map-index ; inline\r
+\r
diff --git a/unmaintained/adsoda/solution2/solution2.factor b/unmaintained/adsoda/solution2/solution2.factor
new file mode 100755 (executable)
index 0000000..fa73120
--- /dev/null
@@ -0,0 +1,126 @@
+USING: kernel\r
+sequences\r
+namespaces\r
+\r
+math\r
+math.vectors\r
+math.matrices\r
+;\r
+IN: adsoda.solution2\r
+\r
+! -------------------\r
+! correctif solution\r
+! ---------------\r
+SYMBOL: matrix\r
+: MIN-VAL-adsoda ( -- x ) 0.00000001\r
+! 0.000000000001 \r
+;\r
+\r
+: zero? ( x -- ? ) \r
+    abs MIN-VAL-adsoda <\r
+;\r
+\r
+! [ number>string string>number ] map \r
+\r
+: with-matrix ( matrix quot -- )\r
+    [ swap matrix set call matrix get ] with-scope ; inline\r
+\r
+: nth-row ( row# -- seq ) matrix get nth ;\r
+\r
+: change-row ( row# quot -- seq ) ! row# quot -- | quot: seq -- seq )\r
+    matrix get swap change-nth ; inline\r
+\r
+: exchange-rows ( row# row# -- ) matrix get exchange ;\r
+\r
+: rows ( -- n ) matrix get length ;\r
+\r
+: cols ( -- n ) 0 nth-row length ;\r
+\r
+: skip ( i seq quot -- n )\r
+    over [ find-from drop ] dip length or ; inline\r
+\r
+: first-col ( row# -- n )\r
+    #! First non-zero column\r
+    0 swap nth-row [ zero? not ] skip ;\r
+\r
+: clear-scale ( col# pivot-row i-row -- n )\r
+    [ over ] dip nth dup zero? [\r
+        3drop 0\r
+    ] [\r
+        [ nth dup zero? ] dip swap [\r
+            2drop 0\r
+        ] [\r
+            swap / neg\r
+        ] if\r
+    ] if ;\r
+\r
+: (clear-col) ( col# pivot-row i -- )\r
+    [ [ clear-scale ] 2keep [ n*v ] dip v+ ] change-row ;\r
+\r
+: rows-from ( row# -- slice )\r
+    rows dup <slice> ;\r
+\r
+: clear-col ( col# row# rows -- )\r
+    [ nth-row ] dip [ [ 2dup ] dip (clear-col) ] each 2drop ;\r
+\r
+: do-row ( exchange-with row# -- )\r
+    [ exchange-rows ] keep\r
+    [ first-col ] keep\r
+    dup 1 + rows-from clear-col ;\r
+\r
+: find-row ( row# quot -- i elt )\r
+    [ rows-from ] dip find ; inline\r
+\r
+: pivot-row ( col# row# -- n )\r
+    [ dupd nth-row nth zero? not ] find-row 2nip ;\r
+\r
+: (echelon) ( col# row# -- )\r
+    over cols < over rows < and [\r
+        2dup pivot-row [ over do-row 1 + ] when*\r
+        [ 1 + ] dip (echelon)\r
+    ] [\r
+        2drop\r
+    ] if ;\r
+\r
+: echelon ( matrix -- matrix' )\r
+    [ 0 0 (echelon) ] with-matrix ;\r
+\r
+: nonzero-rows ( matrix -- matrix' )\r
+    [ [ zero? ] all? not ] filter ;\r
+\r
+: null/rank ( matrix -- null rank )\r
+    echelon dup length swap nonzero-rows length [ - ] keep ;\r
+\r
+: leading ( seq -- n elt ) [ zero? not ] find ;\r
+\r
+: reduced ( matrix' -- matrix'' )\r
+    [\r
+        rows <reversed> [\r
+            dup nth-row leading drop\r
+            dup [ swap dup clear-col ] [ 2drop ] if\r
+        ] each\r
+    ] with-matrix ;\r
+\r
+: basis-vector ( row col# -- )\r
+    [ clone ] dip\r
+    [ swap nth neg recip ] 2keep\r
+    [ 0 spin set-nth ] 2keep\r
+    [ n*v ] dip\r
+    matrix get set-nth ;\r
+\r
+: nullspace ( matrix -- seq )\r
+    echelon reduced dup empty? [\r
+        dup first length identity-matrix [\r
+            [\r
+                dup leading drop\r
+                dup [ basis-vector ] [ 2drop ] if\r
+            ] each\r
+        ] with-matrix flip nonzero-rows\r
+    ] unless ;\r
+\r
+: 1-pivots ( matrix -- matrix )\r
+    [ dup leading nip [ recip v*n ] when* ] map ;\r
+\r
+: solution ( matrix -- matrix )\r
+    echelon nonzero-rows reduced 1-pivots ;\r
+\r
diff --git a/unmaintained/adsoda/solution2/summary.txt b/unmaintained/adsoda/solution2/summary.txt
new file mode 100755 (executable)
index 0000000..a25a451
--- /dev/null
@@ -0,0 +1 @@
+A modification of solution to approximate solutions
\ No newline at end of file
diff --git a/unmaintained/adsoda/summary.txt b/unmaintained/adsoda/summary.txt
new file mode 100755 (executable)
index 0000000..ee666bc
--- /dev/null
@@ -0,0 +1 @@
+ADSODA : Arbitrary-Dimensional Solid Object Display Algorithm
\ No newline at end of file
diff --git a/unmaintained/adsoda/tags.txt b/unmaintained/adsoda/tags.txt
new file mode 100755 (executable)
index 0000000..6e25b2f
--- /dev/null
@@ -0,0 +1 @@
+adsoda 4D viewer
\ No newline at end of file
diff --git a/unmaintained/adsoda/tools/authors.txt b/unmaintained/adsoda/tools/authors.txt
new file mode 100755 (executable)
index 0000000..a6a9693
--- /dev/null
@@ -0,0 +1 @@
+Jeff Bigot
\ No newline at end of file
diff --git a/unmaintained/adsoda/tools/tools-docs.factor b/unmaintained/adsoda/tools/tools-docs.factor
new file mode 100755 (executable)
index 0000000..1d952e3
--- /dev/null
@@ -0,0 +1,62 @@
+! Copyright (C) 2008 Jeff Bigot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays help.markup help.syntax kernel sequences ;
+IN: adsoda.tools
+
+HELP: 3cube
+{ $values 
+    { "array" "array" } { "name" "name" } 
+    { "solid" "solid" } 
+}
+{ $description "array : xmin xmax ymin ymax zmin zmax" 
+"returns a 3D solid with given limits"
+} ;
+
+HELP: 4cube
+{ $values 
+    { "array" "array" } { "name" "name" } 
+    { "solid" "solid" } 
+}
+{ $description "array : xmin xmax ymin ymax zmin zmax wmin wmax"  
+"returns a 4D solid with given limits"
+} ;
+
+
+HELP: equation-system-for-normal
+{ $values
+     { "points" "a list of n points" }
+     { "matrix" "matrix" }
+}
+{ $description "From a list of points, return the matrix" 
+"to solve in order to find the vector normal to the plan defined by the points" } 
+;
+
+HELP: normal-vector
+{ $values
+     { "points" "a list of n points" }
+     { "v" "a vector" }
+}
+{ $description "From a list of points, returns the vector normal to the plan defined by the points" 
+"With n points, creates n-1 vectors and then find a vector orthogonal to every others"
+"returns { f } if a normal vector can not be found" } 
+;
+
+HELP: points-to-hyperplane
+{ $values
+     { "points" "a list of n points" }
+     { "hyperplane" "an hyperplane equation" }
+}
+{ $description "From a list of points, returns the equation of the hyperplan"
+"Finds a normal vector and then translate it so that it includes one of the points"
+
+} 
+;
+
+ARTICLE: "adsoda.tools" "Tools"
+{ $vocab-link "adsoda.tools" }
+"Tools to help in building an " { $vocab-link "adsoda" } "-space"
+;
+
+ABOUT: "adsoda.tools"
+
+
diff --git a/unmaintained/adsoda/tools/tools-tests.factor b/unmaintained/adsoda/tools/tools-tests.factor
new file mode 100755 (executable)
index 0000000..bb54194
--- /dev/null
@@ -0,0 +1,14 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: \r
+adsoda.tools\r
+tools.test\r
+;\r
+\r
+IN: adsoda.tools.tests\r
+\r
+\r
+ [ { 1 0 } ] [ { { 0 0 } { 0 1 } }  normal-vector    ] unit-test\r
+ [ f ] [ { { 0 0 } { 0 0 } }  normal-vector    ] unit-test\r
+\r
+ [  { 1/2 1/2 1+1/2 }  ] [ { { 1 2 } { 2 1 } }  points-to-hyperplane ] unit-test\r
diff --git a/unmaintained/adsoda/tools/tools.factor b/unmaintained/adsoda/tools/tools.factor
new file mode 100755 (executable)
index 0000000..6c4f4c3
--- /dev/null
@@ -0,0 +1,150 @@
+! Copyright (C) 2008 Jeff Bigot\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: \r
+kernel\r
+sequences\r
+math\r
+accessors\r
+adsoda\r
+math.vectors \r
+math.matrices\r
+bunny.model\r
+io.encodings.ascii\r
+io.files\r
+sequences.deep\r
+combinators\r
+adsoda.combinators\r
+fry\r
+io.files.temp\r
+grouping\r
+;\r
+\r
+IN: adsoda.tools\r
+\r
+\r
+\r
+\r
+\r
+! ---------------------------------\r
+: coord-min ( x array -- array )  swap suffix  ;\r
+: coord-max ( x array -- array )  swap neg suffix ;\r
+\r
+: 4cube ( array name -- solid )\r
+! array : xmin xmax ymin ymax zmin zmax wmin wmax\r
+    <solid> \r
+    4 >>dimension\r
+    swap >>name\r
+    swap\r
+    { \r
+       [ { 1 0 0 0 } coord-min ] [ { -1 0 0 0 } coord-max ] \r
+       [ { 0 1 0 0 } coord-min ] [ { 0 -1 0 0 } coord-max ]\r
+       [ { 0 0 1 0 } coord-min ] [ { 0 0 -1 0 } coord-max ] \r
+       [ { 0 0 0 1 } coord-min ] [ { 0 0 0 -1 } coord-max ]\r
+    }\r
+    [ curry call ] 2map \r
+    [ cut-solid ] each \r
+    ensure-adjacencies\r
+    \r
+; inline\r
+\r
+: 3cube ( array name -- solid )\r
+! array : xmin xmax ymin ymax zmin zmax wmin wmax\r
+    <solid> \r
+    3 >>dimension\r
+    swap >>name\r
+    swap\r
+    { \r
+       [ { 1 0 0 } coord-min ] [ { -1 0 0 } coord-max ] \r
+       [ { 0 1 0 } coord-min ] [ { 0 -1 0 } coord-max ]\r
+       [ { 0 0 1 } coord-min ] [ { 0 0 -1 } coord-max ] \r
+    }\r
+    [ curry call ] 2map \r
+    [ cut-solid ] each \r
+    ensure-adjacencies\r
+    \r
+; inline\r
+\r
+\r
+: equation-system-for-normal ( points -- matrix )\r
+    unclip [ v- 0 suffix ] curry map\r
+    dup first [ drop 1 ] map     suffix\r
+;\r
+\r
+: normal-vector ( points -- v ) \r
+    equation-system-for-normal\r
+    intersect-hyperplanes ;\r
+\r
+: points-to-hyperplane ( points -- hyperplane )\r
+    [ normal-vector 0 suffix ] [ first ] bi\r
+    translate ;\r
+\r
+: refs-to-points ( points faces -- faces )\r
+   [ swap [ nth 10 v*n { 100 100 100 } v+ ] curry map ] \r
+   with map\r
+;\r
+! V{ { 0.1 0.2 } { 1.1 1.3 } } V{ { 1 0 } { 0 1 } }\r
+! V{ { { 1.1 1.3 } { 0.1 0.2 } } { { 0.1 0.2 } { 1.1 1.3 } } }\r
+\r
+: ply-model-path ( -- path )\r
+\r
+! "bun_zipper.ply" \r
+"screw2.ply"\r
+temp-file \r
+;\r
+\r
+: read-bunny-model ( -- v )\r
+ply-model-path ascii [  parse-model ] with-file-reader\r
+\r
+refs-to-points\r
+;\r
+\r
+: 3points-to-normal ( seq -- v )\r
+    unclip [ v- ] curry map first2 cross normalize\r
+;\r
+: 2-faces-to-prism ( seq seq -- seq )\r
+  2dup\r
+    [ do-cycle 2 clump ] bi@ concat-nth  \r
+    !  3 faces rectangulaires\r
+    swap prefix\r
+    swap prefix\r
+;    \r
+\r
+: Xpoints-to-prisme ( seq height -- cube )\r
+    ! from 3 points gives a list of faces representing \r
+    ! a cube of height "height"\r
+    ! and of based on the three points\r
+    ! a face is a group of 3 or mode points.   \r
+    [ dup dup  3points-to-normal ] dip \r
+    v*n [ v+ ] curry map ! 2 eme face triangulaire \r
+    2-faces-to-prism  \r
+\r
+! [ dup number? [ 1 + ] when ] deep-map\r
+! dup keep \r
+;\r
+\r
+\r
+: Xpoints-to-plane4D ( seq x y -- 4Dplane )\r
+    ! from 3 points gives a list of faces representing \r
+    ! a cube in 4th dim\r
+    ! from x to y (height = y-x)\r
+    ! and of based on the X points\r
+    ! a face is a group of 3 or mode points.   \r
+    '[ [ [ _ suffix ] map ] [ [ _ suffix ] map ] bi ] call\r
+    2-faces-to-prism\r
+;\r
+\r
+: 3pointsfaces-to-3Dsolidfaces ( seq -- seq )\r
+    [ 1 Xpoints-to-prisme [ 100 \r
+        110 Xpoints-to-plane4D ] map concat ] map \r
+\r
+;\r
+\r
+: test-figure ( -- solid )\r
+    <solid> \r
+    2 >>dimension\r
+    { 1 -1 -5 } cut-solid \r
+    { -1 -1 -21 } cut-solid \r
+    { -1 0 -12 } cut-solid \r
+    { 1 2 16 } cut-solid\r
+;\r
+\r
index 44280456c1b275cbf28df13d9d59fd9cc129cef0..8e22609714a75a480cb5a81b59e65be546a0b315 100644 (file)
@@ -66,4 +66,4 @@ SYNTAX: ADVISE: ! word adname location => word adname quot loc
     scan-word scan scan-word parse-definition swap [ spin ] dip advise ;
     
 SYNTAX: UNADVISE:    
-    scan-word parsed \ unadvise parsed ;
+    scan-word suffix! \ unadvise suffix! ;
diff --git a/unmaintained/combinators/cleave/authors.txt b/unmaintained/combinators/cleave/authors.txt
deleted file mode 100755 (executable)
index 6cfd5da..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Eduardo Cavazos
diff --git a/unmaintained/combinators/cleave/cleave-tests.factor b/unmaintained/combinators/cleave/cleave-tests.factor
deleted file mode 100644 (file)
index 94d8c3e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-
-USING: kernel math math.functions tools.test combinators.cleave ;
-
-IN: combinators.cleave.tests
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: unit-test* ( input output -- ) swap unit-test ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-[ { [ 1 ] [ 2 ] [ 3 ] [ 4 ] } 0arr ]       [ { 1 2 3 4 } ] unit-test*
-
-[ 3 { 1+ 1- 2^ } 1arr ]                    [ { 4 2 8 } ]   unit-test*
-
-[ 3 4 { [ + ] [ - ] [ ^ ] } 2arr ]         [ { 7 -1 81 } ] unit-test*
-
-[ 1 2 3 { [ + + ] [ - - ] [ * * ] } 3arr ] [ { 6 2 6 } ]   unit-test*
-
diff --git a/unmaintained/combinators/cleave/cleave.factor b/unmaintained/combinators/cleave/cleave.factor
deleted file mode 100755 (executable)
index 4a036b6..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-
-USING: kernel combinators words quotations arrays sequences locals macros
-       shuffle generalizations fry ;
-
-IN: combinators.cleave
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: >quot ( obj -- quot ) dup word? [ 1quotation ] when ;
-
-: >quots ( seq -- seq ) [ >quot ] map ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: [ncleave] ( SEQ N -- quot )
-   SEQ >quots [ [ N nkeep ] curry ] map concat [ N ndrop ] append >quotation ;
-
-MACRO: ncleave ( seq n -- quot ) [ncleave] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! Cleave into array
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: [narr] ( seq n -- quot ) over length '[ _ _ ncleave _ narray ] ;
-
-MACRO: narr ( seq n -- array ) [narr] ;
-
-MACRO: 0arr ( seq -- array ) 0 [narr] ;
-MACRO: 1arr ( seq -- array ) 1 [narr] ;
-MACRO: 2arr ( seq -- array ) 2 [narr] ;
-MACRO: 3arr ( seq -- array ) 3 [narr] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-MACRO: <arr> ( seq -- )
-  [ >quots ] [ length ] bi
- '[ _ cleave _ narray ] ;
-
-MACRO: <2arr> ( seq -- )
-  [ >quots ] [ length ] bi
- '[ _ 2cleave _ narray ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: {1} ( x     -- {x}     ) 1array ; inline
-: {2} ( x y   -- {x,y}   ) 2array ; inline
-: {3} ( x y z -- {x,y,z} ) 3array ; inline
-
-: {n} narray ;
-
-: {bi}  ( x p q   -- {p(x),q(x)}      ) bi  {2} ; inline
-
-: {tri} ( x p q r -- {p(x),q(x),r(x)} ) tri {3} ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! Spread into array
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-MACRO: <arr*> ( seq -- )
-  [ >quots ] [ length ] bi
- '[ _ spread _ narray ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: {bi*}  ( x y p q     -- {p(x),q(y)}      ) bi*  {2} ; inline
-: {tri*} ( x y z p q r -- {p(x),q(y),r(z)} ) tri* {3} ; inline
diff --git a/unmaintained/combinators/cleave/enhanced/enhanced.factor b/unmaintained/combinators/cleave/enhanced/enhanced.factor
deleted file mode 100644 (file)
index b55979a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-
-USING: combinators.cleave fry kernel macros parser quotations ;
-
-IN: combinators.cleave.enhanced
-
-: \\
-  scan-word literalize parsed
-  scan-word literalize parsed ; parsing
-
-MACRO: bi ( p q -- quot )
-  [ >quot ] dip
-    >quot
-  '[ _ _ [ keep ] dip call ] ;
-
-MACRO: tri ( p q r -- quot )
-  [ >quot ] 2dip
-  [ >quot ] dip
-    >quot
-  '[ _ _ _ [ [ keep ] dip keep ] dip call ] ;
-
-MACRO: bi* ( p q -- quot )
-  [ >quot ] dip
-    >quot
-  '[ _ _ [ dip ] dip call ] ;
-
-MACRO: tri* ( p q r -- quot )
-  [ >quot ] 2dip
-  [ >quot ] dip
-    >quot
-  '[ _ _ _ [ [ 2dip ] dip dip ] dip call ] ;
-
diff --git a/unmaintained/combinators/conditional/conditional.factor b/unmaintained/combinators/conditional/conditional.factor
deleted file mode 100644 (file)
index 3c9d6d2..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-USING: kernel combinators sequences macros fry newfx combinators.cleave ;
-
-IN: combinators.conditional
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-MACRO: 1if ( test then else -- ) '[ dup @ _ _ if ] ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-MACRO: 1cond ( tbl -- )
-  [ [ 1st [ dup ] prepend ] [ 2nd ] bi {2} ] map
-  [ cond ] prefix-on ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
diff --git a/unmaintained/dns/cache/nx/nx.factor b/unmaintained/dns/cache/nx/nx.factor
new file mode 100644 (file)
index 0000000..9904f85
--- /dev/null
@@ -0,0 +1,35 @@
+
+USING: kernel assocs locals combinators
+       math math.functions system unicode.case ;
+
+IN: dns.cache.nx
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: nx-cache ( -- table ) H{ } ;
+
+: nx-cache-at        (      name -- time ) >lower nx-cache at        ;
+: nx-cache-delete-at (      name --      ) >lower nx-cache delete-at ;
+: nx-cache-set-at    ( time name --      ) >lower nx-cache set-at    ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: now ( -- seconds ) millis 1000.0 / round >integer ;
+
+:: non-existent-name? ( NAME -- ? )
+   [let | TIME [ NAME nx-cache-at ] |
+     {
+       { [ TIME f    = ] [                         f ] }
+       { [ TIME now <= ] [ NAME nx-cache-delete-at f ] }
+       { [ t           ] [                         t ] }
+     }
+     cond
+   ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: cache-non-existent-name ( NAME TTL -- )
+   [let | TIME [ TTL now + ] | TIME NAME nx-cache-set-at ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
diff --git a/unmaintained/dns/cache/rr/rr.factor b/unmaintained/dns/cache/rr/rr.factor
new file mode 100644 (file)
index 0000000..cb80190
--- /dev/null
@@ -0,0 +1,65 @@
+
+USING: kernel sequences assocs sets locals combinators
+       accessors system math math.functions unicode.case prettyprint
+       combinators.smart dns ;
+
+IN: dns.cache.rr
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+TUPLE: <entry> time data ;
+
+: now ( -- seconds ) millis 1000.0 / round >integer ;
+
+: expired? ( <entry> -- ? ) time>> now <= ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: make-cache-key ( obj -- key )
+  [ [ name>> >lower ] [ type>> ] [ class>> ] tri ] output>array ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: cache ( -- table ) H{ } ;
+
+: cache-at     (     obj -- ent ) make-cache-key cache at ;
+: cache-delete (     obj --     ) make-cache-key cache delete-at ;
+: cache-set-at ( ent obj --     ) make-cache-key cache set-at ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: cache-get ( OBJ -- rrs/f )
+   [let | ENT [ OBJ cache-at ] |
+     {
+       { [ ENT f =      ] [                  f ] }
+       { [ ENT expired? ] [ OBJ cache-delete f ] }
+       {
+         [ t ]
+         [
+           [let | NAME  [ OBJ name>>       ]
+                  TYPE  [ OBJ type>>       ]
+                  CLASS [ OBJ class>>      ]
+                  TTL   [ ENT time>> now - ] |
+             ENT data>>
+               [| RDATA | T{ rr f NAME TYPE CLASS TTL RDATA } ]
+             map
+           ]
+         ]
+       }
+     }
+     cond
+   ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: cache-add ( RR -- )
+   [let | ENT   [ RR cache-at    ]
+          TIME  [ RR ttl>> now + ]
+          RDATA [ RR rdata>>     ] |
+     {
+       { [ ENT f =      ] [ T{ <entry> f TIME V{ RDATA } } RR cache-set-at ] }
+       { [ ENT expired? ] [ RR cache-delete RR cache-add                   ] }
+       { [ t            ] [ TIME ENT (>>time) RDATA ENT data>> adjoin      ] }
+     }
+     cond
+   ] ;
\ No newline at end of file
diff --git a/unmaintained/dns/dns.factor b/unmaintained/dns/dns.factor
new file mode 100644 (file)
index 0000000..f16664f
--- /dev/null
@@ -0,0 +1,501 @@
+
+USING: kernel byte-arrays combinators strings arrays sequences splitting
+       grouping
+       math math.functions math.parser random
+       destructors
+       io io.binary io.sockets io.encodings.binary
+       accessors
+       combinators.smart
+       assocs
+       ;
+
+IN: dns
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+TUPLE: query name type class ;
+
+TUPLE: rr name type class ttl rdata ;
+
+TUPLE: hinfo cpu os ;
+
+TUPLE: mx preference exchange ;
+
+TUPLE: soa mname rname serial refresh retry expire minimum ;
+
+TUPLE: message
+       id qr opcode aa tc rd ra z rcode
+       question-section
+       answer-section
+       authority-section
+       additional-section ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: random-id ( -- id ) 2 16 ^ random ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! TYPE
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOLS: A NS MD MF CNAME SOA MB MG MR NULL WKS PTR HINFO MINFO MX TXT AAAA ;
+
+: type-table ( -- table )
+  {
+    { A     1 }
+    { NS    2 }
+    { MD    3 }
+    { MF    4 }
+    { CNAME 5 }
+    { SOA   6 }
+    { MB    7 }
+    { MG    8 }
+    { MR    9 }
+    { NULL  10 }
+    { WKS   11 }
+    { PTR   12 }
+    { HINFO 13 }
+    { MINFO 14 }
+    { MX    15 }
+    { TXT   16 }
+    { AAAA  28 }
+  } ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! CLASS
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOLS: IN CS CH HS ;
+
+: class-table ( -- table )
+  {
+    { IN 1 }
+    { CS 2 }
+    { CH 3 }
+    { HS 4 }
+  } ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! OPCODE
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOLS: QUERY IQUERY STATUS ;
+
+: opcode-table ( -- table )
+  {
+    { QUERY  0 }
+    { IQUERY 1 }
+    { STATUS 2 }
+  } ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! RCODE
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED
+         REFUSED ;
+
+: rcode-table ( -- table )
+  {
+    { NO-ERROR        0 }
+    { FORMAT-ERROR    1 }
+    { SERVER-FAILURE  2 }
+    { NAME-ERROR      3 }
+    { NOT-IMPLEMENTED 4 }
+    { REFUSED         5 }
+  } ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: <message> ( -- message )
+  message new
+    random-id >>id
+    0         >>qr
+    QUERY     >>opcode
+    0         >>aa
+    0         >>tc
+    1         >>rd
+    0         >>ra
+    0         >>z
+    NO-ERROR  >>rcode
+    { }       >>question-section
+    { }       >>answer-section
+    { }       >>authority-section
+    { }       >>additional-section ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: ip->ba ( ip -- ba ) "." split [ string>number ] map >byte-array ;
+
+: ipv6->ba ( ip -- ba ) ":" split [ 16 base> ] map [ 2 >be ] map concat ;
+
+: label->ba ( label -- ba ) [ >byte-array ] [ length ] bi prefix ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: uint8->ba  ( n -- ba ) 1 >be ;
+: uint16->ba ( n -- ba ) 2 >be ;
+: uint32->ba ( n -- ba ) 4 >be ;
+: uint64->ba ( n -- ba ) 8 >be ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: dn->ba ( dn -- ba ) "." split [ label->ba ] map concat ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: query->ba ( query -- ba )
+  [
+    {
+      [ name>>                 dn->ba ]
+      [ type>>  type-table  at uint16->ba ]
+      [ class>> class-table at uint16->ba ]
+    } cleave
+  ] output>array concat ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: hinfo->ba ( rdata -- ba )
+    [ cpu>> label->ba ]
+    [ os>>  label->ba ]
+  bi append ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: mx->ba ( rdata -- ba )
+    [ preference>> uint16->ba ]
+    [ exchange>>   dn->ba ]
+  bi append ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: soa->ba ( rdata -- ba )
+  [
+    {
+      [ mname>>   dn->ba ]
+      [ rname>>   dn->ba ]
+      [ serial>>  uint32->ba ]
+      [ refresh>> uint32->ba ]
+      [ retry>>   uint32->ba ]
+      [ expire>>  uint32->ba ]
+      [ minimum>> uint32->ba ]
+    } cleave
+  ] output>array concat ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: rdata->ba ( type rdata -- ba )
+  swap
+    {
+      { CNAME [ dn->ba ] }
+      { HINFO [ hinfo->ba ] }
+      { MX    [ mx->ba ] }
+      { NS    [ dn->ba ] }
+      { PTR   [ dn->ba ] }
+      { SOA   [ soa->ba ] }
+      { A     [ ip->ba ] }
+    }
+  case ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: rr->ba ( rr -- ba )
+  [
+    {
+      [ name>>                 dn->ba     ]
+      [ type>>  type-table  at uint16->ba ]
+      [ class>> class-table at uint16->ba ]
+      [ ttl>>   uint32->ba ]
+      [
+        [ type>>            ] [ rdata>> ] bi rdata->ba
+        [ length uint16->ba ] [         ] bi append
+      ]
+    } cleave
+  ] output>array concat ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: header-bits-ba ( message -- ba )
+  [
+    {
+      [ qr>>                     15 shift ]
+      [ opcode>> opcode-table at 11 shift ]
+      [ aa>>                     10 shift ]
+      [ tc>>                      9 shift ]
+      [ rd>>                      8 shift ]
+      [ ra>>                      7 shift ]
+      [ z>>                       4 shift ]
+      [ rcode>>  rcode-table at   0 shift ]
+    } cleave
+  ] sum-outputs uint16->ba ;
+
+: message->ba ( message -- ba )
+  [
+    {
+      [ id>> uint16->ba ]
+      [ header-bits-ba ]
+      [ question-section>>   length uint16->ba ]
+      [ answer-section>>     length uint16->ba ]
+      [ authority-section>>  length uint16->ba ]
+      [ additional-section>> length uint16->ba ]
+      [ question-section>>   [ query->ba ] map concat ]
+      [ answer-section>>     [ rr->ba    ] map concat ]
+      [ authority-section>>  [ rr->ba    ] map concat ]
+      [ additional-section>> [ rr->ba    ] map concat ]
+    } cleave
+  ] output>array concat ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-single ( ba i -- n ) at ;
+: get-double ( ba i -- n ) dup 2 + subseq be> ;
+: get-quad   ( ba i -- n ) dup 4 + subseq be> ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: label-length ( ba i -- length ) get-single ;
+
+: skip-label ( ba i -- ba i ) 2dup label-length + 1 + ;
+
+: null-label? ( ba i -- ? ) get-single 0 = ;
+
+: get-label ( ba i -- label ) [ 1 + ] [ skip-label nip ] 2bi subseq >string ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: bit-test ( a b -- ? ) bitand 0 = not ;
+
+: pointer? ( ba i -- ? ) get-single BIN: 11000000 bit-test ;
+
+: pointer ( ba i -- val ) get-double BIN: 0011111111111111 bitand ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: skip-name ( ba i -- ba i )
+    {
+      { [ 2dup null-label? ] [ 1 + ] }
+      { [ 2dup pointer?    ] [ 2 + ] }
+      { [ t ] [ skip-label skip-name ] }
+    }
+  cond ;
+
+: get-name ( ba i -- name )
+    {
+      { [ 2dup null-label? ] [ 2drop "" ] }
+      { [ 2dup pointer?    ] [ dupd pointer get-name ] }
+      {
+        [ t ]
+        [
+          [ get-label ]
+          [ skip-label get-name ]
+          2bi
+          "." glue 
+        ]
+      }
+    }
+  cond ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-query ( ba i -- query )
+    [ get-name ]
+    [
+      skip-name
+      [ 0 + get-double type-table  value-at ]
+      [ 2 + get-double class-table value-at ]
+      2bi
+    ]
+  2bi query boa ;
+
+: skip-query ( ba i -- ba i ) skip-name 4 + ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-mx ( ba i -- mx ) [ get-double ] [ 2 + get-double ] 2bi mx boa ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-soa ( ba i -- soa )
+    {
+      [           get-name ]
+      [ skip-name get-name ]
+      [
+        skip-name
+        skip-name
+        {
+          [  0 + get-quad ]
+          [  4 + get-quad ]
+          [  8 + get-quad ]
+          [ 12 + get-quad ]
+          [ 16 + get-quad ]
+        }
+          2cleave
+      ]
+    }
+  2cleave soa boa ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-ip ( ba i -- ip ) dup 4 + subseq >array [ number>string ] map "." join ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-ipv6 ( ba i -- ip )
+  dup 16 + subseq 2 group [ be> 16 >base ] map ":" join ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-rdata ( ba i type -- rdata )
+    {
+      { CNAME [ get-name ] }
+      { NS    [ get-name ] }
+      { PTR   [ get-name ] }
+      { MX    [ get-mx   ] }
+      { SOA   [ get-soa  ] }
+      { A     [ get-ip   ] }
+      { AAAA  [ get-ipv6 ] }
+    }
+  case ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-rr ( ba i -- rr )
+  [ get-name ]
+  [
+    skip-name
+      {
+        [ 0 + get-double type-table  value-at ]
+        [ 2 + get-double class-table value-at ]
+        [ 4 + get-quad   ]
+        [ [ 10 + ] [ get-double type-table value-at ] 2bi get-rdata ]
+      }
+    2cleave
+  ]
+    2bi rr boa ;
+
+: skip-rr ( ba i -- ba i ) skip-name 8 + 2dup get-double + 2 + ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-question-section ( ba i count -- seq ba i )
+  [ drop [ skip-query ] [ get-query ] 2bi ] map -rot ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: get-rr-section ( ba i count -- seq ba i )
+  [ drop [ skip-rr ] [ get-rr ] 2bi ] map -rot ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: >> ( x n -- y ) neg shift ;
+
+: get-header-bits ( ba i -- qr opcode aa tc rd ra z rcode )
+    get-double
+    {
+      [ 15 >> BIN:    1 bitand ]
+      [ 11 >> BIN:  111 bitand opcode-table value-at ]
+      [ 10 >> BIN:    1 bitand ]
+      [  9 >> BIN:    1 bitand ]
+      [  8 >> BIN:    1 bitand ]
+      [  7 >> BIN:    1 bitand ]
+      [  4 >> BIN:  111 bitand ]
+      [       BIN: 1111 bitand rcode-table value-at ]
+    }
+  cleave ;
+
+: parse-message ( ba -- message )
+  0
+  {
+    [ get-double ]
+    [ 2 + get-header-bits ]
+    [
+      4 +
+      {
+        [ 8 +            ]
+        [ 0 + get-double ]
+        [ 2 + get-double ]
+        [ 4 + get-double ]
+        [ 6 + get-double ]
+      }
+        2cleave
+      {
+        [ get-question-section ]
+        [ get-rr-section ]
+        [ get-rr-section ]
+        [ get-rr-section ]
+      } spread
+      2drop
+    ]
+  }
+    2cleave message boa ;
+
+: ba->message ( ba -- message ) parse-message ;
+
+: with-message-bytes ( ba quot -- ) [ ba->message ] dip call message->ba ; inline
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: send-receive-udp ( ba server -- ba )
+  f 0 <inet4> <datagram>
+    [
+      [ send ] [ receive drop ] bi
+    ]
+  with-disposal ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: send-receive-tcp ( ba server -- ba )
+  [ dup length 2 >be prepend ] [ ] bi*
+  binary
+    [
+      write flush
+      2 read be> read
+    ]
+  with-client ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: >dns-inet4 ( obj -- inet4 )
+  dup string?
+    [ 53 <inet4> ]
+    [            ]
+  if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: ask-server ( message server -- message )
+  [ message->ba ] [ >dns-inet4 ] bi*
+  2dup
+  send-receive-udp parse-message
+  dup tc>> 1 =
+    [ drop send-receive-tcp parse-message ]
+    [ nip nip                             ]
+  if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: dns-servers ( -- seq ) V{ } ;
+
+: dns-server ( -- server ) dns-servers random ;
+
+: ask ( message -- message ) dns-server ask-server ;
+
+: query->message ( query -- message ) <message> swap 1array >>question-section ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: message-query ( message -- query ) question-section>> first ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ERROR: name-error name ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: fully-qualified ( name -- name )
+    {
+      { [ dup empty?         ] [ "." append ] }
+      { [ dup last CHAR: . = ] [            ] }
+      { [ t                  ] [ "." append ] }
+    }
+  cond ;
diff --git a/unmaintained/dns/forwarding/forwarding.factor b/unmaintained/dns/forwarding/forwarding.factor
new file mode 100644 (file)
index 0000000..4b7db30
--- /dev/null
@@ -0,0 +1,124 @@
+
+USING: kernel sequences combinators accessors locals random
+       combinators.short-circuit
+       io.sockets
+       dns dns.util dns.cache.rr dns.cache.nx
+       dns.resolver ;
+
+IN: dns.forwarding
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: query->rrs ( QUERY -- rrs/f )
+   [let | RRS [ QUERY cache-get ] |
+     RRS
+       [ RRS ]
+       [
+         [let | NAME  [ QUERY name>>  ]
+                TYPE  [ QUERY type>>  ]
+                CLASS [ QUERY class>> ] |
+               
+           [let | RRS/CNAME [ T{ query f NAME CNAME CLASS } cache-get ] |
+
+             RRS/CNAME f =
+               [ f ]
+               [
+                 [let | RR/CNAME [ RRS/CNAME first ] |
+            
+                   [let | REAL-NAME [ RR/CNAME rdata>> ] |
+              
+                     [let | RRS [
+                                  T{ query f REAL-NAME TYPE CLASS } query->rrs
+                                ] |
+
+                       RRS
+                         [ RRS/CNAME RRS append ]
+                         [ f ]
+                       if
+                     ] ] ]
+               ]
+             if
+           ] ]
+       ]
+     if
+   ] ;
+
+:: answer-from-cache ( MSG -- msg/f )
+   [let | QUERY [ MSG message-query ] |
+
+     [let | NX  [ QUERY name>> non-existent-name? ]
+            RRS [ QUERY query->rrs                ] |
+
+       {
+         { [ NX  ] [ MSG NAME-ERROR >>rcode          ] }
+         { [ RRS ] [ MSG RRS        >>answer-section ] }
+         { [ t   ] [ f                               ] }
+       }
+       cond
+     ]
+   ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: message-soa ( message -- rr/soa )
+  authority-section>> [ type>> SOA = ] filter first ;
+
+! :: cache-message ( MSG -- msg )
+!    MSG rcode>> NAME-ERROR =
+!      [
+!        [let | NAME [ MSG message-query name>> ]
+!               TTL  [ MSG message-soa   ttl>>  ] |
+!          NAME TTL cache-non-existent-name
+!        ]
+!      ]
+!    when
+!    MSG answer-section>>     [ cache-add ] each
+!    MSG authority-section>>  [ cache-add ] each
+!    MSG additional-section>> [ cache-add ] each
+!    MSG ;
+
+:: cache-message ( MSG -- msg )
+   MSG rcode>> NAME-ERROR =
+     [
+       [let | RR/SOA [ MSG
+                         authority-section>>
+                         [ type>> SOA = ] filter
+                       dup empty? [ drop f ] [ first ] if ] |
+         RR/SOA
+           [
+             [let | NAME [ MSG message-query name>> ]
+                    TTL  [ MSG message-soa   ttl>>  ] |
+               NAME TTL cache-non-existent-name
+             ]
+           ]
+         when
+       ]
+     ]
+   when
+   MSG answer-section>>     [ cache-add ] each
+   MSG authority-section>>  [ cache-add ] each
+   MSG additional-section>> [ cache-add ] each
+   MSG ;
+
+! : answer-from-server ( msg servers -- msg ) random ask-server cache-message ;
+
+: answer-from-server ( msg servers -- msg ) ask-servers cache-message ;
+
+:: find-answer ( MSG SERVERS -- msg )
+   { [ MSG answer-from-cache ] [ MSG SERVERS answer-from-server ] } 0|| ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: start-server ( ADDR-SPEC SERVERS -- )
+
+  [let | SOCKET [ ADDR-SPEC <datagram> ] |
+
+    [
+      SOCKET receive-packet
+        [ parse-message SERVERS find-answer message->ba ]
+      change-data
+      respond
+    ]
+    forever
+
+  ] ;
diff --git a/unmaintained/dns/misc/misc.factor b/unmaintained/dns/misc/misc.factor
new file mode 100644 (file)
index 0000000..72f553c
--- /dev/null
@@ -0,0 +1,34 @@
+
+USING: kernel combinators sequences splitting math 
+       io.files io.encodings.utf8 random dns.util ;
+
+IN: dns.misc
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: resolv-conf-servers ( -- seq )
+  "/etc/resolv.conf" utf8 file-lines
+  [ " " split ] map
+  [ first "nameserver" = ] filter
+  [ second ] map ;
+
+: resolv-conf-server ( -- ip ) resolv-conf-servers random ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: cdr-name ( name -- name ) dup CHAR: . index 1 + tail ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: domain-has-name? ( domain name -- ? )
+    {
+      { [ 2dup =       ] [ 2drop t ] }
+      { [ 2dup longer? ] [ 2drop f ] }
+      { [ t            ] [ cdr-name domain-has-name? ] }
+    }
+  cond ;
+
+: name-in-domain? ( name domain -- ? ) swap domain-has-name? ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
diff --git a/unmaintained/dns/resolver/resolver.factor b/unmaintained/dns/resolver/resolver.factor
new file mode 100644 (file)
index 0000000..32ad236
--- /dev/null
@@ -0,0 +1,72 @@
+
+USING: kernel accessors namespaces continuations
+       io io.sockets io.binary io.timeouts io.encodings.binary
+       destructors
+       locals strings sequences random prettyprint calendar dns dns.misc ;
+
+IN: dns.resolver
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: send-receive-udp ( BA SERVER -- ba )
+   T{ inet4 f f 0 } <datagram>
+   T{ duration { second 3 } } over set-timeout
+     [| SOCKET | BA SERVER SOCKET send SOCKET receive drop ]
+   with-disposal ;
+
+:: send-receive-tcp ( BA SERVER -- ba )
+   [let | BA [ BA length 2 >be BA append ] |
+     SERVER binary
+       [
+         T{ duration { second 3 } } input-stream get set-timeout
+         BA write flush 2 read be> read
+       ]
+     with-client                                        ] ;
+
+:: send-receive-server ( BA SERVER -- msg )
+   [let | RESULT [ BA SERVER send-receive-udp parse-message ] |
+     RESULT tc>> 1 =
+       [ BA SERVER send-receive-tcp parse-message ]
+       [ RESULT                                   ]
+     if                                                 ] ;
+
+: >dns-inet4 ( obj -- inet4 ) dup string? [ 53 <inet4> ] [ ] if ;
+
+:: send-receive-servers ( BA SERVERS -- msg )
+   SERVERS empty? [ "send-receive-servers: servers list empty" throw ] when
+   [let | SERVER [ SERVERS random >dns-inet4 ] |
+     ! if this throws an error ...
+     [ BA SERVER send-receive-server ]
+     ! we try with the other servers...
+     [ drop BA SERVER SERVERS remove send-receive-servers ]
+     recover                                            ] ;
+
+:: ask-servers ( MSG SERVERS -- msg )
+   MSG message->ba SERVERS send-receive-servers ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: fully-qualified ( name -- name ) dup "." tail? [ ] [ "." append ] if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: dns-servers ( -- seq )
+  \ dns-servers get
+    [ ]
+    [ resolv-conf-servers \ dns-servers set dns-servers ]
+  if* ;
+
+! : dns-server ( -- server ) dns-servers random ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: dns-ip4 ( name -- ips )
+  fully-qualified
+  [let | MSG [ A IN query boa query->message dns-servers ask-servers ] |
+    MSG rcode>> NO-ERROR =
+      [ MSG answer-section>> [ type>> A = ] filter [ rdata>> ] map ]
+      [ "dns-ip: rcode = " MSG rcode>> unparse append throw        ]
+    if ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
diff --git a/unmaintained/dns/server/server.factor b/unmaintained/dns/server/server.factor
new file mode 100644 (file)
index 0000000..773fe31
--- /dev/null
@@ -0,0 +1,208 @@
+
+USING: kernel combinators sequences sets math threads namespaces continuations
+       debugger io io.sockets unicode.case accessors destructors
+       combinators.short-circuit combinators.smart
+       fry arrays
+       dns dns.util dns.misc ;
+
+IN: dns.server
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOL: records-var
+
+: records ( -- records ) records-var get ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: {name-type-class} ( obj -- array )
+  [ [ name>> >lower ] [ type>> ] [ class>> ] tri ] output>array ; 
+
+: rr=query? ( obj obj -- ? ) [ {name-type-class} ] bi@ = ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: matching-rrs  ( query -- rrs ) records [ rr=query? ] with filter ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! zones
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: zones    ( -- names ) records [ type>> NS  = ] filter [ name>> ] map prune ;
+: my-zones ( -- names ) records [ type>> SOA = ] filter [ name>> ] map ;
+
+: delegated-zones ( -- names ) zones my-zones diff ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! name->zone
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: name->zone ( name -- zone/f )
+  zones sort-largest-first [ name-in-domain? ] with find nip ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! name->authority
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: name->authority ( name -- rrs-ns ) name->zone NS IN query boa matching-rrs ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! extract-names
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: rr->rdata-names ( rr -- names/f )
+    {
+      { [ dup type>> NS    = ] [ rdata>>            1array ] }
+      { [ dup type>> MX    = ] [ rdata>> exchange>> 1array ] }
+      { [ dup type>> CNAME = ] [ rdata>>            1array ] }
+      { [ t ]                  [ drop f ] }
+    }
+  cond ;
+
+: extract-rdata-names ( message -- names )
+  [ answer-section>> ] [ authority-section>> ] bi append
+  [ rr->rdata-names ] map concat ;
+
+: extract-names ( message -- names )
+  [ message-query name>> ] [ extract-rdata-names ] bi swap prefix ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! fill-authority
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: fill-authority ( message -- message )
+  dup
+    extract-names [ name->authority ] map concat prune
+    over answer-section>> diff
+  >>authority-section ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! fill-additional
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: name->rrs-a ( name -- rrs-a ) A IN query boa matching-rrs ;
+
+: fill-additional ( message -- message )
+  dup
+    extract-rdata-names [ name->rrs-a ] map concat prune
+    over answer-section>> diff
+  >>additional-section ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! query->rrs
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+DEFER: query->rrs
+
+: matching-rrs? ( query -- rrs/f ) matching-rrs [ empty? ] [ drop f ] [ ] 1if ;
+
+: matching-cname? ( query -- rrs/f )
+  [ ] [ clone CNAME >>type matching-rrs ] bi ! query rrs
+  [ empty? not ]
+    [ first swap clone over rdata>> >>name query->rrs swap prefix ]
+    [ 2drop f ]
+  1if ;
+
+: query->rrs ( query -- rrs/f ) { [ matching-rrs? ] [ matching-cname? ] } 1|| ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! have-answers
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: have-answers ( message -- message/f )
+  dup message-query query->rrs
+  [ empty? ]
+    [ 2drop f ]
+    [ >>answer-section fill-authority fill-additional ]
+  1if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! have-delegates?
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: cdr-name ( name -- name ) dup CHAR: . index 1 + tail ;
+
+: is-soa? ( name -- ? ) SOA IN query boa matching-rrs empty? not ;
+
+: have-ns? ( name -- rrs/f )
+  NS IN query boa matching-rrs [ empty? ] [ drop f ] [ ] 1if ;
+
+: name->delegates ( name -- rrs-ns )
+    {
+      [ "" =    { } and ]
+      [ is-soa? { } and ]
+      [ have-ns? ]
+      [ cdr-name name->delegates ]
+    }
+  1|| ;
+
+: have-delegates ( message -- message/f )
+  dup message-query name>> name->delegates ! message rrs-ns
+  [ empty? ]
+    [ 2drop f ]
+    [
+      dup [ rdata>> A IN query boa matching-rrs ] map concat
+                                           ! message rrs-ns rrs-a
+      [ >>authority-section ]
+      [ >>additional-section ]
+      bi*
+    ]
+  1if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! outsize-zones
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: outside-zones ( message -- message/f )
+  dup message-query name>> name->zone f =
+    [ ]
+    [ drop f ]
+  if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! is-nx
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: is-nx ( message -- message/f )
+  [ message-query name>> records [ name>> = ] with filter empty? ]
+    [
+      NAME-ERROR >>rcode
+      dup
+        message-query name>> name->zone SOA IN query boa matching-rrs
+      >>authority-section
+    ]
+    [ drop f ]
+  1if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: none-of-type ( message -- message )
+  dup
+    message-query name>> name->zone SOA IN query boa matching-rrs
+  >>authority-section ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: find-answer ( message -- message )
+    {
+      [ have-answers   ]
+      [ have-delegates ]
+      [ outside-zones  ]
+      [ is-nx          ]
+      [ none-of-type   ]
+    }
+  1|| ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: (handle-request) ( packet -- )
+  [ [ find-answer ] with-message-bytes ] change-data respond ;
+
+: handle-request ( packet -- ) [ (handle-request) ] curry in-thread ;
+
+: receive-loop ( socket -- )
+  [ receive-packet handle-request ] [ receive-loop ] bi ;
+
+: loop ( addr-spec -- )
+  [ <datagram> '[ _ [ receive-loop ] with-disposal ] try ] [ loop ] bi ;
+
diff --git a/unmaintained/dns/stub/stub.factor b/unmaintained/dns/stub/stub.factor
new file mode 100644 (file)
index 0000000..a15feb5
--- /dev/null
@@ -0,0 +1,20 @@
+
+USING: kernel sequences random accessors dns ;
+
+IN: dns.stub
+
+! Stub resolver
+! 
+! Generally useful, but particularly when running a forwarding,
+! caching, nameserver on localhost with multiple Factor instances
+! querying it.
+
+: name->ip ( name -- ip )
+  A IN query boa
+  query->message
+  ask
+  dup rcode>> NAME-ERROR =
+    [ message-query name>> name-error ]
+    [ answer-section>> [ type>> A = ] filter random rdata>> ]
+  if ;
+
diff --git a/unmaintained/dns/util/util.factor b/unmaintained/dns/util/util.factor
new file mode 100644 (file)
index 0000000..6934d3b
--- /dev/null
@@ -0,0 +1,31 @@
+
+USING: kernel sequences sorting math math.order macros fry ;
+
+IN: dns.util
+
+: tri-chain ( obj p q r -- x y z )
+  [ [ call dup ] dip call dup ] dip call ; inline
+
+MACRO: 1if ( test then else -- ) '[ dup @ _ _ if ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: sort-largest-first ( seq -- seq ) [ length ] sort-with reverse ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: longer? ( seq seq -- ? ) [ length ] bi@ > ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+USING: io.sockets accessors ;
+
+TUPLE: packet data addr socket ;
+
+: receive-packet ( socket -- packet ) [ receive ] keep packet boa ;
+
+: respond ( packet -- ) [ data>> ] [ addr>> ] [ socket>> ] tri send ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: forever ( quot: ( -- ) -- ) [ call ] [ forever ] bi ; inline recursive
\ No newline at end of file
diff --git a/unmaintained/drills/deployed/deploy.factor b/unmaintained/drills/deployed/deploy.factor
new file mode 100644 (file)
index 0000000..c1e9307
--- /dev/null
@@ -0,0 +1,14 @@
+USING: tools.deploy.config ;
+H{
+    { 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-ui? t }
+    { deploy-word-props? t }
+    { deploy-io 3 }
+}
diff --git a/unmaintained/drills/deployed/deployed.factor b/unmaintained/drills/deployed/deployed.factor
new file mode 100644 (file)
index 0000000..5681c73
--- /dev/null
@@ -0,0 +1,36 @@
+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 ;
+: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
+: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
+
+: show ( model -- gadget ) dup it set-global [ random ] <arrow>
+   { [ [ first ] card ]
+     [ [ second ] card ]
+     [ '[ |<< it get _ model-changed ] "No" op ]
+          [ '[ |<< [ it get [
+        _ value>> swap remove
+        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
+     ] change-model ] with-return ] "Yes" op ]
+   } cleave
+2array { 1 0 } <track> swap [ 0.5 track-add ] each
+3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
+it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
+
+: drill ( -- ) [
+   open-panel [
+         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
+            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
+         "Got it?" open-window
+   ] [ 0 exit ] if*
+] with-ui ;
+
+MAIN: drill
\ No newline at end of file
diff --git a/unmaintained/drills/deployed/tags.txt b/unmaintained/drills/deployed/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/unmaintained/drills/drills.factor b/unmaintained/drills/drills.factor
new file mode 100644 (file)
index 0000000..1da1fca
--- /dev/null
@@ -0,0 +1,37 @@
+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-border-btn> ;
+
+: show ( model -- gadget ) dup it set-global [ random ] <arrow>
+   { [ [ first ] card ]
+     [ [ second ] card ]
+     [ '[ |<< it get _ model-changed ] "No" op ]
+          [ '[ |<< [ it get [
+        _ value>> swap remove
+        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
+     ] change-model ] with-return ] "Yes" op ]
+   } cleave
+2array { 1 0 } <track> swap [ 0.5 track-add ] each
+3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
+it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
+
+: drill ( -- ) [
+   open-panel [
+         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
+            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
+         "Got it?" open-window
+   ] when*
+] with-ui ;
+
+MAIN: drill
\ No newline at end of file
diff --git a/unmaintained/drills/tags.txt b/unmaintained/drills/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index 1b4224c864727a704c017979c10d2fb7e89b239f..e14ffb4a83911b421f9ff29d816934a79742d79e 100644 (file)
@@ -34,7 +34,7 @@ M: graph num-vertices
     vertices length ;
 
 M: graph num-edges
-   [ vertices ] [ '[ _ adjlist length ] sigma ] bi ;
+   [ vertices ] [ '[ _ adjlist length ] map-sum ] bi ;
 
 M: graph adjlist
     [ vertices ] [ swapd '[ _ swap _ adj? ] filter ] bi ;
diff --git a/unmaintained/models/combinators/authors.txt b/unmaintained/models/combinators/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/models/combinators/combinators-docs.factor b/unmaintained/models/combinators/combinators-docs.factor
new file mode 100644 (file)
index 0000000..8ac3657
--- /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 { "model" model } { "oldval" "starting value" } { "quot" "applied to update and previous values" } { "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"
diff --git a/unmaintained/models/combinators/combinators.factor b/unmaintained/models/combinators/combinators.factor
new file mode 100644 (file)
index 0000000..4896910
--- /dev/null
@@ -0,0 +1,105 @@
+USING: accessors arrays kernel models models.product monads
+sequences sequences.extras shuffle ;
+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 >>
diff --git a/unmaintained/models/combinators/summary.txt b/unmaintained/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/unmaintained/models/combinators/templates/templates.factor b/unmaintained/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/unmaintained/newfx/newfx.factor b/unmaintained/newfx/newfx.factor
deleted file mode 100644 (file)
index bf7955f..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-
-USING: kernel sequences assocs circular sets fry ;
-
-USING: math multi-methods ;
-
-QUALIFIED: sequences
-QUALIFIED: assocs
-QUALIFIED: circular
-QUALIFIED: sets
-
-IN: newfx
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! Now, we can see a new world coming into view.
-! A world in which there is the very real prospect of a new world order.
-!
-!    - George Herbert Walker Bush
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: at ( col key -- val )
-GENERIC: of ( key col -- val )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: grab ( col key -- col val )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: is ( col key val -- col )
-GENERIC: as ( col val key -- col )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: is-of ( key val col -- col )
-GENERIC: as-of ( val key col -- col )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: mutate-at ( col key val -- )
-GENERIC: mutate-as ( col val key -- )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: at-mutate ( key val col -- )
-GENERIC: as-mutate ( val key col -- )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! sequence
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: at { sequence number  } swap nth ;
-METHOD: of { number  sequence }      nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: grab { sequence number } dupd swap nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: is { sequence number object  } swap pick set-nth ;
-METHOD: as { sequence object  number }      pick set-nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: is-of { number object  sequence } dup [ swapd set-nth ] dip ;
-METHOD: as-of { object  number sequence } dup [       set-nth ] dip ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: mutate-at { sequence number object  } swap rot set-nth ;
-METHOD: mutate-as { sequence object  number }      rot set-nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: at-mutate { number object  sequence } swapd set-nth ;
-METHOD: as-mutate { object  number sequence }       set-nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! assoc
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: at { assoc object } swap assocs:at ;
-METHOD: of { object assoc }      assocs:at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: grab { assoc object } dupd swap assocs:at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: is { assoc object object } swap pick set-at ;
-METHOD: as { assoc object object }      pick set-at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: is-of { object object assoc } dup [ swapd set-at ] dip ;
-METHOD: as-of { object object assoc } dup [       set-at ] dip ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: mutate-at { assoc object object } swap rot set-at ;
-METHOD: mutate-as { assoc object object }      rot set-at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-METHOD: at-mutate { object object assoc } swapd set-at ;
-METHOD: as-mutate { object object assoc }       set-at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: push      ( seq obj -- seq ) over sequences:push ;
-: push-on   ( obj seq -- seq ) tuck sequences:push ;
-: pushed    ( seq obj --     ) swap sequences:push ;
-: pushed-on ( obj seq --     )      sequences:push ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: member?    ( seq obj -- ? ) swap sequences:member? ;
-: member-of? ( obj seq -- ? )      sequences:member? ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: delete-at-key ( tbl key -- tbl ) over delete-at ;
-: delete-key-of ( key tbl -- tbl ) tuck delete-at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: delete      ( seq elt -- seq ) over sequences:delete ;
-: delete-from ( elt seq -- seq ) tuck sequences:delete ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: deleted      ( seq elt -- ) swap sequences:delete ;
-: deleted-from ( elt seq -- )      sequences:delete ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: remove      ( seq obj -- seq ) swap sequences:remove ;
-: remove-from ( obj seq -- seq )      sequences:remove ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: filter-of ( quot seq -- seq ) swap filter ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: map-over ( quot seq -- seq ) swap map ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: push-circular ( seq elt -- seq ) over circular:push-circular ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: prefix-on ( elt seq -- seq ) swap prefix ;
-: suffix-on ( elt seq -- seq ) swap suffix ;
-
-: suffix!      ( seq elt -- seq ) over sequences:push ;
-: suffix-on!   ( elt seq -- seq ) tuck sequences:push ;
-: suffixed!    ( seq elt --     ) swap sequences:push ;
-: suffixed-on! ( elt seq --     )      sequences:push ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: subseq ( seq from to -- subseq ) rot sequences:subseq ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: key ( table val -- key ) swap assocs:value-at ;
-
-: key-of ( val table -- key ) assocs:value-at ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: index    ( seq obj -- i ) swap sequences:index ;
-: index-of ( obj seq -- i )      sequences:index ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: 1st ( seq -- obj ) 0 swap nth ;
-: 2nd ( seq -- obj ) 1 swap nth ;
-: 3rd ( seq -- obj ) 2 swap nth ;
-: 4th ( seq -- obj ) 3 swap nth ;
-: 5th ( seq -- obj ) 4 swap nth ;
-: 6th ( seq -- obj ) 5 swap nth ;
-: 7th ( seq -- obj ) 6 swap nth ;
-: 8th ( seq -- obj ) 7 swap nth ;
-: 9th ( seq -- obj ) 8 swap nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! A note about the 'mutate' qualifier. Other words also technically mutate
-! their primary object. However, the 'mutate' qualifier is supposed to
-! indicate that this is the main objective of the word, as a side effect.
-
-: adjoin      ( seq elt -- seq ) over sets:adjoin ;
-: adjoin-on   ( elt seq -- seq ) tuck sets:adjoin ;
-: adjoined    ( set elt --     ) swap sets:adjoin ;
-: adjoined-on ( elt set --     )      sets:adjoin ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: start ( seq subseq -- i ) swap sequences:start ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: pluck         ( seq i   -- seq ) cut-slice rest-slice append ;
-: pluck-from    ( i   seq -- seq ) swap pluck ;
-: pluck!        ( seq i   -- seq ) over delete-nth ;
-: pluck-from!   ( i   seq -- seq ) tuck delete-nth ;
-: plucked!      ( seq i   --     ) swap delete-nth ;
-: plucked-from! ( i   seq --     )      delete-nth ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: snip          ( seq a b -- seq ) [ over ] dip [ head ] [ tail ] 2bi* append ;
-: snip-this     ( a b seq -- seq ) -rot snip ;
-: snip!         ( seq a b -- seq )      pick delete-slice ;
-: snip-this!    ( a b seq -- seq ) -rot pick delete-slice ;
-: snipped!      ( seq a b --     )       rot delete-slice ;
-: snipped-from! ( a b seq --     )           delete-slice ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: invert-index ( seq i -- seq i ) [ dup length 1 - ] dip - ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: append!      ( a b -- ab )      over sequences:push-all ;
-: append-to!   ( b a -- ab ) swap over sequences:push-all ;
-: appended!    ( a b --    ) swap      sequences:push-all ;
-: appended-to! ( b a --    )           sequences:push-all ;
-
-: prepend!   ( a b -- ba  ) over append 0 pick copy ;
-: prepended! ( a b --     ) over append 0 rot  copy ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: insert ( seq i obj -- seq ) [ cut ] dip prefix append ;
-
-: splice ( seq i seq -- seq ) [ cut ] dip prepend append ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: purge ( seq quot -- seq ) [ not ] compose filter ; inline
-
-: purge! ( seq quot -- seq )
-  dupd '[ swap @ [ pluck! ] [ drop ] if ] each-index ; inline
diff --git a/unmaintained/recipes/authors.txt b/unmaintained/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/unmaintained/recipes/icons/back.tiff b/unmaintained/recipes/icons/back.tiff
new file mode 100644 (file)
index 0000000..27b8112
Binary files /dev/null and b/unmaintained/recipes/icons/back.tiff differ
diff --git a/unmaintained/recipes/icons/hate.tiff b/unmaintained/recipes/icons/hate.tiff
new file mode 100644 (file)
index 0000000..d7d5f8e
Binary files /dev/null and b/unmaintained/recipes/icons/hate.tiff differ
diff --git a/unmaintained/recipes/icons/love.tiff b/unmaintained/recipes/icons/love.tiff
new file mode 100644 (file)
index 0000000..ae2fa7b
Binary files /dev/null and b/unmaintained/recipes/icons/love.tiff differ
diff --git a/unmaintained/recipes/icons/more.tiff b/unmaintained/recipes/icons/more.tiff
new file mode 100644 (file)
index 0000000..b4ec27b
Binary files /dev/null and b/unmaintained/recipes/icons/more.tiff differ
diff --git a/unmaintained/recipes/icons/submit.tiff b/unmaintained/recipes/icons/submit.tiff
new file mode 100644 (file)
index 0000000..7c98267
Binary files /dev/null and b/unmaintained/recipes/icons/submit.tiff differ
diff --git a/unmaintained/recipes/recipes.factor b/unmaintained/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/unmaintained/recipes/summary.txt b/unmaintained/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/unmaintained/sudokus/authors.txt b/unmaintained/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/unmaintained/sudokus/sudokus.factor b/unmaintained/sudokus/sudokus.factor
new file mode 100644 (file)
index 0000000..c7bc694
--- /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 shuffle ;
+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 [ [ f swap [ length random ] keep 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
diff --git a/unmaintained/sudokus/summary.txt b/unmaintained/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
diff --git a/unmaintained/ui/gadgets/alerts/alerts.factor b/unmaintained/ui/gadgets/alerts/alerts.factor
new file mode 100644 (file)
index 0000000..70943e6
--- /dev/null
@@ -0,0 +1,29 @@
+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 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' )
+    [
+        string <label>  T{ font { name "sans-serif" } { size 14 } } >>font dup , :> lbl
+        <model-field*> ->% 1 :> fldm
+        "okay" <model-border-btn> :> 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 ;
diff --git a/unmaintained/ui/gadgets/alerts/authors.txt b/unmaintained/ui/gadgets/alerts/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/unmaintained/ui/gadgets/alerts/summary.txt b/unmaintained/ui/gadgets/alerts/summary.txt
new file mode 100644 (file)
index 0000000..f1cd420
--- /dev/null
@@ -0,0 +1 @@
+Really simple dialog boxes
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/comboboxes/authors.txt b/unmaintained/ui/gadgets/comboboxes/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/unmaintained/ui/gadgets/comboboxes/comboboxes.factor b/unmaintained/ui/gadgets/comboboxes/comboboxes.factor
new file mode 100644 (file)
index 0000000..3eb1180
--- /dev/null
@@ -0,0 +1,22 @@
+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 drop ] 2keep swap
+   T{ button-up } = [
+      [ spawner>> ]
+      [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
+      [ hide-glass ] tri
+   ] [ drop ] if t ;
+
+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 <basic> >>model ] keep
+    <basic> combo-table new-table [ 1array ] >>quot >>table ;
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/comboboxes/summary.txt b/unmaintained/ui/gadgets/comboboxes/summary.txt
new file mode 100644 (file)
index 0000000..0f2ce2b
--- /dev/null
@@ -0,0 +1 @@
+Combo boxes have a model choosen from a list of options
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/controls/authors.txt b/unmaintained/ui/gadgets/controls/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/ui/gadgets/controls/controls-docs.factor b/unmaintained/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/unmaintained/ui/gadgets/controls/controls.factor b/unmaintained/ui/gadgets/controls/controls.factor
new file mode 100644 (file)
index 0000000..5de6da8
--- /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 ui.gadgets.editors.private
+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 append! ;
+
+SYNTAX: IMG-BTN: image-prep [ swap <button> ] curry append! ;
+
+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 ; 
diff --git a/unmaintained/ui/gadgets/controls/summary.txt b/unmaintained/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/unmaintained/ui/gadgets/layout/authors.txt b/unmaintained/ui/gadgets/layout/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/ui/gadgets/layout/layout-docs.factor b/unmaintained/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/unmaintained/ui/gadgets/layout/layout.factor b/unmaintained/ui/gadgets/layout/layout.factor
new file mode 100644 (file)
index 0000000..c287b9a
--- /dev/null
@@ -0,0 +1,90 @@
+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 ] 2dip swap '[ [ _ templates set _ , @ ] with-interface ] ] when* ;
+
+SYNTAX: ,% scan string>number [ <layout> , ] curry append! ;
+SYNTAX: ->% scan string>number '[ [ _ <layout> , ] [ output-model ] bi ] append! ;
+
+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 append! ;
+
+: 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 ;
diff --git a/unmaintained/ui/gadgets/layout/summary.txt b/unmaintained/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
diff --git a/unmaintained/ui/gadgets/poppers/authors.txt b/unmaintained/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/unmaintained/ui/gadgets/poppers/poppers.factor b/unmaintained/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 5e284be5877c5a362301014727b3102cc3d4201c..3572677aa6d54dc801c3647a43f3c8b62ce703ba 100644 (file)
@@ -6,7 +6,6 @@ namespace factor
 aging_collector::aging_collector(factor_vm *parent_) :
        copying_collector<aging_space,aging_policy>(
                parent_,
-               &parent_->gc_stats.aging_stats,
                parent_->data->aging,
                aging_policy(parent_)) {}
 
@@ -22,28 +21,40 @@ void factor_vm::collect_aging()
                current_gc->op = collect_to_tenured_op;
 
                to_tenured_collector collector(this);
+
+               current_gc->event->started_code_scan();
                collector.trace_cards(data->tenured,
                        card_points_to_aging,
-                       simple_unmarker(card_mark_mask));
-               collector.cheneys_algorithm();
+                       full_unmarker());
+               current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
+
+               current_gc->event->started_code_scan();
+               collector.trace_code_heap_roots(&code->points_to_aging);
+               current_gc->event->ended_code_scan(collector.code_blocks_scanned);
+
+               collector.tenure_reachable_objects();
+
+               current_gc->event->started_code_sweep();
+               update_code_heap_for_minor_gc(&code->points_to_aging);
+               current_gc->event->ended_code_sweep();
        }
        {
                /* If collection fails here, do a to_tenured collection. */
                current_gc->op = collect_aging_op;
 
                std::swap(data->aging,data->aging_semispace);
-               reset_generation(data->aging);
+               data->reset_generation(data->aging);
 
                aging_collector collector(this);
 
                collector.trace_roots();
                collector.trace_contexts();
-               collector.trace_code_heap_roots(&code->points_to_aging);
+
                collector.cheneys_algorithm();
-               update_code_heap_for_minor_gc(&code->points_to_aging);
 
-               nursery.here = nursery.start;
+               data->reset_generation(&nursery);
                code->points_to_nursery.clear();
+               code->points_to_aging.clear();
        }
 }
 
index 1fa82972ffcb4c4f4efd23f3b476776381fc87ee..56550b211ab8d14de566c5dfa26255cb5d51ed29 100644 (file)
@@ -3,9 +3,10 @@ namespace factor
 
 struct aging_policy {
        factor_vm *parent;
-       zone *aging, *tenured;
+       aging_space *aging;
+       tenured_space *tenured;
 
-       aging_policy(factor_vm *parent_) :
+       explicit aging_policy(factor_vm *parent_) :
                parent(parent_),
                aging(parent->data->aging),
                tenured(parent->data->tenured) {}
@@ -14,10 +15,14 @@ struct aging_policy {
        {
                return !(aging->contains_p(untagged) || tenured->contains_p(untagged));
        }
+
+       void promoted_object(object *obj) {}
+
+       void visited_object(object *obj) {}
 };
 
 struct aging_collector : copying_collector<aging_space,aging_policy> {
-       aging_collector(factor_vm *parent_);
+       explicit aging_collector(factor_vm *parent_);
 };
 
 }
index c2ec2a645e6bae172efdb58eb67e29cf7518e47b..ccb2d1a1a2f21d05e57cc030e9385e1fe4ab8ea7 100644 (file)
@@ -1,8 +1,20 @@
 namespace factor
 {
 
-struct aging_space : old_space {
-       aging_space(cell size, cell start) : old_space(size,start) {}
+struct aging_space : bump_allocator<object> {
+       object_start_map starts;
+
+       explicit aging_space(cell size, cell start) :
+               bump_allocator<object>(size,start), starts(size,start) {}
+
+       object *allot(cell size)
+       {
+               if(here + size > end) return NULL;
+
+               object *obj = bump_allocator<object>::allot(size);
+               starts.record_object_start_offset(obj);
+               return obj;
+       }
 };
 
 }
index ed3adf5c9bf82c3a3283a1738ccdefff44121992..d07b6e353b9c6f255326cfa91e5e87b02b1891e0 100755 (executable)
@@ -14,7 +14,10 @@ char *factor_vm::pinned_alien_offset(cell obj)
                        alien *ptr = untag<alien>(obj);
                        if(to_boolean(ptr->expired))
                                general_error(ERROR_EXPIRED,obj,false_object,NULL);
-                       return pinned_alien_offset(ptr->base) + ptr->displacement;
+                       if(to_boolean(ptr->base))
+                               type_error(ALIEN_TYPE,obj);
+                       else
+                               return (char *)ptr->address;
                }
        case F_TYPE:
                return NULL;
@@ -27,8 +30,8 @@ char *factor_vm::pinned_alien_offset(cell obj)
 /* make an alien */
 cell factor_vm::allot_alien(cell delegate_, cell displacement)
 {
-       gc_root<object> delegate(delegate_,this);
-       gc_root<alien> new_alien(allot<alien>(sizeof(alien)),this);
+       data_root<object> delegate(delegate_,this);
+       data_root<alien> new_alien(allot<alien>(sizeof(alien)),this);
 
        if(delegate.type_p(ALIEN_TYPE))
        {
@@ -41,6 +44,7 @@ cell factor_vm::allot_alien(cell delegate_, cell displacement)
 
        new_alien->displacement = displacement;
        new_alien->expired = false_object;
+       new_alien->update_address();
 
        return new_alien.value();
 }
@@ -113,9 +117,9 @@ DEFINE_ALIEN_ACCESSOR(cell,void *,box_alien,pinned_alien_offset)
 /* open a native library and push a handle */
 void factor_vm::primitive_dlopen()
 {
-       gc_root<byte_array> path(dpop(),this);
+       data_root<byte_array> path(dpop(),this);
        path.untag_check(this);
-       gc_root<dll> library(allot<dll>(sizeof(dll)),this);
+       data_root<dll> library(allot<dll>(sizeof(dll)),this);
        library->path = path.value();
        ffi_dlopen(library.untagged());
        dpush(library.value());
@@ -124,8 +128,8 @@ void factor_vm::primitive_dlopen()
 /* look up a symbol in a native library */
 void factor_vm::primitive_dlsym()
 {
-       gc_root<object> library(dpop(),this);
-       gc_root<byte_array> name(dpop(),this);
+       data_root<object> library(dpop(),this);
+       data_root<byte_array> name(dpop(),this);
        name.untag_check(this);
 
        symbol_char *sym = name->data<symbol_char>();
@@ -168,12 +172,7 @@ char *factor_vm::alien_offset(cell obj)
        case BYTE_ARRAY_TYPE:
                return untag<byte_array>(obj)->data<char>();
        case ALIEN_TYPE:
-               {
-                       alien *ptr = untag<alien>(obj);
-                       if(to_boolean(ptr->expired))
-                               general_error(ERROR_EXPIRED,obj,false_object,NULL);
-                       return alien_offset(ptr->base) + ptr->displacement;
-               }
+               return (char *)untag<alien>(obj)->address;
        case F_TYPE:
                return NULL;
        default:
diff --git a/vm/allot.hpp b/vm/allot.hpp
new file mode 100644 (file)
index 0000000..2c2c58c
--- /dev/null
@@ -0,0 +1,29 @@
+namespace factor
+{
+
+/*
+ * It is up to the caller to fill in the object's fields in a meaningful
+ * fashion!
+ */
+inline object *factor_vm::allot_object(cell type, cell size)
+{
+       /* If the object is smaller than the nursery, allocate it in the nursery,
+       after a GC if needed */
+       if(nursery.size > size)
+       {
+               /* If there is insufficient room, collect the nursery */
+               if(nursery.here + size > nursery.end)
+                       primitive_minor_gc();
+
+               object *obj = nursery.allot(size);
+
+               obj->initialize(type);
+               return obj;
+       }
+       /* If the object is bigger than the nursery, allocate it in
+       tenured space */
+       else
+               return allot_large_object(type,size);
+}
+
+}
index 09c6998e69e37c5f24d37d92c3aa369c679e1b51..4c97ef59a0f0dd93ffafbffe48e40e48e55a43d4 100644 (file)
@@ -3,46 +3,36 @@
 namespace factor
 {
 
-/* make a new array with an initial element */
 array *factor_vm::allot_array(cell capacity, cell fill_)
 {
-       gc_root<object> fill(fill_,this);
-       gc_root<array> new_array(allot_array_internal<array>(capacity),this);
-
-       if(fill.value() == tag_fixnum(0))
-               memset(new_array->data(),'\0',capacity * sizeof(cell));
-       else
-       {
-               /* No need for write barrier here. Either the object is in
-               the nursery, or it was allocated directly in tenured space
-               and the write barrier is already hit for us in that case. */
-               for(cell i = 0; i < capacity; i++)
-                       new_array->data()[i] = fill.value();
-       }
-       return new_array.untagged();
+       data_root<object> fill(fill_,this);
+       array *new_array = allot_uninitialized_array<array>(capacity);
+       memset_cell(new_array->data(),fill.value(),capacity * sizeof(cell));
+       return new_array;
 }
 
-/* push a new array on the stack */
 void factor_vm::primitive_array()
 {
-       cell initial = dpop();
-       cell size = unbox_array_size();
-       dpush(tag<array>(allot_array(size,initial)));
+       data_root<object> fill(dpop(),this);
+       cell capacity = unbox_array_size();
+       array *new_array = allot_uninitialized_array<array>(capacity);
+       memset_cell(new_array->data(),fill.value(),capacity * sizeof(cell));
+       dpush(tag<array>(new_array));
 }
 
 cell factor_vm::allot_array_1(cell obj_)
 {
-       gc_root<object> obj(obj_,this);
-       gc_root<array> a(allot_array_internal<array>(1),this);
+       data_root<object> obj(obj_,this);
+       data_root<array> a(allot_uninitialized_array<array>(1),this);
        set_array_nth(a.untagged(),0,obj.value());
        return a.value();
 }
 
 cell factor_vm::allot_array_2(cell v1_, cell v2_)
 {
-       gc_root<object> v1(v1_,this);
-       gc_root<object> v2(v2_,this);
-       gc_root<array> a(allot_array_internal<array>(2),this);
+       data_root<object> v1(v1_,this);
+       data_root<object> v2(v2_,this);
+       data_root<array> a(allot_uninitialized_array<array>(2),this);
        set_array_nth(a.untagged(),0,v1.value());
        set_array_nth(a.untagged(),1,v2.value());
        return a.value();
@@ -50,11 +40,11 @@ cell factor_vm::allot_array_2(cell v1_, cell v2_)
 
 cell factor_vm::allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
 {
-       gc_root<object> v1(v1_,this);
-       gc_root<object> v2(v2_,this);
-       gc_root<object> v3(v3_,this);
-       gc_root<object> v4(v4_,this);
-       gc_root<array> a(allot_array_internal<array>(4),this);
+       data_root<object> v1(v1_,this);
+       data_root<object> v2(v2_,this);
+       data_root<object> v3(v3_,this);
+       data_root<object> v4(v4_,this);
+       data_root<array> a(allot_uninitialized_array<array>(4),this);
        set_array_nth(a.untagged(),0,v1.value());
        set_array_nth(a.untagged(),1,v2.value());
        set_array_nth(a.untagged(),2,v3.value());
@@ -64,15 +54,16 @@ cell factor_vm::allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
 
 void factor_vm::primitive_resize_array()
 {
-       array *a = untag_check<array>(dpop());
+       data_root<array> a(dpop(),this);
+       a.untag_check(this);
        cell capacity = unbox_array_size();
-       dpush(tag<array>(reallot_array(a,capacity)));
+       dpush(tag<array>(reallot_array(a.untagged(),capacity)));
 }
 
 void growable_array::add(cell elt_)
 {
        factor_vm *parent = elements.parent;
-       gc_root<object> elt(elt_,parent);
+       data_root<object> elt(elt_,parent);
        if(count == array_capacity(elements.untagged()))
                elements = parent->reallot_array(elements.untagged(),count * 2);
 
@@ -82,7 +73,7 @@ void growable_array::add(cell elt_)
 void growable_array::append(array *elts_)
 {
        factor_vm *parent = elements.parent;
-       gc_root<array> elts(elts_,parent);
+       data_root<array> elts(elts_,parent);
        cell capacity = array_capacity(elts.untagged());
        if(count + capacity > array_capacity(elements.untagged()))
        {
index 48be881230a35672c2c8ba9771704e5c52cc032c..8eb2b530b0686944d44c34255c657fc9bf7ad6d4 100755 (executable)
@@ -15,7 +15,6 @@ inline void factor_vm::set_array_nth(array *array, cell slot, cell value)
 #ifdef FACTOR_DEBUG
        assert(slot < array_capacity(array));
        assert(array->h.hi_tag() == ARRAY_TYPE);
-       check_tagged_pointer(value);
 #endif
        cell *slot_ptr = &array->data()[slot];
        *slot_ptr = value;
@@ -24,7 +23,7 @@ inline void factor_vm::set_array_nth(array *array, cell slot, cell value)
 
 struct growable_array {
        cell count;
-       gc_root<array> elements;
+       data_root<array> elements;
 
        explicit growable_array(factor_vm *parent, cell capacity = 10) :
                count(0), elements(parent->allot_array(capacity,false_object),parent) {}
index d8c5452b08b95da865c12a25cc6d7536e95922b8..5a391e7625f3c1faa28ed503c4f07fc76092f408 100755 (executable)
@@ -1299,7 +1299,7 @@ bignum *factor_vm::bignum_digit_to_bignum(bignum_digit_type digit, int negative_
 bignum *factor_vm::allot_bignum(bignum_length_type length, int negative_p)
 {
        BIGNUM_ASSERT ((length >= 0) || (length < BIGNUM_RADIX));
-       bignum * result = allot_array_internal<bignum>(length + 1);
+       bignum * result = allot_uninitialized_array<bignum>(length + 1);
        BIGNUM_SET_NEGATIVE_P (result, negative_p);
        return (result);
 }
diff --git a/vm/bitwise_hacks.hpp b/vm/bitwise_hacks.hpp
new file mode 100644 (file)
index 0000000..6cd2a5b
--- /dev/null
@@ -0,0 +1,52 @@
+namespace factor
+{
+
+inline cell log2(cell x)
+{
+       cell n;
+#if defined(FACTOR_X86) || defined(FACTOR_AMD64)
+       asm ("bsr %1, %0;":"=r"(n):"r"(x));
+#elif defined(FACTOR_PPC)
+       asm ("cntlzw %1, %0;":"=r"(n):"r"(x));
+       n = (31 - n);
+#else
+       #error Unsupported CPU
+#endif
+       return n;
+}
+
+inline cell rightmost_clear_bit(cell x)
+{
+       return log2(~x & (x + 1));
+}
+
+inline cell rightmost_set_bit(cell x)
+{
+       return log2(x & -x);
+}
+
+inline cell popcount(cell x)
+{
+#ifdef FACTOR_64
+       u64 k1 = 0x5555555555555555ll;
+       u64 k2 = 0x3333333333333333ll;
+       u64 k4 = 0x0f0f0f0f0f0f0f0fll;
+       u64 kf = 0x0101010101010101ll;
+       cell ks = 56;
+#else
+       u32 k1 = 0x55555555;
+       u32 k2 = 0x33333333;
+       u32 k4 = 0xf0f0f0f;
+       u32 kf = 0x1010101;
+       cell ks = 24;
+#endif
+
+       x =  x       - ((x >> 1)  & k1); // put count of each 2 bits into those 2 bits
+       x = (x & k2) + ((x >> 2)  & k2); // put count of each 4 bits into those 4 bits
+       x = (x       +  (x >> 4)) & k4 ; // put count of each 8 bits into those 8 bits
+       x = (x * kf) >> ks; // returns 8 most significant bits of x + (x<<8) + (x<<16) + (x<<24) + ...
+
+       return x;
+}
+
+}
diff --git a/vm/bump_allocator.hpp b/vm/bump_allocator.hpp
new file mode 100644 (file)
index 0000000..bbe4df8
--- /dev/null
@@ -0,0 +1,54 @@
+namespace factor
+{
+
+template<typename Block> struct bump_allocator {
+       /* offset of 'here' and 'end' is hardcoded in compiler backends */
+       cell here;
+       cell start;
+       cell end;
+       cell size;
+
+       explicit bump_allocator(cell size_, cell start_) :
+               here(start_), start(start_), end(start_ + size_), size(size_) {}
+
+       bool contains_p(Block *block)
+       {
+               return ((cell)block - start) < size;
+       }
+
+       Block *allot(cell size)
+       {
+               cell h = here;
+               here = h + align(size,data_alignment);
+               return (Block *)h;
+       }
+
+       cell occupied_space()
+       {
+               return here - start;
+       }
+
+       cell free_space()
+       {
+               return end - here;
+       }
+
+       cell next_object_after(cell scan)
+       {
+               cell size = ((Block *)scan)->size();
+               if(scan + size < here)
+                       return scan + size;
+               else
+                       return 0;
+       }
+
+       cell first_object()
+       {
+               if(start != here)
+                       return start;
+               else
+                       return 0;
+       }
+};
+
+}
index 56b5db7ad84c7ba20e363d40f96a86d8417bb348..7cfe6c2ff0d6dbea3e393cfb02a2bdb8c7a4f4c7 100644 (file)
@@ -5,7 +5,7 @@ namespace factor
 
 byte_array *factor_vm::allot_byte_array(cell size)
 {
-       byte_array *array = allot_array_internal<byte_array>(size);
+       byte_array *array = allot_uninitialized_array<byte_array>(size);
        memset(array + 1,0,size);
        return array;
 }
@@ -19,14 +19,15 @@ void factor_vm::primitive_byte_array()
 void factor_vm::primitive_uninitialized_byte_array()
 {
        cell size = unbox_array_size();
-       dpush(tag<byte_array>(allot_array_internal<byte_array>(size)));
+       dpush(tag<byte_array>(allot_uninitialized_array<byte_array>(size)));
 }
 
 void factor_vm::primitive_resize_byte_array()
 {
-       byte_array *array = untag_check<byte_array>(dpop());
+       data_root<byte_array> array(dpop(),this);
+       array.untag_check(this);
        cell capacity = unbox_array_size();
-       dpush(tag<byte_array>(reallot_array(array,capacity)));
+       dpush(tag<byte_array>(reallot_array(array.untagged(),capacity)));
 }
 
 void growable_byte_array::append_bytes(void *elts, cell len)
@@ -43,7 +44,7 @@ void growable_byte_array::append_bytes(void *elts, cell len)
 
 void growable_byte_array::append_byte_array(cell byte_array_)
 {
-       gc_root<byte_array> byte_array(byte_array_,elements.parent);
+       data_root<byte_array> byte_array(byte_array_,elements.parent);
 
        cell len = array_capacity(byte_array.untagged());
        cell new_size = count + len;
index 8ca95d9d1e2e218400d22ac0580d1fb8dc8157c9..a96baff6ec33d64a2b796c3be4e880d4d5745f1c 100755 (executable)
@@ -3,7 +3,7 @@ namespace factor
 
 struct growable_byte_array {
        cell count;
-       gc_root<byte_array> elements;
+       data_root<byte_array> elements;
 
        explicit growable_byte_array(factor_vm *parent,cell capacity = 40) : count(0), elements(parent->allot_byte_array(capacity),parent) { }
 
@@ -13,4 +13,11 @@ struct growable_byte_array {
        void trim();
 };
 
+template<typename Type> byte_array *factor_vm::byte_array_from_value(Type *value)
+{
+       byte_array *data = allot_uninitialized_array<byte_array>(sizeof(Type));
+       memcpy(data->data<char>(),value,sizeof(Type));
+       return data;
+}
+
 }
index dca0eb6c24486730faea06cd3a1b57a138c32935..4fe19c0bc0c481fb23e47cdc08ae2751113036ba 100644 (file)
@@ -21,7 +21,7 @@ void factor_vm::init_callbacks(cell size)
 
 void callback_heap::update(callback *stub)
 {
-       tagged<array> code_template(parent->userenv[CALLBACK_STUB]);
+       tagged<array> code_template(parent->special_objects[CALLBACK_STUB]);
 
        cell rel_class = untag_fixnum(array_nth(code_template.untagged(),1));
        cell offset = untag_fixnum(array_nth(code_template.untagged(),3));
@@ -35,18 +35,18 @@ void callback_heap::update(callback *stub)
 
 callback *callback_heap::add(code_block *compiled)
 {
-       tagged<array> code_template(parent->userenv[CALLBACK_STUB]);
+       tagged<array> code_template(parent->special_objects[CALLBACK_STUB]);
        tagged<byte_array> insns(array_nth(code_template.untagged(),0));
        cell size = array_capacity(insns.untagged());
 
-       cell bump = align8(size) + sizeof(callback);
+       cell bump = align(size,sizeof(cell)) + sizeof(callback);
        if(here + bump > seg->end) fatal_error("Out of callback space",0);
 
        callback *stub = (callback *)here;
        stub->compiled = compiled;
        memcpy(stub + 1,insns->data<void>(),size);
 
-       stub->size = align8(size);
+       stub->size = align(size,sizeof(cell));
        here += bump;
 
        update(stub);
index 4721fc4ece60b0e1c620b653ceca0bc1dc1b061e..85f392af0e6cafbed634bf3c6f3169a86ac5dbe3 100755 (executable)
@@ -76,7 +76,7 @@ code_block *factor_vm::frame_code(stack_frame *frame)
        return (code_block *)frame->xt - 1;
 }
 
-cell factor_vm::frame_type(stack_frame *frame)
+code_block_type factor_vm::frame_type(stack_frame *frame)
 {
        return frame_code(frame)->type();
 }
@@ -97,7 +97,7 @@ cell factor_vm::frame_scan(stack_frame *frame)
 {
        switch(frame_type(frame))
        {
-       case QUOTATION_TYPE:
+       case code_block_unoptimized:
                {
                        cell quot = frame_executing(frame);
                        if(to_boolean(quot))
@@ -111,7 +111,7 @@ cell factor_vm::frame_scan(stack_frame *frame)
                        else
                                return false_object;
                }
-       case WORD_TYPE:
+       case code_block_optimized:
                return false_object;
        default:
                critical_error("Bad frame type",frame_type(frame));
@@ -130,8 +130,8 @@ struct stack_frame_accumulator {
 
        void operator()(stack_frame *frame)
        {
-               gc_root<object> executing(parent->frame_executing(frame),parent);
-               gc_root<object> scan(parent->frame_scan(frame),parent);
+               data_root<object> executing(parent->frame_executing(frame),parent);
+               data_root<object> scan(parent->frame_scan(frame),parent);
 
                frames.add(executing.value());
                frames.add(scan.value());
@@ -142,7 +142,7 @@ struct stack_frame_accumulator {
 
 void factor_vm::primitive_callstack_to_array()
 {
-       gc_root<callstack> callstack(dpop(),this);
+       data_root<callstack> callstack(dpop(),this);
 
        stack_frame_accumulator accum(this);
        iterate_callstack_object(callstack.untagged(),accum);
@@ -184,8 +184,8 @@ void factor_vm::primitive_innermost_stack_frame_scan()
 
 void factor_vm::primitive_set_innermost_stack_frame_quot()
 {
-       gc_root<callstack> callstack(dpop(),this);
-       gc_root<quotation> quot(dpop(),this);
+       data_root<callstack> callstack(dpop(),this);
+       data_root<quotation> quot(dpop(),this);
 
        callstack.untag_check(this);
        quot.untag_check(this);
index 4d449042816e03f9e2b3609c5232677a7a46f76c..76bf3ecea49754997eeb99789691575abdc077f1 100755 (executable)
@@ -12,7 +12,7 @@ VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom, factor_vm *
 keep the callstack in a GC root and use relative offsets */
 template<typename Iterator> void factor_vm::iterate_callstack_object(callstack *stack_, Iterator &iterator)
 {
-       gc_root<callstack> stack(stack_,this);
+       data_root<callstack> stack(stack_,this);
        fixnum frame_offset = untag_fixnum(stack->length) - sizeof(stack_frame);
 
        while(frame_offset >= 0)
index 1f77148b5c1121c76477fe2e251e5f4d023e4b9a..dc6a488e26e1533e0ed064c3690684cc097ae52b 100755 (executable)
@@ -127,9 +127,8 @@ void *factor_vm::get_rel_symbol(array *literals, cell index)
                }
        case ARRAY_TYPE:
                {
-                       cell i;
                        array *names = untag<array>(symbol);
-                       for(i = 0; i < array_capacity(names); i++)
+                       for(cell i = 0; i < array_capacity(names); i++)
                        {
                                symbol_char *name = alien_offset(array_nth(names,i));
                                void *sym = ffi_dlsym(d,name);
@@ -179,7 +178,7 @@ cell factor_vm::compute_relocation(relocation_entry rel, cell index, code_block
        case RT_UNTAGGED:
                return untag_fixnum(ARG);
        case RT_MEGAMORPHIC_CACHE_HITS:
-               return (cell)&megamorphic_cache_hits;
+               return (cell)&dispatch_stats.megamorphic_cache_hits;
        case RT_VM:
                return (cell)this + untag_fixnum(ARG);
        case RT_CARDS_OFFSET:
@@ -286,7 +285,7 @@ struct literal_references_updater {
                if(parent->relocation_type_of(rel) == RT_IMMEDIATE)
                {
                        cell offset = parent->relocation_offset_of(rel) + (cell)(compiled + 1);
-                       array *literals = parent->untag<array>(compiled->literals);
+                       array *literals = untag<array>(compiled->literals);
                        fixnum absolute_value = array_nth(literals,index);
                        parent->store_address_in_code_block(parent->relocation_class_of(rel),offset,absolute_value);
                }
@@ -346,7 +345,7 @@ void factor_vm::update_word_references(code_block *compiled)
           are referenced after this is done. So instead of polluting
           the code heap with dead PICs that will be freed on the next
           GC, we add them to the free list immediately. */
-       else if(compiled->type() == PIC_TYPE)
+       else if(compiled->pic_p())
                code->code_heap_free(compiled);
        else
        {
@@ -379,7 +378,7 @@ struct literal_and_word_references_updater {
        }
 };
 
-void factor_vm::update_code_block_for_full_gc(code_block *compiled)
+void factor_vm::update_code_block_words_and_literals(code_block *compiled)
 {
        if(code->needs_fixup_p(compiled))
                relocate_code_block(compiled);
@@ -437,9 +436,9 @@ void factor_vm::fixup_labels(array *labels, code_block *compiled)
 }
 
 /* Might GC */
-code_block *factor_vm::allot_code_block(cell size, cell type)
+code_block *factor_vm::allot_code_block(cell size, code_block_type type)
 {
-       heap_block *block = code->heap_allot(size + sizeof(code_block),type);
+       code_block *block = code->allocator->allot(size + sizeof(code_block));
 
        /* If allocation failed, do a full GC and compact the code heap.
        A full GC that occurs as a result of the data heap filling up does not
@@ -449,35 +448,31 @@ code_block *factor_vm::allot_code_block(cell size, cell type)
        if(block == NULL)
        {
                primitive_compact_gc();
-               block = code->heap_allot(size + sizeof(code_block),type);
+               block = code->allocator->allot(size + sizeof(code_block));
 
                /* Insufficient room even after code GC, give up */
                if(block == NULL)
                {
-                       cell used, total_free, max_free;
-                       code->heap_usage(&used,&total_free,&max_free);
-
-                       print_string("Code heap stats:\n");
-                       print_string("Used: "); print_cell(used); nl();
-                       print_string("Total free space: "); print_cell(total_free); nl();
-                       print_string("Largest free block: "); print_cell(max_free); nl();
+                       std::cout << "Code heap used: " << code->allocator->occupied_space() << "\n";
+                       std::cout << "Code heap free: " << code->allocator->free_space() << "\n";
                        fatal_error("Out of memory in add-compiled-block",0);
                }
        }
 
-       return (code_block *)block;
+       block->set_type(type);
+       return block;
 }
 
 /* Might GC */
-code_block *factor_vm::add_code_block(cell type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_)
+code_block *factor_vm::add_code_block(code_block_type type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_)
 {
-       gc_root<byte_array> code(code_,this);
-       gc_root<object> labels(labels_,this);
-       gc_root<object> owner(owner_,this);
-       gc_root<byte_array> relocation(relocation_,this);
-       gc_root<array> literals(literals_,this);
+       data_root<byte_array> code(code_,this);
+       data_root<object> labels(labels_,this);
+       data_root<object> owner(owner_,this);
+       data_root<byte_array> relocation(relocation_,this);
+       data_root<array> literals(literals_,this);
 
-       cell code_length = align8(array_capacity(code.untagged()));
+       cell code_length = array_capacity(code.untagged());
        code_block *compiled = allot_code_block(code_length,type);
 
        compiled->owner = owner.value();
diff --git a/vm/code_block_visitor.hpp b/vm/code_block_visitor.hpp
new file mode 100644 (file)
index 0000000..09410d4
--- /dev/null
@@ -0,0 +1,89 @@
+namespace factor
+{
+
+template<typename Visitor> struct call_frame_code_block_visitor {
+       factor_vm *parent;
+       Visitor visitor;
+
+       explicit call_frame_code_block_visitor(factor_vm *parent_, Visitor visitor_) :
+               parent(parent_), visitor(visitor_) {}
+
+       void operator()(stack_frame *frame)
+       {
+               cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->xt;
+
+               code_block *new_block = visitor(parent->frame_code(frame));
+               frame->xt = new_block->xt();
+
+               FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->xt + offset);
+       }
+};
+
+template<typename Visitor> struct callback_code_block_visitor {
+       callback_heap *callbacks;
+       Visitor visitor;
+
+       explicit callback_code_block_visitor(callback_heap *callbacks_, Visitor visitor_) :
+               callbacks(callbacks_), visitor(visitor_) {}
+
+       void operator()(callback *stub)
+       {
+               stub->compiled = visitor(stub->compiled);
+               callbacks->update(stub);
+       }
+};
+
+template<typename Visitor> struct code_block_visitor {
+       factor_vm *parent;
+       Visitor visitor;
+
+       explicit code_block_visitor(factor_vm *parent_, Visitor visitor_) :
+               parent(parent_), visitor(visitor_) {}
+
+       void visit_object_code_block(object *obj)
+       {
+               switch(obj->type())
+               {
+               case WORD_TYPE:
+                       {
+                               word *w = (word *)obj;
+                               if(w->code)
+                                       w->code = visitor(w->code);
+                               if(w->profiling)
+                                       w->profiling = visitor(w->profiling);
+       
+                               parent->update_word_xt(w);
+                               break;
+                       }
+               case QUOTATION_TYPE:
+                       {
+                               quotation *q = (quotation *)obj;
+                               if(q->code)
+                                       parent->set_quot_xt(q,visitor(q->code));
+                               break;
+                       }
+               case CALLSTACK_TYPE:
+                       {
+                               callstack *stack = (callstack *)obj;
+                               call_frame_code_block_visitor<Visitor> call_frame_visitor(parent,visitor);
+                               parent->iterate_callstack_object(stack,call_frame_visitor);
+                               break;
+                       }
+               }
+       }
+
+       void visit_context_code_blocks()
+       {
+               call_frame_code_block_visitor<Visitor> call_frame_visitor(parent,visitor);
+               parent->iterate_active_frames(call_frame_visitor);
+       }
+
+       void visit_callback_code_blocks()
+       {
+               callback_code_block_visitor<Visitor> callback_visitor(parent->callbacks,visitor);
+               parent->callbacks->iterate(callback_visitor);
+       }
+
+};
+
+}
index 288c2221f22ff41f40fe541cbf5daa99878b4b5a..98da158b165cbe0cb011cada864658b8d37e78c5 100755 (executable)
@@ -3,7 +3,21 @@
 namespace factor
 {
 
-code_heap::code_heap(bool secure_gc, cell size) : heap(secure_gc,size,true) {}
+code_heap::code_heap(cell size)
+{
+       if(size > (1L << (sizeof(cell) * 8 - 6))) fatal_error("Heap too large",size);
+       seg = new segment(align_page(size),true);
+       if(!seg) fatal_error("Out of memory in heap allocator",size);
+       allocator = new free_list_allocator<code_block>(size,seg->start);
+}
+
+code_heap::~code_heap()
+{
+       delete allocator;
+       allocator = NULL;
+       delete seg;
+       seg = NULL;
+}
 
 void code_heap::write_barrier(code_block *compiled)
 {
@@ -22,18 +36,33 @@ bool code_heap::needs_fixup_p(code_block *compiled)
        return needs_fixup.count(compiled) > 0;
 }
 
+bool code_heap::marked_p(code_block *compiled)
+{
+       return allocator->state.marked_p(compiled);
+}
+
+void code_heap::set_marked_p(code_block *compiled)
+{
+       allocator->state.set_marked_p(compiled);
+}
+
+void code_heap::clear_mark_bits()
+{
+       allocator->state.clear_mark_bits();
+}
+
 void code_heap::code_heap_free(code_block *compiled)
 {
        points_to_nursery.erase(compiled);
        points_to_aging.erase(compiled);
        needs_fixup.erase(compiled);
-       heap_free(compiled);
+       allocator->free(compiled);
 }
 
 /* Allocate a code heap during startup */
 void factor_vm::init_code_heap(cell size)
 {
-       code = new code_heap(secure_gc,size);
+       code = new code_heap(size);
 }
 
 bool factor_vm::in_code_heap_p(cell ptr)
@@ -44,8 +73,8 @@ bool factor_vm::in_code_heap_p(cell ptr)
 /* Compile a word definition with the non-optimizing compiler. Allocates memory */
 void factor_vm::jit_compile_word(cell word_, cell def_, bool relocate)
 {
-       gc_root<word> word(word_,this);
-       gc_root<quotation> def(def_,this);
+       data_root<word> word(word_,this);
+       data_root<quotation> def(def_,this);
 
        jit_compile(def.value(),relocate);
 
@@ -59,7 +88,8 @@ struct word_updater {
        factor_vm *parent;
 
        explicit word_updater(factor_vm *parent_) : parent(parent_) {}
-       void operator()(code_block *compiled)
+
+       void operator()(code_block *compiled, cell size)
        {
                parent->update_word_references(compiled);
        }
@@ -73,22 +103,53 @@ void factor_vm::update_code_heap_words()
        iterate_code_heap(updater);
 }
 
+/* After a full GC that did not grow the heap, we have to update references
+to literals and other words. */
+struct word_and_literal_code_heap_updater {
+       factor_vm *parent;
+
+       explicit word_and_literal_code_heap_updater(factor_vm *parent_) : parent(parent_) {}
+
+       void operator()(code_block *block, cell size)
+       {
+               parent->update_code_block_words_and_literals(block);
+       }
+};
+
+void factor_vm::update_code_heap_words_and_literals()
+{
+       word_and_literal_code_heap_updater updater(this);
+       iterate_code_heap(updater);
+}
+
+/* After growing the heap, we have to perform a full relocation to update
+references to card and deck arrays. */
+struct code_heap_relocator {
+       factor_vm *parent;
+
+       explicit code_heap_relocator(factor_vm *parent_) : parent(parent_) {}
+
+       void operator()(code_block *block, cell size)
+       {
+               parent->relocate_code_block(block);
+       }
+};
+
 void factor_vm::primitive_modify_code_heap()
 {
-       gc_root<array> alist(dpop(),this);
+       data_root<array> alist(dpop(),this);
 
        cell count = array_capacity(alist.untagged());
 
        if(count == 0)
                return;
 
-       cell i;
-       for(i = 0; i < count; i++)
+       for(cell i = 0; i < count; i++)
        {
-               gc_root<array> pair(array_nth(alist.untagged(),i),this);
+               data_root<array> pair(array_nth(alist.untagged(),i),this);
 
-               gc_root<word> word(array_nth(pair.untagged(),0),this);
-               gc_root<object> data(array_nth(pair.untagged(),1),this);
+               data_root<word> word(array_nth(pair.untagged(),0),this);
+               data_root<object> data(array_nth(pair.untagged(),1),this);
 
                switch(data.type())
                {
@@ -105,7 +166,7 @@ void factor_vm::primitive_modify_code_heap()
                                cell code = array_nth(compiled_data,4);
 
                                code_block *compiled = add_code_block(
-                                       WORD_TYPE,
+                                       code_block_optimized,
                                        code,
                                        labels,
                                        owner,
@@ -120,136 +181,35 @@ void factor_vm::primitive_modify_code_heap()
                        break;
                }
 
-               update_word_xt(word.value());
+               update_word_xt(word.untagged());
        }
 
        update_code_heap_words();
 }
 
-/* Push the free space and total size of the code heap */
-void factor_vm::primitive_code_room()
-{
-       cell used, total_free, max_free;
-       code->heap_usage(&used,&total_free,&max_free);
-       dpush(tag_fixnum(code->seg->size / 1024));
-       dpush(tag_fixnum(used / 1024));
-       dpush(tag_fixnum(total_free / 1024));
-       dpush(tag_fixnum(max_free / 1024));
-}
-
-code_block *code_heap::forward_code_block(code_block *compiled)
-{
-       return (code_block *)forwarding[compiled];
-}
-
-struct callframe_forwarder {
-       factor_vm *parent;
-
-       explicit callframe_forwarder(factor_vm *parent_) : parent(parent_) {}
-
-       void operator()(stack_frame *frame)
-       {
-               cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->xt;
-
-               code_block *forwarded = parent->code->forward_code_block(parent->frame_code(frame));
-               frame->xt = forwarded->xt();
-
-               FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->xt + offset);
-       }
-};
-
-void factor_vm::forward_object_xts()
-{
-       begin_scan();
-
-       cell obj;
-
-       while(to_boolean(obj = next_object()))
-       {
-               switch(tagged<object>(obj).type())
-               {
-               case WORD_TYPE:
-                       {
-                               word *w = untag<word>(obj);
-
-                               if(w->code)
-                                       w->code = code->forward_code_block(w->code);
-                               if(w->profiling)
-                                       w->profiling = code->forward_code_block(w->profiling);
-
-                               update_word_xt(obj);
-                       }
-                       break;
-               case QUOTATION_TYPE:
-                       {
-                               quotation *quot = untag<quotation>(obj);
-
-                               if(quot->code)
-                               {
-                                       quot->code = code->forward_code_block(quot->code);
-                                       set_quot_xt(quot,quot->code);
-                               }
-                       }
-                       break;
-               case CALLSTACK_TYPE:
-                       {
-                               callstack *stack = untag<callstack>(obj);
-                               callframe_forwarder forwarder(this);
-                               iterate_callstack_object(stack,forwarder);
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       end_scan();
-}
-
-void factor_vm::forward_context_xts()
+code_heap_room factor_vm::code_room()
 {
-       callframe_forwarder forwarder(this);
-       iterate_active_frames(forwarder);
-}
-
-struct callback_forwarder {
-       code_heap *code;
-       callback_heap *callbacks;
-
-       callback_forwarder(code_heap *code_, callback_heap *callbacks_) :
-               code(code_), callbacks(callbacks_) {}
+       code_heap_room room;
 
-       void operator()(callback *stub)
-       {
-               stub->compiled = code->forward_code_block(stub->compiled);
-               callbacks->update(stub);
-       }
-};
+       room.size             = code->allocator->size;
+       room.occupied_space   = code->allocator->occupied_space();
+       room.total_free       = code->allocator->free_space();
+       room.contiguous_free  = code->allocator->largest_free_block();
+       room.free_block_count = code->allocator->free_block_count();
 
-void factor_vm::forward_callback_xts()
-{
-       callback_forwarder forwarder(code,callbacks);
-       callbacks->iterate(forwarder);
+       return room;
 }
 
-/* Move all free space to the end of the code heap. Live blocks must be marked
-on entry to this function. XTs in code blocks must be updated after this
-function returns. */
-void factor_vm::compact_code_heap(bool trace_contexts_p)
+void factor_vm::primitive_code_room()
 {
-       code->compact_heap();
-       forward_object_xts();
-       if(trace_contexts_p)
-       {
-               forward_context_xts();
-               forward_callback_xts();
-       }
+       code_heap_room room = code_room();
+       dpush(tag<byte_array>(byte_array_from_value(&room)));
 }
 
 struct stack_trace_stripper {
        explicit stack_trace_stripper() {}
 
-       void operator()(code_block *compiled)
+       void operator()(code_block *compiled, cell size)
        {
                compiled->owner = false_object;
        }
index 0a96a0b27b17521fb676a6160bab2a415728a934..8f4790d2f9e0bd6d5e3b1e1a5f64c48392c72438 100755 (executable)
@@ -1,7 +1,13 @@
 namespace factor
 {
 
-struct code_heap : heap {
+struct code_heap {
+       /* The actual memory area */
+       segment *seg;
+
+       /* Memory allocator */
+       free_list_allocator<code_block> *allocator;
+
        /* Set of blocks which need full relocation. */
        std::set<code_block *> needs_fixup;
 
@@ -11,12 +17,23 @@ struct code_heap : heap {
        /* Code blocks which may reference objects in aging space or the nursery */
        std::set<code_block *> points_to_aging;
 
-       explicit code_heap(bool secure_gc, cell size);
+       explicit code_heap(cell size);
+       ~code_heap();
        void write_barrier(code_block *compiled);
        void clear_remembered_set();
        bool needs_fixup_p(code_block *compiled);
+       bool marked_p(code_block *compiled);
+       void set_marked_p(code_block *compiled);
+       void clear_mark_bits();
        void code_heap_free(code_block *compiled);
-       code_block *forward_code_block(code_block *compiled);
+};
+
+struct code_heap_room {
+       cell size;
+       cell occupied_space;
+       cell total_free;
+       cell contiguous_free;
+       cell free_block_count;
 };
 
 }
diff --git a/vm/code_roots.hpp b/vm/code_roots.hpp
new file mode 100644 (file)
index 0000000..64f2b0c
--- /dev/null
@@ -0,0 +1,29 @@
+namespace factor
+{
+
+struct code_root {
+       cell value;
+       bool valid;
+       factor_vm *parent;
+
+       void push()
+       {
+               parent->code_roots.push_back(this);
+       }
+
+       explicit code_root(cell value_, factor_vm *parent_) :
+               value(value_), valid(true), parent(parent_)
+       {
+               push();
+       }
+
+       ~code_root()
+       {
+#ifdef FACTOR_DEBUG
+               assert(parent->code_roots.back() == this);
+#endif
+               parent->code_roots.pop_back();
+       }
+};
+
+}
index bbaad1d5702895b122d4a0dbb55e34f1b84a5fcd..db5b33ba23944884ae32faf093cd504876271915 100644 (file)
@@ -1,21 +1,13 @@
 namespace factor
 {
 
-template<typename TargetGeneration, typename Policy> struct collector {
+template<typename TargetGeneration, typename Policy> struct collector_workhorse {
        factor_vm *parent;
-       data_heap *data;
-       code_heap *code;
-       gc_state *current_gc;
-       generation_statistics *stats;
        TargetGeneration *target;
        Policy policy;
 
-       explicit collector(factor_vm *parent_, generation_statistics *stats_, TargetGeneration *target_, Policy policy_) :
+       explicit collector_workhorse(factor_vm *parent_, TargetGeneration *target_, Policy policy_) :
                parent(parent_),
-               data(parent_->data),
-               code(parent_->code),
-               current_gc(parent_->current_gc),
-               stats(stats_),
                target(target_),
                policy(policy_) {}
 
@@ -24,125 +16,239 @@ template<typename TargetGeneration, typename Policy> struct collector {
                parent->check_data_pointer(untagged);
 
                /* is there another forwarding pointer? */
-               while(untagged->h.forwarding_pointer_p())
-                       untagged = untagged->h.forwarding_pointer();
+               while(untagged->forwarding_pointer_p())
+                       untagged = untagged->forwarding_pointer();
 
                /* we've found the destination */
-               untagged->h.check_header();
                return untagged;
        }
 
-       void trace_handle(cell *handle)
+       object *promote_object(object *untagged)
        {
-               cell pointer = *handle;
+               cell size = untagged->size();
+               object *newpointer = target->allot(size);
+               /* XXX not exception-safe */
+               if(!newpointer) longjmp(parent->current_gc->gc_unwind,1);
 
-               if(immediate_p(pointer)) return;
+               memcpy(newpointer,untagged,size);
+               untagged->forward_to(newpointer);
 
-               object *untagged = parent->untag<object>(pointer);
-               if(!policy.should_copy_p(untagged))
-                       return;
+               policy.promoted_object(newpointer);
 
-               object *forwarding = resolve_forwarding(untagged);
+               return newpointer;
+       }
+
+       object *operator()(object *obj)
+       {
+               if(!policy.should_copy_p(obj))
+               {
+                       policy.visited_object(obj);
+                       return obj;
+               }
 
-               if(forwarding == untagged)
-                       untagged = promote_object(untagged);
+               object *forwarding = resolve_forwarding(obj);
+
+               if(forwarding == obj)
+                       return promote_object(obj);
                else if(policy.should_copy_p(forwarding))
-                       untagged = promote_object(forwarding);
+                       return promote_object(forwarding);
                else
-                       untagged = forwarding;
+               {
+                       policy.visited_object(forwarding);
+                       return forwarding;
+               }
+       }
+};
+
+template<typename TargetGeneration, typename Policy>
+inline static slot_visitor<collector_workhorse<TargetGeneration,Policy> > make_collector_workhorse(
+       factor_vm *parent,
+       TargetGeneration *target,
+       Policy policy)
+{
+       return slot_visitor<collector_workhorse<TargetGeneration,Policy> >(parent,
+               collector_workhorse<TargetGeneration,Policy>(parent,target,policy));
+}
+
+struct dummy_unmarker {
+       void operator()(card *ptr) {}
+};
+
+struct simple_unmarker {
+       card unmask;
+       explicit simple_unmarker(card unmask_) : unmask(unmask_) {}
+       void operator()(card *ptr) { *ptr &= ~unmask; }
+};
+
+struct full_unmarker {
+       explicit full_unmarker() {}
+       void operator()(card *ptr) { *ptr = 0; }
+};
+
+template<typename TargetGeneration, typename Policy> struct collector {
+       factor_vm *parent;
+       data_heap *data;
+       code_heap *code;
+       TargetGeneration *target;
+       slot_visitor<collector_workhorse<TargetGeneration,Policy> > workhorse;
+       cell cards_scanned;
+       cell decks_scanned;
+       cell code_blocks_scanned;
+
+       explicit collector(factor_vm *parent_, TargetGeneration *target_, Policy policy_) :
+               parent(parent_),
+               data(parent_->data),
+               code(parent_->code),
+               target(target_),
+               workhorse(make_collector_workhorse(parent_,target_,policy_)),
+               cards_scanned(0),
+               decks_scanned(0),
+               code_blocks_scanned(0) {}
 
-               *handle = RETAG(untagged,TAG(pointer));
+       void trace_handle(cell *handle)
+       {
+               workhorse.visit_handle(handle);
        }
 
-       void trace_slots(object *ptr)
+       void trace_object(object *ptr)
        {
-               cell *slot = (cell *)ptr;
-               cell *end = (cell *)((cell)ptr + parent->binary_payload_start(ptr));
+               workhorse.visit_slots(ptr);
+               if(ptr->type() == ALIEN_TYPE)
+                       ((alien *)ptr)->update_address();
+       }
 
-               if(slot != end)
-               {
-                       slot++;
-                       for(; slot < end; slot++) trace_handle(slot);
-               }
+       void trace_roots()
+       {
+               workhorse.visit_roots();
        }
 
-       object *promote_object(object *untagged)
+       void trace_contexts()
        {
-               cell size = parent->untagged_object_size(untagged);
-               object *newpointer = target->allot(size);
-               /* XXX not exception-safe */
-               if(!newpointer) longjmp(current_gc->gc_unwind,1);
+               workhorse.visit_contexts();
+       }
 
-               memcpy(newpointer,untagged,size);
-               untagged->h.forward_to(newpointer);
+       /* Trace all literals referenced from a code block. Only for aging and nursery collections */
+       void trace_literal_references(code_block *compiled)
+       {
+               workhorse.visit_literal_references(compiled);
+       }
 
-               stats->object_count++;
-               stats->bytes_copied += size;
+       void trace_code_heap_roots(std::set<code_block *> *remembered_set)
+       {
+               std::set<code_block *>::const_iterator iter = remembered_set->begin();
+               std::set<code_block *>::const_iterator end = remembered_set->end();
 
-               return newpointer;
+               for(; iter != end; iter++)
+               {
+                       trace_literal_references(*iter);
+                       code_blocks_scanned++;
+               }
        }
 
-       void trace_stack_elements(segment *region, cell *top)
+       inline cell first_card_in_deck(cell deck)
        {
-               for(cell *ptr = (cell *)region->start; ptr <= top; ptr++)
-                       trace_handle(ptr);
+               return deck << (deck_bits - card_bits);
        }
 
-       void trace_registered_locals()
+       inline cell last_card_in_deck(cell deck)
        {
-               std::vector<cell>::const_iterator iter = parent->gc_locals.begin();
-               std::vector<cell>::const_iterator end = parent->gc_locals.end();
+               return first_card_in_deck(deck + 1);
+       }
 
-               for(; iter < end; iter++)
-                       trace_handle((cell *)(*iter));
+       inline cell card_deck_for_address(cell a)
+       {
+               return addr_to_deck(a - data->start);
        }
 
-       void trace_registered_bignums()
+       inline cell card_start_address(cell card)
        {
-               std::vector<cell>::const_iterator iter = parent->gc_bignums.begin();
-               std::vector<cell>::const_iterator end = parent->gc_bignums.end();
+               return (card << card_bits) + data->start;
+       }
 
-               for(; iter < end; iter++)
+       inline cell card_end_address(cell card)
+       {
+               return ((card + 1) << card_bits) + data->start;
+       }
+
+       void trace_partial_objects(cell start, cell end, cell card_start, cell card_end)
+       {
+               if(card_start < end)
                {
-                       cell *handle = (cell *)(*iter);
+                       start += sizeof(cell);
 
-                       if(*handle)
-                       {
-                               *handle |= BIGNUM_TYPE;
-                               trace_handle(handle);
-                               *handle &= ~BIGNUM_TYPE;
-                       }
+                       if(start < card_start) start = card_start;
+                       if(end > card_end) end = card_end;
+
+                       cell *slot_ptr = (cell *)start;
+                       cell *end_ptr = (cell *)end;
+
+                       for(; slot_ptr < end_ptr; slot_ptr++)
+                               workhorse.visit_handle(slot_ptr);
                }
        }
 
-       /* Copy roots over at the start of GC, namely various constants, stacks,
-       the user environment and extra roots registered by local_roots.hpp */
-       void trace_roots()
+       template<typename SourceGeneration, typename Unmarker>
+       void trace_cards(SourceGeneration *gen, card mask, Unmarker unmarker)
        {
-               trace_handle(&parent->true_object);
-               trace_handle(&parent->bignum_zero);
-               trace_handle(&parent->bignum_pos_one);
-               trace_handle(&parent->bignum_neg_one);
+               card_deck *decks = data->decks;
+               card_deck *cards = data->cards;
 
-               trace_registered_locals();
-               trace_registered_bignums();
+               cell gen_start_card = addr_to_card(gen->start - data->start);
 
-               for(int i = 0; i < USER_ENV; i++) trace_handle(&parent->userenv[i]);
-       }
+               cell first_deck = card_deck_for_address(gen->start);
+               cell last_deck = card_deck_for_address(gen->end);
 
-       void trace_contexts()
-       {
-               context *ctx = parent->ctx;
+               cell start = 0, binary_start = 0, end = 0;
 
-               while(ctx)
+               for(cell deck_index = first_deck; deck_index < last_deck; deck_index++)
                {
-                       trace_stack_elements(ctx->datastack_region,(cell *)ctx->datastack);
-                       trace_stack_elements(ctx->retainstack_region,(cell *)ctx->retainstack);
+                       if(decks[deck_index] & mask)
+                       {
+                               decks_scanned++;
+
+                               cell first_card = first_card_in_deck(deck_index);
+                               cell last_card = last_card_in_deck(deck_index);
 
-                       trace_handle(&ctx->catchstack_save);
-                       trace_handle(&ctx->current_callback_save);
+                               for(cell card_index = first_card; card_index < last_card; card_index++)
+                               {
+                                       if(cards[card_index] & mask)
+                                       {
+                                               cards_scanned++;
 
-                       ctx = ctx->next;
+                                               if(end < card_start_address(card_index))
+                                               {
+                                                       start = gen->starts.find_object_containing_card(card_index - gen_start_card);
+                                                       binary_start = start + ((object *)start)->binary_payload_start();
+                                                       end = start + ((object *)start)->size();
+                                               }
+
+scan_next_object:                              if(start < card_end_address(card_index))
+                                               {
+                                                       trace_partial_objects(
+                                                               start,
+                                                               binary_start,
+                                                               card_start_address(card_index),
+                                                               card_end_address(card_index));
+                                                       if(end < card_end_address(card_index))
+                                                       {
+                                                               start = gen->next_object_after(start);
+                                                               if(start)
+                                                               {
+                                                                       binary_start = start + ((object *)start)->binary_payload_start();
+                                                                       end = start + ((object *)start)->size();
+                                                                       goto scan_next_object;
+                                                               }
+                                                       }
+                                               }
+
+                                               unmarker(&cards[card_index]);
+
+                                               if(!start) return;
+                                       }
+                               }
+
+                               unmarker(&decks[deck_index]);
+                       }
                }
        }
 };
diff --git a/vm/compaction.cpp b/vm/compaction.cpp
new file mode 100644 (file)
index 0000000..0bbc7c8
--- /dev/null
@@ -0,0 +1,191 @@
+#include "master.hpp"
+
+namespace factor {
+
+template<typename Block> struct forwarder {
+       mark_bits<Block> *forwarding_map;
+
+       explicit forwarder(mark_bits<Block> *forwarding_map_) :
+               forwarding_map(forwarding_map_) {}
+
+       Block *operator()(Block *block)
+       {
+               return forwarding_map->forward_block(block);
+       }
+};
+
+static inline cell tuple_size_with_forwarding(mark_bits<object> *forwarding_map, object *obj)
+{
+       /* The tuple layout may or may not have been forwarded already. Tricky. */
+       object *layout_obj = (object *)UNTAG(((tuple *)obj)->layout);
+       tuple_layout *layout;
+
+       if(layout_obj < obj)
+       {
+               /* It's already been moved up; dereference through forwarding
+               map to get the size */
+               layout = (tuple_layout *)forwarding_map->forward_block(layout_obj);
+       }
+       else
+       {
+               /* It hasn't been moved up yet; dereference directly */
+               layout = (tuple_layout *)layout_obj;
+       }
+
+       return tuple_size(layout);
+}
+
+struct compaction_sizer {
+       mark_bits<object> *forwarding_map;
+
+       explicit compaction_sizer(mark_bits<object> *forwarding_map_) :
+               forwarding_map(forwarding_map_) {}
+
+       cell operator()(object *obj)
+       {
+               if(!forwarding_map->marked_p(obj))
+                       return forwarding_map->unmarked_block_size(obj);
+               else if(obj->type() == TUPLE_TYPE)
+                       return align(tuple_size_with_forwarding(forwarding_map,obj),data_alignment);
+               else
+                       return obj->size();
+       }
+};
+
+struct object_compaction_updater {
+       factor_vm *parent;
+       slot_visitor<forwarder<object> > slot_forwarder;
+       code_block_visitor<forwarder<code_block> > code_forwarder;
+       mark_bits<object> *data_forwarding_map;
+       object_start_map *starts;
+
+       explicit object_compaction_updater(factor_vm *parent_,
+               slot_visitor<forwarder<object> > slot_forwarder_,
+               code_block_visitor<forwarder<code_block> > code_forwarder_,
+               mark_bits<object> *data_forwarding_map_) :
+               parent(parent_),
+               slot_forwarder(slot_forwarder_),
+               code_forwarder(code_forwarder_),
+               data_forwarding_map(data_forwarding_map_),
+               starts(&parent->data->tenured->starts) {}
+
+       void operator()(object *old_address, object *new_address, cell size)
+       {
+               cell payload_start;
+               if(old_address->type() == TUPLE_TYPE)
+                       payload_start = tuple_size_with_forwarding(data_forwarding_map,old_address);
+               else
+                       payload_start = old_address->binary_payload_start();
+
+               memmove(new_address,old_address,size);
+
+               slot_forwarder.visit_slots(new_address,payload_start);
+               code_forwarder.visit_object_code_block(new_address);
+               starts->record_object_start_offset(new_address);
+       }
+};
+
+template<typename SlotForwarder> struct code_block_compaction_updater {
+       factor_vm *parent;
+       SlotForwarder slot_forwarder;
+
+       explicit code_block_compaction_updater(factor_vm *parent_, SlotForwarder slot_forwarder_) :
+               parent(parent_), slot_forwarder(slot_forwarder_) {}
+
+       void operator()(code_block *old_address, code_block *new_address, cell size)
+       {
+               memmove(new_address,old_address,size);
+               slot_forwarder.visit_literal_references(new_address);
+               parent->relocate_code_block(new_address);
+       }
+};
+
+/* Compact data and code heaps */
+void factor_vm::collect_compact_impl(bool trace_contexts_p)
+{
+       current_gc->event->started_compaction();
+
+       tenured_space *tenured = data->tenured;
+       mark_bits<object> *data_forwarding_map = &tenured->state;
+       mark_bits<code_block> *code_forwarding_map = &code->allocator->state;
+
+       /* Figure out where blocks are going to go */
+       data_forwarding_map->compute_forwarding();
+       code_forwarding_map->compute_forwarding();
+
+       slot_visitor<forwarder<object> > slot_forwarder(this,forwarder<object>(data_forwarding_map));
+       code_block_visitor<forwarder<code_block> > code_forwarder(this,forwarder<code_block>(code_forwarding_map));
+
+       /* Object start offsets get recomputed by the object_compaction_updater */
+       data->tenured->starts.clear_object_start_offsets();
+
+       /* Slide everything in tenured space up, and update data and code heap
+       pointers inside objects. */
+       object_compaction_updater object_updater(this,slot_forwarder,code_forwarder,data_forwarding_map);
+       compaction_sizer object_sizer(data_forwarding_map);
+       tenured->compact(object_updater,object_sizer);
+
+       /* Slide everything in the code heap up, and update data and code heap
+       pointers inside code blocks. */
+       code_block_compaction_updater<slot_visitor<forwarder<object> > > code_block_updater(this,slot_forwarder);
+       standard_sizer<code_block> code_block_sizer;
+       code->allocator->compact(code_block_updater,code_block_sizer);
+
+       slot_forwarder.visit_roots();
+       if(trace_contexts_p)
+       {
+               slot_forwarder.visit_contexts();
+               code_forwarder.visit_context_code_blocks();
+               code_forwarder.visit_callback_code_blocks();
+       }
+
+       update_code_roots_for_compaction();
+
+       current_gc->event->ended_compaction();
+}
+
+struct object_code_block_updater {
+       code_block_visitor<forwarder<code_block> > *visitor;
+
+       explicit object_code_block_updater(code_block_visitor<forwarder<code_block> > *visitor_) :
+               visitor(visitor_) {}
+
+       void operator()(object *obj)
+       {
+               visitor->visit_object_code_block(obj);
+       }
+};
+
+struct dummy_slot_forwarder {
+       void visit_literal_references(code_block *compiled) {}
+};
+
+/* Compact just the code heap */
+void factor_vm::collect_compact_code_impl(bool trace_contexts_p)
+{
+       /* Figure out where blocks are going to go */
+       mark_bits<code_block> *code_forwarding_map = &code->allocator->state;
+       code_forwarding_map->compute_forwarding();
+       code_block_visitor<forwarder<code_block> > code_forwarder(this,forwarder<code_block>(code_forwarding_map));
+
+       if(trace_contexts_p)
+       {
+               code_forwarder.visit_context_code_blocks();
+               code_forwarder.visit_callback_code_blocks();
+       }
+
+       /* Update code heap references in data heap */
+       object_code_block_updater updater(&code_forwarder);
+       each_object(updater);
+
+       /* Slide everything in the code heap up, and update code heap
+       pointers inside code blocks. */
+       dummy_slot_forwarder slot_forwarder;
+       code_block_compaction_updater<dummy_slot_forwarder> code_block_updater(this,slot_forwarder);
+       standard_sizer<code_block> code_block_sizer;
+       code->allocator->compact(code_block_updater,code_block_sizer);
+
+       update_code_roots_for_compaction();
+}
+
+}
diff --git a/vm/compaction.hpp b/vm/compaction.hpp
new file mode 100644 (file)
index 0000000..412ef35
--- /dev/null
@@ -0,0 +1,4 @@
+namespace factor
+{
+
+}
index cc7029e7f1012996aac7b30242ef544dcef58357..f5fac1119ef54630a96d66a3f8c6bcad8bced9a4 100644 (file)
@@ -3,6 +3,20 @@
 namespace factor
 {
 
+context::context(cell ds_size, cell rs_size) :
+       callstack_top(NULL),
+       callstack_bottom(NULL),
+       datastack(0),
+       retainstack(0),
+       datastack_save(0),
+       retainstack_save(0),
+       magic_frame(NULL),
+       datastack_region(new segment(ds_size,false)),
+       retainstack_region(new segment(rs_size,false)),
+       catchstack_save(0),
+       current_callback_save(0),
+       next(NULL) {}
+
 void factor_vm::reset_datastack()
 {
        ds = ds_bot - sizeof(cell);
@@ -42,11 +56,7 @@ context *factor_vm::alloc_context()
                unused_contexts = unused_contexts->next;
        }
        else
-       {
-               new_context = new context;
-               new_context->datastack_region = new segment(ds_size,false);
-               new_context->retainstack_region = new segment(rs_size,false);
-       }
+               new_context = new context(ds_size,rs_size);
 
        return new_context;
 }
@@ -80,9 +90,9 @@ void factor_vm::nest_stacks(stack_frame *magic_frame)
 
        new_ctx->magic_frame = magic_frame;
 
-       /* save per-callback userenv */
-       new_ctx->current_callback_save = userenv[CURRENT_CALLBACK_ENV];
-       new_ctx->catchstack_save = userenv[CATCHSTACK_ENV];
+       /* save per-callback special_objects */
+       new_ctx->current_callback_save = special_objects[OBJ_CURRENT_CALLBACK];
+       new_ctx->catchstack_save = special_objects[OBJ_CATCHSTACK];
 
        new_ctx->next = ctx;
        ctx = new_ctx;
@@ -102,9 +112,9 @@ void factor_vm::unnest_stacks()
        ds = ctx->datastack_save;
        rs = ctx->retainstack_save;
 
-       /* restore per-callback userenv */
-       userenv[CURRENT_CALLBACK_ENV] = ctx->current_callback_save;
-       userenv[CATCHSTACK_ENV] = ctx->catchstack_save;
+       /* restore per-callback special_objects */
+       special_objects[OBJ_CURRENT_CALLBACK] = ctx->current_callback_save;
+       special_objects[OBJ_CATCHSTACK] = ctx->catchstack_save;
 
        context *old_ctx = ctx;
        ctx = old_ctx->next;
@@ -133,7 +143,7 @@ bool factor_vm::stack_to_array(cell bottom, cell top)
                return false;
        else
        {
-               array *a = allot_array_internal<array>(depth / sizeof(cell));
+               array *a = allot_uninitialized_array<array>(depth / sizeof(cell));
                memcpy(a + 1,(void*)bottom,depth);
                dpush(tag<array>(a));
                return true;
@@ -196,4 +206,12 @@ void factor_vm::primitive_check_datastack()
        }
 }
 
+void factor_vm::primitive_load_locals()
+{
+       fixnum count = untag_fixnum(dpop());
+       memcpy((cell *)(rs + sizeof(cell)),(cell *)(ds - sizeof(cell) * (count - 1)),sizeof(cell) * count);
+       ds -= sizeof(cell) * count;
+       rs += sizeof(cell) * count;
+}
+
 }
index f66b5d0fe2e0c4474867daea68b2d5dbd59f26c6..ddbae5de78baefbaa212c1d862e09f95ce66ffc7 100644 (file)
@@ -41,11 +41,13 @@ struct context {
        /* memory region holding current retain stack */
        segment *retainstack_region;
 
-       /* saved userenv slots on entry to callback */
+       /* saved special_objects slots on entry to callback */
        cell catchstack_save;
        cell current_callback_save;
 
        context *next;
+
+       context(cell ds_size, cell rs_size);
 };
 
 #define ds_bot (ctx->datastack_region->start)
index 640d355bf4a6779864cef38605e726673e7fc84e..89501a3a4ad2338d7b0f938328e8f1ecff4ecbcb 100644 (file)
 namespace factor
 {
 
-struct dummy_unmarker {
-       void operator()(card *ptr) {}
-};
-
-struct simple_unmarker {
-       card unmask;
-       simple_unmarker(card unmask_) : unmask(unmask_) {}
-       void operator()(card *ptr) { *ptr &= ~unmask; }
-};
-
 template<typename TargetGeneration, typename Policy>
 struct copying_collector : collector<TargetGeneration,Policy> {
        cell scan;
 
-       explicit copying_collector(factor_vm *parent_, generation_statistics *stats_, TargetGeneration *target_, Policy policy_) :
-               collector<TargetGeneration,Policy>(parent_,stats_,target_,policy_), scan(target_->here) {}
-
-       inline cell first_card_in_deck(cell deck)
-       {
-               return deck << (deck_bits - card_bits);
-       }
-
-       inline cell last_card_in_deck(cell deck)
-       {
-               return first_card_in_deck(deck + 1);
-       }
-
-       inline cell card_deck_for_address(cell a)
-       {
-               return addr_to_deck(a - this->data->start);
-       }
-
-       inline cell card_start_address(cell card)
-       {
-               return (card << card_bits) + this->data->start;
-       }
-
-       inline cell card_end_address(cell card)
-       {
-               return ((card + 1) << card_bits) + this->data->start;
-       }
-
-       void trace_partial_objects(cell start, cell end, cell card_start, cell card_end)
-       {
-               if(card_start < end)
-               {
-                       start += sizeof(cell);
-
-                       if(start < card_start) start = card_start;
-                       if(end > card_end) end = card_end;
-
-                       cell *slot_ptr = (cell *)start;
-                       cell *end_ptr = (cell *)end;
-
-                       if(slot_ptr != end_ptr)
-                       {
-                               for(; slot_ptr < end_ptr; slot_ptr++)
-                                       this->trace_handle(slot_ptr);
-                       }
-               }
-       }
-
-       template<typename SourceGeneration, typename Unmarker>
-       void trace_cards(SourceGeneration *gen, card mask, Unmarker unmarker)
-       {
-               u64 start_time = current_micros();
-       
-               card_deck *decks = this->data->decks;
-               card_deck *cards = this->data->cards;
-       
-               cell gen_start_card = addr_to_card(gen->start - this->data->start);
-
-               cell first_deck = card_deck_for_address(gen->start);
-               cell last_deck = card_deck_for_address(gen->end);
-       
-               cell start = 0, binary_start = 0, end = 0;
-       
-               for(cell deck_index = first_deck; deck_index < last_deck; deck_index++)
-               {
-                       if(decks[deck_index] & mask)
-                       {
-                               this->parent->gc_stats.decks_scanned++;
-
-                               cell first_card = first_card_in_deck(deck_index);
-                               cell last_card = last_card_in_deck(deck_index);
-       
-                               for(cell card_index = first_card; card_index < last_card; card_index++)
-                               {
-                                       if(cards[card_index] & mask)
-                                       {
-                                               this->parent->gc_stats.cards_scanned++;
-
-                                               if(end < card_start_address(card_index))
-                                               {
-                                                       start = gen->find_object_containing_card(card_index - gen_start_card);
-                                                       binary_start = start + this->parent->binary_payload_start((object *)start);
-                                                       end = start + this->parent->untagged_object_size((object *)start);
-                                               }
-       
-#ifdef FACTOR_DEBUG
-                                               assert(addr_to_card(start - this->data->start) <= card_index);
-                                               assert(start < card_end_address(card_index));
-#endif
-
-scan_next_object:                              {
-                                                       trace_partial_objects(
-                                                               start,
-                                                               binary_start,
-                                                               card_start_address(card_index),
-                                                               card_end_address(card_index));
-                                                       if(end < card_end_address(card_index))
-                                                       {
-                                                               start = gen->next_object_after(this->parent,start);
-                                                               if(start)
-                                                               {
-                                                                       binary_start = start + this->parent->binary_payload_start((object *)start);
-                                                                       end = start + this->parent->untagged_object_size((object *)start);
-                                                                       goto scan_next_object;
-                                                               }
-                                                       }
-                                               }
-       
-                                               unmarker(&cards[card_index]);
-       
-                                               if(!start) goto end;
-                                       }
-                               }
-       
-                               unmarker(&decks[deck_index]);
-                       }
-               }
-
-end:           this->parent->gc_stats.card_scan_time += (current_micros() - start_time);
-       }
-
-       /* Trace all literals referenced from a code block. Only for aging and nursery collections */
-       void trace_literal_references(code_block *compiled)
-       {
-               this->trace_handle(&compiled->owner);
-               this->trace_handle(&compiled->literals);
-               this->trace_handle(&compiled->relocation);
-               this->parent->gc_stats.code_blocks_scanned++;
-       }
-
-       void trace_code_heap_roots(std::set<code_block *> *remembered_set)
-       {
-               std::set<code_block *>::const_iterator iter = remembered_set->begin();
-               std::set<code_block *>::const_iterator end = remembered_set->end();
-
-               for(; iter != end; iter++) trace_literal_references(*iter);
-       }
+       explicit copying_collector(factor_vm *parent_, TargetGeneration *target_, Policy policy_) :
+               collector<TargetGeneration,Policy>(parent_,target_,policy_), scan(target_->here) {}
 
        void cheneys_algorithm()
        {
                while(scan && scan < this->target->here)
                {
-                       this->trace_slots((object *)scan);
-                       scan = this->target->next_object_after(this->parent,scan);
+                       this->trace_object((object *)scan);
+                       scan = this->target->next_object_after(scan);
                }
        }
 };
index 61b05a1735747880f3871f967012dd45dca8868e..40f2521e501241882460b16a5200abdf4fdc2d64 100644 (file)
@@ -37,13 +37,13 @@ DEF(void,primitive_fixnum_multiply,(void *vm)):
        lwz r3,0(DS_REG)
        lwz r4,-4(DS_REG)
        subi DS_REG,DS_REG,4
-       srawi r3,r3,3
+       srawi r3,r3,4
        mullwo. r6,r3,r4
        bso multiply_overflow
        stw r6,0(DS_REG)
        blr
 multiply_overflow:
-       srawi r4,r4,3
+       srawi r4,r4,4
        b MANGLE(overflow_fixnum_multiply)
        
 /* Note that the XT is passed to the quotation in r11 */
index 2e85be0f8129efcba9f77dea5cb92e658faeeca9..c0532f0ece1cae33aa6b1786f47c799f721b86a9 100644 (file)
 
 #define PUSH_NONVOLATILE \
        push %ebx ; \
-       push %ebp ; \
        push %ebp
 
 #define POP_NONVOLATILE \
-       pop %ebp ; \
        pop %ebp ; \
        pop %ebx
 
index 5e307f0500cbbcee51c79b1dba366fb06931e5f8..8ccd703bfeb015e87ee4ad291f12336ce620abb1 100644 (file)
                push %rdi ; \
                push %rsi ; \
                push %rbx ; \
-               push %rbp ; \
                push %rbp
 
        #define POP_NONVOLATILE \
-               pop %rbp ; \
                pop %rbp ; \
                pop %rbx ; \
                pop %rsi ; \
                push %rbx ; \
                push %rbp ; \
                push %r12 ; \
-               push %r13 ; \
                push %r13
 
        #define POP_NONVOLATILE \
-               pop %r13 ; \
                pop %r13 ; \
                pop %r12 ; \
                pop %rbp ; \
index c497a0aad24a9cf869643791ea25fcd513499e98..411a0cdaa69bed2ff50a56483e5f90fc4a3f1228 100644 (file)
@@ -25,7 +25,7 @@ DEF(void,primitive_fixnum_multiply,(void *myvm)):
        mov (DS_REG),ARITH_TEMP_1
        mov ARITH_TEMP_1,DIV_RESULT
        mov -CELL_SIZE(DS_REG),ARITH_TEMP_2
-       sar $3,ARITH_TEMP_2
+       sar $4,ARITH_TEMP_2
        sub $CELL_SIZE,DS_REG
        imul ARITH_TEMP_2
        jo multiply_overflow
@@ -33,7 +33,7 @@ DEF(void,primitive_fixnum_multiply,(void *myvm)):
        pop ARG2
        ret
 multiply_overflow:
-       sar $3,ARITH_TEMP_1
+       sar $4,ARITH_TEMP_1
        mov ARITH_TEMP_1,ARG0
        mov ARITH_TEMP_2,ARG1
        pop ARG2
@@ -43,14 +43,20 @@ DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)):
        PUSH_NONVOLATILE
        mov ARG0,NV0
        mov ARG1,NV1
-       
+
+    /* Save old stack pointer and align */
+    mov STACK_REG,ARG0
+    and $-16,STACK_REG
+    add $CELL_SIZE,STACK_REG
+    push ARG0
+
        /* Create register shadow area for Win64 */
        sub $32,STACK_REG
-       
+
        /* Save stack pointer */
        lea -CELL_SIZE(STACK_REG),ARG0
        call MANGLE(save_callstack_bottom)
-       
+
        /* Call quot-xt */
        mov NV0,ARG0
        mov NV1,ARG1
@@ -59,6 +65,9 @@ DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)):
        /* Tear down register shadow area */
        add $32,STACK_REG
 
+    /* Undo stack alignment */
+    mov (STACK_REG),STACK_REG
+
        POP_NONVOLATILE
        ret
 
index 335938acab6a47c1de25c63911381ac4fa8490ec..43fbd930f1b5fb6caac4894091da0f738d97d156 100755 (executable)
@@ -9,7 +9,9 @@ void factor_vm::init_card_decks()
        decks_offset = (cell)data->decks - addr_to_deck(data->start);
 }
 
-data_heap::data_heap(cell young_size_, cell aging_size_, cell tenured_size_)
+data_heap::data_heap(cell young_size_,
+       cell aging_size_,
+       cell tenured_size_)
 {
        young_size_ = align(young_size_,deck_size);
        aging_size_ = align(aging_size_,deck_size);
@@ -19,30 +21,27 @@ data_heap::data_heap(cell young_size_, cell aging_size_, cell tenured_size_)
        aging_size = aging_size_;
        tenured_size = tenured_size_;
 
-       cell total_size = young_size + 2 * aging_size + 2 * tenured_size;
-
-       total_size += deck_size;
-
+       cell total_size = young_size + 2 * aging_size + tenured_size + deck_size;
        seg = new segment(total_size,false);
 
        cell cards_size = addr_to_card(total_size);
-
        cards = new card[cards_size];
        cards_end = cards + cards_size;
+       memset(cards,0,cards_size);
 
        cell decks_size = addr_to_deck(total_size);
        decks = new card_deck[decks_size];
        decks_end = decks + decks_size;
+       memset(decks,0,decks_size);
 
        start = align(seg->start,deck_size);
 
        tenured = new tenured_space(tenured_size,start);
-       tenured_semispace = new tenured_space(tenured_size,tenured->end);
 
-       aging = new aging_space(aging_size,tenured_semispace->end);
+       aging = new aging_space(aging_size,tenured->end);
        aging_semispace = new aging_space(aging_size,aging->end);
 
-       nursery = new zone(young_size,aging_semispace->end);
+       nursery = new nursery_space(young_size,aging_semispace->end);
 
        assert(seg->end - nursery->end <= deck_size);
 }
@@ -54,7 +53,6 @@ data_heap::~data_heap()
        delete aging;
        delete aging_semispace;
        delete tenured;
-       delete tenured_semispace;
        delete[] cards;
        delete[] decks;
 }
@@ -62,112 +60,113 @@ data_heap::~data_heap()
 data_heap *data_heap::grow(cell requested_bytes)
 {
        cell new_tenured_size = (tenured_size * 2) + requested_bytes;
-       return new data_heap(young_size,aging_size,new_tenured_size);
+       return new data_heap(young_size,
+               aging_size,
+               new_tenured_size);
 }
 
-void factor_vm::clear_cards(old_space *gen)
+template<typename Generation> void data_heap::clear_cards(Generation *gen)
 {
-       cell first_card = addr_to_card(gen->start - data->start);
-       cell last_card = addr_to_card(gen->end - data->start);
-       memset(&data->cards[first_card],0,last_card - first_card);
+       cell first_card = addr_to_card(gen->start - start);
+       cell last_card = addr_to_card(gen->end - start);
+       memset(&cards[first_card],0,last_card - first_card);
 }
 
-void factor_vm::clear_decks(old_space *gen)
+template<typename Generation> void data_heap::clear_decks(Generation *gen)
 {
-       cell first_deck = addr_to_deck(gen->start - data->start);
-       cell last_deck = addr_to_deck(gen->end - data->start);
-       memset(&data->decks[first_deck],0,last_deck - first_deck);
+       cell first_deck = addr_to_deck(gen->start - start);
+       cell last_deck = addr_to_deck(gen->end - start);
+       memset(&decks[first_deck],0,last_deck - first_deck);
 }
 
-/* After garbage collection, any generations which are now empty need to have
-their allocation pointers and cards reset. */
-void factor_vm::reset_generation(old_space *gen)
+void data_heap::reset_generation(nursery_space *gen)
 {
        gen->here = gen->start;
-       if(secure_gc) memset((void*)gen->start,69,gen->size);
+}
 
+void data_heap::reset_generation(aging_space *gen)
+{
+       gen->here = gen->start;
        clear_cards(gen);
        clear_decks(gen);
-       gen->clear_object_start_offsets();
+       gen->starts.clear_object_start_offsets();
+}
+
+void data_heap::reset_generation(tenured_space *gen)
+{
+       clear_cards(gen);
+       clear_decks(gen);
+}
+
+bool data_heap::low_memory_p()
+{
+       return (tenured->free_space() <= nursery->size + aging->size);
+}
+
+void data_heap::mark_all_cards()
+{
+       memset(cards,-1,cards_end - cards);
+       memset(decks,-1,decks_end - decks);
 }
 
 void factor_vm::set_data_heap(data_heap *data_)
 {
        data = data_;
        nursery = *data->nursery;
-       nursery.here = nursery.start;
        init_card_decks();
-       reset_generation(data->aging);
-       reset_generation(data->tenured);
 }
 
-void factor_vm::init_data_heap(cell young_size, cell aging_size, cell tenured_size, bool secure_gc_)
+void factor_vm::init_data_heap(cell young_size, cell aging_size, cell tenured_size)
 {
        set_data_heap(new data_heap(young_size,aging_size,tenured_size));
-       secure_gc = secure_gc_;
-}
-
-/* Size of the object pointed to by a tagged pointer */
-cell factor_vm::object_size(cell tagged)
-{
-       if(immediate_p(tagged))
-               return 0;
-       else
-               return untagged_object_size(untag<object>(tagged));
 }
 
 /* Size of the object pointed to by an untagged pointer */
-cell factor_vm::untagged_object_size(object *pointer)
+cell object::size() const
 {
-       return align8(unaligned_object_size(pointer));
-}
+       if(free_p()) return ((free_heap_block *)this)->size();
 
-/* Size of the data area of an object pointed to by an untagged pointer */
-cell factor_vm::unaligned_object_size(object *pointer)
-{
-       switch(pointer->h.hi_tag())
+       switch(type())
        {
        case ARRAY_TYPE:
-               return array_size((array*)pointer);
+               return align(array_size((array*)this),data_alignment);
        case BIGNUM_TYPE:
-               return array_size((bignum*)pointer);
+               return align(array_size((bignum*)this),data_alignment);
        case BYTE_ARRAY_TYPE:
-               return array_size((byte_array*)pointer);
+               return align(array_size((byte_array*)this),data_alignment);
        case STRING_TYPE:
-               return string_size(string_capacity((string*)pointer));
+               return align(string_size(string_capacity((string*)this)),data_alignment);
        case TUPLE_TYPE:
-               return tuple_size(untag<tuple_layout>(((tuple *)pointer)->layout));
+               {
+                       tuple_layout *layout = (tuple_layout *)UNTAG(((tuple *)this)->layout);
+                       return align(tuple_size(layout),data_alignment);
+               }
        case QUOTATION_TYPE:
-               return sizeof(quotation);
+               return align(sizeof(quotation),data_alignment);
        case WORD_TYPE:
-               return sizeof(word);
+               return align(sizeof(word),data_alignment);
        case FLOAT_TYPE:
-               return sizeof(boxed_float);
+               return align(sizeof(boxed_float),data_alignment);
        case DLL_TYPE:
-               return sizeof(dll);
+               return align(sizeof(dll),data_alignment);
        case ALIEN_TYPE:
-               return sizeof(alien);
+               return align(sizeof(alien),data_alignment);
        case WRAPPER_TYPE:
-               return sizeof(wrapper);
+               return align(sizeof(wrapper),data_alignment);
        case CALLSTACK_TYPE:
-               return callstack_size(untag_fixnum(((callstack *)pointer)->length));
+               return align(callstack_size(untag_fixnum(((callstack *)this)->length)),data_alignment);
        default:
-               critical_error("Invalid header",(cell)pointer);
+               critical_error("Invalid header",(cell)this);
                return 0; /* can't happen */
        }
 }
 
-void factor_vm::primitive_size()
-{
-       box_unsigned_cell(object_size(dpop()));
-}
-
 /* The number of cells from the start of the object which should be scanned by
 the GC. Some types have a binary payload at the end (string, word, DLL) which
 we ignore. */
-cell factor_vm::binary_payload_start(object *pointer)
+cell object::binary_payload_start() const
 {
-       switch(pointer->h.hi_tag())
+       switch(type())
        {
        /* these objects do not refer to other objects at all */
        case FLOAT_TYPE:
@@ -188,109 +187,83 @@ cell factor_vm::binary_payload_start(object *pointer)
                return sizeof(string);
        /* everything else consists entirely of pointers */
        case ARRAY_TYPE:
-               return array_size<array>(array_capacity((array*)pointer));
+               return array_size<array>(array_capacity((array*)this));
        case TUPLE_TYPE:
-               return tuple_size(untag<tuple_layout>(((tuple *)pointer)->layout));
+               return tuple_size(untag<tuple_layout>(((tuple *)this)->layout));
        case WRAPPER_TYPE:
                return sizeof(wrapper);
        default:
-               critical_error("Invalid header",(cell)pointer);
+               critical_error("Invalid header",(cell)this);
                 return 0; /* can't happen */
        }
 }
 
-/* Push memory usage statistics in data heap */
-void factor_vm::primitive_data_room()
+data_heap_room factor_vm::data_room()
 {
-       dpush(tag_fixnum((data->cards_end - data->cards) >> 10));
-       dpush(tag_fixnum((data->decks_end - data->decks) >> 10));
-
-       growable_array a(this);
-
-       a.add(tag_fixnum((nursery.end - nursery.here) >> 10));
-       a.add(tag_fixnum((nursery.size) >> 10));
-
-       a.add(tag_fixnum((data->aging->end - data->aging->here) >> 10));
-       a.add(tag_fixnum((data->aging->size) >> 10));
-
-       a.add(tag_fixnum((data->tenured->end - data->tenured->here) >> 10));
-       a.add(tag_fixnum((data->tenured->size) >> 10));
-
-       a.trim();
-       dpush(a.elements.value());
+       data_heap_room room;
+
+       room.nursery_size             = nursery.size;
+       room.nursery_occupied         = nursery.occupied_space();
+       room.nursery_free             = nursery.free_space();
+       room.aging_size               = data->aging->size;
+       room.aging_occupied           = data->aging->occupied_space();
+       room.aging_free               = data->aging->free_space();
+       room.tenured_size             = data->tenured->size;
+       room.tenured_occupied         = data->tenured->occupied_space();
+       room.tenured_total_free       = data->tenured->free_space();
+       room.tenured_contiguous_free  = data->tenured->largest_free_block();
+       room.tenured_free_block_count = data->tenured->free_block_count();
+       room.cards                    = data->cards_end - data->cards;
+       room.decks                    = data->decks_end - data->decks;
+       room.mark_stack               = data->tenured->mark_stack.capacity() * sizeof(cell);
+
+       return room;
 }
 
-/* Disables GC and activates next-object ( -- obj ) primitive */
-void factor_vm::begin_scan()
+void factor_vm::primitive_data_room()
 {
-       heap_scan_ptr = data->tenured->start;
-       gc_off = true;
+       data_heap_room room = data_room();
+       dpush(tag<byte_array>(byte_array_from_value(&room)));
 }
 
-void factor_vm::end_scan()
-{
-       gc_off = false;
-}
+struct object_accumulator {
+       cell type;
+       std::vector<cell> objects;
 
-void factor_vm::primitive_begin_scan()
-{
-       begin_scan();
-}
+       explicit object_accumulator(cell type_) : type(type_) {}
+
+       void operator()(object *obj)
+       {
+               if(type == TYPE_COUNT || obj->type() == type)
+                       objects.push_back(tag_dynamic(obj));
+       }
+};
 
-cell factor_vm::next_object()
+cell factor_vm::instances(cell type)
 {
-       if(!gc_off)
-               general_error(ERROR_HEAP_SCAN,false_object,false_object,NULL);
+       object_accumulator accum(type);
+       each_object(accum);
+       cell object_count = accum.objects.size();
 
-       if(heap_scan_ptr >= data->tenured->here)
-               return false_object;
+       data_roots.push_back(data_root_range(&accum.objects[0],object_count));
 
-       object *obj = (object *)heap_scan_ptr;
-       heap_scan_ptr += untagged_object_size(obj);
-       return tag_dynamic(obj);
-}
+       array *objects = allot_array(object_count,false_object);
+       memcpy(objects->data(),&accum.objects[0],object_count * sizeof(cell));
 
-/* Push object at heap scan cursor and advance; pushes f when done */
-void factor_vm::primitive_next_object()
-{
-       dpush(next_object());
-}
+       data_roots.pop_back();
 
-/* Re-enables GC */
-void factor_vm::primitive_end_scan()
-{
-       gc_off = false;
+       return tag<array>(objects);
 }
 
-template<typename Iterator> void factor_vm::each_object(Iterator &iterator)
+void factor_vm::primitive_all_instances()
 {
-       begin_scan();
-       cell obj;
-       while(to_boolean(obj = next_object()))
-               iterator(tagged<object>(obj));
-       end_scan();
+       primitive_full_gc();
+       dpush(instances(TYPE_COUNT));
 }
 
-struct word_counter {
-       cell count;
-       explicit word_counter() : count(0) {}
-       void operator()(tagged<object> obj) { if(obj.type_p(WORD_TYPE)) count++; }
-};
-
-struct word_accumulator {
-       growable_array words;
-       explicit word_accumulator(int count,factor_vm *vm) : words(vm,count) {}
-       void operator()(tagged<object> obj) { if(obj.type_p(WORD_TYPE)) words.add(obj.value()); }
-};
-
 cell factor_vm::find_all_words()
 {
-       word_counter counter;
-       each_object(counter);
-       word_accumulator accum(counter.count,this);
-       each_object(accum);
-       accum.words.trim();
-       return accum.words.elements.value();
+       return instances(WORD_TYPE);
 }
 
 }
index 10f3698e746fb9c94eaa35b7b60e4bdf7fb2fbee..ce156696b8a3d0109f5057b5ad63ea5e32009550 100755 (executable)
@@ -10,11 +10,10 @@ struct data_heap {
 
        segment *seg;
 
-       zone *nursery;
+       nursery_space *nursery;
        aging_space *aging;
        aging_space *aging_semispace;
        tenured_space *tenured;
-       tenured_space *tenured_semispace;
 
        card *cards;
        card *cards_end;
@@ -25,6 +24,30 @@ struct data_heap {
        explicit data_heap(cell young_size, cell aging_size, cell tenured_size);
        ~data_heap();
        data_heap *grow(cell requested_size);
+       template<typename Generation> void clear_cards(Generation *gen);
+       template<typename Generation> void clear_decks(Generation *gen);
+       void reset_generation(nursery_space *gen);
+       void reset_generation(aging_space *gen);
+       void reset_generation(tenured_space *gen);
+       bool low_memory_p();
+       void mark_all_cards();
+};
+
+struct data_heap_room {
+       cell nursery_size;
+       cell nursery_occupied;
+       cell nursery_free;
+       cell aging_size;
+       cell aging_occupied;
+       cell aging_free;
+       cell tenured_size;
+       cell tenured_occupied;
+       cell tenured_total_free;
+       cell tenured_contiguous_free;
+       cell tenured_free_block_count;
+       cell cards;
+       cell decks;
+       cell mark_stack;
 };
 
 }
diff --git a/vm/data_heap_checker.cpp b/vm/data_heap_checker.cpp
new file mode 100644 (file)
index 0000000..fb05508
--- /dev/null
@@ -0,0 +1,101 @@
+#include "master.hpp"
+
+/* A tool to debug write barriers. Call check_data_heap() to ensure that all
+cards that should be marked are actually marked. */
+
+namespace factor
+{
+
+enum generation {
+       nursery_generation,
+       aging_generation,
+       tenured_generation
+};
+
+inline generation generation_of(factor_vm *parent, object *obj)
+{
+       if(parent->data->nursery->contains_p(obj))
+               return nursery_generation;
+       else if(parent->data->aging->contains_p(obj))
+               return aging_generation;
+       else if(parent->data->tenured->contains_p(obj))
+               return tenured_generation;
+       else
+       {
+               critical_error("Bad object",(cell)obj);
+               return (generation)-1;
+       }
+}
+
+struct slot_checker {
+       factor_vm *parent;
+       object *obj;
+       generation gen;
+
+       explicit slot_checker(factor_vm *parent_, object *obj_, generation gen_) :
+               parent(parent_), obj(obj_), gen(gen_) {}
+
+       void check_write_barrier(cell *slot_ptr, generation target, char mask)
+       {
+               cell object_card_pointer = parent->cards_offset + ((cell)obj >> card_bits);
+               cell slot_card_pointer = parent->cards_offset + ((cell)slot_ptr >> card_bits);
+               char slot_card_value = *(char *)slot_card_pointer;
+               if((slot_card_value & mask) != mask)
+               {
+                       printf("card not marked\n");
+                       printf("source generation: %d\n",gen);
+                       printf("target generation: %d\n",target);
+                       printf("object: 0x%lx\n",(cell)obj);
+                       printf("object type: %ld\n",obj->type());
+                       printf("slot pointer: 0x%lx\n",(cell)slot_ptr);
+                       printf("slot value: 0x%lx\n",*slot_ptr);
+                       printf("card of object: 0x%lx\n",object_card_pointer);
+                       printf("card of slot: 0x%lx\n",slot_card_pointer);
+                       printf("\n");
+                       parent->factorbug();
+               }
+       }
+
+       void operator()(cell *slot_ptr)
+       {
+               if(!immediate_p(*slot_ptr))
+               {
+                       generation target = generation_of(parent,untag<object>(*slot_ptr));
+                       switch(gen)
+                       {
+                       case nursery_generation:
+                               break;
+                       case aging_generation:
+                               if(target == nursery_generation)
+                                       check_write_barrier(slot_ptr,target,card_points_to_nursery);
+                               break;
+                       case tenured_generation:
+                               if(target == nursery_generation)
+                                       check_write_barrier(slot_ptr,target,card_points_to_nursery);
+                               else if(target == aging_generation)
+                                       check_write_barrier(slot_ptr,target,card_points_to_aging);
+                               break;
+                       }
+               }
+       }
+};
+
+struct object_checker {
+       factor_vm *parent;
+
+       explicit object_checker(factor_vm *parent_) : parent(parent_) {}
+
+       void operator()(object *obj)
+       {
+               slot_checker checker(parent,obj,generation_of(parent,obj));
+               obj->each_slot(checker);
+       }
+};
+
+void factor_vm::check_data_heap()
+{
+       object_checker checker(this);
+       each_object(checker);
+}
+
+}
diff --git a/vm/data_roots.hpp b/vm/data_roots.hpp
new file mode 100644 (file)
index 0000000..8e366a7
--- /dev/null
@@ -0,0 +1,56 @@
+namespace factor
+{
+
+template<typename Type>
+struct data_root : public tagged<Type> {
+       factor_vm *parent;
+
+       void push()
+       {
+               parent->data_roots.push_back(data_root_range(&this->value_,1));
+       }
+
+       explicit data_root(cell value_, factor_vm *parent_)
+               : tagged<Type>(value_), parent(parent_)
+       {
+               push();
+       }
+
+       explicit data_root(Type *value_, factor_vm *parent_) :
+               tagged<Type>(value_), parent(parent_)
+       {
+               push();
+       }
+
+       const data_root<Type>& operator=(const Type *x) { tagged<Type>::operator=(x); return *this; }
+       const data_root<Type>& operator=(const cell &x) { tagged<Type>::operator=(x); return *this; }
+
+       ~data_root()
+       {
+               parent->data_roots.pop_back();
+       }
+};
+
+/* A similar hack for the bignum implementation */
+struct gc_bignum {
+       bignum **addr;
+       factor_vm *parent;
+
+       gc_bignum(bignum **addr_, factor_vm *parent_) : addr(addr_), parent(parent_)
+       {
+               if(*addr_) parent->check_data_pointer(*addr_);
+               parent->bignum_roots.push_back((cell)addr);
+       }
+
+       ~gc_bignum()
+       {
+#ifdef FACTOR_DEBUG
+               assert(parent->bignum_roots.back() == (cell)addr);
+#endif
+               parent->bignum_roots.pop_back();
+       }
+};
+
+#define GC_BIGNUM(x) gc_bignum x##__data_root(&x,this)
+
+}
index 4b47e2422130b4dd404717450b5c0aaa870f2cf0..aa16b39a81ca1e17f7e8b98410d0f8d774eb3d8c 100755 (executable)
@@ -3,36 +3,31 @@
 namespace factor
 {
 
-void factor_vm::print_chars(string* str)
+std::ostream &operator<<(std::ostream &out, const string *str)
 {
-       cell i;
-       for(i = 0; i < string_capacity(str); i++)
-               putchar(string_nth(str,i));
+       for(cell i = 0; i < string_capacity(str); i++)
+               out << (char)str->nth(i);
+       return out;
 }
 
 void factor_vm::print_word(word* word, cell nesting)
 {
        if(tagged<object>(word->vocabulary).type_p(STRING_TYPE))
-       {
-               print_chars(untag<string>(word->vocabulary));
-               print_string(":");
-       }
+               std::cout << untag<string>(word->vocabulary) << ":";
 
        if(tagged<object>(word->name).type_p(STRING_TYPE))
-               print_chars(untag<string>(word->name));
+               std::cout << untag<string>(word->name);
        else
        {
-               print_string("#<not a string: ");
+               std::cout << "#<not a string: ";
                print_nested_obj(word->name,nesting);
-               print_string(">");
+               std::cout << ">";
        }
 }
 
-void factor_vm::print_factor_string(stringstr)
+void factor_vm::print_factor_string(string *str)
 {
-       putchar('"');
-       print_chars(str);
-       putchar('"');
+       std::cout << '"' << str << '"';
 }
 
 void factor_vm::print_array(array* array, cell nesting)
@@ -51,12 +46,12 @@ void factor_vm::print_array(array* array, cell nesting)
 
        for(i = 0; i < length; i++)
        {
-               print_string(" ");
+               std::cout << " ";
                print_nested_obj(array_nth(array,i),nesting);
        }
 
        if(trimmed)
-               print_string("...");
+               std::cout << "...";
 }
 
 void factor_vm::print_tuple(tuple *tuple, cell nesting)
@@ -64,12 +59,10 @@ void factor_vm::print_tuple(tuple *tuple, cell nesting)
        tuple_layout *layout = untag<tuple_layout>(tuple->layout);
        cell length = to_fixnum(layout->size);
 
-       print_string(" ");
+       std::cout << " ";
        print_nested_obj(layout->klass,nesting);
 
-       cell i;
        bool trimmed;
-
        if(length > 10 && !full_output)
        {
                trimmed = true;
@@ -78,21 +71,21 @@ void factor_vm::print_tuple(tuple *tuple, cell nesting)
        else
                trimmed = false;
 
-       for(i = 0; i < length; i++)
+       for(cell i = 0; i < length; i++)
        {
-               print_string(" ");
+               std::cout << " ";
                print_nested_obj(tuple->data()[i],nesting);
        }
 
        if(trimmed)
-               print_string("...");
+               std::cout << "...";
 }
 
 void factor_vm::print_nested_obj(cell obj, fixnum nesting)
 {
        if(nesting <= 0 && !full_output)
        {
-               print_string(" ... ");
+               std::cout << " ... ";
                return;
        }
 
@@ -101,7 +94,7 @@ void factor_vm::print_nested_obj(cell obj, fixnum nesting)
        switch(tagged<object>(obj).type())
        {
        case FIXNUM_TYPE:
-               print_fixnum(untag_fixnum(obj));
+               std::cout << untag_fixnum(obj);
                break;
        case WORD_TYPE:
                print_word(untag<word>(obj),nesting - 1);
@@ -110,30 +103,27 @@ void factor_vm::print_nested_obj(cell obj, fixnum nesting)
                print_factor_string(untag<string>(obj));
                break;
        case F_TYPE:
-               print_string("f");
+               std::cout << "f";
                break;
        case TUPLE_TYPE:
-               print_string("T{");
+               std::cout << "T{";
                print_tuple(untag<tuple>(obj),nesting - 1);
-               print_string(" }");
+               std::cout << " }";
                break;
        case ARRAY_TYPE:
-               print_string("{");
+               std::cout << "{";
                print_array(untag<array>(obj),nesting - 1);
-               print_string(" }");
+               std::cout << " }";
                break;
        case QUOTATION_TYPE:
-               print_string("[");
+               std::cout << "[";
                quot = untag<quotation>(obj);
                print_array(untag<array>(quot->array),nesting - 1);
-               print_string(" ]");
+               std::cout << " ]";
                break;
        default:
-               print_string("#<type ");
-               print_cell(tagged<object>(obj).type());
-               print_string(" @ ");
-               print_cell_hex(obj);
-               print_string(">");
+               std::cout << "#<type " << tagged<object>(obj).type() << " @ ";
+               std::cout << std::hex << obj << std::dec << ">";
                break;
        }
 }
@@ -148,19 +138,19 @@ void factor_vm::print_objects(cell *start, cell *end)
        for(; start <= end; start++)
        {
                print_obj(*start);
-               nl();
+               std::cout << std::endl;
        }
 }
 
 void factor_vm::print_datastack()
 {
-       print_string("==== DATA STACK:\n");
+       std::cout << "==== DATA STACK:\n";
        print_objects((cell *)ds_bot,(cell *)ds);
 }
 
 void factor_vm::print_retainstack()
 {
-       print_string("==== RETAIN STACK:\n");
+       std::cout << "==== RETAIN STACK:\n";
        print_objects((cell *)rs_bot,(cell *)rs);
 }
 
@@ -171,34 +161,48 @@ struct stack_frame_printer {
        void operator()(stack_frame *frame)
        {
                parent->print_obj(parent->frame_executing(frame));
-               print_string("\n");
+               std::cout << std::endl;
                parent->print_obj(parent->frame_scan(frame));
-               print_string("\n");
-               print_string("word/quot addr: ");
-               print_cell_hex((cell)parent->frame_executing(frame));
-               print_string("\n");
-               print_string("word/quot xt: ");
-               print_cell_hex((cell)frame->xt);
-               print_string("\n");
-               print_string("return address: ");
-               print_cell_hex((cell)FRAME_RETURN_ADDRESS(frame,parent));
-               print_string("\n");
+               std::cout << std::endl;
+               std::cout << "word/quot addr: ";
+               std::cout << std::hex << (cell)parent->frame_executing(frame) << std::dec;
+               std::cout << std::endl;
+               std::cout << "word/quot xt: ";
+               std::cout << std::hex << (cell)frame->xt << std::dec;
+               std::cout << std::endl;
+               std::cout << "return address: ";
+               std::cout << std::hex << (cell)FRAME_RETURN_ADDRESS(frame,parent) << std::dec;
+               std::cout << std::endl;
        }
 };
 
 void factor_vm::print_callstack()
 {
-       print_string("==== CALL STACK:\n");
+       std::cout << "==== CALL STACK:\n";
        stack_frame_printer printer(this);
        iterate_callstack(ctx,printer);
 }
 
+struct padded_address {
+       cell value;
+
+       explicit padded_address(cell value_) : value(value_) {}
+};
+
+std::ostream &operator<<(std::ostream &out, const padded_address &value)
+{
+       char prev = out.fill('0');
+       out.width(sizeof(cell) * 2);
+       out << std::hex << value.value << std::dec;
+       out.fill(prev);
+       return out;
+}
+
 void factor_vm::dump_cell(cell x)
 {
-       print_cell_hex_pad(x); print_string(": ");
+       std::cout << padded_address(x) << ": ";
        x = *(cell *)x;
-       print_cell_hex_pad(x); print_string(" tag "); print_cell(TAG(x));
-       nl();
+       std::cout << padded_address(x) << " tag " << TAG(x) << std::endl;
 }
 
 void factor_vm::dump_memory(cell from, cell to)
@@ -209,147 +213,161 @@ void factor_vm::dump_memory(cell from, cell to)
                dump_cell(from);
 }
 
-void factor_vm::dump_zone(const char *name, zone *z)
+template<typename Generation>
+void factor_vm::dump_generation(const char *name, Generation *gen)
 {
-       print_string(name); print_string(": ");
-       print_string("Start="); print_cell(z->start);
-       print_string(", size="); print_cell(z->size);
-       print_string(", here="); print_cell(z->here - z->start); nl();
+       std::cout << name << ": ";
+       std::cout << "Start=" << gen->start;
+       std::cout << ", size=" << gen->size;
+       std::cout << ", end=" << gen->end;
+       std::cout << std::endl;
 }
 
 void factor_vm::dump_generations()
 {
-       dump_zone("Nursery",&nursery);
-       dump_zone("Aging",data->aging);
-       dump_zone("Tenured",data->tenured);
-
-       print_string("Cards: base=");
-       print_cell((cell)data->cards);
-       print_string(", size=");
-       print_cell((cell)(data->cards_end - data->cards));
-       nl();
+       dump_generation("Nursery",&nursery);
+       dump_generation("Aging",data->aging);
+       dump_generation("Tenured",data->tenured);
+
+       std::cout << "Cards:";
+       std::cout << "base=" << (cell)data->cards << ", ";
+       std::cout << "size=" << (cell)(data->cards_end - data->cards) << std::endl;
 }
 
-void factor_vm::dump_objects(cell type)
-{
-       primitive_full_gc();
-       begin_scan();
+struct object_dumper {
+       factor_vm *parent;
+       cell type;
 
-       cell obj;
-       while(to_boolean(obj = next_object()))
+       explicit object_dumper(factor_vm *parent_, cell type_) :
+               parent(parent_), type(type_) {}
+
+       void operator()(object *obj)
        {
-               if(type == TYPE_COUNT || tagged<object>(obj).type_p(type))
+               if(type == TYPE_COUNT || obj->type() == type)
                {
-                       print_cell_hex_pad(obj);
-                       print_string(" ");
-                       print_nested_obj(obj,2);
-                       nl();
+                       std::cout << padded_address((cell)obj) << " ";
+                       parent->print_nested_obj(tag_dynamic(obj),2);
+                       std::cout << std::endl;
                }
        }
+};
 
-       end_scan();
+void factor_vm::dump_objects(cell type)
+{
+       primitive_full_gc();
+       object_dumper dumper(this,type);
+       each_object(dumper);
 }
 
-struct data_references_finder {
-       cell look_for, obj;
+struct data_reference_slot_visitor {
+       cell look_for;
+       object *obj;
        factor_vm *parent;
 
-       explicit data_references_finder(cell look_for_, cell obj_, factor_vm *parent_)
-               look_for(look_for_), obj(obj_), parent(parent_) { }
+       explicit data_reference_slot_visitor(cell look_for_, object *obj_, factor_vm *parent_) :
+               look_for(look_for_), obj(obj_), parent(parent_) { }
 
        void operator()(cell *scan)
        {
                if(look_for == *scan)
                {
-                       print_cell_hex_pad(obj);
-                       print_string(" ");
-                       parent->print_nested_obj(obj,2);
-                       nl();
+                       std::cout << padded_address((cell)obj) << " ";
+                       parent->print_nested_obj(tag_dynamic(obj),2);
+                       std::cout << std::endl;
                }
        }
 };
 
-void factor_vm::find_data_references(cell look_for)
-{
-       begin_scan();
+struct data_reference_object_visitor {
+       cell look_for;
+       factor_vm *parent;
 
-       cell obj;
+       explicit data_reference_object_visitor(cell look_for_, factor_vm *parent_) :
+               look_for(look_for_), parent(parent_) {}
 
-       while(to_boolean(obj = next_object()))
+       void operator()(object *obj)
        {
-               data_references_finder finder(look_for,obj,this);
-               do_slots(UNTAG(obj),finder);
+               data_reference_slot_visitor visitor(look_for,obj,parent);
+               obj->each_slot(visitor);
        }
+};
 
-       end_scan();
+void factor_vm::find_data_references(cell look_for)
+{
+       data_reference_object_visitor visitor(look_for,this);
+       each_object(visitor);
 }
 
-/* Dump all code blocks for debugging */
-void factor_vm::dump_code_heap()
-{
-       cell reloc_size = 0, literal_size = 0;
+struct code_block_printer {
+       factor_vm *parent;
+       cell reloc_size, literal_size;
 
-       heap_block *scan = code->first_block();
+       explicit code_block_printer(factor_vm *parent_) :
+               parent(parent_), reloc_size(0), literal_size(0) {}
 
-       while(scan)
+       void operator()(code_block *scan, cell size)
        {
                const char *status;
-               if(scan->type() == FREE_BLOCK_TYPE)
+               if(scan->free_p())
                        status = "free";
-               else if(code->state->is_marked_p(scan))
+               else if(parent->code->marked_p(scan))
                {
-                       reloc_size += object_size(((code_block *)scan)->relocation);
-                       literal_size += object_size(((code_block *)scan)->literals);
+                       reloc_size += parent->object_size(scan->relocation);
+                       literal_size += parent->object_size(scan->literals);
                        status = "marked";
                }
                else
                {
-                       reloc_size += object_size(((code_block *)scan)->relocation);
-                       literal_size += object_size(((code_block *)scan)->literals);
+                       reloc_size += parent->object_size(scan->relocation);
+                       literal_size += parent->object_size(scan->literals);
                        status = "allocated";
                }
 
-               print_cell_hex((cell)scan); print_string(" ");
-               print_cell_hex(scan->size()); print_string(" ");
-               print_string(status); print_string("\n");
-
-               scan = code->next_block(scan);
+               std::cout << std::hex << (cell)scan << std::dec << " ";
+               std::cout << std::hex << size << std::dec << " ";
+               std::cout << status << std::endl;
        }
-       
-       print_cell(reloc_size); print_string(" bytes of relocation data\n");
-       print_cell(literal_size); print_string(" bytes of literal data\n");
+};
+
+/* Dump all code blocks for debugging */
+void factor_vm::dump_code_heap()
+{
+       code_block_printer printer(this);
+       code->allocator->iterate(printer);
+       std::cout << printer.reloc_size << " bytes of relocation data\n";
+       std::cout << printer.literal_size << " bytes of literal data\n";
 }
 
 void factor_vm::factorbug()
 {
        if(fep_disabled)
        {
-               print_string("Low level debugger disabled\n");
+               std::cout << "Low level debugger disabled\n";
                exit(1);
        }
 
        /* open_console(); */
 
-       print_string("Starting low level debugger...\n");
-       print_string("  Basic commands:\n");
-       print_string("q                -- continue executing Factor - NOT SAFE\n");
-       print_string("im               -- save image to fep.image\n");
-       print_string("x                -- exit Factor\n");
-       print_string("  Advanced commands:\n");
-       print_string("d <addr> <count> -- dump memory\n");
-       print_string("u <addr>         -- dump object at tagged <addr>\n");
-       print_string(". <addr>         -- print object at tagged <addr>\n");
-       print_string("t                -- toggle output trimming\n");
-       print_string("s r              -- dump data, retain stacks\n");
-       print_string(".s .r .c         -- print data, retain, call stacks\n");
-       print_string("e                -- dump environment\n");
-       print_string("g                -- dump generations\n");
-       print_string("data             -- data heap dump\n");
-       print_string("words            -- words dump\n");
-       print_string("tuples           -- tuples dump\n");
-       print_string("refs <addr>      -- find data heap references to object\n");
-       print_string("push <addr>      -- push object on data stack - NOT SAFE\n");
-       print_string("code             -- code heap dump\n");
+       std::cout << "Starting low level debugger...\n";
+       std::cout << "  Basic commands:\n";
+       std::cout << "q                -- continue executing Factor - NOT SAFE\n";
+       std::cout << "im               -- save image to fep.image\n";
+       std::cout << "x                -- exit Factor\n";
+       std::cout << "  Advanced commands:\n";
+       std::cout << "d <addr> <count> -- dump memory\n";
+       std::cout << "u <addr>         -- dump object at tagged <addr>\n";
+       std::cout << ". <addr>         -- print object at tagged <addr>\n";
+       std::cout << "t                -- toggle output trimming\n";
+       std::cout << "s r              -- dump data, retain stacks\n";
+       std::cout << ".s .r .c         -- print data, retain, call stacks\n";
+       std::cout << "e                -- dump environment\n";
+       std::cout << "g                -- dump generations\n";
+       std::cout << "data             -- data heap dump\n";
+       std::cout << "words            -- words dump\n";
+       std::cout << "tuples           -- tuples dump\n";
+       std::cout << "refs <addr>      -- find data heap references to object\n";
+       std::cout << "push <addr>      -- push object on data stack - NOT SAFE\n";
+       std::cout << "code             -- code heap dump\n";
 
        bool seen_command = false;
 
@@ -357,7 +375,7 @@ void factor_vm::factorbug()
        {
                char cmd[1024];
 
-               print_string("READY\n");
+               std::cout << "READY\n";
                fflush(stdout);
 
                if(scanf("%1000s",cmd) <= 0)
@@ -397,7 +415,7 @@ void factor_vm::factorbug()
                {
                        cell addr = read_cell_hex();
                        print_obj(addr);
-                       print_string("\n");
+                       std::cout << std::endl;
                }
                else if(strcmp(cmd,"t") == 0)
                        full_output = !full_output;
@@ -413,9 +431,8 @@ void factor_vm::factorbug()
                        print_callstack();
                else if(strcmp(cmd,"e") == 0)
                {
-                       int i;
-                       for(i = 0; i < USER_ENV; i++)
-                               dump_cell((cell)&userenv[i]);
+                       for(cell i = 0; i < special_object_count; i++)
+                               dump_cell((cell)&special_objects[i]);
                }
                else if(strcmp(cmd,"g") == 0)
                        dump_generations();
@@ -430,9 +447,9 @@ void factor_vm::factorbug()
                else if(strcmp(cmd,"refs") == 0)
                {
                        cell addr = read_cell_hex();
-                       print_string("Data heap references:\n");
+                       std::cout << "Data heap references:\n";
                        find_data_references(addr);
-                       nl();
+                       std::cout << std::endl;
                }
                else if(strcmp(cmd,"words") == 0)
                        dump_objects(WORD_TYPE);
@@ -446,14 +463,14 @@ void factor_vm::factorbug()
                else if(strcmp(cmd,"code") == 0)
                        dump_code_heap();
                else
-                       print_string("unknown command\n");
+                       std::cout << "unknown command\n";
        }
 }
 
 void factor_vm::primitive_die()
 {
-       print_string("The die word was called by the library. Unless you called it yourself,\n");
-       print_string("you have triggered a bug in Factor. Please report.\n");
+       std::cout << "The die word was called by the library. Unless you called it yourself,\n";
+       std::cout << "you have triggered a bug in Factor. Please report.\n";
        factorbug();
 }
 
index 0abde2e711a84ade9b18e3baa4beafc610837a3d..3eba483fe655574f03cdfa5563c78838feb6af53 100755 (executable)
@@ -22,10 +22,10 @@ cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode)
 {
        array *buckets = untag<array>(table);
        cell bucket = array_nth(buckets,hashcode & (array_capacity(buckets) - 1));
-       if(tagged<object>(bucket).type_p(WORD_TYPE) || !to_boolean(bucket))
-               return bucket;
-       else
+       if(TAG(bucket) == ARRAY_TYPE)
                return search_lookup_alist(bucket,klass);
+       else
+               return bucket;
 }
 
 cell factor_vm::nth_superclass(tuple_layout *layout, fixnum echelon)
@@ -46,10 +46,8 @@ cell factor_vm::lookup_tuple_method(cell obj, cell methods)
 
        array *echelons = untag<array>(methods);
 
-       fixnum echelon = untag_fixnum(layout->echelon);
-       fixnum max_echelon = array_capacity(echelons) - 1;
-       if(echelon > max_echelon) echelon = max_echelon;
-       
+       fixnum echelon = std::min(untag_fixnum(layout->echelon),(fixnum)array_capacity(echelons) - 1);
+
        while(echelon >= 0)
        {
                cell echelon_methods = array_nth(echelons,echelon);
@@ -72,45 +70,20 @@ cell factor_vm::lookup_tuple_method(cell obj, cell methods)
        return false_object;
 }
 
-cell factor_vm::lookup_hi_tag_method(cell obj, cell methods)
+cell factor_vm::lookup_method(cell obj, cell methods)
 {
-       array *hi_tag_methods = untag<array>(methods);
-       cell tag = untag<object>(obj)->h.hi_tag() - HEADER_TYPE;
-#ifdef FACTOR_DEBUG
-       assert(tag < TYPE_COUNT - HEADER_TYPE);
-#endif
-       return array_nth(hi_tag_methods,tag);
-}
+       cell tag = TAG(obj);
+       cell method = array_nth(untag<array>(methods),tag);
 
-cell factor_vm::lookup_hairy_method(cell obj, cell methods)
-{
-       cell method = array_nth(untag<array>(methods),TAG(obj));
-       if(tagged<object>(method).type_p(WORD_TYPE))
-               return method;
-       else
+       if(tag == TUPLE_TYPE)
        {
-               switch(TAG(obj))
-               {
-               case TUPLE_TYPE:
+               if(TAG(method) == ARRAY_TYPE)
                        return lookup_tuple_method(obj,method);
-                       break;
-               case OBJECT_TYPE:
-                       return lookup_hi_tag_method(obj,method);
-                       break;
-               default:
-                       critical_error("Bad methods array",methods);
-                       return 0;
-               }
+               else
+                       return method;
        }
-}
-
-cell factor_vm::lookup_method(cell obj, cell methods)
-{
-       cell tag = TAG(obj);
-       if(tag == TUPLE_TYPE || tag == OBJECT_TYPE)
-               return lookup_hairy_method(obj,methods);
        else
-               return array_nth(untag<array>(methods),TAG(obj));
+               return method;
 }
 
 void factor_vm::primitive_lookup_method()
@@ -122,15 +95,11 @@ void factor_vm::primitive_lookup_method()
 
 cell factor_vm::object_class(cell obj)
 {
-       switch(TAG(obj))
-       {
-       case TUPLE_TYPE:
+       cell tag = TAG(obj);
+       if(tag == TUPLE_TYPE)
                return untag<tuple>(obj)->layout;
-       case OBJECT_TYPE:
-               return untag<object>(obj)->h.value;
-       default:
-               return tag_fixnum(TAG(obj));
-       }
+       else
+               return tag_fixnum(tag);
 }
 
 cell factor_vm::method_cache_hashcode(cell klass, array *array)
@@ -149,7 +118,7 @@ void factor_vm::update_method_cache(cell cache, cell klass, cell method)
 
 void factor_vm::primitive_mega_cache_miss()
 {
-       megamorphic_cache_misses++;
+       dispatch_stats.megamorphic_cache_misses++;
 
        cell cache = dpop();
        fixnum index = untag_fixnum(dpop());
@@ -166,42 +135,38 @@ void factor_vm::primitive_mega_cache_miss()
 
 void factor_vm::primitive_reset_dispatch_stats()
 {
-       megamorphic_cache_hits = megamorphic_cache_misses = 0;
+       memset(&dispatch_stats,0,sizeof(dispatch_statistics));
 }
 
 void factor_vm::primitive_dispatch_stats()
 {
-       growable_array stats(this);
-       stats.add(allot_cell(megamorphic_cache_hits));
-       stats.add(allot_cell(megamorphic_cache_misses));
-       stats.trim();
-       dpush(stats.elements.value());
+       dpush(tag<byte_array>(byte_array_from_value(&dispatch_stats)));
 }
 
 void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cache_)
 {
-       gc_root<array> methods(methods_,parent);
-       gc_root<array> cache(cache_,parent);
+       data_root<array> methods(methods_,parent);
+       data_root<array> cache(cache_,parent);
 
        /* Generate machine code to determine the object's class. */
-       emit_class_lookup(index,PIC_HI_TAG_TUPLE);
+       emit_class_lookup(index,PIC_TUPLE);
 
        /* Do a cache lookup. */
-       emit_with(parent->userenv[MEGA_LOOKUP],cache.value());
+       emit_with(parent->special_objects[MEGA_LOOKUP],cache.value());
        
        /* If we end up here, the cache missed. */
-       emit(parent->userenv[JIT_PROLOG]);
+       emit(parent->special_objects[JIT_PROLOG]);
 
        /* Push index, method table and cache on the stack. */
        push(methods.value());
        push(tag_fixnum(index));
        push(cache.value());
-       word_call(parent->userenv[MEGA_MISS_WORD]);
+       word_call(parent->special_objects[MEGA_MISS_WORD]);
 
        /* Now the new method has been stored into the cache, and its on
           the stack. */
-       emit(parent->userenv[JIT_EPILOG]);
-       emit(parent->userenv[JIT_EXECUTE_JUMP]);
+       emit(parent->special_objects[JIT_EPILOG]);
+       emit(parent->special_objects[JIT_EXECUTE_JUMP]);
 }
 
 }
index 412ef35bb4403ee39e5aa0ef975114ad79a07a9b..87d08e2760fb28de9a3662e99f5ab8c395f15cfd 100644 (file)
@@ -1,4 +1,16 @@
 namespace factor
 {
 
+struct dispatch_statistics {
+       cell megamorphic_cache_hits;
+       cell megamorphic_cache_misses;
+
+       cell cold_call_to_ic_transitions;
+       cell ic_to_pic_transitions;
+       cell pic_to_mega_transitions;
+
+       cell pic_tag_count;
+       cell pic_tuple_count;
+};
+
 }
index a1fc71ffbc38ea88fbc3326b7d15fea336dad167..7d7b1f00801a7a3a8a434605ab05ac1854a11e92 100755 (executable)
@@ -5,22 +5,24 @@ namespace factor
 
 void fatal_error(const char *msg, cell tagged)
 {
-       print_string("fatal_error: "); print_string(msg);
-       print_string(": "); print_cell_hex(tagged); nl();
+       std::cout << "fatal_error: " << msg;
+       std::cout << ": " << std::hex << tagged << std::dec;
+       std::cout << std::endl;
        exit(1);
 }
 
 void critical_error(const char *msg, cell tagged)
 {
-       print_string("You have triggered a bug in Factor. Please report.\n");
-       print_string("critical_error: "); print_string(msg);
-       print_string(": "); print_cell_hex(tagged); nl();
+       std::cout << "You have triggered a bug in Factor. Please report.\n";
+       std::cout << "critical_error: " << msg;
+       std::cout << ": " << std::hex << tagged << std::dec;
+       std::cout << std::endl;
        tls_vm()->factorbug();
 }
 
 void out_of_memory()
 {
-       print_string("Out of memory\n\n");
+       std::cout << "Out of memory\n\n";
        tls_vm()->dump_generations();
        exit(1);
 }
@@ -29,14 +31,15 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
 {
        /* If the error handler is set, we rewind any C stack frames and
        pass the error to user-space. */
-       if(!current_gc && to_boolean(userenv[BREAK_ENV]))
+       if(!current_gc && to_boolean(special_objects[OBJ_BREAK]))
        {
                /* If error was thrown during heap scan, we re-enable the GC */
                gc_off = false;
 
                /* Reset local roots */
-               gc_locals.clear();
-               gc_bignums.clear();
+               data_roots.clear();
+               bignum_roots.clear();
+               code_roots.clear();
 
                /* If we had an underflow or overflow, stack pointers might be
                out of bounds */
@@ -53,23 +56,23 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
                else
                        callstack_top = ctx->callstack_top;
 
-               throw_impl(userenv[BREAK_ENV],callstack_top,this);
+               throw_impl(special_objects[OBJ_BREAK],callstack_top,this);
        }
        /* Error was thrown in early startup before error handler is set, just
        crash. */
        else
        {
-               print_string("You have triggered a bug in Factor. Please report.\n");
-               print_string("early_error: ");
+               std::cout << "You have triggered a bug in Factor. Please report.\n";
+               std::cout << "early_error: ";
                print_obj(error);
-               nl();
+               std::cout << std::endl;
                factorbug();
        }
 }
 
 void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top)
 {
-       throw_error(allot_array_4(userenv[ERROR_ENV],
+       throw_error(allot_array_4(special_objects[OBJ_ERROR],
                tag_fixnum(error),arg1,arg2),callstack_top);
 }
 
@@ -112,7 +115,7 @@ void factor_vm::memory_protection_error(cell addr, stack_frame *native_stack)
 
 void factor_vm::signal_error(int signal, stack_frame *native_stack)
 {
-       general_error(ERROR_SIGNAL,tag_fixnum(signal),false_object,native_stack);
+       general_error(ERROR_SIGNAL,allot_cell(signal),false_object,native_stack);
 }
 
 void factor_vm::divide_by_zero_error()
index c1ea2e19071231722304bb3c28c8a1366d6208ef..4b237e03a023c707fec6fc49cbe1e2ca3da37f68 100755 (executable)
@@ -13,7 +13,6 @@ enum vm_error_type
        ERROR_ARRAY_SIZE,
        ERROR_C_STRING,
        ERROR_FFI,
-       ERROR_HEAP_SCAN,
        ERROR_UNDEFINED_SYMBOL,
        ERROR_DS_UNDERFLOW,
        ERROR_DS_OVERFLOW,
index 2f4994c9a2f73f8e2f09f799a4daf20e31a8f83d..c83e9cdb6b11dcc786b50ad15069ac14686b5984 100755 (executable)
@@ -4,7 +4,7 @@ namespace factor
 {
 
 factor_vm *vm;
-unordered_map<THREADHANDLE, factor_vm*> thread_vms;
+std::map<THREADHANDLE, factor_vm*> thread_vms;
 
 void init_globals()
 {
@@ -15,29 +15,16 @@ void factor_vm::default_parameters(vm_parameters *p)
 {
        p->image_path = NULL;
 
-       /* We make a wild guess here that if we're running on ARM, we don't
-       have a lot of memory. */
-#ifdef FACTOR_ARM
-       p->ds_size = 8 * sizeof(cell);
-       p->rs_size = 8 * sizeof(cell);
-
-       p->code_size = 4;
-       p->young_size = 1;
-       p->aging_size = 1;
-       p->tenured_size = 6;
-#else
        p->ds_size = 32 * sizeof(cell);
        p->rs_size = 32 * sizeof(cell);
 
        p->code_size = 8 * sizeof(cell);
        p->young_size = sizeof(cell) / 4;
        p->aging_size = sizeof(cell) / 2;
-       p->tenured_size = 4 * sizeof(cell);
-#endif
+       p->tenured_size = 24 * sizeof(cell);
 
        p->max_pic_size = 3;
 
-       p->secure_gc = false;
        p->fep = false;
        p->signals = true;
 
@@ -85,7 +72,6 @@ void factor_vm::init_parameters_from_args(vm_parameters *p, int argc, vm_char **
                else if(factor_arg(arg,STRING_LITERAL("-codeheap=%d"),&p->code_size));
                else if(factor_arg(arg,STRING_LITERAL("-pic=%d"),&p->max_pic_size));
                else if(factor_arg(arg,STRING_LITERAL("-callbacks=%d"),&p->callback_size));
-               else if(STRCMP(arg,STRING_LITERAL("-securegc")) == 0) p->secure_gc = true;
                else if(STRCMP(arg,STRING_LITERAL("-fep")) == 0) p->fep = true;
                else if(STRCMP(arg,STRING_LITERAL("-nosignals")) == 0) p->signals = false;
                else if(STRNCMP(arg,STRING_LITERAL("-i="),3) == 0) p->image_path = arg + 3;
@@ -96,14 +82,14 @@ void factor_vm::init_parameters_from_args(vm_parameters *p, int argc, vm_char **
 /* Do some initialization that we do once only */
 void factor_vm::do_stage1_init()
 {
-       print_string("*** Stage 2 early init... ");
+       std::cout << "*** Stage 2 early init... ";
        fflush(stdout);
 
        compile_all_words();
-       userenv[STAGE2_ENV] = true_object;
+       update_code_heap_words();
+       special_objects[OBJ_STAGE2] = true_object;
 
-       print_string("done\n");
-       fflush(stdout);
+       std::cout << "done\n";
 }
 
 void factor_vm::init_factor(vm_parameters *p)
@@ -148,17 +134,17 @@ void factor_vm::init_factor(vm_parameters *p)
 
        init_profiler();
 
-       userenv[CPU_ENV] = allot_alien(false_object,(cell)FACTOR_CPU_STRING);
-       userenv[OS_ENV] = allot_alien(false_object,(cell)FACTOR_OS_STRING);
-       userenv[CELL_SIZE_ENV] = tag_fixnum(sizeof(cell));
-       userenv[EXECUTABLE_ENV] = allot_alien(false_object,(cell)p->executable_path);
-       userenv[ARGS_ENV] = false_object;
-       userenv[EMBEDDED_ENV] = false_object;
+       special_objects[OBJ_CPU] = allot_alien(false_object,(cell)FACTOR_CPU_STRING);
+       special_objects[OBJ_OS] = allot_alien(false_object,(cell)FACTOR_OS_STRING);
+       special_objects[OBJ_CELL_SIZE] = tag_fixnum(sizeof(cell));
+       special_objects[OBJ_EXECUTABLE] = allot_alien(false_object,(cell)p->executable_path);
+       special_objects[OBJ_ARGS] = false_object;
+       special_objects[OBJ_EMBEDDED] = false_object;
 
        /* We can GC now */
        gc_off = false;
 
-       if(!to_boolean(userenv[STAGE2_ENV]))
+       if(!to_boolean(special_objects[OBJ_STAGE2]))
                do_stage1_init();
 }
 
@@ -173,7 +159,7 @@ void factor_vm::pass_args_to_factor(int argc, vm_char **argv)
        }
 
        args.trim();
-       userenv[ARGS_ENV] = args.elements.value();
+       special_objects[OBJ_ARGS] = args.elements.value();
 }
 
 void factor_vm::start_factor(vm_parameters *p)
@@ -181,7 +167,7 @@ void factor_vm::start_factor(vm_parameters *p)
        if(p->fep) factorbug();
 
        nest_stacks(NULL);
-       c_to_factor_toplevel(userenv[BOOT_ENV]);
+       c_to_factor_toplevel(special_objects[OBJ_BOOT]);
        unnest_stacks();
 }
 
@@ -194,7 +180,7 @@ void factor_vm::stop_factor()
 
 char *factor_vm::factor_eval_string(char *string)
 {
-       char *(*callback)(char *) = (char *(*)(char *))alien_offset(userenv[EVAL_CALLBACK_ENV]);
+       char *(*callback)(char *) = (char *(*)(char *))alien_offset(special_objects[OBJ_EVAL_CALLBACK]);
        return callback(string);
 }
 
@@ -205,13 +191,13 @@ void factor_vm::factor_eval_free(char *result)
 
 void factor_vm::factor_yield()
 {
-       void (*callback)() = (void (*)())alien_offset(userenv[YIELD_CALLBACK_ENV]);
+       void (*callback)() = (void (*)())alien_offset(special_objects[OBJ_YIELD_CALLBACK]);
        callback();
 }
 
 void factor_vm::factor_sleep(long us)
 {
-       void (*callback)(long) = (void (*)(long))alien_offset(userenv[SLEEP_CALLBACK_ENV]);
+       void (*callback)(long) = (void (*)(long))alien_offset(special_objects[OBJ_SLEEP_CALLBACK]);
        callback(us);
 }
 
diff --git a/vm/free_list.cpp b/vm/free_list.cpp
new file mode 100644 (file)
index 0000000..ed961e3
--- /dev/null
@@ -0,0 +1,135 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+void free_list::clear_free_list()
+{
+       for(cell i = 0; i < free_list_count; i++)
+               small_blocks[i].clear();
+       large_blocks.clear();
+       free_block_count = 0;
+       free_space = 0;
+}
+
+void free_list::initial_free_list(cell start, cell end, cell occupied)
+{
+       clear_free_list();
+       if(occupied != end - start)
+       {
+               free_heap_block *last_block = (free_heap_block *)(start + occupied);
+               last_block->make_free(end - (cell)last_block);
+               add_to_free_list(last_block);
+       }
+}
+
+void free_list::add_to_free_list(free_heap_block *block)
+{
+       cell size = block->size();
+
+       free_block_count++;
+       free_space += size;
+
+       if(size < free_list_count * block_granularity)
+               small_blocks[size / block_granularity].push_back(block);
+       else
+               large_blocks.insert(block);
+}
+
+free_heap_block *free_list::find_free_block(cell size)
+{
+       /* Check small free lists */
+       if(size / block_granularity < free_list_count)
+       {
+               std::vector<free_heap_block *> &blocks = small_blocks[size / block_granularity];
+               if(blocks.size() == 0)
+               {
+                       /* Round up to a multiple of 'size' */
+                       cell large_block_size = ((allocation_page_size + size - 1) / size) * size;
+
+                       /* Allocate a block this big */
+                       free_heap_block *large_block = find_free_block(large_block_size);
+                       if(!large_block) return NULL;
+
+                       large_block = split_free_block(large_block,large_block_size);
+
+                       /* Split it up into pieces and add each piece back to the free list */
+                       for(cell offset = 0; offset < large_block_size; offset += size)
+                       {
+                               free_heap_block *small_block = large_block;
+                               large_block = (free_heap_block *)((cell)large_block + size);
+                               small_block->make_free(size);
+                               add_to_free_list(small_block);
+                       }
+               }
+
+               free_heap_block *block = blocks.back();
+               blocks.pop_back();
+
+               free_block_count--;
+               free_space -= block->size();
+
+               return block;
+       }
+       else
+       {
+               /* Check large free list */
+               free_heap_block key;
+               key.make_free(size);
+               large_block_set::iterator iter = large_blocks.lower_bound(&key);
+               large_block_set::iterator end = large_blocks.end();
+
+               if(iter != end)
+               {
+                       free_heap_block *block = *iter;
+                       large_blocks.erase(iter);
+
+                       free_block_count--;
+                       free_space -= block->size();
+
+                       return block;
+               }
+
+               return NULL;
+       }
+}
+
+free_heap_block *free_list::split_free_block(free_heap_block *block, cell size)
+{
+       if(block->size() != size)
+       {
+               /* split the block in two */
+               free_heap_block *split = (free_heap_block *)((cell)block + size);
+               split->make_free(block->size() - size);
+               block->make_free(size);
+               add_to_free_list(split);
+       }
+
+       return block;
+}
+
+bool free_list::can_allot_p(cell size)
+{
+       return largest_free_block() >= std::max(size,allocation_page_size);
+}
+
+cell free_list::largest_free_block()
+{
+       if(large_blocks.size())
+       {
+               large_block_set::reverse_iterator last = large_blocks.rbegin();
+               return (*last)->size();
+       }
+       else
+       {
+               for(int i = free_list_count - 1; i >= 0; i--)
+               {
+                       if(small_blocks[i].size())
+                               return small_blocks[i].back()->size();
+               }
+
+               return 0;
+       }
+}
+
+}
diff --git a/vm/free_list.hpp b/vm/free_list.hpp
new file mode 100644 (file)
index 0000000..d934ec3
--- /dev/null
@@ -0,0 +1,51 @@
+namespace factor
+{
+
+static const cell free_list_count = 32;
+static const cell allocation_page_size = 1024;
+
+struct free_heap_block
+{
+       cell header;
+
+       bool free_p() const
+       {
+               return (header & 1) == 1;
+       }
+
+       cell size() const
+       {
+               return header & ~7;
+       }
+
+       void make_free(cell size)
+       {
+               header = size | 1;
+       }
+};
+
+struct block_size_compare {
+       bool operator()(free_heap_block *a, free_heap_block *b)
+       {
+               return a->size() < b->size();
+       }
+};
+
+typedef std::multiset<free_heap_block *, block_size_compare> large_block_set;
+
+struct free_list {
+       std::vector<free_heap_block *> small_blocks[free_list_count];
+       large_block_set large_blocks;
+       cell free_block_count;
+       cell free_space;
+
+       void clear_free_list();
+       void initial_free_list(cell start, cell end, cell occupied);
+       void add_to_free_list(free_heap_block *block);
+       free_heap_block *find_free_block(cell size);
+       free_heap_block *split_free_block(free_heap_block *block, cell size);
+       bool can_allot_p(cell size);
+       cell largest_free_block();
+};
+
+}
diff --git a/vm/free_list_allocator.hpp b/vm/free_list_allocator.hpp
new file mode 100644 (file)
index 0000000..62e4e09
--- /dev/null
@@ -0,0 +1,218 @@
+namespace factor
+{
+
+template<typename Block> struct free_list_allocator {
+       cell size;
+       cell start;
+       cell end;
+       free_list free_blocks;
+       mark_bits<Block> state;
+
+       explicit free_list_allocator(cell size, cell start);
+       void initial_free_list(cell occupied);
+       bool contains_p(Block *block);
+       Block *first_block();
+       Block *last_block();
+       Block *next_block_after(Block *block);
+       Block *next_allocated_block_after(Block *block);
+       bool can_allot_p(cell size);
+       Block *allot(cell size);
+       void free(Block *block);
+       cell occupied_space();
+       cell free_space();
+       cell largest_free_block();
+       cell free_block_count();
+       void sweep();
+       template<typename Iterator, typename Sizer> void compact(Iterator &iter, Sizer &sizer);
+       template<typename Iterator, typename Sizer> void iterate(Iterator &iter, Sizer &sizer);
+       template<typename Iterator> void iterate(Iterator &iter);
+};
+
+template<typename Block>
+free_list_allocator<Block>::free_list_allocator(cell size_, cell start_) :
+       size(size_),
+       start(start_),
+       end(start_ + size_),
+       state(mark_bits<Block>(size_,start_))
+{
+       initial_free_list(0);
+}
+
+template<typename Block> void free_list_allocator<Block>::initial_free_list(cell occupied)
+{
+       free_blocks.initial_free_list(start,end,occupied);
+}
+
+template<typename Block> bool free_list_allocator<Block>::contains_p(Block *block)
+{
+       return ((cell)block - start) < size;
+}
+
+template<typename Block> Block *free_list_allocator<Block>::first_block()
+{
+       return (Block *)start;
+}
+
+template<typename Block> Block *free_list_allocator<Block>::last_block()
+{
+       return (Block *)end;
+}
+
+template<typename Block> Block *free_list_allocator<Block>::next_block_after(Block *block)
+{
+       return (Block *)((cell)block + block->size());
+}
+
+template<typename Block> Block *free_list_allocator<Block>::next_allocated_block_after(Block *block)
+{
+       while(block != this->last_block() && block->free_p())
+       {
+               free_heap_block *free_block = (free_heap_block *)block;
+               block = (object *)((cell)free_block + free_block->size());
+       }
+
+       if(block == this->last_block())
+               return NULL;
+       else
+               return block;
+}
+
+template<typename Block> bool free_list_allocator<Block>::can_allot_p(cell size)
+{
+       return free_blocks.can_allot_p(size);
+}
+
+template<typename Block> Block *free_list_allocator<Block>::allot(cell size)
+{
+       size = align(size,block_granularity);
+
+       free_heap_block *block = free_blocks.find_free_block(size);
+       if(block)
+       {
+               block = free_blocks.split_free_block(block,size);
+               return (Block *)block;
+       }
+       else
+               return NULL;
+}
+
+template<typename Block> void free_list_allocator<Block>::free(Block *block)
+{
+       free_heap_block *free_block = (free_heap_block *)block;
+       free_block->make_free(block->size());
+       free_blocks.add_to_free_list(free_block);
+}
+
+template<typename Block> cell free_list_allocator<Block>::free_space()
+{
+       return free_blocks.free_space;
+}
+
+template<typename Block> cell free_list_allocator<Block>::occupied_space()
+{
+       return size - free_blocks.free_space;
+}
+
+template<typename Block> cell free_list_allocator<Block>::largest_free_block()
+{
+       return free_blocks.largest_free_block();
+}
+
+template<typename Block> cell free_list_allocator<Block>::free_block_count()
+{
+       return free_blocks.free_block_count;
+}
+
+template<typename Block>
+void free_list_allocator<Block>::sweep()
+{
+       free_blocks.clear_free_list();
+
+       Block *start = this->first_block();
+       Block *end = this->last_block();
+
+       while(start != end)
+       {
+               /* find next unmarked block */
+               start = state.next_unmarked_block_after(start);
+       
+               if(start != end)
+               {
+                       /* find size */
+                       cell size = state.unmarked_block_size(start);
+                       assert(size > 0);
+
+                       free_heap_block *free_block = (free_heap_block *)start;
+                       free_block->make_free(size);
+                       free_blocks.add_to_free_list(free_block);
+
+                       start = (Block *)((char *)start + size);
+               }
+       }
+}
+
+template<typename Block, typename Iterator> struct heap_compactor {
+       mark_bits<Block> *state;
+       char *address;
+       Iterator &iter;
+
+       explicit heap_compactor(mark_bits<Block> *state_, Block *address_, Iterator &iter_) :
+               state(state_), address((char *)address_), iter(iter_) {}
+
+       void operator()(Block *block, cell size)
+       {
+               if(this->state->marked_p(block))
+               {
+                       iter(block,(Block *)address,size);
+                       address += size;
+               }
+       }
+};
+
+/* The forwarding map must be computed first by calling
+state.compute_forwarding(). */
+template<typename Block>
+template<typename Iterator, typename Sizer>
+void free_list_allocator<Block>::compact(Iterator &iter, Sizer &sizer)
+{
+       heap_compactor<Block,Iterator> compactor(&state,first_block(),iter);
+       iterate(compactor,sizer);
+
+       /* Now update the free list; there will be a single free block at
+       the end */
+       free_blocks.initial_free_list(start,end,(cell)compactor.address - start);
+}
+
+/* During compaction we have to be careful and measure object sizes differently */
+template<typename Block>
+template<typename Iterator, typename Sizer>
+void free_list_allocator<Block>::iterate(Iterator &iter, Sizer &sizer)
+{
+       Block *scan = first_block();
+       Block *end = last_block();
+
+       while(scan != end)
+       {
+               cell size = sizer(scan);
+               Block *next = (Block *)((cell)scan + size);
+               if(!scan->free_p()) iter(scan,size);
+               scan = next;
+       }
+}
+
+template<typename Block> struct standard_sizer {
+       cell operator()(Block *block)
+       {
+               return block->size();
+       }
+};
+
+template<typename Block>
+template<typename Iterator>
+void free_list_allocator<Block>::iterate(Iterator &iter)
+{
+       standard_sizer<Block> sizer;
+       iterate(iter,sizer);
+}
+
+}
index f9db1c8653284c3893d1b0bc19ae4861e85567a6..188ab55efc067547cb5068d43ff323b792f478af 100644 (file)
@@ -4,197 +4,152 @@ namespace factor
 {
 
 full_collector::full_collector(factor_vm *parent_) :
-       copying_collector<tenured_space,full_policy>(
+       collector<tenured_space,full_policy>(
                parent_,
-               &parent_->gc_stats.full_stats,
                parent_->data->tenured,
                full_policy(parent_)) {}
 
-struct stack_frame_marker {
-       factor_vm *parent;
-       full_collector *collector;
+/* After a sweep, invalidate any code heap roots which are not marked,
+so that if a block makes a tail call to a generic word, and the PIC
+compiler triggers a GC, and the caller block gets gets GCd as a result,
+the PIC code won't try to overwrite the call site */
+void factor_vm::update_code_roots_for_sweep()
+{
+       std::vector<code_root *>::const_iterator iter = code_roots.begin();
+       std::vector<code_root *>::const_iterator end = code_roots.end();
 
-       explicit stack_frame_marker(full_collector *collector_) :
-               parent(collector_->parent), collector(collector_) {}
+       mark_bits<code_block> *state = &code->allocator->state;
 
-       void operator()(stack_frame *frame)
+       for(; iter < end; iter++)
        {
-               collector->mark_code_block(parent->frame_code(frame));
+               code_root *root = *iter;
+               code_block *block = (code_block *)(root->value & -block_granularity);
+               if(root->valid && !state->marked_p(block))
+                       root->valid = false;
        }
-};
-
-/* Mark code blocks executing in currently active stack frames. */
-void full_collector::mark_active_blocks()
-{
-       stack_frame_marker marker(this);
-       parent->iterate_active_frames(marker);
 }
 
-void full_collector::mark_object_code_block(object *obj)
+/* After a compaction, invalidate any code heap roots which are not
+marked as above, and also slide the valid roots up so that call sites
+can be updated correctly. */
+void factor_vm::update_code_roots_for_compaction()
 {
-       switch(obj->h.hi_tag())
-       {
-       case WORD_TYPE:
-               {
-                       word *w = (word *)obj;
-                       if(w->code)
-                               mark_code_block(w->code);
-                       if(w->profiling)
-                               mark_code_block(w->profiling);
-                       break;
-               }
-       case QUOTATION_TYPE:
-               {
-                       quotation *q = (quotation *)obj;
-                       if(q->code)
-                               mark_code_block(q->code);
-                       break;
-               }
-       case CALLSTACK_TYPE:
-               {
-                       callstack *stack = (callstack *)obj;
-                       stack_frame_marker marker(this);
-                       parent->iterate_callstack_object(stack,marker);
-                       break;
-               }
-       }
-}
+       std::vector<code_root *>::const_iterator iter = code_roots.begin();
+       std::vector<code_root *>::const_iterator end = code_roots.end();
 
-struct callback_tracer {
-       full_collector *collector;
+       mark_bits<code_block> *state = &code->allocator->state;
 
-       callback_tracer(full_collector *collector_) : collector(collector_) {}
-       
-       void operator()(callback *stub)
+       for(; iter < end; iter++)
        {
-               collector->mark_code_block(stub->compiled);
-       }
-};
-
-void full_collector::trace_callbacks()
-{
-       callback_tracer tracer(this);
-       parent->callbacks->iterate(tracer);
-}
+               code_root *root = *iter;
+               code_block *block = (code_block *)(root->value & -block_granularity);
 
-/* Trace all literals referenced from a code block. Only for aging and nursery collections */
-void full_collector::trace_literal_references(code_block *compiled)
-{
-       this->trace_handle(&compiled->owner);
-       this->trace_handle(&compiled->literals);
-       this->trace_handle(&compiled->relocation);
-}
-
-/* Mark all literals referenced from a word XT. Only for tenured
-collections */
-void full_collector::mark_code_block(code_block *compiled)
-{
-       this->code->mark_block(compiled);
-       trace_literal_references(compiled);
-}
+               /* Offset of return address within 16-byte allocation line */
+               cell offset = root->value - (cell)block;
 
-void full_collector::cheneys_algorithm()
-{
-       while(scan && scan < target->here)
-       {
-               object *obj = (object *)scan;
-               this->trace_slots(obj);
-               this->mark_object_code_block(obj);
-               scan = target->next_object_after(this->parent,scan);
+               if(root->valid && state->marked_p((code_block *)root->value))
+               {
+                       block = state->forward_block(block);
+                       root->value = (cell)block + offset;
+               }
+               else
+                       root->valid = false;
        }
 }
 
-/* After growing the heap, we have to perform a full relocation to update
-references to card and deck arrays. */
-struct big_code_heap_updater {
-       factor_vm *parent;
+struct code_block_marker {
+       code_heap *code;
+       full_collector *collector;
 
-       big_code_heap_updater(factor_vm *parent_) : parent(parent_) {}
+       explicit code_block_marker(code_heap *code_, full_collector *collector_) :
+               code(code_), collector(collector_) {}
 
-       void operator()(heap_block *block)
+       code_block *operator()(code_block *compiled)
        {
-               parent->relocate_code_block((code_block *)block);
-       }
-};
-
-/* After a full GC that did not grow the heap, we have to update references
-to literals and other words. */
-struct small_code_heap_updater {
-       factor_vm *parent;
-
-       small_code_heap_updater(factor_vm *parent_) : parent(parent_) {}
+               if(!code->marked_p(compiled))
+               {
+                       code->set_marked_p(compiled);
+                       collector->trace_literal_references(compiled);
+               }
 
-       void operator()(heap_block *block)
-       {
-               parent->update_code_block_for_full_gc((code_block *)block);
+               return compiled;
        }
 };
 
-void factor_vm::collect_full_impl(bool trace_contexts_p)
+void factor_vm::collect_mark_impl(bool trace_contexts_p)
 {
        full_collector collector(this);
 
-       code->state->clear_mark_bits();
+       code->clear_mark_bits();
+       data->tenured->clear_mark_bits();
+       data->tenured->clear_mark_stack();
+
+       code_block_visitor<code_block_marker> code_marker(this,code_block_marker(code,&collector));
 
        collector.trace_roots();
         if(trace_contexts_p)
        {
                collector.trace_contexts();
-               collector.mark_active_blocks();
-               collector.trace_callbacks();
+               code_marker.visit_context_code_blocks();
+               code_marker.visit_callback_code_blocks();
        }
 
-       collector.cheneys_algorithm();
-
-       reset_generation(data->aging);
-       nursery.here = nursery.start;
-}
-
-void factor_vm::collect_growing_heap(cell requested_bytes,
-       bool trace_contexts_p,
-       bool compact_code_heap_p)
-{
-       /* Grow the data heap and copy all live objects to the new heap. */
-       data_heap *old = data;
-       set_data_heap(data->grow(requested_bytes));
-       collect_full_impl(trace_contexts_p);
-       delete old;
+       std::vector<object *> *mark_stack = &data->tenured->mark_stack;
 
-       if(compact_code_heap_p)
+       while(!mark_stack->empty())
        {
-               compact_code_heap(trace_contexts_p);
-               big_code_heap_updater updater(this);
-               iterate_code_heap(updater);
-       }
-       else
-       {
-               big_code_heap_updater updater(this);
-               code->free_unmarked(updater);
+               object *obj = mark_stack->back();
+               mark_stack->pop_back();
+               collector.trace_object(obj);
+               code_marker.visit_object_code_block(obj);
        }
 
+       data->reset_generation(data->tenured);
+       data->reset_generation(data->aging);
+       data->reset_generation(&nursery);
        code->clear_remembered_set();
 }
 
-void factor_vm::collect_full(bool trace_contexts_p, bool compact_code_heap_p)
+void factor_vm::collect_sweep_impl()
 {
-       /* Copy all live objects to the tenured semispace. */
-       std::swap(data->tenured,data->tenured_semispace);
-       reset_generation(data->tenured);
-       collect_full_impl(trace_contexts_p);
+       current_gc->event->started_data_sweep();
+       data->tenured->sweep();
+       update_code_roots_for_sweep();
+       current_gc->event->ended_data_sweep();
+
+       current_gc->event->started_code_sweep();
+       code->allocator->sweep();
+       current_gc->event->ended_code_sweep();
+}
 
-       if(compact_code_heap_p)
+void factor_vm::collect_full(bool trace_contexts_p)
+{
+       collect_mark_impl(trace_contexts_p);
+       collect_sweep_impl();
+       if(data->low_memory_p())
        {
-               compact_code_heap(trace_contexts_p);
-               big_code_heap_updater updater(this);
-               iterate_code_heap(updater);
+               current_gc->op = collect_compact_op;
+               current_gc->event->op = collect_compact_op;
+               collect_compact_impl(trace_contexts_p);
        }
        else
-       {
-               small_code_heap_updater updater(this);
-               code->free_unmarked(updater);
-       }
+               update_code_heap_words_and_literals();
+}
 
-       code->clear_remembered_set();
+void factor_vm::collect_compact(bool trace_contexts_p)
+{
+       collect_mark_impl(trace_contexts_p);
+       collect_compact_impl(trace_contexts_p);
+}
+
+void factor_vm::collect_growing_heap(cell requested_bytes, bool trace_contexts_p)
+{
+       /* Grow the data heap and copy all live objects to the new heap. */
+       data_heap *old = data;
+       set_data_heap(data->grow(requested_bytes));
+       collect_mark_impl(trace_contexts_p);
+       collect_compact_code_impl(trace_contexts_p);
+       delete old;
 }
 
 }
index 8cc37f782d5acc013a3a0303174a8457fce6a099..eb125b7429e9a8c4f3abeca3af3477e6abb1c9aa 100644 (file)
@@ -3,26 +3,31 @@ namespace factor
 
 struct full_policy {
        factor_vm *parent;
-       zone *tenured;
+       tenured_space *tenured;
 
-       full_policy(factor_vm *parent_) : parent(parent_), tenured(parent->data->tenured) {}
+       explicit full_policy(factor_vm *parent_) : parent(parent_), tenured(parent->data->tenured) {}
 
        bool should_copy_p(object *untagged)
        {
                return !tenured->contains_p(untagged);
        }
+
+       void promoted_object(object *obj)
+       {
+               tenured->mark_and_push(obj);
+       }
+
+       void visited_object(object *obj)
+       {
+               if(!tenured->marked_p(obj))
+                       tenured->mark_and_push(obj);
+       }
 };
 
-struct full_collector : copying_collector<tenured_space,full_policy> {
+struct full_collector : collector<tenured_space,full_policy> {
        bool trace_contexts_p;
 
-       full_collector(factor_vm *parent_);
-       void mark_active_blocks();
-       void mark_object_code_block(object *object);
-       void trace_callbacks();
-       void trace_literal_references(code_block *compiled);
-       void mark_code_block(code_block *compiled);
-       void cheneys_algorithm();
+       explicit full_collector(factor_vm *parent_);
 };
 
 }
index c8ba57b7f2a5315c92d59cb1ceab37420ecc72ee..32ca44ae1cba251477794fd17de68f6f0c17b6f6 100755 (executable)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -3,9 +3,128 @@
 namespace factor
 {
 
-gc_state::gc_state(gc_op op_) : op(op_), start_time(current_micros()) {}
+gc_event::gc_event(gc_op op_, factor_vm *parent) :
+       op(op_),
+       cards_scanned(0),
+       decks_scanned(0),
+       code_blocks_scanned(0),
+       start_time(current_micros()),
+       card_scan_time(0),
+       code_scan_time(0),
+       data_sweep_time(0),
+       code_sweep_time(0),
+       compaction_time(0)
+{
+       data_heap_before = parent->data_room();
+       code_heap_before = parent->code_room();
+       start_time = current_micros();
+}
+
+void gc_event::started_card_scan()
+{
+       temp_time = current_micros();
+}
+
+void gc_event::ended_card_scan(cell cards_scanned_, cell decks_scanned_)
+{
+       cards_scanned += cards_scanned_;
+       decks_scanned += decks_scanned_;
+       card_scan_time = (current_micros() - temp_time);
+}
 
-gc_state::~gc_state() {}
+void gc_event::started_code_scan()
+{
+       temp_time = current_micros();
+}
+
+void gc_event::ended_code_scan(cell code_blocks_scanned_)
+{
+       code_blocks_scanned += code_blocks_scanned_;
+       code_scan_time = (current_micros() - temp_time);
+}
+
+void gc_event::started_data_sweep()
+{
+       temp_time = current_micros();
+}
+
+void gc_event::ended_data_sweep()
+{
+       data_sweep_time = (current_micros() - temp_time);
+}
+
+void gc_event::started_code_sweep()
+{
+       temp_time = current_micros();
+}
+
+void gc_event::ended_code_sweep()
+{
+       code_sweep_time = (current_micros() - temp_time);
+}
+
+void gc_event::started_compaction()
+{
+       temp_time = current_micros();
+}
+
+void gc_event::ended_compaction()
+{
+       compaction_time = (current_micros() - temp_time);
+}
+
+void gc_event::ended_gc(factor_vm *parent)
+{
+       data_heap_after = parent->data_room();
+       code_heap_after = parent->code_room();
+       total_time = current_micros() - start_time;
+}
+
+gc_state::gc_state(gc_op op_, factor_vm *parent) : op(op_), start_time(current_micros())
+{
+       event = new gc_event(op,parent);
+}
+
+gc_state::~gc_state()
+{
+       delete event;
+       event = NULL;
+}
+
+void factor_vm::end_gc()
+{
+       current_gc->event->ended_gc(this);
+       if(gc_events) gc_events->push_back(*current_gc->event);
+       delete current_gc->event;
+       current_gc->event = NULL;
+}
+
+void factor_vm::start_gc_again()
+{
+       end_gc();
+
+       switch(current_gc->op)
+       {
+       case collect_nursery_op:
+               current_gc->op = collect_aging_op;
+               break;
+       case collect_aging_op:
+               current_gc->op = collect_to_tenured_op;
+               break;
+       case collect_to_tenured_op:
+               current_gc->op = collect_full_op;
+               break;
+       case collect_full_op:
+       case collect_compact_op:
+               current_gc->op = collect_growing_heap_op;
+               break;
+       default:
+               critical_error("Bad GC op",current_gc->op);
+               break;
+       }
+
+       current_gc->event = new gc_event(current_gc->op,this);
+}
 
 void factor_vm::update_code_heap_for_minor_gc(std::set<code_block *> *remembered_set)
 {
@@ -16,79 +135,64 @@ void factor_vm::update_code_heap_for_minor_gc(std::set<code_block *> *remembered
        for(; iter != end; iter++) update_literal_references(*iter);
 }
 
-void factor_vm::record_gc_stats(generation_statistics *stats)
-{
-       cell gc_elapsed = (current_micros() - current_gc->start_time);
-       stats->collections++;
-       stats->gc_time += gc_elapsed;
-       if(stats->max_gc_time < gc_elapsed)
-               stats->max_gc_time = gc_elapsed;
-}
-
-void factor_vm::gc(gc_op op,
-       cell requested_bytes,
-       bool trace_contexts_p,
-       bool compact_code_heap_p)
+void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
 {
        assert(!gc_off);
        assert(!current_gc);
 
        save_stacks();
 
-       current_gc = new gc_state(op);
+       current_gc = new gc_state(op,this);
 
        /* Keep trying to GC higher and higher generations until we don't run out
        of space */
        if(setjmp(current_gc->gc_unwind))
        {
                /* We come back here if a generation is full */
-               switch(current_gc->op)
-               {
-               case collect_nursery_op:
-                       current_gc->op = collect_aging_op;
-                       break;
-               case collect_aging_op:
-                       current_gc->op = collect_to_tenured_op;
-                       break;
-               case collect_to_tenured_op:
-                       current_gc->op = collect_full_op;
-                       break;
-               case collect_full_op:
-                       current_gc->op = collect_growing_heap_op;
-                       break;
-               default:
-                       critical_error("Bad GC op\n",op);
-                       break;
-               }
+               start_gc_again();
        }
 
+       current_gc->event->op = current_gc->op;
+
        switch(current_gc->op)
        {
        case collect_nursery_op:
                collect_nursery();
-               record_gc_stats(&gc_stats.nursery_stats);
                break;
        case collect_aging_op:
                collect_aging();
-               record_gc_stats(&gc_stats.aging_stats);
+               if(data->low_memory_p())
+               {
+                       current_gc->op = collect_full_op;
+                       current_gc->event->op = collect_full_op;
+                       collect_full(trace_contexts_p);
+               }
                break;
        case collect_to_tenured_op:
                collect_to_tenured();
-               record_gc_stats(&gc_stats.aging_stats);
+               if(data->low_memory_p())
+               {
+                       current_gc->op = collect_full_op;
+                       current_gc->event->op = collect_full_op;
+                       collect_full(trace_contexts_p);
+               }
                break;
        case collect_full_op:
-               collect_full(trace_contexts_p,compact_code_heap_p);
-               record_gc_stats(&gc_stats.full_stats);
+               collect_full(trace_contexts_p);
+               break;
+       case collect_compact_op:
+               collect_compact(trace_contexts_p);
                break;
        case collect_growing_heap_op:
-               collect_growing_heap(requested_bytes,trace_contexts_p,compact_code_heap_p);
-               record_gc_stats(&gc_stats.full_stats);
+               collect_growing_heap(requested_bytes,trace_contexts_p);
                break;
        default:
-               critical_error("Bad GC op\n",op);
+               critical_error("Bad GC op",current_gc->op);
                break;
        }
 
+       end_gc();
+
        delete current_gc;
        current_gc = NULL;
 }
@@ -97,168 +201,97 @@ void factor_vm::primitive_minor_gc()
 {
        gc(collect_nursery_op,
                0, /* requested size */
-               true, /* trace contexts? */
-               false /* compact code heap? */);
+               true /* trace contexts? */);
 }
 
 void factor_vm::primitive_full_gc()
 {
        gc(collect_full_op,
                0, /* requested size */
-               true, /* trace contexts? */
-               false /* compact code heap? */);
+               true /* trace contexts? */);
 }
 
 void factor_vm::primitive_compact_gc()
 {
-       gc(collect_full_op,
+       gc(collect_compact_op,
                0, /* requested size */
-               true, /* trace contexts? */
-               true /* compact code heap? */);
+               true /* trace contexts? */);
 }
 
-void factor_vm::add_gc_stats(generation_statistics *stats, growable_array *result)
+void factor_vm::inline_gc(cell *data_roots_base, cell data_roots_size)
 {
-       result->add(allot_cell(stats->collections));
-       result->add(tag<bignum>(long_long_to_bignum(stats->gc_time)));
-       result->add(tag<bignum>(long_long_to_bignum(stats->max_gc_time)));
-       result->add(allot_cell(stats->collections == 0 ? 0 : stats->gc_time / stats->collections));
-       result->add(allot_cell(stats->object_count));
-       result->add(tag<bignum>(long_long_to_bignum(stats->bytes_copied)));
-}
-
-void factor_vm::primitive_gc_stats()
-{
-       growable_array result(this);
-
-       add_gc_stats(&gc_stats.nursery_stats,&result);
-       add_gc_stats(&gc_stats.aging_stats,&result);
-       add_gc_stats(&gc_stats.full_stats,&result);
-
-       u64 total_gc_time =
-               gc_stats.nursery_stats.gc_time +
-               gc_stats.aging_stats.gc_time +
-               gc_stats.full_stats.gc_time;
-
-       result.add(tag<bignum>(ulong_long_to_bignum(total_gc_time)));
-       result.add(tag<bignum>(ulong_long_to_bignum(gc_stats.cards_scanned)));
-       result.add(tag<bignum>(ulong_long_to_bignum(gc_stats.decks_scanned)));
-       result.add(tag<bignum>(ulong_long_to_bignum(gc_stats.card_scan_time)));
-       result.add(allot_cell(gc_stats.code_blocks_scanned));
-
-       result.trim();
-       dpush(result.elements.value());
-}
-
-void factor_vm::clear_gc_stats()
-{
-       memset(&gc_stats,0,sizeof(gc_statistics));
+       data_roots.push_back(data_root_range(data_roots_base,data_roots_size));
+       primitive_minor_gc();
+       data_roots.pop_back();
 }
 
-void factor_vm::primitive_clear_gc_stats()
+VM_C_API void inline_gc(cell *data_roots_base, cell data_roots_size, factor_vm *parent)
 {
-       clear_gc_stats();
+       parent->inline_gc(data_roots_base,data_roots_size);
 }
 
-/* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
-   to coalesce equal but distinct quotations and wrappers. */
-void factor_vm::primitive_become()
+/*
+ * It is up to the caller to fill in the object's fields in a meaningful
+ * fashion!
+ */
+object *factor_vm::allot_large_object(cell type, cell size)
 {
-       array *new_objects = untag_check<array>(dpop());
-       array *old_objects = untag_check<array>(dpop());
-
-       cell capacity = array_capacity(new_objects);
-       if(capacity != array_capacity(old_objects))
-               critical_error("bad parameters to become",0);
-
-       cell i;
-
-       for(i = 0; i < capacity; i++)
+       /* If tenured space does not have enough room, collect and compact */
+       if(!data->tenured->can_allot_p(size))
        {
-               tagged<object> old_obj(array_nth(old_objects,i));
-               tagged<object> new_obj(array_nth(new_objects,i));
+               primitive_compact_gc();
 
-               if(old_obj != new_obj)
-                       old_obj->h.forward_to(new_obj.untagged());
+               /* If it still won't fit, grow the heap */
+               if(!data->tenured->can_allot_p(size))
+               {
+                       gc(collect_growing_heap_op,
+                               size, /* requested size */
+                               true /* trace contexts? */);
+               }
        }
 
-       primitive_full_gc();
+       object *obj = data->tenured->allot(size);
 
-       /* If a word's definition quotation was in old_objects and the
-          quotation in new_objects is not compiled, we might leak memory
-          by referencing the old quotation unless we recompile all
-          unoptimized words. */
-       compile_all_words();
-}
-
-void factor_vm::inline_gc(cell *gc_roots_base, cell gc_roots_size)
-{
-       for(cell i = 0; i < gc_roots_size; i++)
-               gc_locals.push_back((cell)&gc_roots_base[i]);
+       /* Allows initialization code to store old->new pointers
+       without hitting the write barrier in the common case of
+       a nursery allocation */
+       write_barrier(obj,size);
 
-       primitive_minor_gc();
-
-       for(cell i = 0; i < gc_roots_size; i++)
-               gc_locals.pop_back();
+       obj->initialize(type);
+       return obj;
 }
 
-VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *parent)
+void factor_vm::primitive_enable_gc_events()
 {
-       parent->inline_gc(gc_roots_base,gc_roots_size);
+       gc_events = new std::vector<gc_event>();
 }
 
-/*
- * It is up to the caller to fill in the object's fields in a meaningful
- * fashion!
- */
-object *factor_vm::allot_object(header header, cell size)
+void factor_vm::primitive_disable_gc_events()
 {
-#ifdef GC_DEBUG
-       if(!gc_off)
-               primitive_full_gc();
-#endif
-
-       object *obj;
-
-       /* If the object is smaller than the nursery, allocate it in the nursery,
-       after a GC if needed */
-       if(nursery.size > size)
+       if(gc_events)
        {
-               /* If there is insufficient room, collect the nursery */
-               if(nursery.here + size > nursery.end)
-                       primitive_minor_gc();
+               growable_array result(this);
 
-               obj = nursery.allot(size);
-       }
-       /* If the object is bigger than the nursery, allocate it in
-       tenured space */
-       else
-       {
-               /* If tenured space does not have enough room, collect */
-               if(data->tenured->here + size > data->tenured->end)
-                       primitive_full_gc();
+               std::vector<gc_event> *gc_events = this->gc_events;
+               this->gc_events = NULL;
 
-               /* If it still won't fit, grow the heap */
-               if(data->tenured->here + size > data->tenured->end)
+               std::vector<gc_event>::const_iterator iter = gc_events->begin();
+               std::vector<gc_event>::const_iterator end = gc_events->end();
+
+               for(; iter != end; iter++)
                {
-                       gc(collect_growing_heap_op,
-                               size, /* requested size */
-                               true, /* trace contexts? */
-                               false /* compact code heap? */);
+                       gc_event event = *iter;
+                       byte_array *obj = byte_array_from_value(&event);
+                       result.add(tag<byte_array>(obj));
                }
 
-               obj = data->tenured->allot(size);
+               result.trim();
+               dpush(result.elements.value());
 
-               /* Allows initialization code to store old->new pointers
-               without hitting the write barrier in the common case of
-               a nursery allocation */
-               char *start = (char *)obj;
-               for(cell offset = 0; offset < size; offset += card_size)
-                       write_barrier((cell *)(start + offset));
+               delete this->gc_events;
        }
-
-       obj->h = header;
-       return obj;
+       else
+               dpush(false_object);
 }
 
 }
index 18b926ed8caccdb42f8989c068ab115a52069f11..d80d57dafefefb0fd74c4028976da401251b4b8f 100755 (executable)
--- a/vm/gc.hpp
+++ b/vm/gc.hpp
@@ -6,37 +6,53 @@ enum gc_op {
        collect_aging_op,
        collect_to_tenured_op,
        collect_full_op,
+       collect_compact_op,
        collect_growing_heap_op
 };
 
-/* statistics */
-struct generation_statistics {
-       cell collections;
-       u64 gc_time;
-       u64 max_gc_time;
-       cell object_count;
-       u64 bytes_copied;
-};
+struct gc_event {
+       gc_op op;
+       data_heap_room data_heap_before;
+       code_heap_room code_heap_before;
+       data_heap_room data_heap_after;
+       code_heap_room code_heap_after;
+       cell cards_scanned;
+       cell decks_scanned;
+       cell code_blocks_scanned;
+       u64 start_time;
+       cell total_time;
+       cell card_scan_time;
+       cell code_scan_time;
+       cell data_sweep_time;
+       cell code_sweep_time;
+       cell compaction_time;
+       u64 temp_time;
 
-struct gc_statistics {
-       generation_statistics nursery_stats;
-       generation_statistics aging_stats;
-       generation_statistics full_stats;
-       u64 cards_scanned;
-       u64 decks_scanned;
-       u64 card_scan_time;
-       u64 code_blocks_scanned;
+       explicit gc_event(gc_op op_, factor_vm *parent);
+       void started_card_scan();
+       void ended_card_scan(cell cards_scanned_, cell decks_scanned_);
+       void started_code_scan();
+       void ended_code_scan(cell code_blocks_scanned_);
+       void started_data_sweep();
+       void ended_data_sweep();
+       void started_code_sweep();
+       void ended_code_sweep();
+       void started_compaction();
+       void ended_compaction();
+       void ended_gc(factor_vm *parent);
 };
 
 struct gc_state {
        gc_op op;
        u64 start_time;
         jmp_buf gc_unwind;
+       gc_event *event;
 
-       explicit gc_state(gc_op op_);
+       explicit gc_state(gc_op op_, factor_vm *parent);
        ~gc_state();
+       void start_again(gc_op op_, factor_vm *parent);
 };
 
-VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *parent);
+VM_C_API void inline_gc(cell *data_roots_base, cell data_roots_size, factor_vm *parent);
 
 }
index 0ba6d11da2bba6badf46585da898646fde4c0862..f45785f9ef69d45e10ebb546bc8eeebbd81b0c4f 100755 (executable)
@@ -1,7 +1,7 @@
 namespace factor
 {
 
-template<typename Array> cell array_capacity(Array *array)
+template<typename Array> cell array_capacity(const Array *array)
 {
 #ifdef FACTOR_DEBUG
        assert(array->h.hi_tag() == Array::type_number);
@@ -19,7 +19,7 @@ template<typename Array> cell array_size(Array *array)
        return array_size<Array>(array_capacity(array));
 }
 
-template<typename Array> Array *factor_vm::allot_array_internal(cell capacity)
+template<typename Array> Array *factor_vm::allot_uninitialized_array(cell capacity)
 {
        Array *array = allot<Array>(array_size<Array>(capacity));
        array->capacity = tag_fixnum(capacity);
@@ -33,7 +33,7 @@ template<typename Array> bool factor_vm::reallot_array_in_place_p(Array *array,
 
 template<typename Array> Array *factor_vm::reallot_array(Array *array_, cell capacity)
 {
-       gc_root<Array> array(array_,this);
+       data_root<Array> array(array_,this);
 
        if(reallot_array_in_place_p(array.untagged(),capacity))
        {
@@ -46,7 +46,7 @@ template<typename Array> Array *factor_vm::reallot_array(Array *array_, cell cap
                if(capacity < to_copy)
                        to_copy = capacity;
 
-               Array *new_array = allot_array_internal<Array>(capacity);
+               Array *new_array = allot_uninitialized_array<Array>(capacity);
 
                memcpy(new_array + 1,array.untagged() + 1,to_copy * Array::element_size);
                memset((char *)(new_array + 1) + to_copy * Array::element_size,
diff --git a/vm/heap.cpp b/vm/heap.cpp
deleted file mode 100644 (file)
index 71aac62..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-#include "master.hpp"
-
-/* This malloc-style heap code is reasonably generic. Maybe in the future, it
-will be used for the data heap too, if we ever get mark/sweep/compact GC. */
-
-namespace factor
-{
-
-void heap::clear_free_list()
-{
-       memset(&free,0,sizeof(heap_free_list));
-}
-
-heap::heap(bool secure_gc_, cell size, bool executable_p) : secure_gc(secure_gc_)
-{
-       if(size > (1L << (sizeof(cell) * 8 - 6))) fatal_error("Heap too large",size);
-       seg = new segment(align_page(size),executable_p);
-       if(!seg) fatal_error("Out of memory in heap allocator",size);
-       state = new mark_bits<heap_block,block_size_increment>(seg->start,size);
-       clear_free_list();
-}
-
-heap::~heap()
-{
-       delete seg;
-       seg = NULL;
-       delete state;
-       state = NULL;
-}
-
-void heap::add_to_free_list(free_heap_block *block)
-{
-       if(block->size() < free_list_count * block_size_increment)
-       {
-               int index = block->size() / block_size_increment;
-               block->next_free = free.small_blocks[index];
-               free.small_blocks[index] = block;
-       }
-       else
-       {
-               block->next_free = free.large_blocks;
-               free.large_blocks = block;
-       }
-}
-
-/* Called after reading the code heap from the image file, and after code heap
-compaction. Makes a free list consisting of one free block, at the very end. */
-void heap::build_free_list(cell size)
-{
-       clear_free_list();
-       free_heap_block *end = (free_heap_block *)(seg->start + size);
-       end->set_type(FREE_BLOCK_TYPE);
-       end->set_size(seg->end - (cell)end);
-       add_to_free_list(end);
-}
-
-void heap::assert_free_block(free_heap_block *block)
-{
-       if(block->type() != FREE_BLOCK_TYPE)
-               critical_error("Invalid block in free list",(cell)block);
-}
-
-free_heap_block *heap::find_free_block(cell size)
-{
-       cell attempt = size;
-
-       while(attempt < free_list_count * block_size_increment)
-       {
-               int index = attempt / block_size_increment;
-               free_heap_block *block = free.small_blocks[index];
-               if(block)
-               {
-                       assert_free_block(block);
-                       free.small_blocks[index] = block->next_free;
-                       return block;
-               }
-
-               attempt *= 2;
-       }
-
-       free_heap_block *prev = NULL;
-       free_heap_block *block = free.large_blocks;
-
-       while(block)
-       {
-               assert_free_block(block);
-               if(block->size() >= size)
-               {
-                       if(prev)
-                               prev->next_free = block->next_free;
-                       else
-                               free.large_blocks = block->next_free;
-                       return block;
-               }
-
-               prev = block;
-               block = block->next_free;
-       }
-
-       return NULL;
-}
-
-free_heap_block *heap::split_free_block(free_heap_block *block, cell size)
-{
-       if(block->size() != size )
-       {
-               /* split the block in two */
-               free_heap_block *split = (free_heap_block *)((cell)block + size);
-               split->set_type(FREE_BLOCK_TYPE);
-               split->set_size(block->size() - size);
-               split->next_free = block->next_free;
-               block->set_size(size);
-               add_to_free_list(split);
-       }
-
-       return block;
-}
-
-/* Allocate a block of memory from the mark and sweep GC heap */
-heap_block *heap::heap_allot(cell size, cell type)
-{
-       size = (size + block_size_increment - 1) & ~(block_size_increment - 1);
-
-       free_heap_block *block = find_free_block(size);
-       if(block)
-       {
-               block = split_free_block(block,size);
-               block->set_type(type);
-               return block;
-       }
-       else
-               return NULL;
-}
-
-/* Deallocates a block manually */
-void heap::heap_free(heap_block *block)
-{
-       block->set_type(FREE_BLOCK_TYPE);
-       add_to_free_list((free_heap_block *)block);
-}
-
-void heap::mark_block(heap_block *block)
-{
-       state->set_marked_p(block,true);
-}
-
-/* Compute total sum of sizes of free blocks, and size of largest free block */
-void heap::heap_usage(cell *used, cell *total_free, cell *max_free)
-{
-       *used = 0;
-       *total_free = 0;
-       *max_free = 0;
-
-       heap_block *scan = first_block();
-
-       while(scan)
-       {
-               cell size = scan->size();
-
-               if(scan->type() == FREE_BLOCK_TYPE)
-               {
-                       *total_free += size;
-                       if(size > *max_free)
-                               *max_free = size;
-               }
-               else
-                       *used += size;
-
-               scan = next_block(scan);
-       }
-}
-
-/* The size of the heap after compaction */
-cell heap::heap_size()
-{
-       heap_block *scan = first_block();
-       
-       while(scan)
-       {
-               if(scan->type() == FREE_BLOCK_TYPE) break;
-               else scan = next_block(scan);
-       }
-
-       assert(scan->type() == FREE_BLOCK_TYPE);
-       assert((cell)scan + scan->size() == seg->end);
-
-       return (cell)scan - (cell)first_block();
-}
-
-void heap::compact_heap()
-{
-       forwarding.clear();
-
-       heap_block *scan = first_block();
-       char *address = (char *)scan;
-
-       /* Slide blocks up while building the forwarding hashtable. */
-       while(scan)
-       {
-               heap_block *next = next_block(scan);
-               if(state->is_marked_p(scan))
-               {
-                       cell size = scan->size();
-                       memmove(address,scan,size);
-                       forwarding[scan] = address;
-                       address += size;
-               }
-
-               scan = next;
-       }
-
-       /* Now update the free list; there will be a single free block at
-       the end */
-       build_free_list((cell)address - seg->start);
-}
-
-heap_block *heap::free_allocated(heap_block *prev, heap_block *scan)
-{
-       if(secure_gc)
-               memset(scan + 1,0,scan->size() - sizeof(heap_block));
-
-       if(prev && prev->type() == FREE_BLOCK_TYPE)
-       {
-               prev->set_size(prev->size() + scan->size());
-               return prev;
-       }
-       else
-       {
-               scan->set_type(FREE_BLOCK_TYPE);
-               return scan;
-       }
-}
-
-}
diff --git a/vm/heap.hpp b/vm/heap.hpp
deleted file mode 100644 (file)
index a3c0571..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-namespace factor
-{
-
-static const cell free_list_count = 32;
-static const cell block_size_increment = 16;
-
-struct heap_free_list {
-       free_heap_block *small_blocks[free_list_count];
-       free_heap_block *large_blocks;
-};
-
-struct heap {
-       bool secure_gc;
-       segment *seg;
-       heap_free_list free;
-       mark_bits<heap_block,block_size_increment> *state;
-       unordered_map<heap_block *, char *> forwarding;
-
-       explicit heap(bool secure_gc_, cell size, bool executable_p);
-       ~heap();
-
-       inline heap_block *next_block(heap_block *block)
-       {
-               cell next = ((cell)block + block->size());
-               if(next == seg->end)
-                       return NULL;
-               else
-                       return (heap_block *)next;
-       }
-       
-       inline heap_block *first_block()
-       {
-               return (heap_block *)seg->start;
-       }
-       
-       inline heap_block *last_block()
-       {
-               return (heap_block *)seg->end;
-       }
-
-       void clear_free_list();
-       void new_heap(cell size);
-       void add_to_free_list(free_heap_block *block);
-       void build_free_list(cell size);
-       void assert_free_block(free_heap_block *block);
-       free_heap_block *find_free_block(cell size);
-       free_heap_block *split_free_block(free_heap_block *block, cell size);
-       heap_block *heap_allot(cell size, cell type);
-       void heap_free(heap_block *block);
-       void mark_block(heap_block *block);
-       void heap_usage(cell *used, cell *total_free, cell *max_free);
-       cell heap_size();
-       void compact_heap();
-
-       heap_block *free_allocated(heap_block *prev, heap_block *scan);
-
-       /* After code GC, all referenced code blocks have status set to B_MARKED, so any
-       which are allocated and not marked can be reclaimed. */
-       template<typename Iterator> void free_unmarked(Iterator &iter)
-       {
-               clear_free_list();
-       
-               heap_block *prev = NULL;
-               heap_block *scan = first_block();
-       
-               while(scan)
-               {
-                       if(scan->type() == FREE_BLOCK_TYPE)
-                       {
-                               if(prev && prev->type() == FREE_BLOCK_TYPE)
-                                       prev->set_size(prev->size() + scan->size());
-                               else
-                                       prev = scan;
-                       }
-                       else if(state->is_marked_p(scan))
-                       {
-                               if(prev && prev->type() == FREE_BLOCK_TYPE)
-                                       add_to_free_list((free_heap_block *)prev);
-                               prev = scan;
-                               iter(scan);
-                       }
-                       else
-                               prev = free_allocated(prev,scan);
-
-                       scan = next_block(scan);
-               }
-
-               if(prev && prev->type() == FREE_BLOCK_TYPE)
-                       add_to_free_list((free_heap_block *)prev);
-       }
-};
-
-}
index c6d1ad7aca6ebb80572a0325dcd518ba20765288..db91b4f1ea2bc69a554283b51b51eef8579c71e7 100755 (executable)
@@ -6,7 +6,7 @@ namespace factor
 /* Certain special objects in the image are known to the runtime */
 void factor_vm::init_objects(image_header *h)
 {
-       memcpy(userenv,h->userenv,sizeof(userenv));
+       memcpy(special_objects,h->special_objects,sizeof(special_objects));
 
        true_object = h->true_object;
        bignum_zero = h->bignum_zero;
@@ -16,31 +16,22 @@ void factor_vm::init_objects(image_header *h)
 
 void factor_vm::load_data_heap(FILE *file, image_header *h, vm_parameters *p)
 {
-       cell good_size = h->data_size + (1 << 20);
-
-       if(good_size > p->tenured_size)
-               p->tenured_size = good_size;
+       p->tenured_size = std::max((h->data_size * 3) / 2,p->tenured_size);
 
        init_data_heap(p->young_size,
                p->aging_size,
-               p->tenured_size,
-               p->secure_gc);
-
-       clear_gc_stats();
+               p->tenured_size);
 
        fixnum bytes_read = fread((void*)data->tenured->start,1,h->data_size,file);
 
        if((cell)bytes_read != h->data_size)
        {
-               print_string("truncated image: ");
-               print_fixnum(bytes_read);
-               print_string(" bytes read, ");
-               print_cell(h->data_size);
-               print_string(" bytes expected\n");
+               std::cout << "truncated image: " << bytes_read << " bytes read, ";
+               std::cout << h->data_size << " bytes expected\n";
                fatal_error("load_data_heap failed",0);
        }
 
-       data->tenured->here = data->tenured->start + h->data_size;
+       data->tenured->initial_free_list(h->data_size);
 }
 
 void factor_vm::load_code_heap(FILE *file, image_header *h, vm_parameters *p)
@@ -52,19 +43,16 @@ void factor_vm::load_code_heap(FILE *file, image_header *h, vm_parameters *p)
 
        if(h->code_size != 0)
        {
-               size_t bytes_read = fread(code->first_block(),1,h->code_size,file);
+               size_t bytes_read = fread(code->allocator->first_block(),1,h->code_size,file);
                if(bytes_read != h->code_size)
                {
-                       print_string("truncated image: ");
-                       print_fixnum(bytes_read);
-                       print_string(" bytes read, ");
-                       print_cell(h->code_size);
-                       print_string(" bytes expected\n");
+                       std::cout << "truncated image: " << bytes_read << " bytes read, ";
+                       std::cout << h->code_size << " bytes expected\n";
                        fatal_error("load_code_heap failed",0);
                }
        }
 
-       code->build_free_list(h->code_size);
+       code->allocator->initial_free_list(h->code_size);
 }
 
 void factor_vm::data_fixup(cell *handle, cell data_relocation_base)
@@ -102,9 +90,12 @@ void factor_vm::fixup_quotation(quotation *quot, cell code_relocation_base)
                quot->xt = (void *)lazy_jit_compile;
 }
 
-void factor_vm::fixup_alien(alien *d)
+void factor_vm::fixup_alien(alien *ptr)
 {
-       if(!to_boolean(d->base)) d->expired = true_object;
+       if(!to_boolean(ptr->base))
+               ptr->expired = true_object;
+       else
+               ptr->update_address();
 }
 
 struct stack_frame_fixupper {
@@ -144,18 +135,18 @@ void factor_vm::relocate_object(object *object,
        cell data_relocation_base,
        cell code_relocation_base)
 {
-       cell hi_tag = object->h.hi_tag();
+       cell type = object->type();
        
        /* Tuple relocation is a bit trickier; we have to fix up the
-       layout object before we can get the tuple size, so do_slots is
+       layout object before we can get the tuple size, so each_slot is
        out of the question */
-       if(hi_tag == TUPLE_TYPE)
+       if(type == TUPLE_TYPE)
        {
                tuple *t = (tuple *)object;
                data_fixup(&t->layout,data_relocation_base);
 
                cell *scan = t->data();
-               cell *end = (cell *)((cell)object + untagged_object_size(object));
+               cell *end = (cell *)((cell)object + object->size());
 
                for(; scan < end; scan++)
                        data_fixup(scan,data_relocation_base);
@@ -163,9 +154,9 @@ void factor_vm::relocate_object(object *object,
        else
        {
                object_fixupper fixupper(this,data_relocation_base);
-               do_slots((cell)object,fixupper);
+               object->each_slot(fixupper);
 
-               switch(hi_tag)
+               switch(type)
                {
                case WORD_TYPE:
                        fixup_word((word *)object,code_relocation_base);
@@ -190,8 +181,8 @@ void factor_vm::relocate_object(object *object,
 where it is loaded, we need to fix up pointers in the image. */
 void factor_vm::relocate_data(cell data_relocation_base, cell code_relocation_base)
 {
-       for(cell i = 0; i < USER_ENV; i++)
-               data_fixup(&userenv[i],data_relocation_base);
+       for(cell i = 0; i < special_object_count; i++)
+               data_fixup(&special_objects[i],data_relocation_base);
 
        data_fixup(&true_object,data_relocation_base);
        data_fixup(&bignum_zero,data_relocation_base);
@@ -203,8 +194,8 @@ void factor_vm::relocate_data(cell data_relocation_base, cell code_relocation_ba
        while(obj)
        {
                relocate_object((object *)obj,data_relocation_base,code_relocation_base);
-               data->tenured->record_object_start_offset((object *)obj);
-               obj = data->tenured->next_object_after(this,obj);
+               data->tenured->starts.record_object_start_offset((object *)obj);
+               obj = data->tenured->next_object_after(obj);
        }
 }
 
@@ -222,10 +213,10 @@ struct code_block_fixupper {
        factor_vm *parent;
        cell data_relocation_base;
 
-       code_block_fixupper(factor_vm *parent_, cell data_relocation_base_) :
+       explicit code_block_fixupper(factor_vm *parent_, cell data_relocation_base_) :
                parent(parent_), data_relocation_base(data_relocation_base_) { }
 
-       void operator()(code_block *compiled)
+       void operator()(code_block *compiled, cell size)
        {
                parent->fixup_code_block(compiled,data_relocation_base);
        }
@@ -244,8 +235,8 @@ void factor_vm::load_image(vm_parameters *p)
        FILE *file = OPEN_READ(p->image_path);
        if(file == NULL)
        {
-               print_string("Cannot open image file: "); print_native_string(p->image_path); nl();
-               print_string(strerror(errno)); nl();
+               std::cout << "Cannot open image file: " << p->image_path << std::endl;
+               std::cout << strerror(errno) << std::endl;
                exit(1);
        }
 
@@ -270,7 +261,7 @@ void factor_vm::load_image(vm_parameters *p)
        relocate_code(h.data_relocation_base);
 
        /* Store image path name */
-       userenv[IMAGE_ENV] = allot_alien(false_object,(cell)p->image_path);
+       special_objects[OBJ_IMAGE] = allot_alien(false_object,(cell)p->image_path);
 }
 
 /* Save the current image to disk */
@@ -282,37 +273,35 @@ bool factor_vm::save_image(const vm_char *filename)
        file = OPEN_WRITE(filename);
        if(file == NULL)
        {
-               print_string("Cannot open image file: "); print_native_string(filename); nl();
-               print_string(strerror(errno)); nl();
+               std::cout << "Cannot open image file: " << filename << std::endl;
+               std::cout << strerror(errno) << std::endl;
                return false;
        }
 
        h.magic = image_magic;
        h.version = image_version;
        h.data_relocation_base = data->tenured->start;
-       h.data_size = data->tenured->here - data->tenured->start;
+       h.data_size = data->tenured->occupied_space();
        h.code_relocation_base = code->seg->start;
-       h.code_size = code->heap_size();
+       h.code_size = code->allocator->occupied_space();
 
        h.true_object = true_object;
        h.bignum_zero = bignum_zero;
        h.bignum_pos_one = bignum_pos_one;
        h.bignum_neg_one = bignum_neg_one;
 
-       for(cell i = 0; i < USER_ENV; i++)
-               h.userenv[i] = (save_env_p(i) ? userenv[i] : false_object);
+       for(cell i = 0; i < special_object_count; i++)
+               h.special_objects[i] = (save_env_p(i) ? special_objects[i] : false_object);
 
        bool ok = true;
 
        if(fwrite(&h,sizeof(image_header),1,file) != 1) ok = false;
        if(fwrite((void*)data->tenured->start,h.data_size,1,file) != 1) ok = false;
-       if(fwrite(code->first_block(),h.code_size,1,file) != 1) ok = false;
+       if(fwrite(code->allocator->first_block(),h.code_size,1,file) != 1) ok = false;
        if(fclose(file)) ok = false;
 
        if(!ok)
-       {
-               print_string("save-image failed: "); print_string(strerror(errno)); nl();
-       }
+               std::cout << "save-image failed: " << strerror(errno) << std::endl;
 
        return ok;
 }
@@ -322,7 +311,7 @@ void factor_vm::primitive_save_image()
        /* do a full GC to push everything into tenured space */
        primitive_compact_gc();
 
-       gc_root<byte_array> path(dpop(),this);
+       data_root<byte_array> path(dpop(),this);
        path.untag_check(this);
        save_image((vm_char *)(path.untagged() + 1));
 }
@@ -332,17 +321,16 @@ void factor_vm::primitive_save_image_and_exit()
        /* We unbox this before doing anything else. This is the only point
        where we might throw an error, so we have to throw an error here since
        later steps destroy the current image. */
-       gc_root<byte_array> path(dpop(),this);
+       data_root<byte_array> path(dpop(),this);
        path.untag_check(this);
 
-       /* strip out userenv data which is set on startup anyway */
-       for(cell i = 0; i < USER_ENV; i++)
-               if(!save_env_p(i)) userenv[i] = false_object;
+       /* strip out special_objects data which is set on startup anyway */
+       for(cell i = 0; i < special_object_count; i++)
+               if(!save_env_p(i)) special_objects[i] = false_object;
 
-       gc(collect_full_op,
+       gc(collect_compact_op,
                0, /* requested size */
-               false, /* discard objects only reachable from stacks */
-               true /* compact the code heap */);
+               false /* discard objects only reachable from stacks */);
 
        /* Save the image */
        if(save_image((vm_char *)(path.untagged() + 1)))
index 8a7080110ce2357f78b5cce14b8bf6542635dddc..cca0e9e378a548d0e81cc735e276f9c14c68c7e4 100755 (executable)
@@ -25,7 +25,7 @@ struct image_header {
        /* tagged pointer to bignum -1 */
        cell bignum_neg_one;
        /* Initial user environment */
-       cell userenv[USER_ENV];
+       cell special_objects[special_object_count];
 };
 
 struct vm_parameters {
@@ -34,7 +34,6 @@ struct vm_parameters {
        cell ds_size, rs_size;
        cell young_size, aging_size, tenured_size;
        cell code_size;
-       bool secure_gc;
        bool fep;
        bool console;
        bool signals;
index f6e756f758cc064e6981891c7967f1fcc08a89b2..469bb8bf2e8aa2e007e836fc60a5a5dcc63b21db 100755 (executable)
@@ -6,10 +6,6 @@ namespace factor
 void factor_vm::init_inline_caching(int max_size)
 {
        max_pic_size = max_size;
-       cold_call_to_ic_transitions = 0;
-       ic_to_pic_transitions = 0;
-       pic_to_mega_transitions = 0;
-       for(int i = 0; i < 4; i++) pic_counts[i] = 0;
 }
 
 void factor_vm::deallocate_inline_cache(cell return_address)
@@ -19,15 +15,9 @@ void factor_vm::deallocate_inline_cache(cell return_address)
        check_code_pointer((cell)old_xt);
 
        code_block *old_block = (code_block *)old_xt - 1;
-       cell old_type = old_block->type();
 
-#ifdef FACTOR_DEBUG
-       /* The call target was either another PIC,
-          or a compiled quotation (megamorphic stub) */
-       assert(old_type == PIC_TYPE || old_type == QUOTATION_TYPE);
-#endif
-
-       if(old_type == PIC_TYPE)
+       /* Free the old PIC since we know its unreachable */
+       if(old_block->pic_p())
                code->code_heap_free(old_block);
 }
 
@@ -35,50 +25,34 @@ void factor_vm::deallocate_inline_cache(cell return_address)
 it contains */
 cell factor_vm::determine_inline_cache_type(array *cache_entries)
 {
-       bool seen_hi_tag = false, seen_tuple = false;
+       bool seen_tuple = false;
 
        cell i;
        for(i = 0; i < array_capacity(cache_entries); i += 2)
        {
-               cell klass = array_nth(cache_entries,i);
-
                /* Is it a tuple layout? */
-               switch(TAG(klass))
+               if(TAG(array_nth(cache_entries,i)) == ARRAY_TYPE)
                {
-               case FIXNUM_TYPE:
-                       {
-                               fixnum type = untag_fixnum(klass);
-                               if(type >= HEADER_TYPE)
-                                       seen_hi_tag = true;
-                       }
-                       break;
-               case ARRAY_TYPE:
                        seen_tuple = true;
                        break;
-               default:
-                       critical_error("Expected a fixnum or array",klass);
-                       break;
                }
        }
 
-       if(seen_hi_tag && seen_tuple) return PIC_HI_TAG_TUPLE;
-       if(seen_hi_tag && !seen_tuple) return PIC_HI_TAG;
-       if(!seen_hi_tag && seen_tuple) return PIC_TUPLE;
-       if(!seen_hi_tag && !seen_tuple) return PIC_TAG;
-
-       critical_error("Oops",0);
-       return 0;
+       return seen_tuple ? PIC_TUPLE : PIC_TAG;
 }
 
 void factor_vm::update_pic_count(cell type)
 {
-       pic_counts[type - PIC_TAG]++;
+       if(type == PIC_TAG)
+               dispatch_stats.pic_tag_count++;
+       else
+               dispatch_stats.pic_tuple_count++;
 }
 
 struct inline_cache_jit : public jit {
        fixnum index;
 
-       explicit inline_cache_jit(cell generic_word_,factor_vm *vm) : jit(PIC_TYPE,generic_word_,vm) {};
+       explicit inline_cache_jit(cell generic_word_,factor_vm *vm) : jit(code_block_pic,generic_word_,vm) {};
 
        void emit_check(cell klass);
        void compile_inline_cache(fixnum index,
@@ -91,10 +65,10 @@ struct inline_cache_jit : public jit {
 void inline_cache_jit::emit_check(cell klass)
 {
        cell code_template;
-       if(TAG(klass) == FIXNUM_TYPE && untag_fixnum(klass) < HEADER_TYPE)
-               code_template = parent->userenv[PIC_CHECK_TAG];
+       if(TAG(klass) == FIXNUM_TYPE)
+               code_template = parent->special_objects[PIC_CHECK_TAG];
        else
-               code_template = parent->userenv[PIC_CHECK];
+               code_template = parent->special_objects[PIC_CHECK_TUPLE];
 
        emit_with(code_template,klass);
 }
@@ -107,9 +81,9 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
                                            cell cache_entries_,
                                            bool tail_call_p)
 {
-       gc_root<word> generic_word(generic_word_,parent);
-       gc_root<array> methods(methods_,parent);
-       gc_root<array> cache_entries(cache_entries_,parent);
+       data_root<word> generic_word(generic_word_,parent);
+       data_root<array> methods(methods_,parent);
+       data_root<array> cache_entries(cache_entries_,parent);
 
        cell inline_cache_type = parent->determine_inline_cache_type(cache_entries.untagged());
        parent->update_pic_count(inline_cache_type);
@@ -127,7 +101,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
 
                /* Yes? Jump to method */
                cell method = array_nth(cache_entries.untagged(),i + 1);
-               emit_with(parent->userenv[PIC_HIT],method);
+               emit_with(parent->special_objects[PIC_HIT],method);
        }
 
        /* Generate machine code to handle a cache miss, which ultimately results in
@@ -139,14 +113,18 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
        push(methods.value());
        push(tag_fixnum(index));
        push(cache_entries.value());
-       word_special(parent->userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
+       word_special(parent->special_objects[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
 }
 
-code_block *factor_vm::compile_inline_cache(fixnum index,cell generic_word_,cell methods_,cell cache_entries_,bool tail_call_p)
+code_block *factor_vm::compile_inline_cache(fixnum index,
+       cell generic_word_,
+       cell methods_,
+       cell cache_entries_,
+       bool tail_call_p)
 {
-       gc_root<word> generic_word(generic_word_,this);
-       gc_root<array> methods(methods_,this);
-       gc_root<array> cache_entries(cache_entries_,this);
+       data_root<word> generic_word(generic_word_,this);
+       data_root<array> methods(methods_,this);
+       data_root<array> cache_entries(cache_entries_,this);
 
        inline_cache_jit jit(generic_word.value(),this);
        jit.compile_inline_cache(index,
@@ -159,7 +137,7 @@ code_block *factor_vm::compile_inline_cache(fixnum index,cell generic_word_,cell
        return code;
 }
 
-/* A generic word's definition performs general method lookup. Allocates memory */
+/* A generic word's definition performs general method lookup. */
 void *factor_vm::megamorphic_call_stub(cell generic_word)
 {
        return untag<word>(generic_word)->xt;
@@ -173,12 +151,12 @@ cell factor_vm::inline_cache_size(cell cache_entries)
 /* Allocates memory */
 cell factor_vm::add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_)
 {
-       gc_root<array> cache_entries(cache_entries_,this);
-       gc_root<object> klass(klass_,this);
-       gc_root<word> method(method_,this);
+       data_root<array> cache_entries(cache_entries_,this);
+       data_root<object> klass(klass_,this);
+       data_root<word> method(method_,this);
 
        cell pic_size = array_capacity(cache_entries.untagged());
-       gc_root<array> new_cache_entries(reallot_array(cache_entries.untagged(),pic_size + 2),this);
+       data_root<array> new_cache_entries(reallot_array(cache_entries.untagged(),pic_size + 2),this);
        set_array_nth(new_cache_entries.untagged(),pic_size,klass.value());
        set_array_nth(new_cache_entries.untagged(),pic_size + 1,method.value());
        return new_cache_entries.value();
@@ -187,29 +165,34 @@ cell factor_vm::add_inline_cache_entry(cell cache_entries_, cell klass_, cell me
 void factor_vm::update_pic_transitions(cell pic_size)
 {
        if(pic_size == max_pic_size)
-               pic_to_mega_transitions++;
+               dispatch_stats.pic_to_mega_transitions++;
        else if(pic_size == 0)
-               cold_call_to_ic_transitions++;
+               dispatch_stats.cold_call_to_ic_transitions++;
        else if(pic_size == 1)
-               ic_to_pic_transitions++;
+               dispatch_stats.ic_to_pic_transitions++;
 }
 
-/* The cache_entries parameter is either f (on cold call site) or an array (on cache miss).
-Called from assembly with the actual return address */
-void *factor_vm::inline_cache_miss(cell return_address)
+/* The cache_entries parameter is empty (on cold call site) or has entries
+(on cache miss). Called from assembly with the actual return address.
+Compilation of the inline cache may trigger a GC, which may trigger a compaction;
+also, the block containing the return address may now be dead. Use a code_root
+to take care of the details. */
+void *factor_vm::inline_cache_miss(cell return_address_)
 {
-       check_code_pointer(return_address);
+       code_root return_address(return_address_,this);
+
+       check_code_pointer(return_address.value);
 
        /* Since each PIC is only referenced from a single call site,
           if the old call target was a PIC, we can deallocate it immediately,
           instead of leaving dead PICs around until the next GC. */
-       deallocate_inline_cache(return_address);
+       deallocate_inline_cache(return_address.value);
 
-       gc_root<array> cache_entries(dpop(),this);
+       data_root<array> cache_entries(dpop(),this);
        fixnum index = untag_fixnum(dpop());
-       gc_root<array> methods(dpop(),this);
-       gc_root<word> generic_word(dpop(),this);
-       gc_root<object> object(((cell *)ds)[-index],this);
+       data_root<array> methods(dpop(),this);
+       data_root<word> generic_word(dpop(),this);
+       data_root<object> object(((cell *)ds)[-index],this);
 
        void *xt;
 
@@ -224,7 +207,7 @@ void *factor_vm::inline_cache_miss(cell return_address)
                cell klass = object_class(object.value());
                cell method = lookup_method(object.value(),methods.value());
 
-               gc_root<array> new_cache_entries(add_inline_cache_entry(
+               data_root<array> new_cache_entries(add_inline_cache_entry(
                                                           cache_entries.value(),
                                                           klass,
                                                           method),this);
@@ -232,18 +215,21 @@ void *factor_vm::inline_cache_miss(cell return_address)
                                          generic_word.value(),
                                          methods.value(),
                                          new_cache_entries.value(),
-                                         tail_call_site_p(return_address))->xt();
+                                         tail_call_site_p(return_address.value))->xt();
        }
 
        /* Install the new stub. */
-       set_call_target(return_address,xt);
+       if(return_address.valid)
+       {
+               set_call_target(return_address.value,xt);
 
 #ifdef PIC_DEBUG
-       printf("Updated %s call site 0x%lx with 0x%lx\n",
-              tail_call_site_p(return_address) ? "tail" : "non-tail",
-              return_address,
-              (cell)xt);
+               std::cout << "Updated "
+                       << (tail_call_site_p(return_address) ? "tail" : "non-tail")
+                       << " call site 0x" << std::hex << return_address << std::dec
+                       << " with " << std::hex << (cell)xt << std::dec;
 #endif
+       }
 
        return xt;
 }
@@ -253,24 +239,4 @@ VM_C_API void *inline_cache_miss(cell return_address, factor_vm *parent)
        return parent->inline_cache_miss(return_address);
 }
 
-void factor_vm::primitive_reset_inline_cache_stats()
-{
-       cold_call_to_ic_transitions = ic_to_pic_transitions = pic_to_mega_transitions = 0;
-       cell i;
-       for(i = 0; i < 4; i++) pic_counts[i] = 0;
-}
-
-void factor_vm::primitive_inline_cache_stats()
-{
-       growable_array stats(this);
-       stats.add(allot_cell(cold_call_to_ic_transitions));
-       stats.add(allot_cell(ic_to_pic_transitions));
-       stats.add(allot_cell(pic_to_mega_transitions));
-       cell i;
-       for(i = 0; i < 4; i++)
-               stats.add(allot_cell(pic_counts[i]));
-       stats.trim();
-       dpush(stats.elements.value());
-}
-
 }
index d5cfc1745c23a63ae3f97eca4a9e8cf11bdf3480..a8f9cb6897f4507fb05ab931ab68ef071e43bb1a 100755 (executable)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -16,9 +16,9 @@ normal operation. */
 
 void factor_vm::init_c_io()
 {
-       userenv[STDIN_ENV] = allot_alien(false_object,(cell)stdin);
-       userenv[STDOUT_ENV] = allot_alien(false_object,(cell)stdout);
-       userenv[STDERR_ENV] = allot_alien(false_object,(cell)stderr);
+       special_objects[OBJ_STDIN] = allot_alien(false_object,(cell)stdin);
+       special_objects[OBJ_STDOUT] = allot_alien(false_object,(cell)stdout);
+       special_objects[OBJ_STDERR] = allot_alien(false_object,(cell)stderr);
 }
 
 void factor_vm::io_error()
@@ -33,8 +33,8 @@ void factor_vm::io_error()
 
 void factor_vm::primitive_fopen()
 {
-       gc_root<byte_array> mode(dpop(),this);
-       gc_root<byte_array> path(dpop(),this);
+       data_root<byte_array> mode(dpop(),this);
+       data_root<byte_array> path(dpop(),this);
        mode.untag_check(this);
        path.untag_check(this);
 
@@ -88,7 +88,7 @@ void factor_vm::primitive_fread()
                return;
        }
 
-       gc_root<byte_array> buf(allot_array_internal<byte_array>(size),this);
+       data_root<byte_array> buf(allot_uninitialized_array<byte_array>(size),this);
 
        for(;;)
        {
index ced487e659e0db593f2d40eb4f0d66c1dd3cf82e..e72e88bfdff70c6c45945cdbfc34bbfec1b32c49 100644 (file)
@@ -10,7 +10,7 @@ namespace factor
 - polymorphic inline caches (inline_cache.cpp) */
 
 /* Allocates memory */
-jit::jit(cell type_, cell owner_, factor_vm *vm)
+jit::jit(code_block_type type_, cell owner_, factor_vm *vm)
        : type(type_),
          owner(owner_,vm),
          code(vm),
@@ -24,7 +24,7 @@ jit::jit(cell type_, cell owner_, factor_vm *vm)
 
 void jit::emit_relocation(cell code_template_)
 {
-       gc_root<array> code_template(code_template_,parent);
+       data_root<array> code_template(code_template_,parent);
        cell capacity = array_capacity(code_template.untagged());
        for(cell i = 1; i < capacity; i += 3)
        {
@@ -43,11 +43,11 @@ void jit::emit_relocation(cell code_template_)
 /* Allocates memory */
 void jit::emit(cell code_template_)
 {
-       gc_root<array> code_template(code_template_,parent);
+       data_root<array> code_template(code_template_,parent);
 
        emit_relocation(code_template.value());
 
-       gc_root<byte_array> insns(array_nth(code_template.untagged(),0),parent);
+       data_root<byte_array> insns(array_nth(code_template.untagged(),0),parent);
 
        if(computing_offset_p)
        {
@@ -71,16 +71,16 @@ void jit::emit(cell code_template_)
 }
 
 void jit::emit_with(cell code_template_, cell argument_) {
-       gc_root<array> code_template(code_template_,parent);
-       gc_root<object> argument(argument_,parent);
+       data_root<array> code_template(code_template_,parent);
+       data_root<object> argument(argument_,parent);
        literal(argument.value());
        emit(code_template.value());
 }
 
 void jit::emit_class_lookup(fixnum index, cell type)
 {
-       emit_with(parent->userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
-       emit(parent->userenv[type]);
+       emit_with(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
+       emit(parent->special_objects[type]);
 }
 
 /* Facility to convert compiled code offsets to quotation offsets.
index d69f44d05d035002c59e36c6b5b2d99ba53d5b70..b5a2457d570b4495ecc10b904b96e6d8dd13d082 100644 (file)
@@ -2,8 +2,8 @@ namespace factor
 {
 
 struct jit {
-       cell type;
-       gc_root<object> owner;
+       code_block_type type;
+       data_root<object> owner;
        growable_byte_array code;
        growable_byte_array relocation;
        growable_array literals;
@@ -12,7 +12,7 @@ struct jit {
        cell offset;
        factor_vm *parent;
 
-       explicit jit(cell jit_type, cell owner, factor_vm *vm);
+       explicit jit(code_block_type type, cell owner, factor_vm *parent);
        void compute_position(cell offset);
 
        void emit_relocation(cell code_template);
@@ -21,35 +21,41 @@ struct jit {
        void literal(cell literal) { literals.add(literal); }
        void emit_with(cell code_template_, cell literal_);
 
-       void push(cell literal) {
-               emit_with(parent->userenv[JIT_PUSH_IMMEDIATE],literal);
+       void push(cell literal)
+       {
+               emit_with(parent->special_objects[JIT_PUSH_IMMEDIATE],literal);
        }
 
-       void word_jump(cell word_) {
-               gc_root<word> word(word_,parent);
+       void word_jump(cell word_)
+       {
+               data_root<word> word(word_,parent);
                literal(tag_fixnum(xt_tail_pic_offset));
                literal(word.value());
-               emit(parent->userenv[JIT_WORD_JUMP]);
+               emit(parent->special_objects[JIT_WORD_JUMP]);
        }
 
-       void word_call(cell word) {
-               emit_with(parent->userenv[JIT_WORD_CALL],word);
+       void word_call(cell word)
+       {
+               emit_with(parent->special_objects[JIT_WORD_CALL],word);
        }
 
-       void word_special(cell word) {
-               emit_with(parent->userenv[JIT_WORD_SPECIAL],word);
+       void word_special(cell word)
+       {
+               emit_with(parent->special_objects[JIT_WORD_SPECIAL],word);
        }
 
-       void emit_subprimitive(cell word_) {
-               gc_root<word> word(word_,parent);
-               gc_root<array> code_pair(word->subprimitive,parent);
-               literals.append(parent->untag<array>(array_nth(code_pair.untagged(),0)));
+       void emit_subprimitive(cell word_)
+       {
+               data_root<word> word(word_,parent);
+               data_root<array> code_pair(word->subprimitive,parent);
+               literals.append(untag<array>(array_nth(code_pair.untagged(),0)));
                emit(array_nth(code_pair.untagged(),1));
        }
 
        void emit_class_lookup(fixnum index, cell type);
 
-       fixnum get_position() {
+       fixnum get_position()
+       {
                if(computing_offset_p)
                {
                        /* If this is still on, emit() didn't clear it,
@@ -60,7 +66,8 @@ struct jit {
                        return position;
        }
 
-        void set_position(fixnum position_) {
+        void set_position(fixnum position_)
+       {
                if(computing_offset_p)
                        position = position_;
        }
index 34dbe163f93efa64f25182fe0d90ae522a65c705..048c9c460f072e42d89a60b354772f246d0fc76c 100644 (file)
@@ -23,47 +23,41 @@ inline static cell align(cell a, cell b)
        return (a + (b-1)) & ~(b-1);
 }
 
-inline static cell align8(cell a)
-{
-       return align(a,8);
-}
+static const cell data_alignment = 16;
 
 #define WORD_SIZE (signed)(sizeof(cell)*8)
 
-#define TAG_MASK 7
-#define TAG_BITS 3
+#define TAG_MASK 15
+#define TAG_BITS 4
 #define TAG(x) ((cell)(x) & TAG_MASK)
 #define UNTAG(x) ((cell)(x) & ~TAG_MASK)
 #define RETAG(x,tag) (UNTAG(x) | (tag))
 
 /*** Tags ***/
 #define FIXNUM_TYPE 0
-#define BIGNUM_TYPE 1
+#define F_TYPE 1
 #define ARRAY_TYPE 2
 #define FLOAT_TYPE 3
 #define QUOTATION_TYPE 4
-#define F_TYPE 5
-#define OBJECT_TYPE 6
+#define BIGNUM_TYPE 5
+#define ALIEN_TYPE 6
 #define TUPLE_TYPE 7
-
-#define HEADER_TYPE 8 /* anything less than this is a tag */
-
-#define GC_COLLECTED 5 /* can be anything other than FIXNUM_TYPE */
-
-/*** Header types ***/
 #define WRAPPER_TYPE 8
 #define BYTE_ARRAY_TYPE 9
 #define CALLSTACK_TYPE 10
 #define STRING_TYPE 11
 #define WORD_TYPE 12
 #define DLL_TYPE 13
-#define ALIEN_TYPE 14
 
-#define TYPE_COUNT 15
+#define TYPE_COUNT 14
 
-/* Not real types, but code_block's type can be set to this */
-#define PIC_TYPE 16
-#define FREE_BLOCK_TYPE 17
+enum code_block_type
+{
+       code_block_unoptimized,
+       code_block_optimized,
+       code_block_profiling,
+       code_block_pic
+};
 
 /* Constants used when floating-point trap exceptions are thrown */
 enum
@@ -80,7 +74,8 @@ static const cell false_object = F_TYPE;
 
 inline static bool immediate_p(cell obj)
 {
-       return (obj == false_object || TAG(obj) == FIXNUM_TYPE);
+       /* We assume that fixnums have tag 0 and false_object has tag 1 */
+       return TAG(obj) <= F_TYPE;
 }
 
 inline static fixnum untag_fixnum(cell tagged)
@@ -96,51 +91,62 @@ inline static cell tag_fixnum(fixnum untagged)
        return RETAG(untagged << TAG_BITS,FIXNUM_TYPE);
 }
 
-inline static cell tag_for(cell type)
-{
-       return type < HEADER_TYPE ? type : OBJECT_TYPE;
-}
-
 struct object;
 
-struct header {
-       cell value;
+#define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
+
+struct object {
+       NO_TYPE_CHECK;
+       cell header;
 
-        /* Default ctor to make gcc 3.x happy */
-        explicit header() { abort(); }
+       cell size() const;
+       cell binary_payload_start() const;
 
-       explicit header(cell value_) : value(value_ << TAG_BITS) {}
+       cell *slots() const { return (cell *)this; }
 
-       void check_header() {
-#ifdef FACTOR_DEBUG
-               assert(TAG(value) == FIXNUM_TYPE && untag_fixnum(value) < TYPE_COUNT);
-#endif
+       template<typename Iterator> void each_slot(Iterator &iter);
+
+       /* Only valid for objects in tenured space; must cast to free_heap_block
+       to do anything with it if its free */
+       bool free_p() const
+       {
+               return (header & 1) == 1;
        }
 
-       cell hi_tag() {
-               check_header();
-               return value >> TAG_BITS;
+       cell type() const
+       {
+               return (header >> 2) & TAG_MASK;
        }
 
-       bool forwarding_pointer_p() {
-               return TAG(value) == GC_COLLECTED;
+       void initialize(cell type)
+       {
+               header = type << 2;
        }
 
-       object *forwarding_pointer() {
-               return (object *)UNTAG(value);
+       cell hashcode() const
+       {
+               return (header >> 6);
        }
 
-       void forward_to(object *pointer) {
-               value = RETAG(pointer,GC_COLLECTED);
+       void set_hashcode(cell hashcode)
+       {
+               header = (header & 0x3f) | (hashcode << 6);
        }
-};
 
-#define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
+       bool forwarding_pointer_p() const
+       {
+               return (header & 2) == 2;
+       }
 
-struct object {
-       NO_TYPE_CHECK;
-       header h;
-       cell *slots() { return (cell *)this; }
+       object *forwarding_pointer() const
+       {
+               return (object *)UNTAG(header);
+       }
+
+       void forward_to(object *pointer)
+       {
+               header = ((cell)pointer | 2);
+       }
 };
 
 /* Assembly code makes assumptions about the layout of this struct */
@@ -150,7 +156,7 @@ struct array : public object {
        /* tagged */
        cell capacity;
 
-       cell *data() { return (cell *)(this + 1); }
+       cell *data() const { return (cell *)(this + 1); }
 };
 
 /* These are really just arrays, but certain elements have special
@@ -171,7 +177,7 @@ struct bignum : public object {
        /* tagged */
        cell capacity;
 
-       cell *data() { return (cell *)(this + 1); }
+       cell *data() const { return (cell *)(this + 1); }
 };
 
 struct byte_array : public object {
@@ -180,7 +186,12 @@ struct byte_array : public object {
        /* tagged */
        cell capacity;
 
-       template<typename Scalar> Scalar *data() { return (Scalar *)(this + 1); }
+#ifndef FACTOR_64
+       cell padding0;
+       cell padding1;
+#endif
+
+       template<typename Scalar> Scalar *data() const { return (Scalar *)(this + 1); }
 };
 
 /* Assembly code makes assumptions about the layout of this struct */
@@ -193,39 +204,53 @@ struct string : public object {
        /* tagged */
        cell hashcode;
 
-       u8 *data() { return (u8 *)(this + 1); }
+       u8 *data() const { return (u8 *)(this + 1); }
+
+       cell nth(cell i) const;
 };
 
 /* The compiled code heap is structured into blocks. */
-struct heap_block
+struct code_block
 {
        cell header;
+       cell owner; /* tagged pointer to word, quotation or f */
+       cell literals; /* tagged pointer to array or f */
+       cell relocation; /* tagged pointer to byte-array or f */
 
-       cell type() { return (header >> 1) & 0x1f; }
-       void set_type(cell type)
+       bool free_p() const
        {
-               header = ((header & ~(0x1f << 1)) | (type << 1));
+               return (header & 1) == 1;
        }
 
-       cell size() { return (header >> 6); }
-       void set_size(cell size)
+       code_block_type type() const
        {
-               header = (header & 0x2f) | (size << 6);
+               return (code_block_type)((header >> 1) & 0x3);
        }
-};
 
-struct free_heap_block : public heap_block
-{
-       free_heap_block *next_free;
-};
+       void set_type(code_block_type type)
+       {
+               header = ((header & ~0x7) | (type << 1));
+       }
 
-struct code_block : public heap_block
-{
-       cell owner; /* tagged pointer to word, quotation or f */
-       cell literals; /* tagged pointer to array or f */
-       cell relocation; /* tagged pointer to byte-array or f */
+       bool pic_p() const
+       {
+               return type() == code_block_pic;
+       }
 
-       void *xt() { return (void *)(this + 1); }
+       bool optimized_p() const
+       {
+               return type() == code_block_optimized;
+       }
+
+       cell size() const
+       {
+               return header & ~7;
+       }
+
+       void *xt() const
+       {
+               return (void *)(this + 1);
+       }
 };
 
 /* Assembly code makes assumptions about the layout of this struct */
@@ -298,6 +323,16 @@ struct alien : public object {
        cell expired;
        /* untagged */
        cell displacement;
+       /* untagged */
+       cell address;
+
+       void update_address()
+       {
+               if(base == false_object)
+                       address = displacement;
+               else
+                       address = UNTAG(base) + sizeof(byte_array) + displacement;
+       }
 };
 
 struct dll : public object {
@@ -308,8 +343,7 @@ struct dll : public object {
        void *dll;
 };
 
-struct stack_frame
-{
+struct stack_frame {
        void *xt;
        /* Frame size in bytes */
        cell size;
@@ -320,13 +354,13 @@ struct callstack : public object {
        /* tagged */
        cell length;
        
-       stack_frame *frame_at(cell offset)
+       stack_frame *frame_at(cell offset) const
        {
                return (stack_frame *)((char *)(this + 1) + offset);
        }
 
-       stack_frame *top() { return (stack_frame *)(this + 1); }
-       stack_frame *bottom() { return (stack_frame *)((cell)(this + 1) + untag_fixnum(length)); }
+       stack_frame *top() const { return (stack_frame *)(this + 1); }
+       stack_frame *bottom() const { return (stack_frame *)((cell)(this + 1) + untag_fixnum(length)); }
 };
 
 struct tuple : public object {
@@ -334,7 +368,15 @@ struct tuple : public object {
        /* tagged layout */
        cell layout;
 
-       cell *data() { return (cell *)(this + 1); }
+       cell *data() const { return (cell *)(this + 1); }
+};
+
+struct data_root_range {
+       cell *start;
+       cell len;
+
+       explicit data_root_range(cell *start_, cell len_) :
+               start(start_), len(len_) {}
 };
 
 }
diff --git a/vm/local_roots.hpp b/vm/local_roots.hpp
deleted file mode 100644 (file)
index 6ae059f..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-namespace factor
-{
-
-template<typename Type>
-struct gc_root : public tagged<Type>
-{
-       factor_vm *parent;
-
-       void push() { parent->check_tagged_pointer(tagged<Type>::value()); parent->gc_locals.push_back((cell)this); }
-       
-       explicit gc_root(cell value_,factor_vm *vm) : tagged<Type>(value_),parent(vm) { push(); }
-       explicit gc_root(Type *value_, factor_vm *vm) : tagged<Type>(value_),parent(vm) { push(); }
-
-       const gc_root<Type>& operator=(const Type *x) { tagged<Type>::operator=(x); return *this; }
-       const gc_root<Type>& operator=(const cell &x) { tagged<Type>::operator=(x); return *this; }
-
-       ~gc_root() {
-#ifdef FACTOR_DEBUG
-               assert(parent->gc_locals.back() == (cell)this);
-#endif
-               parent->gc_locals.pop_back();
-       }
-};
-
-/* A similar hack for the bignum implementation */
-struct gc_bignum
-{
-       bignum **addr;
-       factor_vm *parent;
-       gc_bignum(bignum **addr_, factor_vm *vm) : addr(addr_), parent(vm) {
-               if(*addr_)
-                       parent->check_data_pointer(*addr_);
-               parent->gc_bignums.push_back((cell)addr);
-       }
-
-       ~gc_bignum() {
-#ifdef FACTOR_DEBUG
-               assert(parent->gc_bignums.back() == (cell)addr);
-#endif
-               parent->gc_bignums.pop_back();
-       }
-};
-
-#define GC_BIGNUM(x) gc_bignum x##__gc_root(&x,this)
-
-}
index 2d76b12c38701cd61f762498a8d237d4b317ec48..3fa7dcbf078c3aa9534a7b83eaa3a0472015d86b 100644 (file)
@@ -47,7 +47,7 @@ void factor_vm::call_fault_handler(
        else
                signal_callstack_top = NULL;
 
-       MACH_STACK_POINTER(thread_state) = fix_stack_pointer(MACH_STACK_POINTER(thread_state));
+       MACH_STACK_POINTER(thread_state) = align_stack_pointer(MACH_STACK_POINTER(thread_state));
 
        /* Now we point the program counter at the right handler function. */
        if(exception == EXC_BAD_ACCESS)
@@ -63,7 +63,13 @@ void factor_vm::call_fault_handler(
        }
        else
        {
-               signal_number = (exception == EXC_ARITHMETIC ? SIGFPE : SIGABRT);
+               switch(exception)
+               {
+               case EXC_ARITHMETIC: signal_number = SIGFPE; break;
+               case EXC_BAD_INSTRUCTION: signal_number = SIGILL; break;
+               default: signal_number = SIGABRT; break;
+               }
+
                MACH_PROGRAM_COUNTER(thread_state) = (cell)factor::misc_signal_handler_impl;
        }
 }
@@ -78,7 +84,7 @@ static void call_fault_handler(
 {
        THREADHANDLE thread_id = pthread_from_mach_thread_np(thread);
        assert(thread_id);
-       unordered_map<THREADHANDLE, factor_vm*>::const_iterator vm = thread_vms.find(thread_id);
+       std::map<THREADHANDLE, factor_vm*>::const_iterator vm = thread_vms.find(thread_id);
        if (vm != thread_vms.end())
            vm->second->call_fault_handler(exception,code,exc_state,thread_state,float_state);
 }
@@ -226,7 +232,7 @@ void mach_initialize ()
                fatal_error("mach_port_insert_right() failed",0);
 
        /* The exceptions we want to catch. */
-       mask = EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC;
+       mask = EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION | EXC_MASK_ARITHMETIC;
 
        /* Create the thread listening on the exception port.  */
        start_thread(mach_exception_thread,NULL);
index 7945be185063cf2f41962bf333c7470b66387bfd..d4b1dcda8dc341d03125a79bfe274304804b465d 100644 (file)
@@ -1,43 +1,35 @@
 namespace factor
 {
 
-const int forwarding_granularity = 128;
+const int block_granularity = 16;
+const int mark_bits_granularity = sizeof(cell) * 8;
+const int mark_bits_mask = sizeof(cell) * 8 - 1;
 
-template<typename Block, int Granularity> struct mark_bits {
-       cell start;
+template<typename Block> struct mark_bits {
        cell size;
+       cell start;
        cell bits_size;
-       unsigned int *marked;
-       unsigned int *freed;
-       cell forwarding_size;
+       cell *marked;
        cell *forwarding;
 
        void clear_mark_bits()
        {
-               memset(marked,0,bits_size * sizeof(unsigned int));
-       }
-
-       void clear_free_bits()
-       {
-               memset(freed,0,bits_size * sizeof(unsigned int));
+               memset(marked,0,bits_size * sizeof(cell));
        }
 
        void clear_forwarding()
        {
-               memset(forwarding,0,forwarding_size * sizeof(cell));
+               memset(forwarding,0,bits_size * sizeof(cell));
        }
 
-       explicit mark_bits(cell start_, cell size_) :
-               start(start_),
+       explicit mark_bits(cell size_, cell start_) :
                size(size_),
-               bits_size(size / Granularity / 32),
-               marked(new unsigned int[bits_size]),
-               freed(new unsigned int[bits_size]),
-               forwarding_size(size / Granularity / forwarding_granularity),
-               forwarding(new cell[forwarding_size])
+               start(start_),
+               bits_size(size / block_granularity / mark_bits_granularity),
+               marked(new cell[bits_size]),
+               forwarding(new cell[bits_size])
        {
                clear_mark_bits();
-               clear_free_bits();
                clear_forwarding();
        }
 
@@ -45,58 +37,169 @@ template<typename Block, int Granularity> struct mark_bits {
        {
                delete[] marked;
                marked = NULL;
-               delete[] freed;
-               freed = NULL;
                delete[] forwarding;
                forwarding = NULL;
        }
 
-       std::pair<cell,cell> bitmap_deref(Block *address)
+       cell block_line(Block *address)
        {
-               cell word_number = (((cell)address - start) / Granularity);
-               cell word_index = (word_number >> 5);
-               cell word_shift = (word_number & 31);
+               return (((cell)address - start) / block_granularity);
+       }
 
-#ifdef FACTOR_DEBUG
-               assert(word_index < bits_size);
-#endif
+       Block *line_block(cell line)
+       {
+               return (Block *)(line * block_granularity + start);
+       }
 
+       std::pair<cell,cell> bitmap_deref(Block *address)
+       {
+               cell line_number = block_line(address);
+               cell word_index = (line_number / mark_bits_granularity);
+               cell word_shift = (line_number & mark_bits_mask);
                return std::make_pair(word_index,word_shift);
        }
 
-       bool bitmap_elt(unsigned int *bits, Block *address)
+       bool bitmap_elt(cell *bits, Block *address)
+       {
+               std::pair<cell,cell> position = bitmap_deref(address);
+               return (bits[position.first] & ((cell)1 << position.second)) != 0;
+       }
+
+       Block *next_block_after(Block *block)
        {
-               std::pair<cell,cell> pair = bitmap_deref(address);
-               return (bits[pair.first] & (1 << pair.second)) != 0;
+               return (Block *)((cell)block + block->size());
        }
 
-       void set_bitmap_elt(unsigned int *bits, Block *address, bool flag)
+       void set_bitmap_range(cell *bits, Block *address)
        {
-               std::pair<cell,cell> pair = bitmap_deref(address);
-               if(flag)
-                       bits[pair.first] |= (1 << pair.second);
+               std::pair<cell,cell> start = bitmap_deref(address);
+               std::pair<cell,cell> end = bitmap_deref(next_block_after(address));
+
+               cell start_mask = ((cell)1 << start.second) - 1;
+               cell end_mask = ((cell)1 << end.second) - 1;
+
+               if(start.first == end.first)
+                       bits[start.first] |= start_mask ^ end_mask;
                else
-                       bits[pair.first] &= ~(1 << pair.second);
+               {
+#ifdef FACTOR_DEBUG
+                       assert(start.first < bits_size);
+#endif
+                       bits[start.first] |= ~start_mask;
+
+                       for(cell index = start.first + 1; index < end.first; index++)
+                               bits[index] = (cell)-1;
+
+                       if(end_mask != 0)
+                       {
+#ifdef FACTOR_DEBUG
+                               assert(end.first < bits_size);
+#endif
+                               bits[end.first] |= end_mask;
+                       }
+               }
        }
 
-       bool is_marked_p(Block *address)
+       bool marked_p(Block *address)
        {
                return bitmap_elt(marked,address);
        }
 
-       void set_marked_p(Block *address, bool marked_p)
+       void set_marked_p(Block *address)
+       {
+               set_bitmap_range(marked,address);
+       }
+
+       /* The eventual destination of a block after compaction is just the number
+       of marked blocks before it. Live blocks must be marked on entry. */
+       void compute_forwarding()
+       {
+               cell accum = 0;
+               for(cell index = 0; index < bits_size; index++)
+               {
+                       forwarding[index] = accum;
+                       accum += popcount(marked[index]);
+               }
+       }
+
+       /* We have the popcount for every mark_bits_granularity entries; look
+       up and compute the rest */
+       Block *forward_block(Block *original)
+       {
+#ifdef FACTOR_DEBUG
+               assert(marked_p(original));
+#endif
+               std::pair<cell,cell> position = bitmap_deref(original);
+
+               cell approx_popcount = forwarding[position.first];
+               cell mask = ((cell)1 << position.second) - 1;
+
+               cell new_line_number = approx_popcount + popcount(marked[position.first] & mask);
+               Block *new_block = line_block(new_line_number);
+#ifdef FACTOR_DEBUG
+               assert(new_block <= original);
+#endif
+               return new_block;
+       }
+
+       Block *next_unmarked_block_after(Block *original)
        {
-               set_bitmap_elt(marked,address,marked_p);
+               std::pair<cell,cell> position = bitmap_deref(original);
+               cell bit_index = position.second;
+
+               for(cell index = position.first; index < bits_size; index++)
+               {
+                       cell mask = ((fixnum)marked[index] >> bit_index);
+                       if(~mask)
+                       {
+                               /* Found an unmarked block on this page.
+                               Stop, it's hammer time */
+                               cell clear_bit = rightmost_clear_bit(mask);
+                               return line_block(index * mark_bits_granularity + bit_index + clear_bit);
+                       }
+                       else
+                       {
+                               /* No unmarked blocks on this page.
+                               Keep looking */
+                               bit_index = 0;
+                       }
+               }
+
+               /* No unmarked blocks were found */
+               return (Block *)(this->start + this->size);
        }
 
-       bool is_free_p(Block *address)
+       Block *next_marked_block_after(Block *original)
        {
-               return bitmap_elt(freed,address);
+               std::pair<cell,cell> position = bitmap_deref(original);
+               cell bit_index = position.second;
+
+               for(cell index = position.first; index < bits_size; index++)
+               {
+                       cell mask = (marked[index] >> bit_index);
+                       if(mask)
+                       {
+                               /* Found an marked block on this page.
+                               Stop, it's hammer time */
+                               cell set_bit = rightmost_set_bit(mask);
+                               return line_block(index * mark_bits_granularity + bit_index + set_bit);
+                       }
+                       else
+                       {
+                               /* No marked blocks on this page.
+                               Keep looking */
+                               bit_index = 0;
+                       }
+               }
+
+               /* No marked blocks were found */
+               return (Block *)(this->start + this->size);
        }
 
-       void set_free_p(Block *address, bool free_p)
+       cell unmarked_block_size(Block *original)
        {
-               set_bitmap_elt(freed,address,free_p);
+               Block *next_marked = next_marked_block_after(original);
+               return ((char *)next_marked - (char *)original);
        }
 };
 
index 847980fac679060e169189ed2f716c18db82b2b9..23c70782dfe8a30557b5d86b2fc8d82683c39ac5 100755 (executable)
 
 /* C++ headers */
 #include <algorithm>
+#include <map>
 #include <set>
 #include <vector>
-
-#if __GNUC__ == 4
-        #include <tr1/unordered_map>
-
-       namespace factor
-       {
-               using std::tr1::unordered_map;
-       }
-#elif __GNUC__ == 3
-        #include <boost/unordered_map.hpp>
-
-       namespace factor
-       {
-               using boost::unordered_map;
-       }
-#else
-        #error Factor requires GCC 3.x or later
-#endif
+#include <iostream>
 
 /* Forward-declare this since it comes up in function prototypes */
 namespace factor
@@ -60,17 +44,24 @@ namespace factor
 #include "segments.hpp"
 #include "contexts.hpp"
 #include "run.hpp"
+#include "objects.hpp"
 #include "profiler.hpp"
 #include "errors.hpp"
 #include "bignumint.hpp"
 #include "bignum.hpp"
 #include "code_block.hpp"
-#include "zone.hpp"
+#include "bump_allocator.hpp"
+#include "bitwise_hacks.hpp"
+#include "mark_bits.hpp"
+#include "free_list.hpp"
+#include "free_list_allocator.hpp"
 #include "write_barrier.hpp"
-#include "old_space.hpp"
+#include "object_start_map.hpp"
+#include "nursery_space.hpp"
 #include "aging_space.hpp"
 #include "tenured_space.hpp"
 #include "data_heap.hpp"
+#include "code_heap.hpp"
 #include "gc.hpp"
 #include "debug.hpp"
 #include "strings.hpp"
@@ -78,20 +69,23 @@ namespace factor
 #include "words.hpp"
 #include "float_bits.hpp"
 #include "io.hpp"
-#include "mark_bits.hpp"
-#include "heap.hpp"
 #include "image.hpp"
 #include "alien.hpp"
-#include "code_heap.hpp"
 #include "callbacks.hpp"
+#include "dispatch.hpp"
 #include "vm.hpp"
+#include "allot.hpp"
 #include "tagged.hpp"
-#include "local_roots.hpp"
+#include "data_roots.hpp"
+#include "code_roots.hpp"
+#include "slot_visitor.hpp"
 #include "collector.hpp"
 #include "copying_collector.hpp"
 #include "nursery_collector.hpp"
 #include "aging_collector.hpp"
 #include "to_tenured_collector.hpp"
+#include "code_block_visitor.hpp"
+#include "compaction.hpp"
 #include "full_collector.hpp"
 #include "callstack.hpp"
 #include "generic_arrays.hpp"
@@ -101,7 +95,6 @@ namespace factor
 #include "byte_arrays.hpp"
 #include "jit.hpp"
 #include "quotations.hpp"
-#include "dispatch.hpp"
 #include "inline_cache.hpp"
 #include "factor.hpp"
 #include "utilities.hpp"
index 169790d3653f529042eed579701b87a494ca1bd9..4266edc09c3dec40d5eee9bb3e617c4892ca2a2f 100755 (executable)
@@ -231,32 +231,18 @@ void factor_vm::primitive_byte_array_to_bignum()
        drepl(tag<bignum>(result));
 }
 
-cell factor_vm::unbox_array_size()
+cell factor_vm::unbox_array_size_slow()
 {
-       switch(tagged<object>(dpeek()).type())
+       if(tagged<object>(dpeek()).type() == BIGNUM_TYPE)
        {
-       case FIXNUM_TYPE:
-               {
-                       fixnum n = untag_fixnum(dpeek());
-                       if(n >= 0 && n < (fixnum)array_size_max)
-                       {
-                               dpop();
-                               return n;
-                       }
-                       break;
-               }
-       case BIGNUM_TYPE:
+               bignum *zero = untag<bignum>(bignum_zero);
+               bignum *max = cell_to_bignum(array_size_max);
+               bignum *n = untag<bignum>(dpeek());
+               if(bignum_compare(n,zero) != bignum_comparison_less
+                       && bignum_compare(n,max) == bignum_comparison_less)
                {
-                       bignum * zero = untag<bignum>(bignum_zero);
-                       bignum * max = cell_to_bignum(array_size_max);
-                       bignum * n = untag<bignum>(dpeek());
-                       if(bignum_compare(n,zero) != bignum_comparison_less
-                               && bignum_compare(n,max) == bignum_comparison_less)
-                       {
-                               dpop();
-                               return bignum_to_cell(n);
-                       }
-                       break;
+                       dpop();
+                       return bignum_to_cell(n);
                }
        }
 
@@ -393,7 +379,7 @@ fixnum factor_vm::to_fixnum(cell tagged)
        }
 }
 
-VM_C_API fixnum to_fixnum(cell tagged,factor_vm *parent)
+VM_C_API fixnum to_fixnum(cell tagged, factor_vm *parent)
 {
        return parent->to_fixnum(tagged);
 }
@@ -413,7 +399,7 @@ void factor_vm::box_signed_1(s8 n)
        dpush(tag_fixnum(n));
 }
 
-VM_C_API void box_signed_1(s8 n,factor_vm *parent)
+VM_C_API void box_signed_1(s8 n, factor_vm *parent)
 {
        return parent->box_signed_1(n);
 }
@@ -423,7 +409,7 @@ void factor_vm::box_unsigned_1(u8 n)
        dpush(tag_fixnum(n));
 }
 
-VM_C_API void box_unsigned_1(u8 n,factor_vm *parent)
+VM_C_API void box_unsigned_1(u8 n, factor_vm *parent)
 {
        return parent->box_unsigned_1(n);
 }
@@ -433,7 +419,7 @@ void factor_vm::box_signed_2(s16 n)
        dpush(tag_fixnum(n));
 }
 
-VM_C_API void box_signed_2(s16 n,factor_vm *parent)
+VM_C_API void box_signed_2(s16 n, factor_vm *parent)
 {
        return parent->box_signed_2(n);
 }
@@ -443,7 +429,7 @@ void factor_vm::box_unsigned_2(u16 n)
        dpush(tag_fixnum(n));
 }
 
-VM_C_API void box_unsigned_2(u16 n,factor_vm *parent)
+VM_C_API void box_unsigned_2(u16 n, factor_vm *parent)
 {
        return parent->box_unsigned_2(n);
 }
@@ -453,7 +439,7 @@ void factor_vm::box_signed_4(s32 n)
        dpush(allot_integer(n));
 }
 
-VM_C_API void box_signed_4(s32 n,factor_vm *parent)
+VM_C_API void box_signed_4(s32 n, factor_vm *parent)
 {
        return parent->box_signed_4(n);
 }
@@ -463,7 +449,7 @@ void factor_vm::box_unsigned_4(u32 n)
        dpush(allot_cell(n));
 }
 
-VM_C_API void box_unsigned_4(u32 n,factor_vm *parent)
+VM_C_API void box_unsigned_4(u32 n, factor_vm *parent)
 {
        return parent->box_unsigned_4(n);
 }
@@ -473,7 +459,7 @@ void factor_vm::box_signed_cell(fixnum integer)
        dpush(allot_integer(integer));
 }
 
-VM_C_API void box_signed_cell(fixnum integer,factor_vm *parent)
+VM_C_API void box_signed_cell(fixnum integer, factor_vm *parent)
 {
        return parent->box_signed_cell(integer);
 }
@@ -483,7 +469,7 @@ void factor_vm::box_unsigned_cell(cell cell)
        dpush(allot_cell(cell));
 }
 
-VM_C_API void box_unsigned_cell(cell cell,factor_vm *parent)
+VM_C_API void box_unsigned_cell(cell cell, factor_vm *parent)
 {
        return parent->box_unsigned_cell(cell);
 }
@@ -496,7 +482,7 @@ void factor_vm::box_signed_8(s64 n)
                dpush(tag_fixnum(n));
 }
 
-VM_C_API void box_signed_8(s64 n,factor_vm *parent)
+VM_C_API void box_signed_8(s64 n, factor_vm *parent)
 {
        return parent->box_signed_8(n);
 }
@@ -515,7 +501,7 @@ s64 factor_vm::to_signed_8(cell obj)
        }
 }
 
-VM_C_API s64 to_signed_8(cell obj,factor_vm *parent)
+VM_C_API s64 to_signed_8(cell obj, factor_vm *parent)
 {
        return parent->to_signed_8(obj);
 }
@@ -528,7 +514,7 @@ void factor_vm::box_unsigned_8(u64 n)
                dpush(tag_fixnum(n));
 }
 
-VM_C_API void box_unsigned_8(u64 n,factor_vm *parent)
+VM_C_API void box_unsigned_8(u64 n, factor_vm *parent)
 {
        return parent->box_unsigned_8(n);
 }
@@ -547,7 +533,7 @@ u64 factor_vm::to_unsigned_8(cell obj)
        }
 }
 
-VM_C_API u64 to_unsigned_8(cell obj,factor_vm *parent)
+VM_C_API u64 to_unsigned_8(cell obj, factor_vm *parent)
 {
        return parent->to_unsigned_8(obj);
 }
@@ -567,7 +553,7 @@ float factor_vm::to_float(cell value)
        return untag_float_check(value);
 }
 
-VM_C_API float to_float(cell value,factor_vm *parent)
+VM_C_API float to_float(cell value, factor_vm *parent)
 {
        return parent->to_float(value);
 }
@@ -577,7 +563,7 @@ void factor_vm::box_double(double flo)
         dpush(allot_float(flo));
 }
 
-VM_C_API void box_double(double flo,factor_vm *parent)
+VM_C_API void box_double(double flo, factor_vm *parent)
 {
        return parent->box_double(flo);
 }
@@ -587,7 +573,7 @@ double factor_vm::to_double(cell value)
        return untag_float_check(value);
 }
 
-VM_C_API double to_double(cell value,factor_vm *parent)
+VM_C_API double to_double(cell value, factor_vm *parent)
 {
        return parent->to_double(value);
 }
index 1f7eda26fa6d84e2a529319b1f06506cc921d8d8..2fed585f98075b597dba69a52ae7c7853d1af672 100644 (file)
@@ -58,7 +58,21 @@ inline double factor_vm::fixnum_to_float(cell tagged)
        return (double)untag_fixnum(tagged);
 }
 
-// defined in assembler
+inline cell factor_vm::unbox_array_size()
+{
+       cell obj = dpeek();
+       if(TAG(obj) == FIXNUM_TYPE)
+       {
+               fixnum n = untag_fixnum(obj);
+               if(n >= 0 && n < (fixnum)array_size_max)
+               {
+                       dpop();
+                       return n;
+               }
+       }
+
+       return unbox_array_size_slow();
+}
 
 VM_C_API void box_float(float flo, factor_vm *vm);
 VM_C_API float to_float(cell value, factor_vm *vm);
index 909cde02f8767dd764e47eba2ef6cbe0e5bab296..5eb77fd763009d396a9490cdf63632bd44410c72 100644 (file)
@@ -6,7 +6,6 @@ namespace factor
 nursery_collector::nursery_collector(factor_vm *parent_) :
        copying_collector<aging_space,nursery_policy>(
                parent_,
-               &parent_->gc_stats.nursery_stats,
                parent_->data->aging,
                nursery_policy(parent_)) {}
 
@@ -18,17 +17,30 @@ void factor_vm::collect_nursery()
 
        collector.trace_roots();
        collector.trace_contexts();
+
+       current_gc->event->started_card_scan();
        collector.trace_cards(data->tenured,
                card_points_to_nursery,
                simple_unmarker(card_points_to_nursery));
-       collector.trace_cards(data->aging,
-               card_points_to_nursery,
-               simple_unmarker(card_mark_mask));
+       if(data->aging->here != data->aging->start)
+       {
+               collector.trace_cards(data->aging,
+                       card_points_to_nursery,
+                       full_unmarker());
+       }
+       current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
+
+       current_gc->event->started_code_scan();
        collector.trace_code_heap_roots(&code->points_to_nursery);
+       current_gc->event->ended_code_scan(collector.code_blocks_scanned);
+
        collector.cheneys_algorithm();
+
+       current_gc->event->started_code_sweep();
        update_code_heap_for_minor_gc(&code->points_to_nursery);
+       current_gc->event->ended_code_sweep();
 
-       nursery.here = nursery.start;
+       data->reset_generation(&nursery);
        code->points_to_nursery.clear();
 }
 
index f9d21729299d5658674ab205b80063f820a9176c..de9b38d283f40038291bdd0fe5e2ece070026796 100644 (file)
@@ -4,16 +4,20 @@ namespace factor
 struct nursery_policy {
        factor_vm *parent;
 
-       nursery_policy(factor_vm *parent_) : parent(parent_) {}
+       explicit nursery_policy(factor_vm *parent_) : parent(parent_) {}
 
-       bool should_copy_p(object *untagged)
+       bool should_copy_p(object *obj)
        {
-               return parent->nursery.contains_p(untagged);
+               return parent->nursery.contains_p(obj);
        }
+
+       void promoted_object(object *obj) {}
+
+       void visited_object(object *obj) {}
 };
 
 struct nursery_collector : copying_collector<aging_space,nursery_policy> {
-       nursery_collector(factor_vm *parent_);
+       explicit nursery_collector(factor_vm *parent_);
 };
 
 }
diff --git a/vm/nursery_space.hpp b/vm/nursery_space.hpp
new file mode 100644 (file)
index 0000000..c44d2a8
--- /dev/null
@@ -0,0 +1,9 @@
+namespace factor
+{
+
+struct nursery_space : bump_allocator<object>
+{
+       explicit nursery_space(cell size, cell start) : bump_allocator<object>(size,start) {}
+};
+
+}
diff --git a/vm/object_start_map.cpp b/vm/object_start_map.cpp
new file mode 100644 (file)
index 0000000..3159313
--- /dev/null
@@ -0,0 +1,95 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+object_start_map::object_start_map(cell size_, cell start_) :
+       size(size_), start(start_)
+{
+       object_start_offsets = new card[addr_to_card(size_)];
+       object_start_offsets_end = object_start_offsets + addr_to_card(size_);
+       clear_object_start_offsets();
+}
+
+object_start_map::~object_start_map()
+{
+       delete[] object_start_offsets;
+}
+
+cell object_start_map::first_object_in_card(cell card_index)
+{
+       return object_start_offsets[card_index];
+}
+
+cell object_start_map::find_object_containing_card(cell card_index)
+{
+       if(card_index == 0)
+               return start;
+       else
+       {
+               card_index--;
+
+               while(first_object_in_card(card_index) == card_starts_inside_object)
+               {
+#ifdef FACTOR_DEBUG
+                       /* First card should start with an object */
+                       assert(card_index > 0);
+#endif
+                       card_index--;
+               }
+
+               return start + (card_index << card_bits) + first_object_in_card(card_index);
+       }
+}
+
+/* we need to remember the first object allocated in the card */
+void object_start_map::record_object_start_offset(object *obj)
+{
+       cell idx = addr_to_card((cell)obj - start);
+       card obj_start = ((cell)obj & addr_card_mask);
+       object_start_offsets[idx] = std::min(object_start_offsets[idx],obj_start);
+}
+
+void object_start_map::clear_object_start_offsets()
+{
+       memset(object_start_offsets,card_starts_inside_object,addr_to_card(size));
+}
+
+void object_start_map::update_card_for_sweep(cell index, u16 mask)
+{
+       cell offset = object_start_offsets[index];
+       if(offset != card_starts_inside_object)
+       {
+               mask >>= (offset / block_granularity);
+
+               if(mask == 0)
+               {
+                       /* The rest of the block after the old object start is free */
+                       object_start_offsets[index] = card_starts_inside_object;
+               }
+               else
+               {
+                       /* Move the object start forward if necessary */
+                       object_start_offsets[index] = offset + (rightmost_set_bit(mask) * block_granularity);
+               }
+       }
+}
+
+void object_start_map::update_for_sweep(mark_bits<object> *state)
+{
+       for(cell index = 0; index < state->bits_size; index++)
+       {
+               cell mask = state->marked[index];
+#ifdef FACTOR_64
+               update_card_for_sweep(index * 4,      mask        & 0xffff);
+               update_card_for_sweep(index * 4 + 1, (mask >> 16) & 0xffff);
+               update_card_for_sweep(index * 4 + 2, (mask >> 32) & 0xffff);
+               update_card_for_sweep(index * 4 + 3, (mask >> 48) & 0xffff);
+#else
+               update_card_for_sweep(index * 2,      mask        & 0xffff);
+               update_card_for_sweep(index * 2 + 1, (mask >> 16) & 0xffff);
+#endif
+       }
+}
+
+}
diff --git a/vm/object_start_map.hpp b/vm/object_start_map.hpp
new file mode 100644 (file)
index 0000000..a2e24ee
--- /dev/null
@@ -0,0 +1,22 @@
+namespace factor
+{
+
+static const cell card_starts_inside_object = 0xff;
+
+struct object_start_map {
+       cell size, start;
+       card *object_start_offsets;
+       card *object_start_offsets_end;
+
+       explicit object_start_map(cell size_, cell start_);
+       ~object_start_map();
+
+       cell first_object_in_card(cell card_index);
+       cell find_object_containing_card(cell card_index);
+       void record_object_start_offset(object *obj);
+       void clear_object_start_offsets();
+       void update_card_for_sweep(cell index, u16 mask);
+       void update_for_sweep(mark_bits<object> *state);
+};
+
+}
diff --git a/vm/objects.cpp b/vm/objects.cpp
new file mode 100644 (file)
index 0000000..b034eaf
--- /dev/null
@@ -0,0 +1,159 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+void factor_vm::primitive_special_object()
+{
+       fixnum e = untag_fixnum(dpeek());
+       drepl(special_objects[e]);
+}
+
+void factor_vm::primitive_set_special_object()
+{
+       fixnum e = untag_fixnum(dpop());
+       cell value = dpop();
+       special_objects[e] = value;
+}
+
+void factor_vm::primitive_identity_hashcode()
+{
+       cell tagged = dpeek();
+       object *obj = untag<object>(tagged);
+       drepl(tag_fixnum(obj->hashcode()));
+}
+
+void factor_vm::compute_identity_hashcode(object *obj)
+{
+       object_counter++;
+       if(object_counter == 0) object_counter++;
+       obj->set_hashcode((cell)obj ^ object_counter);
+}
+
+void factor_vm::primitive_compute_identity_hashcode()
+{
+       object *obj = untag<object>(dpop());
+       compute_identity_hashcode(obj);
+}
+
+void factor_vm::primitive_set_slot()
+{
+       fixnum slot = untag_fixnum(dpop());
+       object *obj = untag<object>(dpop());
+       cell value = dpop();
+
+       cell *slot_ptr = &obj->slots()[slot];
+       *slot_ptr = value;
+       write_barrier(slot_ptr);
+}
+
+cell factor_vm::clone_object(cell obj_)
+{
+       data_root<object> obj(obj_,this);
+
+       if(immediate_p(obj.value()))
+               return obj.value();
+       else
+       {
+               cell size = object_size(obj.value());
+               object *new_obj = allot_object(obj.type(),size);
+               memcpy(new_obj,obj.untagged(),size);
+               new_obj->set_hashcode(0);
+               return tag_dynamic(new_obj);
+       }
+}
+
+void factor_vm::primitive_clone()
+{
+       drepl(clone_object(dpeek()));
+}
+
+/* Size of the object pointed to by a tagged pointer */
+cell factor_vm::object_size(cell tagged)
+{
+       if(immediate_p(tagged))
+               return 0;
+       else
+               return untag<object>(tagged)->size();
+}
+
+void factor_vm::primitive_size()
+{
+       box_unsigned_cell(object_size(dpop()));
+}
+
+struct slot_become_visitor {
+       std::map<object *,object *> *become_map;
+
+       explicit slot_become_visitor(std::map<object *,object *> *become_map_) :
+               become_map(become_map_) {}
+
+       object *operator()(object *old)
+       {
+               std::map<object *,object *>::const_iterator iter = become_map->find(old);
+               if(iter != become_map->end())
+                       return iter->second;
+               else
+                       return old;
+       }
+};
+
+struct object_become_visitor {
+       slot_visitor<slot_become_visitor> *workhorse;
+
+       explicit object_become_visitor(slot_visitor<slot_become_visitor> *workhorse_) :
+               workhorse(workhorse_) {}
+
+       void operator()(object *obj)
+       {
+               workhorse->visit_slots(obj);
+       }
+};
+
+/* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
+   to coalesce equal but distinct quotations and wrappers. */
+void factor_vm::primitive_become()
+{
+       array *new_objects = untag_check<array>(dpop());
+       array *old_objects = untag_check<array>(dpop());
+
+       cell capacity = array_capacity(new_objects);
+       if(capacity != array_capacity(old_objects))
+               critical_error("bad parameters to become",0);
+
+       /* Build the forwarding map */
+       std::map<object *,object *> become_map;
+
+       for(cell i = 0; i < capacity; i++)
+       {
+               tagged<object> old_obj(array_nth(old_objects,i));
+               tagged<object> new_obj(array_nth(new_objects,i));
+
+               if(old_obj != new_obj)
+                       become_map[old_obj.untagged()] = new_obj.untagged();
+       }
+
+       /* Update all references to old objects to point to new objects */
+       slot_visitor<slot_become_visitor> workhorse(this,slot_become_visitor(&become_map));
+       workhorse.visit_roots();
+       workhorse.visit_contexts();
+
+       object_become_visitor object_visitor(&workhorse);
+       each_object(object_visitor);
+
+       /* Since we may have introduced old->new references, need to revisit
+       all objects on a minor GC. */
+       data->mark_all_cards();
+       primitive_minor_gc();
+
+       /* If a word's definition quotation was in old_objects and the
+          quotation in new_objects is not compiled, we might leak memory
+          by referencing the old quotation unless we recompile all
+          unoptimized words. */
+       compile_all_words();
+
+       /* Update references to old objects in the code heap */
+       update_code_heap_words_and_literals();
+}
+
+}
diff --git a/vm/objects.hpp b/vm/objects.hpp
new file mode 100644 (file)
index 0000000..3eb2fdc
--- /dev/null
@@ -0,0 +1,120 @@
+namespace factor
+{
+
+static const cell special_object_count = 70;
+
+enum special_object {
+       OBJ_NAMESTACK,            /* used by library only */
+       OBJ_CATCHSTACK,           /* used by library only, per-callback */
+
+       OBJ_CURRENT_CALLBACK = 2, /* used by library only, per-callback */
+       OBJ_WALKER_HOOK,          /* non-local exit hook, used by library only */
+       OBJ_CALLCC_1,             /* used to pass the value in callcc1 */
+
+       OBJ_BREAK            = 5, /* quotation called by throw primitive */
+       OBJ_ERROR,                /* a marker consed onto kernel errors */
+
+       OBJ_CELL_SIZE        = 7, /* sizeof(cell) */
+       OBJ_CPU,                  /* CPU architecture */
+       OBJ_OS,                   /* operating system name */
+
+       OBJ_ARGS            = 10, /* command line arguments */
+       OBJ_STDIN,                /* stdin FILE* handle */
+       OBJ_STDOUT,               /* stdout FILE* handle */
+
+       OBJ_IMAGE           = 13, /* image path name */
+       OBJ_EXECUTABLE,           /* runtime executable path name */
+
+       OBJ_EMBEDDED        = 15, /* are we embedded in another app? */
+       OBJ_EVAL_CALLBACK,        /* used when Factor is embedded in a C app */
+       OBJ_YIELD_CALLBACK,       /* used when Factor is embedded in a C app */
+       OBJ_SLEEP_CALLBACK,       /* used when Factor is embedded in a C app */
+
+       OBJ_COCOA_EXCEPTION = 19, /* Cocoa exception handler quotation */
+
+       OBJ_BOOT            = 20, /* boot quotation */
+       OBJ_GLOBAL,               /* global namespace */
+
+       /* Quotation compilation in quotations.c */
+       JIT_PROLOG          = 23,
+       JIT_PRIMITIVE_WORD,
+       JIT_PRIMITIVE,
+       JIT_WORD_JUMP,
+       JIT_WORD_CALL,
+       JIT_WORD_SPECIAL,
+       JIT_IF_WORD,
+       JIT_IF,
+       JIT_EPILOG,
+       JIT_RETURN,
+       JIT_PROFILING,
+       JIT_PUSH_IMMEDIATE,
+       JIT_DIP_WORD,
+       JIT_DIP,
+       JIT_2DIP_WORD,
+       JIT_2DIP,
+       JIT_3DIP_WORD,
+       JIT_3DIP,
+       JIT_EXECUTE_WORD,
+       JIT_EXECUTE_JUMP,
+       JIT_EXECUTE_CALL,
+       JIT_DECLARE_WORD,
+
+       /* Callback stub generation in callbacks.c */
+       CALLBACK_STUB       = 45,
+       
+       /* Incremented on every modify-code-heap call; invalidates call( inline
+       caching */
+       REDEFINITION_COUNTER = 46,
+
+       /* Polymorphic inline cache generation in inline_cache.c */
+       PIC_LOAD            = 47,
+       PIC_TAG,
+       PIC_TUPLE,
+       PIC_CHECK_TAG,
+       PIC_CHECK_TUPLE,
+       PIC_HIT,
+       PIC_MISS_WORD,
+       PIC_MISS_TAIL_WORD,
+
+       /* Megamorphic cache generation in dispatch.c */
+       MEGA_LOOKUP         = 57,
+       MEGA_LOOKUP_WORD,
+       MEGA_MISS_WORD,
+
+       OBJ_UNDEFINED       = 60, /* default quotation for undefined words */
+
+       OBJ_STDERR          = 61, /* stderr FILE* handle */
+
+       OBJ_STAGE2          = 62, /* have we bootstrapped? */
+
+       OBJ_CURRENT_THREAD  = 63,
+
+       OBJ_THREADS         = 64,
+       OBJ_RUN_QUEUE       = 65,
+       OBJ_SLEEP_QUEUE     = 66,
+};
+
+#define OBJ_FIRST_SAVE OBJ_BOOT
+#define OBJ_LAST_SAVE OBJ_STAGE2
+
+inline static bool save_env_p(cell i)
+{
+       return (i >= OBJ_FIRST_SAVE && i <= OBJ_LAST_SAVE);
+}
+
+template<typename Iterator> void object::each_slot(Iterator &iter)
+{
+       cell scan = (cell)this;
+       cell payload_start = binary_payload_start();
+       cell end = scan + payload_start;
+
+       scan += sizeof(cell);
+
+       while(scan < end)
+       {
+               iter((cell *)scan);
+               scan += sizeof(cell);
+       }
+}
+
+}
diff --git a/vm/old_space.cpp b/vm/old_space.cpp
deleted file mode 100644 (file)
index 5fd78a7..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "master.hpp"
-
-namespace factor
-{
-
-old_space::old_space(cell size_, cell start_) : zone(size_,start_)
-{
-       object_start_offsets = new card[addr_to_card(size_)];
-       object_start_offsets_end = object_start_offsets + addr_to_card(size_);
-}
-
-old_space::~old_space()
-{
-       delete[] object_start_offsets;
-}
-
-cell old_space::first_object_in_card(cell card_index)
-{
-       return object_start_offsets[card_index];
-}
-
-cell old_space::find_object_containing_card(cell card_index)
-{
-       if(card_index == 0)
-               return start;
-       else
-       {
-               card_index--;
-
-               while(first_object_in_card(card_index) == card_starts_inside_object)
-               {
-#ifdef FACTOR_DEBUG
-                       /* First card should start with an object */
-                       assert(card_index > 0);
-#endif
-                       card_index--;
-               }
-
-               return start + (card_index << card_bits) + first_object_in_card(card_index);
-       }
-}
-
-/* we need to remember the first object allocated in the card */
-void old_space::record_object_start_offset(object *obj)
-{
-       cell idx = addr_to_card((cell)obj - start);
-       if(object_start_offsets[idx] == card_starts_inside_object)
-               object_start_offsets[idx] = ((cell)obj & addr_card_mask);
-}
-
-object *old_space::allot(cell size)
-{
-       if(here + size > end) return NULL;
-
-       object *obj = zone::allot(size);
-       record_object_start_offset(obj);
-       return obj;
-}
-
-void old_space::clear_object_start_offsets()
-{
-       memset(object_start_offsets,card_starts_inside_object,addr_to_card(size));
-}
-
-cell old_space::next_object_after(factor_vm *parent, cell scan)
-{
-       cell size = parent->untagged_object_size((object *)scan);
-       if(scan + size < here)
-               return scan + size;
-       else
-               return 0;
-}
-
-}
diff --git a/vm/old_space.hpp b/vm/old_space.hpp
deleted file mode 100644 (file)
index d037a03..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace factor
-{
-
-static const cell card_starts_inside_object = 0xff;
-
-struct old_space : zone {
-       card *object_start_offsets;
-       card *object_start_offsets_end;
-
-       old_space(cell size_, cell start_);
-       ~old_space();
-
-       cell first_object_in_card(cell card_index);
-       cell find_object_containing_card(cell card_index);
-       void record_object_start_offset(object *obj);
-       object *allot(cell size);
-       void clear_object_start_offsets();
-       cell next_object_after(factor_vm *parent, cell scan);
-};
-
-}
index e682fec13c6268356e2bdd3c0456d749ef95e3e7..5ed5cf0e81668f80b1318b8d3b1fe8a3534986b4 100644 (file)
@@ -4,12 +4,6 @@
 namespace factor
 {
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.mc_esp;
-}
-
 inline static unsigned int uap_fpu_status(void *uap)
 {
         ucontext_t *ucontext = (ucontext_t *)uap;
@@ -43,6 +37,8 @@ inline static void uap_clear_fpu_status(void *uap)
         }
 }
 
-#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)(ucontext))->uc_mcontext.mc_eip)
+
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_esp)
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_eip)
 
 }
index 8f8d218a104b49db376d9d02ae6767da05102c53..02f7fb3ad2ae45b6361f329dec688f7f6d21f62f 100644 (file)
@@ -4,12 +4,6 @@
 namespace factor
 {
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.mc_rsp;
-}
-
 inline static unsigned int uap_fpu_status(void *uap)
 {
         ucontext_t *ucontext = (ucontext_t *)uap;
@@ -33,6 +27,8 @@ inline static void uap_clear_fpu_status(void *uap)
         }
 }
 
-#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)(ucontext))->uc_mcontext.mc_rip)
+
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_rsp)
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_rip)
 
 }
index 1972a728e6a3ce7077abc6fad0c40c9aa585568b..ff5d29ecd715169681fa809244d71e5e697ba7c1 100644 (file)
@@ -10,4 +10,9 @@ void early_init();
 const char *vm_executable_path();
 const char *default_image_path();
 
+template<typename Type> Type align_stack_pointer(Type sp)
+{
+       return sp;
+}
+
 }
index 70c3eb3ff633f4f09cf7528ed8f3990fbfb8007d..3af92fda998db88ddc41915f5bfbb7048f0a5f95 100644 (file)
@@ -5,15 +5,9 @@
 namespace factor
 {
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-       ucontext_t *ucontext = (ucontext_t *)uap;
-       return (void *)ucontext->uc_mcontext.arm_sp;
-}
-
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.arm_pc)
-
 void flush_icache(cell start, cell len);
 
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.arm_sp)
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.arm_pc)
+
 }
index 62671e5ded63802ef9e62f6531556bf95f85112a..51e017bdad70758ab87b179ca2724a085c13ce47 100644 (file)
@@ -4,14 +4,7 @@ namespace factor
 {
 
 #define FRAME_RETURN_ADDRESS(frame,vm) *((void **)(vm->frame_successor(frame) + 1) + 1)
-
-inline static void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.uc_regs->gregs[PT_R1];
-}
-
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.uc_regs->gregs[PT_NIP])
+#define UAP_STACK_POINTER(ucontext) ((ucontext_t *)ucontext)->uc_mcontext.uc_regs->gregs[PT_R1]
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.uc_regs->gregs[PT_NIP])
 
 }
index bd2315ccef6394e55c592f379fea5c34b0bbff12..53a93d17de0f9745f5bd29d644f707c3e98dced3 100644 (file)
@@ -29,12 +29,6 @@ struct _fpstate {
 
 #define X86_FXSR_MAGIC          0x0000
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-       ucontext_t *ucontext = (ucontext_t *)uap;
-       return (void *)ucontext->uc_mcontext.gregs[7];
-}
-
 inline static unsigned int uap_fpu_status(void *uap)
 {
        ucontext_t *ucontext = (ucontext_t *)uap;
@@ -54,7 +48,8 @@ inline static void uap_clear_fpu_status(void *uap)
            fpregs->mxcsr &= 0xffffffc0;
 }
 
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[14])
+
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[7])
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[14])
 
 }
index 42adb3c6b8cffffac90a481b3bb4a9421714d858..14ba9fb00255485b994926d8ef4de64dc6aade25 100644 (file)
@@ -3,12 +3,6 @@
 namespace factor
 {
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.gregs[15];
-}
-
 inline static unsigned int uap_fpu_status(void *uap)
 {
         ucontext_t *ucontext = (ucontext_t *)uap;
@@ -23,7 +17,7 @@ inline static void uap_clear_fpu_status(void *uap)
         ucontext->uc_mcontext.fpregs->mxcsr &= 0xffffffc0;
 }
 
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[16])
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[15])
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[16])
 
 }
index 2bea926890f4b59ed73053052fdd9772af4b1e8c..30fd4b2081bc9624dd553a668688673894518afe 100644 (file)
@@ -62,7 +62,7 @@ inline static unsigned int uap_fpu_status(void *uap)
        return mach_fpu_status(UAP_FS(uap));
 }
 
-inline static cell fix_stack_pointer(cell sp)
+template<typename Type> Type align_stack_pointer(Type sp)
 {
        return sp;
 }
index 89906cd9a4f6b765e8dfc9510a6334b219ea1d0a..a6fe8e27034d255056171e840882acb8da66c424 100644 (file)
@@ -64,9 +64,9 @@ inline static unsigned int uap_fpu_status(void *uap)
        return mach_fpu_status(UAP_FS(uap));
 }
 
-inline static cell fix_stack_pointer(cell sp)
+template<typename Type> Type align_stack_pointer(Type sp)
 {
-       return ((sp + 4) & ~15) - 4;
+       return (Type)((((cell)sp + 4) & ~15) - 4);
 }
 
 inline static void mach_clear_fpu_status(i386_float_state_t *float_state)
index fd6db4d68cc02a093901c4aaf68650f415c8a001..cb1980ddbf66cb0056ebe9e29cb174d0fb508044 100644 (file)
@@ -62,9 +62,9 @@ inline static unsigned int uap_fpu_status(void *uap)
        return mach_fpu_status(UAP_FS(uap));
 }
 
-inline static cell fix_stack_pointer(cell sp)
+template<typename Type> Type align_stack_pointer(Type sp)
 {
-       return ((sp + 8) & ~15) - 8;
+       return (Type)((((cell)sp + 8) & ~15) - 8);
 }
 
 inline static void mach_clear_fpu_status(x86_float_state64_t *float_state)
index cdc0ff7b426bbb89a6075ba7ac18211baccf8aa7..0d230f48e3651c0568e6f7935ebc80596def9521 100644 (file)
@@ -11,12 +11,8 @@ void early_init();
 const char *vm_executable_path();
 const char *default_image_path();
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-       ucontext_t *ucontext = (ucontext_t *)uap;
-       return ucontext->uc_stack.ss_sp;
-}
-
 void c_to_factor_toplevel(cell quot);
 
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_stack.ss_sp)
+
 }
index 96f169bbcf002be3f4e4c56f7f2beb79369e2b4a..438957bd047ff2c765b3a2d75d5bff0f537cb814 100644 (file)
@@ -14,7 +14,7 @@ NS_DURING
                NS_VOIDRETURN;
 NS_HANDLER
                dpush(allot_alien(false_object,(cell)localException));
-               quot = userenv[COCOA_EXCEPTION_ENV];
+               quot = special_objects[OBJ_COCOA_EXCEPTION];
                if(!tagged<object>(quot).type_p(QUOTATION_TYPE))
                {
                        /* No Cocoa exception handler was registered, so
index f2f47ecf6ccd14160b060eb705a3588226111401..21b3557239fa61c00587a579a8d4c52a35d6a2b2 100644 (file)
@@ -3,9 +3,9 @@
 namespace factor
 {
 
-#define ucontext_stack_pointer(uap) ((void *)_UC_MACHINE_SP((ucontext_t *)uap))
-
 static inline unsigned int uap_fpu_status(void *uap) { return 0; }
-static inline void uap_clear_fpu_status(void *uap) {  }
+static inline void uap_clear_fpu_status(void *uap) {}
+
+#define UAP_STACK_POINTER(ucontext) (_UC_MACHINE_SP((ucontext_t *)ucontext))
 
 }
index a9d52a6c2bfb071689cd42d18f8d2a7a4a2645a1..3e9499899304cdb69211f39e433e41126f14449f 100644 (file)
@@ -3,10 +3,9 @@
 namespace factor
 {
 
-#define ucontext_stack_pointer(uap) \
-       ((void *)(((ucontext_t *)(uap))->uc_mcontext.__gregs[_REG_URSP]))
-
 static inline unsigned int uap_fpu_status(void *uap) { return 0; }
-static inline void uap_clear_fpu_status(void *uap) {  }
+static inline void uap_clear_fpu_status(void *uap) {}
+
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.__gregs[_REG_URSP])
 
 }
index 0abd01921904d8bee7d0b333c0d98222995810d2..34a641c2358c44a79fa6d23554f49eeccad47452 100644 (file)
@@ -3,16 +3,10 @@
 namespace factor
 {
 
-inline static void *openbsd_stack_pointer(void *uap)
-{
-       struct sigcontext *sc = (struct sigcontext*) uap;
-       return (void *)sc->sc_esp;
-}
-
-#define ucontext_stack_pointer openbsd_stack_pointer
-#define UAP_PROGRAM_COUNTER(uap) (((struct sigcontext*)(uap))->sc_eip)
-
 static inline unsigned int uap_fpu_status(void *uap) { return 0; }
-static inline void uap_clear_fpu_status(void *uap) {  }
+static inline void uap_clear_fpu_status(void *uap) {}
+
+#define UAP_STACK_POINTER(ucontext) (((struct sigcontext *)ucontext)->sc_esp)
+#define UAP_PROGRAM_COUNTER(ucontext) (((struct sigcontext *)ucontext)->sc_eip)
 
 }
index 9dce48ee910cd13ff07dd4cce4c92b8f7ec03914..032e77b154a9c31e0954358b305dd3f473996766 100644 (file)
@@ -3,16 +3,10 @@
 namespace factor
 {
 
-inline static void *openbsd_stack_pointer(void *uap)
-{
-       struct sigcontext *sc = (struct sigcontext*) uap;
-       return (void *)sc->sc_rsp;
-}
-
-#define ucontext_stack_pointer openbsd_stack_pointer
-#define UAP_PROGRAM_COUNTER(uap) (((struct sigcontext*)(uap))->sc_rip)
-
 static inline unsigned int uap_fpu_status(void *uap) { return 0; }
-static inline void uap_clear_fpu_status(void *uap) {  }
+static inline void uap_clear_fpu_status(void *uap) {}
+
+#define UAP_STACK_POINTER(ucontext) (((struct sigcontext *)ucontext)->sc_rsp)
+#define UAP_PROGRAM_COUNTER(ucontext) (((struct sigcontext *)ucontext)->sc_rip)
 
 }
index b89b8d541b6c5b3cfde87bc32fb4ac0f4c5fd3f4..2ec8bc138f38bf224274d24917de54d607b982ae 100644 (file)
@@ -3,13 +3,7 @@
 namespace factor
 {
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.gregs[ESP];
-}
-
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[EIP])
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[ESP])
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[EIP])
 
 }
index 0d3a74e11d00f485465ebcb165fa432dc5095dc5..72a7b5c2fd2ff8063e0b2e4a58a9e41cb9200903 100644 (file)
@@ -3,13 +3,7 @@
 namespace factor
 {
 
-inline static void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.gregs[RSP];
-}
-
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[RIP])
+#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[RSP])
+#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[RIP])
 
 }
index 2f9d5a3c89ff70d15fab31d29e1755f4fa983c4d..cd885411369fc83c6b4715e4f349b60442edca82 100644 (file)
@@ -115,63 +115,47 @@ segment::~segment()
        if(retval)
                fatal_error("Segment deallocation failed",0);
 }
-  
-stack_frame *factor_vm::uap_stack_pointer(void *uap)
+
+void factor_vm::dispatch_signal(void *uap, void (handler)())
 {
-       /* There is a race condition here, but in practice a signal
-       delivered during stack frame setup/teardown or while transitioning
-       from Factor to C is a sign of things seriously gone wrong, not just
-       a divide by zero or stack underflow in the listener */
        if(in_code_heap_p(UAP_PROGRAM_COUNTER(uap)))
        {
-               stack_frame *ptr = (stack_frame *)ucontext_stack_pointer(uap);
-               if(!ptr)
-                       critical_error("Invalid uap",(cell)uap);
-               return ptr;
+               stack_frame *ptr = (stack_frame *)UAP_STACK_POINTER(uap);
+               assert(ptr);
+               signal_callstack_top = ptr;
        }
        else
-               return NULL;
-}
+               signal_callstack_top = NULL;
 
-void factor_vm::memory_signal_handler(int signal, siginfo_t *siginfo, void *uap)
-{
-       signal_fault_addr = (cell)siginfo->si_addr;
-       signal_callstack_top = uap_stack_pointer(uap);
-       UAP_PROGRAM_COUNTER(uap) = (cell)factor::memory_signal_handler_impl;
+       UAP_STACK_POINTER(uap) = align_stack_pointer(UAP_STACK_POINTER(uap));
+       UAP_PROGRAM_COUNTER(uap) = (cell)handler;
 }
 
 void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap)
 {
-       tls_vm()->memory_signal_handler(signal,siginfo,uap);
-}
-
-void factor_vm::misc_signal_handler(int signal, siginfo_t *siginfo, void *uap)
-{
-       signal_number = signal;
-       signal_callstack_top = uap_stack_pointer(uap);
-       UAP_PROGRAM_COUNTER(uap) = (cell)factor::misc_signal_handler_impl;
+       factor_vm *vm = tls_vm();
+       vm->signal_fault_addr = (cell)siginfo->si_addr;
+       vm->dispatch_signal(uap,factor::memory_signal_handler_impl);
 }
 
 void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap)
 {
-       tls_vm()->misc_signal_handler(signal,siginfo,uap);
+       factor_vm *vm = tls_vm();
+       vm->signal_number = signal;
+       vm->dispatch_signal(uap,factor::misc_signal_handler_impl);
 }
 
-void factor_vm::fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap)
+void fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap)
 {
-       signal_number = signal;
-       signal_callstack_top = uap_stack_pointer(uap);
-       signal_fpu_status = fpu_status(uap_fpu_status(uap));
+       factor_vm *vm = tls_vm();
+       vm->signal_number = signal;
+       vm->signal_fpu_status = fpu_status(uap_fpu_status(uap));
        uap_clear_fpu_status(uap);
-       UAP_PROGRAM_COUNTER(uap) =
-               (siginfo->si_code == FPE_INTDIV || siginfo->si_code == FPE_INTOVF)
-               ? (cell)factor::misc_signal_handler_impl
-               : (cell)factor::fp_signal_handler_impl;
-}
 
-void fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap)
-{
-       tls_vm()->fpe_signal_handler(signal, siginfo, uap);
+       vm->dispatch_signal(uap,
+               (siginfo->si_code == FPE_INTDIV || siginfo->si_code == FPE_INTOVF)
+               ? factor::misc_signal_handler_impl
+               : factor::fp_signal_handler_impl);
 }
 
 static void sigaction_safe(int signum, const struct sigaction *act, struct sigaction *oldact)
index b12ebd0610372807975afe2f4cca6fe18cc42e3a..403842b2cb6220ce05af969abab11f64cf891922 100644 (file)
@@ -37,8 +37,6 @@ typedef wchar_t vm_char;
 #define OPEN_READ(path) _wfopen(path,L"rb")
 #define OPEN_WRITE(path) _wfopen(path,L"wb")
 
-#define print_native_string(string) wprintf(L"%s",string)
-
 /* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
 #define EPOCH_OFFSET 0x019db1ded53e8000LL
 
index ea0254514827ea2c84769372e4c25b1dee02c36e..b566696ae7eec9b23d37354a7c0c56973b5744dc 100644 (file)
@@ -49,13 +49,12 @@ PRIMITIVE_FORWARD(float_greater)
 PRIMITIVE_FORWARD(float_greatereq)
 PRIMITIVE_FORWARD(word)
 PRIMITIVE_FORWARD(word_xt)
-PRIMITIVE_FORWARD(getenv)
-PRIMITIVE_FORWARD(setenv)
+PRIMITIVE_FORWARD(special_object)
+PRIMITIVE_FORWARD(set_special_object)
 PRIMITIVE_FORWARD(existsp)
 PRIMITIVE_FORWARD(minor_gc)
 PRIMITIVE_FORWARD(full_gc)
 PRIMITIVE_FORWARD(compact_gc)
-PRIMITIVE_FORWARD(gc_stats)
 PRIMITIVE_FORWARD(save_image)
 PRIMITIVE_FORWARD(save_image_and_exit)
 PRIMITIVE_FORWARD(datastack)
@@ -83,9 +82,7 @@ PRIMITIVE_FORWARD(set_string_nth_slow)
 PRIMITIVE_FORWARD(resize_array)
 PRIMITIVE_FORWARD(resize_string)
 PRIMITIVE_FORWARD(array)
-PRIMITIVE_FORWARD(begin_scan)
-PRIMITIVE_FORWARD(next_object)
-PRIMITIVE_FORWARD(end_scan)
+PRIMITIVE_FORWARD(all_instances)
 PRIMITIVE_FORWARD(size)
 PRIMITIVE_FORWARD(die)
 PRIMITIVE_FORWARD(fopen)
@@ -115,7 +112,6 @@ PRIMITIVE_FORWARD(call_clear)
 PRIMITIVE_FORWARD(resize_byte_array)
 PRIMITIVE_FORWARD(dll_validp)
 PRIMITIVE_FORWARD(unimplemented)
-PRIMITIVE_FORWARD(clear_gc_stats)
 PRIMITIVE_FORWARD(jit_compile)
 PRIMITIVE_FORWARD(load_locals)
 PRIMITIVE_FORWARD(check_datastack)
@@ -123,13 +119,15 @@ PRIMITIVE_FORWARD(mega_cache_miss)
 PRIMITIVE_FORWARD(lookup_method)
 PRIMITIVE_FORWARD(reset_dispatch_stats)
 PRIMITIVE_FORWARD(dispatch_stats)
-PRIMITIVE_FORWARD(reset_inline_cache_stats)
-PRIMITIVE_FORWARD(inline_cache_stats)
 PRIMITIVE_FORWARD(optimized_p)
 PRIMITIVE_FORWARD(quot_compiled_p)
 PRIMITIVE_FORWARD(vm_ptr)
 PRIMITIVE_FORWARD(strip_stack_traces)
 PRIMITIVE_FORWARD(callback)
+PRIMITIVE_FORWARD(enable_gc_events)
+PRIMITIVE_FORWARD(disable_gc_events)
+PRIMITIVE_FORWARD(identity_hashcode)
+PRIMITIVE_FORWARD(compute_identity_hashcode)
 
 const primitive_type primitives[] = {
        primitive_bignum_to_fixnum,
@@ -187,13 +185,12 @@ const primitive_type primitives[] = {
        primitive_float_greatereq,
        primitive_word,
        primitive_word_xt,
-       primitive_getenv,
-       primitive_setenv,
+       primitive_special_object,
+       primitive_set_special_object,
        primitive_existsp,
        primitive_minor_gc,
        primitive_full_gc,
        primitive_compact_gc,
-       primitive_gc_stats,
        primitive_save_image,
        primitive_save_image_and_exit,
        primitive_datastack,
@@ -247,9 +244,7 @@ const primitive_type primitives[] = {
        primitive_resize_array,
        primitive_resize_string,
        primitive_array,
-       primitive_begin_scan,
-       primitive_next_object,
-       primitive_end_scan,
+       primitive_all_instances,
        primitive_size,
        primitive_die,
        primitive_fopen,
@@ -279,7 +274,6 @@ const primitive_type primitives[] = {
        primitive_resize_byte_array,
        primitive_dll_validp,
        primitive_unimplemented,
-       primitive_clear_gc_stats,
        primitive_jit_compile,
        primitive_load_locals,
        primitive_check_datastack,
@@ -289,13 +283,15 @@ const primitive_type primitives[] = {
        primitive_lookup_method,
        primitive_reset_dispatch_stats,
        primitive_dispatch_stats,
-       primitive_reset_inline_cache_stats,
-       primitive_inline_cache_stats,
        primitive_optimized_p,
        primitive_quot_compiled_p,
        primitive_vm_ptr,
        primitive_strip_stack_traces,
        primitive_callback,
+       primitive_enable_gc_events,
+       primitive_disable_gc_events,
+       primitive_identity_hashcode,
+       primitive_compute_identity_hashcode,
 };
 
 }
index 4674b726b1adfd65f8ccc5415581c94904d57c9d..403d26f0ca92036796d89bf026170ce4234e4257 100755 (executable)
@@ -11,10 +11,10 @@ void factor_vm::init_profiler()
 /* Allocates memory */
 code_block *factor_vm::compile_profiling_stub(cell word_)
 {
-       gc_root<word> word(word_,this);
+       data_root<word> word(word_,this);
 
-       jit jit(WORD_TYPE,word.value(),this);
-       jit.emit_with(userenv[JIT_PROFILING],word.value());
+       jit jit(code_block_profiling,word.value(),this);
+       jit.emit_with(special_objects[JIT_PROFILING],word.value());
 
        return jit.to_code_block();
 }
@@ -25,22 +25,21 @@ void factor_vm::set_profiling(bool profiling)
        if(profiling == profiling_p)
                return;
 
-       profiling_p = profiling;
-
        /* Push everything to tenured space so that we can heap scan
        and allocate profiling blocks if necessary */
        primitive_full_gc();
 
-       gc_root<array> words(find_all_words(),this);
+       data_root<array> words(find_all_words(),this);
+
+       profiling_p = profiling;
 
-       cell i;
        cell length = array_capacity(words.untagged());
-       for(i = 0; i < length; i++)
+       for(cell i = 0; i < length; i++)
        {
                tagged<word> word(array_nth(words.untagged(),i));
                if(profiling)
                        word->counter = tag_fixnum(0);
-               update_word_xt(word.value());
+               update_word_xt(word.untagged());
        }
 
        update_code_heap_words();
index 9c2c85215d178b6d03a029df2110a2d5483dfb34..8ccafc9d8fb817edaa21643989675716219ea24a 100755 (executable)
@@ -6,11 +6,11 @@ namespace factor
 /* Simple non-optimizing compiler.
 
 This is one of the two compilers implementing Factor; the second one is written
-in Factor and performs advanced optimizations. See core/compiler/compiler.factor.
+in Factor and performs advanced optimizations. See basis/compiler/compiler.factor.
 
 The non-optimizing compiler compiles a quotation at a time by concatenating
 machine code chunks; prolog, epilog, call word, jump to word, etc. These machine
-code chunks are generated from Factor code in core/cpu/.../bootstrap.factor.
+code chunks are generated from Factor code in basis/cpu/.../bootstrap.factor.
 
 Calls to words and constant quotations (referenced by conditionals and dips)
 are direct jumps to machine code blocks. Literals are also referenced directly
@@ -38,29 +38,29 @@ so this results in a big speedup for relatively little effort. */
 
 bool quotation_jit::primitive_call_p(cell i, cell length)
 {
-       return (i + 2) == length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_PRIMITIVE_WORD];
+       return (i + 2) == length && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_PRIMITIVE_WORD];
 }
 
 bool quotation_jit::fast_if_p(cell i, cell length)
 {
        return (i + 3) == length
                && tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(QUOTATION_TYPE)
-               && array_nth(elements.untagged(),i + 2) == parent->userenv[JIT_IF_WORD];
+               && array_nth(elements.untagged(),i + 2) == parent->special_objects[JIT_IF_WORD];
 }
 
 bool quotation_jit::fast_dip_p(cell i, cell length)
 {
-       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_DIP_WORD];
+       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_DIP_WORD];
 }
 
 bool quotation_jit::fast_2dip_p(cell i, cell length)
 {
-       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_2DIP_WORD];
+       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_2DIP_WORD];
 }
 
 bool quotation_jit::fast_3dip_p(cell i, cell length)
 {
-       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_3DIP_WORD];
+       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_3DIP_WORD];
 }
 
 bool quotation_jit::mega_lookup_p(cell i, cell length)
@@ -68,13 +68,13 @@ bool quotation_jit::mega_lookup_p(cell i, cell length)
        return (i + 4) <= length
                && tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(FIXNUM_TYPE)
                && tagged<object>(array_nth(elements.untagged(),i + 2)).type_p(ARRAY_TYPE)
-               && array_nth(elements.untagged(),i + 3) == parent->userenv[MEGA_LOOKUP_WORD];
+               && array_nth(elements.untagged(),i + 3) == parent->special_objects[MEGA_LOOKUP_WORD];
 }
 
 bool quotation_jit::declare_p(cell i, cell length)
 {
        return (i + 2) <= length
-               && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_DECLARE_WORD];
+               && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_DECLARE_WORD];
 }
 
 bool quotation_jit::stack_frame_p()
@@ -88,7 +88,7 @@ bool quotation_jit::stack_frame_p()
                switch(tagged<object>(obj).type())
                {
                case WORD_TYPE:
-                       if(!parent->to_boolean(parent->untag<word>(obj)->subprimitive))
+                       if(!parent->to_boolean(untag<word>(obj)->subprimitive))
                                return true;
                        break;
                case QUOTATION_TYPE:
@@ -110,9 +110,9 @@ bool quotation_jit::trivial_quotation_p(array *elements)
 
 void quotation_jit::emit_quot(cell quot_)
 {
-       gc_root<quotation> quot(quot_,parent);
+       data_root<quotation> quot(quot_,parent);
 
-       array *elements = parent->untag<array>(quot->array);
+       array *elements = untag<array>(quot->array);
 
        /* If the quotation consists of a single word, compile a direct call
        to the word. */
@@ -133,7 +133,7 @@ void quotation_jit::iterate_quotation()
        set_position(0);
 
        if(stack_frame)
-               emit(parent->userenv[JIT_PROLOG]);
+               emit(parent->special_objects[JIT_PROLOG]);
 
        cell i;
        cell length = array_capacity(elements.untagged());
@@ -143,7 +143,7 @@ void quotation_jit::iterate_quotation()
        {
                set_position(i);
 
-               gc_root<object> obj(array_nth(elements.untagged(),i),parent);
+               data_root<object> obj(array_nth(elements.untagged(),i),parent);
 
                switch(obj.type())
                {
@@ -152,23 +152,23 @@ void quotation_jit::iterate_quotation()
                        if(parent->to_boolean(obj.as<word>()->subprimitive))
                                emit_subprimitive(obj.value());
                        /* The (execute) primitive is special-cased */
-                       else if(obj.value() == parent->userenv[JIT_EXECUTE_WORD])
+                       else if(obj.value() == parent->special_objects[JIT_EXECUTE_WORD])
                        {
                                if(i == length - 1)
                                {
-                                       if(stack_frame) emit(parent->userenv[JIT_EPILOG]);
+                                       if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
                                        tail_call = true;
-                                       emit(parent->userenv[JIT_EXECUTE_JUMP]);
+                                       emit(parent->special_objects[JIT_EXECUTE_JUMP]);
                                }
                                else
-                                       emit(parent->userenv[JIT_EXECUTE_CALL]);
+                                       emit(parent->special_objects[JIT_EXECUTE_CALL]);
                        }
                        /* Everything else */
                        else
                        {
                                if(i == length - 1)
                                {
-                                       if(stack_frame) emit(parent->userenv[JIT_EPILOG]);
+                                       if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
                                        tail_call = true;
                                        /* Inline cache misses are special-cased.
                                           The calling convention for tail
@@ -178,8 +178,8 @@ void quotation_jit::iterate_quotation()
                                           the inline cache miss primitive, and
                                           we don't want to clobber the saved
                                           address. */
-                                       if(obj.value() == parent->userenv[PIC_MISS_WORD]
-                                          || obj.value() == parent->userenv[PIC_MISS_TAIL_WORD])
+                                       if(obj.value() == parent->special_objects[PIC_MISS_WORD]
+                                          || obj.value() == parent->special_objects[PIC_MISS_TAIL_WORD])
                                        {
                                                word_special(obj.value());
                                        }
@@ -201,7 +201,7 @@ void quotation_jit::iterate_quotation()
                        {
                                literal(tag_fixnum(0));
                                literal(obj.value());
-                               emit(parent->userenv[JIT_PRIMITIVE]);
+                               emit(parent->special_objects[JIT_PRIMITIVE]);
 
                                i++;
 
@@ -215,12 +215,12 @@ void quotation_jit::iterate_quotation()
                           mutually recursive in the library, but both still work) */
                        if(fast_if_p(i,length))
                        {
-                               if(stack_frame) emit(parent->userenv[JIT_EPILOG]);
+                               if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
                                tail_call = true;
 
                                emit_quot(array_nth(elements.untagged(),i));
                                emit_quot(array_nth(elements.untagged(),i + 1));
-                               emit(parent->userenv[JIT_IF]);
+                               emit(parent->special_objects[JIT_IF]);
 
                                i += 2;
                        }
@@ -228,21 +228,21 @@ void quotation_jit::iterate_quotation()
                        else if(fast_dip_p(i,length))
                        {
                                emit_quot(obj.value());
-                               emit(parent->userenv[JIT_DIP]);
+                               emit(parent->special_objects[JIT_DIP]);
                                i++;
                        }
                        /* 2dip */
                        else if(fast_2dip_p(i,length))
                        {
                                emit_quot(obj.value());
-                               emit(parent->userenv[JIT_2DIP]);
+                               emit(parent->special_objects[JIT_2DIP]);
                                i++;
                        }
                        /* 3dip */
                        else if(fast_3dip_p(i,length))
                        {
                                emit_quot(obj.value());
-                               emit(parent->userenv[JIT_3DIP]);
+                               emit(parent->special_objects[JIT_3DIP]);
                                i++;
                        }
                        else
@@ -276,14 +276,13 @@ void quotation_jit::iterate_quotation()
                set_position(length);
 
                if(stack_frame)
-                       emit(parent->userenv[JIT_EPILOG]);
-               emit(parent->userenv[JIT_RETURN]);
+                       emit(parent->special_objects[JIT_EPILOG]);
+               emit(parent->special_objects[JIT_RETURN]);
        }
 }
 
 void factor_vm::set_quot_xt(quotation *quot, code_block *code)
 {
-       assert(code->type() == QUOTATION_TYPE);
        quot->code = code;
        quot->xt = code->xt();
 }
@@ -291,7 +290,7 @@ void factor_vm::set_quot_xt(quotation *quot, code_block *code)
 /* Allocates memory */
 void factor_vm::jit_compile(cell quot_, bool relocating)
 {
-       gc_root<quotation> quot(quot_,this);
+       data_root<quotation> quot(quot_,this);
        if(quot->code) return;
 
        quotation_jit compiler(quot.value(),true,relocating,this);
@@ -328,29 +327,27 @@ void factor_vm::primitive_quotation_xt()
 
 void factor_vm::compile_all_words()
 {
-       gc_root<array> words(find_all_words(),this);
+       data_root<array> words(find_all_words(),this);
 
        cell i;
        cell length = array_capacity(words.untagged());
        for(i = 0; i < length; i++)
        {
-               gc_root<word> word(array_nth(words.untagged(),i),this);
+               data_root<word> word(array_nth(words.untagged(),i),this);
 
-               if(!word->code || !word_optimized_p(word.untagged()))
+               if(!word->code || !word->code->optimized_p())
                        jit_compile_word(word.value(),word->def,false);
 
-               update_word_xt(word.value());
+               update_word_xt(word.untagged());
 
        }
-
-       update_code_heap_words();
 }
 
 /* Allocates memory */
 fixnum factor_vm::quot_code_offset_to_scan(cell quot_, cell offset)
 {
-       gc_root<quotation> quot(quot_,this);
-       gc_root<array> array(quot->array,this);
+       data_root<quotation> quot(quot_,this);
+       data_root<array> array(quot->array,this);
 
        quotation_jit compiler(quot.value(),false,false,this);
        compiler.compute_position(offset);
@@ -361,7 +358,7 @@ fixnum factor_vm::quot_code_offset_to_scan(cell quot_, cell offset)
 
 cell factor_vm::lazy_jit_compile_impl(cell quot_, stack_frame *stack)
 {
-       gc_root<quotation> quot(quot_,this);
+       data_root<quotation> quot(quot_,this);
        ctx->callstack_top = stack;
        jit_compile(quot.value(),true);
        return quot.value();
index feb2af1ce41d7f71ece2ab17944d2279cd0b3a6f..6d04d80de3d872ad4a33f9288db2fe96d21f0eba 100755 (executable)
@@ -2,11 +2,11 @@ namespace factor
 {
 
 struct quotation_jit : public jit {
-       gc_root<array> elements;
+       data_root<array> elements;
        bool compiling, relocate;
 
        explicit quotation_jit(cell quot, bool compiling_, bool relocate_, factor_vm *vm)
-               : jit(QUOTATION_TYPE,quot,vm),
+               : jit(code_block_unoptimized,quot,vm),
                  elements(owner.as<quotation>().untagged()->array,vm),
                  compiling(compiling_),
                  relocate(relocate_){};
index 79aca937cac55248fbf9474a9b64dba858c1f0e1..59375df1fbd6e00d4ae66166f304843774419506 100755 (executable)
@@ -3,19 +3,6 @@
 namespace factor
 {
 
-void factor_vm::primitive_getenv()
-{
-       fixnum e = untag_fixnum(dpeek());
-       drepl(userenv[e]);
-}
-
-void factor_vm::primitive_setenv()
-{
-       fixnum e = untag_fixnum(dpop());
-       cell value = dpop();
-       userenv[e] = value;
-}
-
 void factor_vm::primitive_exit()
 {
        exit(to_fixnum(dpop()));
@@ -31,43 +18,4 @@ void factor_vm::primitive_sleep()
        sleep_micros(to_cell(dpop()));
 }
 
-void factor_vm::primitive_set_slot()
-{
-       fixnum slot = untag_fixnum(dpop());
-       object *obj = untag<object>(dpop());
-       cell value = dpop();
-
-       cell *slot_ptr = &obj->slots()[slot];
-       *slot_ptr = value;
-       write_barrier(slot_ptr);
-}
-
-void factor_vm::primitive_load_locals()
-{
-       fixnum count = untag_fixnum(dpop());
-       memcpy((cell *)(rs + sizeof(cell)),(cell *)(ds - sizeof(cell) * (count - 1)),sizeof(cell) * count);
-       ds -= sizeof(cell) * count;
-       rs += sizeof(cell) * count;
-}
-
-cell factor_vm::clone_object(cell obj_)
-{
-       gc_root<object> obj(obj_,this);
-
-       if(immediate_p(obj.value()))
-               return obj.value();
-       else
-       {
-               cell size = object_size(obj.value());
-               object *new_obj = allot_object(header(obj.type()),size);
-               memcpy(new_obj,obj.untagged(),size);
-               return tag_dynamic(new_obj);
-       }
-}
-
-void factor_vm::primitive_clone()
-{
-       drepl(clone_object(dpeek()));
-}
-
 }
index 86590e96a2d396c3ac3ef5f526d5f62dfcf399e8..412ef35bb4403ee39e5aa0ef975114ad79a07a9b 100755 (executable)
@@ -1,106 +1,4 @@
 namespace factor
 {
 
-#define USER_ENV 70
-
-enum special_object {
-       NAMESTACK_ENV,            /* used by library only */
-       CATCHSTACK_ENV,           /* used by library only, per-callback */
-
-       CURRENT_CALLBACK_ENV = 2, /* used by library only, per-callback */
-       WALKER_HOOK_ENV,          /* non-local exit hook, used by library only */
-       CALLCC_1_ENV,             /* used to pass the value in callcc1 */
-
-       BREAK_ENV            = 5, /* quotation called by throw primitive */
-       ERROR_ENV,                /* a marker consed onto kernel errors */
-
-       CELL_SIZE_ENV        = 7, /* sizeof(cell) */
-       CPU_ENV,                  /* CPU architecture */
-       OS_ENV,                   /* operating system name */
-
-       ARGS_ENV            = 10, /* command line arguments */
-       STDIN_ENV,                /* stdin FILE* handle */
-       STDOUT_ENV,               /* stdout FILE* handle */
-
-       IMAGE_ENV           = 13, /* image path name */
-       EXECUTABLE_ENV,           /* runtime executable path name */
-
-       EMBEDDED_ENV        = 15, /* are we embedded in another app? */
-       EVAL_CALLBACK_ENV,        /* used when Factor is embedded in a C app */
-       YIELD_CALLBACK_ENV,       /* used when Factor is embedded in a C app */
-       SLEEP_CALLBACK_ENV,       /* used when Factor is embedded in a C app */
-
-       COCOA_EXCEPTION_ENV = 19, /* Cocoa exception handler quotation */
-
-       BOOT_ENV            = 20, /* boot quotation */
-       GLOBAL_ENV,               /* global namespace */
-
-       /* Quotation compilation in quotations.c */
-       JIT_PROLOG          = 23,
-       JIT_PRIMITIVE_WORD,
-       JIT_PRIMITIVE,
-       JIT_WORD_JUMP,
-       JIT_WORD_CALL,
-       JIT_WORD_SPECIAL,
-       JIT_IF_WORD,
-       JIT_IF,
-       JIT_EPILOG,
-       JIT_RETURN,
-       JIT_PROFILING,
-       JIT_PUSH_IMMEDIATE,
-       JIT_DIP_WORD,
-       JIT_DIP,
-       JIT_2DIP_WORD,
-       JIT_2DIP,
-       JIT_3DIP_WORD,
-       JIT_3DIP,
-       JIT_EXECUTE_WORD,
-       JIT_EXECUTE_JUMP,
-       JIT_EXECUTE_CALL,
-       JIT_DECLARE_WORD,
-
-       /* Callback stub generation in callbacks.c */
-       CALLBACK_STUB       = 45,
-
-       /* Polymorphic inline cache generation in inline_cache.c */
-       PIC_LOAD            = 47,
-       PIC_TAG,
-       PIC_HI_TAG,
-       PIC_TUPLE,
-       PIC_HI_TAG_TUPLE,
-       PIC_CHECK_TAG,
-       PIC_CHECK,
-       PIC_HIT,
-       PIC_MISS_WORD,
-       PIC_MISS_TAIL_WORD,
-
-       /* Megamorphic cache generation in dispatch.c */
-       MEGA_LOOKUP         = 57,
-       MEGA_LOOKUP_WORD,
-        MEGA_MISS_WORD,
-
-       UNDEFINED_ENV       = 60, /* default quotation for undefined words */
-
-       STDERR_ENV          = 61, /* stderr FILE* handle */
-
-       STAGE2_ENV          = 62, /* have we bootstrapped? */
-
-       CURRENT_THREAD_ENV  = 63,
-
-       THREADS_ENV         = 64,
-       RUN_QUEUE_ENV       = 65,
-       SLEEP_QUEUE_ENV     = 66,
-       SHUTDOWN_ENV        = 67,
-};
-
-#define FIRST_SAVE_ENV BOOT_ENV
-#define LAST_SAVE_ENV STAGE2_ENV
-
-inline static bool save_env_p(cell i)
-{
-       return (i >= FIRST_SAVE_ENV && i <= LAST_SAVE_ENV);
 }
-
-}
-
diff --git a/vm/slot_visitor.hpp b/vm/slot_visitor.hpp
new file mode 100644 (file)
index 0000000..af920fc
--- /dev/null
@@ -0,0 +1,109 @@
+namespace factor
+{
+
+template<typename Visitor> struct slot_visitor {
+       factor_vm *parent;
+       Visitor visitor;
+
+       explicit slot_visitor<Visitor>(factor_vm *parent_, Visitor visitor_) :
+               parent(parent_), visitor(visitor_) {}
+
+       void visit_handle(cell *handle)
+       {
+               cell pointer = *handle;
+               if(immediate_p(pointer)) return;
+
+               object *untagged = untag<object>(pointer);
+               untagged = visitor(untagged);
+               *handle = RETAG(untagged,TAG(pointer));
+       }
+
+       void visit_slots(object *ptr, cell payload_start)
+       {
+               cell *slot = (cell *)ptr;
+               cell *end = (cell *)((cell)ptr + payload_start);
+
+               if(slot != end)
+               {
+                       slot++;
+                       for(; slot < end; slot++) visit_handle(slot);
+               }
+       }
+
+       void visit_slots(object *ptr)
+       {
+               visit_slots(ptr,ptr->binary_payload_start());
+       }
+
+       void visit_stack_elements(segment *region, cell *top)
+       {
+               for(cell *ptr = (cell *)region->start; ptr <= top; ptr++)
+                       visit_handle(ptr);
+       }
+
+       void visit_data_roots()
+       {
+               std::vector<data_root_range>::const_iterator iter = parent->data_roots.begin();
+               std::vector<data_root_range>::const_iterator end = parent->data_roots.end();
+
+               for(; iter < end; iter++)
+               {
+                       data_root_range r = *iter;
+                       for(cell index = 0; index < r.len; index++)
+                               visit_handle(r.start + index);
+               }
+       }
+
+       void visit_bignum_roots()
+       {
+               std::vector<cell>::const_iterator iter = parent->bignum_roots.begin();
+               std::vector<cell>::const_iterator end = parent->bignum_roots.end();
+
+               for(; iter < end; iter++)
+               {
+                       cell *handle = (cell *)(*iter);
+
+                       if(*handle)
+                               *handle = (cell)visitor(*(object **)handle);
+               }
+       }
+
+       void visit_roots()
+       {
+               visit_handle(&parent->true_object);
+               visit_handle(&parent->bignum_zero);
+               visit_handle(&parent->bignum_pos_one);
+               visit_handle(&parent->bignum_neg_one);
+
+               visit_data_roots();
+               visit_bignum_roots();
+
+               for(cell i = 0; i < special_object_count; i++)
+                       visit_handle(&parent->special_objects[i]);
+       }
+
+       void visit_contexts()
+       {
+               context *ctx = parent->ctx;
+
+               while(ctx)
+               {
+                       visit_stack_elements(ctx->datastack_region,(cell *)ctx->datastack);
+                       visit_stack_elements(ctx->retainstack_region,(cell *)ctx->retainstack);
+
+                       visit_handle(&ctx->catchstack_save);
+                       visit_handle(&ctx->current_callback_save);
+
+                       ctx = ctx->next;
+               }
+       }
+
+       void visit_literal_references(code_block *compiled)
+       {
+               visit_handle(&compiled->owner);
+               visit_handle(&compiled->literals);
+               visit_handle(&compiled->relocation);
+       }
+};
+
+}
index d7434fe660e90434cfca145aff35f578b02e8887..d9a32517a410d5dfd729ca226f9e46411c85c3c3 100644 (file)
@@ -3,20 +3,20 @@
 namespace factor
 {
 
-cell factor_vm::string_nth(string* str, cell index)
+cell string::nth(cell index) const
 {
        /* If high bit is set, the most significant 16 bits of the char
        come from the aux vector. The least significant bit of the
        corresponding aux vector entry is negated, so that we can
        XOR the two components together and get the original code point
        back. */
-       cell lo_bits = str->data()[index];
+       cell lo_bits = data()[index];
 
        if((lo_bits & 0x80) == 0)
                return lo_bits;
        else
        {
-               byte_array *aux = untag<byte_array>(str->aux);
+               byte_array *aux = untag<byte_array>(this->aux);
                cell hi_bits = aux->data<u16>()[index];
                return (hi_bits << 7) ^ lo_bits;
        }
@@ -29,7 +29,7 @@ void factor_vm::set_string_nth_fast(string *str, cell index, cell ch)
 
 void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
 {
-       gc_root<string> str(str_,this);
+       data_root<string> str(str_,this);
 
        byte_array *aux;
 
@@ -45,7 +45,7 @@ void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
                if the most significant bit of a
                character is set. Initially all of
                the bits are clear. */
-               aux = allot_array_internal<byte_array>(untag_fixnum(str->length) * sizeof(u16));
+               aux = allot_uninitialized_array<byte_array>(untag_fixnum(str->length) * sizeof(u16));
 
                str->aux = tag<byte_array>(aux);
                write_barrier(&str->aux);
@@ -78,7 +78,7 @@ string *factor_vm::allot_string_internal(cell capacity)
 /* Allocates memory */
 void factor_vm::fill_string(string *str_, cell start, cell capacity, cell fill)
 {
-       gc_root<string> str(str_,this);
+       data_root<string> str(str_,this);
 
        if(fill <= 0x7f)
                memset(&str->data()[start],fill,capacity - start);
@@ -94,7 +94,7 @@ void factor_vm::fill_string(string *str_, cell start, cell capacity, cell fill)
 /* Allocates memory */
 string *factor_vm::allot_string(cell capacity, cell fill)
 {
-       gc_root<string> str(allot_string_internal(capacity),this);
+       data_root<string> str(allot_string_internal(capacity),this);
        fill_string(str.untagged(),0,capacity,fill);
        return str.untagged();
 }
@@ -115,7 +115,7 @@ bool factor_vm::reallot_string_in_place_p(string *str, cell capacity)
 
 string* factor_vm::reallot_string(string *str_, cell capacity)
 {
-       gc_root<string> str(str_,this);
+       data_root<string> str(str_,this);
 
        if(reallot_string_in_place_p(str.untagged(),capacity))
        {
@@ -135,7 +135,7 @@ string* factor_vm::reallot_string(string *str_, cell capacity)
                if(capacity < to_copy)
                        to_copy = capacity;
 
-               gc_root<string> new_str(allot_string_internal(capacity),this);
+               data_root<string> new_str(allot_string_internal(capacity),this);
 
                memcpy(new_str->data(),str->data(),to_copy);
 
@@ -157,16 +157,17 @@ string* factor_vm::reallot_string(string *str_, cell capacity)
 
 void factor_vm::primitive_resize_string()
 {
-       string* str = untag_check<string>(dpop());
+       data_root<string> str(dpop(),this);
+       str.untag_check(this);
        cell capacity = unbox_array_size();
-       dpush(tag<string>(reallot_string(str,capacity)));
+       dpush(tag<string>(reallot_string(str.untagged(),capacity)));
 }
 
 void factor_vm::primitive_string_nth()
 {
        string *str = untag<string>(dpop());
        cell index = untag_fixnum(dpop());
-       dpush(tag_fixnum(string_nth(str,index)));
+       dpush(tag_fixnum(str->nth(index)));
 }
 
 void factor_vm::primitive_set_string_nth_fast()
index 727ca8516e84eac83250261148bf84df2ffc6aa5..54ff981d99af99fda5ebdccb3ea58fdc5ab36ca1 100644 (file)
@@ -1,7 +1,7 @@
 namespace factor
 {
 
-inline static cell string_capacity(string *str)
+inline static cell string_capacity(const string *str)
 {
        return untag_fixnum(str->length);
 }
index a61c599aebc1ef6ff4425331b994ba87c2568c43..e9f89528bc3b0f68c6bd18240b9ae8e59590e32f 100755 (executable)
@@ -3,12 +3,12 @@ namespace factor
 
 template<typename Type> cell tag(Type *value)
 {
-       return RETAG(value,tag_for(Type::type_number));
+       return RETAG(value,Type::type_number);
 }
 
 inline static cell tag_dynamic(object *value)
 {
-       return RETAG(value,tag_for(value->h.hi_tag()));
+       return RETAG(value,value->type());
 }
 
 template<typename Type>
@@ -16,37 +16,50 @@ struct tagged
 {
        cell value_;
 
-       cell value() const { return value_; }
-       Type *untagged() const { return (Type *)(UNTAG(value_)); }
-
-       cell type() const {
-               cell tag = TAG(value_);
-               if(tag == OBJECT_TYPE)
-                       return untagged()->h.hi_tag();
-               else
-                       return tag;
+       cell type() const
+       {
+               return TAG(value_);
        }
 
-       bool type_p(cell type_) const { return type() == type_; }
+       bool type_p(cell type_) const
+       {
+               return type() == type_;
+       }
 
-       Type *untag_check(factor_vm *parent) const {
-               if(Type::type_number != TYPE_COUNT && !type_p(Type::type_number))
-                       parent->type_error(Type::type_number,value_);
-               return untagged();
+       bool type_p() const
+       {
+               if(Type::type_number == TYPE_COUNT)
+                       return true;
+               else
+                       return type_p(Type::type_number);
        }
 
-       explicit tagged(cell tagged) : value_(tagged) {
+       cell value() const
+       {
 #ifdef FACTOR_DEBUG
-               untag_check(tls_vm());
+               assert(type_p());
 #endif
+               return value_;
        }
 
-       explicit tagged(Type *untagged) : value_(factor::tag(untagged)) {
+       Type *untagged() const
+       {
 #ifdef FACTOR_DEBUG
-               untag_check(tls_vm()); 
+               assert(type_p());
 #endif
+               return (Type *)(UNTAG(value_));
        }
 
+       Type *untag_check(factor_vm *parent) const
+       {
+               if(!type_p())
+                       parent->type_error(Type::type_number,value_);
+               return untagged();
+       }
+
+       explicit tagged(cell tagged) : value_(tagged) {}
+       explicit tagged(Type *untagged) : value_(factor::tag(untagged)) {}
+
        Type *operator->() const { return untagged(); }
        cell *operator&() const { return &value_; }
 
@@ -64,7 +77,7 @@ template<typename Type> Type *factor_vm::untag_check(cell value)
        return tagged<Type>(value).untag_check(this);
 }
 
-template<typename Type> Type *factor_vm::untag(cell value)
+template<typename Type> Type *untag(cell value)
 {
        return tagged<Type>(value).untagged();
 }
index f9f584b200d3d4fc343d0a4c105bd06802c5225f..baab47e383f3bc3c5435158634ba6795bdcde44e 100644 (file)
@@ -1,8 +1,63 @@
 namespace factor
 {
 
-struct tenured_space : old_space {
-       tenured_space(cell size, cell start) : old_space(size,start) {}
+struct tenured_space : free_list_allocator<object> {
+       object_start_map starts;
+       std::vector<object *> mark_stack;
+
+       explicit tenured_space(cell size, cell start) :
+               free_list_allocator<object>(size,start), starts(size,start) {}
+
+       object *allot(cell size)
+       {
+               object *obj = free_list_allocator<object>::allot(size);
+               if(obj)
+               {
+                       starts.record_object_start_offset(obj);
+                       return obj;
+               }
+               else
+                       return NULL;
+       }
+
+       cell first_object()
+       {
+               return (cell)next_allocated_block_after(this->first_block());
+       }
+
+       cell next_object_after(cell scan)
+       {
+               cell size = ((object *)scan)->size();
+               object *next = (object *)(scan + size);
+               return (cell)next_allocated_block_after(next);
+       }
+
+       void clear_mark_bits()
+       {
+               state.clear_mark_bits();
+       }
+
+       void clear_mark_stack()
+       {
+               mark_stack.clear();
+       }
+
+       bool marked_p(object *obj)
+       {
+               return this->state.marked_p(obj);
+       }
+
+       void mark_and_push(object *obj)
+       {
+               this->state.set_marked_p(obj);
+               this->mark_stack.push_back(obj);
+       }
+
+       void sweep()
+       {
+               free_list_allocator<object>::sweep();
+               starts.update_for_sweep(&this->state);
+       }
 };
 
 }
index b5d4793ceb2cf9550aa2477c9c2245ef0cc44c53..0cee7482058a9f3493dae9a37f647a260d9069f9 100644 (file)
@@ -4,30 +4,51 @@ namespace factor
 {
 
 to_tenured_collector::to_tenured_collector(factor_vm *myvm_) :
-       copying_collector<tenured_space,to_tenured_policy>(
+       collector<tenured_space,to_tenured_policy>(
                myvm_,
-               &myvm_->gc_stats.aging_stats,
                myvm_->data->tenured,
                to_tenured_policy(myvm_)) {}
 
+void to_tenured_collector::tenure_reachable_objects()
+{
+       std::vector<object *> *mark_stack = &this->target->mark_stack;
+       while(!mark_stack->empty())
+       {
+               object *obj = mark_stack->back();
+               mark_stack->pop_back();
+               this->trace_object(obj);
+       }
+}
+
 void factor_vm::collect_to_tenured()
 {
        /* Copy live objects from aging space to tenured space. */
        to_tenured_collector collector(this);
 
+       data->tenured->clear_mark_stack();
+
        collector.trace_roots();
        collector.trace_contexts();
+
+       current_gc->event->started_card_scan();
        collector.trace_cards(data->tenured,
                card_points_to_aging,
-               dummy_unmarker());
+               full_unmarker());
+       current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
+
+       current_gc->event->started_code_scan();
        collector.trace_code_heap_roots(&code->points_to_aging);
-       collector.cheneys_algorithm();
+       current_gc->event->ended_code_scan(collector.code_blocks_scanned);
+
+       collector.tenure_reachable_objects();
+
+       current_gc->event->started_code_sweep();
        update_code_heap_for_minor_gc(&code->points_to_aging);
+       current_gc->event->ended_code_sweep();
 
-       nursery.here = nursery.start;
-       reset_generation(data->aging);
-       code->points_to_nursery.clear();
-       code->points_to_aging.clear();
+       data->reset_generation(&nursery);
+       data->reset_generation(data->aging);
+       code->clear_remembered_set();
 }
 
 }
index 64bd9aa04d401626acf0099480454513a07a6a24..2f2717efd1c2b2cc69dc94576c0748a4506c52a0 100644 (file)
@@ -3,18 +3,26 @@ namespace factor
 
 struct to_tenured_policy {
        factor_vm *myvm;
-       zone *tenured;
+       tenured_space *tenured;
 
-       to_tenured_policy(factor_vm *myvm_) : myvm(myvm_), tenured(myvm->data->tenured) {}
+       explicit to_tenured_policy(factor_vm *myvm_) : myvm(myvm_), tenured(myvm->data->tenured) {}
 
        bool should_copy_p(object *untagged)
        {
                return !tenured->contains_p(untagged);
        }
+
+       void promoted_object(object *obj)
+       {
+               tenured->mark_stack.push_back(obj);
+       }
+
+       void visited_object(object *obj) {}
 };
 
-struct to_tenured_collector : copying_collector<tenured_space,to_tenured_policy> {
-       to_tenured_collector(factor_vm *myvm_);
+struct to_tenured_collector : collector<tenured_space,to_tenured_policy> {
+       explicit to_tenured_collector(factor_vm *myvm_);
+       void tenure_reachable_objects();
 };
 
 }
index 2d195ea13b4fe9b79ff515ca28b749f5a00e8b56..eaac437753d90e41e4ca1e159b0bb5fc81403e97 100755 (executable)
@@ -3,34 +3,29 @@
 namespace factor
 {
 
-/* push a new tuple on the stack */
-tuple *factor_vm::allot_tuple(cell layout_)
+/* push a new tuple on the stack, filling its slots with f */
+void factor_vm::primitive_tuple()
 {
-       gc_root<tuple_layout> layout(layout_,this);
-       gc_root<tuple> t(allot<tuple>(tuple_size(layout.untagged())),this);
+       data_root<tuple_layout> layout(dpop(),this);
+       tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
        t->layout = layout.value();
-       return t.untagged();
-}
 
-void factor_vm::primitive_tuple()
-{
-       gc_root<tuple_layout> layout(dpop(),this);
-       tuple *t = allot_tuple(layout.value());
-       fixnum i;
-       for(i = tuple_size(layout.untagged()) - 1; i >= 0; i--)
-               t->data()[i] = false_object;
+       memset_cell(t->data(),false_object,tuple_size(layout.untagged()) - sizeof(cell));
 
-       dpush(tag<tuple>(t));
+       dpush(t.value());
 }
 
 /* push a new tuple on the stack, filling its slots from the stack */
 void factor_vm::primitive_tuple_boa()
 {
-       gc_root<tuple_layout> layout(dpop(),this);
-       gc_root<tuple> t(allot_tuple(layout.value()),this);
+       data_root<tuple_layout> layout(dpop(),this);
+       tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
+       t->layout = layout.value();
+
        cell size = untag_fixnum(layout.untagged()->size) * sizeof(cell);
-       memcpy(t->data(),(cell *)(ds - (size - sizeof(cell))),size);
+       memcpy(t->data(),(cell *)(ds - size + sizeof(cell)),size);
        ds -= size;
+
        dpush(t.value());
 }
 
index 04b23b58578e4f699b5ad558ed9b761f933c7da4..bcd041fc65d07b60b8d7cf6cbe13960b9200ad0c 100644 (file)
@@ -1,7 +1,7 @@
 namespace factor
 {
 
-inline static cell tuple_size(tuple_layout *layout)
+inline static cell tuple_size(const tuple_layout *layout)
 {
        cell size = untag_fixnum(layout->size);
        return sizeof(tuple) + size * sizeof(cell);
index 0595430283b72a05198e1863f3eee597cc23cb29..8f063a9ad4628686d3e366d007181a076a17d611 100755 (executable)
@@ -11,38 +11,6 @@ vm_char *safe_strdup(const vm_char *str)
        return ptr;
 }
 
-/* We don't use printf directly, because format directives are not portable.
-Instead we define the common cases here. */
-void nl()
-{
-       fputs("\n",stdout);
-}
-
-void print_string(const char *str)
-{
-       fputs(str,stdout);
-}
-
-void print_cell(cell x)
-{
-       printf(CELL_FORMAT,x);
-}
-
-void print_cell_hex(cell x)
-{
-       printf(CELL_HEX_FORMAT,x);
-}
-
-void print_cell_hex_pad(cell x)
-{
-       printf(CELL_HEX_PAD_FORMAT,x);
-}
-
-void print_fixnum(fixnum x)
-{
-       printf(FIXNUM_FORMAT,x);
-}
-
 cell read_cell_hex()
 {
        cell cell;
index f93fe13f78b2b65e83c1beece7dc21892126b3ed..94b9de6f483d98cbaf9fd8a66a64e2fbae65d28c 100755 (executable)
@@ -1,11 +1,31 @@
 namespace factor
 {
-       vm_char *safe_strdup(const vm_char *str);
-       void print_string(const char *str);
-       void nl();
-       void print_cell(cell x);
-       void print_cell_hex(cell x);
-       void print_cell_hex_pad(cell x);
-       void print_fixnum(fixnum x);
-       cell read_cell_hex();
+
+inline static void memset_cell(void *dst, cell pattern, size_t size)
+{
+#ifdef __APPLE__
+       #ifdef FACTOR_64
+               memset_pattern8(dst,&pattern,size);
+       #else
+               memset_pattern4(dst,&pattern,size);
+       #endif
+#else
+       if(pattern == 0)
+               memset(dst,0,size);
+       else
+       {
+               cell *start = (cell *)dst;
+               cell *end = (cell *)((cell)dst + size);
+               while(start < end)
+               {
+                       *start = pattern;
+                       start++;
+               }
+       }
+#endif
+}
+
+vm_char *safe_strdup(const vm_char *str);
+cell read_cell_hex();
+
 }
index 50dc441086e6543e566d9fa8f36357755f479925..72c63292fd94d25d89d85a9832fb492c0eaaae61 100755 (executable)
--- a/vm/vm.cpp
+++ b/vm/vm.cpp
@@ -6,11 +6,13 @@ namespace factor
 factor_vm::factor_vm() :\r
        nursery(0,0),\r
        profiling_p(false),\r
-       secure_gc(false),\r
        gc_off(false),\r
        current_gc(NULL),\r
+       gc_events(NULL),\r
        fep_disabled(false),\r
        full_output(false)\r
-       { }\r
+{\r
+       primitive_reset_dispatch_stats();\r
+}\r
 \r
 }\r
index c1c6014eea9aaab7b5ebfc7e03e88b587fa08a8d..c1f7fdb1295ce8319fdbe877484ca83172fb2e87 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -2,6 +2,7 @@ namespace factor
 {
 
 struct growable_array;
+struct code_root;
 
 struct factor_vm
 {
@@ -11,14 +12,14 @@ struct factor_vm
        context *ctx;
        
        /* New objects are allocated here */
-       zone nursery;
+       nursery_space nursery;
 
        /* Add this to a shifted address to compute write barrier offsets */
        cell cards_offset;
        cell decks_offset;
 
        /* TAGGED user environment data; see getenv/setenv prims */
-       cell userenv[USER_ENV];
+       cell special_objects[special_object_count];
 
        /* Data stack and retain stack sizes */
        cell ds_size, rs_size;
@@ -39,13 +40,6 @@ struct factor_vm
        unsigned int signal_fpu_status;
        stack_frame *signal_callstack_top;
 
-       /* Zeroes out deallocated memory; set by the -securegc command line argument */
-       bool secure_gc;
-
-       /* A heap walk allows useful things to be done, like finding all
-          references to an object for debugging purposes. */
-       cell heap_scan_ptr;
-
        /* GC is off during heap walking */
        bool gc_off;
 
@@ -61,14 +55,16 @@ struct factor_vm
        /* Only set if we're performing a GC */
        gc_state *current_gc;
 
-       /* Statistics */
-       gc_statistics gc_stats;
+       /* If not NULL, we push GC events here */
+       std::vector<gc_event> *gc_events;
 
        /* If a runtime function needs to call another function which potentially
-          allocates memory, it must wrap any local variable references to Factor
-          objects in gc_root instances */
-       std::vector<cell> gc_locals;
-       std::vector<cell> gc_bignums;
+          allocates memory, it must wrap any references to the data and code
+          heaps with data_root and code_root smart pointers, which register
+          themselves here. See data_roots.hpp and code_roots.hpp */
+       std::vector<data_root_range> data_roots;
+       std::vector<cell> bignum_roots;
+       std::vector<code_root *> code_roots;
 
        /* Debugger */
        bool fep_disabled;
@@ -80,18 +76,14 @@ struct factor_vm
        cell bignum_neg_one;
 
        /* Method dispatch statistics */
-       cell megamorphic_cache_hits;
-       cell megamorphic_cache_misses;
-
-       cell cold_call_to_ic_transitions;
-       cell ic_to_pic_transitions;
-       cell pic_to_mega_transitions;
-       /* Indexed by PIC_TAG, PIC_HI_TAG, PIC_TUPLE, PIC_HI_TAG_TUPLE */
-       cell pic_counts[4];
+       dispatch_statistics dispatch_stats;
 
        /* Number of entries in a polymorphic inline cache */
        cell max_pic_size;
 
+       /* Incrementing object counter for identity hashing */
+       cell object_counter;
+
        // contexts
        void reset_datastack();
        void reset_retainstack();
@@ -109,6 +101,7 @@ struct factor_vm
        void primitive_set_datastack();
        void primitive_set_retainstack();
        void primitive_check_datastack();
+       void primitive_load_locals();
 
        template<typename Iterator> void iterate_active_frames(Iterator &iter)
        {
@@ -123,15 +116,21 @@ struct factor_vm
        }
 
        // run
-       void primitive_getenv();
-       void primitive_setenv();
        void primitive_exit();
        void primitive_micros();
        void primitive_sleep();
        void primitive_set_slot();
-       void primitive_load_locals();
+
+       // objects
+       void primitive_special_object();
+       void primitive_set_special_object();
+       void primitive_identity_hashcode();
+       void compute_identity_hashcode(object *obj);
+       void primitive_compute_identity_hashcode();
+       cell object_size(cell tagged);
        cell clone_object(cell obj_);
        void primitive_clone();
+       void primitive_become();
 
        // profiler
        void init_profiler();
@@ -220,25 +219,38 @@ struct factor_vm
 
        //data heap
        void init_card_decks();
-       void clear_cards(old_space *gen);
-       void clear_decks(old_space *gen);
-       void reset_generation(old_space *gen);
        void set_data_heap(data_heap *data_);
-       void init_data_heap(cell young_size, cell aging_size, cell tenured_size, bool secure_gc_);
-       cell untagged_object_size(object *pointer);
-       cell unaligned_object_size(object *pointer);
+       void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
        void primitive_size();
-       cell binary_payload_start(object *pointer);
+       data_heap_room data_room();
        void primitive_data_room();
        void begin_scan();
        void end_scan();
-       void primitive_begin_scan();
-       cell next_object();
-       void primitive_next_object();
-       void primitive_end_scan();
-       template<typename Iterator> void each_object(Iterator &iterator);
+       cell instances(cell type);
+       void primitive_all_instances();
        cell find_all_words();
-       cell object_size(cell tagged);
+
+       template<typename Generation, typename Iterator>
+       inline void each_object(Generation *gen, Iterator &iterator)
+       {
+               cell obj = gen->first_object();
+               while(obj)
+               {
+                       iterator((object *)obj);
+                       obj = gen->next_object_after(obj);
+               }
+       }
+
+       template<typename Iterator> inline void each_object(Iterator &iterator)
+       {
+               gc_off = true;
+
+               each_object(data->tenured,iterator);
+               each_object(data->aging,iterator);
+               each_object(data->nursery,iterator);
+
+               gc_off = false;
+       }
 
        /* the write barrier must be called any time we are potentially storing a
           pointer from an older generation to a younger one */
@@ -248,30 +260,47 @@ struct factor_vm
                *(char *)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
        }
 
+       inline void write_barrier(object *obj, cell size)
+       {
+               cell start = (cell)obj & -card_size;
+               cell end = ((cell)obj + size + card_size - 1) & -card_size;
+
+               for(cell offset = start; offset < end; offset += card_size)
+                       write_barrier((cell *)offset);
+       }
+
+       // data heap checker
+       void check_data_heap();
+
        // gc
+       void end_gc();
+       void start_gc_again();
        void update_code_heap_for_minor_gc(std::set<code_block *> *remembered_set);
        void collect_nursery();
        void collect_aging();
        void collect_to_tenured();
-       void collect_full_impl(bool trace_contexts_p);
-       void collect_growing_heap(cell requested_bytes, bool trace_contexts_p, bool compact_code_heap_p);
-       void collect_full(bool trace_contexts_p, bool compact_code_heap_p);
-       void record_gc_stats(generation_statistics *stats);
-       void gc(gc_op op, cell requested_bytes, bool trace_contexts_p, bool compact_code_heap_p);
+       void update_code_roots_for_sweep();
+       void update_code_roots_for_compaction();
+       void collect_mark_impl(bool trace_contexts_p);
+       void collect_sweep_impl();
+       void collect_full(bool trace_contexts_p);
+       void collect_compact_impl(bool trace_contexts_p);
+       void collect_compact_code_impl(bool trace_contexts_p);
+       void collect_compact(bool trace_contexts_p);
+       void collect_growing_heap(cell requested_bytes, bool trace_contexts_p);
+       void gc(gc_op op, cell requested_bytes, bool trace_contexts_p);
        void primitive_minor_gc();
        void primitive_full_gc();
        void primitive_compact_gc();
-       void primitive_gc_stats();
-       void clear_gc_stats();
-       void primitive_become();
-       void inline_gc(cell *gc_roots_base, cell gc_roots_size);
-       object *allot_object(header header, cell size);
-       void add_gc_stats(generation_statistics *stats, growable_array *result);
-       void primitive_clear_gc_stats();
+       void inline_gc(cell *data_roots_base, cell data_roots_size);
+       void primitive_enable_gc_events();
+       void primitive_disable_gc_events();
+       object *allot_object(cell type, cell size);
+       object *allot_large_object(cell type, cell size);
 
        template<typename Type> Type *allot(cell size)
        {
-               return (Type *)allot_object(header(Type::type_number),size);
+               return (Type *)allot_object(Type::type_number,size);
        }
 
        inline void check_data_pointer(object *pointer)
@@ -285,20 +314,8 @@ struct factor_vm
        #endif
        }
 
-       inline void check_tagged_pointer(cell tagged)
-       {
-       #ifdef FACTOR_DEBUG
-               if(!immediate_p(tagged))
-               {
-                       object *obj = untag<object>(tagged);
-                       check_data_pointer(obj);
-                       obj->h.hi_tag();
-               }
-       #endif
-       }
-
        // generic arrays
-       template<typename Array> Array *allot_array_internal(cell capacity);
+       template<typename Array> Array *allot_uninitialized_array(cell capacity);
        template<typename Array> bool reallot_array_in_place_p(Array *array, cell capacity);
        template<typename Array> Array *reallot_array(Array *array_, cell capacity);
 
@@ -316,7 +333,7 @@ struct factor_vm
        void print_callstack();
        void dump_cell(cell x);
        void dump_memory(cell from, cell to);
-       void dump_zone(const char *name, zone *z);
+       template<typename Generation> void dump_generation(const char *name, Generation *gen);
        void dump_generations();
        void dump_objects(cell type);
        void find_data_references_step(cell *scan);
@@ -335,7 +352,7 @@ struct factor_vm
        inline void set_array_nth(array *array, cell slot, cell value);
 
        //strings
-       cell string_nth(string* str, cell index);
+       cell string_nth(const string *str, cell index);
        void set_string_nth_fast(string *str, cell index, cell ch);
        void set_string_nth_slow(string *str_, cell index, cell ch);
        void set_string_nth(string *str, cell index, cell ch);
@@ -361,8 +378,9 @@ struct factor_vm
        void primitive_uninitialized_byte_array();
        void primitive_resize_byte_array();
 
+       template<typename Type> byte_array *byte_array_from_value(Type *value);
+
        //tuples
-       tuple *allot_tuple(cell layout_);
        void primitive_tuple();
        void primitive_tuple_boa();
 
@@ -370,7 +388,7 @@ struct factor_vm
        word *allot_word(cell name_, cell vocab_, cell hashcode_);
        void primitive_word();
        void primitive_word_xt();
-       void update_word_xt(cell w_);
+       void update_word_xt(word *w_);
        void primitive_optimized_p();
        void primitive_wrapper();
 
@@ -409,7 +427,8 @@ struct factor_vm
        void primitive_bignum_log2();
        unsigned int bignum_producer(unsigned int digit);
        void primitive_byte_array_to_bignum();
-       cell unbox_array_size();
+       inline cell unbox_array_size();
+       cell unbox_array_size_slow();
        void primitive_fixnum_to_float();
        void primitive_bignum_to_float();
        void primitive_str_to_float();
@@ -458,8 +477,9 @@ struct factor_vm
        inline double untag_float_check(cell tagged);
        inline fixnum float_to_fixnum(cell tagged);
        inline double fixnum_to_float(cell tagged);
+
+       // tagged
        template<typename Type> Type *untag_check(cell value);
-       template<typename Type> Type *untag(cell value);
 
        //io
        void init_c_io();
@@ -494,12 +514,12 @@ struct factor_vm
        void update_literal_references(code_block *compiled);
        void relocate_code_block_step(relocation_entry rel, cell index, code_block *compiled);
        void update_word_references(code_block *compiled);
-       void update_code_block_for_full_gc(code_block *compiled);
+       void update_code_block_words_and_literals(code_block *compiled);
        void check_code_address(cell address);
        void relocate_code_block(code_block *compiled);
        void fixup_labels(array *labels, code_block *compiled);
-       code_block *allot_code_block(cell size, cell type);
-       code_block *add_code_block(cell type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_);
+       code_block *allot_code_block(cell size, code_block_type type);
+       code_block *add_code_block(code_block_type type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_);
 
        //code heap
        inline void check_code_pointer(cell ptr)
@@ -513,25 +533,16 @@ struct factor_vm
        bool in_code_heap_p(cell ptr);
        void jit_compile_word(cell word_, cell def_, bool relocate);
        void update_code_heap_words();
+       void update_code_heap_words_and_literals();
        void primitive_modify_code_heap();
+       code_heap_room code_room();
        void primitive_code_room();
-       void forward_object_xts();
-       void forward_context_xts();
-       void forward_callback_xts();
-       void compact_code_heap(bool trace_contexts_p);
        void primitive_strip_stack_traces();
 
        /* Apply a function to every code block */
        template<typename Iterator> void iterate_code_heap(Iterator &iter)
        {
-               heap_block *scan = code->first_block();
-
-               while(scan)
-               {
-                       if(scan->type() != FREE_BLOCK_TYPE)
-                               iter((code_block *)scan);
-                       scan = code->next_block(scan);
-               }
+               code->allocator->iterate(iter);
        }
 
        //callbacks
@@ -566,7 +577,7 @@ struct factor_vm
        void primitive_callstack();
        void primitive_set_callstack();
        code_block *frame_code(stack_frame *frame);
-       cell frame_type(stack_frame *frame);
+       code_block_type frame_type(stack_frame *frame);
        cell frame_executing(stack_frame *frame);
        stack_frame *frame_successor(stack_frame *frame);
        cell frame_scan(stack_frame *frame);
@@ -579,24 +590,6 @@ struct factor_vm
        void save_callstack_bottom(stack_frame *callstack_bottom);
        template<typename Iterator> void iterate_callstack(context *ctx, Iterator &iterator);
 
-       /* Every object has a regular representation in the runtime, which makes GC
-       much simpler. Every slot of the object until binary_payload_start is a pointer
-       to some other object. */
-       template<typename Iterator> void do_slots(cell obj, Iterator &iter)
-       {
-               cell scan = obj;
-               cell payload_start = binary_payload_start((object *)obj);
-               cell end = obj + payload_start;
-
-               scan += sizeof(cell);
-
-               while(scan < end)
-               {
-                       iter((cell *)scan);
-                       scan += sizeof(cell);
-               }
-       }
-
        //alien
        char *pinned_alien_offset(cell obj);
        cell allot_alien(cell delegate_, cell displacement);
@@ -633,8 +626,6 @@ struct factor_vm
        cell nth_superclass(tuple_layout *layout, fixnum echelon);
        cell nth_hashcode(tuple_layout *layout, fixnum echelon);
        cell lookup_tuple_method(cell obj, cell methods);
-       cell lookup_hi_tag_method(cell obj, cell methods);
-       cell lookup_hairy_method(cell obj, cell methods);
        cell lookup_method(cell obj, cell methods);
        void primitive_lookup_method();
        cell object_class(cell obj);
@@ -655,8 +646,6 @@ struct factor_vm
        cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
        void update_pic_transitions(cell pic_size);
        void *inline_cache_miss(cell return_address);
-       void primitive_reset_inline_cache_stats();
-       void primitive_inline_cache_stats();
 
        //factor
        void default_parameters(vm_parameters *p);
@@ -690,17 +679,12 @@ struct factor_vm
        void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
        bool windows_stat(vm_char *path);
 
-   #if defined(WINNT)
+  #if defined(WINNT)
        void open_console();
        LONG exception_handler(PEXCEPTION_POINTERS pe);
-       // next method here:
-   #endif
+  #endif
   #else  // UNIX
-       void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap);
-       void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap);
-       void fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap);
-       stack_frame *uap_stack_pointer(void *uap);
-
+       void dispatch_signal(void *uap, void (handler)());
   #endif
 
   #ifdef __APPLE__
@@ -711,6 +695,6 @@ struct factor_vm
 
 };
 
-extern unordered_map<THREADHANDLE, factor_vm *> thread_vms;
+extern std::map<THREADHANDLE, factor_vm *> thread_vms;
 
 }
index 6193a5c93c4f2b420def23c2bd03fb84bdfe15d2..dfaeed2496300b5e844a9f49dc088f2a11934a4b 100644 (file)
@@ -5,15 +5,15 @@ namespace factor
 
 word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
 {
-       gc_root<object> vocab(vocab_,this);
-       gc_root<object> name(name_,this);
+       data_root<object> vocab(vocab_,this);
+       data_root<object> name(name_,this);
 
-       gc_root<word> new_word(allot<word>(sizeof(word)),this);
+       data_root<word> new_word(allot<word>(sizeof(word)),this);
 
        new_word->hashcode = hashcode_;
        new_word->vocabulary = vocab.value();
        new_word->name = name.value();
-       new_word->def = userenv[UNDEFINED_ENV];
+       new_word->def = special_objects[OBJ_UNDEFINED];
        new_word->props = false_object;
        new_word->counter = tag_fixnum(0);
        new_word->pic_def = false_object;
@@ -23,7 +23,7 @@ word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
        new_word->code = NULL;
 
        jit_compile_word(new_word.value(),new_word->def,true);
-       update_word_xt(new_word.value());
+       update_word_xt(new_word.untagged());
 
        if(profiling_p)
                relocate_code_block(new_word->profiling);
@@ -43,7 +43,7 @@ void factor_vm::primitive_word()
 /* word-xt ( word -- start end ) */
 void factor_vm::primitive_word_xt()
 {
-       gc_root<word> w(dpop(),this);
+       data_root<word> w(dpop(),this);
        w.untag_check(this);
 
        if(profiling_p)
@@ -59,17 +59,17 @@ void factor_vm::primitive_word_xt()
 }
 
 /* Allocates memory */
-void factor_vm::update_word_xt(cell w_)
+void factor_vm::update_word_xt(word *w_)
 {
-       gc_root<word> w(w_,this);
+       data_root<word> w(w_,this);
 
        if(profiling_p)
        {
                if(!w->profiling)
                {
-                       /* Note: can't do w->profiling = ... since if LHS
-                       evaluates before RHS, since in that case if RHS does a
-                       GC, we will have an invalid pointer on the LHS */
+                       /* Note: can't do w->profiling = ... since LHS evaluates
+                       before RHS, and if RHS does a GC, we will have an
+                       invalid pointer on the LHS */
                        code_block *profiling = compile_profiling_stub(w.value());
                        w->profiling = profiling;
                }
@@ -82,7 +82,8 @@ void factor_vm::update_word_xt(cell w_)
 
 void factor_vm::primitive_optimized_p()
 {
-       drepl(tag_boolean(word_optimized_p(untag_check<word>(dpeek()))));
+       word *w = untag_check<word>(dpeek());
+       drepl(tag_boolean(w->code->optimized_p()));
 }
 
 void factor_vm::primitive_wrapper()
index 1701def6dce7326f9d71400fd66c1e21fe572525..412ef35bb4403ee39e5aa0ef975114ad79a07a9b 100644 (file)
@@ -1,9 +1,4 @@
 namespace factor
 {
 
-inline bool word_optimized_p(word *word)
-{
-       return word->code->type() == WORD_TYPE;
-}
-
 }
diff --git a/vm/zone.hpp b/vm/zone.hpp
deleted file mode 100644 (file)
index 4fe4ae9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace factor
-{
-
-struct zone {
-       /* offset of 'here' and 'end' is hardcoded in compiler backends */
-       cell here;
-       cell start;
-       cell end;
-       cell size;
-
-       zone(cell size_, cell start_) : here(0), start(start_), end(start_ + size_), size(size_) {}
-
-       inline bool contains_p(object *pointer)
-       {
-               return ((cell)pointer - start) < size;
-       }
-
-       inline object *allot(cell size)
-       {
-               cell h = here;
-               here = h + align8(size);
-               return (object *)h;
-       }
-};
-
-}