aboutsummaryrefslogtreecommitdiff
path: root/src/lang
diff options
context:
space:
mode:
authorEduardo Julian2014-12-21 01:19:59 -0400
committerEduardo Julian2014-12-21 01:19:59 -0400
commit4dc96027d8e90734aea3a5e109b8786fc112e88b (patch)
tree37cbeb650fd283608c59cd421889621b5de7a611 /src/lang
parent42940f107ebd3aa944ea06d4d4a577e58a3eeea7 (diff)
The machinery is in place to allow loading modules at runtime.
Diffstat (limited to 'src/lang')
-rw-r--r--src/lang/compiler.clj35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lang/compiler.clj b/src/lang/compiler.clj
index f1a78ed89..1595fe58e 100644
--- a/src/lang/compiler.clj
+++ b/src/lang/compiler.clj
@@ -134,9 +134,9 @@
(defcompiler ^:private compile-captured
[::&analyser/captured ?scope ?captured-id ?source]
(do ;; (prn 'CAPTURED [?scope ?captured-id])
- (doto *writer*
- (.visitVarInsn Opcodes/ALOAD 0)
- (.visitFieldInsn Opcodes/GETFIELD (apply str (interpose "$" ?scope)) (str "__" ?captured-id) "Ljava/lang/Object;"))))
+ (doto *writer*
+ (.visitVarInsn Opcodes/ALOAD 0)
+ (.visitFieldInsn Opcodes/GETFIELD (apply str (interpose "$" ?scope)) (str "__" ?captured-id) "Ljava/lang/Object;"))))
(defcompiler ^:private compile-global
[::&analyser/global ?owner-class ?name]
@@ -203,8 +203,8 @@
(do ;; (prn 'compile-static-field ?owner ?field)
;; (assert false)
(compile-form (assoc *state* :form ?target))
- (doto *writer*
- (.visitFieldInsn Opcodes/GETFIELD (->class ?owner) ?field (->java-sig *type*)))
+ (doto *writer*
+ (.visitFieldInsn Opcodes/GETFIELD (->class ?owner) ?field (->java-sig *type*)))
))
(defcompiler ^:private compile-static-method
@@ -221,13 +221,13 @@
(defcompiler ^:private compile-dynamic-method
[::&analyser/dynamic-method ?target ?owner ?method-name ?method-type ?args]
(do ;; (prn 'compile-dynamic-access ?target ?owner ?method-name ?method-type ?args)
- ;; (assert false)
- (do (compile-form (assoc *state* :form ?target))
- (doseq [arg ?args]
- (compile-form (assoc *state* :form arg)))
- (doto *writer*
- (.visitMethodInsn Opcodes/INVOKEVIRTUAL (->class ?owner) ?method-name (method->sig ?method-type))
- (.visitInsn Opcodes/ACONST_NULL)))
+ ;; (assert false)
+ (do (compile-form (assoc *state* :form ?target))
+ (doseq [arg ?args]
+ (compile-form (assoc *state* :form arg)))
+ (doto *writer*
+ (.visitMethodInsn Opcodes/INVOKEVIRTUAL (->class ?owner) ?method-name (method->sig ?method-type))
+ (.visitInsn Opcodes/ACONST_NULL)))
))
(defcompiler ^:private compile-if
@@ -681,4 +681,13 @@
(when (not (compile-form (assoc state :form input)))
(assert false input)))
(.visitEnd =class)
- (.toByteArray =class)))
+ (.toByteArray =class))
+
+ (comment
+ (-> (java.io.File. "./") .toURL vector into-array java.net.URLClassLoader. (.loadClass "test2"))
+ (-> (java.io.File. "./") .toURL vector into-array java.net.URLClassLoader. (.loadClass "test2.Function"))
+ (let [test2 (-> (java.io.File. "./") .toURL vector into-array java.net.URLClassLoader. (.loadClass "test2"))
+ main (first (.getDeclaredMethods test2))]
+ (.invoke main nil (to-array [nil])))
+ )
+ )