diff options
Diffstat (limited to 'transform.e')
| -rw-r--r-- | transform.e | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/transform.e b/transform.e index 1598d19..eb8e8bf 100644 --- a/transform.e +++ b/transform.e @@ -2719,7 +2719,8 @@ allocate-transformation-state s" transformation-state" variable ~ accessors for the transformation state, defined far, far above. : hex-output-metadata-label-loop-buffer-start ; : hex-output-metadata-label-loop-buffer-length 8 + ; -: hex-output-metadata-first-entry 2 8 * + ; +: hex-output-metadata-latest-output-point 2 8 * + ; +: hex-output-metadata-first-entry 3 8 * + ; : hex-output-metadata-entry-data-start ; : hex-output-metadata-entry-data-length 8 + ; : hex-output-metadata-entry-type 2 8 * + ; @@ -2740,6 +2741,7 @@ allocate-transformation-state s" transformation-state" variable transformation-state transformation-state-output-metadata @ dup hex-output-metadata-label-loop-buffer-start 0 swap ! dup hex-output-metadata-label-loop-buffer-length 0 swap ! + dup hex-output-metadata-latest-output-point 0 swap ! dup hex-output-metadata-first-entry 0 swap ! ; ~ (pointer -- boolean) @@ -2790,6 +2792,10 @@ allocate-transformation-state s" transformation-state" variable ~ This overwrites whatever entries currently exist with the new ones, and ~ adds a zero delimiter at the end. ~ +~ In addition to setting up the entries, we also set latest-output-point to +~ the start of the label-loop buffer here. This needs to happen at the start +~ of each pass, so although it doesn't quite fit the name, we do it here. +~ ~ It requires the header to have already been initialized; in particular it ~ requires the label-loop buffer start pointer to be valid. : create-hex-output-metadata-top-of-file-entries @@ -2798,6 +2804,18 @@ allocate-transformation-state s" transformation-state" variable swap hex-output-metadata-first-entry ~ (label buffer start, metadata output point) + ~ This likely won't affect anything, because every call to pack* + ~ overwrites it, but we initialize the latest output point to the start of + ~ the label loop buffer here. That way, in the event the very first thing in + ~ the output is something that's supposed to have a special comment on it, + ~ hex-tilde-replacement will know where to attach the metadata entry. + ~ + ~ If that was word soup, go read about hex-tilde-replacement and + ~ hex-tilde-alternate and come back. :) + over + transformation-state transformation-state-output-metadata @ + hex-output-metadata-latest-output-point ! + 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 @@ -2975,9 +2993,14 @@ allocate-transformation-state s" transformation-state" variable ~ (data start, data length) : hex-pack-trace - hex-output-metadata-entry-type-line-comment - s" pack" - add-hex-output-metadata-entry ; + ~ We keep a running tally of the next address in the output, for the + ~ benefit of hex-tilde-replacement, which needs to know where to attach its + ~ metadata entries. + + + dup is-in-label-loop-buffer { + transformation-state transformation-state-output-metadata @ + hex-output-metadata-latest-output-point ! + } { drop } if-else ; ~ By overriding colon, we can special-case the definitions of particular ~ words. It's very metacircular. @@ -3630,7 +3653,12 @@ allocate-transformation-state s" transformation-state" variable ~ ~ (string pointer) : hex-tilde-replacement - ." hmmm " emitstring newline ; + transformation-state transformation-state-output-metadata @ + hex-output-metadata-latest-output-point @ + 0 + hex-output-metadata-entry-type-line-comment + 4 roll + add-hex-output-metadata-entry ; ~ The tilde alternate is a very important word for the hex transform; it has |