diff options
author | Eduardo Julian | 2022-04-05 18:32:42 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-04-05 18:32:42 -0400 |
commit | 60daee098f92a44c3b404a9f5801f2e8126ad650 (patch) | |
tree | 7b58d0f6f937b8be5dcb46eaf0411f7961907c8a /lux-jvm/source/luxc/lang/translation/jvm/primitive.lux | |
parent | a2d994a3f7a39964452df7523f69e16b10b266f9 (diff) |
No longer depending on the ASM library for JVM bytecode generation.
Diffstat (limited to '')
-rw-r--r-- | lux-jvm/source/luxc/lang/translation/jvm/primitive.lux | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux deleted file mode 100644 index 734b55316..000000000 --- a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux +++ /dev/null @@ -1,114 +0,0 @@ -(.using - [library - [lux {"-" i64} - ["[0]" ffi {"+" import:}] - [macro - ["^" pattern]] - [math - [number - ["i" int]]] - [target - [jvm - ["[0]" type]]] - [tool - [compiler - [phase ("operation@[0]" monad)]]]]] - [luxc - [lang - [host - ["[0]" jvm {"+" Inst Operation} - ["_" inst]]]]]) - -(def: .public bit - (-> Bit (Operation Inst)) - (let [Boolean (type.class "java.lang.Boolean" (list))] - (function (_ value) - (operation@in (_.GETSTATIC Boolean (if value "TRUE" "FALSE") Boolean))))) - -(import: java/lang/Byte - "[1]::[0]" - ("static" MAX_VALUE byte) - ("static" MIN_VALUE byte)) - -(import: java/lang/Short - "[1]::[0]" - ("static" MAX_VALUE short) - ("static" MIN_VALUE short)) - -(def: .public (i64 value) - (-> (I64 Any) (Operation Inst)) - (case (.int value) - (^.template [<int> <instruction>] - [<int> - (operation@in (|>> <instruction> (_.wrap type.long)))]) - ([+0 _.LCONST_0] - [+1 _.LCONST_1]) - - (^.template [<int> <instruction>] - [<int> - (operation@in (|>> <instruction> _.I2L (_.wrap type.long)))]) - ([-1 _.ICONST_M1] - ... [+0 _.ICONST_0] - ... [+1 _.ICONST_1] - [+2 _.ICONST_2] - [+3 _.ICONST_3] - [+4 _.ICONST_4] - [+5 _.ICONST_5]) - - 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@in (|>> constantI (_.wrap type.long)))))) - -(import: java/lang/Double - "[1]::[0]" - ("static" doubleToRawLongBits "manual" [double] int)) - -(def: d0-bits - Int - (java/lang/Double::doubleToRawLongBits +0.0)) - -(def: .public (f64 value) - (-> Frac (Operation Inst)) - (case value - (^.template [<int> <instruction>] - [<int> - (operation@in (|>> <instruction> (_.wrap type.double)))]) - ([+1.0 _.DCONST_1]) - - (^.template [<int> <instruction>] - [<int> - (operation@in (|>> <instruction> _.F2D (_.wrap type.double)))]) - ([+2.0 _.FCONST_2]) - - (^.template [<int> <instruction>] - [<int> - (operation@in (|>> <instruction> _.I2D (_.wrap type.double)))]) - ([-1.0 _.ICONST_M1] - ... [+0.0 _.ICONST_0] - ... [+1.0 _.ICONST_1] - ... [+2.0 _.ICONST_2] - [+3.0 _.ICONST_3] - [+4.0 _.ICONST_4] - [+5.0 _.ICONST_5]) - - _ - (let [constantI (if (|> value - (as java/lang/Double) - java/lang/Double::doubleToRawLongBits - (i.= ..d0-bits)) - _.DCONST_0 - (_.double value))] - (operation@in (|>> constantI (_.wrap type.double)))))) - -(def: .public text - (-> Text (Operation Inst)) - (|>> _.string operation@in)) |