diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lux/analyser.clj | 38 | ||||
-rw-r--r-- | src/lux/analyser/case.clj | 4 | ||||
-rw-r--r-- | src/lux/analyser/host.clj | 22 | ||||
-rw-r--r-- | src/lux/compiler/lux.clj | 5 | ||||
-rw-r--r-- | src/lux/host.clj | 8 |
5 files changed, 29 insertions, 48 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj index f85b3d619..1606a95c2 100644 --- a/src/lux/analyser.clj +++ b/src/lux/analyser.clj @@ -166,57 +166,57 @@ (&&host/analyse-jvm-null? analyse ?object) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_instanceof"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] ["lux;Cons" [?object ["lux;Nil" _]]]]]]]]] (&&host/analyse-jvm-instanceof analyse ?class ?object) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_new"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?classes]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?args]]] ["lux;Nil" _]]]]]]]]]]] (&&host/analyse-jvm-new analyse ?class ?classes ?args) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_getstatic"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?field]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?field]]] ["lux;Nil" _]]]]]]]]] (&&host/analyse-jvm-getstatic analyse ?class ?field) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_getfield"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?field]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?field]]] ["lux;Cons" [?object ["lux;Nil" _]]]]]]]]]]] (&&host/analyse-jvm-getfield analyse ?class ?field ?object) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_putstatic"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?field]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?field]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]]] (&&host/analyse-jvm-putstatic analyse ?class ?field ?value) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_putfield"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?field]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?field]]] ["lux;Cons" [?object ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]]]]] (&&host/analyse-jvm-putfield analyse ?class ?field ?object ?value) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_invokestatic"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?method]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?classes]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?args]]] ["lux;Nil" _]]]]]]]]]]]]] (&&host/analyse-jvm-invokestatic analyse ?class ?method ?classes ?args) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_invokevirtual"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?method]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?classes]]] ["lux;Cons" [?object ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?args]]] @@ -224,8 +224,8 @@ (&&host/analyse-jvm-invokevirtual analyse ?class ?method ?classes ?object ?args) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_invokeinterface"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?method]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?classes]]] ["lux;Cons" [?object ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?args]]] @@ -233,8 +233,8 @@ (&&host/analyse-jvm-invokeinterface analyse ?class ?method ?classes ?object ?args) [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_jvm_invokespecial"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?method]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?class]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?classes]]] ["lux;Cons" [?object ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?args]]] @@ -408,7 +408,7 @@ ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]] (&&lux/analyse-def analyse ?name ?value) - + [["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ "_lux_declare-macro"]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" ["" ?name]]]] ["lux;Nil" _]]]]]]] diff --git a/src/lux/analyser/case.clj b/src/lux/analyser/case.clj index cb76d8d54..ebbb6911a 100644 --- a/src/lux/analyser/case.clj +++ b/src/lux/analyser/case.clj @@ -101,8 +101,8 @@ (fail "##9##")))] (adjust-type* up type*)) - [_] - (assert false (aget type 0)) + ;; [_] + ;; (assert false (aget type 0)) )) (defn adjust-type [type] diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index e490bc62f..11d43ce9e 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -18,14 +18,6 @@ [env :as &&env]))) ;; [Utils] -(defn ^:private extract-ident [ident] - (matchv ::M/objects [ident] - [["lux;Meta" [_ ["lux;SymbolS" [_ ?ident]]]]] - (return ?ident) - - [_] - (fail "[Analyser Error] Can't extract Symbol."))) - (defn ^:private extract-text [text] (matchv ::M/objects [text] [["lux;Meta" [_ ["lux;TextS" ?text]]]] @@ -115,7 +107,7 @@ (return (&/|list (&/T (&/V "jvm-putfield" (&/T ?class ?field =object =value)) =type))))) (defn analyse-jvm-invokestatic [analyse ?class ?method ?classes ?args] - (|do [=classes (&/map% &host/extract-jvm-param ?classes) + (|do [=classes (&/map% extract-text ?classes) =return (&host/lookup-static-method ?class ?method =classes) ;; :let [_ (matchv ::M/objects [=return] ;; [["lux;DataT" _return-class]] @@ -138,7 +130,7 @@ (do-template [<name> <tag>] (defn <name> [analyse ?class ?method ?classes ?object ?args] - (|do [=classes (&/map% &host/extract-jvm-param ?classes) + (|do [=classes (&/map% extract-text ?classes) =return (&host/lookup-virtual-method ?class ?method =classes) =object (&&/analyse-1 analyse (&/V "lux;DataT" ?class) ?object) =args (&/map2% (fn [?c ?o] @@ -151,7 +143,7 @@ ) (defn analyse-jvm-invokespecial [analyse ?class ?method ?classes ?object ?args] - (|do [=classes (&/map% &host/extract-jvm-param ?classes) + (|do [=classes (&/map% extract-text ?classes) =return (if (= "<init>" ?method) (return &type/$Void) (&host/lookup-virtual-method ?class ?method =classes)) @@ -166,7 +158,7 @@ (return (&/|list (&/T (&/V "jvm-null?" =object) (&/V "lux;DataT" "java.lang.Boolean")))))) (defn analyse-jvm-new [analyse ?class ?classes ?args] - (|do [=classes (&/map% &host/extract-jvm-param ?classes) + (|do [=classes (&/map% extract-text ?classes) =args (&/flat-map% analyse ?args)] (return (&/|list (&/T (&/V "jvm-new" (&/T ?class =classes =args)) (&/V "lux;DataT" ?class)))))) @@ -239,7 +231,7 @@ (|do [=interfaces (&/map% extract-text ?interfaces) =fields (&/map% (fn [?field] (matchv ::M/objects [?field] - [["lux;Meta" [_ ["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ ?field-name]]]] + [["lux;Meta" [_ ["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?field-name]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?field-type]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?field-modifiers]]] ["lux;Nil" _]]]]]]]]]]] @@ -253,7 +245,7 @@ ?fields) =methods (&/map% (fn [?method] (matchv ::M/objects [?method] - [[?idx ["lux;Meta" [_ ["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ ?method-name]]]] + [[?idx ["lux;Meta" [_ ["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method-name]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?method-inputs]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method-output]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?method-modifiers]]] @@ -297,7 +289,7 @@ (|do [=supers (&/map% extract-text ?supers) =methods (&/map% (fn [method] (matchv ::M/objects [method] - [["lux;Meta" [_ ["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;SymbolS" [_ ?method-name]]]] + [["lux;Meta" [_ ["lux;FormS" ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?method-name]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?inputs]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TextS" ?output]]] ["lux;Cons" [["lux;Meta" [_ ["lux;TupleS" ?modifiers]]] diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj index f1c261d6b..b1023689e 100644 --- a/src/lux/compiler/lux.clj +++ b/src/lux/compiler/lux.clj @@ -64,10 +64,7 @@ (|do [:let [_ (doto *writer* (.visitInsn Opcodes/DUP) (.visitLdcInsn (int idx)))] - ret (try (compile elem) - (catch Exception e - (prn 'compile-tuple (aget elem 0) (->> ?elems (&/|map #(aget % 0)) &/->seq)) - (throw e))) + ret (compile elem) :let [_ (.visitInsn *writer* Opcodes/AASTORE)]] (return ret))) (&/|range num-elems) ?elems)] diff --git a/src/lux/host.clj b/src/lux/host.clj index d248c708e..cf9830169 100644 --- a/src/lux/host.clj +++ b/src/lux/host.clj @@ -75,14 +75,6 @@ "V" )) -(defn extract-jvm-param [token] - (matchv ::M/objects [token] - [["lux;Meta" [_ ["lux;SymbolS" [_ ?ident]]]]] - (return ?ident) - - [_] - (fail (str "[Host] Unknown JVM param: " (pr-str token))))) - (do-template [<name> <static?>] (defn <name> [target field] (if-let [type* (first (for [^Field =field (.getDeclaredFields (Class/forName target)) |