aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Julian2015-03-10 02:09:03 -0400
committerEduardo Julian2015-03-10 02:09:03 -0400
commit8e82cb7ab2276c5622af30cf43527aa79c8d36e5 (patch)
tree338913e89848f209ed000138bbf439279a3843c4 /src
parente2fcc7ebbb1f423a3137aa5525b9409f870fe191 (diff)
- Added null values as jvm-null.
Diffstat (limited to '')
-rw-r--r--src/lux.clj10
-rw-r--r--src/lux/analyser.clj3
-rw-r--r--src/lux/base.clj3
-rw-r--r--src/lux/compiler.clj3
-rw-r--r--src/lux/compiler/host.clj5
5 files changed, 20 insertions, 4 deletions
diff --git a/src/lux.clj b/src/lux.clj
index 5b56f9244..a8bdd4f31 100644
--- a/src/lux.clj
+++ b/src/lux.clj
@@ -10,10 +10,14 @@
;; TODO: Allow setting fields.
;; TODO: monitor enter & monitor exit.
;; TODO: Add column & line numbers for syntactic elements.
+ ;; TODO: Add source-file information to .class files for easier debugging.
+ ;; TODO: Add conversions between primitives
+ ;; TODO: Being able to ask if a value is null or not. (null?)
+ ;; TODO: invokespecial & invokeinterface
+ ;; TODO: bitwise operators
+ ;; TODO: multianewarray
;; TODO:
- ;; TODO:
- ;; TODO:
-
+
(time (&compiler/compile-all ["lux"]))
(time (&compiler/compile-all ["lux" "test2"]))
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj
index 6ea706814..ad21eadd1 100644
--- a/src/lux/analyser.clj
+++ b/src/lux/analyser.clj
@@ -44,6 +44,9 @@
(return (list [::&&/Expression [::&&/variant ?tag [::&&/Expression [::&&/tuple (list)] tuple-type]]
[::&type/Variant (list [?tag tuple-type])]])))
+ [["Ident" "jvm-null"]]
+ (return (list [::&&/Expression [::&&/jvm-null] [::&type/Data "null"]]))
+
[["Ident" ?ident]]
(&&lux/analyse-ident analyse-ast ?ident)
diff --git a/src/lux/base.clj b/src/lux/base.clj
index 689cf205f..aa39d591b 100644
--- a/src/lux/base.clj
+++ b/src/lux/base.clj
@@ -1,6 +1,7 @@
(ns lux.base
(:require (clojure [template :refer [do-template]])
- [clojure.core.match :as M :refer [match matchv]]))
+ [clojure.core.match :as M :refer [match matchv]]
+ clojure.core.match.array))
;; [Resources]
;; [Resources/Contants]
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index cef1cb710..2fa180aea 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -184,6 +184,9 @@
[::&a/exec ?exprs]
(&&host/compile-exec compile-expression ?type ?exprs)
+ [::&a/jvm-null]
+ (&&host/compile-jvm-null compile-expression ?type)
+
[::&a/jvm-new ?class ?classes ?args]
(&&host/compile-jvm-new compile-expression ?type ?class ?classes ?args)
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index f50ab719f..9805d2c70 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -199,6 +199,11 @@
(prepare-return! *type*))]]
(return nil)))
+(defn compile-jvm-null [compile *type*]
+ (exec [*writer* &/get-writer
+ :let [_ (.visitInsn *writer* Opcodes/ACONST_NULL)]]
+ (return nil)))
+
(defn compile-jvm-new [compile *type* ?class ?classes ?args]
(exec [*writer* &/get-writer
:let [init-sig (str "(" (reduce str "" (map &host/->type-signature ?classes)) ")V")