diff options
author | Eduardo Julian | 2021-08-11 02:38:59 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-08-11 02:38:59 -0400 |
commit | a62ce3f9c2b605e0033f4772b0f64c4525de4d86 (patch) | |
tree | ecbabe8f110d82b2e6481cf7c0532d4bd4386570 /lux-jvm | |
parent | 464b6e8f5e6c62f58fa8c7ff61ab2ad215e98bd1 (diff) |
Relocated maybe and lazy from data to control.
Diffstat (limited to 'lux-jvm')
10 files changed, 108 insertions, 108 deletions
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux index 8a06289da..fa8b1420e 100644 --- a/lux-jvm/source/luxc/lang/directive/jvm.lux +++ b/lux-jvm/source/luxc/lang/directive/jvm.lux @@ -586,7 +586,7 @@ (-> Text ..Phase Archive i (..Operation Requirements))] ..Handler)) (function (_ extension_name phase archive input) - (case (<code>.run parser input) + (case (<code>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -601,7 +601,7 @@ (Parser <type>) (do {! <>.monad} [raw <code>.text] - (<>.lift (<text>.run <parser> raw))))] + (<>.lift (<text>.result <parser> raw))))] [class_declaration Declaration parser.declaration'] [class (Type Class) parser.class] diff --git a/lux-jvm/source/luxc/lang/host/jvm/inst.lux b/lux-jvm/source/luxc/lang/host/jvm/inst.lux index f7a8e6b18..7229babab 100644 --- a/lux-jvm/source/luxc/lang/host/jvm/inst.lux +++ b/lux-jvm/source/luxc/lang/host/jvm/inst.lux @@ -6,12 +6,12 @@ [monad (#+ do)]] [control ["." function] + ["." maybe] ["." try] ["p" parser ["s" code]]] [data ["." product] - ["." maybe] [collection ["." list ("#@." functor)]]] [macro @@ -367,9 +367,9 @@ (def: .public (LOOKUPSWITCH default keys+labels) (-> //.Label (List [Int //.Label]) Inst) (function (_ visitor) - (let [keys+labels (list.sort (function (_ left right) - (i.< (product.left left) (product.left right))) - keys+labels) + (let [keys+labels (list.sorted (function (_ left right) + (i.< (product.left left) (product.left right))) + keys+labels) array_size (list.size keys+labels) keys_array (ffi.array int array_size) labels_array (ffi.array org/objectweb/asm/Label array_size) diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux index 46242abc7..dbf49b552 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm.lux @@ -6,6 +6,7 @@ [monad (#+ do)]] [control pipe + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] ["." io (#+ IO io)] @@ -14,7 +15,6 @@ [data [binary (#+ Binary)] ["." product] - ["." maybe] ["." text ("#@." hash) ["%" format (#+ format)]] [collection @@ -126,25 +126,25 @@ (|>> valueI (inst.PUTSTATIC (type.class bytecode_name (list)) ..value_field ..$Value) inst.RETURN))))] - (io.run (do (try.with io.monad) - [_ (loader.store eval_class bytecode library) - class (loader.load eval_class loader) - value (\ io.monad in (..class_value eval_class class))] - (in [value - [eval_class bytecode]]))))) + (io.run! (do (try.with io.monad) + [_ (loader.store eval_class bytecode library) + class (loader.load eval_class loader) + value (\ io.monad in (..class_value eval_class class))] + (in [value + [eval_class bytecode]]))))) (def: (execute! library loader [class_name class_bytecode]) (-> Library java/lang/ClassLoader Definition (Try Any)) - (io.run (do (try.with io.monad) - [existing_class? (|> (atom.read library) - (\ io.monad map (function (_ library) - (dictionary.key? library class_name))) - (try.lifted io.monad) - (: (IO (Try Bit)))) - _ (if existing_class? - (in []) - (loader.store class_name class_bytecode library))] - (loader.load class_name loader)))) + (io.run! (do (try.with io.monad) + [existing_class? (|> (atom.read library) + (\ io.monad map (function (_ library) + (dictionary.key? library class_name))) + (try.lifted io.monad) + (: (IO (Try Bit)))) + _ (if existing_class? + (in []) + (loader.store class_name class_bytecode library))] + (loader.load class_name loader)))) (def: (define! library loader context custom valueI) (-> Library java/lang/ClassLoader generation.Context (Maybe Text) Inst (Try [Text Any Definition])) @@ -175,11 +175,11 @@ [(..class_name context) bytecode]) (def: (re_learn context custom [_ bytecode]) - (io.run + (io.run! (loader.store (maybe.else (..class_name context) custom) bytecode library))) (def: (re_load context custom [directive_name bytecode]) - (io.run + (io.run! (do (try.with io.monad) [.let [class_name (maybe.else (..class_name context) custom)] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/common.lux index 283081608..b6bba249f 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/common.lux @@ -53,7 +53,7 @@ ... (function (_ (^@ def-name [def-module def-name]) def-bytecode) ... (let [normal-name (format (name.normalize def-name) (%n (text/hash def-name))) ... class-name (format (text.replace-all "/" "." def-module) "." normal-name)] -... (<| (macro.run state) +... (<| (macro.result state) ... (do macro.monad ... [_ (..store-class class-name def-bytecode) ... class (..load-class class-name)] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux index 14d31d4e2..eaee3b51e 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux @@ -47,7 +47,7 @@ (-> Text Phase Archive s (Operation Inst))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux index 2d94e822c..6fc52a0ab 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -5,6 +5,7 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe ("#\." functor)] ["." exception (#+ exception:)] ["." function] ["<>" parser ("#\." monad) @@ -12,7 +13,6 @@ ["<.>" synthesis (#+ Parser)]]] [data ["." product] - ["." maybe ("#\." functor)] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux index b39157480..dfca4a6e6 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux @@ -345,11 +345,11 @@ [functionI (generate archive functionS) argsI (monad.map @ (generate archive) argsS) .let [applyI (|> argsI - (list.chunk //runtime.num_apply_variants) - (list@map (.function (_ chunkI+) + (list.sub //runtime.num_apply_variants) + (list@map (.function (_ subI+) (|>> (_.CHECKCAST //.$Function) - (_.fuse chunkI+) - (_.INVOKEVIRTUAL //.$Function //runtime.apply_method (//runtime.apply_signature (list.size chunkI+)))))) + (_.fuse subI+) + (_.INVOKEVIRTUAL //.$Function //runtime.apply_method (//runtime.apply_signature (list.size subI+)))))) _.fuse)]] (in (|>> functionI applyI)))) diff --git a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux index aad3955cf..ae3b84518 100644 --- a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux +++ b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux @@ -1,12 +1,12 @@ (.module: [lux #* [control + pipe [monad (#+ do)] - pipe] + ["." maybe]] [data ["e" error] ["." product] - ["." maybe] [text ("text/" Equivalence<Text>) format] [collection @@ -41,7 +41,7 @@ (typeA.with-type output-type (_primitive.analyse (` ((~ (code.text procedure)) (~+ params))))))) (analysis.with-current-module "") - (macro.run (initL.compiler [])) + (macro.result (initL.compiler [])) (case> (#e.Success _) <success> @@ -62,7 +62,7 @@ (typeA.with-type output-type (_primitive.analyse syntax)))) (analysis.with-current-module "") - (macro.run (initL.compiler [])) + (macro.result (initL.compiler [])) (case> (#e.Success _) <success> diff --git a/lux-jvm/test/test/luxc/lang/synthesis/procedure.lux b/lux-jvm/test/test/luxc/lang/synthesis/procedure.lux index ab6c9de6f..2c4c5f599 100644 --- a/lux-jvm/test/test/luxc/lang/synthesis/procedure.lux +++ b/lux-jvm/test/test/luxc/lang/synthesis/procedure.lux @@ -26,7 +26,7 @@ (la.procedure nameA argsA)) (case> (^ [_ (#.Form (list& [_ (#.Text procedure)] argsS))]) (and (text/= nameA procedure) - (list.every? (product.uncurry corresponds?) + (list.every? (product.uncurried corresponds?) (list.zip2 argsA argsS))) _ diff --git a/lux-jvm/test/test/luxc/lang/translation/jvm.lux b/lux-jvm/test/test/luxc/lang/translation/jvm.lux index 7c97b1e78..233178409 100644 --- a/lux-jvm/test/test/luxc/lang/translation/jvm.lux +++ b/lux-jvm/test/test/luxc/lang/translation/jvm.lux @@ -1,10 +1,10 @@ (.module: lux (lux [io] - (control [monad #+ do] - pipe) - (data [maybe] - ["e" error] + (control pipe + [monad #+ do] + [maybe]) + (data ["e" error] [bit] [bit "bit/" Eq<Bit>] [number "int/" Number<Int> Codec<Text,Int>] @@ -35,7 +35,7 @@ [sampleI (expressionT.translate (|> (~ (<tag> <sample>)) <step1> <step2> (`)))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (<test> <sample> (:coerce <cast> valueT)) @@ -51,9 +51,9 @@ ["jvm convert long-to-short" "jvm convert short-to-long" code.int int-sample Int i/=] ["jvm convert long-to-byte" "jvm convert byte-to-long" code.int int-sample Int i/=] )] - ($_ seq - <2step> - ))))) + ($_ seq + <2step> + ))))) (context: "Conversions [Part 2]" (<| (times +100) @@ -67,7 +67,7 @@ [sampleI (expressionT.translate (|> (~ (<tag> <sample>)) <step1> <step2> <step3> (`)))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (<test> <sample> (:coerce <cast> valueT)) @@ -94,7 +94,7 @@ [sampleI (expressionT.translate (|> (~ (<tag> <sample>)) <step1> <step2> <step3> <step4> (`)))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (<test> <sample> (:coerce <cast> valueT)) @@ -135,7 +135,7 @@ (<pre> (<tag> param)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (<test> (<reference> param subject) (:coerce <type> valueT)) @@ -149,9 +149,9 @@ [(format "jvm " <domain> " /") </>] [(format "jvm " <domain> " %") <%>] )] - ($_ seq - <tests> - )))))] + ($_ seq + <tests> + )))))] ["int" gen-int code.int Int i/= (i/* 10) i/+ i/- i/* i// i/% "jvm convert long-to-int" "jvm convert int-to-long"] ["long" gen-int code.int Int i/= (i/* 10) i/+ i/- i/* i// i/% id id] @@ -174,7 +174,7 @@ (<convert> (code.nat param)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (n/= (<reference> param subject) (:coerce Nat valueT)) @@ -208,7 +208,7 @@ ("jvm convert long-to-int" (code.nat shift)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (<test> (<reference> shift (<pre-subject> subject)) (:coerce <type> valueT)) @@ -240,7 +240,7 @@ (<pre> (<tag> param))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success valueT) (bit/= (<reference> param subject) (:coerce Bit valueT)) @@ -251,9 +251,9 @@ [(format "jvm " <domain> " =") <=>] [(format "jvm " <domain> " <") <<>] )] - ($_ seq - <tests> - )))))] + ($_ seq + <tests> + )))))] ["int" gen-int code.int i/= i/< "jvm convert long-to-int"] ["long" gen-int code.int i/= i/< id] @@ -296,7 +296,7 @@ <post>))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputZ) (<test> <value> (:coerce <type> outputZ)) @@ -318,9 +318,9 @@ ["double" Frac valueD f/= (code.frac valueD) id] )] - ($_ seq - <array> - ))))) + ($_ seq + <array> + ))))) (context: "Array [Part 2]" (<| (times +100) @@ -344,7 +344,7 @@ <post>))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (<test> <value> (:coerce <type> outputT)) @@ -358,38 +358,38 @@ (code.int valueL) id] )] - ($_ seq - <array> - (test "java.lang.Double (level 1)" - (|> (do macro.Monad<Meta> - [#let [inner (|> ("jvm array new" +0 "java.lang.Double" (~ (code.nat size))) - ("jvm array write" "java.lang.Double" (~ (code.nat idx)) (~ (code.frac valueD))) - (`))] - sampleI (expressionT.translate (|> ("jvm array new" +1 "java.lang.Double" (~ (code.nat size))) - ("jvm array write" "#Array" (~ (code.nat idx)) (~ inner)) - ("jvm array read" "#Array" (~ (code.nat idx))) - ("jvm array read" "java.lang.Double" (~ (code.nat idx))) - (`)))] - (evalT.eval sampleI)) - (lang.with-current-module "") - (macro.run (io.run init-jvm)) - (case> (#e.Success outputT) - (f/= valueD (:coerce Frac outputT)) - - (#e.Error error) - #0))) - (test "jvm array length" - (|> (do macro.Monad<Meta> - [sampleI (expressionT.translate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code.nat size))))))] - (evalT.eval sampleI)) - (lang.with-current-module "") - (macro.run (io.run init-jvm)) - (case> (#e.Success outputT) - (n/= size (:coerce Nat outputT)) - - (#e.Error error) - #0))) - ))))) + ($_ seq + <array> + (test "java.lang.Double (level 1)" + (|> (do macro.Monad<Meta> + [#let [inner (|> ("jvm array new" +0 "java.lang.Double" (~ (code.nat size))) + ("jvm array write" "java.lang.Double" (~ (code.nat idx)) (~ (code.frac valueD))) + (`))] + sampleI (expressionT.translate (|> ("jvm array new" +1 "java.lang.Double" (~ (code.nat size))) + ("jvm array write" "#Array" (~ (code.nat idx)) (~ inner)) + ("jvm array read" "#Array" (~ (code.nat idx))) + ("jvm array read" "java.lang.Double" (~ (code.nat idx))) + (`)))] + (evalT.eval sampleI)) + (lang.with-current-module "") + (macro.result (io.run! init-jvm)) + (case> (#e.Success outputT) + (f/= valueD (:coerce Frac outputT)) + + (#e.Error error) + #0))) + (test "jvm array length" + (|> (do macro.Monad<Meta> + [sampleI (expressionT.translate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code.nat size))))))] + (evalT.eval sampleI)) + (lang.with-current-module "") + (macro.result (io.run! init-jvm)) + (case> (#e.Success outputT) + (n/= size (:coerce Nat outputT)) + + (#e.Error error) + #0))) + ))))) (host.import: java/lang/Class (getName [] String)) @@ -434,7 +434,7 @@ [sampleI (expressionT.translate (` ("jvm object null?" ("jvm object null"))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (:coerce Bit outputT) @@ -445,7 +445,7 @@ [sampleI (expressionT.translate (` ("jvm object null?" (~ (code.int sample)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (not (:coerce Bit outputT)) @@ -456,7 +456,7 @@ [sampleI (expressionT.translate (` ("jvm object synchronized" (~ (code.int monitor)) (~ (code.int sample)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (i/= sample (:coerce Int outputT)) @@ -471,7 +471,7 @@ (~ exception-message$)))))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (case (:coerce (e.Error Any) outputT) (#e.Error error) @@ -487,7 +487,7 @@ [sampleI (expressionT.translate (` ("jvm object class" (~ (code.text class)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (|> outputT (:coerce Class) (Class::getName []) (text/= class)) @@ -498,7 +498,7 @@ [sampleI (expressionT.translate (` ("jvm object instance?" (~ (code.text instance-class)) (~ instance))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (:coerce Bit outputT) @@ -530,7 +530,7 @@ [sampleI (expressionT.translate (` ("jvm convert int-to-long" ("jvm member static get" "java.util.GregorianCalendar" "AD" "int"))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (i/= GregorianCalendar::AD (:coerce Int outputT)) @@ -542,7 +542,7 @@ ("jvm member static get" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (is? hostL.unit (:coerce Text outputT)) @@ -553,7 +553,7 @@ [sampleI (expressionT.translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ value-memberS))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (text/= sample-string (:coerce Text outputT)) @@ -566,7 +566,7 @@ (~ (code.text other-sample-string)) (~ value-memberS)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (text/= other-sample-string (:coerce Text outputT)) @@ -595,7 +595,7 @@ (~ coded-intS))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (i/= sample (:coerce Int outputT)) @@ -608,7 +608,7 @@ (~ (code.int sample)) (~ object-longS)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (:coerce Bit outputT) @@ -621,7 +621,7 @@ (~ array-listS) (~ object-longS)))))] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (:coerce Bit outputT) @@ -632,7 +632,7 @@ [sampleI (expressionT.translate array-listS)] (evalT.eval sampleI)) (lang.with-current-module "") - (macro.run (io.run init-jvm)) + (macro.result (io.run! init-jvm)) (case> (#e.Success outputT) (host.instance? ArrayList (:coerce Object outputT)) |