aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lux/analyser/host.clj3
-rw-r--r--src/lux/analyser/lux.clj13
-rw-r--r--src/lux/base.clj6
-rw-r--r--src/lux/compiler/cache.clj2
-rw-r--r--src/lux/compiler/host.clj2
-rw-r--r--src/lux/lexer.clj64
-rw-r--r--src/lux/packager/program.clj2
7 files changed, 37 insertions, 55 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 20028441c..55d534f96 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -304,6 +304,7 @@
[gret exceptions parent-gvars gvars gargs] (if (= "<init>" method)
(return (&/T [Void/TYPE &/$Nil &/$Nil &/$Nil &/$Nil]))
(&host/lookup-virtual-method class-loader class method classes))
+ ;; :let [_ (prn '<name> 0 gret)]
_ (ensure-catching exceptions)
=object (&&/analyse-1+ analyse object)
[sub-class sub-params] (ensure-object (&&/expr-type* =object))
@@ -313,6 +314,8 @@
parent-gvars
super-params*)]
[output-type =args] (analyse-method-call-helper analyse gret gtype-env gvars gargs args)
+ ;; :let [_ (prn '<name> 1 (&type/show-type output-type))]
+ ;; :let [_ (prn '<name> 2 (&type/show-type (as-otype+ output-type)))]
_ (&type/check exo-type (as-otype+ output-type))
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index 9526fed0f..c0aefed35 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -233,15 +233,15 @@
(&/map% (partial &&/clean-analysis $var) =exprs))))
_
- (fail (str "[Analyser Error] Can't create variant if the expected type is " (&type/show-type exo-type*))))
+ (fail (str "[Analyser Error] Can't create variant if the expected type is " (&type/show-type exo-type*) " " idx " " (->> ?values (&/|map &/show-ast) (&/|interpose " ") (&/fold str "")))))
(fn [err]
(|case exo-type
(&/$VarT ?id)
(|do [=exo-type (&type/deref ?id)]
- (fail (str err "\n" "[Analyser Error] Can't create variant if the expected type is " (&type/show-type =exo-type))))
+ (fail (str err "\n" "[Analyser Error] Can't create variant if the expected type is " (&type/show-type =exo-type) " " idx " " (->> ?values (&/|map &/show-ast) (&/|interpose " ") (&/fold str "")))))
_
- (fail (str err "\n" "[Analyser Error] Can't create variant if the expected type is " (&type/show-type exo-type))))))
+ (fail (str err "\n" "[Analyser Error] Can't create variant if the expected type is " (&type/show-type exo-type) " " idx " " (->> ?values (&/|map &/show-ast) (&/|interpose " ") (&/fold str "")))))))
)))
(defn analyse-record [analyse exo-type ?elems]
@@ -382,12 +382,13 @@
(|do [macro-expansion (fn [state] (try (-> ?value (.apply ?args) (.apply state))
(catch java.lang.StackOverflowError e
(|let [[r-prefix r-name] real-name]
- (do (prn 'find-def [r-prefix r-name])
+ (do (.printStackTrace e)
(throw e))))))
module-name &/get-module-name
;; :let [[r-prefix r-name] real-name
- ;; _ (when (or (= "jvm-import" r-name)
- ;; ;; (= "defclass" r-name)
+ ;; _ (when (or (= "defsig" r-name)
+ ;; (= "deftype" r-name)
+ ;; (= "@type" r-name)
;; )
;; (->> (&/|map &/show-ast macro-expansion)
;; (&/|interpose "\n")
diff --git a/src/lux/base.clj b/src/lux/base.clj
index 901011bb1..5451cf4da 100644
--- a/src/lux/base.clj
+++ b/src/lux/base.clj
@@ -232,6 +232,9 @@
(def module-class-name "_")
(def +name-separator+ ";")
+(def ^String compiler-name "Lux/JVM")
+(def ^String compiler-version "0.3.3")
+
;; Constructors
(def empty-cursor (T ["" -1 -1]))
@@ -718,9 +721,6 @@
;; lux;type-env
(|table)])))
-(def ^String compiler-name "Lux/JVM")
-(def ^String compiler-version "0.3.3")
-
(defn default-compiler-info [mode]
(T [;; compiler-name
compiler-name
diff --git a/src/lux/compiler/cache.clj b/src/lux/compiler/cache.clj
index 1bd3a1876..27bf56411 100644
--- a/src/lux/compiler/cache.clj
+++ b/src/lux/compiler/cache.clj
@@ -67,7 +67,7 @@
(clean-file f))
nil))
-(defn ^:private install-all-classes-in-module [!classes module* module-path]
+(defn ^:private install-all-classes-in-module [!classes module* ^String module-path]
(doseq [^File file (seq (.listFiles (File. module-path)))
:when (not (.isDirectory file))
:let [file-name (.getName file)]
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index b9a91b356..c01548798 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -506,7 +506,7 @@
_
(.visitInsn writer Opcodes/ARETURN)))
-(defn ^:private prepare-method-input [idx input method-visitor]
+(defn ^:private prepare-method-input [idx input ^MethodVisitor method-visitor]
"(-> Int [Text GenericClass] MethodVisitor (Lux FrameTag))"
(|case input
[_ (&/$GenericClass name params)]
diff --git a/src/lux/lexer.clj b/src/lux/lexer.clj
index cd41b4be7..27116af91 100644
--- a/src/lux/lexer.clj
+++ b/src/lux/lexer.clj
@@ -44,17 +44,6 @@
(defn ^:private escape-char* [escaped]
"(-> Text Text)"
- ;; (prn 'escape-char*
- ;; escaped
- ;; (cond (.equals ^Object escaped "\\t") "\t"
- ;; (.equals ^Object escaped "\\b") "\b"
- ;; (.equals ^Object escaped "\\n") "\n"
- ;; (.equals ^Object escaped "\\r") "\r"
- ;; (.equals ^Object escaped "\\f") "\f"
- ;; (.equals ^Object escaped "\\\"") "\""
- ;; (.equals ^Object escaped "\\\\") "\\"
- ;; :else
- ;; (assert false (str "[Lexer Error] Unknown escape character: " escaped))))
(cond (.equals ^Object escaped "\\t") "\t"
(.equals ^Object escaped "\\b") "\b"
(.equals ^Object escaped "\\n") "\n"
@@ -65,10 +54,6 @@
:else
(assert false (str "[Lexer Error] Unknown escape character: " escaped))))
-(defn ^:private escape-unicode [^String unicode]
- "(-> Text Text)"
- (str (char (Integer/valueOf (.substring unicode 2) 16))))
-
(defn ^:private clean-line [^String raw-line]
"(-> Text Text)"
(let [line-length (.length raw-line)
@@ -100,48 +85,41 @@
(assert false (str "[Lexer] Invalid escaping syntax: " raw-line " " idx))))
(do (.append buffer current-char)
(recur (+ 1 idx)))))
- (.toString buffer))))
- ;; (-> raw-line
- ;; (string/replace #"\\u[0-9a-fA-F]{4}" escape-unicode)
- ;; (string/replace #"\\." escape-char*))
- )
-
-(defn ^:private lex-text-body [offset]
- (|do [[_ eol? ^String pre-quotes*] (&reader/read-regex #"^([^\"]*)")
+ (.toString buffer)))))
+
+(defn ^:private lex-text-body [multi-line? offset]
+ (|do [[_ eol? ^String pre-quotes**] (&reader/read-regex #"^([^\"]*)")
+ pre-quotes* (if multi-line?
+ (|do [:let [empty-line? (and eol? (= "" pre-quotes**))]
+ _ (&/assert! (or empty-line?
+ (>= (.length pre-quotes**) offset))
+ "Each line of a multi-line text must have an appropriate offset!")]
+ (return (if empty-line?
+ "\n"
+ (str "\n" (.substring pre-quotes** offset)))))
+ (return pre-quotes**))
[pre-quotes post-quotes] (if (.endsWith pre-quotes* "\\")
(if eol?
(fail "[Lexer Error] Can't leave dangling back-slash \\")
(if (if-let [^String back-slashes (re-find #"\\+$" pre-quotes*)]
(odd? (.length back-slashes)))
- (|do [_ (&reader/read-regex #"^([\"])")
- next-part (lex-text-body offset)]
+ (|do [[_ eol?* _] (&reader/read-regex #"^([\"])")
+ next-part (lex-text-body eol?* offset)]
(return (&/T [(.substring pre-quotes* 0 (dec (.length pre-quotes*)))
(str "\"" next-part)])))
- (|do [post-quotes* (lex-text-body offset)]
+ (|do [post-quotes* (lex-text-body false offset)]
(return (&/T [pre-quotes* post-quotes*])))))
(if eol?
- (|do [[_ _ ^String line-prefix] (&reader/read-regex #"^( +|$)")
- :let [empty-line? (= "" line-prefix)]
- _ (&/assert! (or empty-line?
- (>= (.length line-prefix) offset))
- "Each line of a multi-line text must have an appropriate offset!")
- next-part (lex-text-body offset)]
+ (|do [next-part (lex-text-body true offset)]
(return (&/T [pre-quotes*
- (str "\n"
- (if empty-line?
- ""
- (.substring line-prefix offset))
- next-part)])))
- (return (&/T [pre-quotes* ""]))))
- :let [cleaned (str (clean-line pre-quotes) post-quotes)
- ;; _ (println 'cleaned cleaned)
- ]]
- (return cleaned)))
+ next-part])))
+ (return (&/T [pre-quotes* ""]))))]
+ (return (str (clean-line pre-quotes) post-quotes))))
(def ^:private lex-text
(|do [[meta _ _] (&reader/read-text "\"")
:let [[_ _ _column] meta]
- token (lex-text-body (inc _column))
+ token (lex-text-body false (inc _column))
_ (&reader/read-text "\"")]
(return (&/T [meta ($Text token)]))))
diff --git a/src/lux/packager/program.clj b/src/lux/packager/program.clj
index 61baecce3..339c31894 100644
--- a/src/lux/packager/program.clj
+++ b/src/lux/packager/program.clj
@@ -64,7 +64,7 @@
"(-> JarOutputStream Null)"
(let [resources-dir (new File resources-path)]
(if (.exists resources-dir)
- (doseq [res (.listFiles resources-dir)]
+ (doseq [^File res (.listFiles resources-dir)]
(with-open [in (->> res (new FileInputStream) (new BufferedInputStream))]
(let [buffer (byte-array buffer-size)]
(doto out