aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2017-02-26 18:48:33 -0400
committerEduardo Julian2017-02-26 18:48:33 -0400
commit8fafa00056cbd4b0a3da77258e4d258a2f25767e (patch)
tree8c4d6e1f1acb199aced7608eb458f138c1a6d2f3
parent78e43d0be6fac5b8513e9dc4081a10391632feaa (diff)
- Implemented new IO procedures for JS.
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/compiler/js/proc/common.clj13
1 files changed, 12 insertions, 1 deletions
diff --git a/luxc/src/lux/compiler/js/proc/common.clj b/luxc/src/lux/compiler/js/proc/common.clj
index 942f24c79..a1b26a45b 100644
--- a/luxc/src/lux/compiler/js/proc/common.clj
+++ b/luxc/src/lux/compiler/js/proc/common.clj
@@ -392,6 +392,15 @@
=message (compile ?message)]
(return (str "LuxRT.error(" =message ")"))))
+(defn ^:private compile-io-exit [compile ?values special-args]
+ (|do [:let [(&/$Cons ?code (&/$Nil)) ?values]
+ =code (compile ?code)]
+ (return (str "(process && process.exit && process.exit(LuxRT.fromNumberI64(" =code ")))"))))
+
+(defn ^:private compile-io-current-time [compile ?values special-args]
+ (|do [:let [(&/$Nil) ?values]]
+ (return (str "LuxRT.toNumberI64(" "(new Date()).getTime()" ")"))))
+
(defn ^:private compile-atom-new [compile ?values special-args]
(|do [:let [(&/$Cons ?init (&/$Nil)) ?values]
=init (compile ?init)]
@@ -492,7 +501,9 @@
"io"
(case proc
"log" (compile-io-log compile ?values special-args)
- "error" (compile-io-error compile ?values special-args))
+ "error" (compile-io-error compile ?values special-args)
+ "exit" (compile-io-exit compile ?values special-args)
+ "current-time" (compile-io-current-time compile ?values special-args))
"text"
(case proc