aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lux/analyser/host.clj6
-rw-r--r--src/lux/analyser/parser.clj24
-rw-r--r--src/lux/base.clj7
-rw-r--r--src/lux/compiler/host.clj14
-rw-r--r--src/lux/host.clj11
5 files changed, 60 insertions, 2 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 80b627ec9..6df324c1d 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -642,6 +642,9 @@
(&&/analyse-1 analyse output-type ?body)
(&/|reverse ?inputs)))]
(return (&/V &/$StaticMethodAnalysis (&/T [?name =privacy-modifier ?anns ?gvars ?exceptions ?inputs ?output =body]))))
+
+ (&/$AbstractMethodSyntax ?name ?anns ?gvars ?exceptions ?inputs ?output)
+ (return (&/V &/$AbstractMethodAnalysis (&/T [?name ?anns ?gvars ?exceptions ?inputs ?output])))
)))
(defn ^:private mandatory-methods [supers]
@@ -664,6 +667,9 @@
(&/$StaticMethodAnalysis _)
mmap
+
+ (&/$AbstractMethodSyntax _)
+ mmap
))
{}
methods)
diff --git a/src/lux/analyser/parser.clj b/src/lux/analyser/parser.clj
index 28b8d93c6..8f142f86b 100644
--- a/src/lux/analyser/parser.clj
+++ b/src/lux/analyser/parser.clj
@@ -182,6 +182,9 @@
[_ (&/$TextS "default")]
(return (&/V &/$DefaultIM &/unit-tag))
+ [_ (&/$TextS "abstract")]
+ (return (&/V &/$AbstractIM &/unit-tag))
+
[_ (&/$TextS "final")]
(return (&/V &/$FinalIM &/unit-tag))
@@ -277,11 +280,32 @@
_
(fail "")))
+(defn ^:private parse-method-abstract-def [ast]
+ (|case ast
+ [_ (&/$FormS (&/$Cons [_ (&/$TextS "abstract")]
+ (&/$Cons [_ (&/$TextS ?name)]
+ (&/$Cons [_ (&/$TupleS anns)]
+ (&/$Cons [_ (&/$TupleS gvars)]
+ (&/$Cons [_ (&/$TupleS exceptions)]
+ (&/$Cons [_ (&/$TupleS inputs)]
+ (&/$Cons output
+ (&/$Nil)))))))))]
+ (|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 (&/V &/$AbstractMethodSyntax (&/T [?name =anns =gvars =exceptions =inputs =output]))))
+
+ _
+ (fail "")))
+
(defn parse-method-def [ast]
(&/try-all% (&/|list #((parse-method-init-def ast) %)
#((parse-method-virtual-def ast) %)
#((parse-method-override-def ast) %)
#((parse-method-static-def ast) %)
+ #((parse-method-abstract-def ast) %)
(fn [state]
(fail* (str "[Analyser Error] Invalid method definition: " (&/show-ast ast)))))))
diff --git a/src/lux/base.clj b/src/lux/base.clj
index bbd610b5c..e3d0a049e 100644
--- a/src/lux/base.clj
+++ b/src/lux/base.clj
@@ -125,6 +125,7 @@
;; Inheritance Modifiers
(deftags
["DefaultIM"
+ "AbstractIM"
"FinalIM"])
;; Methods
@@ -132,13 +133,15 @@
["ConstructorMethodSyntax"
"VirtualMethodSyntax"
"OverridenMethodSyntax"
- "StaticMethodSyntax"])
+ "StaticMethodSyntax"
+ "AbstractMethodSyntax"])
(deftags
["ConstructorMethodAnalysis"
"VirtualMethodAnalysis"
"OverridenMethodAnalysis"
- "StaticMethodAnalysis"])
+ "StaticMethodAnalysis"
+ "AbstractMethodAnalysis"])
;; Meta-data
(deftags
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index b7f5c8679..6cfc87864 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -582,6 +582,20 @@
(.visitMaxs 0 0)
(.visitEnd))]]
(return nil))))
+
+ (&/$AbstractMethodSyntax ?name ?anns ?gvars ?exceptions ?inputs ?output)
+ (|let [=method-decl (&/T [?name ?anns ?gvars ?exceptions (&/|map &/|second ?inputs) ?output])
+ [simple-signature generic-signature] (&host-generics/method-signatures =method-decl)]
+ (&/with-writer (.visitMethod class-writer
+ (+ Opcodes/ACC_PUBLIC Opcodes/ACC_ABSTRACT)
+ ?name
+ simple-signature
+ generic-signature
+ (->> ?exceptions (&/|map &host-generics/->bytecode-class-name) &/->seq (into-array java.lang.String)))
+ (|do [^MethodVisitor =method &/get-writer
+ :let [_ (&/|map (partial compile-annotation =method) ?anns)
+ _ (.visitEnd =method)]]
+ (return nil))))
))
(defn ^:private compile-method-decl [^ClassWriter class-writer =method-decl]
diff --git a/src/lux/host.clj b/src/lux/host.clj
index 241a975ea..abcd830c8 100644
--- a/src/lux/host.clj
+++ b/src/lux/host.clj
@@ -327,6 +327,16 @@
(.visitMaxs 0 0)
(.visitEnd)))
+ (&/$AbstractMethodSyntax =name =anns =gvars =exceptions =inputs =output)
+ (|let [method-decl [=name =anns =gvars =exceptions (&/|map &/|second =inputs) =output]
+ [simple-signature generic-signature] (&host-generics/method-signatures method-decl)]
+ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_ABSTRACT)
+ =name
+ simple-signature
+ generic-signature
+ (->> =exceptions (&/|map &host-generics/gclass->bytecode-class-name) &/->seq (into-array java.lang.String)))
+ (.visitEnd)))
+
_
(assert false (println-str 'compile-dummy-method (&/adt->text method-def)))
))
@@ -351,6 +361,7 @@
"(-> InheritanceModifier Int)"
(|case inheritance-modifier
(&/$DefaultIM) 0
+ (&/$AbstractIM) Opcodes/ACC_ABSTRACT
(&/$FinalIM) Opcodes/ACC_FINAL))
(defn use-dummy-class [class-decl super-class interfaces ctor-args fields methods]