diff options
Diffstat (limited to 'transform.e')
| -rw-r--r-- | transform.e | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/transform.e b/transform.e index 723484c..507c1f1 100644 --- a/transform.e +++ b/transform.e @@ -826,6 +826,53 @@ allocate-transform-state s" transform-state" variable ; make-immediate +~ It's convenient to be able to work with strings in label-transformed +~ code. If we don't provide an alternate for it, we get codeword pointers in +~ the host address space, which therefore don't work. +: label-string-alternate + ~ Wrapping s" is surprisingly difficult; see log-load-string-alternate + ~ for detailed notes on how it works. This is pretty much the same + ~ implementation, except the label transform doesn't track user stack depth + ~ so we don't have to worry about that part. + interpreter-flags @ + ' s" entry-to-execution-token + swap-transform-variables + ~ Since [ is an immediate word, we have to go to extra trouble to compile + ~ it as part of the alternate. + [ ' [ entry-to-execution-token , ] + execute + swap-transform-variables + swap interpreter-flags ! + ~ Whew. What a mouthful. + ~ (string pointer) + + ~ Now. If we are in immediate mode, we've left the string on the stack and + ~ that's all we wanted. If we're in compile mode, it's our job to output + ~ a litstring invocation. + interpreter-flags @ 0x01 & { + swap-transform-variables + L@' litstring + swap-transform-variables + + offset-to-target-address-space , ~ litstring + here @ swap packstring 8 packalign here ! + } if + ; make-immediate + + +: label-dot-string-alternate + ' label-string-alternate entry-to-execution-token execute + + interpreter-flags @ 0x01 & { + swap-transform-variables + L@' emitstring + swap-transform-variables + + offset-to-target-address-space , ~ emitstring + } { emitstring } if-else + ; make-immediate + + ~ Because docol requires it, we provide a special mini-version of the label ~ system. We only do L@' and L!', because that's all we need. These are real ~ labels; there can be arbitrarily many of them, and they can have forward @@ -1028,6 +1075,11 @@ allocate-transform-state s" transform-state" variable dup s" ;" stringcmp 0 = { swap drop ' label-semicolon-alternate swap } if dup s" ;asm" stringcmp 0 = { swap drop ' label-semicolon-assembly-alternate swap } if + ~ It is nontrivial to construct a string with a double-quote in it. + dup ' s" entry-to-name stringcmp 0 = { + swap drop ' label-string-alternate swap } if + dup ' ." entry-to-name stringcmp 0 = { + swap drop ' label-dot-string-alternate swap } if dup s" L@'" stringcmp 0 = { swap drop ' label-L@'-alternate swap } if dup s" L!'" stringcmp 0 = { swap drop ' label-L!'-alternate swap } if dup s" keyword" stringcmp 0 = { |