aboutsummaryrefslogtreecommitdiff
path: root/source/lux/host
diff options
context:
space:
mode:
authorEduardo Julian2015-07-26 23:09:47 -0400
committerEduardo Julian2015-07-26 23:09:47 -0400
commit8fb7683f9029127be9cf36336c367813c88f681b (patch)
treef90c677183cb46b04b70550614a78befa44480a4 /source/lux/host
parent9b7cfd6f5bcc93e2f2f0c3129b7ec6d62c69bb37 (diff)
- Changed the name of lux/host/java to lux/host/jvm
- Completed lux/host/jvm - Modified (slightly) the syntax used in several host (JVM) special forms. - The "defsyntax" macro now binds all of the arguments it receives inside a variable named "tokens".
Diffstat (limited to 'source/lux/host')
-rw-r--r--source/lux/host/jvm.lux (renamed from source/lux/host/java.lux)178
1 files changed, 69 insertions, 109 deletions
diff --git a/source/lux/host/java.lux b/source/lux/host/jvm.lux
index 9bd0c838c..a3a74d608 100644
--- a/source/lux/host/java.lux
+++ b/source/lux/host/jvm.lux
@@ -16,7 +16,8 @@
macro
syntax)))
-## [Utils/Parsers]
+## [Utils]
+## Parsers
(def finally^
(Parser Syntax)
(form^ (do Parser/Monad
@@ -88,20 +89,6 @@
(M;wrap [method arity-classes arity-args])
)))
-## [Utils/Lux]
-## (def (find-class-field field class)
-## (-> Text Text (Lux Type))
-## ...)
-
-## (def (find-virtual-method method class)
-## (-> Text Text (Lux (List (, (List Type) Type))))
-## ...)
-
-## (def (find-static-method method class)
-## (-> Text Text (Lux (List (, (List Type) Type))))
-## ...)
-
-
## [Syntax]
(defsyntax #export (throw ex)
(emit (list (` (_jvm_throw (~ ex))))))
@@ -192,100 +179,73 @@
(emit (list (` (_jvm_program (~ (symbol$ args))
(~ body))))))
-## (defsyntax #export (.? [field local-symbol^] obj)
-## (case obj
-## (#;Meta [_ (#;SymbolS obj-name)])
-## (do Lux/Monad
-## [obj-type (find-var-type obj-name)]
-## (case obj-type
-## (#;DataT class)
-## (do Lux/Monad
-## [field-class (find-field field class)]
-## (_jvm_getfield (~ (text$ class)) (~ (text$ field)) (~ (text$ field-class))))
-
-## _
-## (fail "Can only get field from object.")))
-
-## _
-## (do Lux/Monad
-## [g!obj (gensym "")]
-## (emit (list (` (;let [(~ g!obj) (~ obj)]
-## (.? (~ field) (~ g!obj)))))))))
-
-## (defsyntax #export (.= [field local-symbol^] value obj)
-## (case obj
-## (#;Meta [_ (#;SymbolS obj-name)])
-## (do Lux/Monad
-## [obj-type (find-var-type obj-name)]
-## (case obj-type
-## (#;DataT class)
-## (do Lux/Monad
-## [field-class (find-field field class)]
-## (_jvm_putfield (~ (text$ class)) (~ (text$ field)) (~ (text$ field-class)) (~ value)))
-
-## _
-## (fail "Can only set field of object.")))
-
-## _
-## (do Lux/Monad
-## [g!obj (gensym "")]
-## (emit (list (` (;let [(~ g!obj) (~ obj)]
-## (.= (~ field) (~ value) (~ g!obj)))))))))
-
-## (defsyntax #export (.! [call method-call^] obj)
-## (case obj
-## (#;Meta [_ (#;SymbolS obj-name)])
-## (do Lux/Monad
-## [obj-type (find-var-type obj-name)]
-## (case obj-type
-## (#;DataT class)
-## (do Lux/Monad
-## [#let [[m-name ?m-classes m-args] call]
-## all-m-details (find-virtual-method m-name class)
-## m-ins (case [?m-classes all-m-details]
-## (\ [#;None (list [m-ins m-out])])
-## (M;wrap m-ins)
-
-## (\ [(#;Some m-ins) _])
-## (M;wrap m-ins)
-
-## _
-## #;None)]
-## (emit (list (` (_jvm_invokevirtual (~ (text$ m-name)) (~ (text$ class)) [(~@ (:: List/Functor (F;map text$ m-ins)))]
-## (~ obj) [(~@ m-args)])))))
-
-## _
-## (fail "Can only call method on object.")))
-
-## _
-## (do Lux/Monad
-## [g!obj (gensym "")]
-## (emit (list (` (;let [(~ g!obj) (~ obj)]
-## (.! (~@ *tokens*)))))))))
-
-## (defsyntax #export (..? [field local-symbol^] [class local-symbol^])
-## (emit (list (` (_jvm_getstatic (~ (text$ class)) (~ (text$ field)))))))
-
-## (defsyntax #export (..= [field local-symbol^] value [class local-symbol^])
-## (emit (list (` (_jvm_putstatic (~ (text$ class)) (~ (text$ field)) (~ value))))))
-
-## (defsyntax #export (..! [call method-call^] [class local-symbol^])
-## (do Lux/Monad
-## [#let [[m-name ?m-classes m-args] call]
-## all-m-details (find-static-method m-name class)
-## m-ins (case [?m-classes all-m-details]
-## (\ [#;None (list [m-ins m-out])])
-## (M;wrap m-ins)
-
-## (\ [(#;Some m-ins) _])
-## (M;wrap m-ins)
-
-## _
-## #;None)]
-## (emit (list (` (_jvm_invokestatic (~ (text$ m-name)) (~ (text$ class))
-## [(~@ (:: List/Functor (F;map text$ m-ins)))]
-## [(~@ m-args)]))))
-## ))
+(defsyntax #export (.? [field local-symbol^] obj)
+ (case obj
+ (#;Meta [_ (#;SymbolS obj-name)])
+ (do Lux/Monad
+ [obj-type (find-var-type obj-name)]
+ (case obj-type
+ (#;DataT class)
+ (emit (list (` (_jvm_getfield (~ (text$ class)) (~ (text$ field))))))
+
+ _
+ (fail "Can only get field from object.")))
+
+ _
+ (do Lux/Monad
+ [g!obj (gensym "")]
+ (emit (list (` (;let [(~ g!obj) (~ obj)]
+ (.? (~ (text$ field)) (~ g!obj)))))))))
+
+(defsyntax #export (.= [field local-symbol^] value obj)
+ (case obj
+ (#;Meta [_ (#;SymbolS obj-name)])
+ (do Lux/Monad
+ [obj-type (find-var-type obj-name)]
+ (case obj-type
+ (#;DataT class)
+ (emit (list (` (_jvm_putfield (~ (text$ class)) (~ (text$ field)) (~ value)))))
+
+ _
+ (fail "Can only set field of object.")))
+
+ _
+ (do Lux/Monad
+ [g!obj (gensym "")]
+ (emit (list (` (;let [(~ g!obj) (~ obj)]
+ (.= (~ (text$ field)) (~ value) (~ g!obj)))))))))
+
+(defsyntax #export (.! [call method-call^] obj)
+ (case obj
+ (#;Meta [_ (#;SymbolS obj-name)])
+ (do Lux/Monad
+ [obj-type (find-var-type obj-name)]
+ (case obj-type
+ (#;DataT class)
+ (let [[m-name ?m-classes m-args] call]
+ (emit (list (` (_jvm_invokevirtual (~ (text$ class)) (~ (text$ m-name)) [(~@ (map text$ ?m-classes))]
+ (~ obj) [(~@ m-args)])))))
+
+ _
+ (fail "Can only call method on object.")))
+
+ _
+ (do Lux/Monad
+ [g!obj (gensym "")]
+ (emit (list (` (;let [(~ g!obj) (~ obj)]
+ (.! (~@ *tokens*)))))))))
+
+(defsyntax #export (..? [field local-symbol^] [class local-symbol^])
+ (emit (list (` (_jvm_getstatic (~ (text$ class)) (~ (text$ field)))))))
+
+(defsyntax #export (..= [field local-symbol^] value [class local-symbol^])
+ (emit (list (` (_jvm_putstatic (~ (text$ class)) (~ (text$ field)) (~ value))))))
+
+(defsyntax #export (..! [call method-call^] [class local-symbol^])
+ (let [[m-name m-classes m-args] call]
+ (emit (list (` (_jvm_invokestatic (~ (text$ class)) (~ (text$ m-name))
+ [(~@ (map text$ m-classes))]
+ [(~@ m-args)]))))))
## (definterface Function []
## (#public #abstract apply [java.lang.Object] java.lang.Object))