From b63ac226cc2ea843f08f7c72b18d22602462c624 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 7 Sep 2019 01:50:37 -0400 Subject: Modified compiler's machinery to use the new abstractions for descriptors and signatures. --- .../luxc/lang/translation/jvm/procedure/common.lux | 109 ++++++++++----------- 1 file changed, 54 insertions(+), 55 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/jvm/procedure/common.lux') diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.lux index 6e7891460..06ae2ba26 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.lux @@ -16,8 +16,7 @@ ["." dictionary]]] [target [jvm - [type - ["." descriptor]]]] + ["." type]]] [tool [compiler ["." synthesis (#+ Synthesis %synthesis)] @@ -53,19 +52,19 @@ (#static MIN_VALUE Double) (#static MAX_VALUE Double)) -(def: $String (descriptor.class "java.lang.String")) -(def: $CharSequence (descriptor.class "java.lang.CharSequence")) -(def: $System (descriptor.class "java.lang.System")) -(def: $Object (descriptor.class "java.lang.Object")) +(def: $String (type.class "java.lang.String" (list))) +(def: $CharSequence (type.class "java.lang.CharSequence" (list))) +(def: $System (type.class "java.lang.System" (list))) +(def: $Object (type.class "java.lang.Object" (list))) -(def: lux-intI Inst (|>> _.I2L (_.wrap descriptor.long))) -(def: jvm-intI Inst (|>> (_.unwrap descriptor.long) _.L2I)) +(def: lux-intI Inst (|>> _.I2L (_.wrap type.long))) +(def: jvm-intI Inst (|>> (_.unwrap type.long) _.L2I)) (def: check-stringI Inst (_.CHECKCAST $String)) (def: (predicateI tester) (-> (-> Label Inst) Inst) - (let [$Boolean (descriptor.class "java.lang.Boolean")] + (let [$Boolean (type.class "java.lang.Boolean" (list))] (<| _.with-label (function (_ @then)) _.with-label (function (_ @end)) (|>> (tester @then) @@ -111,7 +110,7 @@ conditionalsG (|> conditionalsG+ (list@map product.right) _.fuse)]] - (wrap (|>> inputG (_.unwrap descriptor.long) _.L2I + (wrap (|>> inputG (_.unwrap type.long) _.L2I (_.LOOKUPSWITCH @else table) conditionalsG (_.label @else) @@ -130,15 +129,15 @@ (|>> riskyI (_.CHECKCAST ///.$Function) (_.INVOKESTATIC runtime.$Runtime "try" - (descriptor.method [(list ///.$Function) ///.$Variant]) + (type.method [(list ///.$Function) ///.$Variant (list)]) #0))) (template [ ] [(def: ( [maskI inputI]) (Binary Inst) - (|>> inputI (_.unwrap descriptor.long) - maskI (_.unwrap descriptor.long) - (_.wrap descriptor.long)))] + (|>> inputI (_.unwrap type.long) + maskI (_.unwrap type.long) + (_.wrap type.long)))] [i64::and _.LAND] [i64::or _.LOR] @@ -148,10 +147,10 @@ (template [ ] [(def: ( [shiftI inputI]) (Binary Inst) - (|>> inputI (_.unwrap descriptor.long) + (|>> inputI (_.unwrap type.long) shiftI jvm-intI - (_.wrap descriptor.long)))] + (_.wrap type.long)))] [i64::left-shift _.LSHL] [i64::arithmetic-right-shift _.LSHR] @@ -163,9 +162,9 @@ (Nullary Inst) (|>> (_.wrap )))] - [f64::smallest (_.double (Double::MIN_VALUE)) descriptor.double] - [f64::min (_.double (f.* -1.0 (Double::MAX_VALUE))) descriptor.double] - [f64::max (_.double (Double::MAX_VALUE)) descriptor.double] + [f64::smallest (_.double (Double::MIN_VALUE)) type.double] + [f64::min (_.double (f.* -1.0 (Double::MAX_VALUE))) type.double] + [f64::max (_.double (Double::MAX_VALUE)) type.double] ) (template [ ] @@ -176,25 +175,25 @@ (_.wrap )))] - [i64::+ descriptor.long _.LADD] - [i64::- descriptor.long _.LSUB] - [i64::* descriptor.long _.LMUL] - [i64::/ descriptor.long _.LDIV] - [i64::% descriptor.long _.LREM] + [i64::+ type.long _.LADD] + [i64::- type.long _.LSUB] + [i64::* type.long _.LMUL] + [i64::/ type.long _.LDIV] + [i64::% type.long _.LREM] - [f64::+ descriptor.double _.DADD] - [f64::- descriptor.double _.DSUB] - [f64::* descriptor.double _.DMUL] - [f64::/ descriptor.double _.DDIV] - [f64::% descriptor.double _.DREM] + [f64::+ type.double _.DADD] + [f64::- type.double _.DSUB] + [f64::* type.double _.DMUL] + [f64::/ type.double _.DDIV] + [f64::% type.double _.DREM] ) -(template [ ] +(template [ ] [(template [ ] [(def: ( [paramI subjectI]) (Binary Inst) - (|>> subjectI (_.unwrap ) - paramI (_.unwrap ) + (|>> subjectI (_.unwrap ) + paramI (_.unwrap ) (_.int ) (predicateI _.IF_ICMPEQ)))] @@ -202,8 +201,8 @@ [ +0] [ -1])] - [i64::= i64::< descriptor.long _.LCMP] - [f64::= f64::< descriptor.double _.DCMPG] + [i64::= i64::< type.long _.LCMP] + [f64::= f64::< type.double _.DCMPG] ) (template [ ] @@ -211,22 +210,22 @@ (Unary Inst) (|>> inputI ))] - [i64::f64 (_.unwrap descriptor.long) (<| (_.wrap descriptor.double) _.L2D)] - [i64::char (_.unwrap descriptor.long) - ((|>> _.L2I _.I2C (_.INVOKESTATIC (descriptor.class "java.lang.Character") "toString" (descriptor.method [(list descriptor.char) $String]) #0)))] + [i64::f64 (_.unwrap type.long) (<| (_.wrap type.double) _.L2D)] + [i64::char (_.unwrap type.long) + ((|>> _.L2I _.I2C (_.INVOKESTATIC (type.class "java.lang.Character" (list)) "toString" (type.method [(list type.char) $String (list)]) #0)))] - [f64::i64 (_.unwrap descriptor.double) (<| (_.wrap descriptor.long) _.D2L)] - [f64::encode (_.unwrap descriptor.double) - (_.INVOKESTATIC (descriptor.class "java.lang.Double") "toString" (descriptor.method [(list descriptor.double) $String]) #0)] + [f64::i64 (_.unwrap type.double) (<| (_.wrap type.long) _.D2L)] + [f64::encode (_.unwrap type.double) + (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "toString" (type.method [(list type.double) $String (list)]) #0)] [f64::decode ..check-stringI - (_.INVOKESTATIC runtime.$Runtime "decode_frac" (descriptor.method [(list $String) ///.$Variant]) #0)] + (_.INVOKESTATIC runtime.$Runtime "decode_frac" (type.method [(list $String) ///.$Variant (list)]) #0)] ) (def: (text::size inputI) (Unary Inst) (|>> inputI ..check-stringI - (_.INVOKEVIRTUAL $String "length" (descriptor.method [(list) descriptor.int]) #0) + (_.INVOKEVIRTUAL $String "length" (type.method [(list) type.int (list)]) #0) lux-intI)) (template [ ] @@ -237,13 +236,13 @@ ))] [text::= (<|) (<|) - (_.INVOKEVIRTUAL $Object "equals" (descriptor.method [(list $Object) descriptor.boolean]) #0) - (_.wrap descriptor.boolean)] + (_.INVOKEVIRTUAL $Object "equals" (type.method [(list $Object) type.boolean (list)]) #0) + (_.wrap type.boolean)] [text::< ..check-stringI ..check-stringI - (_.INVOKEVIRTUAL $String "compareTo" (descriptor.method [(list $String) descriptor.int]) #0) + (_.INVOKEVIRTUAL $String "compareTo" (type.method [(list $String) type.int (list)]) #0) (predicateI _.IFLT)] [text::char ..check-stringI jvm-intI - (_.INVOKEVIRTUAL $String "charAt" (descriptor.method [(list descriptor.int) descriptor.char]) #0) + (_.INVOKEVIRTUAL $String "charAt" (type.method [(list type.int) type.char (list)]) #0) lux-intI] ) @@ -251,16 +250,16 @@ (Binary Inst) (|>> leftI ..check-stringI rightI ..check-stringI - (_.INVOKEVIRTUAL $String "concat" (descriptor.method [(list $String) $String]) #0))) + (_.INVOKEVIRTUAL $String "concat" (type.method [(list $String) $String (list)]) #0))) (def: (text::clip [startI endI subjectI]) (Trinary Inst) (|>> subjectI ..check-stringI startI jvm-intI endI jvm-intI - (_.INVOKEVIRTUAL $String "substring" (descriptor.method [(list descriptor.int descriptor.int) $String]) #0))) + (_.INVOKEVIRTUAL $String "substring" (type.method [(list type.int type.int) $String (list)]) #0))) -(def: index-method (descriptor.method [(list $String descriptor.int) descriptor.int])) +(def: index-method (type.method [(list $String type.int) type.int (list)])) (def: (text::index [startI partI textI]) (Trinary Inst) (<| _.with-label (function (_ @not-found)) @@ -280,10 +279,10 @@ runtime.noneI (_.label @end)))) -(def: string-method (descriptor.method [(list $String) descriptor.void])) +(def: string-method (type.method [(list $String) type.void (list)])) (def: (io::log messageI) (Unary Inst) - (let [$PrintStream (descriptor.class "java.io.PrintStream")] + (let [$PrintStream (type.class "java.io.PrintStream" (list))] (|>> (_.GETSTATIC $System "out" $PrintStream) messageI ..check-stringI @@ -292,7 +291,7 @@ (def: (io::error messageI) (Unary Inst) - (let [$Error (descriptor.class "java.lang.Error")] + (let [$Error (type.class "java.lang.Error" (list))] (|>> (_.NEW $Error) _.DUP messageI @@ -303,13 +302,13 @@ (def: (io::exit codeI) (Unary Inst) (|>> codeI jvm-intI - (_.INVOKESTATIC $System "exit" (descriptor.method [(list descriptor.int) descriptor.void]) #0) + (_.INVOKESTATIC $System "exit" (type.method [(list type.int) type.void (list)]) #0) _.NULL)) (def: (io::current-time _) (Nullary Inst) - (|>> (_.INVOKESTATIC $System "currentTimeMillis" (descriptor.method [(list) descriptor.long]) #0) - (_.wrap descriptor.long))) + (|>> (_.INVOKESTATIC $System "currentTimeMillis" (type.method [(list) type.long (list)]) #0) + (_.wrap type.long))) (def: bundle::lux Bundle -- cgit v1.2.3