From 2351250b79656014eb441c39dc8c9a02cad1ee40 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 16 Jan 2023 18:10:26 -0400 Subject: Fixed bug wherein caching system couldn't handle changes to library/lux. --- .../library/lux/meta/compiler/default/platform.lux | 66 ++++++++++++++-------- .../jvm/function/field/constant/arity.lux | 20 +++++-- stdlib/source/test/lux/meta.lux | 4 +- .../lux/phase/translation/jvm/function.lux | 10 +++- .../jvm/function/field/constant/arity.lux | 38 +++++++++++++ stdlib/source/test/lux/meta/compiler/target.lux | 3 + stdlib/source/test/lux/meta/type/nominal.lux | 3 +- 7 files changed, 111 insertions(+), 33 deletions(-) create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux (limited to 'stdlib/source') diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index 61115fb32..488e04e79 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -115,7 +115,8 @@ (-> context.Context module.ID (Key document) (Format document) (archive.Entry document) (Async (Try Any)))) (let [system (the #file_system platform) - write_artifact! (is (-> [artifact.ID (Maybe Text) Binary] (Action Any)) + write_artifact! (is (-> [artifact.ID (Maybe Text) Binary] + (Action Any)) (function (_ [artifact_id custom content]) (is (Async (Try Any)) (cache/artifact.cache! system context @module artifact_id content))))] @@ -152,7 +153,8 @@ ... TODO: Inline ASAP (def (compile_runtime! platform) (All (_ ) - (-> (///translation.Operation [Registry Output]))) + (-> + (///translation.Operation [Registry Output]))) (do phase.monad [_ ..initialize_buffer!] (the #runtime platform))) @@ -201,7 +203,8 @@ (//init.with_defaults .prelude all_extensions))) (def (with_extended_prelude state archive) - (-> Lux Archive Archive) + (-> Lux Archive + Archive) (|> (do try.monad [prelude (meta.result state (meta.module .prelude)) entry (archive.find .prelude archive) @@ -238,13 +241,14 @@ [archive analysis_state] (ioW.thaw (list) compilation_configuration (the #host platform) (the #file_system platform) context import compilation_sources) .let [with_missing_extensions (is (All (_ ) - (-> (//init.Extensions ) (Async (Try )))) + (-> (//init.Extensions ) + (Async (Try )))) (function (_ all_extensions state) (|> (initialize_state analysis_state all_extensions) (phase.result' state) (try#each product.left) async#in)))]] - (if (archive.archived? archive .prelude) + (if (archive.archived? archive descriptor.runtime) (do ! [state (with_missing_extensions all_extensions state) .let [archive (with_extended_prelude (the [///declaration.#analysis ///declaration.#state] state) archive)]] @@ -261,7 +265,8 @@ (def (module_compilation_log module) (All (_ ) - (-> descriptor.Module Text)) + (-> descriptor.Module + Text)) (|>> (the [///declaration.#translation ///declaration.#state ///translation.#log]) @@ -271,7 +276,8 @@ (def with_reset_log (All (_ ) - (-> )) + (-> + )) (has [///declaration.#translation ///declaration.#state ///translation.#log] @@ -296,8 +302,10 @@ #depended_by empty])) (def (depend module import dependence) - (-> descriptor.Module descriptor.Module Dependence Dependence) - (let [transitive_dependency (is (-> (-> Dependence Mapping) descriptor.Module (Set descriptor.Module)) + (-> descriptor.Module descriptor.Module Dependence + Dependence) + (let [transitive_dependency (is (-> (-> Dependence Mapping) descriptor.Module + (Set descriptor.Module)) (function (_ lens module) (|> dependence lens @@ -328,8 +336,10 @@ [import transitive_depended_by]))))) (def (circular_dependency? module import dependence) - (-> descriptor.Module descriptor.Module Dependence Bit) - (let [dependence? (is (-> descriptor.Module (-> Dependence Mapping) descriptor.Module Bit) + (-> descriptor.Module descriptor.Module Dependence + Bit) + (let [dependence? (is (-> descriptor.Module (-> Dependence Mapping) descriptor.Module + Bit) (function (_ from relationship to) (let [targets (|> dependence relationship @@ -357,7 +367,8 @@ ["Duplicates" (%.list %.text (set.list duplicates))]))) (def (verify_dependencies importer importee dependence) - (-> descriptor.Module descriptor.Module Dependence (Try Any)) + (-> descriptor.Module descriptor.Module Dependence + (Try Any)) (cond (text#= importer importee) (exception.except ..module_cannot_import_itself [importer]) @@ -384,10 +395,12 @@ (Signal state)]) (type (Importer state) - (-> (List ///.Custom) descriptor.Module descriptor.Module (Return state))) + (-> (List ///.Custom) descriptor.Module descriptor.Module + (Return state))) (type (Compiler state) - (-> (List ///.Custom) descriptor.Module (Importer state) module.ID (Context state) descriptor.Module (Return state))) + (-> (List ///.Custom) descriptor.Module (Importer state) module.ID (Context state) descriptor.Module + (Return state))) (with_expansions [Lux_Context (..Context ) Lux_Return (..Return ) @@ -398,7 +411,8 @@ (def (parallel initial) (All (_ ) (-> Lux_Context - (-> Lux_Compiler Lux_Importer))) + (-> Lux_Compiler + Lux_Importer))) (let [current (stm.var initial) pending (sharing [] (is Lux_Context @@ -489,7 +503,8 @@ ... TODO: Find a better way, as this only works for the Lux compiler. (def (updated_state archive extended_states state) (All (_ ) - (-> Archive (List ) (Try ))) + (-> Archive (List ) + (Try ))) (do [! try.monad] [modules (monad.each ! (function (_ module) (do ! @@ -503,10 +518,13 @@ (list#each product.left) (set.of_list text.hash)) with_modules (is (All (_ ) - (-> )) + (-> + )) (revised [///declaration.#analysis ///declaration.#state] - (is (All (_ a) (-> a a)) + (is (All (_ a) + (-> a + a)) (function (_ analysis_state) (|> analysis_state (as .Lux) @@ -521,7 +539,8 @@ (def (set_current_module module state) (All (_ ) - (-> descriptor.Module )) + (-> descriptor.Module + )) (|> (///declaration.set_current_module module) (phase.result' state) try.trusted @@ -531,7 +550,8 @@ ... This currently assumes that all imports will be specified once in a single .require form. ... This might not be the case in the future. (def (with_new_dependencies new_dependencies all_dependencies) - (-> (List descriptor.Module) (Set descriptor.Module) [(Set descriptor.Module) (Set descriptor.Module)]) + (-> (List descriptor.Module) (Set descriptor.Module) + [(Set descriptor.Module) (Set descriptor.Module)]) (let [[all_dependencies duplicates _] (is [(Set descriptor.Module) (Set descriptor.Module) Bit] (list#mix (function (_ new [all duplicates seen_prelude?]) (if (set.member? all new) @@ -620,7 +640,8 @@ state document) (-> Import context.Context (List _io.Context) Configuration (///.Compiler .Module) (Key document) (Format document) (///.Compilation state document) - (-> (List ///.Custom) descriptor.Module Lux_Importer module.ID (..Context state) descriptor.Module (..Return state)))) + (-> (List ///.Custom) descriptor.Module Lux_Importer module.ID (..Context state) descriptor.Module + (..Return state)))) (function (_ customs importer import! @module [archive state] module) (loop (again [[archive state] [archive state] compilation custom_compilation @@ -776,7 +797,8 @@ (def (custom import! it) (All (_ ) - (-> Lux_Importer compiler.Compiler (Async (Try [Lux_Context (List Text) Any])))) + (-> Lux_Importer compiler.Compiler + (Async (Try [Lux_Context (List Text) Any])))) (let [/#definition (the compiler.#definition it) [/#module /#name] /#definition] (do ..monad diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux index c798ee0c3..d379a48b3 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux @@ -4,18 +4,26 @@ (.require [library [lux (.except type) + [math + [number + ["[0]" i64]]] [meta [compiler [target [jvm - ["[0]" type] - [constant - [pool (.only Resource)]]]]]]]] + ["[0]" type]]]]]]] ["[0]" // [///////// [arity (.only Arity)]]]) -(def .public minimum Arity 1) -(def .public maximum Arity 8) +(with_template [ ] + [(def .public + Arity + (i64.left_shifted 1))] -(def .public type type.int) + [0 minimum] + [3 maximum] + ) + +(def .public type + type.int) diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 1b037cb8a..b13f9097c 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -828,8 +828,8 @@ (random.and (in head))))))] tags_0 (random_labels 5) tags_1 (random_labels 6) - .let [type_0 {.#Nominal name_0 (list)} - type_1 {.#Nominal name_1 (list)} + .let [type_0 {.#Named [label_module name_1] {.#Nominal name_0 (list)}} + type_1 {.#Named [label_module name_1] {.#Nominal name_1 (list)}} expected_lux (is Lux diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux index a2bdb6ce2..4571d75d3 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux @@ -37,8 +37,12 @@ ["[0]" phase] ["[0]" synthesis] ["[0]" translation]]]]]] - [// - ["[0]T" complex]]) + [/ + [field + [constant + ["[0]T" arity]]] + [// + ["[0]T" complex]]]) (def .public test Test @@ -137,4 +141,6 @@ (try.else false))] (and exact_arity! multiple_applications!))) + + arityT.test ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux new file mode 100644 index 000000000..35dfd07e6 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/constant/arity.lux @@ -0,0 +1,38 @@ +... 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) + [abstract + [monad (.only do)]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [meta + [compiler + [target + [jvm + [type + ["[0]" parser]]]]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + []) + (all _.and + (_.coverage [/.minimum /.maximum] + (and (n.< /.maximum /.minimum) + (n.> 0 /.maximum) + (n.> 0 /.minimum))) + (_.coverage [/.type] + (when (parser.primitive? /.type) + {.#Some _} true + {.#None} false)) + ))) diff --git a/stdlib/source/test/lux/meta/compiler/target.lux b/stdlib/source/test/lux/meta/compiler/target.lux index 6f0987b9f..3c4a88281 100644 --- a/stdlib/source/test/lux/meta/compiler/target.lux +++ b/stdlib/source/test/lux/meta/compiler/target.lux @@ -18,11 +18,14 @@ ["[0]" /]]) (with_expansions [ (these /.old + + /.c++ /.js /.jvm /.lua /.python /.ruby + /.common_lisp /.php /.r diff --git a/stdlib/source/test/lux/meta/type/nominal.lux b/stdlib/source/test/lux/meta/type/nominal.lux index beea5c495..d2b0a14fa 100644 --- a/stdlib/source/test/lux/meta/type/nominal.lux +++ b/stdlib/source/test/lux/meta/type/nominal.lux @@ -81,7 +81,8 @@ /.transmutation (is (g!Bar .Lux))) true))) - (_.for [/.Frame] + (_.for [/.Frame + /.#name /.#type_vars /.#abstraction /.#representation] (all _.and (_.coverage [/.current] (text#= (template.text [g!Bar]) -- cgit v1.2.3