about summary refs log tree commit diff
path: root/compilation
diff options
context:
space:
mode:
Diffstat (limited to 'compilation')
-rw-r--r--compilation/transform.e138
1 files changed, 76 insertions, 62 deletions
diff --git a/compilation/transform.e b/compilation/transform.e
index 5b84009..5469c4c 100644
--- a/compilation/transform.e
+++ b/compilation/transform.e
@@ -3676,8 +3676,9 @@ allocate-transformation-state s" transformation-state" variable
   ~ (entry pointer or 0)
 
   ~   If and only if we actually found one, now loop backwards to find the
-  ~ most recent one that's a comment entry. All length adjustments apply to
-  ~ comment entries, anything else needs to be skipped for this purpose.
+  ~ most recent one that's a saved-data entry. All data-consuming commands
+  ~ apply to saved-data entries, anything else needs to be skipped for this
+  ~ purpose.
   { dup { dup is-saved-data-entry not } { 0 } if-else }
   { transformation-state transformation-state-output-metadata @
     hex-output-metadata-first-entry
@@ -4100,8 +4101,8 @@ allocate-transformation-state s" transformation-state" variable
         ~ formatting.
         dup dup-metadata-entry
         ~ (did anything, entry pointer)
-        ~   Now we have the original entry at the original location, and a copy
-        ~ of it at the next location.
+        ~   Now we have the original entry at the original location, and a
+        ~ copy of it at the next location.
 
         ~   We have a feature which lets a suffix comment be created with a
         ~ negative length, which means it covers bytes before the current output
@@ -4204,6 +4205,60 @@ allocate-transformation-state s" transformation-state" variable
 : hex-comment-first-tab-stop 36 ;
 : hex-comment-second-tab-stop 58 ;
 
+
+~ (subitem entry -- subitem entry)
+: hex-emit-template-subitem
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-decimal = {
+    dup hex-output-metadata-entry-content @
+    dup 10 swap logfloor 1+ advance-current-column
+    .
+  } if
+
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-hex = {
+    ." 0x"
+    dup hex-output-metadata-entry-content @
+    dup 16 swap logfloor 1+ 2 + advance-current-column
+    .hex
+  } if
+
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-hex8 = {
+    ." 0x"
+    dup hex-output-metadata-entry-content @ .hex8
+    4 advance-current-column
+  } if
+
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-hex16 = {
+    ." 0x"
+    dup hex-output-metadata-entry-content @ .hex16
+    6 advance-current-column
+  } if
+
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-hex32 = {
+    ." 0x"
+    dup hex-output-metadata-entry-content @ .hex32
+    10 advance-current-column
+  } if
+
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-hex64 = {
+    ." 0x"
+    dup hex-output-metadata-entry-content @ .hex64
+    18 advance-current-column
+  } if
+
+  dup hex-output-metadata-entry-type @
+  hex-output-metadata-entry-type-push-subitem-string = {
+    dup hex-output-metadata-entry-content @
+    dup stringlen advance-current-column
+    emitstring
+  } if ;
+
+
 ~   This is a helper called from hex-emit-template-string. The word pointer
 ~ is in the outer log's scratch space, and must not be overwritten.
 ~
@@ -4222,70 +4277,29 @@ allocate-transformation-state s" transformation-state" variable
     ~ complex system.
     dup {
       ~ (queued space count, subitem entry)
+      swap dup indent advance-current-column 0 swap
+      ~ (adjusted queued space count, subitem entry)
 
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-decimal = {
-        swap dup indent advance-current-column 0 swap
-
-        dup hex-output-metadata-entry-content @
-        dup 10 swap logfloor 1+ advance-current-column
-        .
-      } if
-
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-hex = {
-        swap dup indent advance-current-column 0 swap
-
-        ." 0x"
-        dup hex-output-metadata-entry-content @
-        dup 16 swap logfloor 1+ 2 + advance-current-column
-        .hex
-      } if
-
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-hex8 = {
-        swap dup indent advance-current-column 0 swap
-
-        ." 0x"
-        dup hex-output-metadata-entry-content @ .hex8
-        4 advance-current-column
-      } if
-
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-hex16 = {
-        swap dup indent advance-current-column 0 swap
-
-        ." 0x"
-        dup hex-output-metadata-entry-content @ .hex16
-        6 advance-current-column
-      } if
-
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-hex32 = {
-        swap dup indent advance-current-column 0 swap
+      hex-emit-template-subitem
+    } if
 
-        ." 0x"
-        dup hex-output-metadata-entry-content @ .hex32
-        10 advance-current-column
-      } if
+    drop drop 0 exit
+  } if
 
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-hex64 = {
-        swap dup indent advance-current-column 0 swap
+  ~   Same as # but with quotes around it. The notation uses single quotes
+  ~ because that's easier to put in a string for syntax reasons, but the
+  ~ output uses double.
+  dup s" '#'" stringcmp 0 = {
+    drop
 
-        ." 0x"
-        dup hex-output-metadata-entry-content @ .hex64
-        18 advance-current-column
-      } if
+    pop-subitem-entry-stack
 
-      dup hex-output-metadata-entry-type @
-      hex-output-metadata-entry-type-push-subitem-string = {
-        swap dup indent advance-current-column 0 swap
+    dup {
+      swap dup indent advance-current-column 0 swap
 
-        dup hex-output-metadata-entry-content @
-        dup stringlen advance-current-column
-        emitstring
-      } if
+      0x22 value@ emitstring drop
+      hex-emit-template-subitem
+      0x22 value@ emitstring drop
     } if
 
     drop drop 0 exit