summary refs log tree commit diff
path: root/labels.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-05-16 00:43:24 -0700
committerIrene Knapp <ireneista@irenes.space>2026-05-16 00:43:24 -0700
commit9922f43d213bb2f710f90cb5165a7580ef0326cd (patch)
tree8efe744025fb1673fa506293f385e96f12d7fb8d /labels.e
parent09ae826c2f99b7e21606e01f577b934c1d669bdc (diff)
it's much closer, most of the labels work correctly now
Force-Push: yes
Change-Id: I45662e60c0035758a2cd57d971031eb0562eccb7
Diffstat (limited to 'labels.e')
-rw-r--r--labels.e20
1 files changed, 16 insertions, 4 deletions
diff --git a/labels.e b/labels.e
index c437003..4e315f7 100644
--- a/labels.e
+++ b/labels.e
@@ -106,9 +106,20 @@
   labels oldest-entry-in { dup }
   { dup label-heading labels next-newer-entry-in } while drop ;
 
+~   This looks up a label by name if it exists, or returns 0 if it doesn't.
+~ The return value if it's found is an entry pointer.
+~
+~   Keep in mind that this is a pointer to the entry in the label dictionary,
+~ not the label's value. It's common for a label's value to itself be a
+~ pointer to a dictionary entry, in the program being compiled, so it's easy
+~ to confuse that.
+~
+~ (name string pointer -- label entry pointer)
+: find-label labels swap find-in ;
+
 ~   This creates a new label given a name for it, initializing its value and
-~ status to zero and adding it to the dictionary. This is responsible for the
-~ initial guess of zero on the first pass.
+~ status to zero and adding it to the label dictionary. This is responsible
+~ for the initial guess of zero on the first pass.
 ~
 ~ (name string pointer -- )
 : new-label labels create-in 0 , 0 , ;
@@ -122,9 +133,9 @@
 ~ Either way, it returns an entry pointer. It's named after the function
 ~ "intern" that many Lisp dialects have.
 ~
-~ (name string pointer -- entry pointer)
+~ (name string pointer -- label entry pointer)
 : intern-label
-  dup labels swap find-in
+  dup find-label
   dup { swap drop }
       { drop dup new-label labels swap find-in } if-else ;
 
@@ -279,6 +290,7 @@
   ~ (iteration count, execution token, output start, output point)
   { 3 pick 100 > }
   { 2 pick execute 4 roll 1+ 4 unroll
+
     check-labels-converged
     { 4 roll drop
       3 roll drop