aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2015-08-31 15:54:45 -0400
committerEduardo Julian2015-08-31 15:54:45 -0400
commit7f0aa70c6115f9321e13f0452d724b9b40c3f981 (patch)
tree092b4944559d198be8bd1e5297770909785b5ba0
parent1857af8628216353c4fa0b75a921d66b266aa0b9 (diff)
- Compiler no longer allows an alias to be reused for another module when importing.
- Compiler now cleans the module's .class files prior to compiling to avoid keeping old .class files around.
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/module.clj28
-rw-r--r--src/lux/compiler.clj3
2 files changed, 17 insertions, 14 deletions
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj
index 6eca13b44..8c27fc08d 100644
--- a/src/lux/analyser/module.clj
+++ b/src/lux/analyser/module.clj
@@ -137,19 +137,6 @@
(return* state
(->> state (&/get$ &/$modules) (&/|contains? name)))))
-(defn alias [module alias reference]
- (fn [state]
- (return* (->> state
- (&/update$ &/$modules
- (fn [ms]
- (&/|update module
- #(&/update$ $module-aliases
- (fn [aliases]
- (&/|put alias reference aliases))
- %)
- ms))))
- nil)))
-
(defn dealias [name]
(|do [current-module &/get-module-name]
(fn [state]
@@ -157,6 +144,21 @@
(return* state real-name)
(fail* (str "Unknown alias: " name))))))
+(defn alias [module alias reference]
+ (fn [state]
+ (if-let [real-name (->> state (&/get$ &/$modules) (&/|get module) (&/get$ $module-aliases) (&/|get alias))]
+ (fail* (str "Can't re-use alias \"" alias "\" @ " module))
+ (return* (->> state
+ (&/update$ &/$modules
+ (fn [ms]
+ (&/|update module
+ #(&/update$ $module-aliases
+ (fn [aliases]
+ (&/|put alias reference aliases))
+ %)
+ ms))))
+ nil))))
+
(defn find-def [module name]
(|do [current-module &/get-module-name]
(fn [state]
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 694c6bfc4..e16a84b20 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -408,7 +408,8 @@
(|do [module-exists? (&a-module/exists? name)]
(if module-exists?
(fail "[Compiler Error] Can't redefine a module!")
- (|do [_ (&a-module/enter-module name)
+ (|do [_ (&&cache/delete name)
+ _ (&a-module/enter-module name)
:let [=class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS)
(.visit Opcodes/V1_6 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER)
(str (&host/->module-class name) "/_") nil "java/lang/Object" nil)