Add example file for compiling native modules (hello.so).

This commit is contained in:
Calvin Rose
2018-04-26 13:13:31 -04:00
parent 8b9bd41205
commit 99709a68fd
10 changed files with 370 additions and 11 deletions
+12 -9
View File
@@ -917,15 +917,18 @@ onvalue."
(error (string "circular dependency: module " path " is loading")))
(def check (get cache path))
(if check check (do
(def newenv (make-env))
(put cache path newenv)
(put loading path true)
(def f (file-open path))
(defn chunks [buf] (file-read f 1024 buf))
(run-context newenv chunks identity default-error-handler)
(file-close f)
(put loading path nil)
newenv)))))
(if (= ".so" (string-slice path -3 -1))
((native path))
(do
(def newenv (make-env))
(put cache path newenv)
(put loading path true)
(def f (file-open path))
(defn chunks [buf] (file-read f 1024 buf))
(run-context newenv chunks identity default-error-handler)
(file-close f)
(put loading path nil)
newenv)))))))
(defn import* [env path & args]
(def newenv (require path))