diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-08-30 13:47:00 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-08-30 13:47:00 -0700 |
| commit | 73ce945376e42de3867fc604fc29343fd831b496 (patch) | |
| tree | 38abfee196fac8e43e6a82e0b031bc48959ee94f | |
| parent | 5a185b3751410d7901652752ddeeb156d1741bfd (diff) | |
abstract the hex transform's metadata low-level pointer manipulation
and move the docs on the data structure to where that is Force-Push: yes Change-Id: I607f2f9ce354026f27a8c6cbba020e29342fe450
| -rw-r--r-- | transform.e | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/transform.e b/transform.e index f32448b..3a6e34c 100644 --- a/transform.e +++ b/transform.e @@ -2606,6 +2606,24 @@ allocate-transformation-state s" transformation-state" variable ~ The hex transform DOES NOT WORK yet. It's still in development. ~ TODO update this note when it does work +~ The output metadata is a header structure followed by an array of +~ entry structures, as follows: +~ +~ (header start) +~ 0x00 - 0x07 Label-loop buffer length +~ (entry start) +~ ... + 0x00 - ... + 0x07 Data pointer +~ ... + 0x08 - ... + 0x0f Referenced data length +~ ... + 0x10 - ... + 0x17 String pointer +~ (entry fields repeat at successive offsets) +~ ... + 0x00 - ... + 0x07 (end) Zero, used as a delimiter +: hex-output-metadata-label-loop-buffer-length ; +: hex-output-metadata-first-entry 8 + ; +: hex-output-metadata-entry-data-start ; +: hex-output-metadata-entry-data-length 8 + ; +: hex-output-metadata-entry-string 2 8 * + ; +: hex-output-metadata-next-entry 3 8 * + ; + : hex-tilde-alternate [ ' ~ entry-to-execution-token , ] ; make-immediate @@ -2708,18 +2726,8 @@ allocate-transformation-state s" transformation-state" variable ~ (length to write, base address --) : hex-sys-write-replacement { over } { - ~ The output metadata is a header structure followed by an array of - ~ entry structures, as follows: - ~ - ~ (header start) - ~ 0x00 - 0x07 Output buffer length - ~ (entry start) - ~ ... + 0x00 - ... + 0x07 Data pointer - ~ ... + 0x08 - ... + 0x0f Referenced data length - ~ ... + 0x10 - ... + 0x17 String pointer - ~ (entry fields repeat at successive offsets) - ~ ... + 0x00 - ... + 0x07 (end) Zero, used as a delimiter - transformation-state transformation-state-output-metadata @ 8 + + transformation-state transformation-state-output-metadata @ + hex-output-metadata-first-entry ~ (length remaining, current output address, metadata scan pointer) { dup @ dup { dup 2 pick >= drop } if ~ dup { dup 2 pick >= } if @@ -2729,9 +2737,9 @@ allocate-transformation-state s" transformation-state" variable ~ We found a matching metadata entry. ~ (length remaining, current output address, metadata scan pointer) - dup 2 8 * + @ ." ~ " emitstring newline + dup hex-output-metadata-entry-string @ ." ~ " emitstring newline } if - 3 8 * + + hex-output-metadata-next-entry } while drop @@ -2862,6 +2870,23 @@ allocate-transformation-state s" transformation-state" variable exit } if + ~ Now we have a bunch of patches that keep track of output metadata. These + ~ are all Forth words, nothing too complicated about the actual patching. + dup s" packstring" stringcmp 0 = { + create dropstring + s" docol" find entry-to-execution-token execute , + make-hidden + + ~ (output point, string pointer) + ~ TODO DO NOT SUBMIT + ~ s" over" find entry-to-execution-token , + ~ ' hex-sys-write-replacement entry-to-execution-token , + + ' ] entry-to-execution-token execute + exit + } if + + ~ If no special case matches, we fall back to just being a regular colon. ~ We already read the word name above, so we have to do the rest of the ~ steps ourselves as well. @@ -3264,11 +3289,11 @@ allocate-transformation-state s" transformation-state" variable transformation-state transformation-state-output-metadata ! ~ Now the stack has nothing of ours on it, so client code can do its thing. - ~ Initialize the contents of the output metadata. See - ~ hex-sys-write-replacement for more notes on its format. + ~ Initialize the contents of the output metadata. See the notes above + ~ hex-output-metadata-* for details on its format. transformation-state transformation-state-output-metadata @ - 0 pack64 - 0 pack64 + 0 pack64 ~ Output buffer length + 0 pack64 ~ End-of-entries delimiter drop ~ It's important that the stack has nothing of ours on it that persists |