diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-08-28 05:28:35 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-08-28 20:12:35 -0700 |
| commit | 6e0227328154e18810d8dfa4489bf84c9c15cbf7 (patch) | |
| tree | cdc3454338b96cadbaec6a15533ecdb9c4b7b3a6 | |
| parent | 9eb7d0fabb2a786d2aa9f56244360afb381e7c18 (diff) | |
change the transforms to take their end delimiters as parameters
this will not be useful until read-to-buffer also does, but it's a step towards that Force-Push: yes Change-Id: Icf03088c9e52e427a5c130949e9ba85655d59044
| -rw-r--r-- | core.e | 2 | ||||
| -rw-r--r-- | evoke.e | 4 | ||||
| -rw-r--r-- | execution.e | 14 | ||||
| -rw-r--r-- | transform.e | 30 |
4 files changed, 30 insertions, 20 deletions
diff --git a/core.e b/core.e index 1effc11..2aabc6f 100644 --- a/core.e +++ b/core.e @@ -1279,6 +1279,8 @@ here ! drop ; : over swap dup 3unroll ; + +~ 0 pick is equivalent to dup. 1 pick is equivlent to over. : pick 2 + dup roll dup 3roll unroll ; ~ Standard Forth doesn't have equivalents of our ndrop and ndup. The HP diff --git a/evoke.e b/evoke.e index 41b5d24..41c3687 100644 --- a/evoke.e +++ b/evoke.e @@ -23,8 +23,8 @@ s" source-to-precompile" variable elf-file-header elf-program-header output-cold-start - source-to-copy-to-log output-warm-start - source-to-precompile label-transform + source-to-copy-to-log s" pyrzqxgl" output-warm-start + source-to-precompile s" pyrzqxgl" label-transform ~ If we wanted words in the log to be able to call statically-linked ~ words, we could set this to something nonzero. We don't, so we leave it diff --git a/execution.e b/execution.e index 7a10e70..c6b6254 100644 --- a/execution.e +++ b/execution.e @@ -400,16 +400,17 @@ ~ pointers. It was directly jumped to from cold-start. There's nowhere to ~ return to, so it needs to never return. ~ -~ (output buffer start, output point, input string pointer +~ (output buffer start, output point, input string pointer, delimiter pointer ~ -- output buffer start, output point) : output-warm-start ~ While it's not actually a requirement that codeword pointers be ~ word-aligned, it's highly likely that it helps performance. (Whether it ~ does is up to Intel's microcode.) - 3unroll + 4 unroll 3unroll 8 packalign current-offset L!' warm-start - ~ (input string pointer, output buffer start, output point) + ~ (delimiter pointer, input string pointer, + ~ output buffer start, output point) ~ Before handing off to us, cold-start pushed a single value onto the ~ stack, a pointer to the beginning of the log. Now, we load our entire @@ -491,10 +492,11 @@ ~ we can go ahead and dispatch to the log-load transform, and do the rest of ~ the code through that. - ~ (input string pointer, output buffer start, output point) - 3roll + ~ (delimiter pointer, input string pointer, + ~ output buffer start, output point) + 3roll 4 roll log-load-transform - ~ (output point) + ~ (output buffer start, output point) ~ Now everything we need has been added to the log and we're almost ready ~ to jump into it. It's inconvenient for code under the log-load transform diff --git a/transform.e b/transform.e index ebf493f..313882d 100644 --- a/transform.e +++ b/transform.e @@ -285,13 +285,15 @@ : transformation-state-output-buffer-start 2 8 * + ; : transformation-state-user-stack-depth 3 8 * + ; : transformation-state-label-scratch 4 8 * + ; +: transformation-state-delimiter 5 8 * + ; : allocate-transformation-state - 5 8 * allocate + 6 8 * allocate dup transformation-state-saved-here 0 swap ! dup transformation-state-saved-latest 0 swap ! dup transformation-state-output-buffer-start 0 swap ! dup transformation-state-user-stack-depth 0 swap ! - dup transformation-state-label-scratch 0 swap ! ; + dup transformation-state-label-scratch 0 swap ! + dup transformation-state-delimiter 0 swap ! ; allocate-transformation-state s" transformation-state" variable @@ -1248,7 +1250,8 @@ allocate-transformation-state s" transformation-state" variable value@ ~ If it's the magic word, end the transformation. - dup s" pyrzqxgl" stringcmp 0 = { drop dropstring 1 exit } if + dup transformation-state transformation-state-delimiter @ stringcmp 0 = + { drop dropstring 1 exit } if ~ Check whether it's one of the words we have alternates for, and look up ~ the alternate if so. @@ -1435,11 +1438,11 @@ allocate-transformation-state s" transformation-state" variable ~ input string. It is directly analogous to "quit", in interpet.e, but is far ~ more complex. ~ -~ (output buffer start, output point, input string pointer +~ (output buffer start, output point, input string pointer, delimiter pointer ~ -- output buffer start, output point) : label-transform main-input-buffer dup push-input-buffer - swap attach-string-to-input-buffer + 3roll attach-string-to-input-buffer ~ Save the old values of "here" and "latest", and set the initial values ~ of the internal ones. These values need to persist across iterations, @@ -1448,9 +1451,10 @@ allocate-transformation-state s" transformation-state" variable ~ loop, and set it back when the loop ends. here @ transformation-state transformation-state-saved-here ! latest @ transformation-state transformation-state-saved-latest ! - over transformation-state transformation-state-output-buffer-start ! - here ! + 2 pick transformation-state transformation-state-output-buffer-start ! + swap here ! 0 latest ! + transformation-state transformation-state-delimiter ! ~ Now the stack has nothing of ours on it, so client code can do its thing. ~ It's important that the stack has nothing of ours on it that persists @@ -2356,7 +2360,8 @@ allocate-transformation-state s" transformation-state" variable value@ ~ If it's the magic word, end the transformation. - dup s" pyrzqxgl" stringcmp 0 = { drop dropstring 1 exit } if + dup transformation-state transformation-state-delimiter @ stringcmp 0 = + { drop dropstring 1 exit } if ~ Check whether it's one of the words we have alternates for, and look up ~ the alternate if so. @@ -2540,11 +2545,11 @@ allocate-transformation-state s" transformation-state" variable ~ an input string. It is directly analogous to "quit", in interpret.e, but is ~ far more complex. ~ -~ (output buffer start, output point, input string pointer +~ (output buffer start, output point, input string pointer, delimiter pointer ~ -- output buffer start, output point) : log-load-transform main-input-buffer dup push-input-buffer - swap attach-string-to-input-buffer + 3roll attach-string-to-input-buffer ~ Save the old values of "here" and "latest", and set the initial values ~ of the internal ones. These values need to persist across iterations, @@ -2556,10 +2561,11 @@ allocate-transformation-state s" transformation-state" variable ~ user-stack-depth fields of transformation-state. here @ transformation-state transformation-state-saved-here ! latest @ transformation-state transformation-state-saved-latest ! - over transformation-state transformation-state-output-buffer-start ! + 2 pick transformation-state transformation-state-output-buffer-start ! 0 transformation-state transformation-state-user-stack-depth ! - here ! + swap here ! 0 latest ! + transformation-state transformation-state-delimiter ! ~ Now the stack has nothing of ours on it, so client code can do its thing. ~ It's important that the stack has nothing of ours on it that persists |