|
527 | 527 | (defmethod emit* :def
|
528 | 528 | [{:keys [name var init env doc jsdoc export test var-ast]}]
|
529 | 529 | (let [mname (munge name)]
|
| 530 | + (emit-comment doc (concat jsdoc (:jsdoc init))) |
| 531 | + (when (:def-emits-var env) |
| 532 | + (when (= :return (:context env)) |
| 533 | + (emitln "return (")) |
| 534 | + (emitln "(function (){")) |
| 535 | + (emits var) |
530 | 536 | (when init
|
531 |
| - (emit-comment doc (concat jsdoc (:jsdoc init))) |
532 |
| - (when (:def-emits-var env) |
533 |
| - (when (= :return (:context env)) |
534 |
| - (emitln "return (")) |
535 |
| - (emitln "(function (){")) |
536 |
| - (emits var) |
537 | 537 | (emits " = "
|
538 |
| - (if-let [define (get-define mname jsdoc)] |
539 |
| - define |
540 |
| - init)) |
541 |
| - (when (:def-emits-var env) |
542 |
| - (emitln "; return (") |
543 |
| - (emits (merge |
544 |
| - {:op :var-special |
545 |
| - :env (assoc env :context :expr)} |
546 |
| - var-ast)) |
547 |
| - (emitln ");})()") |
548 |
| - (when (= :return (:context env)) |
549 |
| - (emitln ")"))) |
550 |
| - ;; NOTE: JavaScriptCore does not like this under advanced compilation |
551 |
| - ;; this change was primarily for REPL interactions - David |
552 |
| - ;(emits " = (typeof " mname " != 'undefined') ? " mname " : undefined") |
553 |
| - (when-not (= :expr (:context env)) (emitln ";")) |
554 |
| - (when export |
555 |
| - (emitln "goog.exportSymbol('" (munge export) "', " mname ");")) |
556 |
| - (when (and ana/*load-tests* test) |
557 |
| - (when (= :expr (:context env)) |
558 |
| - (emitln ";")) |
559 |
| - (emitln var ".cljs$lang$test = " test ";"))))) |
| 538 | + (if-let [define (get-define mname jsdoc)] |
| 539 | + define |
| 540 | + init))) |
| 541 | + (when (:def-emits-var env) |
| 542 | + (emitln "; return (") |
| 543 | + (emits (merge |
| 544 | + {:op :var-special |
| 545 | + :env (assoc env :context :expr)} |
| 546 | + var-ast)) |
| 547 | + (emitln ");})()") |
| 548 | + (when (= :return (:context env)) |
| 549 | + (emitln ")"))) |
| 550 | + ;; NOTE: JavaScriptCore does not like this under advanced compilation |
| 551 | + ;; this change was primarily for REPL interactions - David |
| 552 | + ;(emits " = (typeof " mname " != 'undefined') ? " mname " : undefined") |
| 553 | + (when-not (= :expr (:context env)) (emitln ";")) |
| 554 | + (when export |
| 555 | + (emitln "goog.exportSymbol('" (munge export) "', " mname ");")) |
| 556 | + (when (and ana/*load-tests* test) |
| 557 | + (when (= :expr (:context env)) |
| 558 | + (emitln ";")) |
| 559 | + (emitln var ".cljs$lang$test = " test ";")))) |
560 | 560 |
|
561 | 561 | (defn emit-apply-to
|
562 | 562 | [{:keys [name params env]}]
|
|
0 commit comments