From da4968b5873fcebdf91e1bae58674ff3d5346e0d Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 23 Jul 2016 00:12:22 -0400 Subject: - Added object/reference/pointer testing. --- src/lux/analyser/host.clj | 15 +++++++++++++++ src/lux/compiler/host.clj | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index cc136b066..76c499f10 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -1035,9 +1035,24 @@ ^:private analyse-bit-unsigned-shift-right "unsigned-shift-right" ) +(defn ^:private analyse-lux-== [analyse exo-type ?values] + (&type/with-var + (fn [$var] + (|do [:let [(&/$Cons left (&/$Cons right (&/$Nil))) ?values] + =left (&&/analyse-1 analyse $var left) + =right (&&/analyse-1 analyse $var right) + _ (&type/check exo-type &type/Bool) + _cursor &/cursor] + (return (&/|list (&&/|meta exo-type _cursor + (&&/$proc (&/T ["lux" "=="]) (&/|list =left =right) (&/|list))))))))) + (defn analyse-host [analyse exo-type compilers category proc ?values] (|let [[_ _ compile-class compile-interface] compilers] (case category + "lux" + (case proc + "==" (analyse-lux-== analyse exo-type ?values)) + "bit" (case proc "and" (analyse-bit-and analyse exo-type ?values) diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj index 29c58e056..1f055e10f 100644 --- a/src/lux/compiler/host.clj +++ b/src/lux/compiler/host.clj @@ -1378,8 +1378,29 @@ ^:private compile-bit-unsigned-shift-right Opcodes/LUSHR ) +(defn ^:private compile-lux-== [compile ?values special-args] + (|do [:let [(&/$Cons ?left (&/$Cons ?right (&/$Nil))) ?values] + ^MethodVisitor *writer* &/get-writer + _ (compile ?left) + _ (compile ?right) + :let [$then (new Label) + $end (new Label) + _ (doto *writer* + (.visitJumpInsn Opcodes/IF_ACMPEQ $then) + ;; else + (.visitFieldInsn Opcodes/GETSTATIC "java/lang/Boolean" "FALSE" "Ljava/lang/Boolean;") + (.visitJumpInsn Opcodes/GOTO $end) + (.visitLabel $then) + (.visitFieldInsn Opcodes/GETSTATIC "java/lang/Boolean" "TRUE" "Ljava/lang/Boolean;") + (.visitLabel $end))]] + (return nil))) + (defn compile-host [compile proc-category proc-name ?values special-args] (case proc-category + "lux" + (case proc-name + "==" (compile-lux-== compile ?values special-args)) + "bit" (case proc-name "and" (compile-bit-and compile ?values special-args) -- cgit v1.2.3