aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm/source
diff options
context:
space:
mode:
authorEduardo Julian2021-07-11 01:51:04 -0400
committerEduardo Julian2021-07-11 01:51:04 -0400
commitabe24425ced15fd784ef6c62d6f186af72b491db (patch)
tree42b6e3cbd179c83fae8941fa4b128b13afc766f5 /lux-jvm/source
parent4610968193df10af12c91f699fec39aeb3ef703a (diff)
Re-named ":coerce" to ":as" since it technically doesn't do coercions.
Diffstat (limited to '')
-rw-r--r--lux-jvm/source/luxc/lang/directive/jvm.lux12
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/primitive.lux10
-rw-r--r--lux-jvm/source/program.lux48
3 files changed, 36 insertions, 34 deletions
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux
index 7b3235c06..bcd40a1f8 100644
--- a/lux-jvm/source/luxc/lang/directive/jvm.lux
+++ b/lux-jvm/source/luxc/lang/directive/jvm.lux
@@ -526,9 +526,9 @@
(def: (true_handler extender pseudo)
(-> jvm.Extender Any jvm.Handler)
(function (_ extension_name phase archive inputs)
- (do phase.monad
- [bytecode ((extender pseudo) extension_name phase archive inputs)]
- (wrap (..bytecode (:coerce (/.Bytecode Inst /.Label) bytecode))))))
+ (\ phase.monad map
+ (|>> (:as (/.Bytecode Inst /.Label)) ..bytecode)
+ ((extender pseudo) extension_name phase archive inputs))))
(def: (def::generation extender)
(-> jvm.Extender
@@ -538,13 +538,13 @@
(^ (list nameC valueC))
(do phase.monad
[[_ _ name] (lux/.evaluate! archive Text nameC)
- [_ handlerV] (lux/.generator archive (:coerce Text name) ..Handler valueC)
+ [_ handlerV] (lux/.generator archive (:as Text name) ..Handler valueC)
_ (|> handlerV
(..true_handler extender)
- (extension.install extender (:coerce Text name))
+ (extension.install extender (:as Text name))
directive.lift_generation)
_ (directive.lift_generation
- (generation.log! (format "Generation " (%.text (:coerce Text name)))))]
+ (generation.log! (format "Generation " (%.text (:as Text name)))))]
(wrap directive.no_requirements))
_
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
index 3383e3856..5f3a98b0f 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
@@ -98,12 +98,14 @@
[+5.0 _.ICONST_5])
_
- (let [constantI (if (i.= ..d0-bits
- (java/lang/Double::doubleToRawLongBits (:coerce java/lang/Double value)))
+ (let [constantI (if (|> value
+ (:as java/lang/Double)
+ java/lang/Double::doubleToRawLongBits
+ (i.= ..d0-bits))
_.DCONST_0
(_.double value))]
(operation@wrap (|>> constantI (_.wrap type.double))))))
-(def: #export (text value)
+(def: #export text
(-> Text (Operation Inst))
- (operation@wrap (_.string value)))
+ (|>> _.string operation@wrap))
diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux
index 9dc641d7f..e9f58a71b 100644
--- a/lux-jvm/source/program.lux
+++ b/lux-jvm/source/program.lux
@@ -113,16 +113,16 @@
Expander
(do try.monad
[apply_method (|> macro
- (:coerce java/lang/Object)
+ (:as java/lang/Object)
(java/lang/Object::getClass)
(java/lang/Class::getMethod "apply" _apply2_args))]
- (:coerce (Try (Try [Lux (List Code)]))
- (java/lang/reflect/Method::invoke
- (:coerce java/lang/Object macro)
- (|> (ffi.array java/lang/Object 2)
- (ffi.array_write 0 (:coerce java/lang/Object inputs))
- (ffi.array_write 1 (:coerce java/lang/Object lux)))
- apply_method))))
+ (:as (Try (Try [Lux (List Code)]))
+ (java/lang/reflect/Method::invoke
+ (:as java/lang/Object macro)
+ (|> (ffi.array java/lang/Object 2)
+ (ffi.array_write 0 (:as java/lang/Object inputs))
+ (ffi.array_write 1 (:as java/lang/Object lux)))
+ apply_method))))
(def: how_to_wrap_a_phase
Synthesis
@@ -214,13 +214,13 @@
(: (Try java/lang/Object))
(do try.monad
[apply_method (|> phase_wrapper
- (:coerce java/lang/Object)
+ (:as java/lang/Object)
(java/lang/Object::getClass)
(java/lang/Class::getMethod runtime.apply_method _apply1_args))]
(java/lang/reflect/Method::invoke
- (:coerce java/lang/Object phase_wrapper)
+ (:as java/lang/Object phase_wrapper)
(|> (ffi.array java/lang/Object 1)
- (ffi.array_write 0 (:coerce java/lang/Object phase)))
+ (ffi.array_write 0 (:as java/lang/Object phase)))
apply_method)))))))
(def: #export platform
@@ -241,30 +241,30 @@
(def: (extender phase_wrapper)
(-> platform.Phase_Wrapper Extender)
## TODO: Stop relying on coercions ASAP.
- (<| (:coerce Extender)
+ (<| (:as Extender)
(function (@self handler))
- (:coerce Handler)
+ (:as Handler)
(function (@self name phase))
- (:coerce Phase)
+ (:as Phase)
(function (@self archive parameters))
- (:coerce Operation)
+ (:as Operation)
(function (@self state))
- (:coerce Try)
+ (:as Try)
try.assume
- (:coerce Try)
+ (:as Try)
(do try.monad
[method (|> handler
- (:coerce java/lang/Object)
+ (:as java/lang/Object)
(java/lang/Object::getClass)
(java/lang/Class::getMethod "apply" _apply5_args))]
(java/lang/reflect/Method::invoke
- (:coerce java/lang/Object handler)
+ (:as java/lang/Object handler)
(|> (ffi.array java/lang/Object 5)
- (ffi.array_write 0 (:coerce java/lang/Object name))
- (ffi.array_write 1 (:coerce java/lang/Object (phase_wrapper phase)))
- (ffi.array_write 2 (:coerce java/lang/Object archive))
- (ffi.array_write 3 (:coerce java/lang/Object parameters))
- (ffi.array_write 4 (:coerce java/lang/Object state)))
+ (ffi.array_write 0 (:as java/lang/Object name))
+ (ffi.array_write 1 (:as java/lang/Object (phase_wrapper phase)))
+ (ffi.array_write 2 (:as java/lang/Object archive))
+ (ffi.array_write 3 (:as java/lang/Object parameters))
+ (ffi.array_write 4 (:as java/lang/Object state)))
method))))
(def: (declare_success! _)