aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/lux/codata/lazy.lux6
-rw-r--r--source/lux/data/io.lux4
-rw-r--r--src/lux/analyser.clj55
-rw-r--r--src/lux/analyser/case.clj2
-rw-r--r--src/lux/compiler/lux.clj12
5 files changed, 42 insertions, 37 deletions
diff --git a/source/lux/codata/lazy.lux b/source/lux/codata/lazy.lux
index 1529c0dae..fb0c0bcb3 100644
--- a/source/lux/codata/lazy.lux
+++ b/source/lux/codata/lazy.lux
@@ -32,6 +32,12 @@
(-> (Lazy a) a))
(thunk id))
+(def #export (call/cc f)
+ (All [a b c] (Lazy (-> a (Lazy b c)) (Lazy a c)))
+ (lambda [k]
+ (f (lambda [a _] (k a))
+ k)))
+
## [Structs]
(defstruct #export Lazy/Functor (Functor Lazy)
(def (map f ma)
diff --git a/source/lux/data/io.lux b/source/lux/data/io.lux
index 2d2a2bc35..1ca68f518 100644
--- a/source/lux/data/io.lux
+++ b/source/lux/data/io.lux
@@ -42,10 +42,10 @@
## [Functions]
(def #export (print x)
(-> Text (IO (,)))
- (io (_jvm_invokevirtual "java.io.PrintStream" "print" ["java.lang.Object"]
+ (io (_jvm_invokevirtual "java.io.PrintStream" "print" ["java.lang.String"]
(_jvm_getstatic "java.lang.System" "out") [x])))
(def #export (println x)
(-> Text (IO (,)))
- (io (_jvm_invokevirtual "java.io.PrintStream" "println" ["java.lang.Object"]
+ (io (_jvm_invokevirtual "java.io.PrintStream" "println" ["java.lang.String"]
(_jvm_getstatic "java.lang.System" "out") [x])))
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj
index 3ff214ee0..552ccd77d 100644
--- a/src/lux/analyser.clj
+++ b/src/lux/analyser.clj
@@ -559,33 +559,34 @@
(defn ^:private analyse-ast [eval! compile-module compile-token exo-type token]
;; (prn 'analyse-ast (&/show-ast token))
- (&/with-cursor (aget token 0)
- (&/with-expected-type exo-type
- (|case token
- [meta (&/$FormS (&/$Cons [_ (&/$IntS idx)] ?values))]
- (&&lux/analyse-variant (partial analyse-ast eval! compile-module compile-token) exo-type idx ?values)
-
- [meta (&/$FormS (&/$Cons [_ (&/$TagS ?ident)] ?values))]
- (|do [;; :let [_ (println 'analyse-ast/_0 (&/ident->text ?ident))]
- [module tag-name] (&/normalize ?ident)
- ;; :let [_ (println 'analyse-ast/_1 (&/ident->text (&/T module tag-name)))]
- idx (&&module/tag-index module tag-name)
- ;; :let [_ (println 'analyse-ast/_2 idx)]
- ]
- (&&lux/analyse-variant (partial analyse-ast eval! compile-module compile-token) exo-type idx ?values))
-
- [meta (&/$FormS (&/$Cons ?fn ?args))]
- (fn [state]
- (|case ((just-analyse (partial analyse-ast eval! compile-module compile-token) ?fn) state)
- (&/$Right state* =fn)
- (do ;; (prn 'GOT_FUN (&/show-ast ?fn) (&/show-ast token) (aget =fn 0 0) (aget =fn 1 0))
- ((&&lux/analyse-apply (partial analyse-ast eval! compile-module compile-token) exo-type meta =fn ?args) state*))
-
- _
- ((analyse-basic-ast (partial analyse-ast eval! compile-module compile-token) eval! compile-module compile-token exo-type token) state)))
-
- _
- (analyse-basic-ast (partial analyse-ast eval! compile-module compile-token) eval! compile-module compile-token exo-type token)))))
+ (|let [[cursor _] token]
+ (&/with-cursor cursor
+ (&/with-expected-type exo-type
+ (|case token
+ [meta (&/$FormS (&/$Cons [_ (&/$IntS idx)] ?values))]
+ (&&lux/analyse-variant (partial analyse-ast eval! compile-module compile-token) exo-type idx ?values)
+
+ [meta (&/$FormS (&/$Cons [_ (&/$TagS ?ident)] ?values))]
+ (|do [;; :let [_ (println 'analyse-ast/_0 (&/ident->text ?ident))]
+ [module tag-name] (&/normalize ?ident)
+ ;; :let [_ (println 'analyse-ast/_1 (&/ident->text (&/T module tag-name)))]
+ idx (&&module/tag-index module tag-name)
+ ;; :let [_ (println 'analyse-ast/_2 idx)]
+ ]
+ (&&lux/analyse-variant (partial analyse-ast eval! compile-module compile-token) exo-type idx ?values))
+
+ [meta (&/$FormS (&/$Cons ?fn ?args))]
+ (fn [state]
+ (|case ((just-analyse (partial analyse-ast eval! compile-module compile-token) ?fn) state)
+ (&/$Right state* =fn)
+ (do ;; (prn 'GOT_FUN (&/show-ast ?fn) (&/show-ast token) (aget =fn 0 0) (aget =fn 1 0))
+ ((&&lux/analyse-apply (partial analyse-ast eval! compile-module compile-token) exo-type meta =fn ?args) state*))
+
+ _
+ ((analyse-basic-ast (partial analyse-ast eval! compile-module compile-token) eval! compile-module compile-token exo-type token) state)))
+
+ _
+ (analyse-basic-ast (partial analyse-ast eval! compile-module compile-token) eval! compile-module compile-token exo-type token))))))
;; [Resources]
(defn analyse [eval! compile-module compile-token]
diff --git a/src/lux/analyser/case.clj b/src/lux/analyser/case.clj
index e86d55497..7a1ec4860 100644
--- a/src/lux/analyser/case.clj
+++ b/src/lux/analyser/case.clj
@@ -233,7 +233,7 @@
;; :let [_ (println "#13")]
case-type (&type/variant-case idx value-type*)
;; :let [_ (println "#14" (&type/show-type case-type))]
- [=test =kont] (case (&/|length ?values)
+ [=test =kont] (case (int (&/|length ?values))
0 (analyse-pattern case-type unit kont)
1 (analyse-pattern case-type (&/|head ?values) kont)
;; 1+
diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj
index 3aa25ac99..6a02ed21d 100644
--- a/src/lux/compiler/lux.clj
+++ b/src/lux/compiler/lux.clj
@@ -34,13 +34,11 @@
(do-template [<name> <class> <sig> <caster>]
(defn <name> [compile *type* value]
(|do [^MethodVisitor *writer* &/get-writer
- :let [_ (try (doto *writer*
- (.visitTypeInsn Opcodes/NEW <class>)
- (.visitInsn Opcodes/DUP)
- (.visitLdcInsn (<caster> value))
- (.visitMethodInsn Opcodes/INVOKESPECIAL <class> "<init>" <sig>))
- (catch Exception e
- (assert false (prn-str '<name> (alength value) (aget value 0) (aget value 1)))))]]
+ :let [_ (doto *writer*
+ (.visitTypeInsn Opcodes/NEW <class>)
+ (.visitInsn Opcodes/DUP)
+ (.visitLdcInsn (<caster> value))
+ (.visitMethodInsn Opcodes/INVOKESPECIAL <class> "<init>" <sig>))]]
(return nil)))
compile-int "java/lang/Long" "(J)V" long