aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEduardo Julian2015-09-12 17:28:30 -0400
committerEduardo Julian2015-09-12 17:28:30 -0400
commit3c1e63b8ea119601f6ba2c9eb709877c76683a8c (patch)
treef1e6dcaef89e27eca1a030ffc48afc38aaa0276f /source
parent5fd179352bbf25bbe4000ae51132fd5553ba256a (diff)
- Added full support for arrays.
Diffstat (limited to 'source')
-rw-r--r--source/lux/host/jvm.lux14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/lux/host/jvm.lux b/source/lux/host/jvm.lux
index c1e122bb6..ba29925a7 100644
--- a/source/lux/host/jvm.lux
+++ b/source/lux/host/jvm.lux
@@ -7,9 +7,9 @@
(lux (control (monoid #as m)
(functor #as F)
(monad #as M #refer (#only do)))
- (data (list #as l #refer #all #open ("" List/Functor))
- (text #as text)
- number/int)
+ (data (list #refer #all #open ("" List/Functor List/Fold))
+ (number/int #refer #all #open ("i:" Int/Ord))
+ maybe)
(meta lux
ast
syntax)))
@@ -107,3 +107,11 @@
(emit (@list (` (;_jvm_try (#;Right (~ expr))
(~ (' (_jvm_catch "java.lang.Exception" e
(#;Left (_jvm_invokevirtual "java.lang.Throwable" "getMessage" [] e []))))))))))
+
+(defsyntax #export (Array [dimensions (?^ int^)] type)
+ (let [dimensions (? 1 dimensions)]
+ (if (i:> dimensions 0)
+ (emit (@list (foldL (lambda [inner _] (` (#;DataT "Array" (@list (~ inner)))))
+ type
+ (repeat dimensions []))))
+ (fail "Array must have positive dimension."))))