summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-08-30 23:23:49 -0700
committerIrene Knapp <ireneista@irenes.space>2026-08-30 23:23:49 -0700
commit6b0e81fe0712b757a6e1d6b8c4c66c874bd57e92 (patch)
tree61e3b51d4a4c7a7fd9c89245fc24cec298df97f7
parentab7caa91be01fe092fdeca65dc797f60abba6406 (diff)
distinguish different types of metadata entry HEAD main
so that each can have its own formatting

Force-Push: yes
Change-Id: I59b2eb556b9c1ab1c71118077073b7a8650ed33b
-rw-r--r--transform.e63
1 files changed, 45 insertions, 18 deletions
diff --git a/transform.e b/transform.e
index bae74e2..69e7d05 100644
--- a/transform.e
+++ b/transform.e
@@ -2623,8 +2623,12 @@ allocate-transformation-state s" transformation-state" variable
 : hex-output-metadata-first-entry 2 8 * + ;
 : hex-output-metadata-entry-data-start ;
 : hex-output-metadata-entry-data-length 8 + ;
-: hex-output-metadata-entry-string 2 8 * + ;
-: hex-output-metadata-next-entry 3 8 * + ;
+: hex-output-metadata-entry-type 2 8 * + ;
+: hex-output-metadata-entry-string 3 8 * + ;
+: hex-output-metadata-next-entry 4 8 * + ;
+: hex-output-metadata-entry-type-line-comment 0 ;
+: hex-output-metadata-entry-type-line-break 1 ;
+: hex-output-metadata-entry-type-string-literal 2 ;
 
 ~   Initialize the contents of the output metadata to all zeroes. This is
 ~ called from hex-transform at its top level, at the very start, to make sure
@@ -2650,31 +2654,32 @@ allocate-transformation-state s" transformation-state" variable
   swap hex-output-metadata-label-loop-buffer-length @ +
   > && ;
 
-~ (data start, data length, string pointer, entry pointer --)
+~ (data start, data length, entry type, string pointer, entry pointer --)
 : hex-output-metadata-entry!
   dup hex-output-metadata-entry-string 3roll swap !
+  dup hex-output-metadata-entry-type 3roll swap !
   dup hex-output-metadata-entry-data-length 3roll swap !
   dup hex-output-metadata-entry-data-start 3roll swap !
   drop ;
 
-~ (entry pointer, data start, data length, string pointer
+~ (entry pointer, data start, data length, entry type, string pointer
 ~  -- next entry pointer)
 : pack-hex-output-metadata-entry
-  3 pick hex-output-metadata-entry!
+  4 pick hex-output-metadata-entry!
   hex-output-metadata-next-entry ;
 
-~ (data start, data length, string pointer --)
+~ (data start, data length, entry type, string pointer --)
 : add-hex-output-metadata-entry
-  2 pick is-in-label-loop-buffer {
+  3 pick is-in-label-loop-buffer {
     transformation-state transformation-state-output-metadata @
     hex-output-metadata-first-entry
-    { dup @ dup { dup 2 pick >= drop } if } {
+    { dup @ dup { dup 3 pick >= drop } if } {
       hex-output-metadata-next-entry
     } while
 
-    4 unroll pack-hex-output-metadata-entry
+    5 unroll pack-hex-output-metadata-entry
     0 pack64 drop
-  } { drop drop drop } if-else ;
+  } { drop drop drop drop } if-else ;
 
 ~   This is the followup to zero-hex-output-metadata, above. Once we do have
 ~ the label-loop buffer, we need to create some default entries. This is
@@ -2693,31 +2698,32 @@ allocate-transformation-state s" transformation-state" variable
   swap hex-output-metadata-first-entry
   ~ (label buffer start, metadata output point)
 
-  over 0
+  over 0 hex-output-metadata-entry-type-line-comment
   s"   This file is a commented hexadecimal representation of a compiled "
   pack-hex-output-metadata-entry
 
-  over 0
+  over 0 hex-output-metadata-entry-type-line-comment
   s" program, the output of Evocation's hex transform. The comments are "
   pack-hex-output-metadata-entry
 
-  over 0
+  over 0 hex-output-metadata-entry-type-line-comment
   s" intended to allow a human reader to audit it. You can convert it to a "
   pack-hex-output-metadata-entry
 
-  over 0
+  over 0 hex-output-metadata-entry-type-line-comment
   s" runnable executable by piping it through the program named 'hex' and "
   pack-hex-output-metadata-entry
 
-  over 0
+  over 0 hex-output-metadata-entry-type-line-comment
   s" chmodding the output 755. The difference between a source and a binary "
   pack-hex-output-metadata-entry
 
-  over 0
+  over 0 hex-output-metadata-entry-type-line-comment
   s" is comments! Enjoy. :)"
   pack-hex-output-metadata-entry
 
-  over 0 s" " pack-hex-output-metadata-entry
+  over 0 hex-output-metadata-entry-type-line-break 0
+  pack-hex-output-metadata-entry
 
   0 swap ! ~ End-of-entries delimiter
   drop ;
@@ -2833,7 +2839,25 @@ allocate-transformation-state s" transformation-state" variable
         ~ We found a matching metadata entry.
         ~ (length remaining, current output address, metadata scan pointer)
 
-        dup hex-output-metadata-entry-string @ ." ~ " emitstring newline
+        dup hex-output-metadata-entry-type @
+        hex-output-metadata-entry-type-line-comment = {
+          dup hex-output-metadata-entry-string @ ." ~ " emitstring newline
+        } if
+
+        dup hex-output-metadata-entry-type @
+        hex-output-metadata-entry-type-line-break = {
+          newline
+        } if
+
+        dup hex-output-metadata-entry-type @
+        hex-output-metadata-entry-type-string-literal = {
+          newline
+          ." ~ Null-terminated string literal: "
+          0x22 value@ emitstring drop
+          dup hex-output-metadata-entry-string @ emitstring
+          0x22 value@ emitstring drop
+          newline
+        } if
       } if
       hex-output-metadata-next-entry
     } while
@@ -2996,7 +3020,10 @@ allocate-transformation-state s" transformation-state" variable
     s" stringlen" find entry-to-execution-token ,
     s" 1+" find entry-to-execution-token ,
     s" swap" find entry-to-execution-token ,
+    ' hex-output-metadata-entry-type-string-literal entry-to-execution-token ,
+    s" swap" find entry-to-execution-token ,
     ' add-hex-output-metadata-entry entry-to-execution-token ,
+    ~ (output point, string pointer)
     ~ Fall through to the inner implementation.
 
     ' ] entry-to-execution-token execute