about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--mu.arc22
-rw-r--r--mu.arc.t34
2 files changed, 44 insertions, 12 deletions
diff --git a/mu.arc b/mu.arc
index a4bf4e2d..934d480c 100644
--- a/mu.arc
+++ b/mu.arc
@@ -18,8 +18,9 @@
   (each (name . body) fns
     (= function*.name body)))
 
-(def run (instrs (o fn-args))
+(def run (instrs (o fn-args) (o otypes))
   (ret result nil
+    (let fn-arg-idx 0
 ;?     (prn instrs)
     (for pc 0 (< pc len.instrs) (++ pc)
 ;?       (prn pc)
@@ -52,10 +53,19 @@
                    (trunc:/ (memory* arg.0.1) (memory* arg.1.1))
                    (memory* oarg.1.1)
                    (mod (memory* arg.0.1) (memory* arg.1.1)))
-              read
-                (= (memory* oarg.0.1)
-                   ; hardcoded channel for now
-                   (memory* pop.fn-args.1))
+              arg
+;?                 (do (prn "arg " arg " fn-arg " fn-arg-idx)
+                    (if arg
+;?                       (do (prn "arg " arg)
+                      (= (memory* oarg.0.1)
+                         (memory* ((fn-args arg.0) 1)))
+;?                       )
+;?                       (do (prn "no arg; using " fn-arg-idx " " fn-args.fn-arg-idx)
+                          (= (memory* oarg.0.1)
+                             (memory* fn-args.fn-arg-idx.1))
+                          (++ fn-arg-idx))
+;?                       )
+;?                 )
               jmp
                 (do (= pc arg.0.1)
 ;?                     (prn "jumping to " pc)
@@ -76,7 +86,7 @@
                       (= (memory* o.1) (memory* pop.results.1)))))
               )))))
 ;?     (prn "return " result)
-    ))
+    )))
 
 (awhen cdr.argv
   (each file it
diff --git a/mu.arc.t b/mu.arc.t
index 3825c4b9..5bca40b5 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -41,8 +41,8 @@
 (clear)
 (add-fns
   '((add-fn
-      ((integer 4) <- read)
-      ((integer 5) <- read)
+      ((integer 4) <- arg)
+      ((integer 5) <- arg)
       ((integer 3) <- add (integer 4) (integer 5))
       (reply)
       ((integer 4) <- loadi 34))
@@ -57,12 +57,34 @@
                        ; add-fn's temporaries
                        4 1  5 3))
   (prn "F - parameterized compound fn"))
+;? (quit)
+
+(clear)
+(add-fns
+  '((add-fn
+      ((integer 5) <- arg 1)
+      ((integer 4) <- arg 0)
+      ((integer 3) <- add (integer 4) (integer 5))
+      (reply)
+      ((integer 4) <- loadi 34))
+    (main
+      ((integer 1) <- loadi 1)
+      ((integer 2) <- loadi 3)
+      (add-fn (integer 1) (integer 2))
+    )))
+(run function*!main)
+;? (prn memory*)
+(if (~iso memory* (obj 1 1  2 3  3 4
+                       ; add-fn's temporaries
+                       4 1  5 3))
+  (prn "F - arg with index"))
+;? (quit)
 
 (clear)
 (add-fns
   '((add-fn
-      ((integer 4) <- read)
-      ((integer 5) <- read)
+      ((integer 4) <- arg)
+      ((integer 5) <- arg)
       ((integer 6) <- add (integer 4) (integer 5))
       (reply (integer 6))
       ((integer 4) <- loadi 34))
@@ -80,8 +102,8 @@
 (clear)
 (add-fns
   '((add-fn
-      ((integer 4) <- read)
-      ((integer 5) <- read)
+      ((integer 4) <- arg)
+      ((integer 5) <- arg)
       ((integer 6) <- add (integer 4) (integer 5))
       (reply (integer 6) (integer 5))
       ((integer 4) <- loadi 34))