From ec1f31b5a1492d5e0ab260397291d4449483bbd9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 23 Aug 2021 02:30:53 -0400 Subject: The Python compiler can now be compiled by the new JVM compiler. --- lux-jvm/source/luxc/lang/directive/jvm.lux | 38 +++++------ lux-jvm/source/luxc/lang/synthesis/variable.lux | 22 +++--- lux-jvm/source/luxc/lang/translation/jvm/case.lux | 52 +++++++-------- .../luxc/lang/translation/jvm/extension/host.lux | 10 +-- lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux | 78 +++++++++++----------- lux-jvm/test/test/luxc/lang/synthesis/loop.lux | 2 +- 6 files changed, 101 insertions(+), 101 deletions(-) (limited to 'lux-jvm') diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux index a7314b0dc..2c6577ae1 100644 --- a/lux-jvm/source/luxc/lang/directive/jvm.lux +++ b/lux-jvm/source/luxc/lang/directive/jvm.lux @@ -18,9 +18,9 @@ ["%" format (#+ format)]] [collection [array (#+ Array)] - ["." list ("#\." fold functor monoid)] + ["." list ("#\." mix functor monoid)] ["." dictionary (#+ Dictionary)] - ["." row (#+ Row) ("#\." functor fold)]]] + ["." row (#+ Row) ("#\." functor mix)]]] [math [number ["." nat]]] @@ -442,18 +442,18 @@ (#/.TABLESWITCH min max default labels) (let [[mapping default] (..relabel [mapping default]) - [mapping labels] (list\fold (function (_ input [mapping output]) - (let [[mapping input] (..relabel [mapping input])] - [mapping (list& input output)])) - [mapping (list)] labels)] + [mapping labels] (list\mix (function (_ input [mapping output]) + (let [[mapping input] (..relabel [mapping input])] + [mapping (list& input output)])) + [mapping (list)] labels)] [mapping (#/.TABLESWITCH min max default (list.reversed labels))]) (#/.LOOKUPSWITCH default keys+labels) (let [[mapping default] (..relabel [mapping default]) - [mapping keys+labels] (list\fold (function (_ [expected input] [mapping output]) - (let [[mapping input] (..relabel [mapping input])] - [mapping (list& [expected input] output)])) - [mapping (list)] keys+labels)] + [mapping keys+labels] (list\mix (function (_ [expected input] [mapping output]) + (let [[mapping input] (..relabel [mapping input])] + [mapping (list& [expected input] output)])) + [mapping (list)] keys+labels)] [mapping (#/.LOOKUPSWITCH default (list.reversed keys+labels))]) )) @@ -515,11 +515,11 @@ (def: (relabel_bytecode [mapping bytecode]) (Re_labeler (/.Bytecode Inst)) - (row\fold (function (_ input [mapping output]) - (let [[mapping input'] (..relabel_instruction [mapping input])] - [mapping (row.suffix input' output)])) - [mapping (row.row)] - bytecode)) + (row\mix (function (_ input [mapping output]) + (let [[mapping input'] (..relabel_instruction [mapping input])] + [mapping (row.suffix input' output)])) + [mapping (row.row)] + bytecode)) (def: fresh Mapping @@ -1033,7 +1033,7 @@ [_scope bodyA] (|> arguments' (#.Item [self selfT]) list.reversed - (list\fold scopeA.with_local (analyse archive bodyC)) + (list\mix scopeA.with_local (analyse archive bodyC)) (typeA.with_type returnT) analysis.with_scope)] (in [privacy strict_floating_point? annotations method_tvars exceptions @@ -1063,7 +1063,7 @@ [_scope bodyA] (|> arguments' (#.Item [self selfT]) list.reversed - (list\fold scopeA.with_local (analyse archive bodyC)) + (list\mix scopeA.with_local (analyse archive bodyC)) (typeA.with_type returnT) analysis.with_scope)] (in [[super_name super_tvars] method_name strict_floating_point? annotations @@ -1091,7 +1091,7 @@ [_scope bodyA] (|> arguments' (#.Item [self selfT]) list.reversed - (list\fold scopeA.with_local (analyse archive bodyC)) + (list\mix scopeA.with_local (analyse archive bodyC)) (typeA.with_type returnT) analysis.with_scope)] (in [name privacy final? strict_floating_point? annotations method_tvars @@ -1116,7 +1116,7 @@ returnT (//A.boxed_reflection_return mapping returnJ) [_scope bodyA] (|> arguments' list.reversed - (list\fold scopeA.with_local (analyse archive bodyC)) + (list\mix scopeA.with_local (analyse archive bodyC)) (typeA.with_type returnT) analysis.with_scope)] (in [name privacy strict_floating_point? annotations method_tvars diff --git a/lux-jvm/source/luxc/lang/synthesis/variable.lux b/lux-jvm/source/luxc/lang/synthesis/variable.lux index 4721187f8..f4e68d25b 100644 --- a/lux-jvm/source/luxc/lang/synthesis/variable.lux +++ b/lux-jvm/source/luxc/lang/synthesis/variable.lux @@ -2,7 +2,7 @@ lux (lux (data [library [number]] - (coll [list "list/" Fold Monoid] + (coll [list "list/" Mix Monoid] ["s" set]))) (luxc (lang ["la" analysis] ["ls" synthesis] @@ -47,7 +47,7 @@ (def: (unused-vars current-arity bound exprS) (-> ls.Arity (List Variable) ls.Synthesis (List Variable)) (let [tracker (loop [exprS exprS - tracker (list/fold s.has init-tracker bound)] + tracker (list/mix s.has init-tracker bound)] (case exprS (#ls.Variable var) (if (non-arg? current-arity var) @@ -58,14 +58,14 @@ (recur memberS tracker) (#ls.Tuple membersS) - (list/fold recur tracker membersS) + (list/mix recur tracker membersS) (#ls.Call funcS argsS) - (list/fold recur (recur funcS tracker) argsS) + (list/mix recur (recur funcS tracker) argsS) (^or (#ls.Recur argsS) (#ls.Procedure name argsS)) - (list/fold recur tracker argsS) + (list/mix recur tracker argsS) (#ls.Let offset inputS outputS) (|> tracker (recur inputS) (recur outputS)) @@ -74,16 +74,16 @@ (|> tracker (recur testS) (recur thenS) (recur elseS)) (#ls.Loop offset initsS bodyS) - (recur bodyS (list/fold recur tracker initsS)) + (recur bodyS (list/mix recur tracker initsS)) (#ls.Case inputS outputPS) - (let [tracker' (list/fold s.has - (recur inputS tracker) - (bound-vars outputPS))] - (list/fold recur tracker' (path-bodies outputPS))) + (let [tracker' (list/mix s.has + (recur inputS tracker) + (bound-vars outputPS))] + (list/mix recur tracker' (path-bodies outputPS))) (#ls.Function arity env bodyS) - (list/fold s.lacks tracker env) + (list/mix s.lacks tracker env) _ tracker diff --git a/lux-jvm/source/luxc/lang/translation/jvm/case.lux b/lux-jvm/source/luxc/lang/translation/jvm/case.lux index 3a6291036..eb1f37f0b 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/case.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/case.lux @@ -8,7 +8,7 @@ ["ex" exception (#+ exception:)]] [data [collection - ["." list ("#@." fold)]]] + ["." list ("#@." mix)]]] [math [number ["n" nat]]] @@ -132,21 +132,21 @@ [( cons) (do {@ phase.monad} [forkG (: (Operation Inst) - (monad.fold @ (function (_ [test thenP] elseG) - (do @ - [thenG (path' stack_depth @else @end phase archive thenP)] - (in (<| _.with_label (function (_ @else)) - (|>> - ( test) - - ( @else) - - thenG - (_.label @else) - elseG))))) - (|>> - (_.GOTO @else)) - (#.Item cons)))] + (monad.mix @ (function (_ [test thenP] elseG) + (do @ + [thenG (path' stack_depth @else @end phase archive thenP)] + (in (<| _.with_label (function (_ @else)) + (|>> + ( test) + + ( @else) + + thenG + (_.label @else) + elseG))))) + (|>> + (_.GOTO @else)) + (#.Item cons)))] (in (|>> peekI forkG)))]) @@ -266,16 +266,16 @@ (Generator [(List synthesis.Member) Synthesis]) (do phase.monad [recordG (phase archive recordS)] - (in (list@fold (function (_ step so_far) - (.let [next (.case step - (#.Left lefts) - (..left_projection lefts) - - (#.Right lefts) - (..right_projection lefts))] - (|>> so_far next))) - recordG - (list.reversed path))))) + (in (list@mix (function (_ step so_far) + (.let [next (.case step + (#.Left lefts) + (..left_projection lefts) + + (#.Right lefts) + (..right_projection lefts))] + (|>> so_far next))) + recordG + (list.reversed path))))) (def: .public (case phase archive [valueS path]) (Generator [Synthesis Path]) 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 31538a0bd..e2855e999 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -16,7 +16,7 @@ ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection - ["." list ("#\." monad fold)] + ["." list ("#\." monad mix)] ["." dictionary (#+ Dictionary)] ["." set]]] [macro @@ -1031,10 +1031,10 @@ (-> Nat (List (Type Value)) Inst) (|> types list.enumeration - (list\fold (function (_ [lux_register type] [jvm_register before]) - (let [[jvm_register' after] (prepare_argument (n.+ offset lux_register) type jvm_register)] - [jvm_register' (|>> before after)])) - (: [Register Inst] [offset (|>>)])) + (list\mix (function (_ [lux_register type] [jvm_register before]) + (let [[jvm_register' after] (prepare_argument (n.+ offset lux_register) type jvm_register)] + [jvm_register' (|>> before after)])) + (: [Register Inst] [offset (|>>)])) product.right)) (def: .public (returnI returnT) 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 77f5b34bc..f3af659fa 100644 --- a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux +++ b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux @@ -11,7 +11,7 @@ format] [collection ["." array] - [list ("list/" Fold)] + [list ("list/" Mix)] ["dict" dictionary]]] [math ["r" random "r/" Monad]] @@ -38,8 +38,8 @@ [... runtime-bytecode @runtime.translate ] (default.with-scope - (typeA.with-type output-type - (_primitive.analyse (` ((~ (code.text procedure)) (~+ params))))))) + (typeA.with-type output-type + (_primitive.analyse (` ((~ (code.text procedure)) (~+ params))))))) (analysis.with-current-module "") (macro.result (initL.compiler [])) (case> (#e.Success _) @@ -59,8 +59,8 @@ [... runtime-bytecode @runtime.translate ] (default.with-scope - (typeA.with-type output-type - (_primitive.analyse syntax)))) + (typeA.with-type output-type + (_primitive.analyse syntax)))) (analysis.with-current-module "") (macro.result (initL.compiler [])) (case> (#e.Success _) @@ -87,9 +87,9 @@ ["jvm convert float-to-int" "java.lang.Float" hostAE.Integer] ["jvm convert float-to-long" "java.lang.Float" hostAE.Long] )] - ($_ seq - - ))) + ($_ seq + + ))) (context: "Conversions [int]." (with-expansions [ (template [ ] @@ -105,9 +105,9 @@ ["jvm convert int-to-long" "java.lang.Integer" hostAE.Long] ["jvm convert int-to-short" "java.lang.Integer" hostAE.Short] )] - ($_ seq - - ))) + ($_ seq + + ))) (context: "Conversions [long]." (with-expansions [ (template [ ] @@ -122,9 +122,9 @@ ["jvm convert long-to-short" "java.lang.Long" hostAE.Short] ["jvm convert long-to-byte" "java.lang.Long" hostAE.Byte] )] - ($_ seq - - ))) + ($_ seq + + ))) (context: "Conversions [char + byte + short]." (with-expansions [ (template [ ] @@ -140,9 +140,9 @@ ["jvm convert byte-to-long" "java.lang.Byte" hostAE.Long] ["jvm convert short-to-long" "java.lang.Short" hostAE.Long] )] - ($_ seq - - ))) + ($_ seq + + ))) (template [ ] [(context: (format "Arithmetic " "[" "].") @@ -159,9 +159,9 @@ [(format "jvm " " /") ] [(format "jvm " " %") ] )] - ($_ seq - - ))) + ($_ seq + + ))) (context: (format "Order " "[" "].") (with-expansions [ (template [ ] @@ -174,9 +174,9 @@ [(format "jvm " " =") hostAE.Boolean] [(format "jvm " " <") hostAE.Boolean] )] - ($_ seq - - ))) + ($_ seq + + ))) (context: (format "Bitwise " "[" "].") (with-expansions [ (template [ ] @@ -193,9 +193,9 @@ [(format "jvm " " shr") "java.lang.Integer" ] [(format "jvm " " ushr") "java.lang.Integer" ] )] - ($_ seq - - )))] + ($_ seq + + )))] ["int" "java.lang.Integer" hostAE.Integer] @@ -217,9 +217,9 @@ [(format "jvm " " /") ] [(format "jvm " " %") ] )] - ($_ seq - - ))) + ($_ seq + + ))) (context: (format "Order " "[" "].") (with-expansions [ (template [ ] @@ -232,9 +232,9 @@ [(format "jvm " " =") hostAE.Boolean] [(format "jvm " " <") hostAE.Boolean] )] - ($_ seq - - )))] + ($_ seq + + )))] ["float" "java.lang.Float" hostAE.Float] @@ -253,9 +253,9 @@ [(format "jvm " " =") hostAE.Boolean] [(format "jvm " " <") hostAE.Boolean] )] - ($_ seq - - )))] + ($_ seq + + )))] ["char" "java.lang.Character" hostAE.Character] @@ -287,10 +287,10 @@ ("jvm array new" (~ (code.nat size))))) boxedT (#.Primitive boxed (list)) boxedTC (` (+0 (~ (code.text boxed)) (+0))) - multi-arrayT (list/fold (function (_ _ innerT) - (|> innerT (list) (#.Primitive "#Array"))) - boxedT - (list.n/range +1 level))]] + multi-arrayT (list/mix (function (_ _ innerT) + (|> innerT (list) (#.Primitive "#Array"))) + boxedT + (list.n/range +1 level))]] ($_ seq (test "jvm array new" (success "jvm array new" diff --git a/lux-jvm/test/test/luxc/lang/synthesis/loop.lux b/lux-jvm/test/test/luxc/lang/synthesis/loop.lux index 7aeafab5f..2b09fb3e7 100644 --- a/lux-jvm/test/test/luxc/lang/synthesis/loop.lux +++ b/lux-jvm/test/test/luxc/lang/synthesis/loop.lux @@ -4,7 +4,7 @@ (control [monad #+ do]) (data [bit "bit/" Eq] [number] - (coll [list "list/" Functor Fold] + (coll [list "list/" Functor] (set ["set" unordered])) text/format) (macro [code]) -- cgit v1.2.3