From f5ac975b7f4f1931a687f4c60d008498f798128b Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Wed, 23 Sep 2026 03:14:24 -0700 Subject: use file calls to read source during compilation as a result of this, the massive invocations to compile things are now shorter not all the way shorter, but significantly shorter :) because of where these changes are, this doesn't change the binary at all, so no new evoke.hex is needed (yay!) Force-Push: yes Change-Id: I35dfd065b2a4fc4bf1b80f402a07088efca43676 --- README.txt | 4 ++-- evoke.e | 30 ++++++++++++++++++++++++++++-- transform.e | 29 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/README.txt b/README.txt index 54c2a2c..d07a5a4 100644 --- a/README.txt +++ b/README.txt @@ -264,7 +264,7 @@ built-in library. the compiler. When you have a change you want to try it out, you can use your existing copy of Evocation to compile a new one, like this: - $ (cat labels.e elf.e transform.e execution.e; echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl swap 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e ; echo pyrzqxgl; cat evoke.e) | ./evoke > evoke2 + $ cat labels.e elf.e transform.e execution.e evoke.e | ./evoke > evoke2 $ chmod 755 evoke2 You can then run ./evoke2 and try out the new features you added. Fun, @@ -343,7 +343,7 @@ can be metacircular while you're metacircular.) also works on Forth programs, including Evocation itself. To produce the hex-dump version of Evocation, do: - $ (cat labels.e elf.e transform.e; echo 's" xyzzy" allocate-string dup 1048576 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e labels.e elf.e transform.e execution.e; echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer '; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl swap 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e; echo pyrzqxgl; cat evoke.e; echo 'xyzzy s" evoke-source" variable 1024 1024 4 * * allocate s" evoke-binary" variable 1024 1024 4 * * allocate s" evoke-metadata" variable evoke-metadata evoke-binary dup evoke-source 5 roll hex-transform bye ' ) | ./evoke > evoke.hex + $ (cat labels.e elf.e transform.e; echo 's" xyzzy" allocate-string dup 1048576 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e labels.e elf.e transform.e execution.e evoke.e; echo 'xyzzy s" evoke-source" variable 1024 1024 4 * * allocate s" evoke-binary" variable 1024 1024 4 * * allocate s" evoke-metadata" variable evoke-metadata evoke-binary dup evoke-source 5 roll hex-transform bye ' ) | ./evoke > evoke.hex It should run to completion, producing output in evoke.hex. Passing evoke.hex through ./hex will give a binary that's byte-for-byte identical to diff --git a/evoke.e b/evoke.e index 8c41ace..9a12075 100644 --- a/evoke.e +++ b/evoke.e @@ -8,8 +8,34 @@ ~ cat evoke.e) \ ~ | ./quine > evoke && chmod 755 evoke && ./evoke -s" source-to-copy-to-log" variable -s" source-to-precompile" variable +: read-inputs + here @ dup + s" core.e" pack-file-contents + s" linux.e" pack-file-contents + s" output.e" pack-file-contents + s" amd64.e" pack-file-contents + s" execution-support.e" pack-file-contents + s" log-load.e" pack-file-contents + s" pyrzqxgl" packstring + 0 pack8 8 packalign here ! + s" source-to-precompile" variable + + here @ dup + s" core.e" pack-file-contents + s" linux.e" pack-file-contents + s" output.e" pack-file-contents + s" amd64.e" pack-file-contents + s" execution-support.e" pack-file-contents + s" log-load.e" pack-file-contents + s" dynamic.e" pack-file-contents + s" input.e" pack-file-contents + s" interpret.e" pack-file-contents + s" flow-control.e" pack-file-contents + s" linux-dynamic.e" pack-file-contents + s" pyrzqxgl" packstring + 0 pack8 8 packalign here ! + s" source-to-copy-to-log" variable ; +read-inputs ~ (output memory start, current output point diff --git a/transform.e b/transform.e index 26ee650..e184c7e 100644 --- a/transform.e +++ b/transform.e @@ -259,6 +259,35 @@ 3roll pack8 } if-else } if-else } forever ; +~ (output point, filename -- output point) +: pack-file-contents + dup 0 0 sys-open + ~ (output point, filename, open result code or file descriptor) + dup 0 > { + ." Couldn't open " swap emitstring space + ." because " space . ." ." newline + 2 ndrop exit + } if + + ~ (output point, filename, file descriptor) + { + dup 3 pick 1024 sys-read + ~ (output point, filename, file descriptor, read result code or length) + + dup 0 > { + ." Error while reading from " 3roll emitstring + ." because " space . ." ." newline + drop exit + } if + + dup 0 = { + 3 ndrop exit + } if + + 4 roll + 3unroll + } forever ; + + ~ In logical terms, this modifies an input buffer metadata structure ~ in-place to push a new, zeroed one into the start of the linked list formed ~ through the next-source field. -- cgit 1.4.1