diff options
author | Eduardo Julian | 2021-05-24 19:29:13 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-05-24 19:29:13 -0400 |
commit | da27db478b368724ee4659eb674dcdbeb2cd8747 (patch) | |
tree | c1c5ef50644fa78ea899ac8c0afa1e234cd03b26 | |
parent | 1ffd2dd7e37d3be90522dfe768226334f60577f5 (diff) |
Re-named lux/host to lux/ffi.
54 files changed, 381 insertions, 424 deletions
diff --git a/stdlib/source/lux/control/concurrency/atom.lux b/stdlib/source/lux/control/concurrency/atom.lux index f8a95a41a..e3b711785 100644 --- a/stdlib/source/lux/control/concurrency/atom.lux +++ b/stdlib/source/lux/control/concurrency/atom.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] ["@" target] [abstract [monad (#+ do)]] @@ -14,7 +14,7 @@ [type abstract]]) -(with_expansions [<jvm> (as_is (host.import: (java/util/concurrent/atomic/AtomicReference a) +(with_expansions [<jvm> (as_is (ffi.import: (java/util/concurrent/atomic/AtomicReference a) ["#::." (new [a]) (get [] a) diff --git a/stdlib/source/lux/control/concurrency/thread.lux b/stdlib/source/lux/control/concurrency/thread.lux index d07edd0d8..4afa4dde3 100644 --- a/stdlib/source/lux/control/concurrency/thread.lux +++ b/stdlib/source/lux/control/concurrency/thread.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract ["." monad (#+ do)]] [control @@ -17,26 +17,26 @@ [// ["." atom (#+ Atom)]]) -(with_expansions [<jvm> (as_is (host.import: java/lang/Object) +(with_expansions [<jvm> (as_is (ffi.import: java/lang/Object) - (host.import: java/lang/Runtime + (ffi.import: java/lang/Runtime ["#::." (#static getRuntime [] java/lang/Runtime) (availableProcessors [] int)]) - (host.import: java/lang/Runnable) + (ffi.import: java/lang/Runnable) - (host.import: java/util/concurrent/TimeUnit + (ffi.import: java/util/concurrent/TimeUnit ["#::." (#enum MILLISECONDS)]) - (host.import: java/util/concurrent/Executor + (ffi.import: java/util/concurrent/Executor ["#::." (execute [java/lang/Runnable] #io void)]) - (host.import: (java/util/concurrent/ScheduledFuture a)) + (ffi.import: (java/util/concurrent/ScheduledFuture a)) - (host.import: java/util/concurrent/ScheduledThreadPoolExecutor + (ffi.import: java/util/concurrent/ScheduledThreadPoolExecutor ["#::." (new [int]) (schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object))]))] @@ -44,11 +44,11 @@ @.jvm (as_is <jvm>) @.js - (as_is (host.import: (setTimeout [host.Function host.Number] #io Any))) + (as_is (ffi.import: (setTimeout [ffi.Function ffi.Number] #io Any))) @.python - (host.import: threading/Timer - (new [host.Float host.Function]) + (ffi.import: threading/Timer + (new [ffi.Float ffi.Function]) (start [] #io #? Any))} ## Default @@ -84,7 +84,7 @@ (def: #export (schedule milli_seconds action) (-> Nat (IO Any) (IO Any)) (for {@.old - (let [runnable (host.object [] [java/lang/Runnable] + (let [runnable (ffi.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void (io.run action)))] @@ -94,7 +94,7 @@ runner))) @.jvm - (let [runnable (host.object [] [java/lang/Runnable] + (let [runnable (ffi.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void (io.run action)))] @@ -104,12 +104,12 @@ runner))) @.js - (..setTimeout [(host.closure [] (io.run action)) + (..setTimeout [(ffi.closure [] (io.run action)) (n.frac milli_seconds)]) @.python (do io.monad - [_ (|> (host.lambda [] (io.run action)) + [_ (|> (ffi.lambda [] (io.run action)) [(|> milli_seconds n.frac (f./ +1,000.0))] threading/Timer::new (threading/Timer::start []))] diff --git a/stdlib/source/lux/data/binary.lux b/stdlib/source/lux/data/binary.lux index 40a7b3fc7..ce8deb1d2 100644 --- a/stdlib/source/lux/data/binary.lux +++ b/stdlib/source/lux/data/binary.lux @@ -1,7 +1,7 @@ (.module: [lux (#- i64) ["@" target] - ["." host] + ["." ffi] [abstract [monad (#+ do)] [equivalence (#+ Equivalence)] @@ -37,15 +37,15 @@ [inverted_slice] ) -(with_expansions [<jvm> (as_is (type: #export Binary (host.type [byte])) +(with_expansions [<jvm> (as_is (type: #export Binary (ffi.type [byte])) - (host.import: java/lang/Object) + (ffi.import: java/lang/Object) - (host.import: java/lang/System + (ffi.import: java/lang/System ["#::." (#static arraycopy [java/lang/Object int java/lang/Object int int] #try void)]) - (host.import: java/util/Arrays + (ffi.import: java/util/Arrays ["#::." (#static copyOfRange [[byte] int int] [byte]) (#static equals [[byte] [byte]] boolean)]) @@ -56,25 +56,25 @@ (def: i64 (-> (primitive "java.lang.Byte") I64) - (|>> host.byte_to_long (:coerce I64) (i64.and ..byte_mask))) + (|>> ffi.byte_to_long (:coerce I64) (i64.and ..byte_mask))) (def: byte (-> (I64 Any) (primitive "java.lang.Byte")) (for {@.old - (|>> .int host.long_to_byte) + (|>> .int ffi.long_to_byte) @.jvm - (|>> .int (:coerce (primitive "java.lang.Long")) host.long_to_byte)})))] + (|>> .int (:coerce (primitive "java.lang.Long")) ffi.long_to_byte)})))] (for {@.old (as_is <jvm>) @.jvm (as_is <jvm>) @.js - (as_is (host.import: ArrayBuffer - (new [host.Number])) + (as_is (ffi.import: ArrayBuffer + (new [ffi.Number])) - (host.import: Uint8Array + (ffi.import: Uint8Array (new [ArrayBuffer]) - (length host.Number)) + (length ffi.Number)) (type: #export Binary Uint8Array)) @@ -87,18 +87,18 @@ (as_is (type: #export Binary (primitive "bytevector")) - (host.import: (make-bytevector [Nat] Binary)) - (host.import: (bytevector-u8-ref [Binary Nat] I64)) - (host.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) - (host.import: (bytevector-length [Binary] Nat)))} + (ffi.import: (make-bytevector [Nat] Binary)) + (ffi.import: (bytevector-u8-ref [Binary Nat] I64)) + (ffi.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) + (ffi.import: (bytevector-length [Binary] Nat)))} ## Default (type: #export Binary (array.Array (I64 Any))))) (template: (!size binary) - (for {@.old (host.array_length binary) - @.jvm (host.array_length binary) + (for {@.old (ffi.array_length binary) + @.jvm (ffi.array_length binary) @.js (|> binary @@ -117,8 +117,8 @@ (array.size binary))) (template: (!read idx binary) - (for {@.old (..i64 (host.array_read idx binary)) - @.jvm (..i64 (host.array_read idx binary)) + (for {@.old (..i64 (ffi.array_read idx binary)) + @.jvm (..i64 (ffi.array_read idx binary)) @.js (|> binary @@ -150,8 +150,8 @@ (:coerce ..Binary))) (template: (!write idx value binary) - (for {@.old (host.array_write idx (..byte value) binary) - @.jvm (host.array_write idx (..byte value) binary) + (for {@.old (ffi.array_write idx (..byte value) binary) + @.jvm (ffi.array_write idx (..byte value) binary) @.js (!!write .Frac n.frac "js array write" idx value binary) @.python (!!write (I64 Any) (:coerce (I64 Any)) "python array write" idx value binary) @@ -167,14 +167,14 @@ (def: #export create (-> Nat Binary) - (for {@.old (|>> (host.array byte)) - @.jvm (|>> (host.array byte)) + (for {@.old (|>> (ffi.array byte)) + @.jvm (|>> (ffi.array byte)) @.js (|>> n.frac ArrayBuffer::new Uint8Array::new) @.python - (|>> ("python apply" (:coerce host.Function ("python constant" "bytearray"))) + (|>> ("python apply" (:coerce ffi.Function ("python constant" "bytearray"))) (:coerce Binary)) @.scheme @@ -283,17 +283,17 @@ (def: (= reference sample) (with_expansions [<jvm> (java/util/Arrays::equals reference sample)] - (for {@.old <jvm> - @.jvm <jvm>} - (let [limit (!size reference)] - (and (n.= limit - (!size sample)) - (loop [idx 0] - (if (n.< limit idx) - (and (n.= (!read idx reference) - (!read idx sample)) - (recur (inc idx))) - true)))))))) + (for {@.old <jvm> + @.jvm <jvm>} + (let [limit (!size reference)] + (and (n.= limit + (!size sample)) + (loop [idx 0] + (if (n.< limit idx) + (and (n.= (!read idx reference) + (!read idx sample)) + (recur (inc idx))) + true)))))))) (for {@.old (as_is) @.jvm (as_is)} diff --git a/stdlib/source/lux/data/text/buffer.lux b/stdlib/source/lux/data/text/buffer.lux index fe648023d..fb90ab15e 100644 --- a/stdlib/source/lux/data/text/buffer.lux +++ b/stdlib/source/lux/data/text/buffer.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] ["@" target] [control ["." function]] diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux index a081233c9..7445d5ebc 100644 --- a/stdlib/source/lux/data/text/encoding.lux +++ b/stdlib/source/lux/data/text/encoding.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract [codec (#+ Codec)]] [control @@ -169,7 +169,7 @@ (|>> :representation)) ) -(with_expansions [<jvm> (as_is (host.import: java/lang/String +(with_expansions [<jvm> (as_is (ffi.import: java/lang/String ["#::." (new [[byte] java/lang/String]) (getBytes [java/lang/String] [byte])]))] @@ -177,42 +177,42 @@ @.jvm (as_is <jvm>) @.js - (as_is (host.import: Uint8Array) + (as_is (ffi.import: Uint8Array) ## On Node - (host.import: Buffer - (#static from #as from|encode [host.String host.String] Buffer) + (ffi.import: Buffer + (#static from #as from|encode [ffi.String ffi.String] Buffer) (#static from #as from|decode [Uint8Array] Buffer) - (toString [host.String] host.String)) + (toString [ffi.String] ffi.String)) ## On the browser - (host.import: TextEncoder - (new [host.String]) - (encode [host.String] Uint8Array)) + (ffi.import: TextEncoder + (new [ffi.String]) + (encode [ffi.String] Uint8Array)) - (host.import: TextDecoder - (new [host.String]) - (decode [Uint8Array] host.String))) + (ffi.import: TextDecoder + (new [ffi.String]) + (decode [Uint8Array] ffi.String))) @.ruby - (as_is (host.import: String #as RubyString + (as_is (ffi.import: String #as RubyString (encode [Text] RubyString) (force_encoding [Text] Text) (bytes [] Binary)) - (host.import: Array #as RubyArray + (ffi.import: Array #as RubyArray (pack [Text] RubyString))) @.php - (as_is (host.import: Almost_Binary) - (host.import: (unpack [host.String host.String] Almost_Binary)) - (host.import: (array_values [Almost_Binary] Binary)) + (as_is (ffi.import: Almost_Binary) + (ffi.import: (unpack [ffi.String ffi.String] Almost_Binary)) + (ffi.import: (array_values [Almost_Binary] Binary)) (def: php_byte_array_format "C*")) @.scheme ## https://srfi.schemers.org/srfi-140/srfi-140.html - (as_is (host.import: (string->utf8 [Text] Binary)) - (host.import: (utf8->string [Binary] Text)))} + (as_is (ffi.import: (string->utf8 [Text] Binary)) + (ffi.import: (utf8->string [Binary] Text)))} (as_is))) (def: (utf8\encode value) @@ -229,10 +229,10 @@ (java/lang/String::getBytes (..name ..utf_8) value) @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (:coerce Binary ("js object do" "getBytes" value ["utf8"])) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|encode [value "utf8"]) ## This coercion is valid as per NodeJS's documentation: ## https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays @@ -271,12 +271,12 @@ @.jvm <jvm> @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (|> ("js object new" ("js constant" "java.lang.String") [value "utf8"]) (:coerce Text) #try.Success) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|decode [value]) (Buffer::toString ["utf8"]) #try.Success) @@ -287,7 +287,7 @@ #try.Success)) @.python - (host.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) + (ffi.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) @.lua (#try.Success ("lua utf8 decode" value)) diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux index d5bbd3be2..a076942bc 100644 --- a/stdlib/source/lux/debug.lux +++ b/stdlib/source/lux/debug.lux @@ -2,7 +2,7 @@ [lux (#- type) ["@" target] ["." type] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monad (#+ do)]] [control @@ -66,23 +66,23 @@ @.js (as_is (import: JSON - (#static stringify [.Any] host.String)) + (#static stringify [.Any] ffi.String)) (import: Array - (#static isArray [.Any] host.Boolean))) + (#static isArray [.Any] ffi.Boolean))) @.python (as_is (type: PyType (primitive "python_type")) (import: (type [.Any] PyType)) - (import: (str [.Any] host.String))) + (import: (str [.Any] ffi.String))) @.lua - (as_is (import: (type [.Any] host.String)) - (import: (tostring [.Any] host.String)) + (as_is (import: (type [.Any] ffi.String)) + (import: (tostring [.Any] ffi.String)) (import: math - (#static type [.Any] #? host.String))) + (#static type [.Any] #? ffi.String))) @.ruby (as_is (import: Class) @@ -91,8 +91,8 @@ (type [] Class))) @.php - (as_is (import: (gettype [.Any] host.String)) - (import: (strval [.Any] host.String))) + (as_is (import: (gettype [.Any] ffi.String)) + (import: (strval [.Any] ffi.String))) @.scheme (as_is (import: (boolean? [.Any] Bit)) @@ -120,7 +120,7 @@ Inspector (with_expansions [<jvm> (let [object (:coerce java/lang/Object value)] (`` (<| (~~ (template [<class> <processing>] - [(case (host.check <class> object) + [(case (ffi.check <class> object) (#.Some value) (`` (|> value (~~ (template.splice <processing>)))) #.None)] @@ -130,12 +130,12 @@ [java/lang/Long [(:coerce .Int) %.int]] [java/lang/Number [java/lang/Number::doubleValue %.frac]] )) - (case (host.check [java/lang/Object] object) + (case (ffi.check [java/lang/Object] object) (#.Some value) (let [value (:coerce (array.Array java/lang/Object) value)] (case (array.read 0 value) (^multi (#.Some tag) - [(host.check java/lang/Integer tag) + [(ffi.check java/lang/Integer tag) (#.Some tag)] [[(array.read 1 value) (array.read 2 value)] @@ -157,7 +157,7 @@ @.jvm <jvm> @.js - (case (host.type_of value) + (case (ffi.type_of value) (^template [<type_of> <then>] [<type_of> (`` (|> value (~~ (template.splice <then>))))]) diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/ffi.js.lux index 8bfe8cc94..8bfe8cc94 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/ffi.js.lux diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/ffi.jvm.lux index ad087f95b..ad087f95b 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/ffi.jvm.lux diff --git a/stdlib/source/lux/host.lua.lux b/stdlib/source/lux/ffi.lua.lux index 785ca82d6..785ca82d6 100644 --- a/stdlib/source/lux/host.lua.lux +++ b/stdlib/source/lux/ffi.lua.lux diff --git a/stdlib/source/lux/host.old.lux b/stdlib/source/lux/ffi.old.lux index 3a69f2464..3a69f2464 100644 --- a/stdlib/source/lux/host.old.lux +++ b/stdlib/source/lux/ffi.old.lux diff --git a/stdlib/source/lux/host.php.lux b/stdlib/source/lux/ffi.php.lux index ac0daf9c5..ac0daf9c5 100644 --- a/stdlib/source/lux/host.php.lux +++ b/stdlib/source/lux/ffi.php.lux diff --git a/stdlib/source/lux/host.py.lux b/stdlib/source/lux/ffi.py.lux index ed67b3705..ed67b3705 100644 --- a/stdlib/source/lux/host.py.lux +++ b/stdlib/source/lux/ffi.py.lux diff --git a/stdlib/source/lux/host.rb.lux b/stdlib/source/lux/ffi.rb.lux index 63f14e8a3..63f14e8a3 100644 --- a/stdlib/source/lux/host.rb.lux +++ b/stdlib/source/lux/ffi.rb.lux diff --git a/stdlib/source/lux/host.scm.lux b/stdlib/source/lux/ffi.scm.lux index 1dde8ab69..1dde8ab69 100644 --- a/stdlib/source/lux/host.scm.lux +++ b/stdlib/source/lux/ffi.scm.lux diff --git a/stdlib/source/lux/target/jvm/bytecode.lux b/stdlib/source/lux/target/jvm/bytecode.lux index a319ef2a7..d79ba042a 100644 --- a/stdlib/source/lux/target/jvm/bytecode.lux +++ b/stdlib/source/lux/target/jvm/bytecode.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type int) - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monoid (#+ Monoid)] ["." monad (#+ Monad do)]] @@ -507,18 +507,18 @@ (def: float_bits (-> java/lang/Float Int) (|>> java/lang/Float::floatToRawIntBits - host.int_to_long + ffi.int_to_long (:coerce Int))) (def: negative_zero_float_bits - (|> -0.0 (:coerce java/lang/Double) host.double_to_float ..float_bits)) + (|> -0.0 (:coerce java/lang/Double) ffi.double_to_float ..float_bits)) (def: #export (float value) (-> java/lang/Float (Bytecode Any)) (if (i.= ..negative_zero_float_bits (..float_bits value)) (..arbitrary_float value) - (case (|> value host.float_to_double (:coerce Frac)) + (case (|> value ffi.float_to_double (:coerce Frac)) (^template [<special> <instruction>] [<special> (..bytecode $0 $1 @_ <instruction> [])]) ([+0.0 _.fconst_0] diff --git a/stdlib/source/lux/target/jvm/constant.lux b/stdlib/source/lux/target/jvm/constant.lux index fbfbfebb3..5d44dfbd6 100644 --- a/stdlib/source/lux/target/jvm/constant.lux +++ b/stdlib/source/lux/target/jvm/constant.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["@" target] [abstract [monad (#+ do)] @@ -118,7 +118,7 @@ (~~ (template.splice <writer>)))))] [integer_writer Integer [] [binaryF.bits/32]] - [float_writer Float [java/lang/Float::floatToRawIntBits host.int_to_long (:coerce I64)] [i32.i32 binaryF.bits/32]] + [float_writer Float [java/lang/Float::floatToRawIntBits ffi.int_to_long (:coerce I64)] [i32.i32 binaryF.bits/32]] [long_writer Long [] [binaryF.bits/64]] [double_writer Double [java/lang/Double::doubleToRawLongBits] [binaryF.bits/64]] [string_writer String [] [//index.writer]] diff --git a/stdlib/source/lux/target/jvm/constant/pool.lux b/stdlib/source/lux/target/jvm/constant/pool.lux index 95dac3986..8f378ed00 100644 --- a/stdlib/source/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/lux/target/jvm/constant/pool.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] [abstract [equivalence (#+ Equivalence)] [monad (#+ Monad do)]] diff --git a/stdlib/source/lux/target/jvm/loader.lux b/stdlib/source/lux/target/jvm/loader.lux index a6a236e47..755f9526e 100644 --- a/stdlib/source/lux/target/jvm/loader.lux +++ b/stdlib/source/lux/target/jvm/loader.lux @@ -16,7 +16,7 @@ [collection ["." array] ["." dictionary (#+ Dictionary)]]] - ["." host (#+ import: object do_to)]]) + ["." ffi (#+ import: object do_to)]]) (type: #export Library (Atom (Dictionary Text Binary))) @@ -65,17 +65,17 @@ (with_expansions [<elemT> (as_is (java/lang/Class java/lang/Object))] (def: java/lang/ClassLoader::defineClass java/lang/reflect/Method - (let [signature (|> (host.array <elemT> 4) - (host.array_write 0 (:coerce <elemT> - (host.class_for java/lang/String))) - (host.array_write 1 (java/lang/Object::getClass (host.array byte 0))) - (host.array_write 2 (:coerce <elemT> - (java/lang/Integer::TYPE))) - (host.array_write 3 (:coerce <elemT> - (java/lang/Integer::TYPE))))] + (let [signature (|> (ffi.array <elemT> 4) + (ffi.array_write 0 (:coerce <elemT> + (ffi.class_for java/lang/String))) + (ffi.array_write 1 (java/lang/Object::getClass (ffi.array byte 0))) + (ffi.array_write 2 (:coerce <elemT> + (java/lang/Integer::TYPE))) + (ffi.array_write 3 (:coerce <elemT> + (java/lang/Integer::TYPE))))] (do_to (java/lang/Class::getDeclaredMethod "defineClass" signature - (host.class_for java/lang/ClassLoader)) + (ffi.class_for java/lang/ClassLoader)) (java/lang/reflect/AccessibleObject::setAccessible true))))) (def: #export (define class_name bytecode loader) @@ -87,12 +87,12 @@ (:coerce java/lang/Object (|> 0 (:coerce (primitive "java.lang.Long")) - host.long_to_int)) + ffi.long_to_int)) (:coerce java/lang/Object (|> bytecode binary.size (:coerce (primitive "java.lang.Long")) - host.long_to_int))))] + ffi.long_to_int))))] (java/lang/reflect/Method::invoke loader signature java/lang/ClassLoader::defineClass))) (def: #export (new_library _) diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux index bb0a388e9..07afd5df0 100644 --- a/stdlib/source/lux/target/jvm/reflection.lux +++ b/stdlib/source/lux/target/jvm/reflection.lux @@ -1,6 +1,6 @@ (.module: [lux (#- type) - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["." type] [abstract ["." monad (#+ do)]] @@ -142,7 +142,7 @@ (-> (-> java/lang/reflect/Type (Try (/.Type Parameter))) java/lang/reflect/Type (Try (/.Type Class))) - (<| (case (host.check java/lang/Class reflection) + (<| (case (ffi.check java/lang/Class reflection) (#.Some class) (let [class_name (|> class (:coerce (java/lang/Class java/lang/Object)) @@ -163,10 +163,10 @@ (exception.throw ..not_a_class reflection) (#try.Success (/.class class_name (list)))))) _) - (case (host.check java/lang/reflect/ParameterizedType reflection) + (case (ffi.check java/lang/reflect/ParameterizedType reflection) (#.Some reflection) (let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)] - (case (host.check java/lang/Class raw) + (case (ffi.check java/lang/Class raw) (#.Some raw) (do {! try.monad} [paramsT (|> reflection @@ -186,11 +186,11 @@ (def: #export (parameter reflection) (-> java/lang/reflect/Type (Try (/.Type Parameter))) - (<| (case (host.check java/lang/reflect/TypeVariable reflection) + (<| (case (ffi.check java/lang/reflect/TypeVariable reflection) (#.Some reflection) (#try.Success (/.var (java/lang/reflect/TypeVariable::getName reflection))) _) - (case (host.check java/lang/reflect/WildcardType reflection) + (case (ffi.check java/lang/reflect/WildcardType reflection) (#.Some reflection) ## TODO: Instead of having single lower/upper bounds, should ## allow for multiple ones. @@ -198,7 +198,7 @@ (array.read 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))] (^template [<pattern> <kind>] [<pattern> - (case (host.check java/lang/reflect/GenericArrayType bound) + (case (ffi.check java/lang/reflect/GenericArrayType bound) (#.Some _) ## TODO: Array bounds should not be "erased" as they ## are right now. @@ -221,7 +221,7 @@ (def: #export (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) - (<| (case (host.check java/lang/Class reflection) + (<| (case (ffi.check java/lang/Class reflection) (#.Some reflection) (let [class_name (|> reflection (:coerce (java/lang/Class java/lang/Object)) @@ -243,7 +243,7 @@ (<t>.run /parser.value (|> class_name //name.internal //name.read)) (#try.Success (/.class class_name (list))))))) _) - (case (host.check java/lang/reflect/GenericArrayType reflection) + (case (ffi.check java/lang/reflect/GenericArrayType reflection) (#.Some reflection) (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType @@ -256,7 +256,7 @@ (def: #export (return reflection) (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (as_is (..type reflection))] - (case (host.check java/lang/Class reflection) + (case (ffi.check java/lang/Class reflection) (#.Some class) (let [class_name (|> reflection (:coerce (java/lang/Class java/lang/Object)) @@ -358,7 +358,7 @@ (def: #export deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) (|>> array.to_list - (list.all (|>> (host.check java/lang/Deprecated))) + (list.all (|>> (ffi.check java/lang/Deprecated))) list.empty? not)) diff --git a/stdlib/source/lux/target/lua.lux b/stdlib/source/lux/target/lua.lux index 4213cd339..144fc2d7b 100644 --- a/stdlib/source/lux/target/lua.lux +++ b/stdlib/source/lux/target/lua.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Location Code int if cond function or and not let ^) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -27,21 +26,11 @@ [type abstract]]) -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (format text.new_line) - (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (|>> (format text.new_line) + (text.replace_all text.new_line nested_new_line)))) (def: input_separator ", ") diff --git a/stdlib/source/lux/target/php.lux b/stdlib/source/lux/target/php.lux index 9ef2511a7..5b976a325 100644 --- a/stdlib/source/lux/target/php.lux +++ b/stdlib/source/lux/target/php.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Location Code Global static int if cond or and not comment for) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -29,21 +28,11 @@ (def: input_separator ", ") (def: statement_suffix ";") -(.for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (.for {@.old (|>> (format text.new_line) - (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (|>> (format text.new_line) + (text.replace_all text.new_line nested_new_line)))) (def: block (-> Text Text) diff --git a/stdlib/source/lux/target/python.lux b/stdlib/source/lux/target/python.lux index 1ae1cca64..77cc7cf28 100644 --- a/stdlib/source/lux/target/python.lux +++ b/stdlib/source/lux/target/python.lux @@ -1,7 +1,7 @@ (.module: [lux (#- Location Code not or and list if cond int comment exec) ["@" target] - ["." host] + ["." ffi] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -30,8 +30,8 @@ (-> Text Text) (text.enclose ["(" ")"])) -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String +(for {@.old (as_is (ffi.import: java/lang/CharSequence) + (ffi.import: java/lang/String ["#::." (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} (as_is)) diff --git a/stdlib/source/lux/target/ruby.lux b/stdlib/source/lux/target/ruby.lux index 641cc8d2e..21a47c8d0 100644 --- a/stdlib/source/lux/target/ruby.lux +++ b/stdlib/source/lux/target/ruby.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Location Code static int if cond function or and not comment) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -29,21 +28,11 @@ (def: input_separator ", ") (def: statement_suffix ";") -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (format text.new_line) - (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (|>> (format text.new_line) + (text.replace_all text.new_line nested_new_line)))) (abstract: #export (Code brand) Text diff --git a/stdlib/source/lux/target/scheme.lux b/stdlib/source/lux/target/scheme.lux index 20bb08be3..408f1d9f1 100644 --- a/stdlib/source/lux/target/scheme.lux +++ b/stdlib/source/lux/target/scheme.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Code int or and if cond let) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)]] @@ -21,19 +20,10 @@ [type abstract]]) -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (text.replace_all text.new_line nested_new_line)))) + (text.replace_all text.new_line nested_new_line))) (abstract: #export (Code k) Text diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index 1b29ee2e1..4203516d4 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type Module primitive type char int) - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["." meta] [abstract ["." monad (#+ do)]] @@ -159,7 +159,7 @@ (list& class super_class super_interfaces))) ## TODO: Get rid of this template block and use the definition in -## lux/host.jvm.lux ASAP +## lux/ffi.jvm.lux ASAP (template [<name> <class>] [(def: #export <name> .Type (#.Primitive <class> #.Nil))] @@ -873,7 +873,7 @@ #.None (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers from_class)) - (#.Cons (:coerce java/lang/reflect/Type (host.class_for java/lang/Object)) + (#.Cons (:coerce java/lang/reflect/Type (ffi.class_for java/lang/Object)) (array.to_list (java/lang/Class::getGenericInterfaces from_class))) (array.to_list (java/lang/Class::getGenericInterfaces from_class))))))) diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index 96c39d8cb..12954ff51 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Definition) - ["." host (#+ import: do-to object)] + ["." ffi (#+ import: do-to object)] [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 3b12fe741..b6fb709fb 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -1,6 +1,6 @@ (.module: [lux (#- i64) - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monad (#+ do)]] [target diff --git a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux index d92d1e686..15552a656 100644 --- a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux @@ -1,7 +1,7 @@ (.module: [lux (#- Module Definition) [type (#+ :share)] - ["." host (#+ import: do_to)] + ["." ffi (#+ import: do_to)] [abstract ["." monad (#+ Monad do)]] [control @@ -106,8 +106,8 @@ (-> Context java/util/jar/Manifest) (let [manifest (java/util/jar/Manifest::new)] (exec (do_to (java/util/jar/Manifest::getMainAttributes manifest) - (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external)) - (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version)) + (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external)) + (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version)) manifest))) ## TODO: Delete ASAP @@ -124,10 +124,10 @@ content (!.use (\ artifact content) []) #let [class_path (format (runtime.class_name context) (get@ #static.artifact_extension static))]] (wrap (do_to sink - (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path)) - (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content))) - (java/io/Flushable::flush) - (java/util/zip/ZipOutputStream::closeEntry))))) + (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path)) + (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content))) + (java/io/Flushable::flush) + (java/util/zip/ZipOutputStream::closeEntry))))) (def: (write_module monad file_system static [module artifacts] sink) (All [!] @@ -164,6 +164,6 @@ sink (java/util/jar/JarOutputStream::new buffer (..manifest program))] sink (monad.fold ! (..write_module monad file_system static) sink order) #let [_ (do_to sink - (java/io/Flushable::flush) - (java/io/Closeable::close))]] + (java/io/Flushable::flush) + (java/io/Closeable::close))]] (wrap (java/io/ByteArrayOutputStream::toByteArray buffer)))) diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux index e5b17b7d6..9cf12bc5c 100644 --- a/stdlib/source/lux/world/console.lux +++ b/stdlib/source/lux/world/console.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] ["@" target] [abstract [monad (#+ do)]] diff --git a/stdlib/source/lux/world/db/jdbc/input.lux b/stdlib/source/lux/world/db/jdbc/input.lux index 625af00ba..f1183ab75 100644 --- a/stdlib/source/lux/world/db/jdbc/input.lux +++ b/stdlib/source/lux/world/db/jdbc/input.lux @@ -1,5 +1,6 @@ (.module: [lux (#- and int) + [ffi (#+ import:)] [control [functor (#+ Contravariant)] [monad (#+ Monad do)] @@ -8,8 +9,7 @@ ["." instant (#+ Instant)]] ["." io (#+ IO)] [world - [binary (#+ Binary)]] - [host (#+ import:)]]) + [binary (#+ Binary)]]]) (import: java/lang/String) diff --git a/stdlib/source/lux/world/db/jdbc/output.lux b/stdlib/source/lux/world/db/jdbc/output.lux index 08a74a4b0..66578ac8d 100644 --- a/stdlib/source/lux/world/db/jdbc/output.lux +++ b/stdlib/source/lux/world/db/jdbc/output.lux @@ -1,5 +1,6 @@ (.module: [lux (#- and int) + [ffi (#+ import:)] [control [functor (#+ Functor)] [apply (#+ Apply)] @@ -10,8 +11,7 @@ ["." instant (#+ Instant)]] ["." io (#+ IO)] [world - [binary (#+ Binary)]] - [host (#+ import:)]]) + [binary (#+ Binary)]]]) (import: java/lang/String) diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index 3b80a7ea8..48a024400 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] ["@" target] [abstract ["." monad (#+ Monad do)]] @@ -231,9 +231,9 @@ ["Instant" (%.instant instant)] ["Path" file])) - (host.import: java/lang/String) + (ffi.import: java/lang/String) - (`` (host.import: java/io/File + (`` (ffi.import: java/io/File ["#::." (new [java/lang/String]) (~~ (template [<name>] @@ -263,24 +263,24 @@ _ (wrap (exception.throw exception [path]))))) - (host.import: java/lang/AutoCloseable + (ffi.import: java/lang/AutoCloseable ["#::." (close [] #io #try void)]) - (host.import: java/io/OutputStream + (ffi.import: java/io/OutputStream ["#::." (write [[byte]] #io #try void) (flush [] #io #try void)]) - (host.import: java/io/FileOutputStream + (ffi.import: java/io/FileOutputStream ["#::." (new [java/io/File boolean] #io #try)]) - (host.import: java/io/InputStream + (ffi.import: java/io/InputStream ["#::." (read [[byte]] #io #try int)]) - (host.import: java/io/FileInputStream + (ffi.import: java/io/FileInputStream ["#::." (new [java/io/File] #io #try)]) @@ -444,45 +444,45 @@ @.jvm (as_is <for_jvm>) @.js - (as_is (host.import: Buffer + (as_is (ffi.import: Buffer (#static from [Binary] ..Buffer)) - (host.import: FileDescriptor) - - (host.import: Stats - (size host.Number) - (mtimeMs host.Number) - (isFile [] #io #try host.Boolean) - (isDirectory [] #io #try host.Boolean)) - - (host.import: FsConstants - (F_OK host.Number) - (R_OK host.Number) - (W_OK host.Number) - (X_OK host.Number)) + (ffi.import: FileDescriptor) + + (ffi.import: Stats + (size ffi.Number) + (mtimeMs ffi.Number) + (isFile [] #io #try ffi.Boolean) + (isDirectory [] #io #try ffi.Boolean)) + + (ffi.import: FsConstants + (F_OK ffi.Number) + (R_OK ffi.Number) + (W_OK ffi.Number) + (X_OK ffi.Number)) - (host.import: Fs + (ffi.import: Fs (constants FsConstants) - (readFileSync [host.String] #io #try Binary) - (appendFileSync [host.String Buffer] #io #try Any) - (writeFileSync [host.String Buffer] #io #try Any) - (statSync [host.String] #io #try Stats) - (accessSync [host.String host.Number] #io #try Any) - (renameSync [host.String host.String] #io #try Any) - (utimesSync [host.String host.Number host.Number] #io #try Any) - (unlink [host.String] #io #try Any) - (readdirSync [host.String] #io #try (Array host.String)) - (mkdirSync [host.String] #io #try Any) - (rmdirSync [host.String] #io #try Any)) - - (host.import: JsPath - (sep host.String) - (basename [host.String] host.String)) + (readFileSync [ffi.String] #io #try Binary) + (appendFileSync [ffi.String Buffer] #io #try Any) + (writeFileSync [ffi.String Buffer] #io #try Any) + (statSync [ffi.String] #io #try Stats) + (accessSync [ffi.String ffi.Number] #io #try Any) + (renameSync [ffi.String ffi.String] #io #try Any) + (utimesSync [ffi.String ffi.Number ffi.Number] #io #try Any) + (unlink [ffi.String] #io #try Any) + (readdirSync [ffi.String] #io #try (Array ffi.String)) + (mkdirSync [ffi.String] #io #try Any) + (rmdirSync [ffi.String] #io #try Any)) + + (ffi.import: JsPath + (sep ffi.String) + (basename [ffi.String] ffi.String)) (template [<name> <path>] [(def: (<name> _) - (-> [] (Maybe (-> host.String Any))) - (host.constant (-> host.String Any) <path>))] + (-> [] (Maybe (-> ffi.String Any))) + (ffi.constant (-> ffi.String Any) <path>))] [normal_require [require]] [global_require [global require]] @@ -490,7 +490,7 @@ ) (def: (require _) - (-> [] (-> host.String Any)) + (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] (^or [(#.Some require) _ _] [_ (#.Some require) _] @@ -675,7 +675,7 @@ )) (def: separator - (if host.on_node_js? + (if ffi.on_node_js? (JsPath::sep (..node_path [])) "/")) )) @@ -685,35 +685,35 @@ (as_is (type: (Tuple/2 left right) (primitive "python_tuple[2]" [left right])) - (host.import: PyFile + (ffi.import: PyFile (read [] #io #try Binary) (write [Binary] #io #try #? Any) (close [] #io #try #? Any)) - (host.import: (open [host.String host.String] #io #try PyFile)) - (host.import: (tuple [[host.Integer host.Integer]] (Tuple/2 host.Integer host.Integer))) - - (host.import: os - (#static F_OK host.Integer) - (#static R_OK host.Integer) - (#static W_OK host.Integer) - (#static X_OK host.Integer) - - (#static mkdir [host.String] #io #try #? Any) - (#static access [host.String host.Integer] #io #try host.Boolean) - (#static remove [host.String] #io #try #? Any) - (#static rmdir [host.String] #io #try #? Any) - (#static rename [host.String host.String] #io #try #? Any) - (#static utime [host.String (Tuple/2 host.Integer host.Integer)] #io #try #? Any) - (#static listdir [host.String] #io #try (Array host.String))) - - (host.import: os/path - (#static isfile [host.String] #io #try host.Boolean) - (#static isdir [host.String] #io #try host.Boolean) - (#static sep host.String) - (#static basename [host.String] host.String) - (#static getsize [host.String] #io #try host.Integer) - (#static getmtime [host.String] #io #try host.Float)) + (ffi.import: (open [ffi.String ffi.String] #io #try PyFile)) + (ffi.import: (tuple [[ffi.Integer ffi.Integer]] (Tuple/2 ffi.Integer ffi.Integer))) + + (ffi.import: os + (#static F_OK ffi.Integer) + (#static R_OK ffi.Integer) + (#static W_OK ffi.Integer) + (#static X_OK ffi.Integer) + + (#static mkdir [ffi.String] #io #try #? Any) + (#static access [ffi.String ffi.Integer] #io #try ffi.Boolean) + (#static remove [ffi.String] #io #try #? Any) + (#static rmdir [ffi.String] #io #try #? Any) + (#static rename [ffi.String ffi.String] #io #try #? Any) + (#static utime [ffi.String (Tuple/2 ffi.Integer ffi.Integer)] #io #try #? Any) + (#static listdir [ffi.String] #io #try (Array ffi.String))) + + (ffi.import: os/path + (#static isfile [ffi.String] #io #try ffi.Boolean) + (#static isdir [ffi.String] #io #try ffi.Boolean) + (#static sep ffi.String) + (#static basename [ffi.String] ffi.String) + (#static getsize [ffi.String] #io #try ffi.Integer) + (#static getmtime [ffi.String] #io #try ffi.Float)) (`` (structure: (file path) (-> Path (File IO)) @@ -881,19 +881,19 @@ ) @.lua - (as_is (host.import: LuaFile - (read [host.String] #io host.String) - (write [host.String] #io #? LuaFile) - (flush [] #io host.Boolean) - (close [] #io host.Boolean)) + (as_is (ffi.import: LuaFile + (read [ffi.String] #io ffi.String) + (write [ffi.String] #io #? LuaFile) + (flush [] #io ffi.Boolean) + (close [] #io ffi.Boolean)) - (host.import: (io/open [host.String host.String] #io #? LuaFile)) + (ffi.import: (io/open [ffi.String ffi.String] #io #? LuaFile)) - (host.import: (package/config host.String)) + (ffi.import: (package/config ffi.String)) - (host.import: (os/rename [host.String host.String] #io #? host.Boolean)) - (host.import: (os/remove [host.String] #io #? host.Boolean)) - (host.import: (os/execute [host.String] #io #? host.Boolean)) + (ffi.import: (os/rename [ffi.String ffi.String] #io #? ffi.Boolean)) + (ffi.import: (os/remove [ffi.String] #io #? ffi.Boolean)) + (ffi.import: (os/execute [ffi.String] #io #? ffi.Boolean)) (def: default_separator Text @@ -1142,19 +1142,19 @@ ) @.ruby - (as_is (host.import: Time #as RubyTime + (as_is (ffi.import: Time #as RubyTime (#static at [Frac] RubyTime) (to_f [] Frac)) - (host.import: Stat #as RubyStat + (ffi.import: Stat #as RubyStat (executable? [] Bit) (size Int) (mtime [] RubyTime)) - (host.import: File #as RubyFile - (#static SEPARATOR host.String) - (#static open [Path host.String] #io #try RubyFile) + (ffi.import: File #as RubyFile + (#static SEPARATOR ffi.String) + (#static open [Path ffi.String] #io #try RubyFile) (#static stat [Path] #io #try RubyStat) (#static delete [Path] #io #try Int) (#static file? [Path] #io #try Bit) @@ -1166,13 +1166,13 @@ (flush [] #io #try #? Any) (close [] #io #try #? Any)) - (host.import: Dir #as RubyDir + (ffi.import: Dir #as RubyDir (#static open [Path] #io #try RubyDir) (children [] #io #try (Array Path)) (close [] #io #try #? Any)) - (host.import: "fileutils" FileUtils #as RubyFileUtils + (ffi.import: "fileutils" FileUtils #as RubyFileUtils (#static touch [Path] #io #try #? Any) (#static move [Path Path] #io #try #? Any) (#static rmdir [Path] #io #try #? Any) @@ -1353,34 +1353,34 @@ ) @.php - (as_is (host.import: (FILE_APPEND Int)) + (as_is (ffi.import: (FILE_APPEND Int)) ## https://www.php.net/manual/en/dir.constants.php - (host.import: (DIRECTORY_SEPARATOR host.String)) + (ffi.import: (DIRECTORY_SEPARATOR ffi.String)) ## https://www.php.net/manual/en/function.pack.php ## https://www.php.net/manual/en/function.unpack.php - (host.import: (unpack [host.String host.String] Binary)) + (ffi.import: (unpack [ffi.String ffi.String] Binary)) ## https://www.php.net/manual/en/ref.filesystem.php ## https://www.php.net/manual/en/function.file-get-contents.php - (host.import: (file_get_contents [Path] #io #try host.String)) + (ffi.import: (file_get_contents [Path] #io #try ffi.String)) ## https://www.php.net/manual/en/function.file-put-contents.php - (host.import: (file_put_contents [Path host.String Int] #io #try host.Integer)) - (host.import: (filemtime [Path] #io #try host.Integer)) - (host.import: (filesize [Path] #io #try host.Integer)) - (host.import: (is_executable [Path] #io #try host.Boolean)) - (host.import: (touch [Path host.Integer] #io #try host.Boolean)) - (host.import: (rename [Path Path] #io #try host.Boolean)) - (host.import: (unlink [Path] #io #try host.Boolean)) + (ffi.import: (file_put_contents [Path ffi.String Int] #io #try ffi.Integer)) + (ffi.import: (filemtime [Path] #io #try ffi.Integer)) + (ffi.import: (filesize [Path] #io #try ffi.Integer)) + (ffi.import: (is_executable [Path] #io #try ffi.Boolean)) + (ffi.import: (touch [Path ffi.Integer] #io #try ffi.Boolean)) + (ffi.import: (rename [Path Path] #io #try ffi.Boolean)) + (ffi.import: (unlink [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.rmdir.php - (host.import: (rmdir [Path] #io #try host.Boolean)) + (ffi.import: (rmdir [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.scandir.php - (host.import: (scandir [Path] #io #try (Array Path))) + (ffi.import: (scandir [Path] #io #try (Array Path))) ## https://www.php.net/manual/en/function.is-file.php - (host.import: (is_file [Path] #io #try host.Boolean)) + (ffi.import: (is_file [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.is-dir.php - (host.import: (is_dir [Path] #io #try host.Boolean)) + (ffi.import: (is_dir [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.mkdir.php - (host.import: (mkdir [Path] #io #try host.Boolean)) + (ffi.import: (mkdir [Path] #io #try ffi.Boolean)) (def: byte_array_format "C*") (def: default_separator (..DIRECTORY_SEPARATOR)) diff --git a/stdlib/source/lux/world/file/watch.lux b/stdlib/source/lux/world/file/watch.lux index b3951068c..4695c1e00 100644 --- a/stdlib/source/lux/world/file/watch.lux +++ b/stdlib/source/lux/world/file/watch.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [predicate (#+ Predicate)] ["." monad (#+ do)]] diff --git a/stdlib/source/lux/world/program.lux b/stdlib/source/lux/world/program.lux index 0abdb2225..07d7ad6be 100644 --- a/stdlib/source/lux/world/program.lux +++ b/stdlib/source/lux/world/program.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract ["." monad (#+ do)]] [control @@ -124,12 +124,12 @@ (|>> %.int error! io.io)) (import: NodeJs_Process - (exit [host.Number] #io Nothing) + (exit [ffi.Number] #io Nothing) (cwd [] #io Path)) (def: (exit_node_js! code) (-> Exit (IO Nothing)) - (case (host.constant ..NodeJs_Process [process]) + (case (ffi.constant ..NodeJs_Process [process]) (#.Some process) (NodeJs_Process::exit (i.frac code) process) @@ -144,8 +144,8 @@ (def: (exit_browser! code) (-> Exit (IO Nothing)) - (case [(host.constant ..Browser_Window [window]) - (host.constant ..Browser_Location [location])] + (case [(ffi.constant ..Browser_Window [window]) + (ffi.constant ..Browser_Location [location])] [(#.Some window) (#.Some location)] (exec (Browser_Window::close [] window) @@ -166,29 +166,29 @@ (..default_exit! code))) (import: Object - (#static entries [Object] (Array (Array host.String)))) + (#static entries [Object] (Array (Array ffi.String)))) (import: NodeJs_OS (homedir [] #io Path)) - (import: (require [host.String] Any))) + (import: (require [ffi.String] Any))) @.python (as_is (import: os - (#static getcwd [] #io host.String) - (#static _exit [host.Integer] #io Nothing)) + (#static getcwd [] #io ffi.String) + (#static _exit [ffi.Integer] #io Nothing)) (import: os/path - (#static expanduser [host.String] #io host.String)) + (#static expanduser [ffi.String] #io ffi.String)) (import: os/environ - (#static keys [] #io (Array host.String)) - (#static get [host.String] #io host.String))) - @.lua (as_is (host.import: LuaFile - (read [host.String] #io #? host.String) - (close [] #io host.Boolean)) + (#static keys [] #io (Array ffi.String)) + (#static get [ffi.String] #io ffi.String))) + @.lua (as_is (ffi.import: LuaFile + (read [ffi.String] #io #? ffi.String) + (close [] #io ffi.Boolean)) - (host.import: (io/popen [host.String] #io #try #? LuaFile)) - (host.import: (os/getenv [host.String] #io #? host.String)) - (host.import: (os/exit [host.Integer] #io Nothing)) + (ffi.import: (io/popen [ffi.String] #io #try #? LuaFile)) + (ffi.import: (os/getenv [ffi.String] #io #? ffi.String)) + (ffi.import: (os/exit [ffi.Integer] #io Nothing)) (def: (run_command default command) (-> Text Text (IO Text)) @@ -208,41 +208,41 @@ (#try.Failure _) (wrap default))))) - @.ruby (as_is (host.import: Env #as RubyEnv + @.ruby (as_is (ffi.import: Env #as RubyEnv (#static keys [] (Array Text)) (#static fetch [Text] Text)) - (host.import: "fileutils" FileUtils #as RubyFileUtils + (ffi.import: "fileutils" FileUtils #as RubyFileUtils (#static pwd [] #io Path)) - (host.import: Dir #as RubyDir + (ffi.import: Dir #as RubyDir (#static home [] #io Path)) - (host.import: Kernel #as RubyKernel + (ffi.import: Kernel #as RubyKernel (#static exit [Int] #io Nothing))) @.php - (as_is (host.import: (exit [Int] #io Nothing)) + (as_is (ffi.import: (exit [Int] #io Nothing)) ## https://www.php.net/manual/en/function.exit.php - (host.import: (getcwd [] #io host.String)) + (ffi.import: (getcwd [] #io ffi.String)) ## https://www.php.net/manual/en/function.getcwd.php - (host.import: (getenv #as getenv/1 [host.String] #io host.String)) - (host.import: (getenv #as getenv/0 [] #io (Array host.String))) + (ffi.import: (getenv #as getenv/1 [ffi.String] #io ffi.String)) + (ffi.import: (getenv #as getenv/0 [] #io (Array ffi.String))) ## https://www.php.net/manual/en/function.getenv.php ## https://www.php.net/manual/en/function.array-keys.php - (host.import: (array_keys [(Array host.String)] (Array host.String))) + (ffi.import: (array_keys [(Array ffi.String)] (Array ffi.String))) ) @.scheme - (as_is (host.import: (exit [Int] #io Nothing)) + (as_is (ffi.import: (exit [Int] #io Nothing)) ## https://srfi.schemers.org/srfi-98/srfi-98.html (abstract: Pair Any) (abstract: PList Any) - (host.import: (get-environment-variables [] #io PList)) - (host.import: (car [Pair] Text)) - (host.import: (cdr [Pair] Text)) - (host.import: (car #as head [PList] Pair)) - (host.import: (cdr #as tail [PList] PList)))} + (ffi.import: (get-environment-variables [] #io PList)) + (ffi.import: (car [Pair] Text)) + (ffi.import: (cdr [Pair] Text)) + (ffi.import: (car #as head [PList] Pair)) + (ffi.import: (cdr #as tail [PList] PList)))} (as_is))) (structure: #export default @@ -252,8 +252,8 @@ (with_expansions [<jvm> ..jvm\\environment] (for {@.old <jvm> @.jvm <jvm> - @.js (io.io (if host.on_node_js? - (case (host.constant Object [process env]) + @.js (io.io (if ffi.on_node_js? + (case (ffi.constant Object [process env]) (#.Some process/env) (array\fold (function (_ entry environment) (<| (maybe.default environment) @@ -306,7 +306,7 @@ <jvm> (io.io (maybe.default "" (java/lang/System::getProperty "user.home")))] (for {@.old <jvm> @.jvm <jvm> - @.js (if host.on_node_js? + @.js (if ffi.on_node_js? (|> (..require "os") (:coerce NodeJs_OS) (NodeJs_OS::homedir [])) @@ -327,8 +327,8 @@ <jvm> (io.io (maybe.default "" (java/lang/System::getProperty "user.dir")))] (for {@.old <jvm> @.jvm <jvm> - @.js (if host.on_node_js? - (case (host.constant ..NodeJs_Process [process]) + @.js (if ffi.on_node_js? + (case (ffi.constant ..NodeJs_Process [process]) (#.Some process) (NodeJs_Process::cwd [] process) @@ -357,10 +357,10 @@ (wrap (undefined)))] (for {@.old <jvm> @.jvm <jvm> - @.js (cond host.on_node_js? + @.js (cond ffi.on_node_js? (..exit_node_js! code) - host.on_browser? + ffi.on_browser? (..exit_browser! code) ## else diff --git a/stdlib/source/lux/world/shell.lux b/stdlib/source/lux/world/shell.lux index 10c3f4718..482100853 100644 --- a/stdlib/source/lux/world/shell.lux +++ b/stdlib/source/lux/world/shell.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["jvm" host (#+ import:)] + ["jvm" ffi (#+ import:)] [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 1be540298..1d72f0937 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -1,7 +1,7 @@ (.module: [lux (#- Name) ["." debug] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [codec (#+ Codec)] [equivalence (#+ Equivalence)] diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 336d9bc96..b94e2a0cf 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [codec (#+ Codec)] [equivalence (#+ Equivalence)] diff --git a/stdlib/source/program/aedifex/repository/identity.lux b/stdlib/source/program/aedifex/repository/identity.lux index 2de3c6751..7ec3cceec 100644 --- a/stdlib/source/program/aedifex/repository/identity.lux +++ b/stdlib/source/program/aedifex/repository/identity.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [equivalence (#+ Equivalence)]] [data diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index 7ac384efa..6b4575627 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index 4b61bc36c..fd0d65d6f 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux index a8f820786..237ff5024 100644 --- a/stdlib/source/spec/compositor/generation/structure.lux +++ b/stdlib/source/spec/compositor/generation/structure.lux @@ -18,7 +18,7 @@ ["." list ("#\." functor)]]] [math ["r" random]] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [tool [compiler ["." analysis] @@ -48,7 +48,7 @@ (let [tag-out (:coerce java/lang/Integer (maybe.assume (array.read 0 valueT))) last?-out (array.read 1 valueT) value-out (:coerce Any (maybe.assume (array.read 2 valueT))) - same-tag? (|> tag-out host.int-to-long (:coerce Nat) (n.= tag-in)) + same-tag? (|> tag-out ffi.int-to-long (:coerce Nat) (n.= tag-in)) same-flag? (case last?-out (#.Some last?-out') (and last?-in (text\= "" (:coerce Text last?-out'))) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 8532b3e12..40a797177 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -39,7 +39,7 @@ ## ["#." tool] ## TODO: Update & expand tests for this ["#." type] ["#." world] - ["#." host] + ["#." ffi] ["#." extension] ["#." target #_ <target>]])) @@ -220,7 +220,7 @@ ## /tool.test /type.test /world.test - /host.test + /ffi.test (for {@.jvm (#.Cons /target/jvm.test tail) @.old (#.Cons /target/jvm.test tail)} tail) diff --git a/stdlib/source/test/lux/control/function/contract.lux b/stdlib/source/test/lux/control/function/contract.lux index 47962d04a..76eb07104 100644 --- a/stdlib/source/test/lux/control/function/contract.lux +++ b/stdlib/source/test/lux/control/function/contract.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["_" test (#+ Test)] - ["." host] + ["." ffi] [abstract [monad (#+ do)]] [control @@ -20,16 +20,16 @@ [expected random.nat]) ($_ _.and (_.cover [/.pre] - (case (host.try (/.pre (n.even? expected) - true)) + (case (ffi.try (/.pre (n.even? expected) + true)) (#try.Success output) output (#try.Failure error) (not (n.even? expected)))) (_.cover [/.post] - (case (host.try (/.post n.odd? - expected)) + (case (ffi.try (/.post n.odd? + expected)) (#try.Success actual) (is? expected actual) diff --git a/stdlib/source/test/lux/host.js.lux b/stdlib/source/test/lux/ffi.js.lux index 5ffe1fbeb..5ffe1fbeb 100644 --- a/stdlib/source/test/lux/host.js.lux +++ b/stdlib/source/test/lux/ffi.js.lux diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 9edaecd0c..9edaecd0c 100644 --- a/stdlib/source/test/lux/host.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux diff --git a/stdlib/source/test/lux/host.lua.lux b/stdlib/source/test/lux/ffi.lua.lux index 0b6cac81b..0b6cac81b 100644 --- a/stdlib/source/test/lux/host.lua.lux +++ b/stdlib/source/test/lux/ffi.lua.lux diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/ffi.old.lux index b14dac30d..b14dac30d 100644 --- a/stdlib/source/test/lux/host.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux diff --git a/stdlib/source/test/lux/host.php.lux b/stdlib/source/test/lux/ffi.php.lux index 0b6cac81b..0b6cac81b 100644 --- a/stdlib/source/test/lux/host.php.lux +++ b/stdlib/source/test/lux/ffi.php.lux diff --git a/stdlib/source/test/lux/host.py.lux b/stdlib/source/test/lux/ffi.py.lux index 0b6cac81b..0b6cac81b 100644 --- a/stdlib/source/test/lux/host.py.lux +++ b/stdlib/source/test/lux/ffi.py.lux diff --git a/stdlib/source/test/lux/host.rb.lux b/stdlib/source/test/lux/ffi.rb.lux index 0b6cac81b..0b6cac81b 100644 --- a/stdlib/source/test/lux/host.rb.lux +++ b/stdlib/source/test/lux/ffi.rb.lux diff --git a/stdlib/source/test/lux/host.scm.lux b/stdlib/source/test/lux/ffi.scm.lux index 0b6cac81b..0b6cac81b 100644 --- a/stdlib/source/test/lux/host.scm.lux +++ b/stdlib/source/test/lux/ffi.scm.lux diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index 5f37be2ef..ddeab3763 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -2,7 +2,7 @@ [lux #* ["_" test (#+ Test)] ["@" target] - ["." host] + ["." ffi] [abstract [monad (#+ do)] {[0 #spec] @@ -118,7 +118,7 @@ )) ))) -(with_expansions [<jvm> (as_is (host.import: java/lang/Double +(with_expansions [<jvm> (as_is (ffi.import: java/lang/Double ["#::." (#static doubleToRawLongBits [double] long) (#static longBitsToDouble [long] double)]))] diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index f2c8963d3..6e22d611f 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type type primitive int) - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["@" target] [abstract ["." monad (#+ do)]] @@ -96,7 +96,7 @@ (def: (get_method name class) (-> Text (java/lang/Class java/lang/Object) java/lang/reflect/Method) (java/lang/Class::getDeclaredMethod name - (host.array (java/lang/Class java/lang/Object) 0) + (ffi.array (java/lang/Class java/lang/Object) 0) class)) (def: $Object (/type.class "java.lang.Object" (list))) @@ -124,8 +124,8 @@ loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) class (io.run (/loader.load class_name loader)) - method (host.try (get_method method_name class))] - (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)) + method (ffi.try (get_method method_name class))] + (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)) (#try.Success actual) (test actual) @@ -165,10 +165,10 @@ (/.invokestatic ..$Byte "valueOf" (/type.method [(list /type.byte) ..$Byte (list)]))) (def: $Byte::random (Random java/lang/Byte) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_byte) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_byte) random.int)) (def: $Byte::literal (-> java/lang/Byte (Bytecode Any)) - (|>> host.byte_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.byte_to_long (:coerce I64) i32.i32 /.int)) (def: $Byte::primitive (Primitive java/lang/Byte) {#unboxed /type.byte @@ -183,10 +183,10 @@ (/.invokestatic ..$Short "valueOf" (/type.method [(list /type.short) ..$Short (list)]))) (def: $Short::random (Random java/lang/Short) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_short) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_short) random.int)) (def: $Short::literal (-> java/lang/Short (Bytecode Any)) - (|>> host.short_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.short_to_long (:coerce I64) i32.i32 /.int)) (def: $Short::primitive (Primitive java/lang/Short) {#unboxed /type.short @@ -201,10 +201,10 @@ (/.invokestatic ..$Integer "valueOf" (/type.method [(list /type.int) ..$Integer (list)]))) (def: $Integer::random (Random java/lang/Integer) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_int) random.int)) (def: $Integer::literal (-> java/lang/Integer (Bytecode Any)) - (|>> host.int_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.int_to_long (:coerce I64) i32.i32 /.int)) (def: $Integer::primitive (Primitive java/lang/Integer) {#unboxed /type.int @@ -230,12 +230,12 @@ (def: $Float::random (Random java/lang/Float) (\ random.monad map - (|>> (:coerce java/lang/Double) host.double_to_float) + (|>> (:coerce java/lang/Double) ffi.double_to_float) random.frac)) (def: $Float::literal /.float) (def: valid_float (Random java/lang/Float) - (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not) + (random.filter (|>> ffi.float_to_double (:coerce Frac) f.not_a_number? not) ..$Float::random)) (def: $Float::primitive (Primitive java/lang/Float) @@ -269,10 +269,10 @@ (/.invokestatic ..$Character "valueOf" (/type.method [(list /type.char) ..$Character (list)]))) (def: $Character::random (Random java/lang/Character) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_char) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int)) (def: $Character::literal (-> java/lang/Character (Bytecode Any)) - (|>> host.char_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.char_to_long (:coerce I64) i32.i32 /.int)) (def: $Character::primitive (Primitive java/lang/Character) {#unboxed /type.char @@ -314,8 +314,8 @@ [_ (<push> (|> expected .int <signed> try.assume))] <wrap>))))] - [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" host.byte_to_long /signed.s1] - [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" host.short_to_long /signed.s2] + [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" ffi.byte_to_long /signed.s1] + [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" ffi.short_to_long /signed.s2] ) (template [<name> <type>] @@ -382,7 +382,7 @@ shift (: (-> (-> java/lang/Integer java/lang/Integer java/lang/Integer) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do {! random.monad} - [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) host.long_to_int) random.nat) + [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) ffi.long_to_int) random.nat) subject ..$Integer::random] (int (reference parameter subject) (do /.monad @@ -390,13 +390,13 @@ _ (..$Integer::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "ICONST_M1" (int (host.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1)) - (_.lift "ICONST_0" (int (host.long_to_int (:coerce java/lang/Long +0)) /.iconst_0)) - (_.lift "ICONST_1" (int (host.long_to_int (:coerce java/lang/Long +1)) /.iconst_1)) - (_.lift "ICONST_2" (int (host.long_to_int (:coerce java/lang/Long +2)) /.iconst_2)) - (_.lift "ICONST_3" (int (host.long_to_int (:coerce java/lang/Long +3)) /.iconst_3)) - (_.lift "ICONST_4" (int (host.long_to_int (:coerce java/lang/Long +4)) /.iconst_4)) - (_.lift "ICONST_5" (int (host.long_to_int (:coerce java/lang/Long +5)) /.iconst_5)) + (_.lift "ICONST_M1" (int (ffi.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1)) + (_.lift "ICONST_0" (int (ffi.long_to_int (:coerce java/lang/Long +0)) /.iconst_0)) + (_.lift "ICONST_1" (int (ffi.long_to_int (:coerce java/lang/Long +1)) /.iconst_1)) + (_.lift "ICONST_2" (int (ffi.long_to_int (:coerce java/lang/Long +2)) /.iconst_2)) + (_.lift "ICONST_3" (int (ffi.long_to_int (:coerce java/lang/Long +3)) /.iconst_3)) + (_.lift "ICONST_4" (int (ffi.long_to_int (:coerce java/lang/Long +4)) /.iconst_4)) + (_.lift "ICONST_5" (int (ffi.long_to_int (:coerce java/lang/Long +5)) /.iconst_5)) (_.lift "LDC_W/INTEGER" (do random.monad [expected ..$Integer::random] @@ -410,7 +410,7 @@ (_.lift "INEG" (unary (function (_ value) ((int/2 "jvm isub" "jvm int -") value - (host.long_to_int (:coerce java/lang/Long +0)))) + (ffi.long_to_int (:coerce java/lang/Long +0)))) /.ineg))) bitwise ($_ _.and (_.lift "IAND" (binary (int/2 "jvm iand" "jvm int and") /.iand)) @@ -463,10 +463,10 @@ (do {! random.monad} [parameter (\ ! map (|>> (n.% 64) (:coerce java/lang/Long)) random.nat) subject ..$Long::random] - (long (reference (host.long_to_int parameter) subject) + (long (reference (ffi.long_to_int parameter) subject) (do /.monad [_ (..$Long::literal subject) - _ (..$Integer::literal (host.long_to_int parameter))] + _ (..$Integer::literal (ffi.long_to_int parameter))] instruction))))) literal ($_ _.and (_.lift "LCONST_0" (long (:coerce java/lang/Long +0) /.lconst_0)) @@ -534,14 +534,14 @@ (<| (..bytecode (for {@.old (function (_ actual) (or (|> actual (:coerce java/lang/Float) ("jvm feq" expected)) - (and (f.not_a_number? (:coerce Frac (host.float_to_double expected))) - (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual))))))) + (and (f.not_a_number? (:coerce Frac (ffi.float_to_double expected))) + (f.not_a_number? (:coerce Frac (ffi.float_to_double (:coerce java/lang/Float actual))))))) @.jvm (function (_ actual) (or (|> actual (:coerce java/lang/Float) "jvm object cast" ("jvm float =" ("jvm object cast" expected))) - (and (f.not_a_number? (:coerce Frac (host.float_to_double expected))) - (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual)))))))})) + (and (f.not_a_number? (:coerce Frac (ffi.float_to_double expected))) + (f.not_a_number? (:coerce Frac (ffi.float_to_double (:coerce java/lang/Float actual)))))))})) (do /.monad [_ bytecode] ..$Float::wrap)))) @@ -568,9 +568,9 @@ _ (..$Float::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "FCONST_0" (float (host.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0)) - (_.lift "FCONST_1" (float (host.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1)) - (_.lift "FCONST_2" (float (host.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2)) + (_.lift "FCONST_0" (float (ffi.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0)) + (_.lift "FCONST_1" (float (ffi.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1)) + (_.lift "FCONST_2" (float (ffi.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2)) (_.lift "LDC_W/FLOAT" (do random.monad [expected ..$Float::random] @@ -584,12 +584,12 @@ (_.lift "FNEG" (unary (function (_ value) ((float/2 "jvm fsub" "jvm float -") value - (host.double_to_float (:coerce java/lang/Double +0.0)))) + (ffi.double_to_float (:coerce java/lang/Double +0.0)))) /.fneg))) comparison (: (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit)) (function (_ instruction standard) (do random.monad - [#let [valid_float (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not) + [#let [valid_float (random.filter (|>> ffi.float_to_double (:coerce Frac) f.not_a_number? not) ..$Float::random)] reference valid_float subject valid_float @@ -892,8 +892,8 @@ (case (do try.monad [_ (/loader.define class_name bytecode loader) class (io.run (/loader.load class_name loader)) - method (host.try (get_method static_method class)) - output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] + method (ffi.try (get_method static_method class)) + output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) (i.= (:coerce Int expected) (:coerce Int actual)) @@ -927,7 +927,7 @@ (-> a Any Bit) (Random Bit))) (function (_ size constructor value literal [*store *load *wrap] test) - (let [!index ($Integer::literal (host.long_to_int (:coerce java/lang/Long +0)))] + (let [!index ($Integer::literal (ffi.long_to_int (:coerce java/lang/Long +0)))] (<| (..bytecode (test value)) (do /.monad [_ (!length size) @@ -957,18 +957,18 @@ (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected))) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) @.jvm - (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))})))) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:coerce java/lang/Byte expected)))))})))) (_.context "short" (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected))) + (|>> (:coerce java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) @.jvm - (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))})))) + (|>> (:coerce java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:coerce java/lang/Short expected)))))})))) (_.context "int" (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] (function (_ expected) @@ -1028,7 +1028,7 @@ (<| (_.lift "MULTIANEWARRAY") (..bytecode (|>> (:coerce Nat) (n.= sizesH))) (do {! /.monad} - [_ (monad.map ! (|>> (:coerce java/lang/Long) host.long_to_int ..$Integer::literal) + [_ (monad.map ! (|>> (:coerce java/lang/Long) ffi.long_to_int ..$Integer::literal) (#.Cons sizesH sizesT)) _ (/.multianewarray type (|> dimensions /unsigned.u1 try.assume)) _ ?length] @@ -1064,40 +1064,40 @@ ($_ _.and (<| (_.context "int") ($_ _.and - (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> host.int_to_long) long::=)) - (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> host.int_to_float) float::=)) - (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> host.int_to_double) double::=)) - (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> host.int_to_byte) + (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> ffi.int_to_long) long::=)) + (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> ffi.int_to_float) float::=)) + (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> ffi.int_to_double) double::=)) + (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> ffi.int_to_byte) (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected))) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) @.jvm - (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))})))) - (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> host.int_to_char) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:coerce java/lang/Byte expected)))))})))) + (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> ffi.int_to_char) (!::= java/lang/Character "jvm ceq" "jvm char ="))) - (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> host.int_to_short) + (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> ffi.int_to_short) (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected))) + (|>> (:coerce java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) @.jvm - (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))})))))) + (|>> (:coerce java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:coerce java/lang/Short expected)))))})))))) (<| (_.context "long") ($_ _.and - (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> host.long_to_int) int::=)) - (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> host.long_to_float) float::=)) - (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> host.long_to_double) double::=)))) + (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> ffi.long_to_int) int::=)) + (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> ffi.long_to_float) float::=)) + (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> ffi.long_to_double) double::=)))) (<| (_.context "float") ($_ _.and - (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> host.float_to_int) int::=)) - (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> host.float_to_long) long::=)) - (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> host.float_to_double) double::=)))) + (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> ffi.float_to_int) int::=)) + (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> ffi.float_to_long) long::=)) + (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> ffi.float_to_double) double::=)))) (<| (_.context "double") ($_ _.and - (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> host.double_to_int) int::=)) - (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> host.double_to_long) long::=)) - (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> host.double_to_float) float::=)))) + (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> ffi.double_to_int) int::=)) + (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> ffi.double_to_long) long::=)) + (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> ffi.double_to_float) float::=)))) ))) (def: value @@ -1156,13 +1156,13 @@ #let [expected (: java/lang/Long (for {@.old ("jvm ladd" - (host.byte_to_long base) + (ffi.byte_to_long base) (.int (/unsigned.value increment))) @.jvm ("jvm object cast" ("jvm long +" - ("jvm object cast" (host.byte_to_long base)) + ("jvm object cast" (ffi.byte_to_long base)) ("jvm object cast" (:coerce java/lang/Long (/unsigned.value increment)))))}))]] (..bytecode (|>> (:coerce Int) (i.= (:coerce Int expected))) (do /.monad @@ -1357,8 +1357,8 @@ loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) class (io.run (/loader.load class_name loader)) - method (host.try (get_method object_method_name class))] - (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)) + method (ffi.try (get_method object_method_name class))] + (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)) (#try.Success actual) (test expected actual) @@ -1498,7 +1498,7 @@ random.nat) choice (\ ! map (n.% options) random.nat) options (|> random.int - (\ ! map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_long (:coerce Int))) + (\ ! map (|>> (:coerce java/lang/Long) ffi.long_to_int ffi.int_to_long (:coerce Int))) (random.set i.hash options) (\ ! map set.to_list)) #let [choice (maybe.assume (list.nth choice options))] @@ -1509,7 +1509,7 @@ [@right /.new_label @wrong /.new_label @return /.new_label - _ (..$Integer::literal (host.long_to_int (:coerce java/lang/Long choice))) + _ (..$Integer::literal (ffi.long_to_int (:coerce java/lang/Long choice))) _ (/.lookupswitch @wrong (list\map (function (_ option) [(|> option /signed.s4 try.assume) (if (i.= choice option) @right @wrong)]) @@ -1709,8 +1709,8 @@ _ (/loader.define interface_class interface_bytecode loader) _ (/loader.define concrete_class concrete_bytecode loader) class (io.run (/loader.load concrete_class loader)) - method (host.try (get_method static_method class)) - output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] + method (ffi.try (get_method static_method class)) + output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) (i.= (:coerce Int expected) (:coerce Int actual)) diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index 4f6080b48..316ef8783 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["_" test (#+ Test)] - ["." host] + ["." ffi] [abstract [monad (#+ do)] {[0 #spec] @@ -97,7 +97,7 @@ (apply duration.inverse day\pred 6) (apply duration.inverse day\pred 7))))) (_.cover [/.now] - (case (host.try /.now) + (case (ffi.try /.now) (#try.Success _) true |