summary refs log tree commit diff
path: root/log-load.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-05-19 00:38:46 -0700
committerIrene Knapp <ireneista@irenes.space>2026-05-19 00:38:46 -0700
commitebd8be68201201fd86fc4a4e4e0a535738af86bd (patch)
treef609d37f12d58ba4dbb5f2a3551cd9344b974c86 /log-load.e
parenteec336dea3d86e176c4bd86c435e6be35fec64e2 (diff)
yessssssss
so okay, now all the machine code stuff is implemented and it builds without crashing

the generated executable still crashes though, but this was enough work that it's getting a celebratory check-in

Force-Push: yes
Change-Id: I201e6912253647da58ef3537c735b478b0dca9fb
Diffstat (limited to 'log-load.e')
-rw-r--r--log-load.e53
1 files changed, 52 insertions, 1 deletions
diff --git a/log-load.e b/log-load.e
index 71324f2..100211c 100644
--- a/log-load.e
+++ b/log-load.e
@@ -98,6 +98,14 @@
 ~ abstractions which would make it difficult or inefficient to work directly
 ~ with these topics. So, in understanding Evocation, it's important to know
 ~ about handles.
+~
+~   Some of these bootstrap words rely on being able to invoke assembler words
+~ that output machine code. Therefore, those words must be available at
+~ runtime. Since nothing can be dynamically available at runtime until after
+~ we've already run the log-load routine, which relies on the stuff in this
+~ file, the assembler words must be statically available via the label
+~ transform. That means their definitions in arm64.e must be loaded before
+~ this file.
 
 
 ~   Find-in is the main word that provides the capability to look up words by
@@ -267,9 +275,52 @@
   mov-reg64-imm64
   ~ (log address, here, output point)
 
-~   :rax push-reg64
+  :rax push-reg64
   pack-next
   8 packalign
 
   swap ! ;
 
+
+~   A keyword is a word that evaluates to its own address, which makes it
+~ suitable for use as a constant. By convention, all our keywords have names
+~ starting with a colon, which imitates the way they work in Common Lisp.
+~
+~   Specifically, it returns its own execution token. Thus, executing its
+~ result repeatedly will keep giving the same value. We aren't in the habit of
+~ doing quote-exec kinds of things in Evocation, but it seems as good as any
+~ other unique value, so we might as well.
+~
+~   Unlike CL, we don't currently have the lexer automatically create keywords
+~ for us; we create them explicitly. Even if we did someday have it be
+~ automatic, the log-load routine would need a way to do it explicitly, which
+~ is this.
+~
+~   It's kind of a pain to look up the appropriate "docol" from here, so we
+~ do it in assembler instead.
+~
+~ (log address, string pointer -- log address)
+: log-load-keyword
+  log-load-create
+  ~ (log address)
+
+  log-load-here @ dup
+  ~ (log address, self execution token, output point)
+
+  dup 8 + pack64
+  ~ (log address, self execution token, output point)
+
+  swap :rax mov-reg64-imm64
+  ~ (log address, output point)
+
+  :rax push-reg64
+  pack-next
+  8 packalign
+  ~ (log address, output point)
+
+  swap log-load-here
+  ~ (output point, log address, here)
+  swap 3unroll
+  ~ (log address, output point, here)
+  ! ;
+