aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool
diff options
context:
space:
mode:
authorEduardo Julian2021-06-12 01:32:40 -0400
committerEduardo Julian2021-06-12 01:32:40 -0400
commitaf3e6e2cb011dc2ad9204440990731a2f272716d (patch)
tree3521c74b05fc5b3ddddbe901d32ace87dbb6c018 /stdlib/source/lux/tool
parent8f575da5095e3b259d4eb6b6f13d3e37ef1d38e4 (diff)
Constraining the year of the snapshot time in Aedifex.
Diffstat (limited to 'stdlib/source/lux/tool')
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux9
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux10
-rw-r--r--stdlib/source/lux/tool/compiler/meta/packager/jvm.lux101
3 files changed, 55 insertions, 65 deletions
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux
index 419fca601..0b4885180 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux
@@ -1,5 +1,8 @@
(.module:
[lux (#- Type)
+ [data
+ [text
+ ["%" format]]]
[target
[jvm
["." type (#+ Type)
@@ -9,7 +12,11 @@
[constant
["." arity]]]])
-(def: #export class (type.class "LuxFunction" (list)))
+(def: #export artifact_id
+ 1)
+
+(def: #export class
+ (type.class (%.nat artifact_id) (list)))
(def: #export init
(Type Method)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
index 011734cc8..ec3080fc2 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
@@ -88,7 +88,11 @@
"/" (%.nat module)
"/" (%.nat id)))
-(def: #export class (type.class "LuxRuntime" (list)))
+(def: artifact_id
+ 0)
+
+(def: #export class
+ (type.class (%.nat ..artifact_id) (list)))
(def: procedure
(-> Text (Type category.Method) (Bytecode Any))
@@ -532,7 +536,7 @@
(row.row)))]
(do ////.monad
[_ (generation.execute! [class bytecode])]
- (generation.save! class [class bytecode]))))
+ (generation.save! ..artifact_id [class bytecode]))))
(def: generate_function
(Operation Any)
@@ -589,7 +593,7 @@
(row.row)))]
(do ////.monad
[_ (generation.execute! [class bytecode])]
- (generation.save! class [class bytecode]))))
+ (generation.save! //function.artifact_id [class bytecode]))))
(def: #export generate
(Operation Any)
diff --git a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
index 15552a656..1df76453c 100644
--- a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
@@ -15,8 +15,8 @@
["." text
["%" format (#+ format)]]
[collection
- ["." row (#+ Row)]
- ["." list ("#\." functor)]]]
+ ["." row (#+ Row) ("#\." fold)]
+ ["." list ("#\." functor fold)]]]
[math
[number
["n" nat]]]
@@ -31,9 +31,11 @@
["." static (#+ Static)]]]
["." // (#+ Packager)
[//
- ["." archive
+ ["." archive (#+ Output)
["." descriptor (#+ Module)]
["." artifact]]
+ [cache
+ ["." dependency]]
["." io #_
["#" archive]]
[//
@@ -106,64 +108,41 @@
(-> Context java/util/jar/Manifest)
(let [manifest (java/util/jar/Manifest::new)]
(exec (do_to (java/util/jar/Manifest::getMainAttributes manifest)
- (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external))
- (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version))
+ (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external))
+ (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version))
manifest)))
-## TODO: Delete ASAP
-(type: (Action ! a)
- (! (Try a)))
-
-(def: (write_class monad file_system static context sink)
- (All [!]
- (-> (Monad !) (file.System !) Static Context java/util/jar/JarOutputStream
- (Action ! java/util/jar/JarOutputStream)))
- (do (try.with monad)
- [artifact (let [[module artifact] context]
- (!.use (\ file_system file) [(io.artifact file_system static module (%.nat artifact))]))
- content (!.use (\ artifact content) [])
- #let [class_path (format (runtime.class_name context) (get@ #static.artifact_extension static))]]
- (wrap (do_to sink
- (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path))
- (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content)))
+(def: (write_class static module artifact content sink)
+ (-> Static archive.ID artifact.ID Binary java/util/jar/JarOutputStream
+ java/util/jar/JarOutputStream)
+ (let [class_path (format (runtime.class_name [module artifact])
+ (get@ #static.artifact_extension static))]
+ (do_to sink
+ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path))
+ (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content)))
+ (java/io/Flushable::flush)
+ (java/util/zip/ZipOutputStream::closeEntry))))
+
+(def: (write_module static [module output] sink)
+ (-> Static [archive.ID Output] java/util/jar/JarOutputStream
+ java/util/jar/JarOutputStream)
+ (row\fold (function (_ [artifact content] sink)
+ (..write_class static module artifact content sink))
+ sink
+ output))
+
+(def: #export (package static)
+ (-> Static Packager)
+ (function (_ archive program)
+ (do {! try.monad}
+ [order (dependency.load_order $.key archive)
+ #let [buffer (java/io/ByteArrayOutputStream::new (.int ..mebi_byte))
+ sink (|> order
+ (list\map (function (_ [module [module_id [descriptor document output]]])
+ [module_id output]))
+ (list\fold (..write_module static)
+ (java/util/jar/JarOutputStream::new buffer (..manifest program))))
+ _ (do_to sink
(java/io/Flushable::flush)
- (java/util/zip/ZipOutputStream::closeEntry)))))
-
-(def: (write_module monad file_system static [module artifacts] sink)
- (All [!]
- (-> (Monad !) (file.System !) Static [archive.ID (List artifact.ID)] java/util/jar/JarOutputStream
- (Action ! java/util/jar/JarOutputStream)))
- (monad.fold (:assume (try.with monad))
- (function (_ artifact sink)
- (..write_class monad file_system static [module artifact] sink))
- sink
- artifacts))
-
-(def: #export (package monad file_system static archive program)
- (All [!] (Packager !))
- (do {! (try.with monad)}
- [cache (:share [!]
- {(Monad !)
- monad}
- {(! (Try (Directory !)))
- (:assume (!.use (\ file_system directory) [(get@ #static.target static)]))})
- order (|> archive
- archive.archived
- (monad.map try.monad (function (_ module)
- (do try.monad
- [[descriptor document] (archive.find module archive)
- module_id (archive.id module archive)]
- (wrap (|> descriptor
- (get@ #descriptor.registry)
- artifact.artifacts
- row.to_list
- (list\map (|>> (get@ #artifact.id)))
- [module_id])))))
- (\ monad wrap))
- #let [buffer (java/io/ByteArrayOutputStream::new (.int ..mebi_byte))
- sink (java/util/jar/JarOutputStream::new buffer (..manifest program))]
- sink (monad.fold ! (..write_module monad file_system static) sink order)
- #let [_ (do_to sink
- (java/io/Flushable::flush)
- (java/io/Closeable::close))]]
- (wrap (java/io/ByteArrayOutputStream::toByteArray buffer))))
+ (java/io/Closeable::close))]]
+ (wrap (java/io/ByteArrayOutputStream::toByteArray buffer)))))