aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js
diff options
context:
space:
mode:
authorEduardo Julian2018-07-03 18:40:16 -0400
committerEduardo Julian2018-07-03 18:40:16 -0400
commitd3f5e1f4baa667bc2eb72edd542cf5d8cd3924ce (patch)
tree2aa771401cce0d08276abc072b9d31e00a651f29 /new-luxc/source/luxc/lang/translation/js
parentbfd2d6c203042dfddb0ce29db3696365fe213314 (diff)
- Re-named ":!" to ":coerce".
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/js.lux78
-rw-r--r--new-luxc/source/luxc/lang/translation/js/eval.jvm.lux30
-rw-r--r--new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/js/statement.jvm.lux2
4 files changed, 56 insertions, 56 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js.lux b/new-luxc/source/luxc/lang/translation/js.lux
index d38409b10..9fd2d098f 100644
--- a/new-luxc/source/luxc/lang/translation/js.lux
+++ b/new-luxc/source/luxc/lang/translation/js.lux
@@ -93,26 +93,26 @@
(Meta Any)
(function (_ compiler)
(#e.Success [(update@ #.host
- (|>> (:! Host)
+ (|>> (:coerce Host)
(set@ #module-buffer (#.Some (StringBuilder::new [])))
- (:! Nothing))
+ (:coerce Nothing))
compiler)
[]])))
(def: #export (with-sub-context expr)
(All [a] (-> (Meta a) (Meta [Text a])))
(function (_ compiler)
- (let [old (:! Host (get@ #.host compiler))
+ (let [old (:coerce Host (get@ #.host compiler))
[old-name old-sub] (get@ #context old)
new-name (format old-name "$" (%i (.int old-sub)))]
(case (expr (set@ #.host
- (:! Nothing (set@ #context [new-name +0] old))
+ (:coerce Nothing (set@ #context [new-name +0] old))
compiler))
(#e.Success [compiler' output])
(#e.Success [(update@ #.host
- (|>> (:! Host)
+ (|>> (:coerce Host)
(set@ #context [old-name (inc old-sub)])
- (:! Nothing))
+ (:coerce Nothing))
compiler')
[new-name output]])
@@ -124,7 +124,7 @@
(function (_ compiler)
(#e.Success [compiler
(|> (get@ #.host compiler)
- (:! Host)
+ (:coerce Host)
(get@ #context)
(let> [name sub]
name))])))
@@ -132,15 +132,15 @@
(def: #export (with-anchor anchor expr)
(All [a] (-> Anchor (Meta a) (Meta a)))
(function (_ compiler)
- (let [old (:! Host (get@ #.host compiler))]
+ (let [old (:coerce Host (get@ #.host compiler))]
(case (expr (set@ #.host
- (:! Nothing (set@ #anchor (#.Some anchor) old))
+ (:coerce Nothing (set@ #anchor (#.Some anchor) old))
compiler))
(#e.Success [compiler' output])
(#e.Success [(update@ #.host
- (|>> (:! Host)
+ (|>> (:coerce Host)
(set@ #anchor (get@ #anchor old))
- (:! Nothing))
+ (:coerce Nothing))
compiler')
output])
@@ -150,7 +150,7 @@
(def: #export anchor
(Meta Anchor)
(function (_ compiler)
- (case (|> compiler (get@ #.host) (:! Host) (get@ #anchor))
+ (case (|> compiler (get@ #.host) (:coerce Host) (get@ #anchor))
(#.Some anchor)
(#e.Success [compiler anchor])
@@ -160,7 +160,7 @@
(def: #export module-buffer
(Meta StringBuilder)
(function (_ compiler)
- (case (|> compiler (get@ #.host) (:! Host) (get@ #module-buffer))
+ (case (|> compiler (get@ #.host) (:coerce Host) (get@ #module-buffer))
#.None
((lang.throw No-Active-Module-Buffer "") compiler)
@@ -170,14 +170,14 @@
(def: #export program-buffer
(Meta StringBuilder)
(function (_ compiler)
- (#e.Success [compiler (|> compiler (get@ #.host) (:! Host) (get@ #program-buffer))])))
+ (#e.Success [compiler (|> compiler (get@ #.host) (:coerce Host) (get@ #program-buffer))])))
(def: (execute code)
(-> Expression (Meta Any))
(function (_ compiler)
(case (|> compiler
(get@ #.host)
- (:! Host)
+ (:coerce Host)
(get@ #interpreter)
(ScriptEngine::eval [code]))
(#e.Error error)
@@ -193,7 +193,7 @@
(AbstractJSObject (isFunction) boolean
true)
(AbstractJSObject (call [args (Array Object)]) Object
- (Object::toString [] (:! Object js-object)))
+ (Object::toString [] (:coerce Object js-object)))
))
(def: (::slice js-object value)
@@ -203,10 +203,10 @@
(AbstractJSObject (isFunction) boolean
true)
(AbstractJSObject (call [args (Array Object)]) Object
- (:! Object
- (js-object (Arrays::copyOfRange [value
- (|> args (array.read +0) maybe.assume (:! Int))
- (.int (array.size value))]))))
+ (:coerce Object
+ (js-object (Arrays::copyOfRange [value
+ (|> args (array.read +0) maybe.assume (:coerce Int))
+ (.int (array.size value))]))))
))
(def: #export int-high-field Text "H")
@@ -218,7 +218,7 @@
(def: jvm-int
(-> Nat Integer)
- (|>> (:! Long) (Long::intValue [])))
+ (|>> (:coerce Long) (Long::intValue [])))
(def: low-mask
Nat
@@ -238,7 +238,7 @@
[]
## Methods
(IntValue (getValue) Long
- (:! Long value))
+ (:coerce Long value))
(AbstractJSObject (getMember [member String]) Object
(cond (text/= int-high-field member)
(|> value .nat high jvm-int)
@@ -262,13 +262,13 @@
[]
## Methods
(StructureValue (getValue) (Array Object)
- (:! (Array Object) value))
+ (:coerce (Array Object) value))
(AbstractJSObject (isArray) boolean
true)
(AbstractJSObject (getMember [member String]) Object
(cond (text/= "toString" member)
- (:! Object
- (::toString value))
+ (:coerce Object
+ (::toString value))
(text/= "length" member)
(jvm-int (array.size value))
@@ -276,32 +276,32 @@
(text/= "slice" member)
(let [js-object (: (-> Object JSObject)
(|>> (cond> [(host.instance? (Array Object))]
- [(:! (Array Object)) js-structure]
+ [(:coerce (Array Object)) js-structure]
[(host.instance? Long)]
- [(:! Int) js-int]
+ [(:coerce Int) js-int]
## else
- [(:! JSObject)])))]
- (:! Object
- (::slice js-object value)))
+ [(:coerce JSObject)])))]
+ (:coerce Object
+ (::slice js-object value)))
## else
- (error! (ex.construct Unknown-Member (format " member = " (:! Text member) "\n"
- "object(structure) = " (Object::toString [] (:! Object value)) "\n")))))
+ (error! (ex.construct Unknown-Member (format " member = " (:coerce Text member) "\n"
+ "object(structure) = " (Object::toString [] (:coerce Object value)) "\n")))))
(AbstractJSObject (getSlot [idx int]) Object
(|> value
- (array.read (|> idx (Integer::longValue []) (:! Nat)))
+ (array.read (|> idx (Integer::longValue []) (:coerce Nat)))
maybe.assume
(cond> [(host.instance? (Array Object))]
- [(:! (Array Object)) js-structure]
+ [(:coerce (Array Object)) js-structure]
[(host.instance? Long)]
- [(:! Int) js-int]
+ [(:coerce Int) js-int]
## else
- [(:! JSObject)])
- (:! Object)))
+ [(:coerce JSObject)])
+ (:coerce Object)))
))
(def: #export unit Text "")
@@ -320,7 +320,7 @@
(-> JS (Meta Any))
(do macro.Monad<Meta>
[module-buffer module-buffer
- #let [_ (Appendable::append [(:! CharSequence code)]
+ #let [_ (Appendable::append [(:coerce CharSequence code)]
module-buffer)]]
(execute code)))
@@ -335,7 +335,7 @@
module-buffer module-buffer
program-buffer program-buffer
#let [module-code (StringBuilder::toString [] module-buffer)
- _ (Appendable::append [(:! CharSequence (format module-code "\n"))]
+ _ (Appendable::append [(:coerce CharSequence (format module-code "\n"))]
program-buffer)]]
(wrap (ioC.write target
(format (module-name module) "/" module-js-name)
diff --git a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
index 94136f356..8019ded53 100644
--- a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
@@ -61,13 +61,13 @@
(^multi [(#.Some high) (#.Some low)]
(and (host.instance? Number high)
(host.instance? Number low))
- [[(Number::longValue [] (:! Number high))
- (Number::longValue [] (:! Number low))]
+ [[(Number::longValue [] (:coerce Number high))
+ (Number::longValue [] (:coerce Number low))]
[high low]])
- (#.Some (.int (n/+ (|> high (:! Nat) (bit.left-shift +32))
- (if (i/< 0 (:! Int low))
- (|> low (:! Nat) (bit.left-shift +32) (bit.logical-right-shift +32))
- (|> low (:! Nat))))))
+ (#.Some (.int (n/+ (|> high (:coerce Nat) (bit.left-shift +32))
+ (if (i/< 0 (:coerce Int low))
+ (|> low (:coerce Nat) (bit.left-shift +32) (bit.logical-right-shift +32))
+ (|> low (:coerce Nat))))))
_
#.None))
@@ -79,7 +79,7 @@
(JSObject::getMember [//.variant-value-field] js-object)]
(^multi [(#.Some tag) ?flag (#.Some value)]
(host.instance? Number tag)
- [[(Number::intValue [] (:! Number tag))
+ [[(Number::intValue [] (:coerce Number tag))
(lux-object value)]
[tag (#.Some value)]])
(#.Some [tag (maybe.default (host.null) ?flag) value])
@@ -101,7 +101,7 @@
(#.Some member)
(case (lux-object member)
(#e.Success parsed-member)
- (recur num-keys (inc idx) (array.write idx (:! Object parsed-member) output))
+ (recur num-keys (inc idx) (array.write idx (:coerce Object parsed-member) output))
(#e.Error error)
#.None)
@@ -117,24 +117,24 @@
(ex.throw Null-Has-No-Lux-Representation "")
(host.instance? Integer js-object)
- (ex.return (Integer::longValue [] (:! Integer js-object)))
+ (ex.return (Integer::longValue [] (:coerce Integer js-object)))
(or (host.instance? java/lang/Boolean js-object)
(host.instance? java/lang/String js-object))
(ex.return js-object)
(host.instance? Number js-object)
- (ex.return (Number::doubleValue [] (:! Number js-object)))
+ (ex.return (Number::doubleValue [] (:coerce Number js-object)))
(~~ (do-template [<interface> <method>]
[(host.instance? <interface> js-object)
- (ex.return (<method> [] (:! <interface> js-object)))]
+ (ex.return (<method> [] (:coerce <interface> js-object)))]
[StructureValue StructureValue::getValue]
[IntValue IntValue::getValue]))
(host.instance? ScriptObjectMirror js-object)
- (let [js-object (:! ScriptObjectMirror js-object)]
+ (let [js-object (:coerce ScriptObjectMirror js-object)]
(case (int js-object)
(#.Some value)
(ex.return value)
@@ -154,17 +154,17 @@
## js-object
## else
- (ex.throw Unknown-Kind-Of-JS-Object (Object::toString [] (:! Object js-object)))))))
+ (ex.throw Unknown-Kind-Of-JS-Object (Object::toString [] (:coerce Object js-object)))))))
## else
- (ex.throw Unknown-Kind-Of-JS-Object (Object::toString [] (:! Object js-object))))))
+ (ex.throw Unknown-Kind-Of-JS-Object (Object::toString [] (:coerce Object js-object))))))
(def: #export (eval code)
(-> Expression (Meta Any))
(function (_ compiler)
(case (|> compiler
(get@ #.host)
- (:! //.Host)
+ (:coerce //.Host)
(get@ #//.interpreter)
(ScriptEngine::eval [code]))
(#e.Error error)
diff --git a/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux
index 305f46adf..5fedc9a9e 100644
--- a/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux
@@ -31,7 +31,7 @@
(def: deg-to-nat
(-> Deg Nat)
- (|>> (:! Nat)))
+ (|>> (:coerce Nat)))
(def: #export translate-deg
(-> Deg (Meta Expression))
diff --git a/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux b/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
index 849ae76c2..317193691 100644
--- a/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
@@ -33,7 +33,7 @@
(wrap [])
tags
- (moduleL.declare-tags tags (macro.export? metaV) (:! Type expressionV)))
+ (moduleL.declare-tags tags (macro.export? metaV) (:coerce Type expressionV)))
(wrap []))
#let [_ (log! (format "DEF " (%ident def-ident)))]]
(wrap []))