aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2021-05-31 13:02:33 -0400
committerEduardo Julian2021-05-31 13:02:33 -0400
commitd5c14e64940a7f6d0e2bb207f12f21fc7b95656d (patch)
tree5cd27e7656cb6b4c2a2388a124b51b3c9765b286
parent38c2eb5d39838e415a8c1f51b79099086b391a22 (diff)
"lux io current-time" is no longer an extension.
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux15
-rw-r--r--stdlib/source/lux/data/format/tar.lux2
-rw-r--r--stdlib/source/lux/time/instant.lux49
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux9
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux19
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux5
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux8
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux10
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux1
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux7
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux9
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux10
16 files changed, 56 insertions, 102 deletions
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux
index 39934dbb8..c9eed9489 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux
@@ -304,17 +304,6 @@
(_.INVOKESPECIAL $Error "<init>" string_method)
_.ATHROW)))
-(def: (io::exit codeI)
- (Unary Inst)
- (|>> codeI jvm_intI
- (_.INVOKESTATIC $System "exit" (type.method [(list type.int) type.void (list)]))
- _.NULL))
-
-(def: (io::current_time _)
- (Nullary Inst)
- (|>> (_.INVOKESTATIC $System "currentTimeMillis" (type.method [(list) type.long (list)]))
- (_.wrap type.long)))
-
(def: bundle::lux
Bundle
(|> (: Bundle bundle.empty)
@@ -376,9 +365,7 @@
(<| (bundle.prefix "io")
(|> (: Bundle bundle.empty)
(bundle.install "log" (unary io::log))
- (bundle.install "error" (unary io::error))
- (bundle.install "exit" (unary io::exit))
- (bundle.install "current-time" (nullary io::current_time)))))
+ (bundle.install "error" (unary io::error)))))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/data/format/tar.lux b/stdlib/source/lux/data/format/tar.lux
index f796b7a6c..7d4968239 100644
--- a/stdlib/source/lux/data/format/tar.lux
+++ b/stdlib/source/lux/data/format/tar.lux
@@ -235,7 +235,7 @@
(recur (dec end))
_
- (binary.slice 0 (dec end) string))))))))
+ (binary.slice 0 (inc end) string))))))))
(template [<type> <representation> <size> <exception> <in> <out> <writer> <parser> <none>]
[(abstract: #export <type>
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 48bc5414a..4658c75d4 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -1,5 +1,6 @@
(.module:
[lux #*
+ ["@" target]
[abstract
[equivalence (#+ Equivalence)]
[order (#+ Order)]
@@ -19,7 +20,8 @@
["." row]]]
[math
[number
- ["i" int]]]
+ ["i" int]
+ ["f" frac]]]
[type
abstract]]
["." // (#+ Time)
@@ -151,7 +153,43 @@
(def: #export now
(IO Instant)
- (io (..from_millis ("lux io current-time"))))
+ (io (..from_millis (for {@.old ("jvm invokestatic:java.lang.System:currentTimeMillis:")
+ @.jvm (|> ("jvm member invoke static" [] "java.lang.System" "currentTimeMillis" [])
+ (: (primitive "java.lang.Long"))
+ (:coerce Int))
+ @.js (let [date ("js object new" ("js constant" "Date") [])]
+ (|> ("js object do" "getTime" date [])
+ (:coerce Frac)
+ "lux f64 i64"))
+ @.python (let [time ("python import" "time")]
+ (|> ("python object do" "time" time [])
+ (:coerce Frac)
+ (f.* +1,000.0)
+ "lux f64 i64"))
+ @.lua (|> ("lua constant" "os.time")
+ "lua apply"
+ (:coerce Int)
+ (i.* +1,000))
+ @.ruby (let [% ("ruby constant" "Time")
+ % ("ruby object do" % "now")]
+ (|> ("ruby object do" % "to_f")
+ (:coerce Frac)
+ (f.* +1,000.0)
+ "lux f64 i64"))
+ @.php (|> ("php constant" "time")
+ "php apply"
+ (:coerce Int)
+ (i.* +1,000))
+ @.scheme (|> ("scheme constant" "current-second")
+ (:coerce Int)
+ (i.* +1,000)
+ ("scheme apply" ("scheme constant" "exact"))
+ ("scheme apply" ("scheme constant" "truncate")))
+ @.common_lisp (|> ("common_lisp constant" "get-universal-time")
+ "common_lisp apply"
+ (:coerce Int)
+ (i.* +1,000))
+ }))))
(template [<field> <type> <post_processing>]
[(def: #export (<field> instant)
@@ -189,6 +227,7 @@
(def: #export (from_date_time date time)
(-> Date Time Instant)
- (..from_millis
- (i.+ (i.* (date.to_days date) (duration.to_millis duration.day))
- (.int (//.to_millis time)))))
+ (|> (date.to_days date)
+ (i.* (duration.to_millis duration.day))
+ (i.+ (.int (//.to_millis time)))
+ ..from_millis))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux
index 4e6a9f7ff..17c27fe4f 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux
@@ -238,8 +238,7 @@
(|> ///bundle.empty
(///bundle.install "log" (unary Text Any))
(///bundle.install "error" (unary Text Nothing))
- (///bundle.install "exit" (unary Int Nothing))
- (///bundle.install "current-time" (nullary Int)))))
+ (///bundle.install "exit" (unary Int Nothing)))))
(def: I64* (type (I64 Any)))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux
index b47bade2d..d1ad7bd99 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux
@@ -156,8 +156,7 @@
(def: (io//log! message)
(Unary (Expression Any))
- (_.progn (list (_.pprint/1 message)
- ## (_.write-line/1 message)
+ (_.progn (list (_.write-line/1 message)
//runtime.unit)))
(def: io_procs
@@ -166,7 +165,6 @@
(|> /.empty
(/.install "log" (unary ..io//log!))
(/.install "error" (unary _.error/1))
- ## (/.install "current-time" (nullary (function.constant (//runtime.io//current_time //runtime.unit))))
)))
(def: #export bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
index ca0e8daa9..deffe31d8 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
@@ -90,12 +90,6 @@
(//runtime.io//log messageG)
//runtime.unit))
-(def: (io//current_time _)
- (Nullary Expression)
- (|> (_.new (_.var "Date") (list))
- (_.do "getTime" (list))
- //runtime.i64//from_number))
-
## TODO: Get rid of this ASAP
(def: lux::syntax_char_case!
(..custom [($_ <>.and
@@ -183,8 +177,7 @@
(<| (/.prefix "io")
(|> /.empty
(/.install "log" (unary io//log))
- (/.install "error" (unary //runtime.io//error))
- (/.install "current-time" (nullary io//current_time)))))
+ (/.install "error" (unary //runtime.io//error)))))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux
index a9251f4d6..24f82d1ef 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux
@@ -396,29 +396,12 @@
(_.invokespecial ..$Error "<init>" ..string-method)
_.athrow))
-(def: exit-method (type.method [(list type.int) type.void (list)]))
-(def: (io::exit codeG)
- (Unary (Bytecode Any))
- ($_ _.compose
- codeG ..jvm-int
- (_.invokestatic ..$System "exit" ..exit-method)
- _.aconst-null))
-
-(def: time-method (type.method [(list) type.long (list)]))
-(def: (io::current-time _)
- (Nullary (Bytecode Any))
- ($_ _.compose
- (_.invokestatic ..$System "currentTimeMillis" ..time-method)
- (///value.wrap type.long)))
-
(def: bundle::io
Bundle
(<| (/////bundle.prefix "io")
(|> (: Bundle /////bundle.empty)
(/////bundle.install "log" (unary ..io::log))
- (/////bundle.install "error" (unary ..io::error))
- (/////bundle.install "exit" (unary ..io::exit))
- (/////bundle.install "current-time" (nullary ..io::current-time)))))
+ (/////bundle.install "error" (unary ..io::error)))))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
index 33a952596..b22dd6d53 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
@@ -167,10 +167,7 @@
(<| (/.prefix "io")
(|> /.empty
(/.install "log" (unary ..io//log!))
- (/.install "error" (unary (!unary "error")))
- (/.install "current-time" (nullary (function.constant (|> (_.var "os.time")
- (_.apply/* (list))
- (_.* (_.int +1,000)))))))))
+ (/.install "error" (unary (!unary "error"))))))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux
index 19e8c8e12..3784c001c 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux
@@ -173,18 +173,12 @@
(/.install "clip" (trinary ..text//clip))
)))
-(def: io//current-time
- (Nullary Expression)
- (|>> _.time/0
- (_.* (_.int +1,000))))
-
(def: io_procs
Bundle
(<| (/.prefix "io")
(|> /.empty
(/.install "log" (unary //runtime.io//log!))
- (/.install "error" (unary //runtime.io//throw!))
- (/.install "current-time" (nullary ..io//current-time)))))
+ (/.install "error" (unary //runtime.io//throw!)))))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
index d7133aa70..66e09f33b 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
@@ -157,8 +157,7 @@
(<| (/.prefix "io")
(|> /.empty
(/.install "log" (unary //runtime.io//log!))
- (/.install "error" (unary //runtime.io//throw!))
- (/.install "current-time" (nullary (function.constant (//runtime.io//current_time! //runtime.unit)))))))
+ (/.install "error" (unary //runtime.io//throw!)))))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
index 39ba71730..030b3b239 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
@@ -166,21 +166,13 @@
(Unary Expression)
_.raise)
-(def: (io//current_time! _)
- (Nullary Expression)
- (|> (_.local "Time")
- (_.do "now" (list))
- (_.do "to_f" (list))
- (_.* (_.float +1000.0))
- (_.do "to_i" (list))))
-
(def: io_procs
Bundle
(<| (/.prefix "io")
(|> /.empty
(/.install "log" (unary ..io//log!))
(/.install "error" (unary ..io//error!))
- (/.install "current-time" (nullary ..io//current_time!)))))
+ )))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux
index 71a122eff..4f1258794 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux
@@ -160,7 +160,6 @@
(|> /.empty
(/.install "log" (unary ..io//log!))
(/.install "error" (unary _.raise/1))
- (/.install "current-time" (nullary (function.constant (//runtime.io//current_time //runtime.unit))))
)))
(def: #export bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux
index 750688dd6..574995de9 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux
@@ -123,9 +123,7 @@
(|> bundle.empty
(bundle.install "log" (unary (|>> _.print/1 ..void)))
(bundle.install "error" (unary _.error/1))
- (bundle.install "exit" (unary ///runtime.io//exit))
- (bundle.install "current-time" (nullary (function (_ _)
- (///runtime.io//current-time ///runtime.unit)))))))
+ )))
(def: #export bundle
Bundle
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux
index cc50cc49f..fd7ffc48b 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux
@@ -266,14 +266,9 @@
(_.call/* (_.var "excl:exit") (list code)))
(_.call/* (_.var "cl-user::quit") (list code)))))
-(runtime: (io//current_time _)
- (_.*/2 [(_.int +1,000)
- (_.get-universal-time/0 [])]))
-
(def: runtime//io
(List (Expression Any))
- (list @io//exit
- @io//current_time))
+ (list @io//exit))
(def: runtime
(_.progn ($_ list\compose
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
index ec8ff641f..f12c8f08b 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
@@ -190,20 +190,11 @@
(runtime: (io//throw! message)
(_.raise (_.Exception/1 message)))
-(runtime: (io//current_time! _)
- ($_ _.then
- (_.import "time")
- (_.return (|> (_.var "time")
- (_.do "time" (list))
- (_.* (_.int +1,000))
- _.int/1))))
-
(def: runtime//io
(Statement Any)
($_ _.then
@io//log!
@io//throw!
- @io//current_time!
))
(def: last_index
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux
index f27dc1154..612cb3153 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux
@@ -343,15 +343,6 @@
@array//write
))
-(runtime: (io//current_time _)
- (|> (_.apply/0 (_.var "current-second"))
- (_.*/2 (_.int +1,000))
- _.exact/1
- _.truncate/1))
-
-(def: runtime//io
- (_.begin (list @io//current_time)))
-
(def: runtime
Computation
(_.begin (list @slice
@@ -361,7 +352,6 @@
runtime//f64
runtime//text
runtime//array
- runtime//io
)))
(def: #export generate