summary refs log tree commit diff
path: root/log-load.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-05-17 17:29:09 -0700
committerIrene Knapp <ireneista@irenes.space>2026-05-17 17:29:09 -0700
commit3b41dbfa2338c11dd8398026c00922f20f32dc81 (patch)
tree1761f2b8f2da972b830cf617d194c7c5be5b1535 /log-load.e
parent4f1a07da9c87a1560da34b8a96a9de4cdc90f1fc (diff)
implement log-load-create; add all the pack/unpack stuff to core.e
Force-Push: yes
Change-Id: I04dd65a9eec71f9b50c8875bdcbe5d4be59888d5
Diffstat (limited to 'log-load.e')
-rw-r--r--log-load.e42
1 files changed, 42 insertions, 0 deletions
diff --git a/log-load.e b/log-load.e
index 029b9da..8053291 100644
--- a/log-load.e
+++ b/log-load.e
@@ -176,3 +176,45 @@
 : log-load-find
   swap log-load-latest @ swap 3unroll swap find-in ;
 
+~   In the code generated by the log-load transform, it's convenient to have
+~ only a single step needed to look up a word's execution token. This helper
+~ does log-load-find, then gets the execution token if an entry is found.
+~
+~ (log address, string pointer -- log address, execution token or 0)
+: log-load-find-execution-token
+  log-load-find dup { entry-to-execution-token } if ;
+
+
+~   This is the same as "create", from interpret.e, except that it takes the
+~ log's address as a parameter rather than hardcoding it, so that it can be
+~ used in situations where the normal compilation process isn't yet available.
+~
+~   TODO: rework things so there's a common backend, rather than two
+~ implementations
+~
+~ (log address, string pointer -- log address)
+: log-load-create
+  dup stringlen 1 + dup 3unroll
+  ~ (log address, name field length, string pointer, name field length)
+
+  3 pick log-load-here swap drop @ 10 + 3unroll memmove
+  ~ (log address, name field length)
+
+  over log-load-here swap drop @
+  ~ (log address, name field length, output point)
+
+  2 pick log-load-latest swap drop @ pack64
+  ~ (log address, name field length, output point)
+  0 pack8
+  0 pack8
+  +
+  ~ (log address, output point)
+  8 packalign
+  ~ (log address, output point)
+
+  over log-load-here swap drop @
+  ~ (log address, output point, old here value)
+  2 pick log-load-latest swap drop !
+  ~ (log address, output point)
+  over log-load-here swap drop ! ;
+