aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2018-12-26 21:07:14 -0400
committerEduardo Julian2018-12-26 21:07:14 -0400
commit8fad159619c38771a423f573c59a67e2f1c0f0fa (patch)
tree51af3fce461306b3ad634a882f17e3162bbe98fa /stdlib
parent93758baa5f3f981112d607f2eb78cf6e849aaa56 (diff)
Expanded the set of available modifiers.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/host/jvm.lux9
-rw-r--r--stdlib/source/lux/host/jvm/access.lux57
-rw-r--r--stdlib/source/lux/host/jvm/modifier.lux74
-rw-r--r--stdlib/source/lux/host/jvm/modifier/class.lux26
-rw-r--r--stdlib/source/lux/host/jvm/modifier/field.lux27
-rw-r--r--stdlib/source/lux/host/jvm/modifier/inner.lux28
-rw-r--r--stdlib/source/lux/host/jvm/modifier/method.lux30
7 files changed, 190 insertions, 61 deletions
diff --git a/stdlib/source/lux/host/jvm.lux b/stdlib/source/lux/host/jvm.lux
index 7e63fd027..388c5cb04 100644
--- a/stdlib/source/lux/host/jvm.lux
+++ b/stdlib/source/lux/host/jvm.lux
@@ -9,7 +9,8 @@
[/
["/." version (#+ Version Minor Major)]
["/." name (#+ Name)]
- ["/." access (#+ Access)]
+ [modifier
+ ["/.M" class]]
["/." magic (#+ Magic)]
["/." constant (#+ Constant)]
["/." index (#+ Index)]])
@@ -33,7 +34,7 @@
#minor-version Minor
#major-version Major
#constant-pool Pool
- #access-flags Access
+ #access-flags /classM.Modifier
#this Index
#super Index
#interfaces (Row Interface)
@@ -44,7 +45,7 @@
(def: default-minor-version Minor (/version.version 0))
(def: #export (class version access super this interfaces)
- (-> Major Access Name Name (List Name) Class)
+ (-> Major /classM.Modifier Name Name (List Name) Class)
(let [with-classes (: (-> Pool Pool)
(|>> (row.add (#/constant.UTF8 (/name.read this)))
(row.add (#/constant.Class (/index.index 1)))
@@ -86,7 +87,7 @@
/version.format
/version.format
(binary.row/16' 1 /constant.format)
- /access.format
+ /classM.format
/index.format
/index.format
(binary.row/16 /index.format)
diff --git a/stdlib/source/lux/host/jvm/access.lux b/stdlib/source/lux/host/jvm/access.lux
deleted file mode 100644
index f0d088a97..000000000
--- a/stdlib/source/lux/host/jvm/access.lux
+++ /dev/null
@@ -1,57 +0,0 @@
-(.module:
- [lux #*
- [control
- [monoid (#+ Monoid)]
- [parser ("parser/." Functor<Parser>)]]
- [data
- [number (#+ hex)
- ["." i64]]
- [format
- ["." binary (#+ Format)]]]
- [type
- abstract]]
- [//
- ["//." encoding (#+ U2)]])
-
-(abstract: #export Access
- {}
-
- U2
-
- (def: #export code
- (-> Access U2)
- (|>> :representation))
-
- (def: #export (combine parameter subject)
- (-> Access Access Access)
- (let [parameter' (//encoding.from-u2 (:representation parameter))
- subject' (//encoding.from-u2 (:representation subject))]
- (:abstraction (//encoding.to-u2 (i64.and parameter'
- subject')))))
-
- (do-template [<name> <code>]
- [(def: #export <name>
- Access
- (|> (hex <code>) //encoding.to-u2 :abstraction))]
-
- [empty "0000"]
- [public "0001"]
- [final "0010"]
- [super "0020"]
- [interface "0200"]
- [abstract "0400"]
- [synthetic "1000"]
- [annotation "2000"]
- [enum "4000"]
- )
-
- (def: #export format
- (Format Access)
- (let [(^open "_/.") //encoding.u2-format]
- {#binary.reader (|> _/reader (parser/map (|>> :abstraction)))
- #binary.writer (|>> :representation _/writer)}))
- )
-
-(structure: #export _ (Monoid Access)
- (def: identity ..empty)
- (def: compose ..combine))
diff --git a/stdlib/source/lux/host/jvm/modifier.lux b/stdlib/source/lux/host/jvm/modifier.lux
new file mode 100644
index 000000000..5c9280164
--- /dev/null
+++ b/stdlib/source/lux/host/jvm/modifier.lux
@@ -0,0 +1,74 @@
+(.module:
+ [lux #*
+ [control
+ ["." monoid]
+ ["." parser]]
+ [data
+ ["." number
+ ["." i64]]
+ [format
+ ["." binary]]
+ [collection
+ [list ("list/." Functor<List>)]]]
+ [type
+ ["." abstract]]
+ [macro (#+ with-gensyms)
+ ["." code]
+ ["s" syntax (#+ Syntax syntax:)]]]
+ [//
+ ["//." encoding]])
+
+(type: Modifier
+ {#code Text
+ #name Text})
+
+(def: modifier
+ (Syntax Modifier)
+ (s.tuple (parser.and s.text
+ s.local-identifier)))
+
+(def: (code modifier)
+ (-> Modifier Code)
+ (code.tuple (list (code.text (get@ #code modifier))
+ (code.local-identifier (get@ #name modifier)))))
+
+(syntax: #export (modifiers: {options (parser.many ..modifier)})
+ (with-gensyms [g!parameter g!subject g!<name> g!<code>]
+ (let [nameC (' Modifier)
+ combineC (' combine)
+ emptyC (' empty)
+ typeC (` (abstract.abstract: (~' #export) (~ nameC)
+ {}
+
+ //encoding.U2
+
+ (.def: (~' #export) (~' code)
+ (.-> (~ nameC) //encoding.U2)
+ (.|>> (~' :representation)))
+
+ (.def: (~' #export) ((~ combineC) (~ g!parameter) (~ g!subject))
+ (.-> (~ nameC) (~ nameC) (~ nameC))
+ ((~' :abstraction) (//encoding.to-u2 (i64.and (//encoding.from-u2 ((~' :representation) (~ g!parameter)))
+ (//encoding.from-u2 ((~' :representation) (~ g!subject)))))))
+
+ (.do-template [(~ g!<code>) (~ g!<name>)]
+ [(.def: (~' #export) (~ g!<name>)
+ (~ nameC)
+ (.|> (number.hex (~ g!<code>)) //encoding.to-u2 (~' :abstraction)))]
+
+ ["0000" (~ emptyC)]
+ (~+ (list/map ..code options))
+ )
+
+ (.def: (~' #export) (~' format)
+ (binary.Format (~ nameC))
+ (.let [(.^open "_/.") //encoding.u2-format]
+ {#binary.reader (|> (~' _/reader)
+ (:: parser.Functor<Parser> (~' map)
+ (|>> (~' :abstraction))))
+ #binary.writer (|>> (~' :representation)
+ (~' _/writer))}))))
+ monoidC (` (.structure: (~' #export) (~' _) (monoid.Monoid (~ nameC))
+ (.def: (~' identity) (~ emptyC))
+ (.def: (~' compose) (~ combineC))))]
+ (wrap (list typeC monoidC)))))
diff --git a/stdlib/source/lux/host/jvm/modifier/class.lux b/stdlib/source/lux/host/jvm/modifier/class.lux
new file mode 100644
index 000000000..e9da25b4a
--- /dev/null
+++ b/stdlib/source/lux/host/jvm/modifier/class.lux
@@ -0,0 +1,26 @@
+(.module:
+ [lux #*
+ [control
+ [monoid (#+)]
+ [parser (#+)]]
+ [data
+ [number (#+)
+ [i64 (#+)]]
+ [format
+ [binary (#+)]]]
+ [type
+ [abstract (#+)]]]
+ [// (#+ modifiers:)
+ [//
+ [encoding (#+)]]])
+
+(modifiers:
+ ["0001" public]
+ ["0010" final]
+ ["0020" super]
+ ["0200" interface]
+ ["0400" abstract]
+ ["1000" synthetic]
+ ["2000" annotation]
+ ["4000" enum]
+ )
diff --git a/stdlib/source/lux/host/jvm/modifier/field.lux b/stdlib/source/lux/host/jvm/modifier/field.lux
new file mode 100644
index 000000000..6099bc62e
--- /dev/null
+++ b/stdlib/source/lux/host/jvm/modifier/field.lux
@@ -0,0 +1,27 @@
+(.module:
+ [lux (#- static)
+ [control
+ [monoid (#+)]
+ [parser (#+)]]
+ [data
+ [number (#+)
+ [i64 (#+)]]
+ [format
+ [binary (#+)]]]
+ [type
+ [abstract (#+)]]]
+ [// (#+ modifiers:)
+ [//
+ [encoding (#+)]]])
+
+(modifiers:
+ ["0001" public]
+ ["0002" private]
+ ["0004" protected]
+ ["0008" static]
+ ["0010" final]
+ ["0040" volatile]
+ ["0080" transient]
+ ["1000" synthetic]
+ ["4000" enum]
+ )
diff --git a/stdlib/source/lux/host/jvm/modifier/inner.lux b/stdlib/source/lux/host/jvm/modifier/inner.lux
new file mode 100644
index 000000000..3b33ed477
--- /dev/null
+++ b/stdlib/source/lux/host/jvm/modifier/inner.lux
@@ -0,0 +1,28 @@
+(.module:
+ [lux (#- static)
+ [control
+ [monoid (#+)]
+ [parser (#+)]]
+ [data
+ [number (#+)
+ [i64 (#+)]]
+ [format
+ [binary (#+)]]]
+ [type
+ [abstract (#+)]]]
+ [// (#+ modifiers:)
+ [//
+ [encoding (#+)]]])
+
+(modifiers:
+ ["0001" public]
+ ["0002" private]
+ ["0004" protected]
+ ["0008" static]
+ ["0010" final]
+ ["0200" interface]
+ ["0400" abstract]
+ ["1000" synthetic]
+ ["2000" annotation]
+ ["4000" enum]
+ )
diff --git a/stdlib/source/lux/host/jvm/modifier/method.lux b/stdlib/source/lux/host/jvm/modifier/method.lux
new file mode 100644
index 000000000..e15a971ae
--- /dev/null
+++ b/stdlib/source/lux/host/jvm/modifier/method.lux
@@ -0,0 +1,30 @@
+(.module:
+ [lux (#- static)
+ [control
+ [monoid (#+)]
+ [parser (#+)]]
+ [data
+ [number (#+)
+ [i64 (#+)]]
+ [format
+ [binary (#+)]]]
+ [type
+ [abstract (#+)]]]
+ [// (#+ modifiers:)
+ [//
+ [encoding (#+)]]])
+
+(modifiers:
+ ["0001" public]
+ ["0002" private]
+ ["0004" protected]
+ ["0008" static]
+ ["0010" final]
+ ["0020" synchronized]
+ ["0040" bridge]
+ ["0080" var-args]
+ ["0100" native]
+ ["0400" abstract]
+ ["0800" strict]
+ ["1000" synthetic]
+ )