about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-26 10:13:34 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-26 10:13:34 -0800
commita9ae22a68b8e2791a30b7a11d55e90c20f26f5cf (patch)
treef6389c4802a842c26654abddea0f0c94b67af51e
parentb3bcdf5eb25486a6c642dc2c69fc9b98ef9ca926 (diff)
downloadmu-a9ae22a68b8e2791a30b7a11d55e90c20f26f5cf.tar.gz
631 - temporary: hook into underlying arc 'eval'
-rw-r--r--eval.mu9
-rw-r--r--mu.arc12
2 files changed, 21 insertions, 0 deletions
diff --git a/eval.mu b/eval.mu
new file mode 100644
index 00000000..66107fc4
--- /dev/null
+++ b/eval.mu
@@ -0,0 +1,9 @@
+; example of calling to underlying arc eval
+
+(function main [
+  (default-space:space-address <- new space:literal 30:literal)
+  (s:string-address <- new "(+ 1 1)")
+  (t:string-address <- $eval s:string-address)
+  (print-primitive-to-host t:string-address)
+  ; then you'll have to read off the characters starting at string-address 't'
+])
diff --git a/mu.arc b/mu.arc
index 3fe6423c..3f63f6de 100644
--- a/mu.arc
+++ b/mu.arc
@@ -768,6 +768,13 @@
                     )
                 $quit
                   (quit)
+                $wait-for-key-from-host
+                  (if ($.current-charterm)
+                        ($.charterm-read-key)
+                      ($.graphics-open?)
+                        ($.get-key-press Viewport))
+                $eval
+                  (new-string:repr:eval:read:to-arc-string (m arg.0))
 
                 ; user-defined functions
                 next-input
@@ -1043,6 +1050,11 @@
 ;?       (prn index " " repr.c) ;? 1
       (= (memory* (+ result 1 index)) c))))
 
+(def to-arc-string (string-address)
+  (let len (memory* string-address)
+    (string:map memory* (range (+ string-address 1)
+                               (+ string-address len)))))
+
 ;; desugar structured assembly based on blocks
 
 (def convert-braces (instrs)