about summary refs log tree commit diff
path: root/transform.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-23 03:14:24 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-23 03:16:26 -0700
commitf5ac975b7f4f1931a687f4c60d008498f798128b (patch)
tree9df5768ba5c103af543e412136625e6ea1c03fd3 /transform.e
parentd5030a4cf75b3600c957b0d48e0e68946367e919 (diff)
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
Diffstat (limited to 'transform.e')
-rw-r--r--transform.e29
1 files changed, 29 insertions, 0 deletions
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.