aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-10-09 01:16:47 -0400
committerEduardo Julian2020-10-09 01:16:47 -0400
commitbae39f32cddb816a6123697269c20dbf4a65ac19 (patch)
treed9ee53073ebe0d83e29dbd24e0dda8d5dd95dc47 /lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
parent79aa92dfd81d569fe6120b8e5c00d41528801153 (diff)
Also using BIPUSH and SIPUSH during JVM generation.
Diffstat (limited to 'lux-jvm/source/luxc/lang/translation/jvm/primitive.lux')
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/primitive.lux33
1 files changed, 25 insertions, 8 deletions
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
index 469e730de..24eeef49e 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
@@ -22,6 +22,14 @@
(function (_ value)
(operation@wrap (_.GETSTATIC Boolean (if value "TRUE" "FALSE") Boolean)))))
+(import: #long java/lang/Byte
+ (#static MAX_VALUE byte)
+ (#static MIN_VALUE byte))
+
+(import: #long java/lang/Short
+ (#static MAX_VALUE short)
+ (#static MIN_VALUE short))
+
(def: #export (i64 value)
(-> (I64 Any) (Operation Inst))
(case (.int value)
@@ -42,9 +50,18 @@
[+4 _.ICONST_4]
[+5 _.ICONST_5])
- _
- (let [loadI (|> value .int _.long)]
- (operation@wrap (|>> loadI (_.wrap type.long))))))
+ value
+ (let [constantI (cond (and (i.>= (java/lang/Byte::MIN_VALUE) value)
+ (i.<= (java/lang/Byte::MAX_VALUE) value))
+ (|>> (_.BIPUSH value) _.I2L)
+
+ (and (i.>= (java/lang/Short::MIN_VALUE) value)
+ (i.<= (java/lang/Short::MAX_VALUE) value))
+ (|>> (_.SIPUSH value) _.I2L)
+
+ ## else
+ (|> value .int _.long))]
+ (operation@wrap (|>> constantI (_.wrap type.long))))))
(import: #long java/lang/Double
(#static doubleToRawLongBits #manual [double] int))
@@ -78,11 +95,11 @@
[+5.0 _.ICONST_5])
_
- (let [loadI (if (i.= ..d0-bits
- (java/lang/Double::doubleToRawLongBits (:coerce java/lang/Double value)))
- _.DCONST_0
- (_.double value))]
- (operation@wrap (|>> loadI (_.wrap type.double))))))
+ (let [constantI (if (i.= ..d0-bits
+ (java/lang/Double::doubleToRawLongBits (:coerce java/lang/Double value)))
+ _.DCONST_0
+ (_.double value))]
+ (operation@wrap (|>> constantI (_.wrap type.double))))))
(def: #export (text value)
(-> Text (Operation Inst))