diff options
author | Eduardo Julian | 2016-04-16 17:57:06 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-04-16 17:57:06 -0400 |
commit | 011842da545d20721d3868ccd8992cb5b883eed3 (patch) | |
tree | da3c693643df12b0a12acdd7abb84f5dd16f9898 /src | |
parent | 6081db0c1d9d9ca140809d9685f26cb2675b0318 (diff) |
- The REPL no longer dies as soon as the first error happens.
- Writing "exit" in the REPL, kills it.
- Fixed a bug wherein checking the presence of multiple methods with the same name being implemented, the names would overwrite each other and make some methods become impossible to check.
- Fixed an error when type-checking parameterized host types.
- Fixed a bug when loading the .lux files in JARs in the class-path.
Diffstat (limited to '')
-rw-r--r-- | src/lux/analyser/host.clj | 21 | ||||
-rw-r--r-- | src/lux/lib/loader.clj | 2 | ||||
-rw-r--r-- | src/lux/repl.clj | 76 | ||||
-rw-r--r-- | src/lux/type/host.clj | 10 |
4 files changed, 59 insertions, 50 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index a2d6fd592..20028441c 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -675,7 +675,7 @@ mmap (&/$OverridenMethodAnalysis =class-decl =name ?strict =anns =gvars =exceptions =inputs =output body) - (assoc mmap =name =inputs) + (update-in mmap [=name] (fn [old-inputs] (if old-inputs (conj old-inputs =inputs) [=inputs]))) (&/$StaticMethodAnalysis _) mmap @@ -692,15 +692,16 @@ (or missing (|let [[am-name am-inputs] abs-meth] (if-let [meth-struct (get methods-map am-name)] - (|let [=inputs meth-struct] - (if (and (= (&/|length =inputs) (&/|length am-inputs)) - (&/fold2 (fn [prev mi ai] - (|let [[iname itype] mi] - (and prev (= (generic-class->simple-class itype) ai)))) - true - =inputs am-inputs)) - nil - abs-meth)) + (if (some (fn [=inputs] + (and (= (&/|length =inputs) (&/|length am-inputs)) + (&/fold2 (fn [prev mi ai] + (|let [[iname itype] mi] + (and prev (= (generic-class->simple-class itype) ai)))) + true + =inputs am-inputs))) + meth-struct) + nil + abs-meth) abs-meth)))) nil abstract-methods)]] diff --git a/src/lux/lib/loader.clj b/src/lux/lib/loader.clj index e70576c24..e8310f9f0 100644 --- a/src/lux/lib/loader.clj +++ b/src/lux/lib/loader.clj @@ -41,7 +41,7 @@ entry (.getNextJarEntry is)] (if entry (if (.endsWith (.getName entry) ".lux") - (recur (assoc lib-data (.substring (.getName entry) 1) (new String (read-stream is))) + (recur (assoc lib-data (.getName entry) (new String (read-stream is))) (.getNextJarEntry is)) (recur lib-data (.getNextJarEntry is))) diff --git a/src/lux/repl.clj b/src/lux/repl.clj index 138eb695f..dd63c1764 100644 --- a/src/lux/repl.clj +++ b/src/lux/repl.clj @@ -20,13 +20,16 @@ (def ^:private repl-module "REPL") (defn ^:private init [] - (do (println "Welcome to the REPL!") - (&compiler/init!) + (do (&compiler/init!) (|case ((|do [_ (&compiler/compile-module "lux")] (&module/enter-module repl-module)) (&/init-state &/$Debug)) (&/$Right ?state _) - (&/set$ &/$source &/$Nil ?state) + (do (println) + (println "Welcome to the REPL!") + (println "Type \"exit\" to leave.") + (println) + (&/set$ &/$source &/$Nil ?state)) (&/$Left ?message) (assert false ?message)) @@ -41,37 +44,40 @@ (loop [state (init) repl-line 0] (let [_ (.print System/out "> ") - line (.readLine input) - line* (&/|list (&/T [(repl-cursor repl-line) line])) - state* (&/update$ &/$source - (fn [_source] (&/|++ _source line*)) - state)] - (|case ((|do [analysed-tokens (&analyser/repl-analyse &compiler/eval! &compiler/compile-module &compiler/compile-token) - optimized-tokens (->> analysed-tokens - (&/|map &a-base/expr-term) - (&/map% &optimizer/optimize-token)) - :let [optimized-tokens* (&/->list (map (fn [analysis optim] - (|let [[[_type _cursor] _term] analysis] - (&a-base/|meta _type _cursor optim))) - (&/->seq analysed-tokens) - (&/->seq optimized-tokens)))] - eval-values (&/map% &compiler/eval! optimized-tokens*) - :let [outputs (map (fn [analysis value] - (|let [[[_type _cursor] _term] analysis] - [_type value])) - (&/->seq analysed-tokens) - (&/->seq eval-values))]] - (return outputs)) - state*) - (&/$Right state** outputs) - (do (doseq [[_type _value] outputs] - (.println System/out (str "=> " (&type/show-type _type) "\n" (pr-str _value) "\n"))) - (recur state** (inc repl-line))) + line (.readLine input)] + (if (= "exit" line) + (println "Till next time...") + (let [line* (&/|list (&/T [(repl-cursor repl-line) line])) + state* (&/update$ &/$source + (fn [_source] (&/|++ _source line*)) + state)] + (|case ((|do [analysed-tokens (&analyser/repl-analyse &compiler/eval! &compiler/compile-module &compiler/compile-token) + optimized-tokens (->> analysed-tokens + (&/|map &a-base/expr-term) + (&/map% &optimizer/optimize-token)) + :let [optimized-tokens* (&/->list (map (fn [analysis optim] + (|let [[[_type _cursor] _term] analysis] + (&a-base/|meta _type _cursor optim))) + (&/->seq analysed-tokens) + (&/->seq optimized-tokens)))] + eval-values (&/map% &compiler/eval! optimized-tokens*) + :let [outputs (map (fn [analysis value] + (|let [[[_type _cursor] _term] analysis] + [_type value])) + (&/->seq analysed-tokens) + (&/->seq eval-values))]] + (return outputs)) + state*) + (&/$Right state** outputs) + (do (doseq [[_type _value] outputs] + (.println System/out (str "=> " (&type/show-type _type) "\n" (pr-str _value) "\n"))) + (recur state** (inc repl-line))) - (&/$Left ^String ?message) - (if (or (= "[Reader Error] EOF" ?message) - (.startsWith ?message "[Parser Error] Unbalanced ")) - (recur state* (inc repl-line)) - (assert false ?message)) - )) + (&/$Left ^String ?message) + (if (or (= "[Reader Error] EOF" ?message) + (.startsWith ?message "[Parser Error] Unbalanced ")) + (recur state* (inc repl-line)) + (do (println ?message) + (recur state (inc repl-line)))) + )))) ))) diff --git a/src/lux/type/host.clj b/src/lux/type/host.clj index 096fb2182..b547a7052 100644 --- a/src/lux/type/host.clj +++ b/src/lux/type/host.clj @@ -81,9 +81,11 @@ (if (.equals "void" base) &/$UnitT (reduce (fn [inner _] (&/$DataT array-data-tag (&/|list inner))) - (&/$DataT base (-> class .getTypeParameters - seq count (repeat (&/$DataT "java.lang.Object" &/$Nil)) - &/->list)) + (&/$DataT base (try (-> (Class/forName base) .getTypeParameters + seq count (repeat (&/$DataT "java.lang.Object" &/$Nil)) + &/->list) + (catch Exception e + (&/|list)))) (range (count (or arr-obrackets arr-pbrackets ""))))) )))) @@ -161,7 +163,7 @@ (->> ^ParameterizedType % .getActualTypeArguments seq &/->list)) nil)))] params* (translate-params existential - super-params + (or super-params (&/|list)) (->> sub .getTypeParameters seq &/->list) params)] (return (&/T [super params*]))) |