aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser/host.clj
diff options
context:
space:
mode:
authorEduardo Julian2016-06-13 23:15:32 -0400
committerEduardo Julian2016-06-13 23:15:32 -0400
commit7caca63387e14d3a6202120f75ae0056f9ddc17f (patch)
treed758f85f7d28e41d21b4e81cb819ea29eb2471a7 /src/lux/analyser/host.clj
parentc711eb3f90ea3a160b662f8bc5e16306db57c197 (diff)
- Implemented a procedure for loading JVM classes.
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/host.clj14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index a677b7973..9cf23b44a 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -858,6 +858,19 @@
(return (&/|list (&&/|meta output-type _cursor
(&&/$proc (&/T ["jvm" "instanceof"]) (&/|list =object) (&/|list class)))))))
+(defn ^:private analyse-jvm-load-class [analyse exo-type ?values]
+ (|do [:let [(&/$Cons [_ (&/$TextS _class-name)] (&/$Nil)) ?values]
+ class-loader &/loader
+ _ (try (do (.loadClass class-loader _class-name)
+ (return nil))
+ (catch Exception e
+ (&/fail-with-loc (str "[Analyser Error] Unknown class: " _class-name))))
+ :let [output-type (&/$HostT "java.lang.Class" (&/|list (&/$HostT _class-name (&/|list))))]
+ _ (&type/check exo-type output-type)
+ _cursor &/cursor]
+ (return (&/|list (&&/|meta output-type _cursor
+ (&&/$proc (&/T ["jvm" "load-class"]) (&/|list) (&/|list _class-name output-type)))))))
+
(let [length-type &type/Int
idx-type &type/Int]
(defn ^:private analyse-array-new [analyse exo-type ?values]
@@ -991,6 +1004,7 @@
"jvm"
(case proc
+ "load-class" (analyse-jvm-load-class analyse exo-type ?values)
"try" (analyse-jvm-try analyse exo-type ?values)
"throw" (analyse-jvm-throw analyse exo-type ?values)
"monitorenter" (analyse-jvm-monitorenter analyse exo-type ?values)