diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-05-22 02:21:51 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-05-22 02:21:51 -0700 |
| commit | 83953f9e4b4fb3130c8ac5e1b8408a2830e21c23 (patch) | |
| tree | 7240ebd90802a40352772f574af0382c5ec9ee10 | |
| parent | 725af82ad48c1d6275a2e9ef6ef88f1c89f2e929 (diff) | |
okay s" ." and ' do their things now
Force-Push: yes Change-Id: I556334ea34157992d2b21306c941ad432cf41b4c
| -rw-r--r-- | interpret.e | 38 | ||||
| -rw-r--r-- | transform.e | 74 |
2 files changed, 109 insertions, 3 deletions
diff --git a/interpret.e b/interpret.e index 5941d15..24ea430 100644 --- a/interpret.e +++ b/interpret.e @@ -402,7 +402,8 @@ latest @ ~ If the ] at the end feels backwards, imagine to yourself that everything ~ that ISN'T defining a word body is part of an implicit [ ... ] sequence. ~ Doing so doesn't really change anything, but may make you happier. -: : word value@ create dropstring docol , make-hidden ] ; +: : word value@ create dropstring docol , make-hidden + [ dup entry-to-execution-token , ] ; ~ The counterpart of : is ;. : ; @@ -417,6 +418,7 @@ latest @ ~ so we do that by hand as well. [ over entry-to-execution-token , ] ; make-immediate make-hidden +latest @ ~ (pointer to [ entry, pointer to ] entry, pointer to ; entry) @@ -446,7 +448,38 @@ latest @ ~ "if". Fortunately flow-control is done with alternates by the log-load ~ transform, so we don't have to worry about it. : ' word value@ find dropstring-with-result - interpreter-flags @ 1 & { literal } if + interpreter-flags @ 0x01 & { literal } if + ; make-immediate + + +~ Let's have strings now. +: s" + consume + interpreter-flags @ 0x01 & { + [ s" litstring" find literal ] + entry-to-execution-token , + } if + here @ key { dup dup 0x22 != && } { pack8 key } while + drop 0 pack8 + interpreter-flags @ 0x01 & + { 8 packalign here ! } + { drop here @ } if-else + ; make-immediate + + +~ Finicky semantics, but also important. +: ." + ' s" entry-to-execution-token execute + interpreter-flags @ 1 & + { [ s" emitstring" find literal ] + entry-to-execution-token , } + { emitstring } if-else + ; make-immediate + + +~ While we're thinking about input, let's also have comments. +: ~ + key { dup dup 10 != && } { drop key } while drop ; make-immediate @@ -514,6 +547,7 @@ latest @ dup entry-flags@ 0x80 invert & entry-flags! dup entry-flags@ 0x80 invert & entry-flags! dup entry-flags@ 0x80 invert & entry-flags! +dup entry-flags@ 0x80 invert & entry-flags! ~ Though we only do it once, this is a bit involved so we provide it as a ~ word. Notionally there are situations in which it could come up again, so diff --git a/transform.e b/transform.e index 7b82eae..d148e58 100644 --- a/transform.e +++ b/transform.e @@ -1947,7 +1947,7 @@ allocate-transform-state s" transform-state" variable ~ net out to zero; we aren't doing it just for kicks. -1 transform-apply-stack-delta - log-load-unroll-log-address ; + log-load-unroll-log-address } if ; make-immediate @@ -1970,6 +1970,76 @@ allocate-transform-state s" transform-state" variable ; make-immediate +~ No matter what mode we're in, we read a name at transform time. Then we +~ look up the name at either log-load time or runtime, depending. +: log-load-tick-alternate + ~ Read the name. + word value@ + + ~ Get the name onto the stack at log-load time. + swap-transform-variables + L@' litstring + swap-transform-variables + + offset-to-target-address-space , ~ litstring + here @ swap packstring 8 packalign here ! + + ~ Apply a delta for the string pointer. + 1 transform-apply-stack-delta + + dropstring + + ~ Now break out the remaining behavior based on mode. + interpreter-flags @ 0x01 & { + log-load-roll-log-address + + swap-transform-variables + L@' log-load-comma + L@' log-load-find-execution-token + L@' litstring + L@' log-load-comma-string + L@' swap + L@' log-load-comma + L@' log-load-find-execution-token + L@' litstring + swap-transform-variables + + ~ The overall stack delta of this sequence is 0. + offset-to-target-address-space , ~ litstring + here @ s" litstring" packstring 8 packalign here ! + offset-to-target-address-space , ~ log-load-find-execution-token + offset-to-target-address-space , ~ log-load-comma + offset-to-target-address-space , ~ swap + offset-to-target-address-space , ~ log-load-comma-string + + offset-to-target-address-space , ~ litstring + here @ s" find" packstring 8 packalign here ! + offset-to-target-address-space , ~ log-load-find-execution-token + offset-to-target-address-space , ~ log-load-comma + + ~ We consumed the string pointer at log-load time, so we apply a delta + ~ for it. As in log-load-string-alternate, this needs to be split into + ~ two parts like this. + -1 transform-apply-stack-delta + + log-load-unroll-log-address + } { + log-load-roll-log-address + + swap-transform-variables + L@' log-find + swap-transform-variables + + offset-to-target-address-space , ~ log-load-comma + + ~ We leave an execution token on the log-load-time stack, so no delta + ~ needed. + + log-load-unroll-log-address + } 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. Unlike the ~ version of this feature for the label transform, for the log-load transform, @@ -2199,6 +2269,8 @@ allocate-transform-state s" transform-state" variable swap drop ' log-load-string-alternate swap } if dup ' ." entry-to-name stringcmp 0 = { swap drop ' log-load-dot-string-alternate swap } if + dup ' ' entry-to-name stringcmp 0 = { + swap drop ' log-load-tick-alternate swap } if dup s" L@'" stringcmp 0 = { swap drop ' log-load-L@'-alternate swap } if dup s" L!'" stringcmp 0 = { swap drop ' log-load-L!'-alternate swap } if dup s" {" stringcmp 0 = { |