aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler
diff options
context:
space:
mode:
authorEduardo Julian2022-02-23 05:30:53 -0400
committerEduardo Julian2022-02-23 05:30:53 -0400
commitf27a91a7b67790272578692ea20e2d875dbb3d35 (patch)
treecf0d9a53f3ef1b16be92ee5a120651b1abbb866d /stdlib/source/library/lux/tool/compiler
parentf07effd9faf3fdaa677f659d6bbccf98931c5e5a (diff)
ADDED Can pass config parameters to compiler and select code based on it. Can also select code based on compiler version.
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler')
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/init.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux13
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux.lux7
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux10
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux5
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/version.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cli.lux10
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/io/archive.lux30
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux3
10 files changed, 49 insertions, 50 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux
index fc7e1b637..7f815abf9 100644
--- a/stdlib/source/library/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/init.lux
@@ -18,6 +18,9 @@
["[0]" dictionary]
["[0]" set]
["[0]" sequence ("[1]#[0]" functor)]]]
+ [meta
+ ["[0]" configuration {"+" Configuration}]
+ ["[0]" version]]
[world
["[0]" file]]]]
["[0]" // "_"
@@ -26,7 +29,6 @@
[language
[lux
[program {"+" Program}]
- ["[1][0]" version]
["[1][0]" syntax {"+" Aliases}]
["[1][0]" synthesis]
["[1][0]" directive {"+" Requirements}]
@@ -51,10 +53,11 @@
["[0]" descriptor]
["[0]" document]]]]]])
-(def: .public (state target module expander host_analysis host generate generation_bundle)
+(def: .public (state target module configuration expander host_analysis host generate generation_bundle)
(All (_ anchor expression directive)
(-> Target
descriptor.Module
+ Configuration
Expander
///analysis.Bundle
(///generation.Host expression directive)
@@ -65,7 +68,7 @@
generation_state [generation_bundle (///generation.state host module)]
eval (///analysis/evaluation.evaluator expander synthesis_state generation_state generate)
analysis_state [(analysisE.bundle eval host_analysis)
- (///analysis.state (///analysis.info ///version.version target))]]
+ (///analysis.state (///analysis.info version.latest target configuration))]]
[extension.empty
[///directive.#analysis [///directive.#state analysis_state
///directive.#phase (analysisP.phase expander)]
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 2ddc8a689..f489c1fb8 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -3,7 +3,6 @@
[lux "*"
["@" target]
["[0]" debug]
- ["[0]" meta]
[abstract
["[0]" monad {"+" Monad do}]]
[control
@@ -27,6 +26,8 @@
["[0]" list ("[1]#[0]" monoid functor mix)]]
[format
["_" binary {"+" Writer}]]]
+ ["[0]" meta
+ ["[0]" configuration {"+" Configuration}]]
[type {"+" :sharing}
["[0]" check]]
[world
@@ -40,7 +41,6 @@
[lux
[program {"+" Program}]
["$" /]
- ["[1][0]" version]
["[0]" syntax]
["[1][0]" synthesis]
["[1][0]" generation {"+" Buffer}]
@@ -240,7 +240,7 @@
(dictionary.merged directives (host_directive_bundle phase_wrapper))])
(def: .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender
- import compilation_sources)
+ import compilation_sources compilation_configuration)
(All (_ <type_vars>)
(-> Context
descriptor.Module
@@ -251,18 +251,19 @@
(-> ///phase.Wrapper (///directive.Bundle <type_vars>))
(Program expression directive)
[Type Type Type] (-> ///phase.Wrapper Extender)
- Import (List _io.Context)
+ Import (List _io.Context) Configuration
(Async (Try [<State+> Archive ///phase.Wrapper]))))
(do [! (try.with async.monad)]
[.let [state (//init.state (value@ context.#host context)
module
+ compilation_configuration
expander
host_analysis
(value@ #host platform)
(value@ #phase platform)
generation_bundle)]
_ (cache.enable! (value@ #&file_system platform) context)
- [archive analysis_state bundles] (ioW.thaw (value@ #host platform) (value@ #&file_system platform) context import compilation_sources)
+ [archive analysis_state bundles] (ioW.thaw compilation_configuration (value@ #host platform) (value@ #&file_system platform) context import compilation_sources)
.let [with_missing_extensions
(: (All (_ <type_vars>)
(-> <Platform> (Program expression directive) <State+>
@@ -753,7 +754,7 @@
(def: .public (compile phase_wrapper import file_context expander platform compilation context)
(All (_ <type_vars>)
(-> ///phase.Wrapper Import Context Expander <Platform> Compilation <Context> <Return>))
- (let [[host_dependencies libraries compilers sources target module] compilation
+ (let [[host_dependencies libraries compilers sources target module configuration] compilation
importer (|> (..compiler phase_wrapper expander platform)
(serial_compiler import file_context platform sources)
(..parallel context))]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux
index 566a7afa9..faf7f3b90 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux
@@ -6,9 +6,10 @@
["<b>" binary {"+" Parser}]]]
[data
[format
- ["_" binary {"+" Writer}]]]]]
+ ["_" binary {"+" Writer}]]]
+ [meta
+ ["[0]" version]]]]
["[0]" / "_"
- ["[1][0]" version]
[analysis
["[0]" module]]
[///
@@ -86,5 +87,5 @@
(def: .public key
(Key .Module)
(key.key [signature.#name (symbol ..compiler)
- signature.#version /version.version]
+ signature.#version version.latest]
(module.empty 0)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
index 5ac2fda49..650842124 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
@@ -28,7 +28,8 @@
["r" rev]
["f" frac]]]
[meta
- ["[0]" location]]]]
+ ["[0]" location]
+ ["[0]" configuration {"+" Configuration}]]]]
["[0]" / "_"
["[1][0]" simple {"+" Simple}]
["[1][0]" complex {"+" Tuple Variant Complex}]
@@ -356,11 +357,12 @@
.#var_counter 0
.#var_bindings (list)])
-(def: .public (info version host)
- (-> Version Text Info)
+(def: .public (info version host configuration)
+ (-> Version Text Configuration Info)
[.#target host
.#version (version.format version)
- .#mode {.#Build}])
+ .#mode {.#Build}
+ .#configuration configuration])
(def: .public (state info)
(-> Info Lux)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
index c9ad8c0eb..d4c947953 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
@@ -38,9 +38,6 @@
["[0]" descriptor]]]]
[tool
[compiler
- [language
- [lux
- [version {"+" version}]]]
[meta
[io {"+" lux_context}]
[archive
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
index fc96c025f..6031ed1db 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
@@ -21,6 +21,8 @@
["n" nat]
["[0]" i32]
["[0]" i64]]]
+ [meta
+ ["[0]" version]]
[target
["[0]" jvm "_"
["_" bytecode {"+" Label Bytecode}]
@@ -48,7 +50,6 @@
["[1]/[0]" count]]]]
["//[1]" /// "_"
[//
- ["[0]" version]
["[0]" synthesis]
["[0]" generation]
[///
@@ -92,7 +93,7 @@
(def: .public (class_name [module id])
(-> unit.ID Text)
(format lux_context
- "." (%.nat version.version)
+ "." (%.nat version.latest)
"." (%.nat module)
"." (%.nat id)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/version.lux b/stdlib/source/library/lux/tool/compiler/language/lux/version.lux
deleted file mode 100644
index cc044938c..000000000
--- a/stdlib/source/library/lux/tool/compiler/language/lux/version.lux
+++ /dev/null
@@ -1,9 +0,0 @@
-(.using
- [library
- [lux "*"]]
- [////
- [version {"+" Version}]])
-
-(def: .public version
- Version
- 00,06,06)
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli.lux b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
index 056652661..f13f1596c 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cli.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
@@ -18,7 +18,8 @@
[math
[number {"+" hex}]]
[meta
- ["[0]" symbol]]
+ ["[0]" symbol]
+ ["[0]" configuration {"+" Configuration}]]
[tool
[compiler
[meta
@@ -52,7 +53,8 @@
#compilers (List Compiler)
#sources (List Source)
#target Target
- #module Module]))
+ #module Module
+ #configuration Configuration]))
(type: .public Interpretation
..Compilation)
@@ -77,6 +79,7 @@
[source_parser "--source" Source <cli>.any]
[target_parser "--target" Target <cli>.any]
[module_parser "--module" Module <cli>.any]
+ [configuration_parser "--configuration" Configuration (<text>.then configuration.parser <cli>.any)]
)
(def: .public service
@@ -88,7 +91,8 @@
(<>.some ..compiler_parser)
(<>.some ..source_parser)
..target_parser
- ..module_parser))]
+ ..module_parser
+ ..configuration_parser))]
($_ <>.or
(<>.after (<cli>.this "build")
compiler)
diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
index 4693a7d2f..13e848153 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
@@ -26,6 +26,9 @@
[math
[number
["n" nat]]]
+ [meta
+ ["[0]" configuration {"+" Configuration}]
+ ["[0]" version]]
[world
["[0]" file]]]]
["[0]" //
@@ -46,7 +49,6 @@
["/[1]" // {"+" Input}
[language
["$" lux
- ["[0]" version]
["[0]" analysis]
["[0]" synthesis]
["[0]" generation]
@@ -145,12 +147,12 @@
..module_parser
registry.parser))
-(def: (fresh_analysis_state host)
- (-> Target .Lux)
- (analysis.state (analysis.info version.version host)))
+(def: (fresh_analysis_state host configuration)
+ (-> Target Configuration .Lux)
+ (analysis.state (analysis.info version.latest host configuration)))
-(def: (analysis_state host archive)
- (-> Target Archive (Try .Lux))
+(def: (analysis_state host configuration archive)
+ (-> Target Configuration Archive (Try .Lux))
(do [! try.monad]
[modules (: (Try (List [descriptor.Module .Module]))
(monad.each ! (function (_ module)
@@ -161,7 +163,7 @@
(document.content $.key))]
(in [module content])))
(archive.archived archive)))]
- (in (with@ .#modules modules (fresh_analysis_state host)))))
+ (in (with@ .#modules modules (fresh_analysis_state host configuration)))))
(def: (cached_artifacts fs context module_id)
(-> (file.System Async) Context module.ID (Async (Try (Dictionary Text Binary))))
@@ -463,9 +465,9 @@
bundles])))))]
(in it)))
-(def: (load_every_reserved_module host_environment fs context import contexts archive)
+(def: (load_every_reserved_module configuration host_environment fs context import contexts archive)
(All (_ expression directive)
- (-> (generation.Host expression directive) (file.System Async) Context Import (List //.Context) Archive
+ (-> Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context) Archive
(Async (Try [Archive .Lux Bundles]))))
(do [! (try.with async.monad)]
[pre_loaded_caches (..pre_loaded_caches fs context import contexts archive)
@@ -482,7 +484,7 @@
(archive.has module entry archive))
archive
loaded_caches)
- analysis_state (..analysis_state (value@ context.#host context) archive)]
+ analysis_state (..analysis_state (value@ context.#host context) configuration archive)]
(in [archive
analysis_state
(list#mix (function (_ [_ [+analysers +synthesizers +generators +directives]]
@@ -494,9 +496,9 @@
..empty_bundles
loaded_caches)])))))
-(def: .public (thaw host_environment fs context import contexts)
+(def: .public (thaw configuration host_environment fs context import contexts)
(All (_ expression directive)
- (-> (generation.Host expression directive) (file.System Async) Context Import (List //.Context)
+ (-> Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context)
(Async (Try [Archive .Lux Bundles]))))
(do async.monad
[binary (# fs read (..general_descriptor fs context))]
@@ -504,9 +506,9 @@
{try.#Success binary}
(do (try.with async.monad)
[archive (async#in (archive.import ///.version binary))]
- (..load_every_reserved_module host_environment fs context import contexts archive))
+ (..load_every_reserved_module configuration host_environment fs context import contexts archive))
{try.#Failure error}
(in {try.#Success [archive.empty
- (fresh_analysis_state (value@ context.#host context))
+ (fresh_analysis_state (value@ context.#host context) configuration)
..empty_bundles]}))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
index 1bfd062fe..fb4d43410 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
@@ -25,9 +25,6 @@
["_" ruby]]
[world
["[0]" file]]]]
- [program
- [compositor
- ["[0]" static {"+" Static}]]]
["[0]" // {"+" Packager}
[//
["[0]" archive {"+" Output}