From 0f9f87286acacb520aa3ab0252131e109184b4cb Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 13 Jan 2023 22:11:05 -0400 Subject: Better formatting for types & symbols for compilation logging. --- .../language/lux/phase/analysis/complex.lux | 6 +- .../lux/phase/extension/declaration/lux.lux | 11 ++- .../language/lux/phase/translation/jvm.lux | 6 +- .../language/lux/phase/translation/jvm/complex.lux | 102 +++++++++++++++++++++ .../lux/phase/translation/jvm/primitive.lux | 4 +- .../lux/phase/translation/jvm/structure.lux | 100 -------------------- .../language/lux/phase/translation/jvm/when.lux | 6 +- .../language/lux/phase/translation/python.lux | 5 +- 8 files changed, 123 insertions(+), 117 deletions(-) create mode 100644 stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux delete mode 100644 stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux (limited to 'stdlib/source/library/lux/meta/compiler/language') diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux index d71d0b0c6..acb4a676e 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux @@ -1,10 +1,10 @@ +... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + (.require [library [lux (.except Tag Analysis) [abstract -... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - ["[0]" monad (.only do)]] [control ["[0]" maybe] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux index 2fffba00c..1a8b75275 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux @@ -16,7 +16,7 @@ ["[0]" binary] ["[0]" product] ["[0]" text - ["%" \\format (.only format)]] + ["%" \\format]] [collection ["[0]" dictionary] ["[0]" array] @@ -192,11 +192,12 @@ (in [])))] (in []))) -(def (announce_definition! short type) +(def (announce_definition! module short type) (All (_ anchor expression declaration) - (-> Text Type (Operation anchor expression declaration Any))) + (-> Text Text Type + (Operation anchor expression declaration Any))) (/////declaration.of_translation - (/////translation.log! (format short " : " (%.type type))))) + (/////translation.log! (%.format short " : " (type.relative_format module type))))) (def lux::def Handler @@ -233,7 +234,7 @@ [_ _ exported?] (evaluate! archive Bit exported?C) _ (/////declaration.of_analysis (moduleA.define short_name [(as Bit exported?) {.#Definition [type value]}])) - _ (..announce_definition! short_name type)] + _ (..announce_definition! current_module short_name type)] (in /////declaration.no_requirements))))])) (def imports diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux index 4ddfd3fd4..15a4a8057 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux @@ -29,7 +29,7 @@ ["[0]" / [runtime (.only Operation Phase Handler)] ["[1][0]" primitive] - ["[1][0]" structure] + ["[1][0]" complex] ["[1][0]" reference] ["[1][0]" function] ["[1][0]" when] @@ -73,11 +73,11 @@ (synthesis.variant @ variantS) (with_source_mapping @ - (/structure.variant phase archive variantS)) + (/complex.variant phase archive variantS)) (synthesis.tuple @ members) (with_source_mapping @ - (/structure.tuple phase archive members)) + (/complex.tuple phase archive members)) [@ {synthesis.#Reference reference}] (with_source_mapping @ diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux new file mode 100644 index 000000000..a449ffa45 --- /dev/null +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux @@ -0,0 +1,102 @@ +... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + +(.require + [library + [lux (.except Variant Tuple Synthesis) + [abstract + ["[0]" monad (.only do)]] + [control + ["[0]" try]] + [data + [collection + ["[0]" list]]] + [math + [number + ["[0]" i32]]] + [meta + [compiler + [target + [jvm + ["_" bytecode (.only Bytecode)] + ["[0]" type] + [encoding + ["[0]" signed]]]]]]]] + ["[0]" // + ["[1][0]" type] + ["[1][0]" runtime (.only Operation Phase Translator)] + ["[1][0]" primitive] + ["///[1]" //// + ["[0]" phase] + ["[1][0]" synthesis (.only Synthesis)] + [analysis + [complex (.only Variant Tuple)]]]]) + +(def .public (lefts lefts) + (-> Nat + (Bytecode Any)) + (when lefts + 0 _.iconst_0 + 1 _.iconst_1 + 2 _.iconst_2 + 3 _.iconst_3 + 4 _.iconst_4 + 5 _.iconst_5 + _ (when (signed.s1 (.int lefts)) + {try.#Success value} + (_.bipush value) + + {try.#Failure _} + (when (signed.s2 (.int lefts)) + {try.#Success value} + (_.sipush value) + + {try.#Failure _} + (_.int (.i64 lefts)))))) + +(def .public (right? right?) + (-> Bit + (Bytecode Any)) + (if right? + //runtime.right_right? + //runtime.left_right?)) + +(def .public (variant phase archive [lefts right? valueS]) + (Translator (Variant Synthesis)) + (do phase.monad + [valueI (phase archive valueS)] + (in (do _.monad + [_ (..lefts lefts) + _ (..right? right?) + _ valueI] + (_.invokestatic //runtime.class "variant" + (type.method [(list) + (list //type.lefts //type.right? //type.value) + //type.variant + (list)])))))) + +(def .public (tuple phase archive membersS) + (Translator (Tuple Synthesis)) + (when membersS + {.#End} + (of phase.monad in //runtime.unit) + + {.#Item singletonS {.#End}} + (phase archive singletonS) + + _ + (do [! phase.monad] + [membersI (|> membersS + list.enumeration + (monad.each ! (function (_ [idx member]) + (do ! + [memberI (phase archive member)] + (in (do _.monad + [_ _.dup + _ (_.int (.i64 idx)) + _ memberI] + _.aastore))))))] + (in (do [! _.monad] + [_ (_.int (.i64 (list.size membersS))) + _ (_.anewarray //type.value)] + (monad.all ! membersI)))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux index 86ffa8239..fdcf78041 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux @@ -137,10 +137,12 @@ ..double_bits (i.= ..d0_bits)) _.dconst_0 - (_.double (as java/lang/Double value)))] + (_.double value))] (do _.monad [_ constantI] ..wrap_f64)))) (def .public text + (-> Text + (Bytecode Any)) _.string) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux deleted file mode 100644 index b06724932..000000000 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux +++ /dev/null @@ -1,100 +0,0 @@ -... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -(.require - [library - [lux (.except Variant Tuple Synthesis) - [abstract - ["[0]" monad (.only do)]] - [control - ["[0]" try]] - [data - [collection - ["[0]" list]]] - [math - [number - ["[0]" i32]]] - [meta - [compiler - [target - [jvm - ["_" bytecode (.only Bytecode)] - ["[0]" type] - [encoding - ["[0]" signed]]]]]]]] - ["[0]" // - ["[1][0]" type] - ["[1][0]" runtime (.only Operation Phase Translator)] - ["[1][0]" primitive] - ["///[1]" //// - ["[0]" phase] - ["[1][0]" synthesis (.only Synthesis)] - [analysis - [complex (.only Variant Tuple)]]]]) - -(def .public (tuple phase archive membersS) - (Translator (Tuple Synthesis)) - (when membersS - {.#End} - (of phase.monad in //runtime.unit) - - {.#Item singletonS {.#End}} - (phase archive singletonS) - - _ - (do [! phase.monad] - [membersI (|> membersS - list.enumeration - (monad.each ! (function (_ [idx member]) - (do ! - [memberI (phase archive member)] - (in (do _.monad - [_ _.dup - _ (_.int (.i64 idx)) - _ memberI] - _.aastore))))))] - (in (do [! _.monad] - [_ (_.int (.i64 (list.size membersS))) - _ (_.anewarray //type.value)] - (monad.all ! membersI)))))) - -(def .public (lefts lefts) - (-> Nat (Bytecode Any)) - (when lefts - 0 _.iconst_0 - 1 _.iconst_1 - 2 _.iconst_2 - 3 _.iconst_3 - 4 _.iconst_4 - 5 _.iconst_5 - _ (when (signed.s1 (.int lefts)) - {try.#Success value} - (_.bipush value) - - {try.#Failure _} - (when (signed.s2 (.int lefts)) - {try.#Success value} - (_.sipush value) - - {try.#Failure _} - (_.int (.i64 lefts)))))) - -(def .public (right? right?) - (-> Bit (Bytecode Any)) - (if right? - //runtime.right_right? - //runtime.left_right?)) - -(def .public (variant phase archive [lefts right? valueS]) - (Translator (Variant Synthesis)) - (do phase.monad - [valueI (phase archive valueS)] - (in (do _.monad - [_ (..lefts lefts) - _ (..right? right?) - _ valueI] - (_.invokestatic //runtime.class "variant" - (type.method [(list) - (list //type.lefts //type.right? //type.value) - //type.variant - (list)])))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux index c2d2536b4..558353ad8 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux @@ -33,7 +33,7 @@ ["[1][0]" type] ["[1][0]" runtime (.only Operation Phase Translator)] ["[1][0]" value] - ["[1][0]" structure] + ["[1][0]" complex] [//// ["[0]" phase (.use "operation#[0]" monad)] ["[0]" translation] @@ -195,8 +195,8 @@ (all _.composite ..peek (_.checkcast //type.variant) - (//structure.lefts lefts) - (//structure.right? right?) + (//complex.lefts lefts) + (//complex.right? right?) //runtime.when _.dup (_.ifnonnull @success) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux index 355b45be8..389716606 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux @@ -11,8 +11,9 @@ [meta [macro ["^" pattern]] - [target - ["_" python]]]]] + [compiler + [target + ["_" python]]]]]] ["[0]" / [runtime (.only Phase)] ["[1][0]" primitive] -- cgit v1.2.3