about summary refs log tree commit diff
path: root/transform.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-08 22:44:30 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-08 22:44:30 -0700
commitcdf13a70a8840d5f79c16c3d4b0aa84d53cbc46e (patch)
treef3bff5432107a6fe3fc810c10f28ee94f4deb5b8 /transform.e
parent880b631f268d70cf0282203f001afc1f0cc7bf31 (diff)
handle the rest of the fields (keywords and numbers) in amd64.e
add a provide-decimal variant of the magic-comment provide command family

note that the fields are all printed in a wrong order, at present

Force-Push: yes
Change-Id: I01f5cbb86f61e78ce652c54fc8b29b88efd1b2b6
Diffstat (limited to 'transform.e')
-rw-r--r--transform.e47
1 files changed, 31 insertions, 16 deletions
diff --git a/transform.e b/transform.e
index 54fd9e6..2227f2a 100644
--- a/transform.e
+++ b/transform.e
@@ -2778,6 +2778,7 @@ allocate-transformation-state s" transformation-state" variable
 ~   ~ : 1 suppress
 ~
 ~   ~ : Do a thing with # and # ?
+~   ~ : provide-decimal
 ~   ~ : provide-hex8
 ~   ~ : provide-hex16
 ~   ~ : provide-hex32
@@ -2901,9 +2902,10 @@ allocate-transformation-state s" transformation-state" variable
 ~ with the "adjust-line" command. When this command executes, it doesn't
 ~ create a new metadata entry. Rather, it scans backwards from the end of the
 ~ entry array, to find the most recently-created entry which is a line or
-~ suffix comment. Then it adjusts the length of that entry, in-place! The
-~ parameter of adjust-line may be positive or negative, and either way it's
-~ added to the pre-existing length of the entry it modifies.
+~ suffix comment. It skips over entries of other types. Then it adjusts the
+~ length of that entry, in-place! The parameter of adjust-line may be positive
+~ or negative, and either way it's added to the pre-existing length of the
+~ entry it modifies.
 ~
 ~   If that doesn't sound confusing, you may not have fully appreciated that
 ~ adjust-line commands don't have to come in the same word as the command that
@@ -3098,13 +3100,13 @@ allocate-transformation-state s" transformation-state" variable
 ~ still just recording the fact that the word did or didn't run.
 ~
 ~   The provide-* commands are deeper than that. They peek at the top item on
-~ the stack OF THE COMPILER, the code being transformed. The -hex* variants
-~ create a corresponding provide-substring-hex* metadata entry and copy the
-~ numeric value into it. The -keyword variant expects to find a keyword (a
-~ word which, when executed, pushes its own execution token onto the stack);
-~ the command extracts the name of the keyword from the dictionary entry
-~ header, and saves a pointer to the name in a provide-substring-string
-~ metadata entry.
+~ the stack OF THE COMPILER, the code being transformed. The -decimal and
+~ -hex* variants create a corresponding -entry-type-provide-substring-
+~ metadata entry of the matching type, and copy the numeric value into it. The
+~ -keyword variant expects to find a keyword (a word which, when executed,
+~ pushes its own execution token onto the stack); the command extracts the
+~ name of the keyword from the dictionary entry header, and saves a pointer to
+~ the name in a provide-substring-string metadata entry.
 ~
 ~   Admit it, you thought writing out "metadata entry" so many times instead
 ~ of just "entry" was silly because there was no other kind of entry in
@@ -3173,11 +3175,12 @@ allocate-transformation-state s" transformation-state" variable
 : hex-output-metadata-entry-type-string-literal 5 ;
 : hex-output-metadata-entry-type-raw-string-literal 6 ;
 : hex-output-metadata-entry-type-alignment 7 ;
-: hex-output-metadata-entry-type-provide-substring-hex8 8 ;
-: hex-output-metadata-entry-type-provide-substring-hex16 9 ;
-: hex-output-metadata-entry-type-provide-substring-hex32 10 ;
-: hex-output-metadata-entry-type-provide-substring-hex64 11 ;
-: hex-output-metadata-entry-type-provide-substring-string 12 ;
+: hex-output-metadata-entry-type-provide-substring-decimal 8 ;
+: hex-output-metadata-entry-type-provide-substring-hex8 9 ;
+: hex-output-metadata-entry-type-provide-substring-hex16 10 ;
+: hex-output-metadata-entry-type-provide-substring-hex32 11 ;
+: hex-output-metadata-entry-type-provide-substring-hex64 12 ;
+: hex-output-metadata-entry-type-provide-substring-string 13 ;
 
 ~   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
@@ -3217,7 +3220,8 @@ allocate-transformation-state s" transformation-state" variable
 
 : is-provide-substring-entry
   hex-output-metadata-entry-type @
-  dup hex-output-metadata-entry-type-provide-substring-hex8 = swap
+  dup hex-output-metadata-entry-type-provide-substring-decimal = swap
+  dup hex-output-metadata-entry-type-provide-substring-hex8 = 3roll || swap
   dup hex-output-metadata-entry-type-provide-substring-hex16 = 3roll || swap
   dup hex-output-metadata-entry-type-provide-substring-hex32 = 3roll || swap
   dup hex-output-metadata-entry-type-provide-substring-hex64 = 3roll || swap
@@ -3700,6 +3704,11 @@ allocate-transformation-state s" transformation-state" variable
         pop-substring-entry-stack
 
         dup hex-output-metadata-entry-type @
+        hex-output-metadata-entry-type-provide-substring-decimal = {
+          dup hex-output-metadata-entry-string @ .
+        } if
+
+        dup hex-output-metadata-entry-type @
         hex-output-metadata-entry-type-provide-substring-hex8 = {
           ." 0x"
           dup hex-output-metadata-entry-string @ .hex8
@@ -4693,6 +4702,12 @@ allocate-transformation-state s" transformation-state" variable
   ~ Notice with all of these that we intentionally read one stack level deeper
   ~ than anything of ours, which will be a value provided by the code the
   ~ magic comment is embedded in.
+  dup s" provide-decimal" stringcmp 0 = {
+    ~ Create a new "provide substring decimal" entry.
+    drop 2 pick hex-output-metadata-entry-type-provide-substring-decimal swap
+    add-hex-output-metadata-entry
+    exit
+  } if
   dup s" provide-hex8" stringcmp 0 = {
     ~ Create a new "provide substring hex8" entry.
     drop 2 pick hex-output-metadata-entry-type-provide-substring-hex8 swap