diff options
Diffstat (limited to 'transform.e')
| -rw-r--r-- | transform.e | 47 |
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 |