about summary refs log tree commit diff stats
path: root/mu.arc
diff options
context:
space:
mode:
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc13
1 files changed, 13 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc
index 5c1b0455..6f214be1 100644
--- a/mu.arc
+++ b/mu.arc
@@ -703,6 +703,19 @@
         :else
           (err "sizeof can't handle @type (arrays require a specific variable)")))))
 
+(def deref (operand)
+  (assert (pos 'deref metadata.operand))
+  (assert typeinfo.operand!address)
+  (apply list (memory* v.operand)
+              typeinfo.operand!elem
+              (drop-one 'deref (cut operand 2))))
+
+(def drop-one (f x)
+  (when acons.x  ; proper lists only
+    (if (testify.f car.x)
+      cdr.x
+      (cons car.x (drop-one f x)))))
+
 ;; desugar structured assembly based on blocks
 
 (def convert-braces (instrs)