diff options
author | Eduardo Julian | 2015-03-01 21:08:57 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-03-01 21:08:57 -0400 |
commit | ae5c933a5208c51fe30d0b9dc976690ee8bc138a (patch) | |
tree | 76c7a03ea3807526c3d3a1a76ac8a2aebea55c1e /src/lux/analyser/host.clj | |
parent | f5b2f04fec382da0d164f772ed65ae058e66d8e2 (diff) |
Code compiles again! (although, I had to employ a hack for "fold", as function self-calls are broken).
Also fixed several small bugs, including the one that caused ".apply" to never make progress (always returned a function with count 0).
Also fixed an issue with scopes that caused class-names to be generated improperly.
Diffstat (limited to 'src/lux/analyser/host.clj')
-rw-r--r-- | src/lux/analyser/host.clj | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index fd4444671..ddc91d2b9 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -16,18 +16,19 @@ (return ?ident) _ - (fail ""))) + (fail "[Analyser Error] Can't extract Ident."))) ;; [Resources] (do-template [<name> <ident> <output-tag> <wrapper-class>] - (defn <name> [analyse ?x ?y] - (exec [:let [=type [::&type/Data <wrapper-class>]] - [=x =y] (&&/analyse-2 analyse ?x ?y) - =x-type (&&/expr-type =x) - =y-type (&&/expr-type =y) - _ (&type/solve =type =x-type) - _ (&type/solve =type =y-type)] - (return (list [::&&/Expression [<output-tag> =x =y] =type])))) + (let [elem-type [::&type/Data <wrapper-class>]] + (defn <name> [analyse ?x ?y] + (exec [[=x =y] (&&/analyse-2 analyse ?x ?y) + ;; =x-type (&&/expr-type =x) + ;; =y-type (&&/expr-type =y) + ;; _ (&type/solve elem-type =x-type) + ;; _ (&type/solve elem-type =y-type) + ] + (return (list [::&&/Expression [<output-tag> =x =y] elem-type]))))) analyse-jvm-iadd "jvm;iadd" ::&&/jvm-iadd "java.lang.Integer" analyse-jvm-isub "jvm;isub" ::&&/jvm-isub "java.lang.Integer" @@ -56,13 +57,15 @@ (defn analyse-jvm-getstatic [analyse ?class ?field] (exec [=class (&host/full-class-name ?class) - =type (&host/lookup-static-field =class ?field)] + :let [_ (prn 'analyse-jvm-getstatic/=class =class)] + =type (&host/lookup-static-field =class ?field) + :let [_ (prn 'analyse-jvm-getstatic/=type =type)]] (return (list [::&&/Expression [::&&/jvm-getstatic =class ?field] =type])))) (defn analyse-jvm-getfield [analyse ?class ?field ?object] (exec [=class (&host/full-class-name ?class) =type (&host/lookup-static-field =class ?field) - =object (&&/analyse-1 ?object)] + =object (&&/analyse-1 analyse ?object)] (return (list [::&&/Expression [::&&/jvm-getfield =class ?field =object] =type])))) (defn analyse-jvm-invokestatic [analyse ?class ?method ?classes ?args] @@ -74,10 +77,15 @@ (defn analyse-jvm-invokevirtual [analyse ?class ?method ?classes ?object ?args] (exec [=class (&host/full-class-name ?class) + :let [_ (prn 'analyse-jvm-invokevirtual/=class =class)] =classes (map-m &host/extract-jvm-param ?classes) - =return (&host/lookup-virtual-method =class ?method =classes) - =object (&&/analyse-1 ?object) - =args (mapcat-m analyse ?args)] + :let [_ (prn 'analyse-jvm-invokevirtual/=classes =classes)] + [=method-args =return] (&host/lookup-virtual-method =class ?method =classes) + :let [_ (prn 'analyse-jvm-invokevirtual/=return =return)] + =object (&&/analyse-1 analyse ?object) + :let [_ (prn 'analyse-jvm-invokevirtual/=object =object)] + =args (mapcat-m analyse ?args) + :let [_ (prn 'analyse-jvm-invokevirtual/=args =args)]] (return (list [::&&/Expression [::&&/jvm-invokevirtual =class ?method =classes =object =args] =return])))) (defn analyse-jvm-new [analyse ?class ?classes ?args] @@ -91,12 +99,12 @@ (return (list [::&&/Expression [::&&/jvm-new-array =class ?length] [::&type/Array [::&type/Data =class]]])))) (defn analyse-jvm-aastore [analyse ?array ?idx ?elem] - (exec [[=array =elem] (&&/analyse-2 ?array ?elem) + (exec [[=array =elem] (&&/analyse-2 analyse ?array ?elem) =array-type (&&/expr-type =array)] (return (list [::&&/Expression [::&&/jvm-aastore =array ?idx =elem] =array-type])))) (defn analyse-jvm-aaload [analyse ?array ?idx] - (exec [=array (&&/analyse-1 ?array) + (exec [=array (&&/analyse-1 analyse ?array) =array-type (&&/expr-type =array)] (return (list [::&&/Expression [::&&/jvm-aaload =array ?idx] =array-type])))) @@ -107,7 +115,7 @@ (return [?class ?field-name]) _ - (fail ""))) + (fail "[Analyser Error] Fields must be Tuple2 of [Ident, Ident]"))) ?fields) :let [=fields (into {} (for [[class field] ?fields] [field {:access :public @@ -126,7 +134,7 @@ (return [?member-name [?inputs ?output]])) _ - (fail ""))) + (fail "[Analyser Error] Invalid method signature!"))) ?members) :let [=methods (into {} (for [[method [inputs output]] ?members] [method {:access :public |