diff options
Diffstat (limited to 'transform.e')
| -rw-r--r-- | transform.e | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/transform.e b/transform.e index 95475c2..9a2cb21 100644 --- a/transform.e +++ b/transform.e @@ -2785,6 +2785,7 @@ allocate-transformation-state s" transformation-state" variable ~ ~ : provide-hex32 ~ ~ : provide-hex64 ~ ~ : provide-keyword +~ ~ : drop-subitem ~ ~ By the way, the reason it's possible to write these examples is that ~ they're all embedded within an outer comment, the text you're reading, so @@ -3072,11 +3073,13 @@ allocate-transformation-state s" transformation-state" variable ~ ~ Where do those items come from? Well, there's a separate stack, the ~ substring entry stack, which is kept in the hex output metadata header. The -~ substring entry stack has an extremely small, fixed maximum depth. Unusually -~ for Evocation, if you underflow or overflow it, you'll get a friendly error -~ message rather than a segfault - how nice! Of course, the error message will -~ appear in the middle of your regular output and corrupt it, but you can't -~ have everything... +~ substring entry stack has an extremely small, fixed maximum depth. The +~ maximum depth is deliberately small, so that any leaks onto it will be +~ detected somewhere close to their root causes, for ease of diagnosis. +~ Unusually for Evocation, if you underflow or overflow it, you'll get a +~ friendly error message rather than a segfault - how nice! Of course, the +~ error message will appear in the middle of your regular output and corrupt +~ it, but you can't have everything... ~ ~ Each time a comment template is being filled and encounters a # ~ placeholder, an item is popped off the substring entry stack and formatted @@ -3133,6 +3136,11 @@ allocate-transformation-state s" transformation-state" variable ~ entry pops it off the substring entry stack and pretty-prints the value it ~ holds. ~ +~ With all this context, it likely doesn't need much explanation, but the +~ drop-subitem command will create an -entry-type-drop-substring entry. When +~ this entry is executed, it will discard an item from the substring entry +~ stack. +~ ~ One more thing: The order in which provide-* commands execute will most ~ likely match the order in which the corresponding bytes are output. This may ~ not always match the order in which the comment template wants to @@ -3173,7 +3181,7 @@ allocate-transformation-state s" transformation-state" variable : hex-output-metadata-current-column 7 8 * + ; : hex-output-metadata-substring-entry-stack-depth 8 8 * + ; : hex-output-metadata-substring-entry-stack-zero 9 8 * + ; -: hex-output-metadata-substring-entry-stack-capacity 3 ; +: hex-output-metadata-substring-entry-stack-capacity 8 ; : hex-output-metadata-first-entry 9 hex-output-metadata-substring-entry-stack-capacity + 8 * + ; : hex-output-metadata-entry-data-start ; @@ -3196,6 +3204,7 @@ allocate-transformation-state s" transformation-state" variable : hex-output-metadata-entry-type-push-substring-hex32 11 ; : hex-output-metadata-entry-type-push-substring-hex64 12 ; : hex-output-metadata-entry-type-push-substring-string 13 ; +: hex-output-metadata-entry-type-drop-substring 14 ; ~ 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 @@ -3243,6 +3252,7 @@ allocate-transformation-state s" transformation-state" variable || ; : is-push-substring-entry + ~ Notably, -entry-type-drop-substring is not a push-substring entry. hex-output-metadata-entry-type @ dup hex-output-metadata-entry-type-push-substring-decimal = swap dup hex-output-metadata-entry-type-push-substring-hex8 = 3roll || swap @@ -3979,6 +3989,11 @@ allocate-transformation-state s" transformation-state" variable dup is-push-substring-entry { dup push-substring-entry-stack } if + + dup hex-output-metadata-entry-type @ + hex-output-metadata-entry-type-drop-substring = { + pop-substring-entry-stack drop + } if } if hex-output-metadata-next-entry } while @@ -4860,6 +4875,14 @@ allocate-transformation-state s" transformation-state" variable add-hex-output-metadata-entry exit } if + dup s" drop-subitem" stringcmp 0 = { + ~ Create a new "drop substring" entry. + drop drop + 2 pick execution-token-to-entry entry-to-name + hex-output-metadata-entry-type-drop-substring swap + add-hex-output-metadata-entry + exit + } if ~ If it's flagged as a suffix by the logic above, create a new ~ suffix-comment entry. |