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. --- .../luxc/lang/translation/jvm/extension/host.lux | 154 ++++++++++----------- 1 file changed, 77 insertions(+), 77 deletions(-) (limited to 'lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux') 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 e2855e999..826c45f1a 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -734,9 +734,9 @@ [($_ <>.and ..class .text ..return (<>.some ..input)) (function (_ extension_name generate archive [class method outputT inputsTS]) (do {! phase.monad} - [inputsTI (monad.map ! (generate_input generate archive) inputsTS)] - (in (|>> (_.fuse (list\map product.right inputsTI)) - (_.INVOKESTATIC class method (type.method [(list) (list\map product.left inputsTI) outputT (list)])) + [inputsTI (monad.each ! (generate_input generate archive) inputsTS)] + (in (|>> (_.fuse (list\each product.right inputsTI)) + (_.INVOKESTATIC class method (type.method [(list) (list\each product.left inputsTI) outputT (list)])) (prepare_output outputT)))))])) (template [ ] @@ -747,13 +747,13 @@ (function (_ extension_name generate archive [class method outputT objectS inputsTS]) (do {! phase.monad} [objectI (generate archive objectS) - inputsTI (monad.map ! (generate_input generate archive) inputsTS)] + inputsTI (monad.each ! (generate_input generate archive) inputsTS)] (in (|>> objectI (_.CHECKCAST class) - (_.fuse (list\map product.right inputsTI)) + (_.fuse (list\each product.right inputsTI)) ( class method (type.method [(list) - (list\map product.left inputsTI) + (list\each product.left inputsTI) outputT (list)])) (prepare_output outputT)))))]))] @@ -769,11 +769,11 @@ [($_ <>.and ..class (<>.some ..input)) (function (_ extension_name generate archive [class inputsTS]) (do {! phase.monad} - [inputsTI (monad.map ! (generate_input generate archive) inputsTS)] + [inputsTI (monad.each ! (generate_input generate archive) inputsTS)] (in (|>> (_.NEW class) _.DUP - (_.fuse (list\map product.right inputsTI)) - (_.INVOKESPECIAL class "" (type.method [(list) (list\map product.left inputsTI) type.void (list)]))))))])) + (_.fuse (list\each product.right inputsTI)) + (_.INVOKESPECIAL class "" (type.method [(list) (list\each product.left inputsTI) type.void (list)]))))))])) (def: member_bundle Bundle @@ -886,14 +886,14 @@ [#synthesis.Access]) (#synthesis.Bit_Fork when then else) - (#synthesis.Bit_Fork when (recur then) (maybe\map recur else)) + (#synthesis.Bit_Fork when (recur then) (maybe\each recur else)) (^template [] [( [[test then] elses]) ( [[test (recur then)] - (list\map (function (_ [else_test else_then]) - [else_test (recur else_then)]) - elses)])]) + (list\each (function (_ [else_test else_then]) + [else_test (recur else_then)]) + elses)])]) ([#synthesis.I64_Fork] [#synthesis.F64_Fork] [#synthesis.Text_Fork]) @@ -913,7 +913,7 @@ (synthesis.variant [lefts right? (recur sub)]) (^ (synthesis.tuple members)) - (synthesis.tuple (list\map recur members)) + (synthesis.tuple (list\each recur members)) (^ (synthesis.variable var)) (|> mapping @@ -934,31 +934,31 @@ (synthesis.branch/get [path (recur recordS)]) (^ (synthesis.loop/scope [offset initsS+ bodyS])) - (synthesis.loop/scope [offset (list\map recur initsS+) (recur bodyS)]) + (synthesis.loop/scope [offset (list\each recur initsS+) (recur bodyS)]) (^ (synthesis.loop/recur updatesS+)) - (synthesis.loop/recur (list\map recur updatesS+)) + (synthesis.loop/recur (list\each recur updatesS+)) (^ (synthesis.function/abstraction [environment arity bodyS])) - (synthesis.function/abstraction [(list\map (function (_ captured) - (case captured - (^ (synthesis.variable var)) - (|> mapping - (dictionary.value captured) - (maybe.else var) - synthesis.variable) - - _ - captured)) - environment) + (synthesis.function/abstraction [(list\each (function (_ captured) + (case captured + (^ (synthesis.variable var)) + (|> mapping + (dictionary.value captured) + (maybe.else var) + synthesis.variable) + + _ + captured)) + environment) arity bodyS]) (^ (synthesis.function/apply [functionS inputsS+])) - (synthesis.function/apply [(recur functionS) (list\map recur inputsS+)]) + (synthesis.function/apply [(recur functionS) (list\each recur inputsS+)]) (#synthesis.Extension [name inputsS+]) - (#synthesis.Extension [name (list\map recur inputsS+)])))) + (#synthesis.Extension [name (list\each recur inputsS+)])))) (def: $Object (type.class "java.lang.Object" (list))) @@ -975,22 +975,22 @@ (let [store_capturedI (|> env list.size list.indices - (list\map (.function (_ register) - (|>> (_.ALOAD 0) - (_.ALOAD (++ register)) - (_.PUTFIELD class (///reference.foreign_name register) $Object)))) + (list\each (.function (_ register) + (|>> (_.ALOAD 0) + (_.ALOAD (++ register)) + (_.PUTFIELD class (///reference.foreign_name register) $Object)))) _.fuse)] (_def.method #$.Public $.noneM "" (anonymous_init_method env) (|>> (_.ALOAD 0) - ((_.fuse (list\map product.right inputsTI))) - (_.INVOKESPECIAL super_class "" (type.method [(list) (list\map product.left inputsTI) type.void (list)])) + ((_.fuse (list\each product.right inputsTI))) + (_.INVOKESPECIAL super_class "" (type.method [(list) (list\each product.left inputsTI) type.void (list)])) store_capturedI _.RETURN)))) (def: (anonymous_instance generate archive class env) (-> Phase Archive (Type Class) (Environment Synthesis) (Operation Inst)) (do {! phase.monad} - [captureI+ (monad.map ! (generate archive) env)] + [captureI+ (monad.each ! (generate archive) env)] (in (|>> (_.NEW class) _.DUP (_.fuse captureI+) @@ -1092,56 +1092,56 @@ class (type.class anonymous_class_name (list)) total_environment (|> overriden_methods ... Get all the environments. - (list\map product.left) + (list\each product.left) ... Combine them. - list\join + list\conjoint ... Remove duplicates. (set.of_list synthesis.hash) set.list) global_mapping (|> total_environment ... Give them names as "foreign" variables. list.enumeration - (list\map (function (_ [id capture]) - [capture (#variable.Foreign id)])) + (list\each (function (_ [id capture]) + [capture (#variable.Foreign id)])) (dictionary.of_list synthesis.hash)) - normalized_methods (list\map (function (_ [environment - [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - body]]) - (let [local_mapping (|> environment - list.enumeration - (list\map (function (_ [foreign_id capture]) - [(synthesis.variable/foreign foreign_id) - (|> global_mapping - (dictionary.value capture) - maybe.trusted)])) - (dictionary.of_list synthesis.hash))] - [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - (normalize_method_body local_mapping body)])) - overriden_methods)] - inputsTI (monad.map ! (generate_input generate archive) inputsTS) + normalized_methods (list\each (function (_ [environment + [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + body]]) + (let [local_mapping (|> environment + list.enumeration + (list\each (function (_ [foreign_id capture]) + [(synthesis.variable/foreign foreign_id) + (|> global_mapping + (dictionary.value capture) + maybe.trusted)])) + (dictionary.of_list synthesis.hash))] + [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + (normalize_method_body local_mapping body)])) + overriden_methods)] + inputsTI (monad.each ! (generate_input generate archive) inputsTS) method_definitions (|> normalized_methods - (monad.map ! (function (_ [ownerT name - strict_fp? annotations varsT - self_name arguments returnT exceptionsT - bodyS]) - (do ! - [bodyG (generation.with_context artifact_id - (generate archive bodyS)) - .let [argumentsT (list\map product.right arguments)]] - (in (_def.method #$.Public - (if strict_fp? - ($_ $.++M $.finalM $.strictM) - $.finalM) - name - (type.method [varsT argumentsT returnT exceptionsT]) - (|>> (prepare_arguments 1 argumentsT) - bodyG - (returnI returnT))))))) - (\ ! map _def.fuse)) + (monad.each ! (function (_ [ownerT name + strict_fp? annotations varsT + self_name arguments returnT exceptionsT + bodyS]) + (do ! + [bodyG (generation.with_context artifact_id + (generate archive bodyS)) + .let [argumentsT (list\each product.right arguments)]] + (in (_def.method #$.Public + (if strict_fp? + ($_ $.++M $.finalM $.strictM) + $.finalM) + name + (type.method [varsT argumentsT returnT exceptionsT]) + (|>> (prepare_arguments 1 argumentsT) + bodyG + (returnI returnT))))))) + (\ ! each _def.fuse)) .let [directive [anonymous_class_name (_def.class #$.V1_6 #$.Public $.finalC anonymous_class_name (list) -- cgit v1.2.3