Skip to content

Commit

Permalink
Emit Var objects from dynamic defs
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonbloom committed Mar 18, 2012
1 parent 1c60dbc commit ea71556
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/clj/cljs/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@
[{:keys [name init env doc export dynamic]}]
(when init
(emit-comment doc (:jsdoc init)))
(print name)
(print (str " = " (if init (emits init) "undefined")))
(print name "="
(let [inits (if init (emits init) "undefined")]
(if dynamic
(let [syms (with-out-str (emit-constant (symbol name)))]
(str "new cljs.core.Var(" syms ", " inits ")"))
inits)))
(when-not (= :expr (:context env))
(print ";\n"))
(when export
Expand Down
2 changes: 2 additions & 0 deletions src/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,8 @@ reduces them without incurring seq initialization"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Reference Types ;;;;;;;;;;;;;;;;

(deftype Var [sym root])

(deftype Atom [state meta validator watches]
IEquiv
(-equiv [o other] (identical? o other))
Expand Down

0 comments on commit ea71556

Please sign in to comment.