diff options
author | Eduardo Julian | 2016-12-06 21:39:26 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-06 21:39:26 -0400 |
commit | 75a02fc2df03a21df044d35115ac72149524ca7a (patch) | |
tree | 84292b8de5f7e1f400641d7061ff6d5617d9b792 /stdlib/source | |
parent | 3a32ba13ae6507c0b842853cc9a83fb443c2f480 (diff) |
- Updated lux/host tests.
- Fixed a bug in the way the [jvm l2b] and [jvm l2s] procedures worked.
- Fixed a bug in interface definition.
- Relaxed the syntacting requirements of class/interface/anonymous-class definition macros.
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/host.lux | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/stdlib/source/lux/host.lux b/stdlib/source/lux/host.lux index 7149cab94..92ff61d92 100644 --- a/stdlib/source/lux/host.lux +++ b/stdlib/source/lux/host.lux @@ -1327,8 +1327,10 @@ imports (add-import [(short-class-name full-class-name) full-class-name] (class-imports *compiler*))]} {#let [class-vars (product;right class-decl)]} - {super (s;opt (super-class-decl^ imports class-vars))} - {interfaces (s;tuple (s;some (super-class-decl^ imports class-vars)))} + {super (s;default object-super-class + (super-class-decl^ imports class-vars))} + {interfaces (s;default (list) + (s;tuple (s;some (super-class-decl^ imports class-vars))))} {annotations (annotations^ imports)} {fields (s;some (field-decl^ imports class-vars))} {methods (s;some (method-def^ imports class-vars))}) @@ -1340,11 +1342,11 @@ (#private datum A) (#private waitingList (java.util.List lux.Function)) ## Methods - (#public new [] [] [] + (#public [] new [] [] (exec (:= .resolved false) (:= .waitingList (ArrayList.new [])) [])) - (#public resolve [] [{value A}] boolean + (#public [] resolve [{value A}] boolean (let [container (.new! [])] (synchronized _jvm_this (if .resolved @@ -1360,18 +1362,18 @@ (i.range 0 (i.dec (i2l sleepers-count))))) (:= .waitingList (null)) true))))) - (#public poll [] [] A + (#public [] poll [] A .datum) - (#public wasResolved [] [] boolean + (#public [] wasResolved [] boolean (synchronized _jvm_this .resolved)) - (#public waitOn [] [{callback lux.Function}] void + (#public [] waitOn [{callback lux.Function}] void (synchronized _jvm_this (exec (if .resolved (lux.Function.apply [(:! Object .datum)] callback) (:! Object (java.util.List.add [callback] .waitingList))) []))) - (#public #static make [A] [{value A}] (lux.concurrency.promise.JvmPromise A) + (#public #static [A] make [{value A}] (lux.concurrency.promise.JvmPromise A) (let [container (.new! [])] (exec (.resolve! (:! (host lux.concurrency.promise.JvmPromise [Unit]) container) [(:! Unit value)]) container)))) @@ -1393,15 +1395,14 @@ replacer (parser->replacer (fold s;either (s;fail "") (List/append field-parsers method-parsers))) - super-class (default object-super-class super) def-code (format "class:" (spaced (list (class-decl$ class-decl) - (super-class-decl$ super-class) + (super-class-decl$ super) (with-brackets (spaced (map super-class-decl$ interfaces))) (inheritance-modifier$ im) (with-brackets (spaced (map annotation$ annotations))) (with-brackets (spaced (map field-decl$ fields))) - (with-brackets (spaced (map (method-def$ replacer super-class) methods))))))]] + (with-brackets (spaced (map (method-def$ replacer super) methods))))))]] (wrap (list (` (;_lux_proc ["jvm" (~ (ast;text def-code))] [])))))) (syntax: #export (interface: {#let [imports (class-imports *compiler*)]} @@ -1410,7 +1411,8 @@ imports (add-import [(short-class-name full-class-name) full-class-name] (class-imports *compiler*))]} {#let [class-vars (product;right class-decl)]} - {supers (s;tuple (s;some (super-class-decl^ imports class-vars)))} + {supers (s;default (list) + (s;tuple (s;some (super-class-decl^ imports class-vars))))} {annotations (annotations^ imports)} {members (s;some (method-decl^ imports class-vars))}) (let [def-code (format "interface:" @@ -1423,8 +1425,10 @@ (syntax: #export (object {#let [imports (class-imports *compiler*)]} {#let [class-vars (list)]} - {super (s;opt (super-class-decl^ imports class-vars))} - {interfaces (s;tuple (s;some (super-class-decl^ imports class-vars)))} + {super (s;default object-super-class + (super-class-decl^ imports class-vars))} + {interfaces (s;default (list) + (s;tuple (s;some (super-class-decl^ imports class-vars))))} {constructor-args (constructor-args^ imports class-vars)} {methods (s;some (overriden-method-def^ imports))}) {#;doc (doc "Allows defining anonymous classes." @@ -1437,12 +1441,11 @@ (exec (do-something some-input) []))) )} - (let [super-class (default object-super-class super) - def-code (format "anon-class:" - (spaced (list (super-class-decl$ super-class) + (let [def-code (format "anon-class:" + (spaced (list (super-class-decl$ super) (with-brackets (spaced (map super-class-decl$ interfaces))) (with-brackets (spaced (map constructor-arg$ constructor-args))) - (with-brackets (spaced (map (method-def$ id super-class) methods))))))] + (with-brackets (spaced (map (method-def$ id super) methods))))))] (wrap (list (` (;_lux_proc ["jvm" (~ (ast;text def-code))] [])))))) (syntax: #export (null) |