diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-07-10 22:08:08 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-07-10 22:08:08 -0700 |
commit | f4bc8c31484c848881f9995a3b8333777fea8440 (patch) | |
tree | 61e8e887b2d97544284e50e1e27ee7e9a1eef33d | |
parent | f9ff24be5a1cb6e1dd67479b59faacaaeeb48d60 (diff) | |
download | mu-f4bc8c31484c848881f9995a3b8333777fea8440.tar.gz |
11 - enhance the language with types
The types aren't actually used yet. That comes later.
-rw-r--r-- | mu.arc | 16 | ||||
-rw-r--r-- | mu.arc.t | 66 |
2 files changed, 42 insertions, 40 deletions
diff --git a/mu.arc b/mu.arc index 3755f4fa..f87bc8d1 100644 --- a/mu.arc +++ b/mu.arc @@ -1,7 +1,9 @@ ; things that a future assembler will need separate memory for: ; code; types; args channel (def clear () - (= types* (table)) + (= types* (obj + integer (obj size 1) + address (obj size 1))) (= memory* (table)) (= function* (table))) (clear) @@ -23,14 +25,14 @@ ;? (prn op " " oarg) (case op loadi - (= (memory* oarg.0) arg.0) + (= (memory* oarg.0.1) arg.0) add - (= (memory* oarg.0) - (+ (memory* arg.0) (memory* arg.1))) + (= (memory* oarg.0.1) + (+ (memory* arg.0.1) (memory* arg.1.1))) read - (= (memory* oarg.0) + (= (memory* oarg.0.1) ; hardcoded channel for now - (memory* pop.fn-args)) + (memory* pop.fn-args.1)) reply (= returned (annotate 'result arg)) ; else user-defined function @@ -38,7 +40,7 @@ ;? (prn "== " memory*) (each o oarg ;? (prn o) - (= memory*.o (memory* pop.results)))) + (= (memory* o.1) (memory* pop.results.1)))) ))))) ;? (prn "return") rep.returned) diff --git a/mu.arc.t b/mu.arc.t index ced0b92d..a36dad9a 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -2,9 +2,9 @@ (clear) (add-fns '((test1 - (1 <- loadi 1) - (2 <- loadi 3) - (3 <- add 1 2)))) + ((integer 1) <- loadi 1) + ((integer 2) <- loadi 3) + ((integer 3) <- add (integer 1) (integer 2))))) (run function*!test1) (if (~iso memory* (obj 1 1 2 3 3 4)) (prn "F - load and add instructions work")) @@ -12,10 +12,10 @@ (clear) (add-fns '((add-fn - (3 <- add 1 2)) + ((integer 3) <- add (integer 1) (integer 2))) (main - (1 <- loadi 1) - (2 <- loadi 3) + ((integer 1) <- loadi 1) + ((integer 2) <- loadi 3) (add-fn)))) (run function*!main) ;? (prn memory*) @@ -25,12 +25,12 @@ (clear) (add-fns '((add-fn - (3 <- add 1 2) + ((integer 3) <- add (integer 1) (integer 2)) (reply) - (4 <- loadi 34)) + ((integer 4) <- loadi 34)) (main - (1 <- loadi 1) - (2 <- loadi 3) + ((integer 1) <- loadi 1) + ((integer 2) <- loadi 3) (add-fn)))) (run function*!main) ;? (prn memory*) @@ -41,15 +41,15 @@ (clear) (add-fns '((add-fn - (4 <- read) - (5 <- read) - (3 <- add 4 5) + ((integer 4) <- read) + ((integer 5) <- read) + ((integer 3) <- add (integer 4) (integer 5)) (reply) - (4 <- loadi 34)) + ((integer 4) <- loadi 34)) (main - (1 <- loadi 1) - (2 <- loadi 3) - (add-fn 1 2) + ((integer 1) <- loadi 1) + ((integer 2) <- loadi 3) + (add-fn (integer 1) (integer 2)) ))) (run function*!main) ;? (prn memory*) @@ -61,15 +61,15 @@ (clear) (add-fns '((add-fn - (4 <- read) - (5 <- read) - (6 <- add 4 5) - (reply 6) - (4 <- loadi 34)) + ((integer 4) <- read) + ((integer 5) <- read) + ((integer 6) <- add (integer 4) (integer 5)) + (reply (integer 6)) + ((integer 4) <- loadi 34)) (main - (1 <- loadi 1) - (2 <- loadi 3) - (3 <- add-fn 1 2)))) + ((integer 1) <- loadi 1) + ((integer 2) <- loadi 3) + ((integer 3) <- add-fn (integer 1) (integer 2))))) (run function*!main) ;? (prn memory*) (if (~iso memory* (obj 1 1 2 3 3 4 @@ -80,15 +80,15 @@ (clear) (add-fns '((add-fn - (4 <- read) - (5 <- read) - (6 <- add 4 5) - (reply 6 5) - (4 <- loadi 34)) + ((integer 4) <- read) + ((integer 5) <- read) + ((integer 6) <- add (integer 4) (integer 5)) + (reply (integer 6) (integer 5)) + ((integer 4) <- loadi 34)) (main - (1 <- loadi 1) - (2 <- loadi 3) - (3 7 <- add-fn 1 2)))) + ((integer 1) <- loadi 1) + ((integer 2) <- loadi 3) + ((integer 3) (integer 7) <- add-fn (integer 1) (integer 2))))) (run function*!main) ;? (prn memory*) (if (~iso memory* (obj 1 1 2 3 3 4 7 3 |