From a2faef20e0646a74dca82a0508a9892a8acc32f0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 14 Dec 2014 16:27:49 -0400 Subject: Added Java class imports. --- src/lang.clj | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'src/lang.clj') diff --git a/src/lang.clj b/src/lang.clj index d8b65afe6..5d5dd0c66 100644 --- a/src/lang.clj +++ b/src/lang.clj @@ -46,16 +46,61 @@ syntax (&parser/parse tokens) ;; _ (prn 'syntax syntax) ann-syntax (&analyser/analyse "test2" syntax) - _ (prn 'ann-syntax ann-syntax) + ;; _ (prn 'ann-syntax ann-syntax) class-data (&compiler/compile "test2" ann-syntax)] (write-file "test2.class" class-data)) - ;; TODO: Define functions as classes inheriting Function. - ;; TODO: Allow importing Java classes. + (let y ... + (lambda x (* x y))) + + (let y ... + (proxy Function1 + (apply1 [_ x] (* x y)))) + + (def (foo w x y z) + ($ * w x y z)) + => + (let f1 (proxy Function1 [w x y] + (apply1 [_ z] + (STATIC-METHOD w x y z))) + (let f2 (proxy Function2 [w x] + (apply1 [_ y] + f1) + (apply2 [_ y z] + (STATIC-METHOD w x y z))) + (proxy Function4 + (apply1 [_ w x] + (proxy Function3 [w] + (apply1 [_ x] + f2) + (apply2 [_ x y] + f1) + (apply3 [_ x y z] + (STATIC-METHOD w x y z)))) + (apply2 [_ w x] + f2) + (apply3 [_ w x y] + f1) + (apply4 [_ w x y z] + (STATIC-METHOD w x y z))))) + + + (proxy Function [] + (apply [_ w] + (proxy Function [w] + (apply [_ x] + (proxy Function [w x] + (apply [_ y] + (proxy Function [w x y] + (apply [_ z] + (STATIC-METHOD w x y z))))))))) + + ;; TODO: Allow using other modules. + ;; TODO: Define functions as classes inheriting Function. ;; TODO: Add tuples. - ;; TODO: Add thunks. ;; TODO: Add pattern-matching. + ;; TODO: Add thunks. ;; TODO: Add Java-interop. ;; TODO: Do tail-call optimization. ;; TODO: Add macros. -- cgit v1.2.3