diff options
author | Eduardo Julian | 2014-12-12 19:07:58 -0400 |
---|---|---|
committer | Eduardo Julian | 2014-12-12 19:07:58 -0400 |
commit | 8f5cd3917fd3a94ae99710a614dce9028f9afad8 (patch) | |
tree | 3a6b14a058ddebb1673042846fe05dd2ff195468 /src/lang/compiler.clj | |
parent | 5b4e9f024b19f5f246d3ddeb3d7e5f5b53d4ac47 (diff) |
Added let (local vars).
Diffstat (limited to 'src/lang/compiler.clj')
-rw-r--r-- | src/lang/compiler.clj | 14 |
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 |