fixed the tests, added str-ref macro

This commit is contained in:
Erik Svedäng 2016-03-18 00:02:23 +01:00
parent a6e052d98c
commit 673da910bb
3 changed files with 14 additions and 5 deletions

View File

@ -10,15 +10,18 @@
;; (println (str (B true)))
(defn f [s]
(println s))
;; (defn f [i]
;; (println (ref (itos (copy i)))))
^ann '(:fn ((:ref :int)) :void)
(defn f [x]
(println (str-ref (copy x))))
;;^ann '(:fn ((:ref (:Array :string))) :void)
(defn draws [state]
(domap f state))
(defn run-app [draw-fn]
(let [state [(copy "hej") (copy "på") (copy "dig!")]]
(let [state [10 20 30]]
(draw-fn &state)))
(defn app []

View File

@ -262,6 +262,9 @@
(for (i 0 (count xs))
(f (nth xs i))))
(defmacro str-ref (x)
(list 'ref (list 'str x)))
(defn second [xs]
(nth xs 1))

View File

@ -234,7 +234,10 @@
(match signature
(:fn ((:ref (:Array t))) :string) (instantiate-str-for-array c-func-name t)
(:fn ((:ref :int)) :string) (let [proto (str "API string " c-func-name "(int x)")
c (str proto " { return itos(x); }")]
{:proto proto :c c :deps ()})
(:fn (:int) :string) (let [proto (str "API string " c-func-name "(int x)")
c (str proto " { return itos(x); }")]
{:proto proto :c c :deps ()})