aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/target/jvm/class.lux36
-rw-r--r--stdlib/source/lux/target/jvm/field.lux24
-rw-r--r--stdlib/source/lux/target/jvm/method.lux22
-rw-r--r--stdlib/source/lux/target/jvm/modifier.lux118
-rw-r--r--stdlib/source/lux/target/jvm/modifier/inner.lux20
5 files changed, 103 insertions, 117 deletions
diff --git a/stdlib/source/lux/target/jvm/class.lux b/stdlib/source/lux/target/jvm/class.lux
index 4677f33e4..0e95c7063 100644
--- a/stdlib/source/lux/target/jvm/class.lux
+++ b/stdlib/source/lux/target/jvm/class.lux
@@ -18,7 +18,7 @@
[abstract (#+)]]]
["." // #_
["#." encoding (#+)]
- ["#." modifier (#+ modifiers:)]
+ ["#." modifier (#+ Modifier modifiers:)]
["#." version (#+ Version Minor Major)]
["#." name (#+ Internal)]
["#." magic (#+ Magic)]
@@ -29,23 +29,12 @@
["#." constant (#+ Constant)
["#/." pool (#+ Pool)]]])
-(modifiers:
- ["0001" public]
- ["0010" final]
- ["0020" super]
- ["0200" interface]
- ["0400" abstract]
- ["1000" synthetic]
- ["2000" annotation]
- ["4000" enum]
- )
-
-(type: #export Class
+(type: #export #rec Class
{#magic Magic
#minor-version Minor
#major-version Major
#constant-pool Pool
- #modifier Modifier
+ #modifier (Modifier Class)
#this (Index //constant.Class)
#super (Index //constant.Class)
#interfaces (Row (Index //constant.Class))
@@ -53,6 +42,17 @@
#methods (Row Method)
#attributes (Row Attribute)})
+(modifiers: Class
+ ["0001" public]
+ ["0010" final]
+ ["0020" super]
+ ["0200" interface]
+ ["0400" abstract]
+ ["1000" synthetic]
+ ["2000" annotation]
+ ["4000" enum]
+ )
+
(def: #export equivalence
(Equivalence Class)
($_ equivalence.product
@@ -60,7 +60,7 @@
//encoding.u2-equivalence
//encoding.u2-equivalence
//constant/pool.equivalence
- ..modifier-equivalence
+ //modifier.equivalence
//index.equivalence
//index.equivalence
(row.equivalence //index.equivalence)
@@ -88,7 +88,7 @@
(def: #export (class version modifier
this super interfaces
fields methods attributes)
- (-> Major Modifier
+ (-> Major (Modifier Class)
Internal Internal (List Internal)
(List (State Pool Field))
(Row Method)
@@ -119,7 +119,7 @@
minor-version (get@ #binaryF.reader //version.format)
major-version (get@ #binaryF.reader //version.format)
constant-pool (get@ #binaryF.reader //constant/pool.format)
- modifier (get@ #binaryF.reader ..modifier-format)
+ modifier (get@ #binaryF.reader //modifier.format)
this (get@ #binaryF.reader //index.format)
super (get@ #binaryF.reader //index.format)
interfaces (get@ #binaryF.reader (binaryF.row/16 //index.format))
@@ -157,7 +157,7 @@
[//version.format #minor-version]
[//version.format #major-version]
[//constant/pool.format #constant-pool]
- [..modifier-format #modifier]
+ [//modifier.format #modifier]
[//index.format #this]
[//index.format #super]
[(binaryF.row/16 //index.format) #interfaces]))
diff --git a/stdlib/source/lux/target/jvm/field.lux b/stdlib/source/lux/target/jvm/field.lux
index 2e0082fe2..062b38ac6 100644
--- a/stdlib/source/lux/target/jvm/field.lux
+++ b/stdlib/source/lux/target/jvm/field.lux
@@ -18,14 +18,20 @@
[abstract (#+)]]]
["." // #_
[encoding (#+)]
- [modifier (#+ modifiers:)]
+ ["." modifier (#+ Modifier modifiers:)]
["#." constant (#+ UTF8)
["#/." pool (#+ Pool)]]
["#." index (#+ Index)]
["#." attribute (#+ Attribute)]
["#." descriptor (#+ Descriptor Value)]])
-(modifiers:
+(type: #export #rec Field
+ {#modifier (Modifier Field)
+ #name (Index UTF8)
+ #descriptor (Index (Descriptor (Value Any)))
+ #attributes (Row Attribute)})
+
+(modifiers: Field
["0001" public]
["0002" private]
["0004" protected]
@@ -37,16 +43,10 @@
["4000" enum]
)
-(type: #export Field
- {#modifier Modifier
- #name (Index UTF8)
- #descriptor (Index (Descriptor (Value Any)))
- #attributes (Row Attribute)})
-
(def: #export equivalence
(Equivalence Field)
($_ equivalence.product
- ..modifier-equivalence
+ modifier.equivalence
//index.equivalence
//index.equivalence
(row.equivalence //attribute.equivalence)))
@@ -54,7 +54,7 @@
(def: #export (reader pool)
(-> Pool (Reader Field))
($_ <>.and
- (get@ #binaryF.reader ..modifier-format)
+ (get@ #binaryF.reader modifier.format)
(get@ #binaryF.reader //index.format)
(get@ #binaryF.reader //index.format)
(get@ #binaryF.reader
@@ -72,14 +72,14 @@
(~~ (template [<format> <slot>]
[((get@ #binaryF.writer <format>) (get@ <slot> field))]
- [..modifier-format #modifier]
+ [modifier.format #modifier]
[//index.format #name]
[//index.format #descriptor]
[(binaryF.row/16 attribute-format) #attributes]))
))))
(def: #export (field modifier name descriptor attributes)
- (-> Modifier UTF8 (Descriptor (Value Any)) (Row Attribute)
+ (-> (Modifier Field) UTF8 (Descriptor (Value Any)) (Row Attribute)
(State Pool Field))
(do state.monad
[@name (//constant/pool.utf8 name)
diff --git a/stdlib/source/lux/target/jvm/method.lux b/stdlib/source/lux/target/jvm/method.lux
index 0141e0a2b..eb039d09b 100644
--- a/stdlib/source/lux/target/jvm/method.lux
+++ b/stdlib/source/lux/target/jvm/method.lux
@@ -18,14 +18,20 @@
[abstract (#+)]]]
["." // #_
[encoding (#+)]
- [modifier (#+ modifiers:)]
+ ["." modifier (#+ Modifier modifiers:)]
["#." constant (#+ UTF8)
[pool (#+ Pool)]]
["#." index (#+ Index)]
["#." attribute (#+ Attribute)]
["#." descriptor (#+ Descriptor)]])
-(modifiers:
+(type: #export #rec Method
+ {#modifier (Modifier Method)
+ #name (Index UTF8)
+ #descriptor (Index (Descriptor //descriptor.Method))
+ #attributes (Row Attribute)})
+
+(modifiers: Method
["0001" public]
["0002" private]
["0004" protected]
@@ -40,16 +46,10 @@
["1000" synthetic]
)
-(type: #export Method
- {#modifier Modifier
- #name (Index UTF8)
- #descriptor (Index (Descriptor //descriptor.Method))
- #attributes (Row Attribute)})
-
(def: #export equivalence
(Equivalence Method)
($_ equivalence.product
- ..modifier-equivalence
+ modifier.equivalence
//index.equivalence
//index.equivalence
(row.equivalence //attribute.equivalence)))
@@ -57,7 +57,7 @@
(def: #export (reader pool)
(-> Pool (Reader Method))
($_ <>.and
- (get@ #binaryF.reader ..modifier-format)
+ (get@ #binaryF.reader modifier.format)
(get@ #binaryF.reader //index.format)
(get@ #binaryF.reader //index.format)
(get@ #binaryF.reader
@@ -75,7 +75,7 @@
(~~ (template [<format> <slot>]
[((get@ #binaryF.writer <format>) (get@ <slot> field))]
- [..modifier-format #modifier]
+ [modifier.format #modifier]
[//index.format #name]
[//index.format #descriptor]
[(binaryF.row/16 attribute-format) #attributes]))
diff --git a/stdlib/source/lux/target/jvm/modifier.lux b/stdlib/source/lux/target/jvm/modifier.lux
index f858e6548..6790c5afe 100644
--- a/stdlib/source/lux/target/jvm/modifier.lux
+++ b/stdlib/source/lux/target/jvm/modifier.lux
@@ -1,84 +1,80 @@
(.module:
[lux #*
[abstract
- ["." equivalence]
- ["." monoid]]
+ ["." equivalence (#+ Equivalence)]
+ ["." monoid (#+ Monoid)]]
[control
- ["." parser
- ["s" code (#+ Parser)]]]
+ ["<>" parser
+ ["<c>" code (#+ Parser)]]]
[data
- ["." number
+ ["." number (#+ hex)
["." i64]]
[format
- ["." binary]]
+ [".F" binary (#+ Format)]]
[collection
- ["." list ("#;." functor)]]]
+ ["." list ("#@." functor)]]]
[type
- ["." abstract]]
+ abstract]
[macro (#+ with-gensyms)
- ["." code]
- [syntax (#+ syntax:)]]]
+ [syntax (#+ syntax:)]
+ ["." code]]]
["." // #_
["#." encoding]])
-(type: Modifier
- {#code Text
- #name Text})
+(abstract: #export (Modifier of)
+ {}
+ //encoding.U2
-(def: modifier
- (Parser Modifier)
- (s.tuple (parser.and s.text
- s.local-identifier)))
+ (template: (!wrap value)
+ (|> value
+ //encoding.to-u2
+ :abstraction))
-(def: (code modifier)
- (-> Modifier Code)
- (code.tuple (list (code.text (get@ #code modifier))
- (code.local-identifier (get@ #name modifier)))))
+ (template: (!unwrap value)
+ (|> value
+ :representation
+ //encoding.from-u2))
-(syntax: #export (modifiers: {options (parser.many ..modifier)})
- (with-gensyms [g!parameter g!subject g!<name> g!<code>]
- (let [g!name (' Modifier)
- g!combine (' combine)
- g!empty (' empty)
- g!format (' modifier-format)
- typeC (` (abstract.abstract: (~' #export) (~ g!name)
- {}
+ (def: #export code
+ (-> (Modifier Any) //encoding.U2)
+ (|>> :representation))
- //encoding.U2
+ (def: modifier
+ (-> Nat Modifier)
+ (|>> !wrap))
- (.def: (~' #export) (~' code)
- (.-> (~ g!name) //encoding.U2)
- (.|>> abstract.:representation))
+ (structure: #export equivalence
+ (All [of] (Equivalence (Modifier of)))
+ (def: (= reference sample)
+ (:: //encoding.u2-equivalence =
+ (:representation reference)
+ (:representation sample))))
- (.def: (~' #export) ((~ g!combine) (~ g!parameter) (~ g!subject))
- (.-> (~ g!name) (~ g!name) (~ g!name))
- (abstract.:abstraction (//encoding.to-u2 (i64.and (//encoding.from-u2 (abstract.:representation (~ g!parameter)))
- (//encoding.from-u2 (abstract.:representation (~ g!subject)))))))
+ (structure: #export monoid
+ (All [of] (Monoid (Modifier of)))
- (.template [(~ g!<code>) (~ g!<name>)]
- [(.def: (~' #export) (~ g!<name>)
- (~ g!name)
- (.|> ((~! number.hex) (~ g!<code>)) //encoding.to-u2 abstract.:abstraction))]
+ (def: identity
+ (!wrap (hex "0000")))
+
+ (def: (compose left right)
+ (!wrap (i64.and (!unwrap left) (!unwrap right)))))
- ["0000" (~ g!empty)]
- (~+ (list;map ..code options))
- )
+ (def: #export empty
+ Modifier
+ (:: ..monoid identity))
- (.structure: (~' #export) (~' modifier-equivalence) (equivalence.Equivalence (~ g!name))
- (.def: ((~' =) (~' reference) (~' sample))
- (.:: //encoding.u2-equivalence (~' =)
- (abstract.:representation (~' reference))
- (abstract.:representation (~' sample)))))
+ (def: #export format
+ (All [of] (Format (Modifier of)))
+ (let [(^open "_@.") //encoding.u2-format]
+ {#binaryF.reader (:: <>.functor map (|>> :abstraction) _@reader)
+ #binaryF.writer (|>> :representation _@writer)}))
+ )
- (.def: (~' #export) (~ g!format)
- (binary.Format (~ g!name))
- (.let [(.^open "_;.") //encoding.u2-format]
- {#binary.reader (|> (~' _;reader)
- (:: parser.functor (~' map)
- (|>> abstract.:abstraction)))
- #binary.writer (|>> abstract.:representation
- (~' _;writer))}))))
- monoidC (` (.structure: (~' #export) (~' modifier-monoid) (monoid.Monoid (~ g!name))
- (.def: (~' identity) (~ g!empty))
- (.def: (~' compose) (~ g!combine))))]
- (wrap (list typeC monoidC)))))
+(syntax: #export (modifiers: ofT {options (<>.many <c>.any)})
+ (with-gensyms [g!modifier g!code]
+ (wrap (list (` (template [(~ g!code) (~ g!modifier)]
+ [(def: (~' #export) (~ g!modifier)
+ (..Modifier (~ ofT))
+ ((~! ..modifier) ((~! number.hex) (~ g!code))))]
+
+ (~+ options)))))))
diff --git a/stdlib/source/lux/target/jvm/modifier/inner.lux b/stdlib/source/lux/target/jvm/modifier/inner.lux
index 2980ef6e4..eec9221fb 100644
--- a/stdlib/source/lux/target/jvm/modifier/inner.lux
+++ b/stdlib/source/lux/target/jvm/modifier/inner.lux
@@ -1,22 +1,12 @@
(.module:
[lux (#- static)
- [abstract
- [equivalence (#+)]
- [monoid (#+)]]
- [control
- [parser (#+)]]
- [data
- [number (#+)
- [i64 (#+)]]
- [format
- [binary (#+)]]]
[type
- [abstract (#+)]]]
- [// (#+ modifiers:)
- [//
- [encoding (#+)]]])
+ abstract]]
+ [// (#+ modifiers:)])
-(modifiers:
+(abstract: #export Inner {} Any)
+
+(modifiers: Inner
["0001" public]
["0002" private]
["0004" protected]