]> gitweb.factorcode.org Git - factor.git/commitdiff
mason: made build targets into a table and added timestamp on report clean-macosx-x86-64 clean-windows-x86-64
authornomennescio <nomennescio@factorcode.org>
Tue, 7 May 2024 11:07:08 +0000 (12:07 +0100)
committernomennescio <nomennescio@factorcode.org>
Tue, 7 May 2024 11:07:08 +0000 (12:07 +0100)
124 files changed:
.github/workflows/build.yml
.github/workflows/test_branch.yml
GNUmakefile
basis/bootstrap/assembler/arm.64.factor
basis/bootstrap/assembler/arm.unix.factor
basis/bootstrap/image/download/download.factor
basis/bootstrap/image/upload/upload.factor
basis/calendar/calendar.factor
basis/calendar/format/format-tests.factor
basis/calendar/format/format.factor
basis/cbor/cbor-tests.factor
basis/checksums/hmac/hmac-tests.factor
basis/checksums/hmac/hmac.factor
basis/checksums/md5/md5-tests.factor
basis/checksums/openssl/openssl-docs.factor
basis/checksums/sha/sha-tests.factor
basis/compiler/constants/constants-docs.factor
basis/compiler/constants/constants.factor
basis/cpu/arm/64/assembler/assembler.factor
basis/cpu/arm/64/assembler/opcodes/opcodes.factor
basis/escape-strings/escape-strings.factor
basis/escape-strings/ui/ui.factor
basis/formatting/formatting.factor
basis/functors/functors.factor
basis/furnace/auth/login/login.factor
basis/hex-strings/authors.txt [new file with mode: 0644]
basis/hex-strings/hex-strings-docs.factor [new file with mode: 0644]
basis/hex-strings/hex-strings-tests.factor [new file with mode: 0644]
basis/hex-strings/hex-strings.factor [new file with mode: 0644]
basis/interpolate/interpolate-docs.factor
basis/interpolate/interpolate-tests.factor
basis/interpolate/interpolate.factor
basis/inverse/inverse-docs.factor
basis/inverse/inverse-tests.factor
basis/inverse/inverse.factor
basis/io/directories/directories.factor
basis/io/files/info/info.factor
basis/io/files/windows/windows.factor
basis/ip-parser/ip-parser.factor
basis/math/bits/bits-docs.factor
basis/math/bits/bits-tests.factor
basis/math/bits/bits.factor
basis/oauth1/oauth1.factor
basis/regexp/classes/classes.factor
basis/sequences/product/product-docs.factor
basis/sequences/product/product-tests.factor
basis/sequences/product/product.factor
basis/tools/disassembler/capstone/capstone.factor
basis/ui/tools/listener/completion/completion.factor
basis/ui/tools/listener/history/history.factor
basis/ui/tools/listener/listener.factor
build.sh
core/io/files/files-tests.factor
core/io/files/files.factor
core/io/pathnames/pathnames-tests.factor
core/io/pathnames/pathnames.factor
core/math/parser/parser-docs.factor
core/math/parser/parser-tests.factor
core/math/parser/parser.factor
extra/aws/aws.factor
extra/backblaze/backblaze.factor
extra/base24/base24-tests.factor
extra/base58/base58-tests.factor
extra/benchmark/reverse-complement/reverse-complement-tests.factor
extra/checksums/process/process.factor
extra/colors/flex-hex/flex-hex.factor
extra/drunken-bishop/drunken-bishop.factor
extra/git/git.factor
extra/gravatar/gravatar.factor
extra/imap/imap.factor
extra/io/streams/tee/authors.txt [new file with mode: 0644]
extra/io/streams/tee/tee-tests.factor [new file with mode: 0644]
extra/io/streams/tee/tee.factor [new file with mode: 0644]
extra/marvel/marvel.factor
extra/mason/authors.txt
extra/mason/build/build.factor
extra/mason/git/git.factor
extra/mason/notify/notify.factor
extra/mason/report/report.factor
extra/mongodb/connection/connection.factor
extra/pcre2/pcre2-tests.factor
extra/pcre2/pcre2.factor
extra/scryfall/scryfall.factor
extra/sequences/prefixed/authors.txt [new file with mode: 0644]
extra/sequences/prefixed/prefixed-tests.factor [new file with mode: 0644]
extra/sequences/prefixed/prefixed.factor [new file with mode: 0644]
extra/sequences/prefixed/tags.txt [new file with mode: 0644]
extra/sequences/suffixed/authors.txt [new file with mode: 0644]
extra/sequences/suffixed/suffixed-tests.factor [new file with mode: 0644]
extra/sequences/suffixed/suffixed.factor [new file with mode: 0644]
extra/sequences/suffixed/tags.txt [new file with mode: 0644]
extra/visionect/visionect.factor
extra/webapps/mason/authors.txt
extra/webapps/mason/backend/backend.factor
extra/webapps/mason/benchmarks/authors.txt [new file with mode: 0644]
extra/webapps/mason/benchmarks/benchmarks.factor [new file with mode: 0644]
extra/webapps/mason/dashboard.xml
extra/webapps/mason/dashboard/dashboard.factor
extra/webapps/mason/mason.factor
extra/webapps/mason/status-update/status-update.factor
extra/webapps/mason/utils/utils.factor
extra/zealot/factor/factor.factor
extra/zim/tools/tools.factor
vm/Config.freebsd
vm/Config.linux
vm/Config.linux.arm
vm/Config.linux.arm.32
vm/Config.linux.arm.64
vm/Config.linux.ppc.32
vm/Config.linux.ppc.64
vm/Config.macosx
vm/Config.unix
vm/Config.windows
vm/Config.windows.x86.32
vm/Config.windows.x86.64
vm/Config.x86.32
vm/Config.x86.64
vm/Config.x86.fat
vm/bignum.cpp
vm/cpu-arm.hpp
vm/instruction_operands.cpp
vm/instruction_operands.hpp
vm/os-linux-arm.64.hpp
vm/os-linux-arm.cpp

index dc4da781504568f46cbcb9a8c27c0b27d5c13652..28c61fe6283ec0711179e2ef7363c17e8d401afd 100644 (file)
@@ -13,7 +13,7 @@ jobs:
   build-linux:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - name: bootstrap
       run: ./build.sh net-bootstrap
     - name: load-all
@@ -26,7 +26,7 @@ jobs:
   build-macos:
     runs-on: macos-11
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - name: build
       run: arch -x86_64 ./build.sh net-bootstrap
     - name: load-all
@@ -39,7 +39,7 @@ jobs:
   build-windows:
     runs-on: windows-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - uses: ilammy/msvc-dev-cmd@v1
     - name: build
       shell: cmd
index 125d82f9f45dfa0a0334a21bd6f27a76d5289e44..cc79c20a3ff81438aad388bd810c2b162ef244d7 100644 (file)
@@ -10,7 +10,7 @@ jobs:
   build-linux:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - name: bootstrap
       run: ./build.sh net-bootstrap
     - name: load-all
@@ -23,7 +23,7 @@ jobs:
   build-macos:
     runs-on: macos-11
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - name: build
       run: arch -x86_64 ./build.sh net-bootstrap
     - name: load-all
@@ -36,7 +36,7 @@ jobs:
   build-windows:
     runs-on: windows-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - uses: ilammy/msvc-dev-cmd@v1
     - name: build
       shell: cmd
index 36d83ef5d10678fbb63409bbb6a3ac3e67e7417f..7ecfc6850399876e48450888c037de18865b5e8f 100644 (file)
@@ -1,3 +1,6 @@
+# build-<target> or build
+BUILD_DIR ?= build
+
 ifdef CONFIG
        VERSION = 0.100
        GIT_LABEL = $(shell echo `git describe --all`-`git rev-parse HEAD`)
@@ -45,6 +48,7 @@ ifdef CONFIG
                CFLAGS += -g -DFACTOR_DEBUG
        else
                CFLAGS += -O3
+               CFLAGS += $(CC_OPT)
        endif
 
        ifneq ($(REPRODUCIBLE), 0)
@@ -56,47 +60,47 @@ ifdef CONFIG
        CONSOLE_EXECUTABLE = factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION)
 
        DLL_OBJS = $(PLAF_DLL_OBJS) \
-               vm/aging_collector.o \
-               vm/alien.o \
-               vm/arrays.o \
-               vm/bignum.o \
-               vm/byte_arrays.o \
-               vm/callbacks.o \
-               vm/callstack.o \
-               vm/code_blocks.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/entry_points.o \
-               vm/errors.o \
-               vm/factor.o \
-               vm/full_collector.o \
-               vm/gc.o \
-               vm/image.o \
-               vm/inline_cache.o \
-               vm/instruction_operands.o \
-               vm/io.o \
-               vm/jit.o \
-               vm/math.o \
-               vm/mvm.o \
-               vm/nursery_collector.o \
-               vm/object_start_map.o \
-               vm/objects.o \
-               vm/primitives.o \
-               vm/quotations.o \
-               vm/run.o \
-               vm/safepoints.o \
-               vm/sampling_profiler.o \
-               vm/strings.o \
-               vm/to_tenured_collector.o \
-               vm/tuples.o \
-               vm/utilities.o \
-               vm/vm.o \
-               vm/words.o
+               $(BUILD_DIR)/aging_collector.o \
+               $(BUILD_DIR)/alien.o \
+               $(BUILD_DIR)/arrays.o \
+               $(BUILD_DIR)/bignum.o \
+               $(BUILD_DIR)/byte_arrays.o \
+               $(BUILD_DIR)/callbacks.o \
+               $(BUILD_DIR)/callstack.o \
+               $(BUILD_DIR)/code_blocks.o \
+               $(BUILD_DIR)/code_heap.o \
+               $(BUILD_DIR)/compaction.o \
+               $(BUILD_DIR)/contexts.o \
+               $(BUILD_DIR)/data_heap.o \
+               $(BUILD_DIR)/data_heap_checker.o \
+               $(BUILD_DIR)/debug.o \
+               $(BUILD_DIR)/dispatch.o \
+               $(BUILD_DIR)/entry_points.o \
+               $(BUILD_DIR)/errors.o \
+               $(BUILD_DIR)/factor.o \
+               $(BUILD_DIR)/full_collector.o \
+               $(BUILD_DIR)/gc.o \
+               $(BUILD_DIR)/image.o \
+               $(BUILD_DIR)/inline_cache.o \
+               $(BUILD_DIR)/instruction_operands.o \
+               $(BUILD_DIR)/io.o \
+               $(BUILD_DIR)/jit.o \
+               $(BUILD_DIR)/math.o \
+               $(BUILD_DIR)/mvm.o \
+               $(BUILD_DIR)/nursery_collector.o \
+               $(BUILD_DIR)/object_start_map.o \
+               $(BUILD_DIR)/objects.o \
+               $(BUILD_DIR)/primitives.o \
+               $(BUILD_DIR)/quotations.o \
+               $(BUILD_DIR)/run.o \
+               $(BUILD_DIR)/safepoints.o \
+               $(BUILD_DIR)/sampling_profiler.o \
+               $(BUILD_DIR)/strings.o \
+               $(BUILD_DIR)/to_tenured_collector.o \
+               $(BUILD_DIR)/tuples.o \
+               $(BUILD_DIR)/utilities.o \
+               $(BUILD_DIR)/vm.o \
+               $(BUILD_DIR)/words.o
 
        MASTER_HEADERS = $(PLAF_MASTER_HEADERS) \
                vm/assert.hpp \
@@ -156,9 +160,11 @@ ifdef CONFIG
 
        FFI_TEST_LIBRARY = libfactor-ffi-test$(SHARED_DLL_EXTENSION)
 
-       TEST_OBJS = vm/ffi_test.o
+       TEST_OBJS = $(BUILD_DIR)/ffi_test.o
 endif
 
+# if CONFIG is not set, call build.sh and find a CONFIG
+# build.sh will call GNUMakefile again to start the build
 default:
        $(MAKE) `./build.sh make-target`
 
@@ -185,6 +191,7 @@ help:
        @echo "DEBUG=1  compile VM with debugging information"
        @echo "REPRODUCIBLE=1  compile VM without timestamp"
        @echo "SITE_CFLAGS=...  additional optimization flags"
+       @echo "LTO=1  compile VM with Link Time Optimization"
        @echo "X11=1  force link with X11 libraries instead of Cocoa (only on Mac OS X)"
 
 ALL = factor factor-ffi-test factor-lib
@@ -233,6 +240,7 @@ windows-x86-64:
        $(MAKE) $(ALL) CONFIG=vm/Config.windows.x86.64
        $(MAKE) factor-console CONFIG=vm/Config.windows.x86.64
 
+# Actually build Factor
 ifdef CONFIG
 
 macosx.app: factor
@@ -256,25 +264,29 @@ factor-console: $(EXE_OBJS) $(DLL_OBJS)
 
 factor-ffi-test: $(FFI_TEST_LIBRARY)
 
-$(FFI_TEST_LIBRARY): vm/ffi_test.o
+$(BUILD_DIR):
+       @echo BUILD_DIR: $(BUILD_DIR)
+       @mkdir -p $(BUILD_DIR)
+
+$(FFI_TEST_LIBRARY): $(BUILD_DIR)/ffi_test.o | $(BUILD_DIR)
        $(TOOLCHAIN_PREFIX)$(CC) $(CFLAGS) $(FFI_TEST_CFLAGS) $(SHARED_FLAG) -o $(FFI_TEST_LIBRARY) $(TEST_OBJS)
 
-vm/resources.o:
-       $(TOOLCHAIN_PREFIX)$(WINDRES) --preprocessor=cat vm/factor.rs vm/resources.o
+$(BUILD_DIR)/resources.o: vm/factor.rs | $(BUILD_DIR)
+       $(TOOLCHAIN_PREFIX)$(WINDRES) --preprocessor=cat $< $@
 
-vm/ffi_test.o: vm/ffi_test.c
+$(BUILD_DIR)/ffi_test.o: vm/ffi_test.c | $(BUILD_DIR)
        $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) $(FFI_TEST_CFLAGS) -std=c99 -o $@ $<
 
-vm/master.hpp.gch: vm/master.hpp $(MASTER_HEADERS)
+$(BUILD_DIR)/master.hpp.gch: vm/master.hpp $(MASTER_HEADERS) | $(BUILD_DIR)
        $(TOOLCHAIN_PREFIX)$(CXX) -c -x c++-header $(CFLAGS) $(CXXFLAGS) -o $@ $<
 
-%.o: %.cpp vm/master.hpp.gch
+$(BUILD_DIR)/%.o: vm/%.cpp $(BUILD_DIR)/master.hpp.gch | $(BUILD_DIR)
        $(TOOLCHAIN_PREFIX)$(CXX) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
 
-%.o: %.S
+$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.S | $(BUILD_DIR)
        $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
 
-%.o: %.mm vm/master.hpp.gch
+$(BUILD_DIR)/%.o: vm/%.mm $(BUILD_DIR)/master.hpp.gch | $(BUILD_DIR)
        $(TOOLCHAIN_PREFIX)$(CXX) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
 
 .SUFFIXES: .mm
@@ -282,8 +294,14 @@ vm/master.hpp.gch: vm/master.hpp $(MASTER_HEADERS)
 endif
 
 clean:
