diff options
Diffstat (limited to '')
-rw-r--r-- | source/lux.lux | 2 | ||||
-rw-r--r-- | src/lux.clj | 10 | ||||
-rw-r--r-- | src/lux/analyser.clj | 3 | ||||
-rw-r--r-- | src/lux/base.clj | 3 | ||||
-rw-r--r-- | src/lux/compiler.clj | 3 | ||||
-rw-r--r-- | src/lux/compiler/host.clj | 5 |
6 files changed, 22 insertions, 4 deletions
diff --git a/source/lux.lux b/source/lux.lux index 76ea2dc4c..994fcd8cd 100644 --- a/source/lux.lux +++ b/source/lux.lux @@ -739,6 +739,8 @@ (#Lambda [f-arg f-return])) f-return f-args))) +(def null jvm-null) + ## (defmacro (case tokens) ## (case' tokens ## (#Cons value branches) 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") |