From d9965e587905cd715ecd4c7150236d660321a02c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 17:18:30 -0400 Subject: Optimized text clipping. --- .../source/luxc/lang/translation/jvm/procedure/common.jvm.lux | 9 ++++----- new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux | 10 ++-------- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'new-luxc') diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux index 1b784ee76..a0a34d9ad 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux @@ -223,7 +223,7 @@ paramI ))] - [text::= id id + [text::= (<|) (<|) (_.INVOKEVIRTUAL "java.lang.Object" "equals" (_t.method (list ///.$Object) (#.Some _t.boolean) (list)) #0) (_.wrap #$.Boolean)] [text::< ..check-stringI ..check-stringI @@ -231,10 +231,10 @@ (predicateI _.IFLT)] [text::concat ..check-stringI ..check-stringI (_.INVOKEVIRTUAL "java.lang.String" "concat" (_t.method (list $String) (#.Some $String) (list)) #0) - id] + (<|)] [text::char ..check-stringI jvm-intI (_.INVOKESTATIC ///.runtime-class "text_char" (_t.method (list $String _t.int) (#.Some ///.$Variant) (list)) #0) - id] + (<|)] ) (do-template [ ] @@ -246,8 +246,7 @@ ))] [text::clip ..check-stringI jvm-intI jvm-intI - (_.INVOKESTATIC ///.runtime-class "text_clip" - (_t.method (list $String _t.int _t.int) (#.Some ///.$Variant) (list)) #0)] + (_.INVOKEVIRTUAL "java.lang.String" "substring" (_t.method (list _t.int _t.int) (#.Some $String) (list)) #0)] ) (def: index-method Method (_t.method (list $String _t.int) (#.Some _t.int) (list))) diff --git a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux index 20c31bd5d..3c8563d75 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux @@ -133,17 +133,11 @@ (def: text-methods Def - (|>> ($d.method #$.Public $.staticM "text_clip" ($t.method (list $String $t.int $t.int) (#.Some $Variant) (list)) + (|>> ($d.method #$.Public $.staticM "text_char" ($t.method (list $String $t.int) (#.Some $Variant) (list)) (try-methodI (|>> (_.ALOAD 0) (_.ILOAD 1) - (_.ILOAD 2) - (_.INVOKEVIRTUAL "java.lang.String" "substring" ($t.method (list $t.int $t.int) (#.Some $String) (list)) #0)))) - ($d.method #$.Public $.staticM "text_char" ($t.method (list $String $t.int) (#.Some $Variant) (list)) - (try-methodI - (|>> (_.ALOAD 0) - (_.ILOAD 1) - (_.INVOKEVIRTUAL "java.lang.String" "codePointAt" ($t.method (list $t.int) (#.Some $t.int) (list)) #0) + (_.INVOKEVIRTUAL "java.lang.String" "charAt" ($t.method (list $t.int) (#.Some $t.char) (list)) #0) _.I2L (_.wrap #$.Long)))) )) -- cgit v1.2.3 From 312cc7dc5f0be0ef0a48ea8470d8ee64b929bc7b Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 19:02:47 -0400 Subject: "lux text char" is now unsafe/optimized. --- .../luxc/lang/translation/jvm/procedure/common.jvm.lux | 4 ++-- new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux | 14 -------------- 2 files changed, 2 insertions(+), 16 deletions(-) (limited to 'new-luxc') diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux index a0a34d9ad..e45a6f8cf 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux @@ -233,8 +233,8 @@ (_.INVOKEVIRTUAL "java.lang.String" "concat" (_t.method (list $String) (#.Some $String) (list)) #0) (<|)] [text::char ..check-stringI jvm-intI - (_.INVOKESTATIC ///.runtime-class "text_char" (_t.method (list $String _t.int) (#.Some ///.$Variant) (list)) #0) - (<|)] + (_.INVOKEVIRTUAL "java.lang.String" "charAt" (_t.method (list _t.int) (#.Some _t.char) (list)) #0) + lux-intI] ) (do-template [ ] diff --git a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux index 3c8563d75..05641fe22 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux @@ -129,19 +129,6 @@ (_.wrap #$.Double)))) )) -(def: clz-method Method ($t.method (list $t.long) (#.Some $t.int) (list))) - -(def: text-methods - Def - (|>> ($d.method #$.Public $.staticM "text_char" ($t.method (list $String $t.int) (#.Some $Variant) (list)) - (try-methodI - (|>> (_.ALOAD 0) - (_.ILOAD 1) - (_.INVOKEVIRTUAL "java.lang.String" "charAt" ($t.method (list $t.int) (#.Some $t.char) (list)) #0) - _.I2L - (_.wrap #$.Long)))) - )) - (def: pm-methods Def (let [tuple-sizeI (|>> (_.ALOAD 0) _.ARRAYLENGTH) @@ -320,7 +307,6 @@ (let [bytecode ($d.class #$.V1_6 #$.Public $.finalC //.runtime-class (list) ["java.lang.Object" (list)] (list) (|>> adt-methods frac-methods - text-methods pm-methods io-methods))] (do phase.Monad -- cgit v1.2.3