aboutsummaryrefslogtreecommitdiff
path: root/src/lang/compiler.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/lang/compiler.clj')
-rw-r--r--src/lang/compiler.clj14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lang/compiler.clj b/src/lang/compiler.clj
index a71a66b8b..8b73720c4 100644
--- a/src/lang/compiler.clj
+++ b/src/lang/compiler.clj
@@ -127,6 +127,19 @@
(assert (compile-form (assoc *state* :form ?else)) "CAN't COMPILE ELSE")
(.visitLabel *writer* end-label)))
+(defcompiler ^:private compile-let
+ [::&analyser/let ?idx ?label ?value ?body]
+ (let [start-label (new Label)
+ end-label (new Label)
+ ?idx (int ?idx)]
+ (.visitLocalVariable *writer* ?label (->java-sig (:type ?value)) nil start-label end-label ?idx)
+ (assert (compile-form (assoc *state* :form ?value)) "CAN't COMPILE LET-VALUE")
+ (doto *writer*
+ (.visitVarInsn Opcodes/ASTORE ?idx)
+ (.visitLabel start-label))
+ (assert (compile-form (assoc *state* :form ?body)) "CAN't COMPILE LET-BODY")
+ (.visitLabel *writer* end-label)))
+
(defcompiler ^:private compile-def
[::&analyser/def ?form ?body]
(match ?form
@@ -221,6 +234,7 @@
compile-dynamic-access
compile-ann-class
compile-if
+ compile-let
compile-def
compile-module
compile-defclass