diff options
Diffstat (limited to 'transform.e')
| -rw-r--r-- | transform.e | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/transform.e b/transform.e index 0e38d90..77671cd 100644 --- a/transform.e +++ b/transform.e @@ -2722,7 +2722,8 @@ allocate-transformation-state s" transformation-state" variable : hex-output-metadata-latest-output-point 2 8 * + ; : hex-output-metadata-is-fresh-line 3 8 * + ; : hex-output-metadata-indentation-depth 4 8 * + ; -: hex-output-metadata-first-entry 5 8 * + ; +: hex-output-metadata-current-column 5 8 * + ; +: hex-output-metadata-first-entry 6 8 * + ; : hex-output-metadata-entry-data-start ; : hex-output-metadata-entry-data-length 8 + ; : hex-output-metadata-entry-type 2 8 * + ; @@ -2749,6 +2750,7 @@ allocate-transformation-state s" transformation-state" variable dup hex-output-metadata-latest-output-point 0 swap ! dup hex-output-metadata-is-fresh-line 1 swap ! dup hex-output-metadata-indentation-depth 0 swap ! + dup hex-output-metadata-current-column 0 swap ! dup hex-output-metadata-first-entry 0 swap ! ; ~ (pointer -- boolean) @@ -2980,6 +2982,16 @@ allocate-transformation-state s" transformation-state" variable transformation-state transformation-state-output-metadata @ hex-output-metadata-indentation-depth ! ; +: current-column@ + transformation-state transformation-state-output-metadata @ + hex-output-metadata-current-column @ ; + +: current-column! + transformation-state transformation-state-output-metadata @ + hex-output-metadata-current-column ! ; + +: advance-current-column current-column@ + current-column! ; + ~ Metadata entries are post-processed before they're output, in order to ~ make the structure of the output code simpler. The post-processing won't ~ happen until output actually occurs, which is important for operations that @@ -3048,8 +3060,7 @@ allocate-transformation-state s" transformation-state" variable ~ In the programs we're actually running the transform on, there's only ever ~ a single call to sys-write which is the whole binary in one go, but we don't ~ want to require that, so we keep all the formatting state in the output -~ metadata. In particular, hex-output-metadata-entry-is-fresh-line is kept -~ there. +~ metadata header. ~ ~ (length to write, base address --) : hex-sys-write-replacement @@ -3068,25 +3079,28 @@ allocate-transformation-state s" transformation-state" variable dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-line-comment = { fresh-line - indentation-depth@ indent + indentation-depth@ dup indent advance-current-column dup hex-output-metadata-entry-string @ ." ~ " emitstring newline 1 is-fresh-line! + 0 current-column! } if dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-suffix-comment = { - space + 40 current-column@ - 1 max indent dup hex-output-metadata-entry-string @ ." ~ " emitstring newline 1 is-fresh-line! + 0 current-column! } if dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-fresh-line = { fresh-line 1 is-fresh-line! + 0 current-column! } if dup hex-output-metadata-entry-type @ @@ -3094,6 +3108,7 @@ allocate-transformation-state s" transformation-state" variable fresh-line newline 1 is-fresh-line! + 0 current-column! } if dup hex-output-metadata-entry-type @ @@ -3105,7 +3120,7 @@ allocate-transformation-state s" transformation-state" variable dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-string-literal = { fresh-line - indentation-depth@ indent + indentation-depth@ dup indent advance-current-column ." ~ Null-terminated string literal: " 0x22 value@ emitstring drop @@ -3114,18 +3129,20 @@ allocate-transformation-state s" transformation-state" variable newline 1 is-fresh-line! + 0 current-column! } if dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-alignment = { fresh-line - indentation-depth@ indent + indentation-depth@ dup indent advance-current-column ." ~ Alignment padding to width " dup hex-output-metadata-entry-string @ . newline 1 is-fresh-line! + 0 current-column! } if } if @@ -3133,8 +3150,9 @@ allocate-transformation-state s" transformation-state" variable } while drop - is-fresh-line@ { indentation-depth@ indent } if + is-fresh-line@ { indentation-depth@ dup indent advance-current-column } if dup 8@ .hex8 space + 3 advance-current-column 0 is-fresh-line! 1+ swap 1- swap |