aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/generator/procedure
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/generator/procedure')
-rw-r--r--new-luxc/source/luxc/generator/procedure/host.jvm.lux168
1 files changed, 168 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/generator/procedure/host.jvm.lux b/new-luxc/source/luxc/generator/procedure/host.jvm.lux
index 66b7bc77e..c99c23385 100644
--- a/new-luxc/source/luxc/generator/procedure/host.jvm.lux
+++ b/new-luxc/source/luxc/generator/procedure/host.jvm.lux
@@ -98,9 +98,177 @@
(@;install "short-to-long" (@;unary convert//short-to-long))
)))
+(do-template [<name> <op> <unwrapX> <unwrapY> <wrap>]
+ [(def: (<name> [xI yI])
+ @;Binary
+ (|>. xI ($i;unwrap <unwrapX>)
+ yI ($i;unwrap <unwrapY>)
+ <op> ($i;wrap <wrap>)))]
+
+ [int//+ $i;IADD #$;Int #$;Int #$;Int]
+ [int//- $i;ISUB #$;Int #$;Int #$;Int]
+ [int//* $i;IMUL #$;Int #$;Int #$;Int]
+ [int/// $i;IDIV #$;Int #$;Int #$;Int]
+ [int//% $i;IREM #$;Int #$;Int #$;Int]
+ [int//and $i;IAND #$;Int #$;Int #$;Int]
+ [int//or $i;IOR #$;Int #$;Int #$;Int]
+ [int//xor $i;IXOR #$;Int #$;Int #$;Int]
+ [int//shl $i;ISHL #$;Int #$;Int #$;Int]
+ [int//shr $i;ISHR #$;Int #$;Int #$;Int]
+ [int//ushr $i;IUSHR #$;Int #$;Int #$;Int]
+
+ [long//+ $i;LADD #$;Long #$;Long #$;Long]
+ [long//- $i;LSUB #$;Long #$;Long #$;Long]
+ [long//* $i;LMUL #$;Long #$;Long #$;Long]
+ [long/// $i;LDIV #$;Long #$;Long #$;Long]
+ [long//% $i;LREM #$;Long #$;Long #$;Long]
+ [long//and $i;LAND #$;Long #$;Long #$;Long]
+ [long//or $i;LOR #$;Long #$;Long #$;Long]
+ [long//xor $i;LXOR #$;Long #$;Long #$;Long]
+ [long//shl $i;LSHL #$;Long #$;Int #$;Long]
+ [long//shr $i;LSHR #$;Long #$;Int #$;Long]
+ [long//ushr $i;LUSHR #$;Long #$;Int #$;Long]
+
+ [float//+ $i;FADD #$;Float #$;Float #$;Float]
+ [float//- $i;FSUB #$;Float #$;Float #$;Float]
+ [float//* $i;FMUL #$;Float #$;Float #$;Float]
+ [float/// $i;FDIV #$;Float #$;Float #$;Float]
+ [float//% $i;FREM #$;Float #$;Float #$;Float]
+
+ [double//+ $i;DADD #$;Double #$;Double #$;Double]
+ [double//- $i;DSUB #$;Double #$;Double #$;Double]
+ [double//* $i;DMUL #$;Double #$;Double #$;Double]
+ [double/// $i;DDIV #$;Double #$;Double #$;Double]
+ [double//% $i;DREM #$;Double #$;Double #$;Double]
+ )
+
+(do-template [<name> <op> <unwrapX> <unwrapY> <wrap>]
+ [(def: (<name> [xI yI])
+ @;Binary
+ (<| $i;with-label (function [@then])
+ $i;with-label (function [@end])
+ (|>. xI ($i;unwrap <unwrapX>)
+ yI ($i;unwrap <unwrapY>)
+ (<op> @then)
+ ($i;GETSTATIC "java.lang.Boolean" "FALSE" ($t;class "java.lang.Boolean" (list)))
+ ($i;GOTO @end)
+ ($i;label @then)
+ ($i;GETSTATIC "java.lang.Boolean" "TRUE" ($t;class "java.lang.Boolean" (list)))
+ ($i;label @end))))]
+
+ [int//= $i;IF_ICMPEQ #$;Int #$;Int #$;Boolean]
+ [int//< $i;IF_ICMPLT #$;Int #$;Int #$;Boolean]
+
+ [char//= $i;IF_ICMPEQ #$;Char #$;Char #$;Boolean]
+ [char//< $i;IF_ICMPLT #$;Char #$;Char #$;Boolean]
+ )
+
+(do-template [<name> <op> <reference> <unwrapX> <unwrapY> <wrap>]
+ [(def: (<name> [xI yI])
+ @;Binary
+ (<| $i;with-label (function [@then])
+ $i;with-label (function [@end])
+ (|>. xI ($i;unwrap <unwrapX>)
+ yI ($i;unwrap <unwrapY>)
+ <op>
+ ($i;int <reference>)
+ ($i;IF_ICMPEQ @then)
+ ($i;GETSTATIC "java.lang.Boolean" "FALSE" ($t;class "java.lang.Boolean" (list)))
+ ($i;GOTO @end)
+ ($i;label @then)
+ ($i;GETSTATIC "java.lang.Boolean" "TRUE" ($t;class "java.lang.Boolean" (list)))
+ ($i;label @end))))]
+
+ [long//= $i;LCMP 0 #$;Long #$;Long #$;Boolean]
+ [long//< $i;LCMP -1 #$;Long #$;Long #$;Boolean]
+
+ [float//= $i;FCMPG 0 #$;Float #$;Float #$;Boolean]
+ [float//< $i;FCMPG -1 #$;Float #$;Float #$;Boolean]
+
+ [double//= $i;DCMPG 0 #$;Double #$;Double #$;Boolean]
+ [double//< $i;DCMPG -1 #$;Double #$;Double #$;Boolean]
+ )
+
+(def: int-procs
+ @;Bundle
+ (<| (@;prefix "int")
+ (|> (dict;new text;Hash<Text>)
+ (@;install "+" (@;binary int//+))
+ (@;install "-" (@;binary int//-))
+ (@;install "*" (@;binary int//*))
+ (@;install "/" (@;binary int///))
+ (@;install "%" (@;binary int//%))
+ (@;install "=" (@;binary int//=))
+ (@;install "<" (@;binary int//<))
+ (@;install "and" (@;binary int//and))
+ (@;install "or" (@;binary int//or))
+ (@;install "xor" (@;binary int//xor))
+ (@;install "shl" (@;binary int//shl))
+ (@;install "shr" (@;binary int//shr))
+ (@;install "ushr" (@;binary int//ushr))
+ )))
+
+(def: long-procs
+ @;Bundle
+ (<| (@;prefix "long")
+ (|> (dict;new text;Hash<Text>)
+ (@;install "+" (@;binary long//+))
+ (@;install "-" (@;binary long//-))
+ (@;install "*" (@;binary long//*))
+ (@;install "/" (@;binary long///))
+ (@;install "%" (@;binary long//%))
+ (@;install "=" (@;binary long//=))
+ (@;install "<" (@;binary long//<))
+ (@;install "and" (@;binary long//and))
+ (@;install "or" (@;binary long//or))
+ (@;install "xor" (@;binary long//xor))
+ (@;install "shl" (@;binary long//shl))
+ (@;install "shr" (@;binary long//shr))
+ (@;install "ushr" (@;binary long//ushr))
+ )))
+
+(def: float-procs
+ @;Bundle
+ (<| (@;prefix "float")
+ (|> (dict;new text;Hash<Text>)
+ (@;install "+" (@;binary float//+))
+ (@;install "-" (@;binary float//-))
+ (@;install "*" (@;binary float//*))
+ (@;install "/" (@;binary float///))
+ (@;install "%" (@;binary float//%))
+ (@;install "=" (@;binary float//=))
+ (@;install "<" (@;binary float//<))
+ )))
+
+(def: double-procs
+ @;Bundle
+ (<| (@;prefix "double")
+ (|> (dict;new text;Hash<Text>)
+ (@;install "+" (@;binary double//+))
+ (@;install "-" (@;binary double//-))
+ (@;install "*" (@;binary double//*))
+ (@;install "/" (@;binary double///))
+ (@;install "%" (@;binary double//%))
+ (@;install "=" (@;binary double//=))
+ (@;install "<" (@;binary double//<))
+ )))
+
+(def: char-procs
+ @;Bundle
+ (<| (@;prefix "char")
+ (|> (dict;new text;Hash<Text>)
+ (@;install "=" (@;binary char//=))
+ (@;install "<" (@;binary char//<))
+ )))
+
(def: #export procedures
@;Bundle
(<| (@;prefix "jvm")
(|> (dict;new text;Hash<Text>)
(dict;merge conversion-procs)
+ (dict;merge int-procs)
+ (dict;merge long-procs)
+ (dict;merge float-procs)
+ (dict;merge double-procs)
+ (dict;merge char-procs)
)))