summary refs log tree commit diff
path: root/input.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-05-22 05:32:50 -0700
committerIrene Knapp <ireneista@irenes.space>2026-05-22 05:34:11 -0700
commit02a165b1e5ce2960207976e0c27b568ab2d33f8d (patch)
tree008c533f786953c99d9a3e0700c4dd5430dd34b3 /input.e
parent3f3bda4692b4017c7ad6ed1c434313b9dcc62cfb (diff)
de-branch'd all the internals
so it's all just high-level flow control now, which makes it load in itself

the output isn't identical on the first self-compilation, but it converges on the second

with this, it is officially self-hosting. WOW.

Force-Push: yes
Change-Id: Ic14de1dae209b200cada269b07c3826c86fa494f
Diffstat (limited to 'input.e')
-rw-r--r--input.e60
1 files changed, 30 insertions, 30 deletions
diff --git a/input.e b/input.e
index 8203673..dd1da1c 100644
--- a/input.e
+++ b/input.e
@@ -97,7 +97,7 @@
 ~ (metadata pointer --)
 : consume-from
   ~ If the length is zero, exit without doing anything.
-  dup buffer-logical-length @ 0 = 0branch [ 2 8 * , ] exit
+  dup buffer-logical-length @ 0 = { exit } if
 
   ~ Decrement the logical length. We do this now to get it over with, since
   ~ adjusting the start pointer is more complex.
@@ -116,13 +116,13 @@
   ~ Check whether the updated start is equal to the physical end.
   dup 4 roll =
   ~ (metadata pointer, updated start, updated start, physical end)
-  0branch [ 5 8 * , ]
-
-  ~ If the logical start pointer is now equal to the physical end pointer,
-  ~ we want to wrap to the physical start. That's what makes it a circular
-  ~ buffer.
-  ~ (metadata pointer, updated start)
-  drop dup buffer-physical-start @
+  {
+    ~ If the logical start pointer is now equal to the physical end pointer,
+    ~ we want to wrap to the physical start. That's what makes it a circular
+    ~ buffer.
+    ~ (metadata pointer, updated start)
+    drop dup buffer-physical-start @
+  } if
 
   ~ However we got here, save the updated logical start pointer.
   ~ (metadata pointer, updated start)
@@ -131,28 +131,28 @@
 
 ~ (metadata pointer -- byte or 0)
 : peek-from
-  dup buffer-logical-length @ 0 = 0branch [ 28 8 * , ]
-
-  ~ If the length is zero, there is no input, but we can still try calling
-  ~ the "refill" word.
-  ~ (metadata pointer)
-  dup input-buffer-refill @ dup 0branch [ 17 8 * , ]
-
-  ~ If the refill word is nonzero, call it. It expects a copy of the metadata
-  ~ pointer as its parameter, so set that up.
-  ~ (metadata pointer, refill word)
-  swap dup 3roll execute
-  ~ (metadata pointer)
-  ~ Now we check if the length is still zero.
-  dup buffer-logical-length @ 0 = 0branch [ 10 8 * , ]
-
-  ~ The length is zero even after calling the refill word, so return null.
-  ~ (metadata pointer)
-  drop 0 exit
-
-  ~ If the refill word is zero, we can't help, just return null.
-  ~ (metadata pointer, refill word)
-  drop drop 0 exit
+  dup buffer-logical-length @ {
+    ~ If the length is zero, there is no input, but we can still try calling
+    ~ the "refill" word.
+    ~ (metadata pointer)
+    dup input-buffer-refill @ dup {
+      ~ If the refill word is zero, we can't help, just return null.
+      ~ (metadata pointer, refill word)
+      drop drop 0 exit
+    } unless
+
+    ~ If the refill word is nonzero, call it. It expects a copy of the metadata
+    ~ pointer as its parameter, so set that up.
+    ~ (metadata pointer, refill word)
+    swap dup 3roll execute
+    ~ (metadata pointer)
+    ~ Now we check if the length is still zero.
+    dup buffer-logical-length @ {
+      ~ The length is zero even after calling the refill word, so return null.
+      ~ (metadata pointer)
+      drop 0 exit
+    } unless
+  } unless
 
   ~   The buffer is non-empty, so read a byte from it. We might have reached
   ~ this point either from the original check, or from the second check after