aboutsummaryrefslogtreecommitdiff
path: root/lux-js
diff options
context:
space:
mode:
authorEduardo Julian2021-06-11 02:48:13 -0400
committerEduardo Julian2021-06-11 02:48:13 -0400
commit8f575da5095e3b259d4eb6b6f13d3e37ef1d38e4 (patch)
treed4ad0bf5582637395508b4a260491373d55e760b /lux-js
parent486488ae17007406a6c90f182b85f7be14b6b373 (diff)
Added import name formatting to "import:" macros for other backends.
Diffstat (limited to '')
-rw-r--r--lux-js/source/program.lux53
1 files changed, 27 insertions, 26 deletions
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux
index 6f9e44497..41b09da2c 100644
--- a/lux-js/source/program.lux
+++ b/lux-js/source/program.lux
@@ -1,7 +1,7 @@
(.module:
[lux #*
[program (#+ program:)]
- ["." host (#+ import:)]
+ ["." ffi (#+ import:)]
["." debug]
[abstract
[monad (#+ do)]]
@@ -17,7 +17,8 @@
["." maybe]
[text
["%" format (#+ format)]
- ["." encoding]]
+ [encoding
+ ["." utf8]]]
[collection
["." array (#+ Array)]]]
[macro
@@ -131,7 +132,7 @@
(import: org/openjdk/nashorn/internal/runtime/Undefined)
(template [<name>]
- [(host.interface: <name>
+ [(ffi.interface: <name>
(getValue [] java/lang/Object))
(`` (import: (~~ (template.identifier ["program/" <name>]))
@@ -154,7 +155,7 @@
(def: (js_int value)
(-> Int org/openjdk/nashorn/api/scripting/JSObject)
- (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/IntValue]
+ (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/IntValue]
[]
## Methods
(program/IntValue
@@ -175,7 +176,7 @@
(def: (::toString js_object)
(-> Any org/openjdk/nashorn/api/scripting/JSObject)
- (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject []
+ (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject []
[]
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (isFunction self) boolean
@@ -187,7 +188,7 @@
(def: (::slice js_object value)
(-> (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject)
- (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject []
+ (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject []
[]
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (isFunction self) boolean
@@ -205,17 +206,17 @@
(-> (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject)
(let [js_object (: (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject)
(function (_ sub_value)
- (<| (case (host.check [java/lang/Object] sub_value)
+ (<| (case (ffi.check [java/lang/Object] sub_value)
(#.Some sub_value)
(|> sub_value (:coerce (Array java/lang/Object)) js_structure)
#.None)
- (case (host.check java/lang/Long sub_value)
+ (case (ffi.check java/lang/Long sub_value)
(#.Some sub_value)
(|> sub_value (:coerce Int) js_int)
#.None)
## else
(:coerce org/openjdk/nashorn/api/scripting/JSObject sub_value))))]
- (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/StructureValue]
+ (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/StructureValue]
[]
## Methods
(program/StructureValue
@@ -247,7 +248,7 @@
set!
_
- (host.null))
+ (ffi.null))
(^ (static runtime.variant_value_field))
(|> value (array.read 2) maybe.assume js_object (:coerce java/lang/Object))
@@ -277,8 +278,8 @@
(case [(org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.i64_high_field] js_object)
(org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.i64_low_field] js_object)]
(^multi [(#.Some high) (#.Some low)]
- [[(host.check java/lang/Number high)
- (host.check java/lang/Number low)]
+ [[(ffi.check java/lang/Number high)
+ (ffi.check java/lang/Number low)]
[(#.Some high) (#.Some low)]]
[[(java/lang/Number::longValue high)
(java/lang/Number::longValue low)]
@@ -299,12 +300,12 @@
(org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.variant_flag_field] js_object)
(org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.variant_value_field] js_object)]
(^multi [(#.Some tag) ?flag (#.Some value)]
- [(host.check java/lang/Number tag)
+ [(ffi.check java/lang/Number tag)
(#.Some tag)]
[(lux_object value)
(#.Some value)])
(#.Some [(java/lang/Number::intValue tag)
- (maybe.default (host.null) ?flag)
+ (maybe.default (ffi.null) ?flag)
value])
_
@@ -322,7 +323,7 @@
(if (n.< num_keys idx)
(case (org/openjdk/nashorn/api/scripting/JSObject::getMember (%.nat idx) js_object)
(#.Some member)
- (case (host.check org/openjdk/nashorn/internal/runtime/Undefined member)
+ (case (ffi.check org/openjdk/nashorn/internal/runtime/Undefined member)
(#.Some _)
(recur (inc idx) output)
@@ -341,21 +342,21 @@
(def: (lux_object js_object)
(-> java/lang/Object (Try Any))
- (`` (<| (if (host.null? js_object)
+ (`` (<| (if (ffi.null? js_object)
(exception.throw ..null_has_no_lux_representation [#.None]))
- (case (host.check org/openjdk/nashorn/internal/runtime/Undefined js_object)
+ (case (ffi.check org/openjdk/nashorn/internal/runtime/Undefined js_object)
(#.Some _)
(exception.throw ..undefined_has_no_lux_representation [])
#.None)
(~~ (template [<class>]
- [(case (host.check <class> js_object)
+ [(case (ffi.check <class> js_object)
(#.Some js_object)
(exception.return js_object)
#.None)]
[java/lang/Boolean] [java/lang/String]))
(~~ (template [<class> <method>]
- [(case (host.check <class> js_object)
+ [(case (ffi.check <class> js_object)
(#.Some js_object)
(exception.return (<method> js_object))
#.None)]
@@ -363,7 +364,7 @@
[java/lang/Number java/lang/Number::doubleValue]
[program/StructureValue program/StructureValue::getValue]
[program/IntValue program/IntValue::getValue]))
- (case (host.check org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object)
+ (case (ffi.check org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object)
(#.Some js_object)
(case (check_int js_object)
(#.Some value)
@@ -394,7 +395,7 @@
(do maybe.monad
[function (|> function
(:coerce java/lang/Object)
- (host.check org/openjdk/nashorn/api/scripting/JSObject))]
+ (ffi.check org/openjdk/nashorn/api/scripting/JSObject))]
(if (org/openjdk/nashorn/api/scripting/JSObject::isFunction function)
(#.Some function)
#.None)))
@@ -483,7 +484,7 @@
(def: define! (..define! interpreter))
(def: (ingest context content)
- (|> content (\ encoding.utf8 decode) try.assume (:coerce _.Statement)))
+ (|> content (\ utf8.codec decode) try.assume (:coerce _.Statement)))
(def: (re_learn context content)
(..execute! interpreter content))
@@ -508,7 +509,7 @@
(def: (evaluate! alias input)
(-> Context _.Expression (Try Any))
(do try.monad
- [?output (host.try (..eval (_.code input)))]
+ [?output (ffi.try (..eval (_.code input)))]
(case ?output
(#.Some output)
(wrap output)
@@ -519,7 +520,7 @@
(def: (execute! input)
(-> _.Statement (Try Any))
(do try.monad
- [?output (host.try (..eval (_.code input)))]
+ [?output (ffi.try (..eval (_.code input)))]
(wrap [])))
(def: (define! context input)
@@ -541,7 +542,7 @@
(def: define! ..define!)
(def: (ingest context content)
- (|> content (\ encoding.utf8 decode) try.assume (:coerce _.Statement)))
+ (|> content (\ utf8.codec decode) try.assume (:coerce _.Statement)))
(def: (re_learn context content)
(..execute! content))
@@ -560,7 +561,7 @@
#platform.host host
#platform.phase js.generate
#platform.runtime runtime.generate
- #platform.write (|>> _.code (\ encoding.utf8 encode))})))
+ #platform.write (|>> _.code (\ utf8.codec encode))})))
(def: (program context program)
(Program _.Expression _.Statement)