-       rm -f vm/*.gch
+       @echo make clean CONFIG: \`$(CONFIG)\`
+       @echo make clean BUILD_DIR: \`$(BUILD_DIR)\`
+       if [ -n "$(BUILD_DIR)" ] && [ "$(BUILD_DIR)" != "/" ]; then rm -f $(BUILD_DIR)/*.o; rm -f $(BUILD_DIR)/*.gch; fi
+       rm -f build/*.o
+       rm -f build/*.gch
        rm -f vm/*.o
+       rm -f vm/*.gch
+       rm -f factor
        rm -f factor.dll
        rm -f factor.lib
        rm -f factor.dll.lib
index ccc1408d60120b16db57e1042b0355d3211923f7..bd6e9b4adf319cb918ddfe79bdb00f6908ec6ede 100644 (file)
@@ -12,6 +12,13 @@ IN: bootstrap.assembler.arm
 
 big-endian off
 
+: context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
+: context-callstack-bottom-offset ( -- n ) 2 bootstrap-cells ; inline
+: context-datastack-offset ( -- n ) 3 bootstrap-cells ; inline
+: context-retainstack-offset ( -- n ) 4 bootstrap-cells ; inline
+: context-callstack-save-offset ( -- n ) 5 bootstrap-cells ; inline
+: context-callstack-seg-offset ( -- n ) 8 bootstrap-cells ; inline
+
 ! X0-X17  volatile     scratch registers
 ! X0-X8                parameter registers
 ! X0                   result register
@@ -77,14 +84,23 @@ big-endian off
 : store1 ( -- ) 0 ds-reg temp1 STRuoff ;
 : store0/1 ( -- ) -8 ds-reg temp1 temp0 STPsoff ;
 : store0/2 ( -- ) -8 ds-reg temp2 temp0 STPsoff ;
+: store2/0 ( -- ) -8 ds-reg temp0 temp2 STPsoff ;
 : store1/0 ( -- ) -8 ds-reg temp0 temp1 STPsoff ;
 : store1/2 ( -- ) -16 ds-reg temp2 temp1 STPsoff ;
 
+! add tag bits to integers
 :: tag ( reg -- ) tag-bits get reg reg LSLi ;
+! remove tag bits
 :: untag ( reg -- ) tag-bits get reg reg ASRi ;
+
 : tagged>offset0 ( -- ) 1 temp0 temp0 ASRi ;
 
+! pops an item from the data stack and pushes it 
+! onto the retain stack (used for dip-like operations)
 : >r ( -- ) pop0 pushr ;
+
+! pops an item from the retain stack and pushes it 
+! onto the data stack (used for dip-like operations)
 : r> ( -- ) popr push0 ;
 
 : absolute-jump ( -- word class )
@@ -100,32 +116,25 @@ big-endian off
     3 words Br
     NOP NOP f rc-absolute-cell ; inline
 
+! This is used when a word is called at the end of a quotation.
+! JIT-WORD-CALL is used for other word calls.
 [
-    ! ! pic-tail-reg 5 [RIP+] LEA
     ! why do we store the address after JMP in EBX, where is it
     ! picked up?
     4 pic-tail-reg ADR
-    ! ! 0 JMP f rc-relative rel-word-pic-tail
-    ! 0 Br f rc-relative-arm64-branch rel-word-pic-tail
     absolute-jump rel-word-pic-tail
 ] JIT-WORD-JUMP jit-define
 
+! This is used when a word is called. 
+! JIT-WORD-JUMP is used if the word is the last piece of code in a quotation.
 [
-    ! ! 0 CALL f rc-relative rel-word-pic
-    ! push-link-reg
-    ! 0 BL f rc-relative-arm64-branch rel-word-pic
-    ! pop-link-reg
     absolute-call rel-word-pic
 ] JIT-WORD-CALL jit-define
 
 : jit-call ( name -- )
-    ! RAX 0 MOV f rc-absolute-cell rel-dlsym
-    ! RAX CALL ;
     absolute-call rel-dlsym ;
 
 :: jit-call-1arg ( arg1s name -- )
-    ! arg1 arg1s MOVr
-    ! name jit-call ;
     arg1s arg1 MOVr
     name jit-call ;
 
@@ -137,31 +146,31 @@ big-endian off
     arg2s arg2 MOVr
     name jit-call ;
 
+! loads the address of the vm struct. 
+! A no-op on ARM (vm-reg always contains this address).
 : jit-load-vm ( -- ) ;
 
+! Loads the address of the ctx struct into ctx-reg.
 : jit-load-context ( -- )
-    ! ctx-reg vm-reg vm-context-offset [+] MOV ;
     vm-context-offset vm-reg ctx-reg LDRuoff ;
 
+! Saves the addresses of the callstack, datastack, and retainstack tops 
+! into the corresponding fields in the ctx struct.
 : jit-save-context ( -- )
     jit-load-context
     ! The reason for -8 I think is because we are anticipating a CALL
     ! instruction. After the call instruction, the contexts frame_top
     ! will point to the origin jump address.
-    ! R11 RSP -8 [+] LEA
-    ! ctx-reg context-callstack-top-offset [+] R11 MOV
     stack-reg temp0 MOVsp
     16 temp0 temp0 SUBi
     context-callstack-top-offset ctx-reg temp0 STRuoff
-    ! ctx-reg context-datastack-offset [+] ds-reg MOV
-    ! ctx-reg context-retainstack-offset [+] rs-reg MOV ;
     context-datastack-offset ctx-reg ds-reg STRuoff
     context-retainstack-offset ctx-reg rs-reg STRuoff ;
 
-! ctx-reg must already have been loaded
+! Retrieves the addresses of the datastack and retainstack tops 
+! from the corresponding fields in the ctx struct.
+! ctx-reg must already have been loaded.
 : jit-restore-context ( -- )
-    ! ds-reg ctx-reg context-datastack-offset [+] MOV
-    ! rs-reg ctx-reg context-retainstack-offset [+] MOV ;
     context-datastack-offset ctx-reg ds-reg LDRuoff
     context-retainstack-offset ctx-reg rs-reg LDRuoff ;
 
@@ -178,18 +187,35 @@ big-endian off
     jit-restore-context
 ] JIT-PRIMITIVE jit-define
 
+! Used to a call a quotation if the quotation is the last piece of code
 : jit-jump-quot ( -- )
-    ! arg1 quot-entry-point-offset [+] JMP ;
     quot-entry-point-offset arg1 temp0 LDUR
     temp0 BR ;
 
+! Used to call a quotation if the quotation is not the last piece of code
 : jit-call-quot ( -- )
-    ! arg1 quot-entry-point-offset [+] CALL ;
     push-link-reg
     quot-entry-point-offset arg1 temp0 LDUR
     temp0 BLR
     pop-link-reg ;
 
+! calls a quotation
+[
+    pop-arg1
+]
+[ jit-call-quot ]
+[ jit-jump-quot ]
+\ (call) define-combinator-primitive
+
+[
+    jit-save-context
+    vm-reg arg2 MOVr
+    "lazy_jit_compile" jit-call
+]
+[ jit-call-quot ]
+[ jit-jump-quot ]
+\ lazy-jit-compile define-combinator-primitive
+
 [
     ! temp2 0 MOV f rc-absolute-cell rel-literal
     ! temp1 temp2 CMP
@@ -199,6 +225,7 @@ big-endian off
     NOP NOP f rc-absolute-cell rel-literal
 ] PIC-CHECK-TUPLE jit-define
 
+
 ! Inline cache miss entry points
 : jit-load-return-address ( -- )
     ! RBX RSP stack-frame-size bootstrap-cell - [+] MOV ;
@@ -261,32 +288,22 @@ big-endian off
     ctx-reg jit-update-tib ;
 
 : jit-pop-context-and-param ( -- )
-    ! arg1 ds-reg [] MOV
-    ! arg1 arg1 alien-offset [+] MOV
-    ! arg2 ds-reg -8 [+] MOV
-    ! ds-reg 16 SUB ;
     pop-arg1
     alien-offset arg1 arg1 ADDi
     0 arg1 arg1 LDRuoff
     pop-arg2 ;
 
 : jit-push-param ( -- )
-    ! ds-reg 8 ADD
-    ! ds-reg [] arg2 MOV ;
     push-arg2 ;
 
 : jit-set-context ( -- )
     jit-pop-context-and-param
     jit-save-context
     arg1 jit-switch-context
-    ! RSP 8 ADD
     16 stack-reg stack-reg ADDi
     jit-push-param ;
 
 : jit-pop-quot-and-param ( -- )
-    ! arg1 ds-reg [] MOV
-    ! arg2 ds-reg -8 [+] MOV
-    ! ds-reg 16 SUB ;
     pop-arg1 pop-arg2 ;
 
 : jit-start-context ( -- )
@@ -327,16 +344,16 @@ big-endian off
     jit-jump-quot ;
 
 [
-    ! 0 [RIP+] EAX MOV rc-relative rel-safepoint
     3 words temp0 LDRl
     0 temp0 W0 STRuoff
     3 words Br
     NOP NOP rc-absolute-cell rel-safepoint
 ] JIT-SAFEPOINT jit-define
 
-! C to Factor entry point
+! The main C to Factor entry point. 
+! Sets up and executes the boot quote, 
+! then performs a teardown and returns into C++. 
 [
-    0xabcd BRK
     ! ! Optimizing compiler's side of callback accesses
     ! ! arguments that are on the stack via the frame pointer.
     ! ! On x86-32 fastcall, and x86-64, some arguments are passed
@@ -345,8 +362,7 @@ big-endian off
     ! frame-reg PUSH
     ! frame-reg stack-reg MOV
 
-    ! ! Save all non-volatile registers
-    ! nv-regs [ PUSH ] each
+    ! Save all non-volatile registers
     -16 SP X19 X18 STPpre
     -16 SP X21 X20 STPpre
     -16 SP X23 X22 STPpre
@@ -358,74 +374,52 @@ big-endian off
 
     jit-save-tib
 
-    ! ! Load VM into vm-reg
-    ! vm-reg 0 MOV 0 rc-absolute-cell rel-vm
+    ! Load VM into vm-reg
     2 words vm-reg LDRl
     3 words Br
     NOP NOP 0 rc-absolute-cell rel-vm
 
-    ! ! Save old context
-    ! nv-reg vm-reg vm-context-offset [+] MOV
-    ! nv-reg PUSH
+    ! Save old context
     vm-context-offset vm-reg ctx-reg LDRuoff
     8 SP ctx-reg STRuoff
 
-    ! ! Switch over to the spare context
-    ! nv-reg vm-reg vm-spare-context-offset [+] MOV
-    ! vm-reg vm-context-offset [+] nv-reg MOV
+    ! Switch over to the spare context
     vm-spare-context-offset vm-reg ctx-reg LDRuoff
     vm-context-offset vm-reg ctx-reg STRuoff
 
-    ! ! Save C callstack pointer
-    ! nv-reg context-callstack-save-offset [+] stack-reg MOV
-
+    ! Save C callstack pointer
     stack-reg temp0 MOVsp
     context-callstack-save-offset ctx-reg temp0 STRuoff
-    ! stack-reg X24 MOVsp
-    ! NOP
 
-    ! ! Load Factor stack pointers
-    ! stack-reg nv-reg context-callstack-bottom-offset [+] MOV
+    ! Load Factor stack pointers
     context-callstack-bottom-offset ctx-reg temp0 LDRuoff
     temp0 stack-reg MOVsp
 
     ctx-reg jit-update-tib
     jit-install-seh
 
-    ! rs-reg nv-reg context-retainstack-offset [+] MOV
-    ! ds-reg nv-reg context-datastack-offset [+] MOV
     context-retainstack-offset ctx-reg rs-reg LDRuoff
     context-datastack-offset ctx-reg ds-reg LDRuoff
 
-    ! ! Call into Factor code
-    ! link-reg 0 MOV f rc-absolute-cell rel-word
-    ! link-reg CALL
+    ! Call into Factor code
     3 words temp0 LDRl
     temp0 BLR
     3 words Br
     NOP NOP f rc-absolute-cell rel-word
 
-    ! ! Load C callstack pointer
-    ! nv-reg vm-reg vm-context-offset [+] MOV
-    ! stack-reg nv-reg context-callstack-save-offset [+] MOV
+    ! Load C callstack pointer
     vm-context-offset vm-reg ctx-reg LDRuoff
 
     context-callstack-save-offset ctx-reg temp0 LDRuoff
     temp0 stack-reg MOVsp
-    ! X24 stack-reg MOVsp
-    ! NOP
 
-    ! ! Load old context
-    ! nv-reg POP
-    ! vm-reg vm-context-offset [+] nv-reg MOV
+    ! Load old context
     8 SP ctx-reg LDRuoff
     vm-context-offset vm-reg ctx-reg STRuoff
 
     jit-restore-tib
 
-    ! ! Restore non-volatile registers
-    ! nv-regs <reversed> [ POP ] each
-    ! frame-reg POP
+    ! Restore non-volatile registers
     16 SP X30 LDRpost
     16 SP X29 X28 LDPpost
     16 SP X27 X26 LDPpost
@@ -434,28 +428,19 @@ big-endian off
     16 SP X21 X20 LDPpost
     16 SP X19 X18 LDPpost
 
-    ! Callbacks which return structs, or use stdcall/fastcall/thiscall,
-    ! need a parameter here.
+    ! Callbacks which return structs, or use stdcall/fastcall/thiscall,
+    ! need a parameter here.
 
-    ! ! See the comment for M\ x86.32 stack-cleanup in cpu.x86.32
-    ! 0xffff RET f rc-absolute-2 rel-untagged
-    4 words temp0 ADR
-    2 temp0 temp0 LDRHuoff
-    temp0 stack-reg stack-reg ADDr
     f RET
-    NOP f rc-absolute-2 rel-untagged
 ] CALLBACK-STUB jit-define
 
+! pushes a literal value to the stack
 [
-    ! ! load literal
-    ! temp0 0 MOV f rc-absolute-cell rel-literal
+    ! load literal
     2 words temp0 LDRl
     3 words Br
     NOP NOP f rc-absolute-cell rel-literal
-    ! ! increment datastack pointer
-    ! ds-reg bootstrap-cell ADD
-    ! ! store literal on datastack
-    ! ds-reg [] temp0 MOV
+    ! store literal on datastack
     push0
 ] JIT-PUSH-LITERAL jit-define
 
@@ -522,56 +507,42 @@ big-endian off
     16 SP X3 X2 LDPpost
     16 SP X1 X0 LDPpost ;
 
+! if-statement control flow
 [
-    ! ! load boolean
-    ! temp0 ds-reg [] MOV
-    ! ! pop boolean
-    ! ds-reg bootstrap-cell SUB
+    ! pop boolean
     pop0
-    ! ! compare boolean with f
-    ! temp0 \ f type-number CMP
+    ! compare boolean with f
     \ f type-number temp0 CMPi
-    ! ! jump to true branch if not equal
-    ! ! 0 JNE f rc-relative rel-word
-    ! 0 NE B.cond f rc-relative-arm64-bcond rel-word
+    ! skip over true branch if equal
     5 words EQ B.cond
+    ! jump to true branch
     absolute-jump rel-word
-    ! ! jump to false branch if equal
-    ! ! 0 JMP f rc-relative rel-word
-    ! 0 Br f rc-relative-arm64-branch rel-word
+    ! jump to false branch
     absolute-jump rel-word
 ] JIT-IF jit-define
 
+! calls the second item on the stack
 [
     >r
-    ! ! 0 CALL f rc-relative rel-word
-    ! push-link-reg
-    ! 0 Br f rc-relative-arm64-branch rel-word
-    ! pop-link-reg
     absolute-call rel-word
     r>
 ] JIT-DIP jit-define
 
+! calls the third item on the stack
 [
     >r >r
-    ! ! 0 CALL f rc-relative rel-word
-    ! push-link-reg
-    ! 0 Br f rc-relative-arm64-branch rel-word
-    ! pop-link-reg
     absolute-call rel-word
     r> r>
 ] JIT-2DIP jit-define
 
+! calls the fourth item on the stack
 [
     >r >r >r
-    ! ! 0 CALL f rc-relative rel-word
-    ! push-link-reg
-    ! 0 Br f rc-relative-arm64-branch rel-word
-    ! pop-link-reg
     absolute-call rel-word
     r> r> r>
 ] JIT-3DIP jit-define
 
+! executes a word pushed onto the stack with \
 [
     ! ! load from stack
     ! temp0 ds-reg [] MOV
@@ -598,19 +569,20 @@ big-endian off
 ] JIT-EXECUTE jit-define
 
 ! https://elixir.bootlin.com/linux/latest/source/arch/arm64/kernel/stacktrace.c#L22
+! Performs setup for a quotation
 [
     ! ! make room for LR plus magic number of callback, 16byte align
-    ! x64 ! stack-reg stack-frame-size bootstrap-cell - SUB
     stack-frame-size stack-reg stack-reg SUBi
     push-link-reg
 ] JIT-PROLOG jit-define
 
+! Performs teardown for a quotation
 [
-    ! x64 ! stack-reg stack-frame-size bootstrap-cell - ADD
     pop-link-reg
     stack-frame-size stack-reg stack-reg ADDi
 ] JIT-EPILOG jit-define
 
+! returns to the outer stack frame
 [ f RET ] JIT-RETURN jit-define
 
 ! ! ! Polymorphic inline caches
@@ -627,6 +599,13 @@ big-endian off
     NOP f rc-absolute-1 rel-untagged
 ] PIC-LOAD jit-define
 
+! ! Factor 2024 Clinic Code:
+! ! this arm relocation could actually work
+! ! due to the small bitwidth required  
+! 0 0 temp2 MOVZ f rc-absolute-arm64-movz rel-untagged
+! temp2 temp2 UXTB
+! temp2 ds-reg temp1 LDRr
+
 [
     ! temp1/32 tag-mask get AND
     tag-mask get temp1 temp1 ANDi
@@ -655,6 +634,14 @@ big-endian off
     NOP f rc-absolute-1 rel-untagged
 ] PIC-CHECK-TAG jit-define
 
+! ! Factor 2024 Clinic Code:
+! ! this arm relocation could actually work
+! ! due to the small bitwidth required  
+! 0 0 temp2 MOVZ f rc-absolute-arm64-movz rel-untagged
+! temp2 temp2 UXTB
+! temp2 temp1 CMPr
+
+
 [
     ! ! 0 JE f rc-relative rel-word
     ! 0 EQ B.cond f rc-relative-arm64-bcond rel-word
@@ -720,70 +707,51 @@ big-endian off
     ] jit-conditional
 ] MEGA-LOOKUP jit-define
 
-! Comparisons
+! helper for comparison operations which return a boolean value
 : jit-compare ( cond -- )
-    ! ! load t
-    ! temp3 0 MOV t rc-absolute-cell rel-literal
+    ! load t
     2 words temp3 LDRl
     3 words Br
     NOP NOP t rc-absolute-cell rel-literal
-    ! ! load f
-    ! temp1 \ f type-number MOV
+    ! load f
     \ f type-number temp2 MOVwi
-    ! ! load first value
-    ! temp0 ds-reg [] MOV
-    ! ! adjust stack pointer
-    ! ds-reg bootstrap-cell SUB
+    ! load values
     load1/0
-    ! ! compare with second value
-    ! ds-reg [] temp0 CMP
+    ! compare
     temp1 temp0 CMPr
-    ! ! move t if true
-    ! [ temp1 temp3 ] dip execute( dst src -- )
+    ! move t if true (f otherwise)
     [ temp2 temp3 temp0 ] dip CSEL
-    ! ! store
-    ! ds-reg [] temp1 MOV
+    ! store
     1 push-down0 ;
 
 ! Math
 
-! Overflowing fixnum arithmetic
+! Overflowing fixnum (integer) arithmetic
 : jit-overflow ( insn func -- )
-    ! ds-reg 8 SUB
     jit-save-context
-    ! arg1 ds-reg [] MOV
-    ! arg2 ds-reg 8 [+] MOV
     load-arg1/2
-    ! arg3 arg1 MOV
-    ! [ [ arg3 arg2 ] dip call ] dip
     [ [ arg2 arg1 arg3 ] dip call ] dip
-    ! ds-reg [] arg3 MOV
     push-down-arg3
-    ! [ JNO ]
-    [ VC B.cond ] [
-        ! arg3 vm-reg MOV
+    [ 8 fixnum+fast VC B.cond ] [
         vm-reg arg3 MOVr
         jit-call
     ] jit-conditional ; inline
 
+! non-overflowing fixnum (integer) arithmetic
 : jit-math ( insn -- )
-    ! ! load second input
-    ! temp0 ds-reg [] MOV
-    ! ! pop stack
-    ! ds-reg bootstrap-cell SUB
+    ! load inputs
     load1/0
-    ! ! compute result
-    ! [ ds-reg [] temp0 ] dip execute( dst src -- )
+    ! compute result
     [ temp0 temp1 temp0 ] dip execute( arg2 arg1 dst -- )
+    ! store result
     1 push-down0 ;
 
+! fixnum (integer) division and modulo operations. 
+! Does not tag or push results.
 : jit-fixnum-/mod ( -- )
-    ! ! load second parameter
-    ! temp1 ds-reg [] MOV
-    ! ! load first parameter
-    ! div-arg ds-reg bootstrap-cell neg [+] MOV
+    ! load parameters
     load1/0
-    ! divide
+    ! divide
     temp0 temp1 temp2 SDIV
     temp1 temp0 temp2 temp0 MSUB ;
 
@@ -799,6 +767,9 @@ big-endian off
     { (start-context-and-delete) [ jit-start-context-and-delete ] }
 
     ! ## Entry points
+    ! called by callback-stub. 
+    ! this contains some C++ setup/teardown, 
+    ! as well as the actual call into the boot quote.
     { c-to-factor [
             arg1 arg2 MOVr
             vm-reg "begin_callback" jit-call-1arg
@@ -830,35 +801,15 @@ big-endian off
     ] }
 
     ! ## Math
-    { fixnum+ [ [ ADDr ] "overflow_fixnum_add" jit-overflow ] }
-    { fixnum- [ [ SUBr ] "overflow_fixnum_subtract" jit-overflow ] }
+    ! Overflowing fixnum (integer) addition
+    { fixnum+ [ 
+        [ ADDr ] "overflow_fixnum_add" jit-overflow ] }
+    ! Overflowing fixnum (integer) subtraction
+    { fixnum- [ 
+        [ SUBr ] "overflow_fixnum_subtract" jit-overflow ] }
+    ! Overflowing fixnum (integer) multiplication
     { fixnum* [
-        ! ds-reg 8 SUB
-        jit-save-context
-        ! RCX ds-reg [] MOV
-        ! RBX ds-reg 8 [+] MOV
-        load1/0
-        ! RBX tag-bits get SAR
-        temp0 untag
-        ! RAX RCX MOV
-        ! RBX IMUL
-        ! RAX * RBX = RDX:RAX
-        temp1 temp0 temp0 MUL
-        ! ds-reg [] RAX MOV
-        1 push-down0
-        ! [ JNO ]
-        [ VC B.cond ] [
-            ! arg1 RCX MOV
-            temp1 arg1 MOVr
-            ! arg1 tag-bits get SAR
-            temp1 untag
-            ! arg2 RBX MOV
-            temp0 arg2 MOVr
-            ! arg3 vm-reg MOV
-            vm-reg arg3 MOVr
-            "overflow_fixnum_multiply" jit-call
-        ] jit-conditional
-    ] }
+        [ MUL ] "overflow_fixnum_multiply" jit-overflow ] }
 
     ! ## Misc
     { fpu-state [
@@ -870,6 +821,11 @@ big-endian off
         FPSR XZR MSRr
         FPCR arg1 MRS
     ] }
+
+! ! Factor 2024 Clinic Code:
+! FPCR arg1 MRS
+! FPSR XZR MSRr
+
     { set-fpu-state [
         ! RSP 2 SUB
         ! RSP [] arg1 16-bit-version-of MOV
@@ -914,246 +870,230 @@ big-endian off
         f RET
     ] }
 
-    ! ## Fixnums
+    ! ! Factor 2024 Clinic Code:
+    ! ! we think the below two lines
+    ! ! 2 temp0 temp0 SUBi ! callstack-length-offset
+    ! ! 0 temp0 arg3 LDRuoff
+    ! ! may need to be replaced with:
+    ! callstack-length-offset arg4 arg3 LDRuoff
+
 
-    ! ### Add
+    ! ## Fixnums
+    ! Non-overflowing fixnum (integer) addition
     { fixnum+fast [ \ ADDr jit-math ] }
 
     ! ### Bit manipulation
+    ! fixnum (integer) bitwise AND
     { fixnum-bitand [ \ ANDr jit-math ] }
+    
+    ! fixnum (integer) bitwise NOT
     { fixnum-bitnot [
-        ! ! complement
-        ! ds-reg [] NOT
         load0
+        ! complement
         temp0 temp0 MVN
-        ! ! clear tag bits
-        ! ds-reg [] tag-mask get XOR
+        ! clear tag bits
         tag-mask get temp0 temp0 EORi
         store0
     ] }
+    
+    ! fixnum (integer) bitwise OR
     { fixnum-bitor [ \ ORRr jit-math ] }
+    
+    ! fixnum (integer) bitwise XOR
     { fixnum-bitxor [ \ EORr jit-math ] }
+    
+    ! fixnum (integer) bitwise shift (positive = left, negative = right)
     { fixnum-shift-fast [
-        ! ! load shift count
-        ! shift-arg ds-reg [] MOV
-        ! ! adjust stack pointer
-        ! ds-reg bootstrap-cell SUB
-        ! ! load value
-        ! temp3 ds-reg [] MOV
+        ! load shift count and value
         load1/0
-        ! ! untag shift count
-        ! shift-arg tag-bits get SAR
+        ! untag shift count
         temp0 untag
-        ! ! make a copy
-        ! temp2 temp3 MOV
+        ! make a copy
         temp1 temp2 MOVr
-        ! ! compute positive shift value in temp2
-        ! temp2 CL SHL
+        ! compute positive shift value in temp1
         temp0 temp1 temp1 LSLr
-        ! ! compute negative shift value in temp3
-        ! shift-arg NEG
+        ! compute negative shift value in temp2
         temp0 temp0 NEG
-        ! temp3 CL SAR
         temp0 temp2 temp2 ASRr
-        ! temp3 tag-mask get bitnot AND
         tag-mask get bitnot temp2 temp2 ANDi
-        ! ! if shift count was negative, move temp3 to temp2
-        ! shift-arg 0 CMP
-        ! temp2 temp3 CMOVGE
-        temp2 temp1 temp0 PL CSEL
-        ! ! push to stack
-        ! ds-reg [] temp2 MOV
+        ! if shift count was negative
+        ! choose temp2 (else temp1)
+        0 temp0 CMPi
+        temp2 temp1 temp0 MI CSEL
+        ! push to stack
         1 push-down0
     ] }
 
     ! ### Comparisons
+    ! returns true if both arguments are fixnums, and false otherwise
     { both-fixnums? [
-        ! temp0 ds-reg [] MOV
-        ! ds-reg bootstrap-cell SUB
         load1/0
-        ! temp0 ds-reg [] OR
         temp1 temp0 temp0 ORRr
-        ! temp0 tag-mask get TEST
         tag-mask get temp0 TSTi
-        ! temp0 \ f type-number MOV
         \ f type-number temp0 MOVwi
-        ! temp1 1 tag-fixnum MOV
         1 tag-fixnum temp1 MOVwi
-        ! temp0 temp1 CMOVE
         temp0 temp1 temp0 EQ CSEL
-        ! ds-reg [] temp0 MOV
         1 push-down0
     ] }
+
+    ! fixnum (integer) equality comparison
     { eq? [ EQ jit-compare ] }
+    ! fixnum (integer) greater-than comparison
     { fixnum> [ GT jit-compare ] }
+    ! fixnum (integer) greater-than-or-equal comparison
     { fixnum>= [ GE jit-compare ] }
+    ! fixnum (integer) less-than comparison
     { fixnum< [ LT jit-compare ] }
+    ! fixnum (integer) less-than-or-equal comparison
     { fixnum<= [ LE jit-compare ] }
 
     ! ### Div/mod
+    ! fixnum (integer) modulo
     { fixnum-mod [
         jit-fixnum-/mod
-        ! ! adjust stack pointer
-        ! ds-reg bootstrap-cell SUB
-        ! ! push to stack
-        ! ds-reg [] mod-arg MOV
+        ! push to stack
         1 push-down0
     ] }
+    ! fixnum (integer) division
     { fixnum/i-fast [
         jit-fixnum-/mod
-        ! ! adjust stack pointer
-        ! ds-reg bootstrap-cell SUB
-        ! ! tag it
-        ! div-arg tag-bits get SHL
+        ! tag it
         tag-bits get temp2 temp0 LSLi
-        ! ! push to stack
-        ! ds-reg [] div-arg MOV
+        ! push to stack
         1 push-down0
     ] }
+    ! fixnum (integer) division and modulo
     { fixnum/mod-fast [
         jit-fixnum-/mod
-        ! ! tag it
-        ! div-arg tag-bits get SHL
+        ! tag it
         temp2 tag
-        ! ! push to stack
-        ! ds-reg [] mod-arg MOV
-        ! ds-reg bootstrap-cell neg [+] div-arg MOV
-        store0/2
+        ! push to stack
+        store2/0
     ] }
 
     ! ### Mul
+    ! Non-overflowing fixnum (integer) multiplication
     { fixnum*fast [
-        ! ! load second input
-        ! temp0 ds-reg [] MOV
-        ! ! pop stack
-        ! ds-reg bootstrap-cell SUB
-        ! ! load first input
-        ! temp1 ds-reg [] MOV
+        ! load both inputs
         load1/0
-        ! ! untag second input
-        ! temp0 tag-bits get SAR
+        ! untag second input
         temp0 untag
-        ! ! multiply
-        ! temp0 temp1 IMUL2
+        ! multiply
         temp1 temp0 temp0 MUL
-        ! ! push result
-        ! ds-reg [] temp0 MOV
+        ! push result
         1 push-down0
     ] }
 
     ! ### Sub
+    ! Non-overflowing fixnum (integer) subtraction
     { fixnum-fast [ \ SUBr jit-math ] }
 
     ! ## Locals
+    ! Drops all current locals stored on the retainstack.
     { drop-locals [
-        ! ! load local count
-        ! temp0 ds-reg [] MOV
-        ! ! adjust stack pointer
-        ! ds-reg bootstrap-cell SUB
+        ! load local count
         pop0
-        ! turn local number into offset
+        ! turn local number into offset
         tagged>offset0
-        ! ! decrement retain stack pointer
-        ! rs-reg temp0 SUB
+        ! decrement retain stack pointer
         temp0 rs-reg rs-reg SUBr
     ] }
+
+    ! Gets the nth local stored on the retainstack.
     { get-local [
-        ! ! load local number
-        ! temp0 ds-reg [] MOV
+        ! load local number
         load0
-        ! turn local number into offset
+        ! turn local number into offset
         tagged>offset0
-        ! ! load local value
-        ! temp0 rs-reg temp0 [+] MOV
+        ! load local value
         temp0 rs-reg temp0 LDRr
-        ! ! push to stack
-        ! ds-reg [] temp0 MOV
+        ! push to stack
         store0
     ] }
+
+    ! Turns the top item on the datastack 
+    ! into a local stored on the retainstack.
     { load-local [ >r ] }
 
     ! ## Objects
+    ! Reads the nth slot of a given object. (non-bounds-checking)
     { slot [
-        ! ! load slot number
-        ! temp0 ds-reg [] MOV
-        ! ! adjust stack pointer
-        ! ds-reg bootstrap-cell SUB
-        ! ! load object
-        ! temp1 ds-reg [] MOV
+        ! load object and slot number
         load1/0
-        ! turn slot number into offset
+        ! turn slot number into offset
         tagged>offset0
-        ! ! mask off tag
-        ! temp1 tag-bits get SHR
-        ! temp1 tag-bits get SHL
+        ! mask off tag
         tag-mask get bitnot temp1 temp1 ANDi
-        ! ! load slot value
-        ! temp0 temp1 temp0 [+] MOV
+        ! load slot value
         temp1 temp0 temp0 LDRr
-        ! ! push to stack
-        ! ds-reg [] temp0 MOV
+        ! push to stack
         1 push-down0
     ] }
+
+    ! nth string element selector (non-bounds-checking)
     { string-nth-fast [
-        ! ! load string index from stack
-        ! temp0 ds-reg bootstrap-cell neg [+] MOV
-        ! temp0 tag-bits get SHR
-        ! ! load string from stack
-        ! temp1 ds-reg [] MOV
+        ! load string index and string from stack
         load1/0
-        ! ! load character
-        ! temp0 8-bit-version-of temp0 temp1 string-offset [++] MOV
-        ! temp0 temp0 8-bit-version-of MOVZX
-        ! temp0 tag-bits get SHL
+        temp1 untag
+        ! load character
+        string-offset temp0 temp0 ADDi
         temp1 temp0 temp0 LDRBr
         temp0 tag
-        ! ! store character to stack
-        ! ds-reg bootstrap-cell SUB
-        ! ds-reg [] temp0 MOV
+        ! store character to stack
         1 push-down0
     ] }
+
+    ! add tag bits to integers
+    ! (the local word tag just shifts left)
     { tag [
-        ! ! load from stack
-        ! temp0 ds-reg [] MOV
+        ! load from stack
         load0
-        ! ! compute tag
-        ! temp0/32 tag-mask get AND
+        ! compute tag
         tag-mask get temp0 temp0 ANDi
-        ! ! tag the tag
-        ! temp0/32 tag-bits get SHL
+        ! tag the tag
         temp0 tag
-        ! ! push to stack
-        ! ds-reg [] temp0 MOV
+        ! push to stack
         store0
     ] }
 
-    ! ## Shufflers
+    ! ## Shufflers
 
-    ! ! ### Drops
+    ! ### Drops
+    ! drops the top n stack items
     { drop [ 1 ndrop ] }
     { 2drop [ 2 ndrop ] }
     { 3drop [ 3 ndrop ] }
     { 4drop [ 4 ndrop ] }
 
-    ! ! ### Dups
+    ! ### Dups
+    ! duplicates the top n stack items in order
     { dup [ load0 push0 ] }
     { 2dup [ load1/0 push1 push0 ] }
     { 3dup [ load2 load1/0 push2 push1 push0 ] }
     { 4dup [ load3/2 load1/0 push3 push2 push1 push0 ] }
+    ! duplicates the second stack item and puts it below the top stack item
     { dupd [ load1/0 store1 push0 ] }
 
-    ! ! ### Misc shufflers
+    ! ### Misc shufflers
+    ! Duplicates the second stack item and puts it above the top stack item
     { over [ load1 push1 ] }
+    ! Duplicates the the third stack item and puts it above the top stack item
     { pick [ load2 push2 ] }
 
-    ! ! ### Nips
+    ! ### Nips
+    ! Drops the second stack item
     { nip [ load0 1 push-down0 ] }
+    ! Drops the second and third stack items
     { 2nip [ load0 2 push-down0 ] }
 
-    ! ! ### Swaps
+    ! ### Swaps
+    ! Rotates the top three elements of the stack (1st -> 3rd)
     { -rot [ pop0 load2/1* store0/2 push1 ] }
+    ! Rotates the top three elements of the stack (1st -> 2nd)
     { rot [ pop0 load2/1* store1/0 push2 ] }
+    ! Swaps the top two elements of the stack
     { swap [ load1/0 store0/1 ] }
+    ! Swaps the second and third elements of the stack
     { swapd [ load2/1 store1/2 ] }
 
     ! ## Signal handling
index 1aa49684386c6a1d4867eb93ff6146c85f403b3b..1035a30e551ff4479018e6e7b08f09455d79c82f 100644 (file)
@@ -5,6 +5,8 @@ IN: bootstrap.assembler.arm
 
 DEFER: stack-reg
 
+! these are all windows-only functions.
+! NO-OPs appear to be correct on UNIX. 
 : jit-save-tib ( -- ) ;
 : jit-restore-tib ( -- ) ;
 : jit-update-tib ( ctx-reg -- ) drop ;
index 6f440b973225c07d1c20bf5d9f2eb021ae62d69e..1db2641040e54a600227628c2f8cfb727709d07d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: assocs bootstrap.image checksums checksums.md5
-http.client http.download io.files kernel math.parser splitting
+hex-strings http.client http.download io.files kernel splitting
 urls ;
 IN: bootstrap.image.download
 
index 0ca221eddb8bca37e8771ce7b42e5e9198887fb7..f0f3a1164292c9e3cceee2c2cc3a192e26970acd 100644 (file)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! Copyright (C) 2015 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: arrays bootstrap.image checksums checksums.openssl io
-io.directories io.encodings.ascii io.encodings.utf8 io.files
-io.files.temp io.files.unique io.launcher io.pathnames kernel
-make math.parser namespaces sequences splitting system unicode ;
+USING: arrays bootstrap.image checksums checksums.openssl
+hex-strings io io.directories io.encodings.ascii
+io.encodings.utf8 io.files io.files.temp io.files.unique
+io.launcher io.pathnames kernel make namespaces sequences
+splitting system unicode ;
 IN: bootstrap.image.upload
 
 SYMBOL: upload-images-destination
index 0b28bdbf18eb484c448f3e11036169a2df667b63..c6fafaf11b3b6ae4852b322cd97a4953a3d3d08b 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays classes.tuple combinators
 combinators.short-circuit kernel literals math math.constants
 math.functions math.intervals math.order math.statistics
-sequences slots.syntax system vocabs vocabs.loader ;
+sequences system vocabs vocabs.loader ;
 FROM: ranges => [a..b) ;
 IN: calendar
 
@@ -353,10 +353,16 @@ M: timestamp <=> [ >gmt tuple-slots ] compare ;
     month>> 3 /mod [ drop 1 + ] unless-zero ; inline
 
 : same-quarter? ( ts1 ts2 -- ? )
-    [ [ year>> ] [ quarter ] bi 2array ] same? ;
+    {
+        [ [ year>> ] same? ]
+        [ [ quarter ] same? ]
+    } 2&& ;
 
 : same-month? ( ts1 ts2 -- ? )
-    [ slots{ year month } ] same? ;
+    {
+        [ [ year>> ] same? ]
+        [ [ month>> ] same? ]
+    } 2&& ;
 
 :: (day-of-year) ( $year $month $day -- n )
     $month cumulative-day-counts nth $day + {
@@ -368,10 +374,17 @@ M: timestamp <=> [ >gmt tuple-slots ] compare ;
     >date< (day-of-year) ;
 
 : same-day? ( ts1 ts2 -- ? )
-    [ slots{ year month day } ] same? ;
+    {
+        [ [ year>> ] same? ]
+        [ [ month>> ] same? ]
+        [ [ day>> ] same? ]
+    } 2&& ;
 
 : same-day-of-year? ( ts1 ts2 -- ? )
-    [ slots{ month day } ] same? ;
+    {
+        [ [ month>> ] same? ]
+        [ [ day>> ] same? ]
+    } 2&& ;
 
 : (day-of-week) ( year month day -- n )
     ! Zeller Congruence
@@ -402,16 +415,26 @@ DEFER: end-of-year
     [ [ year>> ] [ week-number ] bi 2array ] same? ;
 
 : same-hour? ( ts1 ts2 -- ? )
-    [ >gmt slots{ year month day hour } ] same? ;
+    [ >gmt ] bi@ {
+        [ [ year>> ] same? ]
+        [ [ month>> ] same? ]
+        [ [ day>> ] same? ]
+        [ [ hour>> ] same? ]
+    } 2&& ;
 
 : same-minute? ( ts1 ts2 -- ? )
-    [ >gmt slots{ year month day hour minute } ] same? ;
+    [ >gmt ] bi@ {
+        [ [ year>> ] same? ]
+        [ [ month>> ] same? ]
+        [ [ day>> ] same? ]
+        [ [ hour>> ] same? ]
+        [ [ minute>> ] same? ]
+    } 2&& ;
 
 : same-second? ( ts1 ts2 -- ? )
-    [ >gmt ] bi@
-    {
+    [ >gmt ] bi@ {
         [ [ second>> floor ] bi@ = ]
-        [ [ slots{ year month day hour minute } ] same? ]
+        [ same-minute? ]
     } 2&& ;
 
 <PRIVATE
index f502f98568bd156908572684dccdc1a6c16915f5..cde4e5e037981c42947ae489772e5afd241a8eb2 100644 (file)
@@ -90,3 +90,10 @@ Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 { "about a minute ago" } [ 60 relative-time ] unit-test
 { "about a minute ago" } [ 90 relative-time ] unit-test
 { "4 minutes ago" } [ 270 relative-time ] unit-test
+
+{ "1 minute" } [ 60 seconds duration>human-readable ] unit-test
+{ "1 hour" } [ 1 hours duration>human-readable ] unit-test
+{ "3 hours" } [ 3 hours duration>human-readable ] unit-test
+{ "2 minutes and 3 seconds" } [ 123 seconds duration>human-readable ] unit-test
+{ "20 minutes and 34 seconds" } [ 1234 seconds duration>human-readable ] unit-test
+{ "3 hours, 25 minutes and 45 seconds" } [ 12345 seconds duration>human-readable ] unit-test
index e3da029bcc9faf1f93b28c43cbafde0bf4831c4f..a85f24af7207974120dbd25b883d2c1fc7460041 100644 (file)
@@ -205,20 +205,43 @@ M: timestamp present timestamp>string ;
 
 : duration>human-readable ( duration -- string )
     [
-        [
-            duration>years >integer
-            [
-                [ number>string write ]
-                [ 1 > " years, " " year, " ? write ] bi
-            ] unless-zero
-        ] [
-            duration>days >integer 365 mod
+        {
             [
-                [ number>string write ]
-                [ 1 > " days, " " day, " ? write ] bi
-            ] unless-zero
-        ] [ duration>hms write ] tri
-    ] with-string-writer ;
+                duration>years >integer
+                [
+                    [ number>string ]
+                    [ 1 > " years" " year" ? append , ] bi
+                ] unless-zero
+            ] [
+                duration>days >integer 365 mod
+                [
+                    [ number>string ]
+                    [ 1 > " days" " day" ? append , ] bi
+                ] unless-zero
+            ] [
+                duration>hours >integer 24 mod
+                [
+                    [ number>string ]
+                    [ 1 > " hours" " hour" ? append , ] bi
+                ] unless-zero
+            ] [
+                duration>minutes >integer 60 mod
+                [
+                    [ number>string ]
+                    [ 1 > " minutes" " minute" ? append , ] bi
+                ] unless-zero
+            ] [
+                duration>seconds >integer 60 mod
+                [
+                    number>string " seconds" append ,
+                ] unless-zero
+            ]
+        } cleave
+    ] { } make [ "0 seconds" ] [
+        unclip-last-slice over empty? [ nip ] [
+            [ ", " join ] [ " and " glue ] bi*
+        ] if
+    ] if-empty ;
 
 GENERIC: elapsed-time ( seconds -- string )
 
index 3ed11b27a97c8605fb03e7bec048787781dd1dc6..eb0e8403fd1d1a11f851710d58a24d26456b90c2 100644 (file)
@@ -1,5 +1,5 @@
-USING: arrays assocs calendar cbor kernel literals math
-math.parser ranges tools.test urls ;
+USING: arrays assocs calendar cbor hex-strings kernel literals
+math ranges tools.test urls ;
 
 {
     { 0 "00" }
index 092c866f0a019d5b802366cc5a273734aff475eb..8b9cd38bfe0f6fde45f3a3b726e8f53dcb817ee7 100644 (file)
@@ -1,4 +1,4 @@
-USING: checksums.hmac checksums.md5 checksums.sha math.parser
+USING: checksums.hmac checksums.md5 checksums.sha hex-strings
 sequences strings tools.test ;
 
 {
index 4f5dc25f39a7cf0516d462762b095daea8dfdca0..aab1d1014853706164f960ead24569b4c1b0407d 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors arrays checksums io.encodings.binary
-io.files io.streams.byte-array kernel math math.vectors
-sequences ;
+USING: accessors arrays checksums io.encodings.binary io.files
+io.streams.byte-array kernel math math.vectors sequences ;
 IN: checksums.hmac
 
 SLOT: block-size
index 20cf7e98f8bc378555d9b2251002635beb27bf22..723d1025f4d0ccb1ee733dc25db1fa74a1cf152e 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: byte-arrays checksums checksums.common checksums.md5
-io.encodings.binary io.streams.byte-array kernel math.parser
-sequences tools.test ;
+USING: byte-arrays checksums checksums.md5 hex-strings
+io.encodings.binary io.streams.byte-array kernel sequences
+tools.test ;
 
 { "d41d8cd98f00b204e9800998ecf8427e" } [ "" >byte-array md5 checksum-bytes bytes>hex-string ] unit-test
 { "0cc175b9c0f1b6a831c399e269772661" } [ "a" >byte-array md5 checksum-bytes bytes>hex-string ] unit-test
index 700d1095ef20a3e317de5c189611bf570b1528df..f7a51b96a268be54ef94fae92b523224961dc5f8 100644 (file)
@@ -32,8 +32,8 @@ ARTICLE: "checksums.openssl" "OpenSSL checksums"
 "An error thrown if the digest name is unrecognized:"
 { $subsections unknown-digest }
 "An example where we compute the SHA1 checksum of a string using the OpenSSL implementation of SHA1:"
-{ $example "USING: byte-arrays checksums checksums.openssl math.parser ;" "\"hello world\" >byte-array openssl-sha1 checksum-bytes bytes>hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" }
+{ $example "USING: byte-arrays checksums checksums.openssl hex-strings ;" "\"hello world\" >byte-array openssl-sha1 checksum-bytes bytes>hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" }
 "If we use the Factor implementation, we get the same result, just slightly slower:"
-{ $example "USING: byte-arrays checksums checksums.sha math.parser ;" "\"hello world\" >byte-array sha1 checksum-bytes bytes>hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } ;
+{ $example "USING: byte-arrays checksums checksums.sha hex-strings ;" "\"hello world\" >byte-array sha1 checksum-bytes bytes>hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } ;
 
 ABOUT: "checksums.openssl"
index 8ef558bb0b9169c6366622c66849cb1cd5c4e899..2dc2a1e24d9eb4b7030a5ab24bc7236053c4d69c 100644 (file)
@@ -1,6 +1,6 @@
-USING: arrays checksums checksums.common checksums.sha
-checksums.sha.private io.encodings.binary io.streams.byte-array
-kernel math.parser sequences tools.test random ;
+USING: arrays checksums checksums.sha checksums.sha.private
+hex-strings io.encodings.binary io.streams.byte-array kernel
+random sequences tools.test ;
 IN: checksums.sha.tests
 
 { "a9993e364706816aba3e25717850c26c9cd0d89d" } [ "abc" sha1 checksum-bytes bytes>hex-string ] unit-test
index 1552d37e4c332ceaaabdd02f161bc06c707d3efc..a097f05565bcc9fbfdfc79655174381125ad3f83 100644 (file)
@@ -11,6 +11,19 @@ HELP: rc-absolute
 HELP: rc-absolute-cell
 { $description "Indicates that the relocation is a cell-sized absolute address to an object in the VM." } ;
 
+HELP: rc-relative-arm64-branch
+{ $description "Relative address stored, divided by four, in bits 25:0 of an ARM64 instruction." } ;
+
+HELP: rc-relative-arm64-bcond
+{ $description "Relative address stored, divided by four, in bits 23:5 of an ARM64 instruction." } ;
+
+HELP: rc-absolute-arm64-movz
+{ $description "Absolute address stored in bits 20:5 of an ARM64 instruction." } ;
+
+HELP: rc-relative-cell
+{ $description "Indicates that the relocation is a cell-sized relative address to an object in the VM." } ;
+
+
 HELP: rt-cards-offset
 { $description "Relocation offset type for the cards table." }
 { $see-also rel-cards-offset } ;
@@ -86,6 +99,10 @@ $nl
     rc-absolute-2
     rc-absolute-1
     rc-absolute-ppc-2/2/2/2
+    rc-relative-arm64-branch
+    rc-relative-arm64-bcond
+    rc-absolute-arm64-movz
+    rc-relative-cell
 }
 "Relocation types:"
 { $subsections
index 9c9c2acfe905fa3566d11dffee84cd1354e09d6e..3e881dbc4ae3b906d76a6dd1da965d956ee06a7b 100644 (file)
@@ -55,6 +55,8 @@ CONSTANT: rc-absolute-1 11
 CONSTANT: rc-absolute-ppc-2/2/2/2 12
 CONSTANT: rc-relative-arm64-branch 13
 CONSTANT: rc-relative-arm64-bcond 14
+CONSTANT: rc-absolute-arm64-movz 15
+CONSTANT: rc-relative-cell 16
 
 CONSTANT: rt-dlsym 0
 CONSTANT: rt-entry-point 1
index b0c2787f36e920a3eda494c5704bdfafc2cd272d..ead52d3c6c2883c7fe87a97a9a3f791044d6cf78 100644 (file)
@@ -291,7 +291,8 @@ PRIVATE>
 
 : LDUR ( simm9 Rn Rt -- ) 2bw [ swap 9 ?sbits ] 2dip LDUR-encode ;
 
-: LSLi ( uimm6 Rn Rd -- ) 2bw [ tuck [ dup ] 2dip 6 ?ubits ] 2dip LSLi-encode ;
+: LSLi ( uimm6 Rn Rd -- ) 2bw 2bw [ spin 6 ?ubits [ 64 swap - ] [ 63 swap - ] bi ] 
+                                   2dip LSLi-encode ;
 : LSLr ( Rm Rn Rd -- ) 3bw LSLr-encode ;
 
 : LSRi ( uimm6 Rn Rd -- ) 2bw [ tuck [ dup ] 2dip 6 ?ubits ] 2dip LSRi-encode ;
@@ -342,3 +343,5 @@ PRIVATE>
 : SVC ( uimm16 -- ) 16 ?ubits SVC-encode ;
 
 : TSTi ( imm64 Rn -- ) 1bw [ swap encode-bitmask ] dip TSTi-encode ;
+
+: UXTB ( Rn Rd -- ) UXTB-encode ;
index 767dc5b949764c359645d687b4949242af9faf5e..93d70a8c13992502ab08f4a0739b365b9425f567 100644 (file)
@@ -208,21 +208,22 @@ M: integer-literal value value>> ;
 M: object value ;
 
 : arm-bitfield ( seq -- assoc )
-    [ current-vocab name>> ?lookup-word ] map
-    [ dup width ] map>alist
-    dup values [ f = ] any? [ throw ] when ;
+    [ current-vocab name>> ?lookup-word ] map ! looks up the fields associated with the effect labels
+    [ dup width ] map>alist ! creates a list of { field bitwidth } pairs 
+    dup values [ f = ] any? [ throw ] when ; ! if any have no assigned bitwidth, throw.
 
 ERROR: bad-instruction values ;
 
 SYNTAX: ARM-INSTRUCTION:
-    scan-new-word
-    scan-effect
+    scan-new-word ! scans in the name given
+    scan-effect ! scans in the effect given (effect objects hold input and output sequences)
     [
-      in>> arm-bitfield
-      [ keys [ value ] map ]
-      [ values 32 [ - ] accumulate* ] bi zip
-      dup last second 0 = [ bad-instruction ] unless
-      '[ _ bitfield* 4 >le % ]
+      in>> arm-bitfield ! generates a list of { field bitwidth } pairs from the input
+      [ keys [ value ] map ] ! gets the fields back
+      ! for each field, how many bits are left in the instr after it?
+      [ values 32 [ - ] accumulate* ] bi zip ! then combines into another assoc
+      dup last second 0 = [ bad-instruction ] unless ! and there better be 0 bits left after the last field
+      '[ _ bitfield* 4 >le % ] ! this quot is the actual word effect
     ] [ in>> [ string>number ] reject { } <effect> ] bi define-declared ;
 >>
 
@@ -273,7 +274,7 @@ ARM-INSTRUCTION: ANDSi-encode ( bw 11 100100 (N)immrimms Rn Rd -- )
 ARM-INSTRUCTION: ANDSsr-encode ( bw 11 01010 shift2 0 Rm imm6 Rn Rd -- )
 
 ! ASR (immediate): Arithmetic Shift Right (immediate): an alias of SBFM.
-ARM-INSTRUCTION: ASRi-encode ( bw 00 100110 0 immr 011111 Rn Rd -- )
+ARM-INSTRUCTION: ASRi-encode ( bw 00 100110 1 immr 111111 Rn Rd -- )
 
 ! ASR (register): Arithmetic Shift Right (register): an alias of ASRV.
 ARM-INSTRUCTION: ASRr-encode ( bw 0 0 11010110 Rm 0010 10 Rn Rd -- )
@@ -701,7 +702,7 @@ ARM-INSTRUCTION: LDRpre-encode  ( 1 bw 111 0 00 01 0 imm9 11 Rn Rt -- )
 ARM-INSTRUCTION: LDRuoff-encode ( 1 bw 111 0 01 01 imm12 Rn Rt -- )
 
 ! LDR (literal): Load Register (literal).
-ARM-INSTRUCTION: LDRl-encode ( 1 bw 011 0 00 imm19 Rt -- )
+ARM-INSTRUCTION: LDRl-encode ( 0 bw 011 0 00 imm19 Rt -- )
 
 ! LDR (register): Load Register (register).
 ARM-INSTRUCTION: LDRr-encode ( 1 bw 111 0 00 01 1 Rm option3 S 1 0 Rn Rt -- )
@@ -906,7 +907,7 @@ ARM-INSTRUCTION: LDXRB-encode ( 00 001000 0 1 0 11111 0 11111 Rn Rt -- )
 ARM-INSTRUCTION: LDXRH-encode ( 01 001000 0 1 0 11111 0 11111 Rn Rt -- )
 
 ! LSL (immediate): Logical Shift Left (immediate): an alias of UBFM.
-ARM-INSTRUCTION: LSLi-encode ( bw 10 100110 bw immr bw 00000 Rn Rd -- )
+ARM-INSTRUCTION: LSLi-encode ( bw 10 100110 bw immr imms Rn Rd -- )
 
 ! LSL (register): Logical Shift Left (register): an alias of LSLV.
 ARM-INSTRUCTION: LSLr-encode ( bw 0 0 11010110 Rm 0010 00 Rn Rd -- )
index dadf2ab6a26bdcfa81018a355ad7029b7786ffcc..128e4831a0bad872337a5c5c277a0e4adecf6dc5 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2017 John Benediktsson, Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: ascii assocs checksums checksums.sha combinators
-kernel math math.functions math.parser ranges
-math.statistics sequences sets sorting splitting strings uuid ;
+hex-strings kernel math math.functions math.parser
+math.statistics ranges sequences sets sorting splitting strings
+uuid ;
 IN: escape-strings
 
 : find-escapes ( str -- set )
index e4f019694f26c3db4f4d71cf3f0f45be014e8e53..2e136299a95b5dee9c3765688fb5a0b8ffe86bae 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2019 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors checksums checksums.sha documents
-escape-strings kernel math.parser models sequences ui ui.gadgets
+escape-strings hex-strings kernel models sequences ui ui.gadgets
 ui.gadgets.editors ui.gadgets.labeled ui.gadgets.scrollers
 ui.gadgets.tracks ;
 IN: escape-strings.ui
index 53d5c526d05310456586a510d1e52d7939db5bb8..a1ca2c3517a6234836991369618444fa31313298 100644 (file)
@@ -95,7 +95,7 @@ PRIMITIVE: (format-float) ( n fill width precision format locale -- byte-array )
     format-fast-decimal?
     [ "f" format-float-fast ] [ format-decimal-simple ] if ;
 
-EBNF: parse-printf [=[
+EBNF: format-directive [=[
 
 zero      = "0"                  => [[ CHAR: 0 ]]
 char      = "'" (.)              => [[ second ]]
@@ -142,12 +142,13 @@ lists     = "[%" types ", %]"    => [[ second '[ _ { } map-as ", " join "{ " " }
 
 assocs    = "[%" types ": %" types " %]" => [[ [ second ] [ fourth ] bi '[ [ _ _ bi* ":" glue ] { } assoc>map ", " join "{ " " }" surround ] ]]
 
-formats   = "%" (types|fmt-%|lists|assocs|unknown) => [[ second ]]
+formats   = (types|fmt-%|lists|assocs|unknown)
+]=]
 
+EBNF: parse-printf [=[
+formats   = "%"~ <foreign format-directive formats>
 plain-text = [^%]+               => [[ >string ]]
-
 text      = (formats|plain-text)*
-
 ]=]
 
 : printf-quot ( format-string -- format-quot n )
index 2600c97ea3f3545654902cefaa8d2504764154fd..8d97e59f1a4023dc10b2213c6712a397f96d1751 100644 (file)
@@ -2,11 +2,10 @@
 ! See https://factorcode.org/license.txt for BSD license.
 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 locals.parser
-locals.types macros make namespaces parser quotations sequences
-vocabs.parser words words.symbol ;
-
+effects.parser functors.backend generic generic.parser io
+io.streams.string kernel lexer locals.parser locals.types macros
+make namespaces parser present quotations sequences splitting
+strings vocabs.parser words words.symbol ;
 IN: functors
 
 ! This is a hack
@@ -123,8 +122,28 @@ FUNCTOR-SYNTAX: inline [ last-word make-inline ] append! ;
 
 FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } suffix! ;
 
+: (parse-interpolate) ( str -- )
+    [
+        "${" split1-slice [
+            [ >string '[ _ write ] , ] unless-empty
+        ] [
+            [
+                "}" split1-slice
+                [
+                    >string
+                    [ search ] [ [ ] ] [ [ get ] ] ?if
+                    '[ _ @ present write ] ,
+                ]
+                [ (parse-interpolate) ] bi*
+            ] when*
+        ] bi*
+    ] unless-empty ;
+
+: parse-interpolate ( str -- seq )
+    [ (parse-interpolate) ] { } make concat ;
+
 : (INTERPOLATE) ( accum quot -- accum )
-    [ scan-token interpolate-locals-quot ] dip
+    [ scan-token parse-interpolate ] dip
     '[ _ with-string-writer @ ] suffix! ;
 
 PRIVATE>
index 83efd743b573227b51f1cd46e3e0b593d28a3849..556629a0ee2926539ca5507d03b1ed005d439d40 100644 (file)
@@ -2,9 +2,9 @@
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors calendar furnace.actions furnace.asides
 furnace.auth furnace.auth.login.permits furnace.conversations
-furnace.redirection furnace.utilities html.forms http
-http.server.dispatchers kernel logging math.parser namespaces
-sequences urls validators ;
+furnace.redirection furnace.utilities hex-strings html.forms
+http http.server.dispatchers kernel logging math.parser
+namespaces sequences urls validators ;
 IN: furnace.auth.login
 
 SYMBOL: permit-id
diff --git a/basis/hex-strings/authors.txt b/basis/hex-strings/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/hex-strings/hex-strings-docs.factor b/basis/hex-strings/hex-strings-docs.factor
new file mode 100644 (file)
index 0000000..d6ec90d
--- /dev/null
@@ -0,0 +1,63 @@
+! Copyright (C) 2024 Doug Coleman.
+! See https://factorcode.org/license.txt for BSD license.
+USING: byte-arrays help.markup help.syntax kernel sequences
+strings ;
+IN: hex-strings
+
+HELP: hex-digit?
+{ $values
+    { "ch" "a character" }
+    { "?" boolean }
+}
+{ $description "Checks if a digit is in hexadecimal format, e.g. a-f A-F and 0-9" }
+{ $examples
+    { $example "USING: hex-strings prettyprint ;" "CHAR: a hex-digit? ." "t" }
+    { $example "USING: hex-strings prettyprint ;" "CHAR: z hex-digit? ." "f" }
+} ;
+
+HELP: hex-string?
+{ $values
+    { "str" string }
+    { "?" boolean }
+}
+{ $description "Tests if a string is a valid hexadecimal string." }
+{ $examples
+    { $example "USING: hex-strings prettyprint ;" "\"abcdef\" hex-string? ." "t" }
+    { $example "USING: hex-strings prettyprint ;" "\"meow\" hex-string? ." "f" }
+} ;
+
+HELP: bytes>hex-string
+{ $values { "bytes" sequence } { "hex-string" string } }
+{ $description "Converts a sequence of bytes (integers in the range [0,255]) to a string of hex numbers in the range [00,ff]." }
+{ $examples
+    { $example "USING: hex-strings prettyprint ;" "B{ 1 2 3 4 } bytes>hex-string ." "\"01020304\"" }
+}
+{ $notes "Numbers are zero-padded on the left." } ;
+
+HELP: hex-string>bytes
+{ $values { "hex-string" sequence } { "bytes" byte-array } }
+{ $description "Converts a sequence of hex numbers in the range [00,ff] to a sequence of bytes (integers in the range [0,255])." }
+{ $examples
+    { $example "USING: hex-strings prettyprint ;" "\"cafebabe\" hex-string>bytes ." "B{ 202 254 186 190 }" }
+} ;
+
+{ bytes>hex-string hex-string>bytes } related-words
+
+ARTICLE: "hex-strings" "Hex Strings"
+"The " { $vocab-link "hex-strings" } " vocabulary provides words for converting between byte sequences and hexadecimal strings. It also provides predicate words for checking if a string is a valid hexadecimal string for various checksums." $nl
+"Converting between byte sequences and hexadecimal strings:"
+{ $subsections
+    bytes>hex-string
+    hex-string>bytes
+}
+"Check if a string is a known checksum hex string:"
+{ $subsections
+    md5-string? 
+    sha1-string?
+    sha224-string?
+    sha256-string?
+    sha384-string?
+    sha512-string?
+} ;
+
+ABOUT: "hex-strings"
diff --git a/basis/hex-strings/hex-strings-tests.factor b/basis/hex-strings/hex-strings-tests.factor
new file mode 100644 (file)
index 0000000..057f66f
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2024 Doug Coleman.
+! See https://factorcode.org/license.txt for BSD license.
+USING: hex-strings tools.test ;
+IN: hex-strings.tests
+
+{ "deadbeef" } [ B{ 222 173 190 239 } bytes>hex-string ] unit-test
+{ B{ 222 173 190 239 } } [ "deADbeEF" hex-string>bytes ] unit-test
+[ "0" hex-string>bytes ] [ invalid-hex-string-length? ] must-fail-with
+
+{ f } [ "asdf" hex-string? ] unit-test
+{ t } [ "adfAE12309812861cdef" hex-string? ] unit-test
+{ t } [ "" hex-string? ] unit-test
+{ t } [ f hex-string? ] unit-test
diff --git a/basis/hex-strings/hex-strings.factor b/basis/hex-strings/hex-strings.factor
new file mode 100644 (file)
index 0000000..f27baee
--- /dev/null
@@ -0,0 +1,44 @@
+! Copyright (C) 2024 Doug Coleman.
+! See https://factorcode.org/license.txt for BSD license.
+USING: byte-arrays combinators.short-circuit kernel math
+math.order math.parser sequences sequences.private strings ;
+IN: hex-strings
+
+: hex-digit? ( ch -- ? )
+    {
+        [ CHAR: A CHAR: F between? ]
+        [ CHAR: a CHAR: f between? ]
+        [ CHAR: 0 CHAR: 9 between? ]
+    } 1|| ;
+
+: hex-string? ( str -- ? )
+    [ hex-digit? ] all? ;
+
+: md5-string? ( str -- ? ) { [ length 32 = ] [ hex-string? ] } 1&& ;
+: sha1-string? ( str -- ? ) { [ length 40 = ] [ hex-string? ] } 1&& ;
+: sha224-string? ( str -- ? ) { [ length 56 = ] [ hex-string? ] } 1&& ;
+: sha256-string? ( str -- ? ) { [ length 64 = ] [ hex-string? ] } 1&& ;
+: sha384-string? ( str -- ? ) { [ length 96 = ] [ hex-string? ] } 1&& ;
+: sha512-string? ( str -- ? ) { [ length 128 = ] [ hex-string? ] } 1&& ;
+
+ERROR: invalid-hex-string-length n ;
+
+: hex-string>bytes ( hex-string -- bytes )
+    dup length dup even? [ invalid-hex-string-length ] unless 2/ <byte-array> [
+        [
+            [ digit> ] 2dip over even? [
+                [ 16 * ] [ 2/ ] [ set-nth-unsafe ] tri*
+            ] [
+                [ 2/ ] [ [ + ] change-nth-unsafe ] bi*
+            ] if
+        ] curry each-index
+    ] keep ;
+
+: bytes>hex-string ( bytes -- hex-string )
+    dup length 2 * CHAR: 0 <string> [
+        [
+            [ 16 /mod [ >digit ] bi@ ]
+            [ 2 * dup 1 + ]
+            [ [ set-nth-unsafe ] curry bi-curry@ bi* ] tri*
+        ] curry each-index
+    ] keep ;
index bf8a637f9bbf4809d636f030f1ede88bd9dbd678..d0e5ca31ad47bad47ab414a9cd0c41c2b063b4ac 100644 (file)
@@ -3,7 +3,7 @@ IN: interpolate
 
 HELP: interpolate
 { $values { "str" string } }
-{ $description "String interpolation using named variables and/or stack arguments, writing to the " { $link output-stream } "." }
+{ $description "String interpolation using named variables and/or stack arguments, writing to the " { $link output-stream } ". Format directives from the " { $vocab-link "formatting" } " vocabulary can be used as well." }
 { $notes "Stack arguments are numbered from the top of the stack, or provided anonymously by order of arguments." }
 { $examples
     { $example
@@ -21,6 +21,11 @@ HELP: interpolate
         "\"Mr.\" \"Anderson\"" "\"Hello, ${} ${}\" interpolate"
         "Hello, Mr. Anderson"
     }
+    { $example
+        "USING: interpolate ;"
+        "1.2345 \"${:011.5f}\" interpolate"
+        "00001.23450"
+    }
 } ;
 
 HELP: interpolate>string
index 771bd76cdb87134b3663083ed2f99c2fddffad8f..9649a91af2f5737067ed52f6908e7da569412fba 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: interpolate io.streams.string namespaces tools.test locals ;
+USING: formatting interpolate io.streams.string namespaces tools.test ;
 
 { "A B" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
 { "B A" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
@@ -44,3 +44,9 @@ USING: interpolate io.streams.string namespaces tools.test locals ;
 ] unit-test
 
 { "hello, world" } [ "world" I"hello, ${0}" ] unit-test
+
+{ "hello, ####world" } [ "world" I"hello, ${0:'#9s}" ] unit-test
+
+{ "0123.4500" } [ 123.45 I"${:09.4f}" ] unit-test
+
+[ I"${:ABCD}" ] [ unknown-format-directive? ] must-fail-with
index 9d7115ef866997f58a777ba3f4a3f001e2b3113a..d65dc0716519297d9df7dff60c0c3c759af0c76a 100644 (file)
@@ -1,8 +1,10 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors fry generalizations io io.streams.string kernel
-make math math.order math.parser multiline namespaces present
-sequences splitting strings strings.parser vocabs.parser ;
+USING: accessors arrays assocs combinators formatting
+formatting.private fry generalizations io io.streams.string
+kernel make math math.order math.parser multiline namespaces
+present quotations sequences splitting strings strings.parser
+vocabs.parser ;
 IN: interpolate
 
 <PRIVATE
@@ -16,15 +18,18 @@ TUPLE: anon-var ;
 : (parse-interpolate) ( str -- )
     [
         "${" split1-slice [
-            [ >string , ] unless-empty
+            [ >string [ ] 2array , ] unless-empty
         ] [
             [
                 "}" split1-slice
                 [
-                    >string
-                    [ string>number ]
-                    [ 1 + stack-var boa ]
-                    [ [ anon-var new ] [ named-var boa ] if-empty ] ?if ,
+                    >string ":" split1 [
+                        [ string>number ]
+                        [ 1 + stack-var boa ]
+                        [ [ anon-var new ] [ named-var boa ] if-empty ] ?if
+                    ] [
+                        [ [ present ] ] [ format-directive ] if-empty
+                    ] bi* 2array ,
                 ]
                 [ (parse-interpolate) ] bi*
             ] when*
@@ -33,8 +38,8 @@ TUPLE: anon-var ;
 
 : deanonymize ( seq -- seq' )
     0 over <reversed> [
-        dup anon-var? [
-            drop 1 + dup stack-var boa
+        dup first anon-var? [
+            [ 1 + dup stack-var boa ] dip second 2array
         ] when
     ] map! 2drop ;
 
@@ -43,7 +48,7 @@ TUPLE: anon-var ;
 
 : max-stack-var ( seq -- n/f )
     f [
-        dup stack-var? [ n>> [ or ] keep max ] [ drop ] if
+        first dup stack-var? [ n>> [ or ] keep max ] [ drop ] if
     ] reduce ;
 
 :: (interpolate-quot) ( str quot -- quot' )
@@ -51,16 +56,14 @@ TUPLE: anon-var ;
     args max-stack-var    :> vars
 
     args [
-        dup named-var? [
-            name>> quot call '[ _ @ present write ]
-        ] [
-            dup stack-var? [
-                n>> '[ _ npick present write ]
-            ] [
-                '[ _ write ]
-            ] if
-        ] if
-    ] map concat
+        [
+            {
+                { [ dup named-var? ] [ name>> quot call '[ _ @ ] ] }
+                { [ dup stack-var? ] [ n>> '[ _ npick ] ] }
+                [ 1quotation ]
+            } cond
+        ] dip '[ @ @ write ]
+    ] { } assoc>map concat
 
     vars [
         '[ _ ndrop ] append
index adda3838cc03234966968c9b1cc791c5ad46824e..af0a6452f72e75455a3e53d3740285acea9a1443 100644 (file)
@@ -48,6 +48,18 @@ HELP: switch
 "    } switch ;" }
 { $see-also undo } ;
 
+HELP: under
+{ $values { "invertible-quot" quotation } { "quot" quotation } }
+{ $description "Applies " { $snippet "invertible-quot" } ", then " { $snippet "quot" } " and finally the inverse of " { $snippet "invertible-quot" } "." }
+{ $examples
+    "Round a decimal number to two decimals:"
+    { $example
+        "USING: inverse math math.functions prettyprint ;"
+        "123.456 [ 100 * ] [ round ] under ."
+        "123.46"
+    }
+} ;
+
 ARTICLE: { "inverse" "intro" } "Invertible quotations"
 "The inverse vocab defines a way to 'undo' quotations, and builds a pattern matching framework on that basis. A quotation can be inverted by reversing it and inverting each word. To define the inverse for particular word, use"
 { $subsections
index 04db91310840b134ae5052d09dc6bfc32c639974..c619156b8a0c950e4afffb29edb7bfa9270f82df 100644 (file)
@@ -97,3 +97,5 @@ TUPLE: funny-tuple ;
 
 { 0 } [ { 1 2 } [ [ 1 + 2 ] { } output>sequence ] undo ] unit-test
 { { 0 1 } } [ 1 2 [ [ [ 1 + ] bi@ ] input<sequence ] undo ] unit-test
+
+{ 123.46 } [ 123.456 [ 100 * ] [ round ] under ] unit-test
index 3a442db48e512bae153aae5e4fc00e64df7fc870..04ee00c361b76c8dd6d387e0e029fec0edc0b761 100644 (file)
@@ -291,3 +291,6 @@ MACRO: switch ( quot-alist -- quot ) [switch] ;
 SYNTAX: INVERSE: scan-word parse-definition define-inverse ;
 
 SYNTAX: DUAL: scan-word scan-word define-dual ;
+
+MACRO: under ( invertible-quot quot -- quot )
+    over [undo] '[ @ @ @ ] ;
index 6017361f9d5a662ffb8d12480dbd6f77aebaa9e5..2be8612bfd8b0da1c18b0f89972e87888b920f0a 100644 (file)
@@ -160,7 +160,7 @@ ERROR: sequence-expected obj ;
     dup parent-directory 2dup = [ 2drop f ] [ nip ] if ;
 
 : containing-directory ( path -- path' )
-    dup file-info directory? [ parent-directory ] unless ;
+    dup ?file-info directory? [ parent-directory ] unless ;
 
 : ?qualified-directory-files ( path -- seq )
     [ qualified-directory-files ]
index 25a51f7621e79a8e9f903e304d5ccf652140b9c3..2bd50697700297ba6e6eaf5adf2284e4c7bd0c6e 100644 (file)
@@ -27,16 +27,16 @@ HOOK: link-info os ( path -- info )
 PRIVATE>
 
 : directory? ( path/info -- ? )
-    >file-info type>> +directory+ = ;
+    [ >file-info type>> +directory+ = ] ?call ;
 
 : regular-file? ( path/info -- ? )
-    >file-info type>> +regular-file+ = ;
+    [ >file-info type>> +regular-file+ = ] ?call ;
 
 : symbolic-link? ( path/info -- ? )
-    >file-info type>> +symbolic-link+ = ;
+    [ >file-info type>> +symbolic-link+ = ] ?call ;
 
 : sparse-file? ( path/info -- ? )
-    >file-info [ size-on-disk>> ] [ size>> ] bi < ;
+    [ >file-info [ size-on-disk>> ] [ size>> ] bi < ] ?call ;
 
 ! File systems
 HOOK: file-systems os ( -- array )
index 51fe2e823632641fc297b2c9e55fe27ddb75342d..4c28d372d2f8b13405a3d4adc01881ae7ed2597f 100644 (file)
@@ -383,8 +383,7 @@ M: windows normalize-path
         normalize-separators
     ] [
         absolute-path
-        normalize-separators
-        prepend-unicode-prefix
+        [ normalize-separators prepend-unicode-prefix ] ?call
     ] if ;
 
 M: windows home
index a4c64aabda3e6f5a7d38be2940f9820da2d726bf..1d09bf5016c79adda6672e856ed36f1663485670 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2012-2014 John Benediktsson
 ! See https://factorcode.org/license.txt for BSD license
 
-USING: arrays byte-arrays combinators combinators.short-circuit
-endian grouping kernel math math.bitwise math.parser regexp
+USING: byte-arrays combinators combinators.short-circuit endian
+grouping hex-strings kernel math math.bitwise math.parser regexp
 sequences splitting ;
 
 IN: ip-parser
index 6d60935390786f0b36becafc7513d6642d75a2b0..bd3f8f9fab652d1f95b5a4b6f9cc7fa5853e3795 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See https://factorcode.org/license.txt for BSD license.
-USING: help.syntax help.markup math sequences ;
+USING: help.syntax help.markup kernel math sequences ;
 IN: math.bits
 
 ABOUT: "math.bits"
@@ -12,6 +12,12 @@ ARTICLE: "math.bits" "Integer virtual sequences"
     <bits>
     make-bits
     bits>number
+}
+"If you need binary digits instead of " { $link boolean } ", then you can use these:"
+{ $subsections
+    binary-bits
+    <binary-bits>
+    make-binary-bits
 } ;
 
 HELP: bits
@@ -34,3 +40,19 @@ HELP: bits>number
 { $values { "seq" sequence } { "number" integer } }
 { $description "Converts a sequence of booleans in ascending significance into a number." } ;
 { make-bits bits>number } related-words
+
+HELP: binary-bits
+{ $class-description "Tuple representing a number as a virtual sequence of binary digits. The first bit is the least significant bit. Constructors are " { $link <binary-bits> } " or " { $link make-binary-bits } "." } ;
+
+HELP: <binary-bits>
+{ $values { "number" integer } { "length" integer } { "binary-bits" binary-bits } }
+{ $description "Constructor for a " { $link binary-bits } " tuple." } ;
+
+HELP: make-binary-bits
+{ $values { "number" integer } { "binary-bits" binary-bits } }
+{ $description "Creates a sequence of " { $link binary-bits } " in ascending significance. Throws an error on negative numbers." }
+{ $examples
+    { $example "USING: math.bits prettyprint arrays ;" "0b1101 make-binary-bits >array ." "{ 1 0 1 1 }" }
+    { $example "USING: math.bits prettyprint arrays ;" "64 make-binary-bits >array ." "{ 0 0 0 0 0 0 1 }" }
+} ;
+{ <binary-bits> make-binary-bits } related-words
index cf73a0573659d501a7a8b568a40fd894683be552..7ef0301df302fcb4047bad95849d0cf06738eb38 100644 (file)
@@ -30,3 +30,6 @@ USING: tools.test math math.bits sequences arrays ;
 
 { 6 } [ 6 make-bits bits>number ] unit-test
 { 6 } [ 6 3 <bits> >array bits>number ] unit-test
+
+{ { 0 } } [ 0 make-binary-bits >array ] unit-test
+{ { 1 0 1 0 1 1 } } [ 0b110101 make-binary-bits >array ] unit-test
index b8a597e48ce4620e0b433c0a5c8733bd89e121c0..2a2ab592e162207e37658421bc870c79781aadc1 100644 (file)
@@ -18,3 +18,16 @@ INSTANCE: bits immutable-sequence
 
 : bits>number ( seq -- number )
     <reversed> 0 [ [ 1 shift ] dip [ 1 + ] when ] reduce ;
+
+TUPLE: binary-bits < bits ;
+
+C: <binary-bits> binary-bits
+
+M: binary-bits nth-unsafe call-next-method 1 0 ? ; inline
+
+INSTANCE: binary-bits virtual-sequence
+
+: make-binary-bits ( number -- binary-bits )
+    assert-non-negative
+    [ T{ binary-bits { number 0 } { length 1 } } ]
+    [ dup abs log2 1 + <binary-bits> ] if-zero ; inline
index 195dbd7cc027a00c8c5d55b460c601fab6273869..b4c1d00b15bc149a37d065ca4ebec8178d6784ec 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors assocs base64 calendar checksums.hmac
-checksums.sha http http.client kernel make math math.parser
+checksums.sha hex-strings http http.client kernel make math
 namespaces present random sequences sorting strings
 urls.encoding urls.private ;
 IN: oauth1
index 03c2507b03b798cb77b2d9acaa25f41341b2842e..3f2dca5211e4f975d43ef795c62ecf8eaaf6c72d 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs classes combinators
-combinators.short-circuit combinators.smart kernel math
-math.order sequences sets unicode unicode.data ;
+combinators.short-circuit combinators.smart hex-strings kernel
+math math.order sequences sets unicode unicode.data ;
 FROM: ascii => ascii? ;
 IN: regexp.classes
 
@@ -81,13 +81,6 @@ M: non-newline-blank-class class-member?
 M: control-character-class class-member?
     drop control? ; inline
 
-: hex-digit? ( ch -- ? )
-    {
-        [ CHAR: A CHAR: F between? ]
-        [ CHAR: a CHAR: f between? ]
-        [ CHAR: 0 CHAR: 9 between? ]
-    } 1|| ;
-
 M: hex-digit-class class-member?
     drop hex-digit? ; inline
 
index 4c4b046807d4d62a6579dc03f101826822f47a2c..9089513333f18ba87f2d6c8a739f6340fd0bfea9 100644 (file)
@@ -7,16 +7,16 @@ 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 2 3 } { \"a\" \"b\" \"c\" } } <product-sequence> >array ."
+"{
     { 1 \"a\" }
-    { 2 \"a\" }
-    { 3 \"a\" }
     { 1 \"b\" }
-    { 2 \"b\" }
-    { 3 \"b\" }
     { 1 \"c\" }
+    { 2 \"a\" }
+    { 2 \"b\" }
     { 2 \"c\" }
+    { 3 \"a\" }
+    { 3 \"b\" }
     { 3 \"c\" }
 }" } } ;
 
@@ -28,13 +28,13 @@ HELP: <product-sequence>
 { { 1 2 3 } { \"a\" \"b\" \"c\" } } <product-sequence> >array ."
 "{
     { 1 \"a\" }
-    { 2 \"a\" }
-    { 3 \"a\" }
     { 1 \"b\" }
-    { 2 \"b\" }
-    { 3 \"b\" }
     { 1 \"c\" }
+    { 2 \"a\" }
+    { 2 \"b\" }
     { 2 \"c\" }
+    { 3 \"a\" }
+    { 3 \"b\" }
     { 3 \"c\" }
 }" } } ;
 
index 7b3ca557adca3c0a9fbc79e62f422e48b1110608..543b69e2334e0671989c2a03281a5263bb8abdda 100644 (file)
@@ -2,20 +2,30 @@
 ! See https://factorcode.org/license.txt for BSD license.
 USING: arrays kernel make math sequences sequences.product tools.test ;
 
-{ { { 0 "a" } { 1 "a" } { 2 "a" } { 0 "b" } { 1 "b" } { 2 "b" } } }
+{ { { 0 "a" } { 0 "b" } { 1 "a" } { 1 "b" } { 2 "a" } { 2 "b" } } }
 [ { { 0 1 2 } { "a" "b" } } <product-sequence> >array ] unit-test
 
-{ { "a" "aa" "aaa" "b" "bb" "bbb" } }
+{ { "a" "b" "aa" "bb" "aaa" "bbb" } }
 [ { { 1 2 3 } { "a" "b" } } [ first2 <repetition> concat ] 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 "a" t }
+        { 0 "a" f }
+        { 0 "b" t }
+        { 0 "b" f }
+        { 1 "a" t }
+        { 1 "a" f }
+        { 1 "b" t }
+        { 1 "b" f }
+        { 2 "a" t }
+        { 2 "a" f }
+        { 2 "b" t }
+        { 2 "b" f }
     }
 } [ { { 0 1 2 } { "a" "b" } { t f } } [ ] product-map ] unit-test
 
-{ "a1b1c1a2b2c2" } [
+{ "a1a2b1b2c1c2" } [
     [
         { { "a" "b" "c" } { "1" "2" } }
         [ [ % ] each ] product-each
index a1ca1a50478342a3043e2f863cb49c99ae6e7bb0..0a4f703d68bd3e45c18f3ffb5e3b52472cc1b5bc 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Joe Groff.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs kernel math sequences
-sequences.private typed ;
+USING: accessors arrays assocs combinators.short-circuit kernel
+math sequences sequences.private ;
 IN: sequences.product
 
 TUPLE: product-sequence
@@ -17,74 +17,79 @@ M: product-sequence length lengths>> product ;
 
 <PRIVATE
 
-TYPED: product-ns ( n lengths: array -- ns )
-    [ /mod ] map nip ;
+: product-ns ( n lengths -- ns )
+    <reversed> [ /mod ] map nip <reversed> ; inline
 
-TYPED: product-nths ( ns: array seqs -- nths )
-    [ nth-unsafe ] { } 2map-as ;
+: product-nths ( ns seqs -- nths )
+    [ nth-unsafe ] { } 2map-as ; inline
 
-: product@ ( n product-sequence -- ns seqs )
-    [ lengths>> product-ns ] [ nip sequences>> ] 2bi ;
-
-:: (carry-n) ( ns lengths i j -- )
-    i 1 + j = [
-        i ns nth-unsafe i lengths nth-unsafe = [
-            0 i ns set-nth-unsafe
-            ns lengths i 1 +
-            dup ns [ 1 + ] change-nth-unsafe
-            j (carry-n)
-        ] when
-    ] unless ; inline recursive
-
-: carry-ns ( ns lengths -- )
-    0 pick length integer>fixnum-strict (carry-n) ; inline
-
-: product-iter ( ns lengths -- )
-    [ 0 over [ 1 + ] change-nth-unsafe ] dip carry-ns ; inline
+PRIVATE>
 
-: start-product-iter ( sequences -- ns lengths )
-    [ length 0 <array> ] [ [ length ] map ] bi ; inline
+M: product-sequence nth
+    [ lengths>> product-ns ] [ sequences>> product-nths ] bi ;
 
-: end-product-iter? ( ns lengths -- ? )
-    [ last-unsafe ] same? ; inline
+<PRIVATE
 
 : product-length ( sequences -- length )
-    [ length ] [ * ] map-reduce ; inline
+    [ length ] [ * ] map-reduce integer>fixnum-strict ; inline
 
-PRIVATE>
+:: (product-each) ( ... ns sequences k quot: ( ... seq -- ... ) -- ... )
+    k sequences length 1 - = :> done?
+    k sequences nth-unsafe [
+        k ns set-nth-unsafe
+        ns done? quot [
+            sequences k 1 + quot (product-each)
+        ] if
+    ] each ; inline recursive
 
-M: product-sequence nth
-    product@ product-nths ;
+PRIVATE>
 
 :: product-each ( ... sequences quot: ( ... seq -- ... ) -- ... )
-    sequences start-product-iter :> ( ns lengths )
-    lengths [ 0 = ] any? [
-        [ ns lengths end-product-iter? ]
-        [ ns sequences product-nths quot call ns lengths product-iter ] until
+    sequences [ empty? ] any? [
+        sequences length f <array>
+        sequences >array 0 quot (product-each)
     ] unless ; inline
 
 :: product-map-as ( ... sequences quot: ( ... seq -- ... value ) exemplar -- ... sequence )
-    0 :> i!
-    sequences product-length exemplar
+    sequences >array :> sequences
+    sequences product-length exemplar
     [| result |
-        sequences [ quot call i result set-nth-unsafe i 1 + i! ] product-each
+        sequences
+        [ clone swap quot dip [ result set-nth-unsafe ] [ 1 + ] bi ]
+        product-each
         result
-    ] new-like ; inline
+    ] new-like nip ; inline
 
 : product-map ( ... sequences quot: ( ... seq -- ... value ) -- ... sequence )
     over product-map-as ; inline
 
+: all-products ( sequences -- sequences )
+    [ ] product-map ;
+
 :: product-map>assoc ( ... sequences quot: ( ... seq -- ... key value ) exemplar -- ... assoc )
-    0 :> i!
-    sequences product-length { }
+    0 sequences product-length { }
     [| result |
-        sequences [ quot call 2array i result set-nth-unsafe i 1 + i! ] product-each
+        sequences
+        [ clone swap [ quot call 2array ] dip [ result set-nth-unsafe ] [ 1 + ] bi ]
+        product-each
         result
-    ] new-like exemplar assoc-like ; inline
+    ] new-like exemplar assoc-like nip ; inline
+
+<PRIVATE
+
+:: (product-find) ( ... ns sequences k quot: ( ... seq -- ... ? ) -- ... ? )
+    k sequences length 1 - = :> done?
+    k sequences nth-unsafe [
+        k ns set-nth-unsafe
+        ns done? quot [
+            sequences k 1 + quot (product-find)
+        ] if
+    ] find drop ; inline recursive
+
+PRIVATE>
 
 :: product-find ( ... sequences quot: ( ... seq -- ... ? ) -- ... sequence )
-    sequences start-product-iter :> ( ns lengths )
-    lengths [ 0 = ] any? [ f ] [
-        f [ ns lengths end-product-iter? over or ]
-        [ drop ns sequences product-nths quot keep and ns lengths product-iter ] until
+    sequences { [ empty? ] [ [ empty? ] any? ] } 1|| [ f ] [
+        sequences length f <array>
+        [ sequences >array 0 quot (product-find) ] keep and
     ] if ; inline
index 240f06ea1a28dacb226f81eaed459fdaf5103916..a2ffd3adef28f2a776713d0fb28a8a0d1f4ea2f2 100644 (file)
@@ -2,9 +2,9 @@
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data
 alien.destructors alien.libraries alien.strings alien.syntax
-arrays classes.struct combinators destructors kernel layouts
-math math.parser namespaces sequences specialized-arrays
-system tools.disassembler.private tools.memory ;
+arrays classes.struct combinators destructors hex-strings kernel
+math namespaces sequences specialized-arrays system
+tools.disassembler.private tools.memory ;
 IN: tools.disassembler.capstone
 
 << "libcapstone" {
index 8073277d92a920464ad2b9f316a777343fe4923b..5ae2ee81bca1b5a7a517c5783369b8b753818ec3 100644 (file)
@@ -20,9 +20,7 @@ SLOT: interactor
 SLOT: history
 
 : history-list ( interactor -- alist )
-    history>> elements>>
-    [ dup string>> H{ { CHAR: \n CHAR: \s } } substitute ] { } map>assoc
-    <reversed> ;
+    history>> elements>> [ dup string>> ] { } map>assoc <reversed> ;
 
 : history-completions ( short interactor -- seq )
     history-list over empty? [ nip ] [ members completions ] if ;
@@ -59,7 +57,7 @@ M: history-completion completion-quot drop '[ _ history-completions ] ;
 GENERIC: completion-element ( completion-mode -- element )
 
 M: object completion-element drop word-start-elt ;
-M: history-completion completion-element drop one-line-elt ;
+M: history-completion completion-element drop doc-elt ;
 
 GENERIC: completion-banner ( completion-mode -- string )
 
index b237be1f67cb83c47823c53074c31a5599ad7133..4ce7cc8e431da7149231ffcfddc0156e0b76fb32 100644 (file)
@@ -1,13 +1,31 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors documents io.styles kernel math math.order
-sequences ;
+USING: accessors continuations documents io io.encodings.utf8
+io.files io.styles kernel math math.order namespaces
+prettyprint.backend prettyprint.config sequences strings.parser ;
 IN: ui.tools.listener.history
 
-TUPLE: history document elements index ;
+TUPLE: history document elements start index ;
+
+CONSTANT: history-file "~/.factor-history"
+
+: read-history ( -- elements )
+    history-file file-exists? [ history-file utf8 file-lines [ unescape-string <input> ] V{ } map-as ] [ V{ } clone ] if ;
+
+: append-history ( history -- )
+    history-file file-exists?
+    [
+        [
+            history-file utf8 [
+                f string-limit? [
+                    [ elements>> ] [ start>> ] bi [ string>> f f unparse-string print ] swap each-from
+                ] with-variable
+            ] with-file-appender
+        ] [ [ index>> ] keep start<< ] bi
+    ] [ drop ] if ;
 
 : <history> ( document -- history )
-    V{ } clone 0 history boa ;
+    read-history dup length dup history boa ;
 
 <PRIVATE
 
index ccab48c62fbdc9570143707c41c77c8881cd3f03..4999e7f2f4ac111f8aace05c340bb1d53a714453 100644 (file)
@@ -307,7 +307,7 @@ M: listener-operation invoke-command
     ] unless-empty ;
 
 : com-end ( listener -- )
-    input>> interactor-eof ;
+    input>> [ history>> append-history ] [ interactor-eof ] bi ;
 
 : clear-output ( listener -- )
     output>> clear-pane ;
index f8a3c5090f7bf9cc53a7be59dd5f23b9e0c15735..02c86206e5accdb6ee0cddbd520b9f8c164c260d 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -141,12 +141,14 @@ set_cc() {
         if test_programs_installed x86_64-w64-mingw32-gcc x86_64-w64-mingw32-g++; then
             [ -z "$CC" ] && CC=x86_64-w64-mingw32-gcc
             [ -z "$CXX" ] && CXX=x86_64-w64-mingw32-g++
+            [ -z "$CC_OPT" ] && [ "$LTO" == "1" ] && CC_OPT="-flto=auto"
             return
         fi
 
         if test_programs_installed i686-w64-mingw32-gcc i686-w64-mingw32-g++; then
             [ -z "$CC" ] && CC=i686-w64-mingw32-gcc
             [ -z "$CXX" ] && CXX=i686-w64-mingw32-g++
+            [ -z "$CC_OPT" ] && [ "$LTO" == "1" ] && CC_OPT="-flto=auto"
             return
         fi
     fi
@@ -154,6 +156,7 @@ set_cc() {
     if test_programs_installed clang clang++ ; then
         [ -z "$CC" ] && CC=clang
         [ -z "$CXX" ] && CXX=clang++
+        [ -z "$CC_OPT" ] && [ "$LTO" == "1" ] && CC_OPT="-flto"
         return
     fi
 
@@ -161,6 +164,7 @@ set_cc() {
     if test_programs_installed gcc g++ ; then
         [ -z "$CC" ] && CC=gcc
         [ -z "$CXX" ] && CXX=g++
+        [ -z "$CC_OPT" ] && [ "$LTO" == "1" ] && CC_OPT="-flto=auto"
         return
     fi
 
@@ -373,6 +377,8 @@ echo_build_info() {
     $ECHO "DOWNLOADER_NAME=$DOWNLOADER_NAME"
     $ECHO "CC=$CC"
     $ECHO "CXX=$CXX"
+    $ECHO "LTO=$LTO"
+    $ECHO "CC_OPT=$CC_OPT"
     $ECHO "MAKE=$MAKE"
 }
 
@@ -420,6 +426,7 @@ prepare_build_info() {
     find_os
     find_architecture
     find_num_cores
+    if [[ $OS != macosx ]] ; then LTO=1; fi # temporarily try out LTO to collect performance data (not working on MacOSX)
     set_cc
     find_word_size
     set_current_branch
@@ -523,12 +530,14 @@ invoke_make() {
 }
 
 make_clean() {
-    invoke_make clean
+    echo invoke_make clean BUILD_DIR="build-$MAKE_TARGET"
+    invoke_make clean BUILD_DIR="build-$MAKE_TARGET"
 }
 
 make_factor() {
     $ECHO "Building factor with $NUM_CORES cores"
-    invoke_make "CC=$CC" "CXX=$CXX" "$MAKE_TARGET" "-j$NUM_CORES"
+    $ECHO invoke_make "CC=$CC" "CXX=$CXX" "CC_OPT=$CC_OPT" "$MAKE_TARGET" "-j$NUM_CORES"
+    invoke_make "CC=$CC" "CXX=$CXX" "CC_OPT=$CC_OPT" "$MAKE_TARGET" "-j$NUM_CORES"
 }
 
 make_clean_factor() {
@@ -762,6 +771,7 @@ usage() {
     $ECHO "  self-update - git pull, recompile, make local boot image, bootstrap"
     $ECHO "  quick-update - git pull, refresh-all, save"
     $ECHO "  update|latest - git pull, recompile, download a boot image, bootstrap"
+    $ECHO "  clean - run make clean"
     $ECHO "  compile - compile the binary"
     $ECHO "  recompile - recompile the binary"
     $ECHO "  bootstrap - bootstrap with existing boot image"
@@ -805,6 +815,7 @@ case "$1" in
     self-update) update; make_boot_image; bootstrap  ;;
     quick-update) update; refresh_image ;;
     update|latest) update; download_and_bootstrap ;;
+    clean) find_build_info; make_clean ;;
     compile) find_build_info; make_factor ;;
     recompile) find_build_info; make_clean; make_factor ;;
     bootstrap) get_config_info; bootstrap ;;
index ddd6b8ccb648c9dea6b19852816369ec2608c5ec..3eed33dce3898bbc2fa42155d22330b1d04eda8d 100644 (file)
@@ -301,3 +301,5 @@ CONSTANT: pt-array-1
         [ ascii file-contents ] bi "a" =
     ] with-test-file
 ] unit-test
+
+{ f } [ f file-exists? ] unit-test
index 4a68452a6b0ee211c7f075f4d6af388619290147..4790b6537cb3e73410ddc1431f81c69662f47530 100644 (file)
@@ -77,7 +77,7 @@ HOOK: (file-appender) io-backend ( path -- stream )
     [ <file-appender> ] dip with-output-stream ; inline
 
 : file-exists? ( path -- ? )
-    normalize-path native-string>alien (file-exists?) ;
+    [ normalize-path native-string>alien (file-exists?) ] ?call ;
 
 ERROR: no-such-file path ;
 
index ac2ac7c5d92bb86f2873acb04e9bbb46820c4f0f..831d79f6bd9bee181359a8847e2520ddab129d19 100644 (file)
@@ -97,7 +97,8 @@ os windows? [
 
     { "c:/Users" } [ "c:/Users" canonicalize-path ] unit-test
     { "c:/Users" } [ "c:/Users/." canonicalize-path ] unit-test
-    { "c:/Users\\foo\\bar" } [ "c:/Users/foo/bar" canonicalize-path ] unit-test
+    { "c:/Users/foo/bar" } [ "c:/Users/foo/bar" canonicalize-path ] unit-test
+    { "C:/foo/bar" } [ "C:\\foo\\bar" canonicalize-path ] unit-test
 ] [
     { "/" } [ "/" canonicalize-path ] unit-test
     { "/" } [ "/." canonicalize-path ] unit-test
@@ -148,6 +149,7 @@ os windows? [
     { "c:\\" } [ "\\\\?\\c:\\\\\\//Users//\\//merlen//" root-path ] unit-test
     { "d:\\" } [ "\\\\?\\d:\\././././././/../../../" root-path ] unit-test
     { "d:\\" } [ "\\\\?\\d:\\merlen\\dog" root-path ] unit-test
+    { "D:\\" } [ "\\\\?\\D:\\merlen\\dog" root-path ] unit-test
 ] [
     { "/" } [ "/" root-path ] unit-test
     { "/" } [ "//" root-path ] unit-test
@@ -189,3 +191,6 @@ os windows? [
 ! Would be a core/ path except the path already exists in basis
 { "resource:basis/bootstrap/finish-bootstrap.factor" }
 [ "bootstrap/finish-bootstrap.factor" vocab-path ] unit-test
+
+{ f } [ f normalize-path ] unit-test
+{ f } [ f absolute-path ] unit-test
index f67e38dcbd109166b5ee202e835757d50967c0fd..dc044896b7f7101401820a108aa0dfa2dbc9fee9 100644 (file)
@@ -6,6 +6,8 @@ IN: io.pathnames
 
 SYMBOL: current-directory
 
+CONSTANT: cross-platform-path-separator "/"
+
 : path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ;
 
 : path-separator ( -- string ) os windows? "\\" "/" ? ;
@@ -180,6 +182,8 @@ M: string absolute-path
 M: object normalize-path
     absolute-path ;
 
+M: f absolute-path ;
+
 : root-path* ( path -- path' )
     dup absolute-path? [
         dup [ path-separator? ] find
@@ -217,10 +221,10 @@ M: object relative-path relative-path* ;
     ] keep dup absolute-path? [
         [
             [ ".." = ] trim-head
-            path-separator join
+            cross-platform-path-separator join
         ] dip root-path prepend-path
     ] [
-        drop path-separator join [ "." ] when-empty
+        drop cross-platform-path-separator join [ "." ] when-empty
     ] if ;
 
 HOOK: canonicalize-path io-backend ( path -- path' )
index 74895e0baa9e075328b254758efadf33a2b0035a..a66de6e42a5a00ec0be1c5b37b035d81c4b4b738 100644 (file)
@@ -116,20 +116,3 @@ HELP: number>string
 HELP: #
 { $values { "n" real } }
 { $description "Appends the string representation of a real number to the end of the sequence being constructed by " { $link make } "." } ;
-
-HELP: bytes>hex-string
-{ $values { "bytes" sequence } { "hex-string" string } }
-{ $description "Converts a sequence of bytes (integers in the range [0,255]) to a string of hex numbers in the range [00,ff]." }
-{ $examples
-    { $example "USING: math.parser prettyprint ;" "B{ 1 2 3 4 } bytes>hex-string ." "\"01020304\"" }
-}
-{ $notes "Numbers are zero-padded on the left." } ;
-
-HELP: hex-string>bytes
-{ $values { "hex-string" sequence } { "bytes" byte-array } }
-{ $description "Converts a sequence of hex numbers in the range [00,ff] to a sequence of bytes (integers in the range [0,255])." }
-{ $examples
-    { $example "USING: math.parser prettyprint ;" "\"cafebabe\" hex-string>bytes ." "B{ 202 254 186 190 }" }
-} ;
-
-{ bytes>hex-string hex-string>bytes } related-words
index 6748a256c949166dce63a525a90beb0e1e270c3e..8a4d2554a24bdd73fb4af08c121ef5c037748968 100644 (file)
@@ -478,10 +478,6 @@ unit-test
 { 1/0. } [ "0x1p300000" string>number ] unit-test
 { 0.0  } [ "0x1p-300000" string>number ] unit-test
 
-{ "deadbeef" } [ B{ 222 173 190 239 } bytes>hex-string ] unit-test
-{ B{ 222 173 190 239 } } [ "deADbeEF" hex-string>bytes ] unit-test
-[ "0" hex-string>bytes ] [ invalid-hex-string-length? ] must-fail-with
-
 { "143.99999999999997" } [ 0x1.1ffffffffffffp7 number>string ] unit-test
 { "144.0" } [ 0x1.2p7 number>string ] unit-test
 { "144.00000000000003" } [ 0x1.2000000000001p7 number>string ] unit-test
index c5e7c2e11571206835e21447d8c10e03c09ab7ae..1430bfd1105c05f09447f64d87816e3ae502bf25 100644 (file)
@@ -1026,25 +1026,3 @@ M: float >base
     } cond ;
 
 : # ( n -- ) number>string % ; inline
-
-ERROR: invalid-hex-string-length n ;
-
-: hex-string>bytes ( hex-string -- bytes )
-    dup length dup even? [ invalid-hex-string-length ] unless 2/ <byte-array> [
-        [
-            [ digit> ] 2dip over even? [
-                [ 16 * ] [ 2/ ] [ set-nth-unsafe ] tri*
-            ] [
-                [ 2/ ] [ [ + ] change-nth-unsafe ] bi*
-            ] if
-        ] curry each-index
-    ] keep ;
-
-: bytes>hex-string ( bytes -- hex-string )
-    dup length 2 * CHAR: 0 <string> [
-        [
-            [ 16 /mod [ >digit ] bi@ ]
-            [ 2 * dup 1 + ]
-            [ [ set-nth-unsafe ] curry bi-curry@ bi* ] tri*
-        ] curry each-index
-    ] keep ;
index 1f7d91fd948ab46acf37add93d91c346f547f21e..e57a9bb08df123627037dcd4fb06a92490e5251f 100644 (file)
@@ -1,14 +1,11 @@
 ! Copyright (C) 2023 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors arrays ascii assocs assocs.extras calendar
-calendar.format calendar.parser checksums checksums.hmac
-checksums.sha combinators combinators.short-circuit formatting
-http ini-file io.directories io.encodings.string
-io.encodings.utf8 io.files io.files.info io.launcher
-io.pathnames io.streams.string json kernel math math.order
-math.parser multiline prettyprint qw sequences
-sequences.generalizations sets sorting splitting strings urls
-urls.encoding ;
+USING: accessors arrays ascii assocs calendar calendar.format
+calendar.parser checksums checksums.hmac checksums.sha
+combinators combinators.short-circuit formatting hex-strings
+http ini-file io.directories io.encodings.utf8 io.files
+io.files.info io.pathnames io.streams.string json kernel math
+math.order sequences sets sorting splitting urls urls.encoding ;
 IN: aws
 
 : aws-timestamp-valid? ( str -- duration-valid valid? )
index 78e4106c42347873f0bfbc5dc092a7b531dc3bab..70bf1644b0d0baaaec3435d8898cde8599a0664e 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2023 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors assocs assocs.extras checksums checksums.sha
-combinators formatting hashtables http http.client
+combinators formatting hashtables hex-strings http http.client
 http.client.post-data io io.files io.pathnames json kernel make
-math.parser namespaces namespaces.extras sequences sorting urls ;
+namespaces namespaces.extras sequences sorting urls ;
 IN: backblaze
 
 SYMBOL: backblaze-application-key-id
index 54e28120be382777b0e26377f10a068a720ac90b..e6ca88e449bbc5514d7c98d0255ff3b6aaa289b4 100644 (file)
@@ -1,4 +1,4 @@
-USING: base24 endian grouping kernel math.parser sequences
+USING: base24 endian grouping hex-strings kernel sequences
 tools.test ;
 
 IN: base24.tests
index 90a4643cfeb8a1268b73cb27aa381b6f689ce52f..6420b5eba1ffab8feeb75b4e48407e00999a9a75 100644 (file)
@@ -1,4 +1,4 @@
-USING: base58 math.parser strings tools.test ;
+USING: base58 hex-strings strings tools.test ;
 
 { "" } [ "" >base58 >string ] unit-test
 { "" } [ "" base58> >string ] unit-test
index 0c253b081256efbe6d05943fa63ef9299893b0b8..75a2e389a3d4ba31f569d8c831b0f7e0377ecf2f 100644 (file)
@@ -1,5 +1,5 @@
 USING: benchmark.reverse-complement checksums checksums.md5
-io.files io.files.temp kernel math.parser tools.test ;
+hex-strings io.files io.files.temp kernel tools.test ;
 
 { "c071aa7e007a9770b2fb4304f55a17e5" } [
     "resource:extra/benchmark/reverse-complement/reverse-complement-test-in.txt"
index 9074cb12d9aab168ef7295b8a2ba2cf627f6a779..2cc9b69649928a35462f3728eb7da170c504ed9b 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2016 Alexander Ilin.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors ascii checksums checksums.common destructors io
-io.encodings.binary io.launcher kernel math.parser sequences ;
+USING: accessors ascii checksums checksums.common destructors
+hex-strings io io.encodings.binary io.launcher kernel sequences ;
 IN: checksums.process
 
 TUPLE: checksum-process launch-desc ;
index b8287671aea18a84cfdb7a23245f194c834dbb34..c5877f1865e791b97007d2ce05d8f82995124d8c 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2013 John Benediktsson
 ! See https://factorcode.org/license.txt for BSD license
 
-USING: colors.private grouping kernel lexer math regexp.classes
+USING: colors.private grouping hex-strings kernel lexer math
 sequences splitting ;
 
 IN: colors.flex-hex
index 94b55ca319ba555d746f65557dbcf7535b374074..ba9398b87775b21bf4e0ff4f4706ded24125a8d4 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2023 John Benediktsson
 ! See https://factorcode.org/license.txt for BSD license
 
-USING: byte-arrays combinators endian io kernel math
-math.bitwise math.order math.parser namespaces sequences strings
-;
+USING: byte-arrays combinators endian hex-strings io kernel math
+math.bitwise math.order namespaces sequences strings ;
 
 IN: drunken-bishop
 
index 6a01069d55c80d2cb65d046e0419482c1a1649b1..b41055829b22abc3b4869481e076b4d542743bfb 100644 (file)
@@ -3,12 +3,12 @@
 USING: accessors arrays assocs assocs.extras calendar
 calendar.format checksums checksums.sha combinators
 combinators.short-circuit combinators.smart compression.zlib
-constructors endian formatting grouping hashtables ini-file io
-io.directories io.encodings.binary io.encodings.string
-io.encodings.utf8 io.files io.files.info io.pathnames
-io.streams.byte-array io.streams.peek kernel math math.bitwise
-math.parser namespaces random sequences sequences.extras
-splitting splitting.monotonic strings ;
+constructors endian formatting grouping hashtables hex-strings
+ini-file io io.directories io.encodings.binary
+io.encodings.string io.encodings.utf8 io.files io.files.info
+io.pathnames io.streams.byte-array io.streams.peek kernel math
+math.bitwise math.parser namespaces random sequences
+sequences.extras splitting splitting.monotonic strings ;
 IN: git
 
 ERROR: byte-expected offset ;
@@ -20,8 +20,21 @@ ERROR: separator-expected expected-one-of got ;
 : read-until* ( separators -- data )
     dup read-until [ nip ] [ separator-expected ] if ;
 
-: find-git-directory ( path -- path' )
-    [ ".git" tail? ] find-up-to-root ; inline
+ERROR: unknown-dot-git path ;
+
+: parse-dot-git-file ( path -- path' )
+    dup utf8 file-lines ?first "gitdir: " ?head [
+        nip
+    ] [
+        drop unknown-dot-git
+    ] if ;
+
+: find-git-directory ( path -- path'/f )
+    [ ".git" tail? ] find-up-to-root
+    dup ?file-info regular-file? [ parse-dot-git-file ] when ; inline
+
+: find-base-git-directory ( path -- path'/f )
+    find-git-directory dup ".git" tail? [ find-base-git-directory ] unless ;
 
 ERROR: not-a-git-directory path ;
 
@@ -30,9 +43,21 @@ ERROR: not-a-git-directory path ;
         current-directory get not-a-git-directory
     ] unless* ;
 
+: current-git-base-directory ( -- path )
+    current-git-directory find-base-git-directory ;
+
 : make-git-path ( str -- path )
     current-git-directory prepend-path ;
 
+: make-git-base-path ( str -- path )
+    current-git-base-directory prepend-path ;
+
+: get-git-file-contents ( path -- contents )
+    make-git-base-path utf8 file-contents ;
+
+: get-git-file-lines ( path -- contents )
+    make-git-base-path utf8 file-lines ;
+
 : make-refs-path ( str -- path )
     [ "refs/" make-git-path ] dip append-path ;
 
@@ -392,22 +417,29 @@ ERROR: no-pack-for sha1 ;
 
 ERROR: expected-ref got ;
 
+: git-hash? ( str -- ? ) sha1-string? ;
+
 : parse-ref-line ( string -- string' )
-    " " split1 [
-        dup "ref:" = [ drop ] [ expected-ref ] if
-    ] dip ;
+    "ref: " ?head [ expected-ref ] unless ;
+
+: parse-ref ( string -- string' )
+    dup git-hash? [ parse-ref-line ] unless ;
+
+: list-refs-for ( path -- seq )
+    "refs/" append-path recursive-directory-files ;
 
 : list-refs ( -- seq )
-    current-git-directory "refs/" append-path recursive-directory-files ;
+    current-git-base-directory list-refs-for ;
 
 : remote-refs-dirs ( -- seq )
     "remotes" make-refs-path directory-files ;
 
 : ref-contents ( str -- line ) make-refs-path git-line ;
 : git-stash-ref-sha1 ( -- contents ) "stash" ref-contents ;
-: git-ref ( ref -- sha1 ) git-line parse-ref-line ;
+: git-ref ( ref -- sha1 ) git-line parse-ref ;
 : git-head-ref ( -- sha1 ) "HEAD" git-ref ;
-: git-log-for-ref ( ref -- log ) git-line git-read-object ;
+: git-log-for-ref ( ref -- log )
+    dup sha1-string? [ git-line ] unless git-read-object ;
 : git-head-object ( -- commit ) git-head-ref git-log-for-ref ;
 : git-config ( -- config ) "config" make-git-path ;
 
index b468b85203867a4784e1847222b9cc8e92098fe0..767e2a2054208dd971cdfc8016852b822480df4c 100644 (file)
@@ -2,9 +2,9 @@
 ! See https://factorcode.org/license.txt for BSD license
 
 USING: ascii assocs checksums checksums.md5 classes.tuple
-formatting http.client images.http io.encodings.string
-io.encodings.utf8 json kernel math.parser namespaces sequences
-urls ;
+formatting hex-strings http.client images.http
+io.encodings.string io.encodings.utf8 json kernel namespaces
+sequences urls ;
 
 IN: gravatar
 
index ef3fc63f346367e21a21dab56f92c1c582218657..e2ad635061f607fd95ee602c41ba01567d263c06 100644 (file)
@@ -1,9 +1,10 @@
-USING: accessors arrays assocs calendar calendar.english
-calendar.format calendar.parser formatting grouping io io.crlf
-io.encodings.ascii io.encodings.binary io.encodings.string
-io.encodings.utf7 io.encodings.utf8 io.sockets io.sockets.secure
-io.streams.duplex io.streams.string kernel math math.parser
-multiline sequences sequences.extras splitting strings ;
+USING: accessors arrays ascii assocs base64 calendar
+calendar.english calendar.format calendar.parser combinators
+formatting grouping io io.crlf io.encodings.ascii
+io.encodings.binary io.encodings.string io.encodings.utf7
+io.encodings.utf8 io.sockets io.sockets.secure io.streams.duplex
+io.streams.string kernel math math.parser multiline sequences
+sequences.extras splitting splitting.monotonic strings ;
 QUALIFIED: pcre
 IN: imap
 
@@ -155,6 +156,10 @@ PRIVATE>
     [ "UID SEARCH CHARSET UTF-8 %s" sprintf ] dip utf8 encode
     command-response parse-items [ string>number ] map ;
 
+: search-imap-by-subject ( string -- uids ) [ "SUBJECT" ] dip search-mails ;
+: search-imap-by-body ( string -- uids ) [ "BODY" ] dip search-mails ;
+: search-imap-by-from ( string -- uids ) [ "FROM" ] dip search-mails ;
+
 : fetch-mails ( uids data-spec -- texts )
     [ comma-list ] dip "UID FETCH %s %s" sprintf "" command-response but-last ;
 
@@ -175,8 +180,63 @@ PRIVATE>
     "" command-response
     parse-store-mail ;
 
+TUPLE: parsed-email
+date to from subject cc
+return-path
+content-type
+content-transfer-encoding
+headers
+decoded-body ;
+
+: <parsed-email> ( -- obj )
+    parsed-email new
+        V{ } clone >>headers ; inline
+
+: decode-email-body ( parsed-email body -- parsed-email )
+    over content-transfer-encoding>> {
+        { "base64" [ base64> utf8 decode >>decoded-body ] }
+        [
+            ! "unsupported content-transfer-encoding" print
+            drop
+            >>decoded-body
+        ]
+    } case ;
+
+: parse-email-header ( parsed-email strings -- parsed-email )
+    [ nip ?first "\t\s" member? ] monotonic-split
+    [
+        [ [ blank? ] trim ] map " " join
+        ": " split1 swap >lower
+    ] { } map>assoc
+    [
+        [ pick headers>> push-at ]
+        [
+            {
+                { "date" [ >>date ] }
+                { "to" [ >>to ] }
+                { "from" [ >>from ] }
+                { "subject" [ >>subject ] }
+                { "return-path" [ >>return-path ] }
+                { "cc" [ >>to ] }
+                { "content-transfer-encoding" [ >>content-transfer-encoding ] }
+                { "content-type" [ >>content-type ] }
+                [ 2drop ]
+            } case
+        ] 2bi
+    ] assoc-each ;
+
+: parse-email ( string -- parsed-email )
+    [ <parsed-email> ] dip
+    "\r\n\r\n" split1
+    [ string-lines parse-email-header ] dip decode-email-body ;
+
 ! High level API
 
+: reject-uid-lines ( seq -- seq' ) [ "(UID" head? ] reject ;
+
+: fetch-rfc822-mails ( uids -- parsed-emails )
+    [ { } ] [ "(RFC822)" fetch-mails reject-uid-lines [ parse-email ] map ] if-empty ;
+
 : with-imap ( host email password quot -- )
     [ <imap4ssl> ] 3dip '[ _ _ login drop @ ] with-stream ; inline
 
diff --git a/extra/io/streams/tee/authors.txt b/extra/io/streams/tee/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/io/streams/tee/tee-tests.factor b/extra/io/streams/tee/tee-tests.factor
new file mode 100644 (file)
index 0000000..6111d65
--- /dev/null
@@ -0,0 +1,30 @@
+USING: combinators.smart io io.encodings.utf8 io.files
+io.streams.tee kernel tools.test ;
+
+{ t } [
+    "resource:LICENSE.txt" utf8 [
+        [
+            utf8 [
+                tee-to-file-writer
+                [
+                    readln
+                    42 read
+                    " " read-until
+                    read1
+                    read-contents
+                ] output>array
+            ]
+            [
+                [
+                    [
+                        readln
+                        42 read
+                        " " read-until
+                        read1
+                        read-contents
+                    ] output>array
+                ] with-file-reader
+            ] 2bi =
+        ] with-test-file
+    ] with-file-reader
+] unit-test
diff --git a/extra/io/streams/tee/tee.factor b/extra/io/streams/tee/tee.factor
new file mode 100644 (file)
index 0000000..12429f6
--- /dev/null
@@ -0,0 +1,76 @@
+! Copyright (C) 2024 John Benediktsson
+! See https://factorcode.org/license.txt for BSD license
+
+USING: accessors destructors io io.files kernel math namespaces
+sequences ;
+
+IN: io.streams.tee
+
+TUPLE: tee-stream in out ;
+
+C: <tee-stream> tee-stream
+
+INSTANCE: tee-stream input-stream
+
+<PRIVATE
+
+: >tee-stream< ( tee-stream -- in out )
+    [ in>> ] [ out>> ] bi ; inline
+
+MACRO: tee1 ( read-quot write-quot -- quot )
+    '[ >tee-stream< _ [ [ over _ dip ] [ stream-flush ] bi ] bi* ] ;
+
+MACRO: tee2 ( read-quot write-quot -- quot )
+    '[ >tee-stream< _ [ [ 2over _ 2dip ] [ stream-flush ] bi ] bi* ] ;
+
+PRIVATE>
+
+M: tee-stream stream-element-type in>> stream-element-type ;
+
+M: tee-stream stream-read1
+    [ stream-read1 ] [ stream-write1 ] tee1 ;
+
+M:: tee-stream stream-read-unsafe ( n buf stream -- count )
+    n buf stream
+    [ stream-read-unsafe ]
+    [ '[ buf swap head _ stream-write ] unless-zero ] tee1 ;
+
+M:: tee-stream stream-read-partial-unsafe ( n buf stream -- count )
+    n buf stream
+    [ stream-read-partial-unsafe ]
+    [ '[ buf swap head _ stream-write ] unless-zero ] tee1 ;
+
+M: tee-stream stream-readln
+    [ stream-readln ]
+    [ '[ _ [ stream-write ] [ stream-nl ] bi ] when* ] tee1 ;
+
+M: tee-stream stream-read-until
+    >tee-stream<
+    [ stream-read-until ]
+    [
+        dup '[
+            [ [ _ stream-write ] when* ]
+            [ [ _ stream-write1 ] when* ] bi*
+        ] 2over [ call ] 2dip
+    ] bi* ;
+
+M: tee-stream stream-contents*
+    [ stream-contents* ] [ stream-write ] tee1 ;
+
+M: tee-stream dispose
+    >tee-stream< [ dispose ] bi@ ;
+
+: with-tee-stream ( input output quot -- )
+    [ <tee-stream> ] dip with-input-stream ; inline
+
+: tee-to-file-writer ( path encoding -- )
+    [ input-stream ] 2dip '[ _ _ <file-writer> <tee-stream> ] change ;
+
+: tee-to-file-appender ( path encoding -- )
+    [ input-stream ] 2dip '[ _ _ <file-appender> <tee-stream> ] change ;
+
+: tee-to-stdout ( -- )
+    input-stream [ output-stream get-global <tee-stream> ] change ;
+
+: tee-to-stderr ( -- )
+    input-stream [ error-stream get-global <tee-stream> ] change ;
index e2d2c8b1c9a41f637da4af871d4eae5d40f1d274..854ceb1fdaa8b90f5e90b93c70690fc64b316be1 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2014 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: assocs checksums checksums.md5 http.client json kernel
-math.parser namespaces sequences strings system urls ;
+USING: assocs checksums checksums.md5 hex-strings http.client
+json kernel math.parser namespaces sequences strings system urls ;
 IN: marvel
 
 ! https://developer.marvel.com/docs
index db8d84451d6f439c128a9d0422df725583b3da8c..4eba32299c507b27a4da423bddad3a49f58cfb16 100644 (file)
@@ -1,2 +1,3 @@
 Eduardo Cavazos
 Slava Pestov
+nomennescio
index c67369103295e9ff6cdc96bd84bc0d0b1b4f6f72..698c419033d0a5c4cd604ea0a3d507e4f3372b32 100644 (file)
@@ -45,7 +45,7 @@ IN: mason.build
         build-child
         [ notify-report ] [
             status-clean eq?
-            [ notify-upload upload-docs release ] when
+            [ notify-benchmarks notify-upload upload-docs release ] when
         ] bi
         notify-finish
         finish-build
index 362bc8dba7c06aa4a10cbd2d8828c767fa93f190..41d385c625408de37563f0e0c5d84d9556b44dd2 100644 (file)
@@ -7,8 +7,7 @@ splitting ;
 IN: mason.git
 
 : git-id ( -- id )
-    { "git" "show" } process-lines
-    first split-words second ;
+    { "git" "rev-parse" "HEAD" } process-lines first ;
 
 <PRIVATE
 
index a2e350f2deb92dbac359e16531a3947d5e0ce246..7e0f59d5007258253671f4d488ce85808cb26ffb 100644 (file)
@@ -63,6 +63,9 @@ IN: mason.notify
         [ name>> "report" status-notify ] [ email-report ] 2bi
     ] bi ;
 
+: notify-benchmarks ( -- )
+    "benchmark-results" utf8 file-contents f "benchmarks" status-notify ;
+
 : notify-upload ( -- )
     f f "upload" status-notify ;
 
index 1a05114bac99a414e4bf23aa109b38b83f99f424..157382c8ffa6e63fd708a7aca95f23b0812b0c76 100644 (file)
@@ -1,14 +1,19 @@
 ! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: assocs combinators.smart debugger formatting
+USING: arrays assocs combinators.smart debugger formatting
 io.encodings.utf8 io.files io.streams.string kernel literals
-mason.common mason.config mason.disk math namespaces sequences
-splitting xml.syntax xml.writer ;
+mason.common mason.config mason.disk math namespaces prettyprint
+sequences sets splitting xml.syntax xml.writer ;
 IN: mason.report
 
+: git-id>url ( id -- github-url )
+    "https://github.com/factor/factor/commit/" "" prepend-as ; inline
+
+: git-short-link ( id -- short-link )
+    [ git-id>url ] keep 8 head "…" append [XML <a href=<->><-></a> XML] ;
+
 : git-link ( id -- link )
-    [ "https://github.com/factor/factor/commit/" "" prepend-as ] keep
-    [XML <a href=<->><-></a> XML] ;
+    [ git-id>url ] keep [XML <a href=<->><-></a> XML] ;
 
 : common-report ( -- xml )
     target-os get
@@ -132,6 +137,23 @@ IN: mason.report
         ] output>array sift
     ] with-report ;
 
+: benchmark-results ( -- assoc )
+    ${
+        boot-time-file
+        load-time-file
+        test-time-file
+        help-lint-time-file
+        benchmark-time-file
+        html-help-time-file
+    } [
+        dup eval-file 2array
+    ] map
+    benchmarks-file eval-file
+    union ;
+
+: successful-benchmarks ( -- )
+    "benchmark-results" utf8 [ benchmark-results ... ] with-file-writer ;
+
 : build-clean? ( -- ? )
     ${
         load-all-vocabs-file
@@ -142,4 +164,4 @@ IN: mason.report
     } [ eval-file empty? ] all? ;
 
 : success ( -- status )
-    successful-report build-clean? status-clean status-dirty ? ;
+    successful-report build-clean? [ successful-benchmarks status-clean ] [ status-dirty ] if ;
index 57972b141f6c98a291d8f3a4e4b7d1744601eaca..f761372040a0a10c4511637644a52f4140cf74ba 100644 (file)
@@ -1,9 +1,9 @@
 USING: accessors arrays assocs byte-vectors checksums
-checksums.md5 constructors continuations destructors fry
-hashtables io.encodings.binary io.encodings.string
-io.encodings.utf8 io.sockets io.streams.duplex kernel locals
-math math.parser mongodb.cmd mongodb.msg strings
-namespaces sequences splitting ;
+checksums.md5 constructors continuations destructors hashtables
+hex-strings io.encodings.binary io.encodings.string
+io.encodings.utf8 io.sockets io.streams.duplex kernel math
+math.parser mongodb.cmd mongodb.msg namespaces sequences
+splitting strings ;
 IN: mongodb.connection
 
 : md5-checksum ( string -- digest )
index 9ad3ad5990c687380334eaf6879455cb611baaa1..bfdd83e61187a938ab6b55cda1e2d4de1265bf3a 100644 (file)
@@ -10,3 +10,13 @@ USING: pcre2 sequences tools.test ;
     "1999-01-12" "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})"
     findall first
 ] unit-test
+
+{
+    {
+        { { f "h" } }
+        { { f "e" } }
+        { { f "l" } }
+        { { f "l" } }
+        { { f "o" } }
+    }
+} [ "hello" "(.)" findall ] unit-test
index 6c7ec334b67babea526478accb25b3939e0193d8..7fb020abf214ddbdd0affa3387d75199646938dd 100644 (file)
@@ -134,7 +134,6 @@ M:: pcre2 findall ( subject obj -- matches )
                 [ throw ]
             } case
         ] [
-            rc name_count 1 + assert=
             match_data pcre2_get_ovector_pointer
             rc assert-positive 2 * PCRE2_SIZE <c-direct-array> :> ovector
 
@@ -212,7 +211,6 @@ M:: pcre2 findall ( subject obj -- matches )
 
                             f
                         ] [
-                            rc name_count 1 + assert=
                             [
                                 f ovector first2 subject subseq 2array ,
                                 name_table [
index d0b03eb52c139dd21fcc3fdcce064cfdaa9dd032..860d46c21f5eb047c626f3494cdcfdc5f71f687e 100644 (file)
@@ -29,7 +29,7 @@ CONSTANT: scryfall-images-path "resource:scryfall-images/"
 
 : load-scryfall-json ( type path -- uri )
     [ find-scryfall-json "download_uri" of ] dip
-    10 days download-outdated-as path>json ;
+    30 days download-outdated-as path>json ;
 
 MEMO: mtg-oracle-cards ( -- json )
     "oracle_cards" scryfall-oracle-json-path load-scryfall-json ;
@@ -363,6 +363,9 @@ MEMO: scryfall-rulings-json ( -- json )
 : filter-card-faces-main-card-iprop ( seq string prop -- seq' )
     swap >lower '[ _ of >lower _ subseq-of? ] filter-card-faces-main-card ;
 
+: filter-card-faces-main-card-iprop-member ( seq string prop -- seq' )
+    swap >lower '[ _ of [ >lower ] map _ member-of? ] filter-card-faces-main-card ;
+
 : filter-by-flavor-text ( seq string -- seq' )
     "flavor_text" filter-card-faces-main-card-prop ;
 
@@ -375,6 +378,9 @@ MEMO: scryfall-rulings-json ( -- json )
 : filter-by-oracle-itext ( seq string -- seq' )
     "oracle_text" filter-card-faces-main-card-iprop ;
 
+: filter-by-keyword ( seq string -- seq' )
+    "keywords" filter-card-faces-main-card-iprop-member ;
+
 : filter-by-name-text ( seq string -- seq' ) "name" filter-by-text-prop ;
 : filter-by-name-itext ( seq string -- seq' ) "name" filter-by-itext-prop ;
 
@@ -385,57 +391,268 @@ MEMO: scryfall-rulings-json ( -- json )
 : filter-create-map-token ( seq -- seq' ) "create a map token" filter-by-oracle-itext ;
 : filter-map-token ( seq -- seq' ) "map token" filter-by-oracle-itext ;
 
-: filter-affinity ( seq -- seq' ) "affinity" filter-by-oracle-itext ;
-: filter-backup ( seq -- seq' ) "backup" filter-by-oracle-itext ;
-: filter-blitz ( seq -- seq' ) "blitz" filter-by-oracle-itext ;
-: filter-compleated ( seq -- seq' ) "compleated" filter-by-oracle-itext ;
-: filter-corrupted ( seq -- seq' ) "corrupted" filter-by-oracle-itext ;
-: filter-counter ( seq -- seq' ) "counter" filter-by-oracle-itext ;
-: filter-crew ( seq -- seq' ) "crew" filter-by-oracle-itext ;
-: filter-cycling ( seq -- seq' ) "cycling" filter-by-oracle-itext ;
-: filter-deathtouch ( seq -- seq' ) "deathtouch" filter-by-oracle-itext ;
-: filter-defender ( seq -- seq' ) "defender" filter-by-oracle-itext ;
-: filter-descend ( seq -- seq' ) "descend" filter-by-oracle-itext ;
-: filter-destroy-target ( seq -- seq' ) "destroy target" filter-by-oracle-itext ;
-: filter-discover ( seq -- seq' ) "discover" filter-by-oracle-itext ;
-: filter-disguise ( seq -- seq' ) "disguise" filter-by-oracle-itext ;
-: filter-domain ( seq -- seq' ) "domain" filter-by-oracle-itext ;
-: filter-double-strike ( seq -- seq' ) "double strike" filter-by-oracle-itext ;
-: filter-equip ( seq -- seq' ) "equip" filter-by-oracle-itext ;
-: filter-equip-n ( seq -- seq' ) "equip {" filter-by-oracle-itext ;
-: filter-exile ( seq -- seq' ) "exile" filter-by-oracle-itext ;
-: filter-fights ( seq -- seq' ) "fights" filter-by-oracle-itext ;
-: filter-first-strike ( seq -- seq' ) "first strike" filter-by-oracle-itext ;
-: filter-flash ( seq -- seq' ) "flash" filter-by-oracle-itext ;
-: filter-flying ( seq -- seq' ) "flying" filter-by-oracle-itext ;
-: filter-for-mirrodin ( seq -- seq' ) "for mirrodin!" filter-by-oracle-itext ;
-: filter-graveyard ( seq -- seq' ) "graveyard" filter-by-oracle-itext ;
-: filter-haste ( seq -- seq' ) "haste" filter-by-oracle-itext ;
-: filter-hideaway ( seq -- seq' ) "hideaway" filter-by-oracle-itext ;
-: filter-hexproof ( seq -- seq' ) "hexproof" filter-by-oracle-itext ;
-: filter-indestructible ( seq -- seq' ) "indestructible" filter-by-oracle-itext ;
-: filter-investigate ( seq -- seq' ) "investigate" filter-by-oracle-itext ;
-: filter-lifelink ( seq -- seq' ) "lifelink" filter-by-oracle-itext ;
-: filter-madness ( seq -- seq' ) "madness" filter-by-oracle-itext ;
-: filter-menace ( seq -- seq' ) "menace" filter-by-oracle-itext ;
-: filter-mill ( seq -- seq' ) "mill" filter-by-oracle-itext ;
-: filter-ninjutsu ( seq -- seq' ) "ninjutsu" filter-by-oracle-itext ;
-: filter-proliferate ( seq -- seq' ) "proliferate" filter-by-oracle-itext ;
-: filter-protection ( seq -- seq' ) "protection" filter-by-oracle-itext ;
-: filter-prowess ( seq -- seq' ) "prowess" filter-by-oracle-itext ;
-: filter-reach ( seq -- seq' ) "reach" filter-by-oracle-itext ;
-: filter-read-ahead ( seq -- seq' ) "read ahead" filter-by-oracle-itext ;
-: filter-reconfigure ( seq -- seq' ) "reconfigure" filter-by-oracle-itext ;
-: filter-role ( seq -- seq' ) "role" filter-by-oracle-itext ;
-: filter-sacrifice ( seq -- seq' ) "sacrifice" filter-by-oracle-itext ;
-: filter-scry ( seq -- seq' ) "scry" filter-by-oracle-itext ;
-: filter-shroud ( seq -- seq' ) "shroud" filter-by-oracle-itext ;
-: filter-token ( seq -- seq' ) "token" filter-by-oracle-itext ;
-: filter-toxic ( seq -- seq' ) "toxic" filter-by-oracle-itext ;
-: filter-trample ( seq -- seq' ) "trample" filter-by-oracle-itext ;
-: filter-vehicle ( seq -- seq' ) "vehicle" filter-by-oracle-itext ;
-: filter-vigilance ( seq -- seq' ) "vigilance" filter-by-oracle-itext ;
-: filter-ward ( seq -- seq' ) "ward" filter-by-oracle-itext ;
+: filter-adamant-text ( seq -- seq' ) "adamant" filter-by-oracle-itext ;
+: filter-adapt-text ( seq -- seq' ) "adapt" filter-by-oracle-itext ;
+: filter-addendum-text ( seq -- seq' ) "addendum" filter-by-oracle-itext ;
+: filter-affinity-text ( seq -- seq' ) "affinity" filter-by-oracle-itext ;
+: filter-afflict-text ( seq -- seq' ) "afflict" filter-by-oracle-itext ;
+: filter-afterlife-text ( seq -- seq' ) "afterlife" filter-by-oracle-itext ;
+: filter-aftermath-text ( seq -- seq' ) "aftermath" filter-by-oracle-itext ;
+: filter-alliance-text ( seq -- seq' ) "alliance" filter-by-oracle-itext ;
+: filter-amass-text ( seq -- seq' ) "amass" filter-by-oracle-itext ;
+: filter-amplify-text ( seq -- seq' ) "amplify" filter-by-oracle-itext ;
+: filter-annihilator-text ( seq -- seq' ) "annihilator" filter-by-oracle-itext ;
+: filter-ascend-text ( seq -- seq' ) "ascend" filter-by-oracle-itext ;
+: filter-assemble-text ( seq -- seq' ) "assemble" filter-by-oracle-itext ;
+: filter-assist-text ( seq -- seq' ) "assist" filter-by-oracle-itext ;
+: filter-augment-text ( seq -- seq' ) "augment" filter-by-oracle-itext ;
+: filter-awaken-text ( seq -- seq' ) "awaken" filter-by-oracle-itext ;
+: filter-backup-text ( seq -- seq' ) "backup" filter-by-oracle-itext ;
+: filter-banding-text ( seq -- seq' ) "banding" filter-by-oracle-itext ;
+: filter-bargain-text ( seq -- seq' ) "bargain" filter-by-oracle-itext ;
+: filter-basic-landcycling-text ( seq -- seq' ) "basic landcycling" filter-by-oracle-itext ;
+: filter-battalion-text ( seq -- seq' ) "battalion" filter-by-oracle-itext ;
+: filter-battle-cry-text ( seq -- seq' ) "battle cry" filter-by-oracle-itext ;
+: filter-bestow-text ( seq -- seq' ) "bestow" filter-by-oracle-itext ;
+: filter-blitz-text ( seq -- seq' ) "blitz" filter-by-oracle-itext ;
+: filter-bloodrush-text ( seq -- seq' ) "bloodrush" filter-by-oracle-itext ;
+: filter-bloodthirst-text ( seq -- seq' ) "bloodthirst" filter-by-oracle-itext ;
+: filter-boast-text ( seq -- seq' ) "boast" filter-by-oracle-itext ;
+: filter-bolster-text ( seq -- seq' ) "bolster" filter-by-oracle-itext ;
+: filter-bushido-text ( seq -- seq' ) "bushido" filter-by-oracle-itext ;
+: filter-buyback-text ( seq -- seq' ) "buyback" filter-by-oracle-itext ;
+: filter-cascade-text ( seq -- seq' ) "cascade" filter-by-oracle-itext ;
+: filter-casualty-text ( seq -- seq' ) "casualty" filter-by-oracle-itext ;
+: filter-celebration-text ( seq -- seq' ) "celebration" filter-by-oracle-itext ;
+: filter-champion-text ( seq -- seq' ) "champion" filter-by-oracle-itext ;
+: filter-changeling-text ( seq -- seq' ) "changeling" filter-by-oracle-itext ;
+: filter-channel-text ( seq -- seq' ) "channel" filter-by-oracle-itext ;
+: filter-choose-a-background-text ( seq -- seq' ) "choose a background" filter-by-oracle-itext ;
+: filter-chroma-text ( seq -- seq' ) "chroma" filter-by-oracle-itext ;
+: filter-cipher-text ( seq -- seq' ) "cipher" filter-by-oracle-itext ;
+: filter-clash-text ( seq -- seq' ) "clash" filter-by-oracle-itext ;
+: filter-cleave-text ( seq -- seq' ) "cleave" filter-by-oracle-itext ;
+: filter-cloak-text ( seq -- seq' ) "cloak" filter-by-oracle-itext ;
+: filter-cohort-text ( seq -- seq' ) "cohort" filter-by-oracle-itext ;
+: filter-collect-evidence-text ( seq -- seq' ) "collect evidence" filter-by-oracle-itext ;
+: filter-companion-text ( seq -- seq' ) "companion" filter-by-oracle-itext ;
+: filter-compleated-text ( seq -- seq' ) "compleated" filter-by-oracle-itext ;
+: filter-conjure-text ( seq -- seq' ) "conjure" filter-by-oracle-itext ;
+: filter-connive-text ( seq -- seq' ) "connive" filter-by-oracle-itext ;
+: filter-conspire-text ( seq -- seq' ) "conspire" filter-by-oracle-itext ;
+: filter-constellation-text ( seq -- seq' ) "constellation" filter-by-oracle-itext ;
+: filter-converge-text ( seq -- seq' ) "converge" filter-by-oracle-itext ;
+: filter-convert-text ( seq -- seq' ) "convert" filter-by-oracle-itext ;
+: filter-convoke-text ( seq -- seq' ) "convoke" filter-by-oracle-itext ;
+: filter-corrupted-text ( seq -- seq' ) "corrupted" filter-by-oracle-itext ;
+: filter-council's-dilemma-text ( seq -- seq' ) "council's dilemma" filter-by-oracle-itext ;
+: filter-coven-text ( seq -- seq' ) "coven" filter-by-oracle-itext ;
+: filter-craft-text ( seq -- seq' ) "craft" filter-by-oracle-itext ;
+: filter-crew-text ( seq -- seq' ) "crew" filter-by-oracle-itext ;
+: filter-cumulative-upkeep-text ( seq -- seq' ) "cumulative upkeep" filter-by-oracle-itext ;
+: filter-cycling-text ( seq -- seq' ) "cycling" filter-by-oracle-itext ;
+: filter-dash-text ( seq -- seq' ) "dash" filter-by-oracle-itext ;
+: filter-daybound-text ( seq -- seq' ) "daybound" filter-by-oracle-itext ;
+: filter-deathtouch-text ( seq -- seq' ) "deathtouch" filter-by-oracle-itext ;
+: filter-defender-text ( seq -- seq' ) "defender" filter-by-oracle-itext ;
+: filter-delirium-text ( seq -- seq' ) "delirium" filter-by-oracle-itext ;
+: filter-delve-text ( seq -- seq' ) "delve" filter-by-oracle-itext ;
+: filter-descend-text ( seq -- seq' ) "descend" filter-by-oracle-itext ;
+: filter-detain-text ( seq -- seq' ) "detain" filter-by-oracle-itext ;
+: filter-dethrone-text ( seq -- seq' ) "dethrone" filter-by-oracle-itext ;
+: filter-devoid-text ( seq -- seq' ) "devoid" filter-by-oracle-itext ;
+: filter-devour-text ( seq -- seq' ) "devour" filter-by-oracle-itext ;
+: filter-discover-text ( seq -- seq' ) "discover" filter-by-oracle-itext ;
+: filter-disguise-text ( seq -- seq' ) "disguise" filter-by-oracle-itext ;
+: filter-disturb-text ( seq -- seq' ) "disturb" filter-by-oracle-itext ;
+: filter-doctor's-companion-text ( seq -- seq' ) "doctor's companion" filter-by-oracle-itext ;
+: filter-domain-text ( seq -- seq' ) "domain" filter-by-oracle-itext ;
+: filter-double-strike-text ( seq -- seq' ) "double strike" filter-by-oracle-itext ;
+: filter-dredge-text ( seq -- seq' ) "dredge" filter-by-oracle-itext ;
+: filter-echo-text ( seq -- seq' ) "echo" filter-by-oracle-itext ;
+: filter-embalm-text ( seq -- seq' ) "embalm" filter-by-oracle-itext ;
+: filter-emerge-text ( seq -- seq' ) "emerge" filter-by-oracle-itext ;
+: filter-eminence-text ( seq -- seq' ) "eminence" filter-by-oracle-itext ;
+: filter-enchant-text ( seq -- seq' ) "enchant" filter-by-oracle-itext ;
+: filter-encore-text ( seq -- seq' ) "encore" filter-by-oracle-itext ;
+: filter-enlist-text ( seq -- seq' ) "enlist" filter-by-oracle-itext ;
+: filter-enrage-text ( seq -- seq' ) "enrage" filter-by-oracle-itext ;
+: filter-entwine-text ( seq -- seq' ) "entwine" filter-by-oracle-itext ;
+: filter-equip-text ( seq -- seq' ) "equip" filter-by-oracle-itext ;
+: filter-escalate-text ( seq -- seq' ) "escalate" filter-by-oracle-itext ;
+: filter-escape-text ( seq -- seq' ) "escape" filter-by-oracle-itext ;
+: filter-eternalize-text ( seq -- seq' ) "eternalize" filter-by-oracle-itext ;
+: filter-evoke-text ( seq -- seq' ) "evoke" filter-by-oracle-itext ;
+: filter-evolve-text ( seq -- seq' ) "evolve" filter-by-oracle-itext ;
+: filter-exalted-text ( seq -- seq' ) "exalted" filter-by-oracle-itext ;
+: filter-exert-text ( seq -- seq' ) "exert" filter-by-oracle-itext ;
+: filter-exploit-text ( seq -- seq' ) "exploit" filter-by-oracle-itext ;
+: filter-explore-text ( seq -- seq' ) "explore" filter-by-oracle-itext ;
+: filter-extort-text ( seq -- seq' ) "extort" filter-by-oracle-itext ;
+: filter-fabricate-text ( seq -- seq' ) "fabricate" filter-by-oracle-itext ;
+: filter-fading-text ( seq -- seq' ) "fading" filter-by-oracle-itext ;
+: filter-fateful-hour-text ( seq -- seq' ) "fateful hour" filter-by-oracle-itext ;
+: filter-fathomless-descent-text ( seq -- seq' ) "fathomless descent" filter-by-oracle-itext ;
+: filter-fear-text ( seq -- seq' ) "fear" filter-by-oracle-itext ;
+: filter-ferocious-text ( seq -- seq' ) "ferocious" filter-by-oracle-itext ;
+: filter-fight-text ( seq -- seq' ) "fight" filter-by-oracle-itext ;
+: filter-first-strike-text ( seq -- seq' ) "first strike" filter-by-oracle-itext ;
+: filter-flanking-text ( seq -- seq' ) "flanking" filter-by-oracle-itext ;
+: filter-flash-text ( seq -- seq' ) "flash" filter-by-oracle-itext ;
+: filter-flashback-text ( seq -- seq' ) "flashback" filter-by-oracle-itext ;
+: filter-flying-text ( seq -- seq' ) "flying" filter-by-oracle-itext ;
+: filter-food-text ( seq -- seq' ) "food" filter-by-oracle-itext ;
+: filter-for-mirrodin!-text ( seq -- seq' ) "for mirrodin!" filter-by-oracle-itext ;
+: filter-forecast-text ( seq -- seq' ) "forecast" filter-by-oracle-itext ;
+: filter-forestcycling-text ( seq -- seq' ) "forestcycling" filter-by-oracle-itext ;
+: filter-forestwalk-text ( seq -- seq' ) "forestwalk" filter-by-oracle-itext ;
+: filter-foretell-text ( seq -- seq' ) "foretell" filter-by-oracle-itext ;
+: filter-formidable-text ( seq -- seq' ) "formidable" filter-by-oracle-itext ;
+: filter-friends-forever-text ( seq -- seq' ) "friends forever" filter-by-oracle-itext ;
+: filter-fuse-text ( seq -- seq' ) "fuse" filter-by-oracle-itext ;
+: filter-goad-text ( seq -- seq' ) "goad" filter-by-oracle-itext ;
+: filter-graft-text ( seq -- seq' ) "graft" filter-by-oracle-itext ;
+: filter-haste-text ( seq -- seq' ) "haste" filter-by-oracle-itext ;
+: filter-haunt-text ( seq -- seq' ) "haunt" filter-by-oracle-itext ;
+: filter-hellbent-text ( seq -- seq' ) "hellbent" filter-by-oracle-itext ;
+: filter-hero's-reward-text ( seq -- seq' ) "hero's reward" filter-by-oracle-itext ;
+: filter-heroic-text ( seq -- seq' ) "heroic" filter-by-oracle-itext ;
+: filter-hexproof-text ( seq -- seq' ) "hexproof" filter-by-oracle-itext ;
+: filter-hexproof-from-text ( seq -- seq' ) "hexproof from" filter-by-oracle-itext ;
+: filter-hidden-agenda-text ( seq -- seq' ) "hidden agenda" filter-by-oracle-itext ;
+: filter-hideaway-text ( seq -- seq' ) "hideaway" filter-by-oracle-itext ;
+: filter-horsemanship-text ( seq -- seq' ) "horsemanship" filter-by-oracle-itext ;
+: filter-imprint-text ( seq -- seq' ) "imprint" filter-by-oracle-itext ;
+: filter-improvise-text ( seq -- seq' ) "improvise" filter-by-oracle-itext ;
+: filter-incubate-text ( seq -- seq' ) "incubate" filter-by-oracle-itext ;
+: filter-indestructible-text ( seq -- seq' ) "indestructible" filter-by-oracle-itext ;
+: filter-infect-text ( seq -- seq' ) "infect" filter-by-oracle-itext ;
+: filter-ingest-text ( seq -- seq' ) "ingest" filter-by-oracle-itext ;
+: filter-inspired-text ( seq -- seq' ) "inspired" filter-by-oracle-itext ;
+: filter-intensity-text ( seq -- seq' ) "intensity" filter-by-oracle-itext ;
+: filter-intimidate-text ( seq -- seq' ) "intimidate" filter-by-oracle-itext ;
+: filter-investigate-text ( seq -- seq' ) "investigate" filter-by-oracle-itext ;
+: filter-islandcycling-text ( seq -- seq' ) "islandcycling" filter-by-oracle-itext ;
+: filter-islandwalk-text ( seq -- seq' ) "islandwalk" filter-by-oracle-itext ;
+: filter-jump-start-text ( seq -- seq' ) "jump-start" filter-by-oracle-itext ;
+: filter-kicker-text ( seq -- seq' ) "kicker" filter-by-oracle-itext ;
+: filter-kinship-text ( seq -- seq' ) "kinship" filter-by-oracle-itext ;
+: filter-landcycling-text ( seq -- seq' ) "landcycling" filter-by-oracle-itext ;
+: filter-landfall-text ( seq -- seq' ) "landfall" filter-by-oracle-itext ;
+: filter-landwalk-text ( seq -- seq' ) "landwalk" filter-by-oracle-itext ;
+: filter-learn-text ( seq -- seq' ) "learn" filter-by-oracle-itext ;
+: filter-level-up-text ( seq -- seq' ) "level up" filter-by-oracle-itext ;
+: filter-lieutenant-text ( seq -- seq' ) "lieutenant" filter-by-oracle-itext ;
+: filter-lifelink-text ( seq -- seq' ) "lifelink" filter-by-oracle-itext ;
+: filter-living-metal-text ( seq -- seq' ) "living metal" filter-by-oracle-itext ;
+: filter-living-weapon-text ( seq -- seq' ) "living weapon" filter-by-oracle-itext ;
+: filter-madness-text ( seq -- seq' ) "madness" filter-by-oracle-itext ;
+: filter-magecraft-text ( seq -- seq' ) "magecraft" filter-by-oracle-itext ;
+: filter-manifest-text ( seq -- seq' ) "manifest" filter-by-oracle-itext ;
+: filter-megamorph-text ( seq -- seq' ) "megamorph" filter-by-oracle-itext ;
+: filter-meld-text ( seq -- seq' ) "meld" filter-by-oracle-itext ;
+: filter-melee-text ( seq -- seq' ) "melee" filter-by-oracle-itext ;
+: filter-menace-text ( seq -- seq' ) "menace" filter-by-oracle-itext ;
+: filter-mentor-text ( seq -- seq' ) "mentor" filter-by-oracle-itext ;
+: filter-metalcraft-text ( seq -- seq' ) "metalcraft" filter-by-oracle-itext ;
+: filter-mill-text ( seq -- seq' ) "mill" filter-by-oracle-itext ;
+: filter-miracle-text ( seq -- seq' ) "miracle" filter-by-oracle-itext ;
+: filter-modular-text ( seq -- seq' ) "modular" filter-by-oracle-itext ;
+: filter-monstrosity-text ( seq -- seq' ) "monstrosity" filter-by-oracle-itext ;
+: filter-morbid-text ( seq -- seq' ) "morbid" filter-by-oracle-itext ;
+: filter-more-than-meets-the-eye-text ( seq -- seq' ) "more than meets the eye" filter-by-oracle-itext ;
+: filter-morph-text ( seq -- seq' ) "morph" filter-by-oracle-itext ;
+: filter-mountaincycling-text ( seq -- seq' ) "mountaincycling" filter-by-oracle-itext ;
+: filter-mountainwalk-text ( seq -- seq' ) "mountainwalk" filter-by-oracle-itext ;
+: filter-multikicker-text ( seq -- seq' ) "multikicker" filter-by-oracle-itext ;
+: filter-mutate-text ( seq -- seq' ) "mutate" filter-by-oracle-itext ;
+: filter-myriad-text ( seq -- seq' ) "myriad" filter-by-oracle-itext ;
+: filter-nightbound-text ( seq -- seq' ) "nightbound" filter-by-oracle-itext ;
+: filter-ninjutsu-text ( seq -- seq' ) "ninjutsu" filter-by-oracle-itext ;
+: filter-offering-text ( seq -- seq' ) "offering" filter-by-oracle-itext ;
+: filter-open-an-attraction-text ( seq -- seq' ) "open an attraction" filter-by-oracle-itext ;
+: filter-outlast-text ( seq -- seq' ) "outlast" filter-by-oracle-itext ;
+: filter-overload-text ( seq -- seq' ) "overload" filter-by-oracle-itext ;
+: filter-pack-tactics-text ( seq -- seq' ) "pack tactics" filter-by-oracle-itext ;
+: filter-paradox-text ( seq -- seq' ) "paradox" filter-by-oracle-itext ;
+: filter-parley-text ( seq -- seq' ) "parley" filter-by-oracle-itext ;
+: filter-partner-text ( seq -- seq' ) "partner" filter-by-oracle-itext ;
+: filter-partner-with-text ( seq -- seq' ) "partner with" filter-by-oracle-itext ;
+: filter-persist-text ( seq -- seq' ) "persist" filter-by-oracle-itext ;
+: filter-phasing-text ( seq -- seq' ) "phasing" filter-by-oracle-itext ;
+: filter-plainscycling-text ( seq -- seq' ) "plainscycling" filter-by-oracle-itext ;
+: filter-plot-text ( seq -- seq' ) "plot" filter-by-oracle-itext ;
+: filter-populate-text ( seq -- seq' ) "populate" filter-by-oracle-itext ;
+: filter-proliferate-text ( seq -- seq' ) "proliferate" filter-by-oracle-itext ;
+: filter-protection-text ( seq -- seq' ) "protection" filter-by-oracle-itext ;
+: filter-prototype-text ( seq -- seq' ) "prototype" filter-by-oracle-itext ;
+: filter-provoke-text ( seq -- seq' ) "provoke" filter-by-oracle-itext ;
+: filter-prowess-text ( seq -- seq' ) "prowess" filter-by-oracle-itext ;
+: filter-prowl-text ( seq -- seq' ) "prowl" filter-by-oracle-itext ;
+: filter-radiance-text ( seq -- seq' ) "radiance" filter-by-oracle-itext ;
+: filter-raid-text ( seq -- seq' ) "raid" filter-by-oracle-itext ;
+: filter-rally-text ( seq -- seq' ) "rally" filter-by-oracle-itext ;
+: filter-rampage-text ( seq -- seq' ) "rampage" filter-by-oracle-itext ;
+: filter-ravenous-text ( seq -- seq' ) "ravenous" filter-by-oracle-itext ;
+: filter-reach-text ( seq -- seq' ) "reach" filter-by-oracle-itext ;
+: filter-read-ahead-text ( seq -- seq' ) "read ahead" filter-by-oracle-itext ;
+: filter-rebound-text ( seq -- seq' ) "rebound" filter-by-oracle-itext ;
+: filter-reconfigure-text ( seq -- seq' ) "reconfigure" filter-by-oracle-itext ;
+: filter-recover-text ( seq -- seq' ) "recover" filter-by-oracle-itext ;
+: filter-reinforce-text ( seq -- seq' ) "reinforce" filter-by-oracle-itext ;
+: filter-renown-text ( seq -- seq' ) "renown" filter-by-oracle-itext ;
+: filter-replicate-text ( seq -- seq' ) "replicate" filter-by-oracle-itext ;
+: filter-retrace-text ( seq -- seq' ) "retrace" filter-by-oracle-itext ;
+: filter-revolt-text ( seq -- seq' ) "revolt" filter-by-oracle-itext ;
+: filter-riot-text ( seq -- seq' ) "riot" filter-by-oracle-itext ;
+: filter-role-token-text ( seq -- seq' ) "role token" filter-by-oracle-itext ;
+: filter-saddle-text ( seq -- seq' ) "saddle" filter-by-oracle-itext ;
+: filter-scavenge-text ( seq -- seq' ) "scavenge" filter-by-oracle-itext ;
+: filter-scry-text ( seq -- seq' ) "scry" filter-by-oracle-itext ;
+: filter-seek-text ( seq -- seq' ) "seek" filter-by-oracle-itext ;
+: filter-shadow-text ( seq -- seq' ) "shadow" filter-by-oracle-itext ;
+: filter-shroud-text ( seq -- seq' ) "shroud" filter-by-oracle-itext ;
+: filter-skulk-text ( seq -- seq' ) "skulk" filter-by-oracle-itext ;
+: filter-soulbond-text ( seq -- seq' ) "soulbond" filter-by-oracle-itext ;
+: filter-soulshift-text ( seq -- seq' ) "soulshift" filter-by-oracle-itext ;
+: filter-specialize-text ( seq -- seq' ) "specialize" filter-by-oracle-itext ;
+: filter-spectacle-text ( seq -- seq' ) "spectacle" filter-by-oracle-itext ;
+: filter-spell-mastery-text ( seq -- seq' ) "spell mastery" filter-by-oracle-itext ;
+: filter-splice-text ( seq -- seq' ) "splice" filter-by-oracle-itext ;
+: filter-split-second-text ( seq -- seq' ) "split second" filter-by-oracle-itext ;
+: filter-spree-text ( seq -- seq' ) "spree" filter-by-oracle-itext ;
+: filter-squad-text ( seq -- seq' ) "squad" filter-by-oracle-itext ;
+: filter-storm-text ( seq -- seq' ) "storm" filter-by-oracle-itext ;
+: filter-strive-text ( seq -- seq' ) "strive" filter-by-oracle-itext ;
+: filter-sunburst-text ( seq -- seq' ) "sunburst" filter-by-oracle-itext ;
+: filter-support-text ( seq -- seq' ) "support" filter-by-oracle-itext ;
+: filter-surge-text ( seq -- seq' ) "surge" filter-by-oracle-itext ;
+: filter-surveil-text ( seq -- seq' ) "surveil" filter-by-oracle-itext ;
+: filter-suspect-text ( seq -- seq' ) "suspect" filter-by-oracle-itext ;
+: filter-suspend-text ( seq -- seq' ) "suspend" filter-by-oracle-itext ;
+: filter-swampcycling-text ( seq -- seq' ) "swampcycling" filter-by-oracle-itext ;
+: filter-swampwalk-text ( seq -- seq' ) "swampwalk" filter-by-oracle-itext ;
+: filter-threshold-text ( seq -- seq' ) "threshold" filter-by-oracle-itext ;
+: filter-time-travel-text ( seq -- seq' ) "time travel" filter-by-oracle-itext ;
+: filter-totem-armor-text ( seq -- seq' ) "totem armor" filter-by-oracle-itext ;
+: filter-toxic-text ( seq -- seq' ) "toxic" filter-by-oracle-itext ;
+: filter-training-text ( seq -- seq' ) "training" filter-by-oracle-itext ;
+: filter-trample-text ( seq -- seq' ) "trample" filter-by-oracle-itext ;
+: filter-transform-text ( seq -- seq' ) "transform" filter-by-oracle-itext ;
+: filter-transmute-text ( seq -- seq' ) "transmute" filter-by-oracle-itext ;
+: filter-treasure-text ( seq -- seq' ) "treasure" filter-by-oracle-itext ;
+: filter-tribute-text ( seq -- seq' ) "tribute" filter-by-oracle-itext ;
+: filter-typecycling-text ( seq -- seq' ) "typecycling" filter-by-oracle-itext ;
+: filter-undergrowth-text ( seq -- seq' ) "undergrowth" filter-by-oracle-itext ;
+: filter-undying-text ( seq -- seq' ) "undying" filter-by-oracle-itext ;
+: filter-unearth-text ( seq -- seq' ) "unearth" filter-by-oracle-itext ;
+: filter-unleash-text ( seq -- seq' ) "unleash" filter-by-oracle-itext ;
+: filter-vanishing-text ( seq -- seq' ) "vanishing" filter-by-oracle-itext ;
+: filter-venture-into-the-dungeon-text ( seq -- seq' ) "venture into the dungeon" filter-by-oracle-itext ;
+: filter-vigilance-text ( seq -- seq' ) "vigilance" filter-by-oracle-itext ;
+: filter-ward-text ( seq -- seq' ) "ward" filter-by-oracle-itext ;
+: filter-will-of-the-council-text ( seq -- seq' ) "will of the council" filter-by-oracle-itext ;
+: filter-wither-text ( seq -- seq' ) "wither" filter-by-oracle-itext ;
 
 : filter-day ( seq -- seq' ) "day" filter-by-oracle-itext ;
 : filter-night ( seq -- seq' ) "night" filter-by-oracle-itext ;
@@ -452,6 +669,269 @@ MEMO: scryfall-rulings-json ( -- json )
 : filter-saddle ( seq -- seq' ) "saddle" filter-by-oracle-itext ;
 : filter-spree ( seq -- seq' ) "saddle" filter-by-oracle-itext ;
 
+: filter-adamant-keyword ( seq -- seq' ) "adamant" filter-by-keyword ;
+: filter-adapt-keyword ( seq -- seq' ) "adapt" filter-by-keyword ;
+: filter-addendum-keyword ( seq -- seq' ) "addendum" filter-by-keyword ;
+: filter-affinity-keyword ( seq -- seq' ) "affinity" filter-by-keyword ;
+: filter-afflict-keyword ( seq -- seq' ) "afflict" filter-by-keyword ;
+: filter-afterlife-keyword ( seq -- seq' ) "afterlife" filter-by-keyword ;
+: filter-aftermath-keyword ( seq -- seq' ) "aftermath" filter-by-keyword ;
+: filter-alliance-keyword ( seq -- seq' ) "alliance" filter-by-keyword ;
+: filter-amass-keyword ( seq -- seq' ) "amass" filter-by-keyword ;
+: filter-amplify-keyword ( seq -- seq' ) "amplify" filter-by-keyword ;
+: filter-annihilator-keyword ( seq -- seq' ) "annihilator" filter-by-keyword ;
+: filter-ascend-keyword ( seq -- seq' ) "ascend" filter-by-keyword ;
+: filter-assemble-keyword ( seq -- seq' ) "assemble" filter-by-keyword ;
+: filter-assist-keyword ( seq -- seq' ) "assist" filter-by-keyword ;
+: filter-augment-keyword ( seq -- seq' ) "augment" filter-by-keyword ;
+: filter-awaken-keyword ( seq -- seq' ) "awaken" filter-by-keyword ;
+: filter-backup-keyword ( seq -- seq' ) "backup" filter-by-keyword ;
+: filter-banding-keyword ( seq -- seq' ) "banding" filter-by-keyword ;
+: filter-bargain-keyword ( seq -- seq' ) "bargain" filter-by-keyword ;
+: filter-basic-landcycling-keyword ( seq -- seq' ) "basic-landcycling" filter-by-keyword ;
+: filter-battalion-keyword ( seq -- seq' ) "battalion" filter-by-keyword ;
+: filter-battle-cry-keyword ( seq -- seq' ) "battle-cry" filter-by-keyword ;
+: filter-bestow-keyword ( seq -- seq' ) "bestow" filter-by-keyword ;
+: filter-blitz-keyword ( seq -- seq' ) "blitz" filter-by-keyword ;
+: filter-bloodrush-keyword ( seq -- seq' ) "bloodrush" filter-by-keyword ;
+: filter-bloodthirst-keyword ( seq -- seq' ) "bloodthirst" filter-by-keyword ;
+: filter-boast-keyword ( seq -- seq' ) "boast" filter-by-keyword ;
+: filter-bolster-keyword ( seq -- seq' ) "bolster" filter-by-keyword ;
+: filter-bushido-keyword ( seq -- seq' ) "bushido" filter-by-keyword ;
+: filter-buyback-keyword ( seq -- seq' ) "buyback" filter-by-keyword ;
+: filter-cascade-keyword ( seq -- seq' ) "cascade" filter-by-keyword ;
+: filter-casualty-keyword ( seq -- seq' ) "casualty" filter-by-keyword ;
+: filter-celebration-keyword ( seq -- seq' ) "celebration" filter-by-keyword ;
+: filter-champion-keyword ( seq -- seq' ) "champion" filter-by-keyword ;
+: filter-changeling-keyword ( seq -- seq' ) "changeling" filter-by-keyword ;
+: filter-channel-keyword ( seq -- seq' ) "channel" filter-by-keyword ;
+: filter-choose-a-background-keyword ( seq -- seq' ) "choose-a-background" filter-by-keyword ;
+: filter-chroma-keyword ( seq -- seq' ) "chroma" filter-by-keyword ;
+: filter-cipher-keyword ( seq -- seq' ) "cipher" filter-by-keyword ;
+: filter-clash-keyword ( seq -- seq' ) "clash" filter-by-keyword ;
+: filter-cleave-keyword ( seq -- seq' ) "cleave" filter-by-keyword ;
+: filter-cloak-keyword ( seq -- seq' ) "cloak" filter-by-keyword ;
+: filter-cohort-keyword ( seq -- seq' ) "cohort" filter-by-keyword ;
+: filter-collect-evidence-keyword ( seq -- seq' ) "collect-evidence" filter-by-keyword ;
+: filter-companion-keyword ( seq -- seq' ) "companion" filter-by-keyword ;
+: filter-compleated-keyword ( seq -- seq' ) "compleated" filter-by-keyword ;
+: filter-conjure-keyword ( seq -- seq' ) "conjure" filter-by-keyword ;
+: filter-connive-keyword ( seq -- seq' ) "connive" filter-by-keyword ;
+: filter-conspire-keyword ( seq -- seq' ) "conspire" filter-by-keyword ;
+: filter-constellation-keyword ( seq -- seq' ) "constellation" filter-by-keyword ;
+: filter-converge-keyword ( seq -- seq' ) "converge" filter-by-keyword ;
+: filter-convert-keyword ( seq -- seq' ) "convert" filter-by-keyword ;
+: filter-convoke-keyword ( seq -- seq' ) "convoke" filter-by-keyword ;
+: filter-corrupted-keyword ( seq -- seq' ) "corrupted" filter-by-keyword ;
+: filter-council's-dilemma-keyword ( seq -- seq' ) "council's-dilemma" filter-by-keyword ;
+: filter-coven-keyword ( seq -- seq' ) "coven" filter-by-keyword ;
+: filter-craft-keyword ( seq -- seq' ) "craft" filter-by-keyword ;
+: filter-crew-keyword ( seq -- seq' ) "crew" filter-by-keyword ;
+: filter-cumulative-upkeep-keyword ( seq -- seq' ) "cumulative-upkeep" filter-by-keyword ;
+: filter-cycling-keyword ( seq -- seq' ) "cycling" filter-by-keyword ;
+: filter-dash-keyword ( seq -- seq' ) "dash" filter-by-keyword ;
+: filter-daybound-keyword ( seq -- seq' ) "daybound" filter-by-keyword ;
+: filter-deathtouch-keyword ( seq -- seq' ) "deathtouch" filter-by-keyword ;
+: filter-defender-keyword ( seq -- seq' ) "defender" filter-by-keyword ;
+: filter-delirium-keyword ( seq -- seq' ) "delirium" filter-by-keyword ;
+: filter-delve-keyword ( seq -- seq' ) "delve" filter-by-keyword ;
+: filter-descend-keyword ( seq -- seq' ) "descend" filter-by-keyword ;
+: filter-detain-keyword ( seq -- seq' ) "detain" filter-by-keyword ;
+: filter-dethrone-keyword ( seq -- seq' ) "dethrone" filter-by-keyword ;
+: filter-devoid-keyword ( seq -- seq' ) "devoid" filter-by-keyword ;
+: filter-devour-keyword ( seq -- seq' ) "devour" filter-by-keyword ;
+: filter-discover-keyword ( seq -- seq' ) "discover" filter-by-keyword ;
+: filter-disguise-keyword ( seq -- seq' ) "disguise" filter-by-keyword ;
+: filter-disturb-keyword ( seq -- seq' ) "disturb" filter-by-keyword ;
+: filter-doctor's-companion-keyword ( seq -- seq' ) "doctor's-companion" filter-by-keyword ;
+: filter-domain-keyword ( seq -- seq' ) "domain" filter-by-keyword ;
+: filter-double-strike-keyword ( seq -- seq' ) "double-strike" filter-by-keyword ;
+: filter-dredge-keyword ( seq -- seq' ) "dredge" filter-by-keyword ;
+: filter-echo-keyword ( seq -- seq' ) "echo" filter-by-keyword ;
+: filter-embalm-keyword ( seq -- seq' ) "embalm" filter-by-keyword ;
+: filter-emerge-keyword ( seq -- seq' ) "emerge" filter-by-keyword ;
+: filter-eminence-keyword ( seq -- seq' ) "eminence" filter-by-keyword ;
+: filter-enchant-keyword ( seq -- seq' ) "enchant" filter-by-keyword ;
+: filter-encore-keyword ( seq -- seq' ) "encore" filter-by-keyword ;
+: filter-enlist-keyword ( seq -- seq' ) "enlist" filter-by-keyword ;
+: filter-enrage-keyword ( seq -- seq' ) "enrage" filter-by-keyword ;
+: filter-entwine-keyword ( seq -- seq' ) "entwine" filter-by-keyword ;
+: filter-equip-keyword ( seq -- seq' ) "equip" filter-by-keyword ;
+: filter-escalate-keyword ( seq -- seq' ) "escalate" filter-by-keyword ;
+: filter-escape-keyword ( seq -- seq' ) "escape" filter-by-keyword ;
+: filter-eternalize-keyword ( seq -- seq' ) "eternalize" filter-by-keyword ;
+: filter-evoke-keyword ( seq -- seq' ) "evoke" filter-by-keyword ;
+: filter-evolve-keyword ( seq -- seq' ) "evolve" filter-by-keyword ;
+: filter-exalted-keyword ( seq -- seq' ) "exalted" filter-by-keyword ;
+: filter-exert-keyword ( seq -- seq' ) "exert" filter-by-keyword ;
+: filter-exploit-keyword ( seq -- seq' ) "exploit" filter-by-keyword ;
+: filter-explore-keyword ( seq -- seq' ) "explore" filter-by-keyword ;
+: filter-extort-keyword ( seq -- seq' ) "extort" filter-by-keyword ;
+: filter-fabricate-keyword ( seq -- seq' ) "fabricate" filter-by-keyword ;
+: filter-fading-keyword ( seq -- seq' ) "fading" filter-by-keyword ;
+: filter-fateful-hour-keyword ( seq -- seq' ) "fateful-hour" filter-by-keyword ;
+: filter-fathomless-descent-keyword ( seq -- seq' ) "fathomless-descent" filter-by-keyword ;
+: filter-fear-keyword ( seq -- seq' ) "fear" filter-by-keyword ;
+: filter-ferocious-keyword ( seq -- seq' ) "ferocious" filter-by-keyword ;
+: filter-fight-keyword ( seq -- seq' ) "fight" filter-by-keyword ;
+: filter-first-strike-keyword ( seq -- seq' ) "first-strike" filter-by-keyword ;
+: filter-flanking-keyword ( seq -- seq' ) "flanking" filter-by-keyword ;
+: filter-flash-keyword ( seq -- seq' ) "flash" filter-by-keyword ;
+: filter-flashback-keyword ( seq -- seq' ) "flashback" filter-by-keyword ;
+: filter-flying-keyword ( seq -- seq' ) "flying" filter-by-keyword ;
+: filter-food-keyword ( seq -- seq' ) "food" filter-by-keyword ;
+: filter-for-mirrodin!-keyword ( seq -- seq' ) "for-mirrodin!" filter-by-keyword ;
+: filter-forecast-keyword ( seq -- seq' ) "forecast" filter-by-keyword ;
+: filter-forestcycling-keyword ( seq -- seq' ) "forestcycling" filter-by-keyword ;
+: filter-forestwalk-keyword ( seq -- seq' ) "forestwalk" filter-by-keyword ;
+: filter-foretell-keyword ( seq -- seq' ) "foretell" filter-by-keyword ;
+: filter-formidable-keyword ( seq -- seq' ) "formidable" filter-by-keyword ;
+: filter-friends-forever-keyword ( seq -- seq' ) "friends-forever" filter-by-keyword ;
+: filter-fuse-keyword ( seq -- seq' ) "fuse" filter-by-keyword ;
+: filter-goad-keyword ( seq -- seq' ) "goad" filter-by-keyword ;
+: filter-graft-keyword ( seq -- seq' ) "graft" filter-by-keyword ;
+: filter-haste-keyword ( seq -- seq' ) "haste" filter-by-keyword ;
+: filter-haunt-keyword ( seq -- seq' ) "haunt" filter-by-keyword ;
+: filter-hellbent-keyword ( seq -- seq' ) "hellbent" filter-by-keyword ;
+: filter-hero's-reward-keyword ( seq -- seq' ) "hero's-reward" filter-by-keyword ;
+: filter-heroic-keyword ( seq -- seq' ) "heroic" filter-by-keyword ;
+: filter-hexproof-keyword ( seq -- seq' ) "hexproof" filter-by-keyword ;
+: filter-hexproof-from-keyword ( seq -- seq' ) "hexproof-from" filter-by-keyword ;
+: filter-hidden-agenda-keyword ( seq -- seq' ) "hidden-agenda" filter-by-keyword ;
+: filter-hideaway-keyword ( seq -- seq' ) "hideaway" filter-by-keyword ;
+: filter-horsemanship-keyword ( seq -- seq' ) "horsemanship" filter-by-keyword ;
+: filter-imprint-keyword ( seq -- seq' ) "imprint" filter-by-keyword ;
+: filter-improvise-keyword ( seq -- seq' ) "improvise" filter-by-keyword ;
+: filter-incubate-keyword ( seq -- seq' ) "incubate" filter-by-keyword ;
+: filter-indestructible-keyword ( seq -- seq' ) "indestructible" filter-by-keyword ;
+: filter-infect-keyword ( seq -- seq' ) "infect" filter-by-keyword ;
+: filter-ingest-keyword ( seq -- seq' ) "ingest" filter-by-keyword ;
+: filter-inspired-keyword ( seq -- seq' ) "inspired" filter-by-keyword ;
+: filter-intensity-keyword ( seq -- seq' ) "intensity" filter-by-keyword ;
+: filter-intimidate-keyword ( seq -- seq' ) "intimidate" filter-by-keyword ;
+: filter-investigate-keyword ( seq -- seq' ) "investigate" filter-by-keyword ;
+: filter-islandcycling-keyword ( seq -- seq' ) "islandcycling" filter-by-keyword ;
+: filter-islandwalk-keyword ( seq -- seq' ) "islandwalk" filter-by-keyword ;
+: filter-jump-start-keyword ( seq -- seq' ) "jump-start" filter-by-keyword ;
+: filter-kicker-keyword ( seq -- seq' ) "kicker" filter-by-keyword ;
+: filter-kinship-keyword ( seq -- seq' ) "kinship" filter-by-keyword ;
+: filter-landcycling-keyword ( seq -- seq' ) "landcycling" filter-by-keyword ;
+: filter-landfall-keyword ( seq -- seq' ) "landfall" filter-by-keyword ;
+: filter-landwalk-keyword ( seq -- seq' ) "landwalk" filter-by-keyword ;
+: filter-learn-keyword ( seq -- seq' ) "learn" filter-by-keyword ;
+: filter-level-up-keyword ( seq -- seq' ) "level-up" filter-by-keyword ;
+: filter-lieutenant-keyword ( seq -- seq' ) "lieutenant" filter-by-keyword ;
+: filter-lifelink-keyword ( seq -- seq' ) "lifelink" filter-by-keyword ;
+: filter-living-metal-keyword ( seq -- seq' ) "living-metal" filter-by-keyword ;
+: filter-living-weapon-keyword ( seq -- seq' ) "living-weapon" filter-by-keyword ;
+: filter-madness-keyword ( seq -- seq' ) "madness" filter-by-keyword ;
+: filter-magecraft-keyword ( seq -- seq' ) "magecraft" filter-by-keyword ;
+: filter-manifest-keyword ( seq -- seq' ) "manifest" filter-by-keyword ;
+: filter-megamorph-keyword ( seq -- seq' ) "megamorph" filter-by-keyword ;
+: filter-meld-keyword ( seq -- seq' ) "meld" filter-by-keyword ;
+: filter-melee-keyword ( seq -- seq' ) "melee" filter-by-keyword ;
+: filter-menace-keyword ( seq -- seq' ) "menace" filter-by-keyword ;
+: filter-mentor-keyword ( seq -- seq' ) "mentor" filter-by-keyword ;
+: filter-metalcraft-keyword ( seq -- seq' ) "metalcraft" filter-by-keyword ;
+: filter-mill-keyword ( seq -- seq' ) "mill" filter-by-keyword ;
+: filter-miracle-keyword ( seq -- seq' ) "miracle" filter-by-keyword ;
+: filter-modular-keyword ( seq -- seq' ) "modular" filter-by-keyword ;
+: filter-monstrosity-keyword ( seq -- seq' ) "monstrosity" filter-by-keyword ;
+: filter-morbid-keyword ( seq -- seq' ) "morbid" filter-by-keyword ;
+: filter-more-than-meets-the-eye-keyword ( seq -- seq' ) "more-than-meets-the-eye" filter-by-keyword ;
+: filter-morph-keyword ( seq -- seq' ) "morph" filter-by-keyword ;
+: filter-mountaincycling-keyword ( seq -- seq' ) "mountaincycling" filter-by-keyword ;
+: filter-mountainwalk-keyword ( seq -- seq' ) "mountainwalk" filter-by-keyword ;
+: filter-multikicker-keyword ( seq -- seq' ) "multikicker" filter-by-keyword ;
+: filter-mutate-keyword ( seq -- seq' ) "mutate" filter-by-keyword ;
+: filter-myriad-keyword ( seq -- seq' ) "myriad" filter-by-keyword ;
+: filter-nightbound-keyword ( seq -- seq' ) "nightbound" filter-by-keyword ;
+: filter-ninjutsu-keyword ( seq -- seq' ) "ninjutsu" filter-by-keyword ;
+: filter-offering-keyword ( seq -- seq' ) "offering" filter-by-keyword ;
+: filter-open-an-attraction-keyword ( seq -- seq' ) "open-an-attraction" filter-by-keyword ;
+: filter-outlast-keyword ( seq -- seq' ) "outlast" filter-by-keyword ;
+: filter-overload-keyword ( seq -- seq' ) "overload" filter-by-keyword ;
+: filter-pack-tactics-keyword ( seq -- seq' ) "pack-tactics" filter-by-keyword ;
+: filter-paradox-keyword ( seq -- seq' ) "paradox" filter-by-keyword ;
+: filter-parley-keyword ( seq -- seq' ) "parley" filter-by-keyword ;
+: filter-partner-keyword ( seq -- seq' ) "partner" filter-by-keyword ;
+: filter-partner-with-keyword ( seq -- seq' ) "partner-with" filter-by-keyword ;
+: filter-persist-keyword ( seq -- seq' ) "persist" filter-by-keyword ;
+: filter-phasing-keyword ( seq -- seq' ) "phasing" filter-by-keyword ;
+: filter-plainscycling-keyword ( seq -- seq' ) "plainscycling" filter-by-keyword ;
+: filter-plot-keyword ( seq -- seq' ) "plot" filter-by-keyword ;
+: filter-populate-keyword ( seq -- seq' ) "populate" filter-by-keyword ;
+: filter-proliferate-keyword ( seq -- seq' ) "proliferate" filter-by-keyword ;
+: filter-protection-keyword ( seq -- seq' ) "protection" filter-by-keyword ;
+: filter-prototype-keyword ( seq -- seq' ) "prototype" filter-by-keyword ;
+: filter-provoke-keyword ( seq -- seq' ) "provoke" filter-by-keyword ;
+: filter-prowess-keyword ( seq -- seq' ) "prowess" filter-by-keyword ;
+: filter-prowl-keyword ( seq -- seq' ) "prowl" filter-by-keyword ;
+: filter-radiance-keyword ( seq -- seq' ) "radiance" filter-by-keyword ;
+: filter-raid-keyword ( seq -- seq' ) "raid" filter-by-keyword ;
+: filter-rally-keyword ( seq -- seq' ) "rally" filter-by-keyword ;
+: filter-rampage-keyword ( seq -- seq' ) "rampage" filter-by-keyword ;
+: filter-ravenous-keyword ( seq -- seq' ) "ravenous" filter-by-keyword ;
+: filter-reach-keyword ( seq -- seq' ) "reach" filter-by-keyword ;
+: filter-read-ahead-keyword ( seq -- seq' ) "read-ahead" filter-by-keyword ;
+: filter-rebound-keyword ( seq -- seq' ) "rebound" filter-by-keyword ;
+: filter-reconfigure-keyword ( seq -- seq' ) "reconfigure" filter-by-keyword ;
+: filter-recover-keyword ( seq -- seq' ) "recover" filter-by-keyword ;
+: filter-reinforce-keyword ( seq -- seq' ) "reinforce" filter-by-keyword ;
+: filter-renown-keyword ( seq -- seq' ) "renown" filter-by-keyword ;
+: filter-replicate-keyword ( seq -- seq' ) "replicate" filter-by-keyword ;
+: filter-retrace-keyword ( seq -- seq' ) "retrace" filter-by-keyword ;
+: filter-revolt-keyword ( seq -- seq' ) "revolt" filter-by-keyword ;
+: filter-riot-keyword ( seq -- seq' ) "riot" filter-by-keyword ;
+: filter-role-token-keyword ( seq -- seq' ) "role-token" filter-by-keyword ;
+: filter-saddle-keyword ( seq -- seq' ) "saddle" filter-by-keyword ;
+: filter-scavenge-keyword ( seq -- seq' ) "scavenge" filter-by-keyword ;
+: filter-scry-keyword ( seq -- seq' ) "scry" filter-by-keyword ;
+: filter-seek-keyword ( seq -- seq' ) "seek" filter-by-keyword ;
+: filter-shadow-keyword ( seq -- seq' ) "shadow" filter-by-keyword ;
+: filter-shroud-keyword ( seq -- seq' ) "shroud" filter-by-keyword ;
+: filter-skulk-keyword ( seq -- seq' ) "skulk" filter-by-keyword ;
+: filter-soulbond-keyword ( seq -- seq' ) "soulbond" filter-by-keyword ;
+: filter-soulshift-keyword ( seq -- seq' ) "soulshift" filter-by-keyword ;
+: filter-specialize-keyword ( seq -- seq' ) "specialize" filter-by-keyword ;
+: filter-spectacle-keyword ( seq -- seq' ) "spectacle" filter-by-keyword ;
+: filter-spell-mastery-keyword ( seq -- seq' ) "spell-mastery" filter-by-keyword ;
+: filter-splice-keyword ( seq -- seq' ) "splice" filter-by-keyword ;
+: filter-split-second-keyword ( seq -- seq' ) "split-second" filter-by-keyword ;
+: filter-spree-keyword ( seq -- seq' ) "spree" filter-by-keyword ;
+: filter-squad-keyword ( seq -- seq' ) "squad" filter-by-keyword ;
+: filter-storm-keyword ( seq -- seq' ) "storm" filter-by-keyword ;
+: filter-strive-keyword ( seq -- seq' ) "strive" filter-by-keyword ;
+: filter-sunburst-keyword ( seq -- seq' ) "sunburst" filter-by-keyword ;
+: filter-support-keyword ( seq -- seq' ) "support" filter-by-keyword ;
+: filter-surge-keyword ( seq -- seq' ) "surge" filter-by-keyword ;
+: filter-surveil-keyword ( seq -- seq' ) "surveil" filter-by-keyword ;
+: filter-suspect-keyword ( seq -- seq' ) "suspect" filter-by-keyword ;
+: filter-suspend-keyword ( seq -- seq' ) "suspend" filter-by-keyword ;
+: filter-swampcycling-keyword ( seq -- seq' ) "swampcycling" filter-by-keyword ;
+: filter-swampwalk-keyword ( seq -- seq' ) "swampwalk" filter-by-keyword ;
+: filter-threshold-keyword ( seq -- seq' ) "threshold" filter-by-keyword ;
+: filter-time-travel-keyword ( seq -- seq' ) "time-travel" filter-by-keyword ;
+: filter-totem-armor-keyword ( seq -- seq' ) "totem-armor" filter-by-keyword ;
+: filter-toxic-keyword ( seq -- seq' ) "toxic" filter-by-keyword ;
+: filter-training-keyword ( seq -- seq' ) "training" filter-by-keyword ;
+: filter-trample-keyword ( seq -- seq' ) "trample" filter-by-keyword ;
+: filter-transform-keyword ( seq -- seq' ) "transform" filter-by-keyword ;
+: filter-transmute-keyword ( seq -- seq' ) "transmute" filter-by-keyword ;
+: filter-treasure-keyword ( seq -- seq' ) "treasure" filter-by-keyword ;
+: filter-tribute-keyword ( seq -- seq' ) "tribute" filter-by-keyword ;
+: filter-typecycling-keyword ( seq -- seq' ) "typecycling" filter-by-keyword ;
+: filter-undergrowth-keyword ( seq -- seq' ) "undergrowth" filter-by-keyword ;
+: filter-undying-keyword ( seq -- seq' ) "undying" filter-by-keyword ;
+: filter-unearth-keyword ( seq -- seq' ) "unearth" filter-by-keyword ;
+: filter-unleash-keyword ( seq -- seq' ) "unleash" filter-by-keyword ;
+: filter-vanishing-keyword ( seq -- seq' ) "vanishing" filter-by-keyword ;
+: filter-venture-into-the-dungeon-keyword ( seq -- seq' ) "venture-into-the-dungeon" filter-by-keyword ;
+: filter-vigilance-keyword ( seq -- seq' ) "vigilance" filter-by-keyword ;
+: filter-ward-keyword ( seq -- seq' ) "ward" filter-by-keyword ;
+: filter-will-of-the-council-keyword ( seq -- seq' ) "will-of-the-council" filter-by-keyword ;
+: filter-wither-keyword ( seq -- seq' ) "wither" filter-by-keyword ;
+
 : power>n ( string -- n/f )
     [ "*" = ] [ drop -1 ] [ string>number ] ?if ;
 
@@ -734,10 +1214,10 @@ M: sequence deck-and-sideboard. deck. ;
     [
         {
             [ filter-instant ]
-            [ filter-flash ]
-            [ filter-cycling ]
-            [ filter-disguise ]
-            [ filter-madness ]
+            [ filter-flash-keyword ]
+            [ filter-cycling-keyword ]
+            [ filter-disguise-keyword ]
+            [ filter-madness-keyword ]
         } cleave
     ] { } append-outputs-as sort-by-colors ;
 
@@ -764,9 +1244,11 @@ MEMO: get-moxfield-deck ( public-id -- json )
     ] bi
     <moxfield-deck> ;
 
+: moxfield-decks-for-username ( username -- json )
+    get-moxfield-user "data" of ;
+
 : moxfield-random-deck-for-username ( username -- json )
-    get-moxfield-user
-    "data" of
+    moxfield-decks-for-username
     random "publicId" of get-moxfield-deck
     json>moxfield-deck ;
 
@@ -779,4 +1261,4 @@ MEMO: get-moxfield-deck ( public-id -- json )
     moxfield-latest-deck-for-username deck. ;
 
 : moxfield-latest-deck-and-sideboard-for-username. ( username -- )
-    moxfield-latest-deck-for-username deck-and-sideboard. ;
\ No newline at end of file
+    moxfield-latest-deck-for-username deck-and-sideboard. ;
diff --git a/extra/sequences/prefixed/authors.txt b/extra/sequences/prefixed/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/sequences/prefixed/prefixed-tests.factor b/extra/sequences/prefixed/prefixed-tests.factor
new file mode 100644 (file)
index 0000000..e36cedd
--- /dev/null
@@ -0,0 +1,4 @@
+USING: arrays sequences sequences.prefixed tools.test ;
+
+{ { 1 } } [ 1 f <prefixed> >array ] unit-test
+{ { 1 2 3 4 } } [ 1 { 2 3 4 } <prefixed> >array ] unit-test
diff --git a/extra/sequences/prefixed/prefixed.factor b/extra/sequences/prefixed/prefixed.factor
new file mode 100644 (file)
index 0000000..02417a1
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2024 John Benediktsson
+! See https://factorcode.org/license.txt for BSD license
+USING: accessors kernel math math.order sequences sequences.private ;
+IN: sequences.prefixed
+
+TUPLE: prefixed
+{ elt object read-only }
+{ seq sequence read-only } ;
+
+C: <prefixed> prefixed
+
+M: prefixed length seq>> length 1 + ;
+
+M: prefixed nth-unsafe
+    over zero? [ nip elt>> ] [ [ 1 - ] [ seq>> ] bi* nth-unsafe ] if ;
+
+INSTANCE: prefixed immutable-sequence
+
diff --git a/extra/sequences/prefixed/tags.txt b/extra/sequences/prefixed/tags.txt
new file mode 100644 (file)
index 0000000..b5e4471
--- /dev/null
@@ -0,0 +1,2 @@
+collections
+sequences
diff --git a/extra/sequences/suffixed/authors.txt b/extra/sequences/suffixed/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/sequences/suffixed/suffixed-tests.factor b/extra/sequences/suffixed/suffixed-tests.factor
new file mode 100644 (file)
index 0000000..2f169e3
--- /dev/null
@@ -0,0 +1,4 @@
+USING: arrays sequences sequences.suffixed tools.test ;
+
+{ { 1 } } [ f 1 <suffixed> >array ] unit-test
+{ { 1 2 3 4 } } [ { 1 2 3 } 4 <suffixed> >array ] unit-test
diff --git a/extra/sequences/suffixed/suffixed.factor b/extra/sequences/suffixed/suffixed.factor
new file mode 100644 (file)
index 0000000..f377f04
--- /dev/null
@@ -0,0 +1,19 @@
+! Copyright (C) 2024 John Benediktsson
+! See https://factorcode.org/license.txt for BSD license
+USING: accessors kernel math math.order sequences sequences.private ;
+IN: sequences.suffixed
+
+TUPLE: suffixed
+{ seq sequence read-only }
+{ elt object read-only } ;
+
+C: <suffixed> suffixed
+
+M: suffixed length seq>> length 1 + ;
+
+M: suffixed nth-unsafe
+    [ seq>> 2dup bounds-check? ] keep swap
+    [ drop nth-unsafe ] [ 2nip elt>> ] if ;
+
+INSTANCE: suffixed immutable-sequence
+
diff --git a/extra/sequences/suffixed/tags.txt b/extra/sequences/suffixed/tags.txt
new file mode 100644 (file)
index 0000000..b5e4471
--- /dev/null
@@ -0,0 +1,2 @@
+collections
+sequences
index c201906a5290ab846eb3bab6d4bbbaee3188e95c..61ba4cee47f4ad3899d6b3ef4ea5e17a18e355e8 100644 (file)
@@ -2,8 +2,8 @@
 ! See https://factorcode.org/license.txt for BSD license
 
 USING: accessors assocs base64 calendar calendar.format
-checksums.hmac checksums.sha combinators.smart formatting http
-http.client json kernel make math.parser namespaces random
+checksums.hmac checksums.sha combinators.smart formatting
+hex-strings http http.client json kernel make namespaces random
 sequences splitting ;
 
 IN: visionect
index 1901f27a24507e2512d93a1f956aaaa0d2f05714..129dcb4701859fb2e0bed96c57cada07e10b79d4 100644 (file)
@@ -1 +1,2 @@
 Slava Pestov
+nomennescio
index 3a7d24f6ee41a354a25af91c07726dce9ba58073..78ca1f2217eba35711aa59fbc950b06d57eaed2b 100644 (file)
@@ -47,6 +47,27 @@ builder "BUILDERS" {
     { "status" "STATUS" TEXT }
 } define-persistent
 
+TUPLE: run
+run-id timestamp host-name os cpu git-id ;
+
+run "RUNS" {
+    { "run-id" "RUN_ID" INTEGER +db-assigned-id+ }
+    { "timestamp" "TIMESTAMP" TIMESTAMP }
+    { "host-name" "HOST_NAME" TEXT }
+    { "os" "OS" TEXT }
+    { "cpu" "CPU" TEXT }
+    { "git-id" "GIT_ID" TEXT }
+} define-persistent
+
+TUPLE: benchmark
+run-id name duration ;
+
+benchmark "BENCHMARKS" {
+    { "run-id" "RUN_ID" INTEGER +user-assigned-id+ }
+    { "name" "NAME" TEXT +user-assigned-id+ }
+    { "duration" "DURATION_NANOSECONDS" UNSIGNED-BIG-INTEGER }
+} define-persistent
+
 TUPLE: counter id value ;
 
 counter "COUNTER" {
@@ -88,4 +109,4 @@ counter "COUNTER" {
     mason-db [ with-transaction ] with-db ; inline
 
 : init-mason-db ( -- )
-    { builder counter } ensure-tables ;
+    { builder counter run benchmark } ensure-tables ;
diff --git a/extra/webapps/mason/benchmarks/authors.txt b/extra/webapps/mason/benchmarks/authors.txt
new file mode 100644 (file)
index 0000000..94b9049
--- /dev/null
@@ -0,0 +1 @@
+nomennescio
diff --git a/extra/webapps/mason/benchmarks/benchmarks.factor b/extra/webapps/mason/benchmarks/benchmarks.factor
new file mode 100644 (file)
index 0000000..026e41b
--- /dev/null
@@ -0,0 +1,23 @@
+! Copyright (C) 2024 nomennescio.
+! See https://factorcode.org/license.txt for BSD license.
+USING: accessors assocs calendar calendar.format combinators
+db.tuples formatting furnace.actions html.forms
+http.server.responses io io.streams.string kernel math.parser
+sequences webapps.mason.backend webapps.mason.utils ;
+IN: webapps.mason.benchmarks
+
+: benchmark-results ( -- response )
+    [ selected-benchmarks ] with-mason-db
+    [
+        "run,timestamp (UTC),host,os,cpu,git,name,duration (ns)" print
+        '[
+            [ run-id>> ] [ name>> ] [ duration>> ] tri
+            [ _ at { [ run-id>> ] [ timestamp>> timestamp>iso8601Z ] [ host-name>> ] [ os>> ] [ cpu>> ] [ git-id>> ] } cleave ] 2dip
+            "%s,%s,%s,%s,%s,%s,%s,%s\n" printf
+        ] each
+    ] with-string-writer <text-content> ;
+
+: <benchmark-results-action> ( -- action )
+    <action>
+    [ validate-benchmark-selection ] >>init
+    [ benchmark-results ] >>display ;
index 72a686605d4dac2a43c0754cfced5c0d777eac78..d947b8a74bf4040bad474a99c9fa0327e4d577fd 100644 (file)
@@ -5,6 +5,9 @@
     <t:style t:include="resource:extra/webapps/mason/mason.css" />
     <div style="padding: 10px;">
        <h1>Build machines</h1>
+       <t:xml t:name="machines" />
+
+       <h1>Build targets</h1>
        <t:xml t:name="builders" />
 
        <h1>Force build now</h1>
index b0249421e0634a7678feecf5fadb5ec06475f468..0b7bc96a4bd3005f4b41a890b46d982e1ac174bd 100644 (file)
@@ -1,8 +1,10 @@
 ! Copyright (C) 2010 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel furnace.actions html.forms
-sequences sorting xml.syntax webapps.mason.backend
-webapps.mason.utils ;
+USING: accessors arrays calendar.format combinators
+combinators.extras furnace.actions grouping.extras html.forms
+kernel mason.report math.order sequences sorting
+sorting.specification webapps.mason.backend webapps.mason.utils
+xml.syntax ;
 IN: webapps.mason.downloads
 
 CONSTANT: OFFLINE
@@ -18,21 +20,48 @@ CONSTANT: BROKEN
         [ drop f ]
     } cond ;
 
+: machine-list ( builders -- xml )
+    { { host-name>> <=> } { os>> <=> } { cpu>> <=> } } sort-with-spec
+    [ host-name>> ] group-by
+    [
+        first2
+        [
+            [ os/cpu ] [ current-git-id>> git-short-link ] [ status>> ] tri
+            [XML <tr><td></td><td><-></td><td><-></td><td><-></td></tr> XML]
+        ] map
+        [XML <tr><td><i><-></i></td></tr><-> XML]
+    ] map
+    [ [XML <p>No machines.</p> XML] ]
+    [ [XML <table><tr>
+           <th align="left">Machine</th>
+           <th align="left">Target</th>
+           <th align="left">Git</th>
+           <th align="left">Status</th>
+           </tr>
+           <tr><td></td><td></td><td></td><td><i>starting/make-vm/boot/test/upload/finish/idle</i></td></tr>
+           <-></table> XML] ]
+    if-empty ;
+
 : builder-list ( seq -- xml )
     [ os/cpu ] sort-by
     [
-        [ report-url ] [ os/cpu ] [ builder-status ] tri
-        [XML <li><a href=<->><-></a> <-></li> XML]
+        [ os/cpu ] [ report-url ] [ current-timestamp>> timestamp>ymdhms ] [ builder-status ] quad
+        [XML <tr><td><-></td><td><a href=<->><-></a></td><td><-></td></tr> XML]
     ] map
     [ [XML <p>No machines.</p> XML] ]
-    [ [XML <ul><-></ul> XML] ]
+    [ [XML <table><tr>
+           <th align="left">Target</th>
+           <th align="left">Build report</th>
+           <th align="left">Build status</th>
+           </tr><-></table> XML] ]
     if-empty ;
 
 : <dashboard-action> ( -- action )
     <page-action>
     [
         [
-            all-builders builder-list
-            "builders" set-value
+            all-builders
+            [ machine-list "machines" set-value ]
+            [ builder-list "builders" set-value ] bi
         ] with-mason-db
     ] >>init ;
index 5c9b2972e516e9153ee68cf579d4ee49c9efb79c..afaa8b6b1beee377b8be0715f6012105b4ab629e 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors furnace.actions furnace.auth furnace.db
 furnace.redirection http.server.dispatchers urls
 webapps.mason.backend webapps.mason.grids webapps.mason.package
-webapps.mason.release webapps.mason.report
+webapps.mason.release webapps.mason.report webapps.mason.benchmarks
 webapps.mason.downloads webapps.mason.counter
 webapps.mason.status-update webapps.mason.docs-update
 webapps.mason.dashboard webapps.mason.make-release
@@ -26,6 +26,9 @@ build-engineer? define-capability
     <build-report-action>
         "report" add-responder
 
+    <benchmark-results-action>
+        "benchmark-results" add-responder
+
     <download-package-action>
         { mason-app "download-package" } >>template
         "package" add-responder
index 5d259a3a0e5263280f95eaeec69dd2256c84cf43..f31c46c8d9825abf6543e7d982a46bca4f5a9a06 100644 (file)
@@ -1,8 +1,10 @@
 ! Copyright (C) 2010 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors calendar combinators db.tuples furnace.actions
-furnace.redirection html.forms http.server.responses io kernel
-namespaces validators webapps.mason.utils webapps.mason.backend ;
+USING: accessors assocs calendar combinators db.tuples
+furnace.actions furnace.redirection html.forms
+http.server.responses io kernel multiline namespaces parser
+prettyprint sequences splitting validators webapps.mason.backend
+webapps.mason.utils ;
 IN: webapps.mason.status-update
 
 : find-builder ( host-name os cpu -- builder )
@@ -12,6 +14,19 @@ IN: webapps.mason.status-update
         swap >>host-name
     [ select-tuple ] [ dup insert-tuple ] ?unless ;
 
+: update-runs ( builder -- run-id )
+    [ run new ] dip
+    { [ host-name>> >>host-name ]
+      [ os>> >>os ]
+      [ cpu>> >>cpu ]
+      [ current-timestamp>> >>timestamp ]
+      [ current-git-id>> >>git-id ] } cleave
+    dup insert-tuple run-id>> ;
+
+: update-benchmarks ( run-id benchmarks -- )
+    [ benchmark new swap >>run-id ] dip
+    [ first2 [ >>name ] dip >>duration insert-tuple ] with each ;
+
 : heartbeat ( builder -- )
     now >>heartbeat-timestamp
     drop ;
@@ -31,6 +46,10 @@ IN: webapps.mason.status-update
 
 : test ( builder -- ) +test+ status ;
 
+: benchmarks ( builder content -- )
+    [ update-runs ] dip
+    split-lines parse-fresh first update-benchmarks ;
+
 : report ( builder content status -- )
     [
         >>last-report
@@ -62,6 +81,7 @@ IN: webapps.mason.status-update
         { "boot" [ boot ] }
         { "test" [ test ] }
         { "report" [ "report" value "arg" value report ] }
+        { "benchmarks" [ "report" value benchmarks ] }
         { "upload" [ upload ] }
         { "finish" [ finish ] }
         { "release" [ "arg" value release ] }
index 3213d09573fc7362caf23b7a9fb3059d162f08c8..5598a0ab9c3179cbef873f9a53561c24c25134bb 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2010 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs db.tuples furnace.actions
-furnace.utilities html.forms kernel mason.config namespaces
+USING: accessors arrays assocs calendar calendar.format
+db.tuples furnace.actions furnace.utilities html.forms
+io.streams.string kernel mason.config math.parser namespaces
 sequences urls validators webapps.mason.backend
 webapps.mason.version.data xml.syntax ;
 IN: webapps.mason.utils
@@ -9,12 +10,43 @@ IN: webapps.mason.utils
 : link ( url label -- xml )
     [XML <a href=<->><-></a> XML] ;
 
+: timestamp>iso8601Z ( timestamp -- string )
+    [ >utc { YYYY MM DD "T" hhmm ss "Z" } formatted ] with-string-writer ;
+
 : validate-os/cpu ( -- )
     {
         { "os" [ v-one-line ] }
         { "cpu" [ v-one-line ] }
     } validate-params ;
 
+: validate-benchmark-selection ( -- )
+    {
+        { "host" [ [ v-one-line ] v-optional ] }
+        { "os" [ [ v-one-line ] v-optional ] }
+        { "cpu" [ [ v-one-line ] v-optional ] }
+        { "git" [ [ v-one-line ] v-optional ] }
+        { "run" [ [ v-one-line ] v-optional ] }
+        ! { "timestamp" [ [ v-one-line ] v-optional ] } ! parsing of ISO8601 is currently not supported
+        { "name" [ [ v-one-line ] v-optional ] }
+    } validate-params ;
+
+: selected-runs ( -- runs )
+    run new
+    "run" value dec> >>run-id
+    ! "timestamp" value >>timestamp ! parsing of ISO8601 is currently not supported
+    "host" value >>host-name
+    "os" value >>os
+    "cpu" value >>cpu
+    "git" value >>git-id
+    select-tuples ;
+
+: selected-benchmarks ( -- benchmarks runs )
+    selected-runs [ [ run-id>> ] keep ] map>alist
+    [
+        keys [ V{ } clone benchmark new "name" value >>name ] dip
+        [ >>run-id select-tuples append! ] with each
+    ] keep ;
+
 : current-builder ( -- builder/f )
     builder new "os" value >>os "cpu" value >>cpu select-tuple ;
 
index 86529461f7d99c0f7e3895366006deae1cc377a2..1ce494613ba262028a1448fdd675c2c5004feb91 100644 (file)
@@ -2,11 +2,11 @@
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs bootstrap.image calendar cli.git
 combinators combinators.short-circuit concurrency.combinators
-environment formatting http.download io io.directories
-io.launcher io.pathnames kernel math.parser memory modern.paths
-namespaces parser.notes prettyprint regexp.classes sequences
-sequences.extras sets splitting system system-info threads
-tools.test tools.test.private vocabs vocabs.hierarchy
+environment formatting hex-strings http.download io
+io.directories io.launcher io.pathnames kernel math.parser
+memory modern.paths namespaces parser.notes prettyprint
+sequences sequences.extras sets splitting system system-info
+threads tools.test tools.test.private vocabs vocabs.hierarchy
 vocabs.hierarchy.private vocabs.loader vocabs.metadata zealot ;
 IN: zealot.factor
 
index 5e1542631485f568dcd1eff7d48baefff0bacd04..8de828726a72807d3225511fa8e9de3a1438904e 100644 (file)
@@ -2,8 +2,8 @@
 ! See https://factorcode.org/license.txt for BSD license
 
 USING: accessors combinators command-line destructors formatting
-io io.directories io.encodings io.encodings.binary io.files
-kernel math math.parser namespaces sequences uuid zim ;
+hex-strings io io.directories io.encodings io.encodings.binary
+io.files kernel math namespaces sequences uuid zim ;
 
 IN: zim.tools
 
index 6ee84a8e87e2f4087e24c4a918ec1321c544f2e6..dd9b9af5da668727aa7bd327d1777dc0659e8da9 100644 (file)
@@ -1,4 +1,4 @@
 include vm/Config.unix
-PLAF_DLL_OBJS += vm/os-genunix.o vm/os-freebsd.o vm/mvm-unix.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-genunix.o $(BUILD_DIR)/os-freebsd.o $(BUILD_DIR)/mvm-unix.o
 PLAF_MASTER_HEADERS += vm/os-genunix.hpp vm/os-freebsd.hpp
 LIBS = -L/usr/local/lib -lm $(X11_UI_LIBS) -pthread -lc -Wl,--export-dynamic -lthr -lpango-1.0 -lpangocairo-1.0 -lcairo -lglib-2.0 -lgobject-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lgtkglext-x11-1.0 -latk-1.0 -lgio-2.0 -lgdkglext-x11-1.0 -lGL
index 6cdc02942e3c68c6467691a34b9a4a9d74448cfa..4c71af2da51adbab19609222adcf5d72d61c39ed 100644 (file)
@@ -1,5 +1,5 @@
 include vm/Config.unix
-PLAF_DLL_OBJS += vm/os-genunix.o vm/os-linux.o vm/mvm-unix.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-genunix.o $(BUILD_DIR)/os-linux.o $(BUILD_DIR)/mvm-unix.o
 PLAF_MASTER_HEADERS += vm/os-genunix.hpp vm/os-linux.hpp
 LIBS = -ldl -lm -lrt -lpthread -Wl,--export-dynamic
 
index e6f24274eb4936bb3eea10d93dd510fd7d5a1303..3438aa435120010262c4e2e8404c887af19db569 100644 (file)
@@ -1,4 +1,4 @@
 include vm/Config.linux
 include vm/Config.arm
-PLAF_DLL_OBJS += vm/os-linux-arm.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-linux-arm.o
 PLAF_MASTER_HEADERS += vm/os-linux-arm.hpp
index 1677219341a846ae6606564cc0c8c654074f7497..f9a1719af546f181a47c57ea86d11be46e285d39 100644 (file)
@@ -1,4 +1,4 @@
 include vm/Config.linux
 include vm/Config.arm
-PLAF_DLL_OBJS += vm/cpu-arm.32.o
-PLAF_MASTER_HEADERS += vm/cpu-arm.32.hpp
\ No newline at end of file
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-arm.32.o
+PLAF_MASTER_HEADERS += $(BUILD_DIR)/cpu-arm.32.hpp
\ No newline at end of file
index d29c988fee1f9fa390d15eb89b53267a76cb4aa4..80c3712c2d8f3b000dfa7c25fcba5a7b71a106d9 100644 (file)
@@ -1,4 +1,4 @@
 include vm/Config.linux
 include vm/Config.arm
-PLAF_DLL_OBJS += vm/cpu-arm.64.o
-PLAF_MASTER_HEADERS += vm/cpu-arm.64.hpp
\ No newline at end of file
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-arm.64.o
+PLAF_MASTER_HEADERS += $(BUILD_DIR)/cpu-arm.64.hpp
\ No newline at end of file
index 693663de9b2dbfbac2a48383dc5aa374e3f032e5..d3bc8ebf01b605bab3bd7a5c525d98b0b849275a 100644 (file)
@@ -1,3 +1,3 @@
 include vm/Config.linux
-PLAF_DLL_OBJS += vm/cpu-ppc.linux.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-ppc.linux.o
 SITE_CFLAGS += -m32
index d910060ecba7658c855a0f92031b13544c241f01..a33ce7a1309dc9e3226d45eb24b8bdc88df5222c 100644 (file)
@@ -1,3 +1,3 @@
 include vm/Config.linux
-PLAF_DLL_OBJS += vm/cpu-ppc.linux.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-ppc.linux.o
 SITE_CFLAGS += -m64
index ab2cfbe76e1957224d66bc0df4c623044a1620de..1ef92880ecac43fa2d30a26a4194c33e044f5da8 100644 (file)
@@ -1,6 +1,6 @@
 include vm/Config.unix
 
-PLAF_DLL_OBJS += vm/os-macosx.o vm/mach_signal.o vm/mvm-unix.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-macosx.o $(BUILD_DIR)/mach_signal.o $(BUILD_DIR)/mvm-unix.o
 PLAF_MASTER_HEADERS += vm/os-macosx.hpp vm/mach_signal.hpp
 
 DLL_EXTENSION = .dylib
@@ -14,7 +14,7 @@ else
        LIBS = -lm -framework Cocoa -framework AppKit
 endif
 
-LINKER = $(CXX) $(CFLAGS) $(CXXFLAGS) $(SHARED_FLAG) -single_module \
+LINKER = $(CXX) $(CFLAGS) $(CXXFLAGS) $(SHARED_FLAG) \
        -current_version $(VERSION) \
        -compatibility_version $(VERSION) \
        -fvisibility=hidden \
index e667dc61d8eafa9f5e25f6fbcc96a9c3dc2ce1b2..1eac8140b878eef5ab6697480549addbe6314b9b 100644 (file)
@@ -8,8 +8,8 @@ DLL_EXTENSION = .a
 SHARED_DLL_EXTENSION = .so
 SHARED_FLAG = -shared
 
-PLAF_DLL_OBJS += vm/os-unix.o
-PLAF_EXE_OBJS += vm/main-unix.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-unix.o
+PLAF_EXE_OBJS += $(BUILD_DIR)/main-unix.o
 PLAF_MASTER_HEADERS += vm/os-unix.hpp vm/atomic-gcc.hpp vm/atomic.hpp
 
 FFI_TEST_CFLAGS = -fPIC
index 3dd37e99fbc4630a63422768aabd5e45370a69c3..4df270e1c426d0f44c8d0d972d42169e0829fc0e 100644 (file)
@@ -5,8 +5,8 @@ SHARED_DLL_EXTENSION=.dll
 
 LIBS = -lm
 
-PLAF_DLL_OBJS += vm/os-windows.o vm/mvm-windows.o
-PLAF_EXE_OBJS += vm/resources.o vm/main-windows.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-windows.o $(BUILD_DIR)/mvm-windows.o
+PLAF_EXE_OBJS += $(BUILD_DIR)/resources.o $(BUILD_DIR)/main-windows.o
 PLAF_MASTER_HEADERS += vm/os-windows.hpp
 
 EXE_SUFFIX=
index edacb3492ff6d59bd37709d33605ba41b81f106f..b35797f014a1d2689e34422e514a06fa944387e9 100644 (file)
@@ -1,4 +1,4 @@
-PLAF_DLL_OBJS += vm/os-windows-x86.32.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-windows-x86.32.o
 PLAF_MASTER_HEADERS += vm/os-windows.32.hpp vm/atomic-cl-32.hpp vm/atomic.hpp
 DLL_PATH=http://factorcode.org/dlls/32
 WINDRES=windres -F pe-i386
index ade7071c9ec6b2d07ab40c612df37cb2c6c8da63..a10bcb8ac83fd6adf2aa1de1fd1cf27c1d22a127 100644 (file)
@@ -1,4 +1,4 @@
-PLAF_DLL_OBJS += vm/os-windows-x86.64.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/os-windows-x86.64.o
 PLAF_MASTER_HEADERS += vm/os-windows.64.hpp vm/atomic-cl-64.hpp vm/atomic.hpp
 DLL_PATH=http://factorcode.org/dlls/64
 CC=$(WIN64_PATH)-gcc.exe
index 2a55336d566c79209f34afe8fc1871d24024a487..5442a29ae1146e99725c63e172127dd5b61d9b4e 100644 (file)
@@ -1,3 +1,3 @@
-PLAF_DLL_OBJS += vm/cpu-x86.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-x86.o
 PLAF_MASTER_HEADERS += vm/cpu-x86.hpp
 SITE_CFLAGS += -m32
index ce60ae1948220466bf27cf0b36845e1245ed9347..d7e8fb96246a00de423c247f8c67ee65717169cc 100644 (file)
@@ -1,3 +1,3 @@
-PLAF_DLL_OBJS += vm/cpu-x86.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-x86.o
 PLAF_MASTER_HEADERS += vm/cpu-x86.hpp
 SITE_CFLAGS += -m64
index 7bc404084acce229bff266bd387bdde0dc5b8349..5707ac4c8cae409a977a4567717ecca0012ad78b 100644 (file)
@@ -1,3 +1,3 @@
-PLAF_DLL_OBJS += vm/cpu-x86.o
+PLAF_DLL_OBJS += $(BUILD_DIR)/cpu-x86.o
 PLAF_MASTER_HEADERS += vm/cpu-x86.hpp
 
index ed1bbfaa6220075c9aab2a163e8fcdbf9669d1b2..990093291685f5da3ca5d43a8de683819e5de671 100644 (file)
@@ -193,6 +193,8 @@ void factor_vm::bignum_divide(bignum* numerator, bignum* denominator,
                               bignum** quotient, bignum** remainder) {
   if (BIGNUM_ZERO_P(denominator)) {
     divide_by_zero_error();
+    (*quotient) = denominator;
+    (*remainder) = denominator;
     return;
   }
   if (BIGNUM_ZERO_P(numerator)) {
index cfa8e8c52cd181475505b3aee633d975967417d7..aa7ecc55b1d13c8a91b70185d18733b62114a0f0 100644 (file)
@@ -1,6 +1,6 @@
 namespace factor {
 
-#define CALLSTACK_BOTTOM(ctx) (ctx->callstack_seg->end - sizeof(cell) * 5) // omg
+#define CALLSTACK_BOTTOM(ctx) (ctx->callstack_seg->end - sizeof(cell) * 6) // omg
 
 // void c_to_factor(cell quot);
 // void lazy_jit_compile(cell quot);
index 41056ab29cf0054145260f75593f11731d0d0636..070d8e9bca9b4325755e0a3749f86f78c8bbf322 100644 (file)
@@ -74,6 +74,10 @@ fixnum instruction_operand::load_value(cell relative_to) {
     case RC_RELATIVE_ARM64_BCOND:
       return load_value_masked(rel_relative_arm64_bcond_mask, 3, 11, 0) +
              relative_to;
+    case RC_ABSOLUTE_ARM64_MOVZ:
+      return load_value_masked(rel_absolute_arm64_movz_mask, 5, 16, 0);
+    case RC_RELATIVE_CELL:
+      return *(cell*)(pointer - sizeof(cell));
     default:
       critical_error("Bad rel class", rel.klass());
       return 0;
@@ -159,6 +163,12 @@ void instruction_operand::store_value(fixnum absolute_value) {
     case RC_RELATIVE_ARM64_BCOND:
       store_value_masked(relative_value, rel_relative_arm64_bcond_mask, 2, 5);
       break;
+    case RC_ABSOLUTE_ARM64_MOVZ:
+      store_value_masked(absolute_value, rel_absolute_arm64_movz_mask, 0, 5);
+      break;
+    case RC_RELATIVE_CELL:
+      *(cell*)(pointer - sizeof(cell)) = relative_value;
+      break;
     default:
       critical_error("Bad rel class", rel.klass());
       break;
index 72ea3df40ac217603d45186d153c0e25bcbd05c9..fa7168de2f4a822ef71fde89f2429a58063d8df0 100644 (file)
@@ -62,10 +62,14 @@ enum relocation_class {
   RC_ABSOLUTE_1,
   // absolute address in a PowerPC LIS/ORI/SLDI/ORIS/ORI sequence
   RC_ABSOLUTE_PPC_2_2_2_2,
-  // relative address in an ARM64 B/BL instruction
+  // Relative address stored, divided by four, in bits 25:0 of an ARM64 instruction
   RC_RELATIVE_ARM64_BRANCH,
-  // relative address in an ARM64 B.cond instruction
+  // Relative address stored, divided by four, in bits 23:5 of an ARM64 instruction
   RC_RELATIVE_ARM64_BCOND,
+  // Absolute address stored in bits 20:5 of an ARM64 instruction
+  RC_ABSOLUTE_ARM64_MOVZ,
+  // relative address in a pointer-width location
+  RC_RELATIVE_CELL,
 };
 
 static const cell rel_absolute_ppc_2_mask = 0x0000ffff;
@@ -75,6 +79,7 @@ static const cell rel_indirect_arm_mask = 0x00000fff;
 static const cell rel_relative_arm_3_mask = 0x00ffffff;
 static const cell rel_relative_arm64_branch_mask = 0x03ffffff;
 static const cell rel_relative_arm64_bcond_mask = 0x00ffffe0;
+static const cell rel_absolute_arm64_movz_mask = 0x001fffe0;
 
 // code relocation table consists of a table of entries for each fixup
 struct relocation_entry {
index 39a6c388575c6af1286e039510fbdc0c0230e924..8e14b48ab23aa255dc7eea20d22ebd7e9d300887 100644 (file)
@@ -5,7 +5,7 @@
 namespace factor {
 
 #define CALLSTACK_BOTTOM(ctx) \
-  (ctx->callstack_seg->end - sizeof(cell) * 5)
+  (ctx->callstack_seg->end - sizeof(cell) * 6)
 
 static const fixnum xt_tail_pic_offset = 4 + 1;
 
index 13ef08c17eab9af6aeb9fad875612968ca64bd85..66ee290e78f847770ed29c135beb0b7957afec65 100644 (file)
@@ -3,25 +3,25 @@
 namespace factor {
 
 void flush_icache(cell start, cell len) {
-  int result;
+//   int result;
 
-  // XXX: why doesn't this work on Nokia n800? It should behave
-  //      identically to the below assembly.
-  // result = syscall(__ARM_NR_cacheflush,start,start + len,0);
+//   // XXX: why doesn't this work on Nokia n800? It should behave
+//   //      identically to the below assembly.
+//   // result = syscall(__ARM_NR_cacheflush,start,start + len,0);
 
-  // Assembly swiped from
-  // http://lists.arm.linux.org.uk/pipermail/linux-arm/2002-July/003931.html
-  __asm__ __volatile__("mov     r0, %1\n"
-                       "sub     r1, %2, #1\n"
-                       "mov     r2, #0\n"
-                       "swi     " __sys1(__ARM_NR_cacheflush) "\n"
-                                                              "mov     %0, r0\n"
-                       : "=r"(result)
-                       : "r"(start), "r"(start + len)
-                       : "r0", "r1", "r2");
+//   // Assembly swiped from
+//   // http://lists.arm.linux.org.uk/pipermail/linux-arm/2002-July/003931.html
+//   __asm__ __volatile__("mov     r0, %1\n"
+//                        "sub     r1, %2, #1\n"
+//                        "mov     r2, #0\n"
+//                        "swi     " __sys1(__ARM_NR_cacheflush) "\n"
+//                                                               "mov     %0, r0\n"
+//                        : "=r"(result)
+//                        : "r"(start), "r"(start + len)
+//                        : "r0", "r1", "r2");
 
-  if (result < 0)
-    critical_error("flush_icache() failed", result);
+//   if (result < 0)
+//     critical_error("flush_icache() failed", result);
 }
 
 }