aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Julian2015-04-26 19:02:34 -0400
committerEduardo Julian2015-04-26 19:02:34 -0400
commit5046f872d28edfab44e5efb0e200e49267832b49 (patch)
tree954540d2b5f172b0487a984cc2373e843f5dbc30 /src
parent6e72c1363efae036bf511cbc53aa9a10c1c93eb9 (diff)
- Added a new type of definition (#TypeD (,)), to take advantage of an optimization where I can skip doing a full-blowing type-check by doing a pointer-check with &type/Type for both the exo-type and the endo-type.
Diffstat (limited to 'src')
-rw-r--r--src/lux/analyser/lux.clj38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index e2d56c3e0..8d7819fd3 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -116,9 +116,16 @@
(return ?type)
[["lux;MacroD" _]]
- (return &type/Macro))
+ (return &type/Macro)
+
+ [["lux;TypeD" _]]
+ (return &type/Type))
;; :let [_ (println "Got endo-type:" endo-type)]
- _ (&type/check exo-type endo-type)
+ _ (if (and (= &type/Type endo-type) (= &type/Type exo-type))
+ (do ;; (println "OH YEAH" (if (= "" ?module) module-name ?module)
+ ;; ?name)
+ (return nil))
+ (&type/check exo-type endo-type))
;; :let [_ (println "Type-checked:" exo-type endo-type)]
]
(return (&/|list (&/V "Expression" (&/T (&/V "global" (&/T (if (= "" ?module) module-name ?module)
@@ -138,9 +145,15 @@
(return ?type)
[["lux;MacroD" _]]
- (return &type/Macro))
+ (return &type/Macro)
+
+ [["lux;TypeD" _]]
+ (return &type/Type))
;; :let [_ (println "Got endo-type:" endo-type)]
- _ (&type/check exo-type endo-type)
+ _ (if (and (= &type/Type endo-type) (= &type/Type exo-type))
+ (do ;; (println "OH YEAH" ?module* ?name*)
+ (return nil))
+ (&type/check exo-type endo-type))
;; :let [_ (println "Type-checked:" exo-type endo-type)]
]
(return (&/|list (&/V "Expression" (&/T (&/V "global" (&/T ?module* ?name*))
@@ -292,7 +305,7 @@
(return (&/|list output))))
(defn analyse-def [analyse ?name ?value]
- (prn 'analyse-def/CODE ?name (&/show-ast ?value))
+ ;; (prn 'analyse-def/CODE ?name (&/show-ast ?value))
(|do [module-name &/get-module-name
? (&&module/defined? module-name ?name)]
(if ?
@@ -303,11 +316,16 @@
;; :let [_ (prn 'analyse-def/_1)]
=value-type (&&/expr-type =value)
;; :let [_ (prn 'analyse-def/_2)]
- :let [_ (prn 'analyse-def/TYPE ?name (&type/show-type =value-type))
- _ (println)
- def-data (if (&type/type= &type/Macro =value-type)
- (&/V "lux;MacroD" (&/V "lux;None" nil))
- (&/V "lux;ValueD" =value-type))]
+ :let [;; _ (prn 'analyse-def/TYPE ?name (&type/show-type =value-type))
+ ;; _ (println)
+ def-data (cond (&type/type= &type/Macro =value-type)
+ (&/V "lux;MacroD" (&/V "lux;None" nil))
+
+ (&type/type= &type/Type =value-type)
+ (&/V "lux;TypeD" nil)
+
+ :else
+ (&/V "lux;ValueD" =value-type))]
_ (&&module/define module-name ?name def-data)
;; :let [_ (prn 'analyse-def/_3)]
]