From 832a9361b632331e82a64c07baa560487ca8abde Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 29 Dec 2020 00:38:21 -0400 Subject: Moved "lux/data/number" to "lux/math/number". --- lux-jvm/source/luxc/lang/host/jvm/inst.lux | 144 ++++++++++++++--------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'lux-jvm/source/luxc/lang/host/jvm/inst.lux') diff --git a/lux-jvm/source/luxc/lang/host/jvm/inst.lux b/lux-jvm/source/luxc/lang/host/jvm/inst.lux index 9d51a15bb..341ded0e4 100644 --- a/lux-jvm/source/luxc/lang/host/jvm/inst.lux +++ b/lux-jvm/source/luxc/lang/host/jvm/inst.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type int char) - ["." host (#+ import: do-to)] + ["." host (#+ import: do_to)] [abstract [monad (#+ do)]] [control @@ -34,7 +34,7 @@ [phase (#+ Operation)]]]] ["." // (#+ Inst)]) -(def: class-name (|>> type.descriptor descriptor.class-name name.read)) +(def: class_name (|>> type.descriptor descriptor.class_name name.read)) (def: descriptor (|>> type.descriptor descriptor.descriptor)) (def: reflection (|>> type.reflection reflection.reflection)) @@ -42,9 +42,9 @@ (import: java/lang/Object) (import: java/lang/String) -(syntax: (declare {codes (p.many s.local-identifier)}) +(syntax: (declare {codes (p.many s.local_identifier)}) (|> codes - (list@map (function (_ code) (` ((~' #static) (~ (code.local-identifier code)) (~' int))))) + (list@map (function (_ code) (` ((~' #static) (~ (code.local_identifier code)) (~' int))))) wrap)) (`` (import: org/objectweb/asm/Opcodes @@ -147,12 +147,12 @@ ]) ## [Insts] -(def: #export make-label +(def: #export make_label (All [s] (Operation s org/objectweb/asm/Label)) (function (_ state) (#try.Success [state (org/objectweb/asm/Label::new)]))) -(def: #export (with-label action) +(def: #export (with_label action) (All [a] (-> (-> org/objectweb/asm/Label a) a)) (action (org/objectweb/asm/Label::new))) @@ -160,14 +160,14 @@ [(def: #export ( value) (-> Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitLdcInsn ( value)))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitLdcInsn ( value)))))] [boolean Bit function.identity] - [int Int host.long-to-int] + [int Int host.long_to_int] [long Int function.identity] [double Frac function.identity] - [char Nat (|>> .int host.long-to-int host.int-to-char)] + [char Nat (|>> .int host.long_to_int host.int_to_char)] [string Text function.identity] ) @@ -178,8 +178,8 @@ [(def: #export Inst (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitInsn (!prefix )))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitInsn (!prefix )))))] [ICONST_M1] [ICONST_0] [ICONST_1] [ICONST_2] [ICONST_3] [ICONST_4] [ICONST_5] [LCONST_0] [LCONST_1] @@ -190,15 +190,15 @@ (def: #export NULL Inst (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitInsn (!prefix ACONST_NULL))))) + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitInsn (!prefix ACONST_NULL))))) (template [] [(def: #export ( constant) (-> Int Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitIntInsn (!prefix ) constant))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitIntInsn (!prefix ) constant))))] [BIPUSH] [SIPUSH] @@ -208,8 +208,8 @@ [(def: #export Inst (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitInsn (!prefix )))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitInsn (!prefix )))))] [NOP] @@ -271,8 +271,8 @@ [(def: #export ( register) (-> Register Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitVarInsn (!prefix ) (.int register)))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitVarInsn (!prefix ) (.int register)))))] [IINC] [ILOAD] [LLOAD] [FLOAD] [DLOAD] [ALOAD] @@ -283,8 +283,8 @@ [(def: #export ( class field type) (-> (Type Class) Text (Type Value) Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitFieldInsn () (..class-name class) field (..descriptor type)))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitFieldInsn () (..class_name class) field (..descriptor type)))))] [GETSTATIC org/objectweb/asm/Opcodes::GETSTATIC] [PUTSTATIC org/objectweb/asm/Opcodes::PUTSTATIC] @@ -298,8 +298,8 @@ [(def: #export ( class) (-> (Type ) Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitTypeInsn () (..class-name class)))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitTypeInsn () (..class_name class)))))] (~~ (template.splice +))))] @@ -315,32 +315,32 @@ (def: #export (NEWARRAY type) (-> (Type Primitive) Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitIntInsn (org/objectweb/asm/Opcodes::NEWARRAY) - (`` (cond (~~ (template [ ] - [(type@= type) ()] - - [type.boolean org/objectweb/asm/Opcodes::T_BOOLEAN] - [type.byte org/objectweb/asm/Opcodes::T_BYTE] - [type.short org/objectweb/asm/Opcodes::T_SHORT] - [type.int org/objectweb/asm/Opcodes::T_INT] - [type.long org/objectweb/asm/Opcodes::T_LONG] - [type.float org/objectweb/asm/Opcodes::T_FLOAT] - [type.double org/objectweb/asm/Opcodes::T_DOUBLE] - [type.char org/objectweb/asm/Opcodes::T_CHAR])) - ## else - (undefined))))))) + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitIntInsn (org/objectweb/asm/Opcodes::NEWARRAY) + (`` (cond (~~ (template [ ] + [(type@= type) ()] + + [type.boolean org/objectweb/asm/Opcodes::T_BOOLEAN] + [type.byte org/objectweb/asm/Opcodes::T_BYTE] + [type.short org/objectweb/asm/Opcodes::T_SHORT] + [type.int org/objectweb/asm/Opcodes::T_INT] + [type.long org/objectweb/asm/Opcodes::T_LONG] + [type.float org/objectweb/asm/Opcodes::T_FLOAT] + [type.double org/objectweb/asm/Opcodes::T_DOUBLE] + [type.char org/objectweb/asm/Opcodes::T_CHAR])) + ## else + (undefined))))))) (template [ ] - [(def: #export ( class method-name method) + [(def: #export ( class method_name method) (-> (Type Class) Text (Type Method) Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitMethodInsn () - (..class-name class) - method-name - (|> method type.descriptor descriptor.descriptor) - ))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitMethodInsn () + (..class_name class) + method_name + (|> method type.descriptor descriptor.descriptor) + ))))] [INVOKESTATIC org/objectweb/asm/Opcodes::INVOKESTATIC false] [INVOKEVIRTUAL org/objectweb/asm/Opcodes::INVOKEVIRTUAL false] @@ -352,8 +352,8 @@ [(def: #export ( @where) (-> //.Label Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitJumpInsn (!prefix ) @where))))] + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitJumpInsn (!prefix ) @where))))] [IF_ICMPEQ] [IF_ICMPGT] [IF_ICMPLT] [IF_ICMPNE] [IF_ICMPGE] [IF_ICMPLE] @@ -368,46 +368,46 @@ (let [keys+labels (list.sort (function (_ left right) (i.< (product.left left) (product.left right))) keys+labels) - array-size (list.size keys+labels) - keys-array (host.array int array-size) - labels-array (host.array org/objectweb/asm/Label array-size) + array_size (list.size keys+labels) + keys_array (host.array int array_size) + labels_array (host.array org/objectweb/asm/Label array_size) _ (loop [idx 0] - (if (n.< array-size idx) + (if (n.< array_size idx) (let [[key label] (maybe.assume (list.nth idx keys+labels))] (exec - (host.array-write idx (host.long-to-int key) keys-array) - (host.array-write idx label labels-array) + (host.array_write idx (host.long_to_int key) keys_array) + (host.array_write idx label labels_array) (recur (inc idx)))) []))] - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitLookupSwitchInsn default keys-array labels-array))))) + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitLookupSwitchInsn default keys_array labels_array))))) (def: #export (TABLESWITCH min max default labels) (-> Int Int //.Label (List //.Label) Inst) (function (_ visitor) - (let [num-labels (list.size labels) - labels-array (host.array org/objectweb/asm/Label num-labels) + (let [num_labels (list.size labels) + labels_array (host.array org/objectweb/asm/Label num_labels) _ (loop [idx 0] - (if (n.< num-labels idx) - (exec (host.array-write idx + (if (n.< num_labels idx) + (exec (host.array_write idx (maybe.assume (list.nth idx labels)) - labels-array) + labels_array) (recur (inc idx))) []))] - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitTableSwitchInsn min max default labels-array))))) + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitTableSwitchInsn min max default labels_array))))) (def: #export (try @from @to @handler exception) (-> //.Label //.Label //.Label (Type Class) Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitTryCatchBlock @from @to @handler (..class-name exception))))) + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitTryCatchBlock @from @to @handler (..class_name exception))))) (def: #export (label @label) (-> //.Label Inst) (function (_ visitor) - (do-to visitor - (org/objectweb/asm/MethodVisitor::visitLabel @label)))) + (do_to visitor + (org/objectweb/asm/MethodVisitor::visitLabel @label)))) (def: #export (array elementT) (-> (Type Value) Inst) @@ -435,24 +435,24 @@ ## else (undefined))))] - [primitive-wrapper + [primitive_wrapper box.boolean box.byte box.short box.int box.long box.float box.double box.char] - [primitive-unwrap + [primitive_unwrap "booleanValue" "byteValue" "shortValue" "intValue" "longValue" "floatValue" "doubleValue" "charValue"] ) (def: #export (wrap type) (-> (Type Primitive) Inst) - (let [wrapper (type.class (primitive-wrapper type) (list))] + (let [wrapper (type.class (primitive_wrapper type) (list))] (INVOKESTATIC wrapper "valueOf" (type.method [(list type) wrapper (list)])))) (def: #export (unwrap type) (-> (Type Primitive) Inst) - (let [wrapper (type.class (primitive-wrapper type) (list))] + (let [wrapper (type.class (primitive_wrapper type) (list))] (|>> (CHECKCAST wrapper) - (INVOKEVIRTUAL wrapper (primitive-unwrap type) (type.method [(list) type (list)]))))) + (INVOKEVIRTUAL wrapper (primitive_unwrap type) (type.method [(list) type (list)]))))) (def: #export (fuse insts) (-> (List Inst) Inst) -- cgit v1.2.3