This commit is contained in:
Kartik K. Agaram 2014-07-06 01:41:37 -07:00
parent e74ff41321
commit c72d831021
3 changed files with 27 additions and 11 deletions

22
mu.arc
View File

@ -1,5 +1,12 @@
(= types* (table))
(= memory* (table))
(def clear ()
(= types* (table))
(= memory* (table))
(= function* (table)))
(clear)
(def add-fns (fns)
(each (name . body) fns
(= function*.name body)))
(def run (instrs)
(each instr instrs
@ -12,9 +19,14 @@
add
(= memory*.oarg1
(+ memory*.arg1 memory*.arg2))
; else
(prn "aaa") ; user-defined functions go here
))))
(each file (cut argv 1)
;? (prn file)
(run readfile.file)
(awhen cdr.argv
(each file it
;? (prn file)
(add-fns readfile.file))
;? (prn function*)
(run function*!main)
(prn memory*))

View File

@ -1,8 +1,10 @@
(load "mu.arc")
(run '(
(clear)
(add-fns '((test1
(1 <- loadi 1)
(2 <- loadi 3)
(3 <- add 1 2)))
(3 <- add 1 2))))
(run function*!test1)
(if (~iso memory* (obj 1 1 2 3 3 4))
(prn "F - load and add instructions work"))

10
x.mu
View File

@ -1,4 +1,6 @@
(1 <- loadi 1)
(2 <- loadi 3)
(3 <- add 1 2)
(prn 3)
(main
(1 <- loadi 1)
(2 <- loadi 3)
(3 <- add 1 2)
(x <- prn a)
)