aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
authorEduardo Julian2017-12-02 01:10:12 -0400
committerEduardo Julian2017-12-02 01:10:12 -0400
commit46955edbe6cea9f367562b9fb17cef526109d9e0 (patch)
tree65a0ccbd9ea7bd02be39963783adac432d8f5e90 /luxc/src
parentf92c4dc2f813b40f14d240491daa665942165e7e (diff)
- Added new "lux in-module" procedure for changing the module while analysing an expression.
Diffstat (limited to 'luxc/src')
-rw-r--r--luxc/src/lux/analyser.clj7
-rw-r--r--luxc/src/lux/base.clj10
2 files changed, 17 insertions, 0 deletions
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj
index 13bf3bc61..6e765cb9b 100644
--- a/luxc/src/lux/analyser.clj
+++ b/luxc/src/lux/analyser.clj
@@ -162,6 +162,13 @@
(&/with-cursor cursor
(&&lux/analyse-module analyse optimize eval! compile-module ?meta)))
+ "lux in-module"
+ (|let [(&/$Cons [_ (&/$Text ?module)]
+ (&/$Cons ?expr (&/$Nil))) parameters]
+ (&/with-cursor cursor
+ (&/with-module ?module
+ (analyse exo-type ?expr))))
+
;; else
(&/with-analysis-meta cursor exo-type
(cond (.startsWith ^String ?procedure "jvm")
diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj
index ae9b2bb47..ee4bcde10 100644
--- a/luxc/src/lux/base.clj
+++ b/luxc/src/lux/base.clj
@@ -1437,6 +1437,16 @@
($Left msg)
($Left msg))))
+(defn with-module [name body]
+ (fn [state]
+ (|case (body (set$ $current-module ($Some name) state))
+ ($Right [state* output])
+ ($Right (T [(set$ $current-module (get$ $current-module state) state*)
+ output]))
+
+ ($Left msg)
+ ($Left msg))))
+
(defn |eitherL [left right]
(fn [compiler]
(|case (run-state left compiler)