about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-18 15:12:50 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-18 15:12:50 -0700
commit31509055e11946ecc118ebbc6f72e458b17de918 (patch)
tree88c56d9bb9500526ca1912f38117675d2dfccdbb
parentf7710d4de0626fb1ecbdfea2933198a494bfb77b (diff)
magic comments for a bunch more small stuff
especially in the label-transform output

there's more to do, but there are additional magic-comment features that would be handy, so we're checking this in now so that those can be cleanly kept in their own CL

Force-Push: yes
Change-Id: I97a67caddc3f3150c349b7956c1d715db909d1a9
-rw-r--r--core.e2
-rw-r--r--interpret.e20
-rw-r--r--transform.e24
3 files changed, 32 insertions, 14 deletions
diff --git a/core.e b/core.e
index e181d4f..38ffd95 100644
--- a/core.e
+++ b/core.e
@@ -1222,7 +1222,7 @@ here !
   ~   It's possible the padding will be of length zero, so we have to put the
   ~ magic comment provide-* command first.
   ~ : provide-decimal
-  ~ : 0 Alignment padding to width #
+  ~ : 0     (width # alignment padding)
   { 2dup /% drop { drop exit } unless
     swap 0 pack8 swap
     ~ : 1 adjust-length
diff --git a/interpret.e b/interpret.e
index c1d88c4..92b2035 100644
--- a/interpret.e
+++ b/interpret.e
@@ -407,8 +407,14 @@ latest @
 
 ~   The counterpart of : is ;.
 : ;
-  ~ See commentary on "literal", in dynamic.e, regarding "lit exit".
-  lit exit ,
+  ~   See commentary on "literal", in dynamic.e, regarding "lit exit".
+  ~
+  ~   In regard to the magic comment, this is in the same category as strings
+  ~ and high-level flow control, where it's implemented in the base code here
+  ~ because that could be relevant to end-user code that compiles things
+  ~ without using the transforms, but in the regular compiler it's not used
+  ~ because the transforms override this whole implementation.
+  lit exit , ~ : -8 exit    (codeword pointer)
   make-visible
   ~   See above regarding [. Since it's an immediate word, we have to go to
   ~ extra trouble to compile it as part of ;. Since it's also hidden, we have
@@ -457,7 +463,10 @@ latest @
   consume
   interpreter-flags @ 0x01 & {
     [ s" litstring" find literal ]
-    entry-to-execution-token ,
+    ~   The magic comment isn't active in the compiler as-written, since the
+    ~ transformations do this bit themselves, but should still be here for
+    ~ completeness; it could affect other things people compile.
+    entry-to-execution-token , ~ : -8 litstring    (codeword pointer)
   } if
   here @ key { dup dup 0x22 != && } { pack8 key } while
   drop 0 pack8
@@ -472,8 +481,9 @@ latest @
   ' s" entry-to-execution-token execute
   interpreter-flags @ 1 &
     { [ s" emitstring" find literal ]
-      entry-to-execution-token , }
-    { emitstring } if-else
+      ~ As with s", the magic comment is for completeness only.
+      entry-to-execution-token , ~ : -8 emitstring    (codeword pointer)
+    } { emitstring } if-else
   ; make-immediate
 
 
diff --git a/transform.e b/transform.e
index 167089b..13dce31 100644
--- a/transform.e
+++ b/transform.e
@@ -915,9 +915,10 @@ allocate-transformation-state s" transformation-state" variable
   ~ to map it to the target address space. It's stored in the host address
   ~ space to make immediate words work as expected, so the appropriate
   ~ conversion is host-address-space-to-target.
+  ~ : 8     (previous entry pointer)
   latest @ host-address-space-to-target pack64
-  0 pack8
-  0 pack8
+  0 pack8 ~ : -1     (entry flags)
+  0 pack8 ~ : -1     (null reverse-terminator)
   +
   8 packalign
   here @ latest !
@@ -942,6 +943,7 @@ allocate-transformation-state s" transformation-state" variable
   word value@ label-create-alternate dropstring
 
   ~ This looks up "docol" by label.
+  ~ : 8     (docol codeword)
   swap-transform-variables
   L@' docol-codeword-value
   L@' origin
@@ -977,7 +979,7 @@ allocate-transformation-state s" transformation-state" variable
   swap-transform-variables
   L@' exit
   swap-transform-variables
-  offset-to-target-address-space ,
+  offset-to-target-address-space ,     ~ : -8 exit    (codeword pointer)
   ~ : deindent
 
   latest @ dup entry-flags@ 0x80 invert & swap entry-flags!
@@ -1069,7 +1071,7 @@ allocate-transformation-state s" transformation-state" variable
     L@' litstring
     swap-transform-variables
 
-    offset-to-target-address-space ,     ~ litstring
+    offset-to-target-address-space ,   ~ : -8 litstring    (codeword pointer)
     here @ swap packstring 8 packalign here !
   } if
   ; make-immediate
@@ -1083,7 +1085,7 @@ allocate-transformation-state s" transformation-state" variable
     L@' emitstring
     swap-transform-variables
 
-    offset-to-target-address-space ,     ~ emitstring
+    offset-to-target-address-space ,   ~ : -8 emitstring    (codeword pointer)
   } { emitstring } if-else
   ; make-immediate
 
@@ -1444,7 +1446,11 @@ allocate-transformation-state s" transformation-state" variable
       ~ We look up "lit" as a label.
       swap-transform-variables L@' lit swap-transform-variables
       offset-to-target-address-space
-      , ,
+      ~ : 8 lit    (codeword pointer)
+      ,
+      ~ : provide-hex
+      ~ : 8 #    (integer literal)
+      ,
       0 exit
     } if
 
@@ -4100,10 +4106,11 @@ allocate-transformation-state s" transformation-state" variable
           fresh-line
           indentation-depth@ dup indent advance-current-column
 
-          ." ~ String literal with null terminator: "
+          ." ~ "
           0x22 value@ emitstring drop
           dup hex-output-metadata-entry-content @ emitstring
           0x22 value@ emitstring drop
+          ."    (string literal with null)"
 
           newline
           1 is-fresh-line!
@@ -4115,10 +4122,11 @@ allocate-transformation-state s" transformation-state" variable
           fresh-line
           indentation-depth@ dup indent advance-current-column
 
-          ." ~ String literal with no terminator: "
+          ." ~ "
           0x22 value@ emitstring drop
           dup hex-output-metadata-entry-content @ emitstring
           0x22 value@ emitstring drop
+          ."     (raw string literal)"
 
           newline
           1 is-fresh-line!