From 36303d6cb2ce3ab9e36d045b9516c997bd461862 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 24 Aug 2021 05:23:45 -0400 Subject: Outsourced the syntax for labelled type definitions to macros. --- .../source/luxc/lang/translation/jvm/function.lux | 142 ++++++++++----------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'lux-jvm/source/luxc/lang/translation/jvm/function.lux') diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux index 0508e9c62..df80c6088 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux @@ -81,7 +81,7 @@ (def: (inputsI start amount) (-> Register Nat Inst) (|> (enum.range n.enum start (n.+ start (-- amount))) - (list@map _.ALOAD) + (list@each _.ALOAD) _.fuse)) (def: (applysI start amount) @@ -109,7 +109,7 @@ (def: (instance generate archive class arity env) (-> Phase Archive (Type Class) Arity (Environment Synthesis) (Operation Inst)) (do {@ phase.monad} - [captureI+ (monad.map @ (generate archive) env) + [captureI+ (monad.each @ (generate archive) env) .let [argsI (if (poly_arg? arity) (|> (nullsI (-- arity)) (list (_.int +0)) @@ -133,9 +133,9 @@ captureI (|> (case env_size 0 (list) _ (enum.range n.enum 0 (-- env_size))) - (list@map (.function (_ source) - (|>> (_.ALOAD 0) - (_.GETFIELD class (reference.foreign_name source) //.$Value)))) + (list@each (.function (_ source) + (|>> (_.ALOAD 0) + (_.GETFIELD class (reference.foreign_name source) //.$Value)))) _.fuse) argsI (|> (nullsI (-- arity)) (list (_.int +0)) @@ -175,18 +175,18 @@ store_capturedI (|> (case env_size 0 (list) _ (enum.range n.enum 0 (-- env_size))) - (list@map (.function (_ register) - (|>> (_.ALOAD 0) - (_.ALOAD (++ register)) - (_.PUTFIELD class (reference.foreign_name register) //.$Value)))) + (list@each (.function (_ register) + (|>> (_.ALOAD 0) + (_.ALOAD (++ register)) + (_.PUTFIELD class (reference.foreign_name register) //.$Value)))) _.fuse) store_partialI (if (poly_arg? arity) (|> (enum.range n.enum 0 (n.- 2 arity)) - (list@map (.function (_ idx) - (let [register (offset_partial idx)] - (|>> (_.ALOAD 0) - (_.ALOAD (++ register)) - (_.PUTFIELD class (reference.partial_name idx) //.$Value))))) + (list@each (.function (_ idx) + (let [register (offset_partial idx)] + (|>> (_.ALOAD 0) + (_.ALOAD (++ register)) + (_.PUTFIELD class (reference.partial_name idx) //.$Value))))) _.fuse) function.identity)] (def.method #$.Public $.noneM "" (init_method env arity) @@ -201,57 +201,57 @@ Def) (let [num_partials (-- function_arity) @default ($.new_label []) - @labels (list@map $.new_label (list.repeated num_partials [])) + @labels (list@each $.new_label (list.repeated num_partials [])) over_extent (|> (.int function_arity) (i.- (.int apply_arity))) - casesI (|> (list@compose @labels (list @default)) + casesI (|> (list@composite @labels (list @default)) (list.zipped/2 (enum.range n.enum 0 num_partials)) - (list@map (.function (_ [stage @label]) - (let [load_partialsI (if (n.> 0 stage) - (|> (enum.range n.enum 0 (-- stage)) - (list@map (|>> reference.partial_name (load_fieldI class))) - _.fuse) - function.identity)] - (cond (i.= over_extent (.int stage)) - (|>> (_.label @label) - (_.ALOAD 0) - (when> [(new> (n.> 0 stage) [])] - [(_.INVOKEVIRTUAL class "reset" (reset_method class))]) - load_partialsI - (inputsI 1 apply_arity) - (_.INVOKEVIRTUAL class "impl" (implementation_method function_arity)) - _.ARETURN) + (list@each (.function (_ [stage @label]) + (let [load_partialsI (if (n.> 0 stage) + (|> (enum.range n.enum 0 (-- stage)) + (list@each (|>> reference.partial_name (load_fieldI class))) + _.fuse) + function.identity)] + (cond (i.= over_extent (.int stage)) + (|>> (_.label @label) + (_.ALOAD 0) + (when> [(new> (n.> 0 stage) [])] + [(_.INVOKEVIRTUAL class "reset" (reset_method class))]) + load_partialsI + (inputsI 1 apply_arity) + (_.INVOKEVIRTUAL class "impl" (implementation_method function_arity)) + _.ARETURN) - (i.> over_extent (.int stage)) - (let [args_to_completion (|> function_arity (n.- stage)) - args_left (|> apply_arity (n.- args_to_completion))] - (|>> (_.label @label) - (_.ALOAD 0) - (_.INVOKEVIRTUAL class "reset" (reset_method class)) - load_partialsI - (inputsI 1 args_to_completion) - (_.INVOKEVIRTUAL class "impl" (implementation_method function_arity)) - (applysI (++ args_to_completion) args_left) - _.ARETURN)) + (i.> over_extent (.int stage)) + (let [args_to_completion (|> function_arity (n.- stage)) + args_left (|> apply_arity (n.- args_to_completion))] + (|>> (_.label @label) + (_.ALOAD 0) + (_.INVOKEVIRTUAL class "reset" (reset_method class)) + load_partialsI + (inputsI 1 args_to_completion) + (_.INVOKEVIRTUAL class "impl" (implementation_method function_arity)) + (applysI (++ args_to_completion) args_left) + _.ARETURN)) - ... (i.< over_extent (.int stage)) - (let [env_size (list.size env) - load_capturedI (|> (case env_size - 0 (list) - _ (enum.range n.enum 0 (-- env_size))) - (list@map (|>> reference.foreign_name (load_fieldI class))) - _.fuse)] - (|>> (_.label @label) - (_.NEW class) - _.DUP - load_capturedI - get_amount_of_partialsI - (inc_intI apply_arity) - load_partialsI - (inputsI 1 apply_arity) - (nullsI (|> num_partials (n.- apply_arity) (n.- stage))) - (_.INVOKESPECIAL class "" (init_method env function_arity)) - _.ARETURN)) - )))) + ... (i.< over_extent (.int stage)) + (let [env_size (list.size env) + load_capturedI (|> (case env_size + 0 (list) + _ (enum.range n.enum 0 (-- env_size))) + (list@each (|>> reference.foreign_name (load_fieldI class))) + _.fuse)] + (|>> (_.label @label) + (_.NEW class) + _.DUP + load_capturedI + get_amount_of_partialsI + (inc_intI apply_arity) + load_partialsI + (inputsI 1 apply_arity) + (nullsI (|> num_partials (n.- apply_arity) (n.- stage))) + (_.INVOKESPECIAL class "" (init_method env function_arity)) + _.ARETURN)) + )))) _.fuse)] (def.method #$.Public $.noneM //runtime.apply_method (//runtime.apply_signature apply_arity) (|>> get_amount_of_partialsI @@ -263,16 +263,16 @@ (def: .public with_environment (-> (Environment Synthesis) Def) (|>> list.enumeration - (list@map (.function (_ [env_idx env_source]) - (def.field #$.Private $.finalF (reference.foreign_name env_idx) //.$Value))) + (list@each (.function (_ [env_idx env_source]) + (def.field #$.Private $.finalF (reference.foreign_name env_idx) //.$Value))) def.fuse)) (def: (with_partial arity) (-> Arity Def) (if (poly_arg? arity) (|> (enum.range n.enum 0 (n.- 2 arity)) - (list@map (.function (_ idx) - (def.field #$.Private $.finalF (reference.partial_name idx) //.$Value))) + (list@each (.function (_ idx) + (def.field #$.Private $.finalF (reference.partial_name idx) //.$Value))) def.fuse) function.identity)) @@ -284,7 +284,7 @@ (if (poly_arg? arity) (|> (n.min arity //runtime.num_apply_variants) (enum.range n.enum 1) - (list@map (with_apply classD env arity @begin bodyI)) + (list@each (with_apply classD env arity @begin bodyI)) (list& (with_implementation arity @begin bodyI)) def.fuse) (def.method #$.Public $.strictM //runtime.apply_method (//runtime.apply_signature 1) @@ -343,13 +343,13 @@ (Generator Apply) (do {@ phase.monad} [functionI (generate archive functionS) - argsI (monad.map @ (generate archive) argsS) + argsI (monad.each @ (generate archive) argsS) .let [applyI (|> argsI (list.sub //runtime.num_apply_variants) - (list@map (.function (_ subI+) - (|>> (_.CHECKCAST //.$Function) - (_.fuse subI+) - (_.INVOKEVIRTUAL //.$Function //runtime.apply_method (//runtime.apply_signature (list.size subI+)))))) + (list@each (.function (_ subI+) + (|>> (_.CHECKCAST //.$Function) + (_.fuse subI+) + (_.INVOKEVIRTUAL //.$Function //runtime.apply_method (//runtime.apply_signature (list.size subI+)))))) _.fuse)]] (in (|>> functionI applyI)))) -- cgit v1.2.3