summary refs log tree commit diff
path: root/transform.e
diff options
context:
space:
mode:
Diffstat (limited to 'transform.e')
-rw-r--r--transform.e63
1 files changed, 48 insertions, 15 deletions
diff --git a/transform.e b/transform.e
index 61ef373..6b2b64b 100644
--- a/transform.e
+++ b/transform.e
@@ -1779,26 +1779,57 @@ allocate-transform-state s" transform-state" variable
   ; make-immediate
 
 
-~ TODO there should really be an actual word that this alternate is replacing
-~
-~ If it existed, that word would be (string pointer --).
+: log-load-variable-alternate
+  ~   In immediate mode, we have special behavior because of the "here" magic.
+  ~ In compile mode, we compile a dynamic call, which is the same thing that
+  ~ would happen if we didn't have an alternate at all.
+  interpreter-flags @ 0x01 & {
+    s" variable" log-load-compile-dynamic-word
+  } {
+    ~   Calling log-load-create-alternate would result in some redundant rolling
+    ~ and unrolling, so we do it together like this instead.
+    log-load-roll-log-address
+
+    swap-transform-variables
+    L@' log-load-variable
+    L@' 3unroll
+    swap-transform-variables
+
+    offset-to-target-address-space ,     ~ 3unroll
+    offset-to-target-address-space ,     ~ log-load-variable
+
+    ~   We consumed the string and address, so we apply a delta.
+    -2 transform-apply-stack-delta
+
+    log-load-unroll-log-address
+  } if-else
+  ; make-immediate
+
+
 : log-load-keyword-alternate
-  ~   Calling log-load-create-alternate would result in some redundant rolling
-  ~ and unrolling, so we do it together like this instead.
-  log-load-roll-log-address
+  ~   In immediate mode, we have special behavior because of the "here" magic.
+  ~ In compile mode, we compile a dynamic call, which is the same thing that
+  ~ would happen if we didn't have an alternate at all.
+  interpreter-flags @ 0x01 & {
+    s" keyword" log-load-compile-dynamic-word
+  } {
+    ~   Calling log-load-create-alternate would result in some redundant rolling
+    ~ and unrolling, so we do it together like this instead.
+    log-load-roll-log-address
 
-  swap-transform-variables
-  L@' log-load-keyword
-  L@' swap
-  swap-transform-variables
+    swap-transform-variables
+    L@' log-load-keyword
+    L@' swap
+    swap-transform-variables
 
-  offset-to-target-address-space ,     ~ swap
-  offset-to-target-address-space ,     ~ log-load-keyword
+    offset-to-target-address-space ,     ~ swap
+    offset-to-target-address-space ,     ~ log-load-keyword
 
-  ~   We consumed the string, so we apply a delta.
-  -1 transform-apply-stack-delta
+    ~   We consumed the string, so we apply a delta.
+    -1 transform-apply-stack-delta
 
-  log-load-unroll-log-address
+    log-load-unroll-log-address
+  } if-else
   ; make-immediate
 
 
@@ -2130,6 +2161,8 @@ allocate-transform-state s" transform-state" variable
     swap drop ' log-load-right-square-brace-alternate swap } if
   dup s" '" stringcmp 0 = { swap drop ' log-load-tick-alternate swap } if
   dup s" ," stringcmp 0 = { swap drop ' log-load-comma-alternate swap } if
+  dup s" variable" stringcmp 0 = {
+    swap drop ' log-load-variable-alternate swap } if
   dup s" keyword" stringcmp 0 = {
     swap drop ' log-load-keyword-alternate swap } if
   dup s" ~" stringcmp 0 = {