aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux/control/concurrency/thread.lux105
-rw-r--r--stdlib/source/library/lux/target/jvm/field.lux58
-rw-r--r--stdlib/source/library/lux/target/ruby.lux10
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/init.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux7
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux.lux35
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux (renamed from stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux)65
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux62
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux144
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux11
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux21
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/script.lux7
16 files changed, 307 insertions, 238 deletions
diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux
index a43bc47a5..9d91b6ee8 100644
--- a/stdlib/source/library/lux/control/concurrency/thread.lux
+++ b/stdlib/source/library/lux/control/concurrency/thread.lux
@@ -1,26 +1,26 @@
(.using
- [library
- [lux "*"
- ["@" target]
- ["[0]" ffi]
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" try]
- ["[0]" exception {"+" exception:}]
- ["[0]" io {"+" IO io}]]
- [data
- ["[0]" text]
- [collection
- ["[0]" list]]]
- [math
- [number
- ["n" nat]
- ["f" frac]]]
- [time
- ["[0]" instant]]]]
- [//
- ["[0]" atom {"+" Atom}]])
+ [library
+ [lux "*"
+ ["@" target]
+ ["[0]" ffi]
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" try]
+ ["[0]" exception {"+" exception:}]
+ ["[0]" io {"+" IO io}]]
+ [data
+ ["[0]" text]
+ [collection
+ ["[0]" list]]]
+ [math
+ [number
+ ["n" nat]
+ ["f" frac]]]
+ [time
+ ["[0]" instant]]]]
+ [//
+ ["[0]" atom {"+" Atom}]])
(with_expansions [<jvm> (as_is (ffi.import: java/lang/Object)
@@ -84,9 +84,12 @@
@.python (as_is)]
... Default
- (def: runner
- (Atom (List Thread))
- (atom.atom (list)))))
+ (as_is (def: started?
+ (Atom Bit)
+ (atom.atom false))
+ (def: runner
+ (Atom (List Thread))
+ (atom.atom (list))))))
(def: (execute! action)
(-> (IO Any) Any)
@@ -147,27 +150,33 @@
... Starts the event-loop.
(def: .public run!
(IO Any)
- (loop [_ []]
- (do [! io.monad]
- [threads (atom.read! ..runner)]
- (case threads
- ... And... we're done!
- {.#End}
- (in [])
-
- _
- (do !
- [now (# ! each (|>> instant.millis .nat) instant.now)
- .let [[ready pending] (list.partition (function (_ thread)
- (|> (value@ #creation thread)
- (n.+ (value@ #delay thread))
- (n.<= now)))
- threads)]
- swapped? (atom.compare_and_swap! threads pending ..runner)]
- (if swapped?
- (do !
- [_ (monad.each ! (|>> (value@ #action) ..execute! io.io) ready)]
- (again []))
- (panic! (exception.error ..cannot_continue_running_threads []))))
- ))))
+ (do [! io.monad]
+ [started? (atom.read! ..started?)]
+ (if started?
+ (in [])
+ (do !
+ [_ (atom.write! true ..started?)]
+ (loop [_ []]
+ (do !
+ [threads (atom.read! ..runner)]
+ (case threads
+ ... And... we're done!
+ {.#End}
+ (in [])
+
+ _
+ (do !
+ [now (# ! each (|>> instant.millis .nat) instant.now)
+ .let [[ready pending] (list.partition (function (_ thread)
+ (|> (value@ #creation thread)
+ (n.+ (value@ #delay thread))
+ (n.<= now)))
+ threads)]
+ swapped? (atom.compare_and_swap! threads pending ..runner)]
+ (if swapped?
+ (do !
+ [_ (monad.each ! (|>> (value@ #action) ..execute! io.io) ready)]
+ (again []))
+ (panic! (exception.error ..cannot_continue_running_threads []))))
+ )))))))
))
diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux
index 31b302954..ee6daa975 100644
--- a/stdlib/source/library/lux/target/jvm/field.lux
+++ b/stdlib/source/library/lux/target/jvm/field.lux
@@ -1,24 +1,24 @@
(.using
- [library
- [lux {"-" Type static public private}
- [abstract
- [equivalence {"+" Equivalence}]
- ["[0]" monad {"+" do}]]
- [data
- ["[0]" product]
- [format
- ["[0]F" binary {"+" Writer} ("[1]#[0]" monoid)]]
- [collection
- ["[0]" sequence {"+" Sequence}]]]]]
- ["[0]" // "_"
- ["[0]" modifier {"+" Modifier modifiers:}]
- ["[1][0]" constant {"+" UTF8}
- ["[1]/[0]" pool {"+" Pool Resource}]]
- ["[1][0]" index {"+" Index}]
- ["[1][0]" attribute {"+" Attribute}]
- ["[1][0]" type {"+" Type}
- [category {"+" Value}]
- [descriptor {"+" Descriptor}]]])
+ [library
+ [lux {"-" Type static public private}
+ [abstract
+ [equivalence {"+" Equivalence}]
+ ["[0]" monad {"+" do}]]
+ [data
+ ["[0]" product]
+ [format
+ ["[0]F" binary {"+" Writer} ("[1]#[0]" monoid)]]
+ [collection
+ ["[0]" sequence {"+" Sequence}]]]]]
+ ["[0]" // "_"
+ ["[0]" modifier {"+" Modifier modifiers:}]
+ ["[1][0]" constant {"+" UTF8}
+ ["[1]/[0]" pool {"+" Pool Resource}]]
+ ["[1][0]" index {"+" Index}]
+ ["[1][0]" attribute {"+" Attribute}]
+ ["[1][0]" type {"+" Type}
+ [category {"+" Value}]
+ [descriptor {"+" Descriptor}]]])
(type: .public Field
(Rec Field
@@ -60,13 +60,21 @@
[(binaryF.sequence/16 //attribute.writer) #attributes]))
)))
-(def: .public (field modifier name type attributes)
- (-> (Modifier Field) UTF8 (Type Value) (Sequence Attribute)
+(def: .public (field modifier name type with_signature? attributes)
+ (-> (Modifier Field) UTF8 (Type Value) Bit (Sequence Attribute)
(Resource Field))
- (do //constant/pool.monad
+ (do [! //constant/pool.monad]
[@name (//constant/pool.utf8 name)
- @descriptor (//constant/pool.descriptor (//type.descriptor type))]
+ @descriptor (//constant/pool.descriptor (//type.descriptor type))
+ @signature (if with_signature?
+ (# ! each (|>> {.#Some}) (//attribute.signature (//type.signature type)))
+ (in {.#None}))]
(in [#modifier modifier
#name @name
#descriptor @descriptor
- #attributes attributes])))
+ #attributes (case @signature
+ {.#Some @signature}
+ (sequence.suffix @signature attributes)
+
+ {.#None}
+ attributes)])))
diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux
index edc4d44f8..05b1bf768 100644
--- a/stdlib/source/library/lux/target/ruby.lux
+++ b/stdlib/source/library/lux/target/ruby.lux
@@ -130,6 +130,7 @@
["?" exit_status]
["stdout" stdout]
+ ["stdin" stdin]
)
(template [<ruby_name> <lux_name>]
@@ -463,6 +464,11 @@
(|> (..manual "Class")
(..new (list) {.#Some definition})))
+(def: .public (module definition)
+ (-> Block Computation)
+ (|> (..manual "Module")
+ (..new (list) {.#Some definition})))
+
(def: .public (apply_lambda/* args lambda)
(-> (List Expression) Expression Computation)
(|> lambda
@@ -490,9 +496,13 @@
<definitions>))]
+ [0
+ [["gets"]]]
+
[1
[["print"]
["include"]
+ ["extend"]
["require"]
["defined?"]]]
diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux
index c44dd5e7e..ebdddd347 100644
--- a/stdlib/source/library/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/init.lux
@@ -33,12 +33,12 @@
["[1][0]" generation]
["[1][0]" analysis
[macro {"+" Expander}]
- ["[1]/[0]" evaluation]]
+ ["[1]/[0]" evaluation]
+ ["[0]A" module]]
[phase
+ ["[0]P" analysis]
["[0]P" synthesis]
["[0]P" directive]
- ["[0]P" analysis
- ["[0]A" module]]
["[0]" extension {"+" Extender}
["[0]E" analysis]
["[0]E" synthesis]
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 96c638d52..d20a1b7d7 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -41,14 +41,13 @@
["[1][0]" version]
["[0]" syntax]
["[1][0]" analysis
- [macro {"+" Expander}]]
+ [macro {"+" Expander}]
+ ["[0]A" module]]
["[1][0]" synthesis]
["[1][0]" generation {"+" Buffer}]
["[1][0]" directive]
[phase
- ["[0]" extension {"+" Extender}]
- [analysis
- ["[0]A" module]]]]]
+ ["[0]" extension {"+" Extender}]]]]
[meta
["[0]" archive {"+" Output Archive}
["[0]" registry {"+" Registry}]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux
index ae38fc2de..566a7afa9 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux
@@ -1,22 +1,21 @@
(.using
- [library
- [lux "*"
- [control
- ["<>" parser
- ["<b>" binary {"+" Parser}]]]
- [data
- [format
- ["_" binary {"+" Writer}]]]]]
- ["[0]" / "_"
- ["[1][0]" version]
- [phase
- [analysis
- ["[0]" module]]]
- [///
- [meta
- [archive
- ["[0]" signature]
- ["[0]" key {"+" Key}]]]]])
+ [library
+ [lux "*"
+ [control
+ ["<>" parser
+ ["<b>" binary {"+" Parser}]]]
+ [data
+ [format
+ ["_" binary {"+" Writer}]]]]]
+ ["[0]" / "_"
+ ["[1][0]" version]
+ [analysis
+ ["[0]" module]]
+ [///
+ [meta
+ [archive
+ ["[0]" signature]
+ ["[0]" key {"+" Key}]]]]])
... TODO: Remove #module_hash, #imports & #module_state ASAP.
... TODO: Not just from this parser, but from the lux.Module type.
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux
index 3ca157f38..e0798d438 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux "*"
+ [lux {"-" Label}
[abstract
["[0]" monad {"+" do}]]
[control
@@ -15,28 +15,29 @@
[dictionary
["[0]" plist]]]]
["[0]" meta]]]
- ["[0]" /// "_"
- ["[1][0]" extension]
- [//
- ["/" analysis {"+" Operation}]
+ ["/" // {"+" Operation}
+ ["//[1]" // "_"
+ [phase
+ ["[1][0]" extension]]
[///
["[1]" phase]]]])
-(type: .public Tag Text)
+(type: .public Label
+ Text)
(exception: .public (unknown_module [module Text])
(exception.report
["Module" module]))
(template [<name>]
- [(exception: .public (<name> [tags (List Text)
+ [(exception: .public (<name> [labels (List Label)
owner Type])
(exception.report
- ["Tags" (text.interposed " " tags)]
+ ["Labels" (text.interposed " " labels)]
["Type" (%.type owner)]))]
- [cannot_declare_tags_for_unnamed_type]
- [cannot_declare_tags_for_foreign_type]
+ [cannot_declare_labels_for_anonymous_type]
+ [cannot_declare_labels_for_foreign_type]
)
(exception: .public (cannot_define_more_than_once [name Symbol
@@ -70,11 +71,11 @@
(def: .public (empty hash)
(-> Nat Module)
- [.#module_hash hash
- .#module_aliases (list)
- .#definitions (list)
- .#imports (list)
- .#module_state {.#Active}])
+ [.#module_hash hash
+ .#module_aliases (list)
+ .#definitions (list)
+ .#imports (list)
+ .#module_state {.#Active}])
(def: .public (import module)
(-> Text (Operation Any))
@@ -147,7 +148,7 @@
(def: .public (with_module hash name action)
(All (_ a) (-> Nat Text (Operation a) (Operation [Module a])))
(do ///.monad
- [_ (create hash name)
+ [_ (..create hash name)
output (/.with_current_module name
action)
module (///extension.lifted (meta.module name))]
@@ -168,11 +169,11 @@
(plist.has module_name (with@ .#module_state {<tag>} module))
state)
[]]}
- ((///extension.up (/.except can_only_change_state_of_active_module [module_name {<tag>}]))
+ ((///extension.up (/.except ..can_only_change_state_of_active_module [module_name {<tag>}]))
state)))
{.#None}
- ((///extension.up (/.except unknown_module module_name))
+ ((///extension.up (/.except ..unknown_module module_name))
state)))))
(def: .public (<asker> module_name)
@@ -187,7 +188,7 @@
_ #0)]}
{.#None}
- ((///extension.up (/.except unknown_module module_name))
+ ((///extension.up (/.except ..unknown_module module_name))
state)))))]
[set_active active? .#Active]
@@ -195,20 +196,8 @@
[set_cached cached? .#Cached]
)
-(def: (hash module_name)
- (-> Text (Operation Nat))
- (///extension.lifted
- (function (_ state)
- (case (|> state (value@ .#modules) (plist.value module_name))
- {.#Some module}
- {try.#Success [state (value@ .#module_hash module)]}
-
- {.#None}
- ((///extension.up (/.except unknown_module module_name))
- state)))))
-
-(def: .public (declare_tags record? tags exported? type)
- (-> Bit (List Tag) Bit Type (Operation Any))
+(def: .public (declare_labels record? labels exported? type)
+ (-> Bit (List Label) Bit Type (Operation Any))
(do [! ///.monad]
[self_name (///extension.lifted meta.current_module_name)
[type_module type_name] (case type
@@ -216,12 +205,12 @@
(in type_name)
_
- (/.except ..cannot_declare_tags_for_unnamed_type [tags type]))
- _ (///.assertion cannot_declare_tags_for_foreign_type [tags type]
+ (/.except ..cannot_declare_labels_for_anonymous_type [labels type]))
+ _ (///.assertion ..cannot_declare_labels_for_foreign_type [labels type]
(text#= self_name type_module))]
(monad.each ! (function (_ [index short])
(..define short
(if record?
- {.#Slot [exported? type tags index]}
- {.#Tag [exported? type tags index]})))
- (list.enumeration tags))))
+ {.#Slot [exported? type labels index]}
+ {.#Tag [exported? type labels index]})))
+ (list.enumeration labels))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index be1e560ca..2bc7d831e 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -1679,12 +1679,62 @@
{#Protected} ..protected_tag
{#Default} ..default_tag)))
+(type: Exception
+ (Type Class))
+
+(type: .public (Abstract_Method a)
+ [Text
+ Visibility
+ (List (Annotation a))
+ (List (Type Var))
+ (List Argument)
+ (Type Return)
+ (List Exception)])
+
+(def: abstract_tag "abstract")
+
+(def: .public abstract_method_definition
+ (Parser (Abstract_Method Code))
+ (<| <code>.form
+ (<>.after (<code>.text! ..abstract_tag))
+ ($_ <>.and
+ <code>.text
+ ..visibility
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..var))
+ (<code>.tuple (<>.some ..argument))
+ ..return
+ (<code>.tuple (<>.some ..class)))))
+
+(def: .public (analyse_abstract_method analyse archive method)
+ (-> Phase Archive (Abstract_Method Code) (Operation Analysis))
+ (let [[method_name visibility annotations vars arguments return exceptions] method]
+ (do [! phase.monad]
+ [annotationsA (monad.each ! (function (_ [name parameters])
+ (do !
+ [parametersA (monad.each ! (function (_ [name value])
+ (do !
+ [valueA (analyse archive value)]
+ (in [name valueA])))
+ parameters)]
+ (in [name parametersA])))
+ annotations)]
+ (in (/////analysis.tuple (list (/////analysis.text ..abstract_tag)
+ (/////analysis.text method_name)
+ (visibility_analysis visibility)
+ (/////analysis.tuple (list#each annotation_analysis annotationsA))
+ (/////analysis.tuple (list#each var_analysis vars))
+ (/////analysis.tuple (list#each ..argument_analysis arguments))
+ (return_analysis return)
+ (/////analysis.tuple (list#each class_analysis exceptions))
+ ))))))
+
(type: .public (Constructor a)
[Visibility
Strictness
(List (Annotation a))
(List (Type Var))
- (List (Type Class)) ... Exceptions
+ (List Exception)
Text
(List Argument)
(List (Typed a))
@@ -1766,7 +1816,7 @@
Text
(List Argument)
(Type Return)
- (List (Type Class)) ... Exceptions
+ (List Exception)
a])
(def: virtual_tag "virtual")
@@ -1861,9 +1911,9 @@
Strictness
(List (Annotation a))
(List (Type Var))
- (List (Type Class)) ... Exceptions
(List Argument)
(Type Return)
+ (List Exception)
a])
(def: .public static_tag "static")
@@ -1878,16 +1928,16 @@
<code>.bit
(<code>.tuple (<>.some ..annotation))
(<code>.tuple (<>.some ..var))
- (<code>.tuple (<>.some ..class))
(<code>.tuple (<>.some ..argument))
..return
+ (<code>.tuple (<>.some ..class))
<code>.any)))
(def: .public (analyse_static_method analyse archive mapping method)
(-> Phase Archive Mapping (Static_Method Code) (Operation Analysis))
(let [[method_name visibility
- strict_fp? annotations vars exceptions
- arguments return
+ strict_fp? annotations vars
+ arguments return exceptions
body] method]
(do [! phase.monad]
[annotationsA (monad.each ! (function (_ [name parameters])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
index bdf4d3e11..872b224b4 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
@@ -43,6 +43,7 @@
[category {"+" Void Value Return Primitive Object Class Array Var Parameter}]
["[0]T" lux {"+" Mapping}]
["[0]" signature]
+ ["[0]" reflection]
["[0]" descriptor {"+" Descriptor}]
["[0]" parser]]]]
[tool
@@ -53,13 +54,12 @@
["[0]" artifact]]]
[language
[lux
- ["[0]" analysis]
["[0]" synthesis]
["[0]" generation]
["[0]" directive {"+" Handler Bundle}]
+ ["[0]" analysis
+ ["[0]A" type]]
[phase
- [analysis
- ["[0]A" type]]
[generation
[jvm
["[0]" runtime {"+" Anchor Definition Extender}]]]
@@ -76,6 +76,7 @@
(directive.Operation Anchor (Bytecode Any) Definition))
(def: signature (|>> type.signature signature.signature))
+(def: reflection (|>> type.reflection reflection.reflection))
(type: Declaration
[Text (List (Type Var))])
@@ -178,7 +179,8 @@
{#Constructor (jvm.Constructor Code)}
{#Virtual_Method (jvm.Virtual_Method Code)}
{#Static_Method (jvm.Static_Method Code)}
- {#Overriden_Method (jvm.Overriden_Method Code)}))
+ {#Overriden_Method (jvm.Overriden_Method Code)}
+ {#Abstract_Method (jvm.Abstract_Method Code)}))
(def: method
(Parser Method_Definition)
@@ -187,6 +189,7 @@
jvm.virtual_method_definition
jvm.static_method_definition
jvm.overriden_method_definition
+ jvm.abstract_method_definition
))
(def: $Object
@@ -211,7 +214,7 @@
(do pool.monad
[constant (`` (|> value (~~ (template.spliced <constant>))))
attribute (attribute.constant constant)]
- (field.field ..constant::modifier name <type> (sequence.sequence attribute)))])
+ (field.field ..constant::modifier name <type> true (sequence.sequence attribute)))])
([.#Bit type.boolean [(case> #0 +0 #1 +1) .i64 i32.i32 constant.integer pool.integer]]
[.#Int type.byte [.i64 i32.i32 constant.integer pool.integer]]
[.#Int type.short [.i64 i32.i32 constant.integer pool.integer]]
@@ -230,7 +233,7 @@
... TODO: Handle annotations.
{#Variable [name visibility state annotations type]}
(field.field (modifier#composite visibility state)
- name type sequence.empty)))
+ name type true sequence.empty)))
(def: (method_definition archive supers [mapping selfT] [analyse synthesize generate])
(-> Archive
@@ -255,16 +258,21 @@
(jvm.analyse_static_method analyse archive mapping method)
{#Overriden_Method method}
- (jvm.analyse_overriden_method analyse archive selfT mapping supers method))))]
+ (jvm.analyse_overriden_method analyse archive selfT mapping supers method)
+
+ {#Abstract_Method method}
+ (jvm.analyse_abstract_method analyse archive method))))]
(directive.lifted_synthesis
(synthesize archive methodA)))))
+(def: class_name
+ (|>> parser.read_class product.left name.internal))
+
(def: (mock_class [name parameters] super interfaces fields methods modifier)
(-> Declaration (Type Class) (List (Type Class))
(List (Resource field.Field)) (List (Resource method.Method)) (Modifier class.Class)
(Try [External Binary]))
- (let [class_name (|>> parser.read_class product.left name.internal)
- signature (signature.inheritance (list#each type.signature parameters)
+ (let [signature (signature.inheritance (list#each type.signature parameters)
(type.signature super)
(list#each type.signature interfaces))]
(try#each (|>> (format.result class.writer)
@@ -275,22 +283,12 @@
modifier)
(name.internal name)
{.#Some signature}
- (class_name super)
- (list#each class_name interfaces)
+ (..class_name super)
+ (list#each ..class_name interfaces)
fields
methods
sequence.empty))))
-(def: (mock_field it)
- (-> ..Field (Resource field.Field))
- (case it
- ... TODO: Handle constants
- {#Constant [name annotations type term]}
- (undefined)
-
- {#Variable [name visibility state annotations type]}
- (field.field ($_ modifier#composite visibility state) name type sequence.empty)))
-
(def: (mock_value valueT)
(-> (Type Value) (Bytecode Any))
(case (type.primitive? valueT)
@@ -393,7 +391,7 @@
{.#Some (..mock_return return)})
{#Static_Method [name privacy strict_floating_point? annotations
- variables exceptions arguments return
+ variables arguments return exceptions
body]}
(method.method ($_ modifier#composite
method.static
@@ -406,15 +404,15 @@
(list)
{.#Some (..mock_return return)})
- ... {#Abstract [name privacy annotations
- ... variables arguments return exceptions]}
- ... (method.method ($_ modifier#composite
- ... method.abstract
- ... (..method_privacy privacy))
- ... name
- ... (type.method [variables (list#each product.right arguments) return exceptions])
- ... (list)
- ... {.#None})
+ {#Abstract_Method [name privacy annotations
+ variables arguments return exceptions]}
+ (method.method ($_ modifier#composite
+ method.abstract
+ (..method_privacy privacy))
+ name
+ (type.method [variables (list#each product.right arguments) return exceptions])
+ (list)
+ {.#None})
))
(def: (mock declaration super interfaces inheritance fields methods)
@@ -423,7 +421,7 @@
(Modifier class.Class) (List ..Field) (List ..Method_Definition)
(Try [External Binary]))
(mock_class declaration super interfaces
- (list#each ..mock_field fields)
+ (list#each ..field_definition fields)
(list#each (..mock_method super) methods)
inheritance))
@@ -437,6 +435,17 @@
[class_declaration [External (List (Type Var))] parser.declaration']
)
+(def: (save_class! name bytecode)
+ (-> Text Binary (Operation Any))
+ (directive.lifted_generation
+ (do [! phase.monad]
+ [.let [artifact [name bytecode]]
+ artifact_id (generation.learn_custom name artifact.no_dependencies)
+ _ (generation.execute! artifact)
+ _ (generation.save! artifact_id {.#Some name} artifact)
+ _ (generation.log! (format "JVM Class " name))]
+ (in []))))
+
(def: jvm::class
(Handler Anchor (Bytecode Any) Definition)
(/.custom
@@ -458,7 +467,10 @@
fields
methods])
(do [! phase.monad]
- [.let [[name parameters] class_declaration]
+ [.let [[name parameters] class_declaration
+ type_declaration (signature.inheritance (list#each type.signature parameters)
+ (type.signature super)
+ (list#each type.signature interfaces))]
mock (<| phase.lifted
(..mock class_declaration
super
@@ -470,50 +482,47 @@
_ (directive.lifted_generation
(generation.execute! mock))
parameters (directive.lifted_analysis
- (typeA.with_env
- (jvm.parameter_types parameters)))
+ (typeA.check (jvm.parameter_types parameters)))
.let [mapping (list#mix (function (_ [parameterJ parameterT] mapping)
(dictionary.has (parser.name parameterJ) parameterT mapping))
luxT.fresh
parameters)]
superT (directive.lifted_analysis
- (typeA.with_env
- (luxT.check (luxT.class mapping) (..signature super))))
+ (typeA.check (luxT.check (luxT.class mapping) (..signature super))))
interfaceT+ (directive.lifted_analysis
- (typeA.with_env
- (monad.each check.monad
- (|>> ..signature (luxT.check (luxT.class mapping)))
- interfaces)))
- .let [selfT (jvm.inheritance_relationship_type {.#Primitive name (list#each product.right parameters)}
- superT
- interfaceT+)]
+ (typeA.check (monad.each check.monad
+ (|>> ..signature (luxT.check (luxT.class mapping)))
+ interfaces)))
state (extension.lifted phase.state)
- .let [analyse (value@ [directive.#analysis directive.#phase] state)
- synthesize (value@ [directive.#synthesis directive.#phase] state)
- generate (value@ [directive.#generation directive.#phase] state)]
- methods (monad.each ! (..method_definition archive (list& super interfaces) [mapping selfT] [analyse synthesize generate])
+ .let [selfT {.#Primitive name (list#each product.right parameters)}]
+ methods (monad.each ! (..method_definition archive (list& super interfaces) [mapping selfT]
+ [(value@ [directive.#analysis directive.#phase] state)
+ (value@ [directive.#synthesis directive.#phase] state)
+ (value@ [directive.#generation directive.#phase] state)])
methods)
- ... _ (directive.lifted_generation
- ... (generation.save! true ["" name]
- ... [name
- ... (class.class version.v6_0
- ... (modifier#composite class.public inheritance)
- ... (name.internal name) (list#each (|>> product.left parser.name ..constraint) parameters)
- ... super interfaces
- ... (list#each ..field_definition fields)
- ... (list) ... TODO: Add methods
- ... sequence.empty)]))
- _ (directive.lifted_generation
- (generation.log! (format "JVM Class " name)))]
+ bytecode (<| (# ! each (format.result class.writer))
+ phase.lifted
+ (class.class version.v6_0
+ ($_ modifier#composite
+ class.public
+ inheritance)
+ (name.internal name)
+ {.#Some type_declaration}
+ (..class_name super)
+ (list#each ..class_name interfaces)
+ (list#each ..field_definition fields)
+ (list) ... (list#each ..method_definition methods)
+ sequence.empty))
+ _ (..save_class! name bytecode)]
(in directive.no_requirements)))]))
-(def: (method_declaration (^open "it[0]"))
+(def: (method_declaration (^open "/[0]"))
(-> (jvm.Method_Declaration Code) (Resource Method))
- (let [type (type.method [it#type_variables it#arguments it#return it#exceptions])]
+ (let [type (type.method [/#type_variables /#arguments /#return /#exceptions])]
(method.method ($_ modifier#composite
method.public
method.abstract)
- it#name
+ /#name
type
(list)
{.#None})))
@@ -542,17 +551,12 @@
(type.signature $Object)
(list#each type.signature supers))}
(name.internal "java.lang.Object")
- (list#each (|>> parser.read_class product.left name.internal)
- supers)
+ (list#each ..class_name supers)
(list)
(list#each ..method_declaration method_declarations)
sequence.empty))
- ... module generation.module
- ... module_id (generation.module_id module archive)
artifact_id (generation.learn_custom name artifact.no_dependencies)
- .let [artifact [name
- ... (runtime.class_name [module_id artifact_id])
- bytecode]]
+ .let [artifact [name bytecode]]
_ (generation.execute! artifact)
_ (generation.save! artifact_id {.#Some name} artifact)
_ (generation.log! (format "JVM Interface " (%.text name)))]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
index 74f526332..73c67165f 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
@@ -32,13 +32,12 @@
["[1][0]" bundle]
["[1][0]" analysis]
["/[1]" // "_"
- [analysis
- ["[0]A" module]]
["/[1]" // "_"
["[1][0]" analysis
[macro {"+" Expander}]
["[1]/[0]" evaluation]
- ["[0]A" type]]
+ ["[0]A" type]
+ ["[0]A" module]]
["[1][0]" synthesis {"+" Synthesis}]
["[1][0]" generation {"+" Context}]
["[1][0]" directive {"+" Import Requirements Phase Operation Handler Bundle}]
@@ -250,14 +249,14 @@
_
(phase.except ///.invalid_syntax [extension_name %.code inputsC+]))))
-(def: (announce_labels! tags owner)
+(def: (announce_labels! labels owner)
(All (_ anchor expression directive)
(-> (List Text) Type (Operation anchor expression directive (List Any))))
(/////directive.lifted_generation
(monad.each phase.monad
(function (_ tag)
(/////generation.log! (format tag " : Tag of " (%.type owner))))
- tags)))
+ labels)))
(def: (def::type_tagged expander host_analysis)
(-> Expander /////analysis.Bundle Handler)
@@ -290,7 +289,7 @@
(moduleA.define short_name {.#Type [exported? (:as .Type value) (if record?
{.#Right labels}
{.#Left labels})]}))
- _ (moduleA.declare_tags record? labels exported? (:as .Type value))]
+ _ (moduleA.declare_labels record? labels exported? (:as .Type value))]
(in labels)))
_ (..refresh expander host_analysis)
_ (..announce_definition! short_name type)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux
index bd7f69e16..10bf59a29 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux
@@ -23,4 +23,4 @@
(def: .public (constant name type)
(-> Text (Type Value) (Resource Field))
- (field.field ..modifier name type (sequence.sequence)))
+ (field.field ..modifier name type false (sequence.sequence)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
index b02bde225..cc22b43b9 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
@@ -46,7 +46,7 @@
(def: .public (variable name type)
(-> Text (Type Value) (Resource Field))
- (field.field ..modifier name type (sequence.sequence)))
+ (field.field ..modifier name type false (sequence.sequence)))
(def: .public (variables naming amount)
(-> (-> Register Text) Nat (List (Resource Field)))
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 00b7557af..0b14f240e 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
@@ -124,7 +124,7 @@
(encoding/name.internal bytecode_name)
{.#None}
(encoding/name.internal "java.lang.Object") (list)
- (list (field.field ..value::modifier ..value::field ..value::type (sequence.sequence)))
+ (list (field.field ..value::modifier ..value::field ..value::type false (sequence.sequence)))
(list (method.method ..init::modifier "<clinit>" ..init::type
(list)
{.#Some
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 57a446860..a812a0c31 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
@@ -560,7 +560,7 @@
right_projection::method
..try::method))
- (sequence.sequence)))]
+ sequence.empty))]
(do ////.monad
[_ (generation.execute! [class bytecode])
_ (generation.save! ..artifact_id {.#None} [class bytecode])]
@@ -608,8 +608,8 @@
partial_count (: (Resource Field)
(field.field (modifier#composite field.public field.final)
//function/count.field
- //function/count.type
- (sequence.sequence)))
+ //function/count.type .false
+ sequence.empty))
bytecode (<| (format.result class.writer)
try.trusted
(class.class jvm/version.v6_0
@@ -619,7 +619,7 @@
(name.internal (..reflection ^Object)) (list)
(list partial_count)
(list& <init>::method apply::method+)
- (sequence.sequence)))]
+ sequence.empty))]
(do ////.monad
[_ (generation.execute! [class bytecode])
... _ (generation.save! //function.artifact_id {.#None} [class bytecode])
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 294e31ecc..3d7854861 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux {"-" Module}
+ [lux "*"
[type {"+" :sharing}]
[abstract
["[0]" monad {"+" do}]]
@@ -32,8 +32,9 @@
[//
["[0]" archive {"+" Output}
[registry {"+" Registry}]
- ["[0]" descriptor {"+" Module Descriptor}]
["[0]" artifact]
+ ["[0]" module]
+ ["[0]" descriptor]
["[0]" document {"+" Document}]]
["[0]" cache "_"
["[1]/[0]" module {"+" Order}]
@@ -46,7 +47,7 @@
[generation {"+" Context}]]]]]])
(def: (bundle_module module module_id necessary_dependencies output)
- (-> Module archive.ID (Set Context) Output (Try (Maybe _.Statement)))
+ (-> descriptor.Module module.ID (Set Context) Output (Try (Maybe _.Statement)))
(do [! try.monad]
[]
(case (|> output
@@ -76,14 +77,14 @@
(in {.#Some bundle})))))
(def: module_file
- (-> archive.ID file.Path)
+ (-> module.ID file.Path)
(|>> %.nat (text.suffix ".rb")))
(def: (write_module mapping necessary_dependencies [module [module_id entry]] sink)
- (-> (Dictionary Module archive.ID) (Set Context)
- [Module [archive.ID [Descriptor (Document .Module) Output Registry]]]
- (List [archive.ID [Text Binary]])
- (Try (List [archive.ID [Text Binary]])))
+ (-> (Dictionary descriptor.Module module.ID) (Set Context)
+ [descriptor.Module [module.ID (archive.Entry .Module)]]
+ (List [module.ID [Text Binary]])
+ (Try (List [module.ID [Text Binary]])))
(do [! try.monad]
[bundle (: (Try (Maybe _.Statement))
(..bundle_module module module_id necessary_dependencies (value@ archive.#output entry)))]
@@ -104,13 +105,13 @@
"main.rb")
(def: module_id_mapping
- (-> (Order .Module) (Dictionary Module archive.ID))
+ (-> (Order .Module) (Dictionary descriptor.Module module.ID))
(|>> (list#each (function (_ [module [module_id entry]])
[module module_id]))
(dictionary.of_list text.hash)))
(def: included_modules
- (All (_ a) (-> (List [archive.ID a]) (Set archive.ID)))
+ (All (_ a) (-> (List [module.ID a]) (Set module.ID)))
(|>> (list#each product.left)
(list#mix set.has (set.empty nat.hash))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux
index 0f6007e75..e014c3403 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux
@@ -23,8 +23,9 @@
["[0]" // {"+" Packager}
[//
["[0]" archive {"+" Output}
- ["[0]" descriptor]
- ["[0]" artifact]]
+ ["[0]" artifact]
+ ["[0]" module]
+ ["[0]" descriptor]]
["[0]" cache "_"
["[1]/[0]" module]
["[1]/[0]" artifact]]
@@ -37,7 +38,7 @@
(def: (write_module necessary_dependencies sequence [module_id output] so_far)
(All (_ directive)
- (-> (Set Context) (-> directive directive directive) [archive.ID Output] directive
+ (-> (Set Context) (-> directive directive directive) [module.ID Output] directive
(Try directive)))
(|> output
sequence.list