aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser/host.clj
diff options
context:
space:
mode:
authorEduardo Julian2015-05-04 12:20:32 -0400
committerEduardo Julian2015-05-04 12:20:32 -0400
commit99a4eec5bce78ce5262f94a51f2b57ed2507ac46 (patch)
treeaf0696daa04f7ac154843ae60150567b8675fdb1 /src/lux/analyser/host.clj
parentda7d3d23227e6d162ff287c8b1ba3f466caafdff (diff)
- Added the LuxVar type to properly specify the type of environment bindings.
- Implemented "using". - Implemented jvm-program. - Corrected some primitive (un)wrapping errors in lux.compiler.host. - jvm-program is now scoped to enable local variables. - The types of definitions are now stored within the module dictionary. - Added a "main" method that just compiles program.lux.
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/host.clj24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 1528f2032..3c9e3ce3f 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -18,6 +18,17 @@
[_]
(fail "[Analyser Error] Can't extract Symbol.")))
+(defn ^:private analyse-1+ [analyse ?token]
+ (&type/with-var
+ (fn [$var]
+ ;; (prn 'analyse-1+ (aget $var 1) (&/show-ast ?token))
+ (|do [=expr (&&/analyse-1 analyse $var ?token)]
+ (matchv ::M/objects [=expr]
+ [[?item ?type]]
+ (|do [=type (&type/clean $var ?type)]
+ (return (&/T ?item =type)))
+ )))))
+
;; [Resources]
(do-template [<name> <output-tag> <input-class> <output-class>]
(let [input-type (&/V "lux;DataT" <input-class>)
@@ -218,7 +229,7 @@
(do-template [<name> <tag> <from-class> <to-class>]
(defn <name> [analyse ?value]
- (|do [=value (&&/analyse-1 analyse ?value)]
+ (|do [=value (&&/analyse-1 analyse (&/V "lux;DataT" <from-class>) ?value)]
(return (&/|list (&/T (&/V <tag> =value) (&/V "lux;DataT" <to-class>))))))
analyse-jvm-d2f "jvm-d2f" "java.lang.Double" "java.lang.Float"
@@ -243,7 +254,7 @@
(do-template [<name> <tag> <from-class> <to-class>]
(defn <name> [analyse ?value]
- (|do [=value (&&/analyse-1 analyse ?value)]
+ (|do [=value (&&/analyse-1 analyse (&/V "lux;DataT" <from-class>) ?value)]
(return (&/|list (&/T (&/V <tag> =value) (&/V "lux;DataT" <to-class>))))))
analyse-jvm-iand "jvm-iand" "java.lang.Integer" "java.lang.Integer"
@@ -259,6 +270,11 @@
)
(defn analyse-jvm-program [analyse ?args ?body]
- (|do [=body (&&env/with-local ?args (&/V "lux;AppT" (&/T &type/List &type/Text))
- (&&/analyse-1 analyse ?body))]
+ (|do [;; =body (&&env/with-local ?args (&/V "lux;AppT" (&/T &type/List &type/Text))
+ ;; (&&/analyse-1 analyse ?body))
+ =body (&/with-scope ""
+ (&&env/with-local "" (&/V "lux;AppT" (&/T &type/List &type/Text))
+ (analyse-1+ analyse ?body)))
+ ;; =body (analyse-1+ analyse ?body)
+ ]
(return (&/|list (&/V "jvm-program" =body)))))