aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Julian2015-12-06 19:35:11 -0400
committerEduardo Julian2015-12-06 19:35:11 -0400
commitf317f31851f784b8846ec182377b9fd1ad3f0659 (patch)
tree3f31e6eb121221a34e61293d202e61d5129cbb5b /src
parent31b986e80335bf262997b97e3d22486a7b91cc4b (diff)
- Removed modifiers from field/method declaration.
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/host.clj19
-rw-r--r--src/lux/analyser/parser.clj66
-rw-r--r--src/lux/compiler/host.clj13
-rw-r--r--src/lux/host.clj26
-rw-r--r--src/lux/host/generics.clj2
5 files changed, 31 insertions, 95 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index a119ba981..44ebc8d1d 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -528,7 +528,7 @@
(|do [:let [[?cname ?cparams] class-decl
class-type (&/V &/$GenericClass (&/T ?cname &/Nil$))
[?decl ?body] method
- [_ _ _ ?gvars ?exs ?inputs ?output] ?decl
+ [_ _ ?gvars ?exs ?inputs ?output] ?decl
all-gvars (&/|++ ?cparams ?gvars)]
gvar-env (&/map% (fn [gvar]
(|do [ex &type/existential]
@@ -554,7 +554,7 @@
(|do [abstract-methods (mandatory-methods supers)
:let [methods-map (&/fold (fn [mmap mentry]
(prn 'methods-map (count mentry) mentry)
- (|let [[[=name =modifiers =anns =gvars =exceptions =inputs =output] _] mentry]
+ (|let [[[=name =anns =gvars =exceptions =inputs =output] _] mentry]
(assoc mmap =name mentry)))
{}
methods)
@@ -562,7 +562,7 @@
(|let [[am-name am-inputs] abs-meth]
(or missing
(if-let [meth-struct (get methods-map am-name)]
- (|let [[[=name =modifiers =anns =gvars =exceptions =inputs =output] _] meth-struct]
+ (|let [[[=name =anns =gvars =exceptions =inputs =output] _] meth-struct]
(if (and (= (&/|length =inputs) (&/|length am-inputs))
(&/fold2 (fn [prev mi ai]
(|let [[iname itype] mi]
@@ -604,17 +604,7 @@
[name [_ (&&/$captured _ _ source)]]
source))
-(let [captured-slot-modifier {:visibility "private"
- :static? false
- :final? false
- :abstract? false
- :concurrency nil}
- default-<init> (&/T "<init>"
- {:visibility "public"
- :static? false
- :final? false
- :abstract? false
- :concurrency nil}
+(let [default-<init> (&/T "<init>"
(&/|list)
(&/|list)
(&/|list)
@@ -645,7 +635,6 @@
=captured &&env/captured-vars
:let [=fields (&/|map (fn [^objects idx+capt]
(&/T (str &c!base/closure-prefix (aget idx+capt 0))
- captured-slot-modifier
(&/|list)
captured-slot-type))
(&/enumerate =captured))]
diff --git a/src/lux/analyser/parser.clj b/src/lux/analyser/parser.clj
index 3625db30c..074b032ee 100644
--- a/src/lux/analyser/parser.clj
+++ b/src/lux/analyser/parser.clj
@@ -85,42 +85,6 @@
_
(fail (str "[Analyser Error] Wrong syntax for exception handler: " (&/show-ast token)))))
-(defn parse-modifiers [modifiers]
- (&/fold% (fn [so-far modif]
- (|case modif
- [_ (&/$TextS "public")]
- (return (assoc so-far :visibility "public"))
-
- [_ (&/$TextS "private")]
- (return (assoc so-far :visibility "private"))
-
- [_ (&/$TextS "protected")]
- (return (assoc so-far :visibility "protected"))
-
- [_ (&/$TextS "static")]
- (return (assoc so-far :static? true))
-
- [_ (&/$TextS "final")]
- (return (assoc so-far :final? true))
-
- [_ (&/$TextS "abstract")]
- (return (assoc so-far :abstract? true))
-
- [_ (&/$TextS "synchronized")]
- (return (assoc so-far :concurrency "synchronized"))
-
- [_ (&/$TextS "volatile")]
- (return (assoc so-far :concurrency "volatile"))
-
- _
- (fail (str "[Analyser Error] Unknown modifier: " (&/show-ast modif)))))
- {:visibility "default"
- :static? false
- :final? false
- :abstract? false
- :concurrency nil}
- modifiers))
-
(let [failure (fail (str "[Analyser Error] Invalid annotation parameter."))]
(defn ^:private parse-ann-param [param]
(|case param
@@ -162,20 +126,18 @@
(defn ^:private parse-method-decl* [asts]
(|case asts
(&/$Cons [_ (&/$TextS method-name)]
- (&/$Cons [_ (&/$TupleS modifiers)]
- (&/$Cons [_ (&/$TupleS anns)]
- (&/$Cons [_ (&/$TupleS gvars)]
- (&/$Cons [_ (&/$TupleS exceptions)]
- (&/$Cons [_ (&/$TupleS inputs)]
- (&/$Cons output
- *tail*)))))))
- (|do [=modifiers (parse-modifiers modifiers)
- =anns (&/map% parse-ann anns)
+ (&/$Cons [_ (&/$TupleS anns)]
+ (&/$Cons [_ (&/$TupleS gvars)]
+ (&/$Cons [_ (&/$TupleS exceptions)]
+ (&/$Cons [_ (&/$TupleS inputs)]
+ (&/$Cons output
+ *tail*))))))
+ (|do [=anns (&/map% parse-ann anns)
=gvars (&/map% parse-text gvars)
=exceptions (&/map% parse-gclass exceptions)
=inputs (&/map% parse-arg-decl inputs)
=output (parse-gclass output)]
- (return (&/T (&/T method-name =modifiers =anns =gvars =exceptions =inputs =output)
+ (return (&/T (&/T method-name =anns =gvars =exceptions =inputs =output)
*tail*)))
_
@@ -212,14 +174,12 @@
(defn parse-field [ast]
(|case ast
[_ (&/$FormS (&/$Cons [_ (&/$TextS ?name)]
- (&/$Cons [_ (&/$TupleS ?modifiers)]
- (&/$Cons [_ (&/$TupleS ?anns)]
- (&/$Cons [_ (&/$TextS ?type)]
- (&/$Nil))))))]
- (|do [=modifiers (parse-modifiers ?modifiers)
- =anns (&/map% parse-ann ?anns)
+ (&/$Cons [_ (&/$TupleS ?anns)]
+ (&/$Cons [_ (&/$TextS ?type)]
+ (&/$Nil)))))]
+ (|do [=anns (&/map% parse-ann ?anns)
=type (parse-gclass ?type)]
- (return (&/T ?name =modifiers =anns =type)))
+ (return (&/T ?name =anns =type)))
_
(fail (str "[Analyser Error] Invalid field declaration: " (&/show-ast ast)))))
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index ea12ecc96..4b76f003e 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -424,8 +424,8 @@
nil)
(defn ^:private compile-field [^ClassWriter writer field]
- (|let [[=name =modifiers =anns =type] field
- =field (.visitField writer (&host/modifiers->int =modifiers) =name
+ (|let [[=name =anns =type] field
+ =field (.visitField writer Opcodes/ACC_PUBLIC =name
(&host-generics/->type-signature =type) nil nil)]
(do (&/|map (partial compile-annotation =field) =anns)
(.visitEnd =field)
@@ -463,9 +463,10 @@
(defn ^:private compile-method-def [compile ^ClassWriter class-writer method-def]
(|let [[=method-decl =body] method-def
- [=name =modifiers =anns =gvars =exceptions =inputs =output] =method-decl
+ [=name =anns =gvars =exceptions =inputs =output] =method-decl
[simple-signature generic-signature] (&host-generics/method-signatures =method-decl)]
- (&/with-writer (.visitMethod class-writer (&host/modifiers->int =modifiers)
+ (&/with-writer (.visitMethod class-writer
+ Opcodes/ACC_PUBLIC
=name
simple-signature
generic-signature
@@ -481,10 +482,10 @@
(return nil)))))
(defn ^:private compile-method-decl [^ClassWriter class-writer =method-decl]
- (|let [[=name =modifiers =anns =gvars =exceptions =inputs =output] =method-decl
+ (|let [[=name =anns =gvars =exceptions =inputs =output] =method-decl
[simple-signature generic-signature] (&host-generics/method-signatures =method-decl)
=method (.visitMethod class-writer
- (&host/modifiers->int =modifiers)
+ (+ Opcodes/ACC_PUBLIC Opcodes/ACC_ABSTRACT)
=name
simple-signature
generic-signature
diff --git a/src/lux/host.clj b/src/lux/host.clj
index 5807d711a..2f0a1829c 100644
--- a/src/lux/host.clj
+++ b/src/lux/host.clj
@@ -12,7 +12,8 @@
[type :as &type])
[lux.type.host :as &host-type]
[lux.host.generics :as &host-generics])
- (:import (java.lang.reflect Field Method Constructor Modifier Type)
+ (:import (java.lang.reflect Field Method Constructor Modifier Type
+ GenericArrayType ParameterizedType TypeVariable)
(org.objectweb.asm Opcodes
Label
ClassWriter
@@ -155,21 +156,6 @@
(defn location [scope]
(->> scope (&/|map &/normalize-name) (&/|interpose "$") (&/fold str "")))
-(defn modifiers->int [mods]
- (+ (case (:visibility mods)
- "default" 0
- "public" Opcodes/ACC_PUBLIC
- "private" Opcodes/ACC_PRIVATE
- "protected" Opcodes/ACC_PROTECTED)
- (if (:static? mods) Opcodes/ACC_STATIC 0)
- (if (:final? mods) Opcodes/ACC_FINAL 0)
- (if (:abstract? mods) Opcodes/ACC_ABSTRACT 0)
- (case (:concurrency mods)
- "synchronized" Opcodes/ACC_SYNCHRONIZED
- "volatile" Opcodes/ACC_VOLATILE
- ;; else
- 0)))
-
(defn primitive-jvm-type? [type]
(case type
("boolean" "byte" "short" "int" "long" "float" "double" "char")
@@ -256,16 +242,16 @@
(&host-generics/->bytecode-class-name (&host-generics/super-class-name super-class))
(->> interfaces (&/|map (comp &host-generics/->bytecode-class-name &host-generics/super-class-name)) &/->seq (into-array String))))
_ (&/|map (fn [field]
- (|let [[=name =modifiers =anns =type] field]
- (doto (.visitField =class (modifiers->int =modifiers) =name
+ (|let [[=name =anns =type] field]
+ (doto (.visitField =class Opcodes/ACC_PUBLIC =name
(&host-generics/->type-signature =type) nil nil)
(.visitEnd))))
fields)
_ (&/|map (fn [method-decl]
(prn 'use-dummy-class (count method-decl) method-decl)
- (|let [[=name =modifiers =anns =gvars =exceptions =inputs =output] method-decl
+ (|let [[=name =anns =gvars =exceptions =inputs =output] method-decl
[simple-signature generic-signature] (&host-generics/method-signatures method-decl)]
- (doto (.visitMethod =class (modifiers->int =modifiers)
+ (doto (.visitMethod =class Opcodes/ACC_PUBLIC
=name
simple-signature
generic-signature
diff --git a/src/lux/host/generics.clj b/src/lux/host/generics.clj
index 4fd2c3269..79b28b2ef 100644
--- a/src/lux/host/generics.clj
+++ b/src/lux/host/generics.clj
@@ -102,7 +102,7 @@
(assert false "gclass->bytecode-class-name doesn't work on arrays."))))
(defn method-signatures [method-decl]
- (|let [[=name =modifiers =anns =gvars =exceptions =inputs =output] method-decl
+ (|let [[=name =anns =gvars =exceptions =inputs =output] method-decl
simple-signature (str "(" (&/fold str "" (&/|map (comp gclass->simple-signature &/|second) =inputs)) ")" (gclass->simple-signature =output))
generic-signature (str "<" (->> =gvars (&/|interpose " ") (&/fold str "")) ">"
"(" (&/fold str "" (&/|map (comp gclass->signature &/|second) =inputs)) ")"