|
330 | 330 | (defmethod emit* :no-op [m])
|
331 | 331 |
|
332 | 332 | (defmethod emit* :var
|
333 |
| - [{:keys [info env form] :as arg}] |
334 |
| - (let [var-name (:name info) |
335 |
| - info (if (= (namespace var-name) "js") |
336 |
| - (let [js-module-name (get-in @env/*compiler* [:js-module-index (name var-name)])] |
337 |
| - (or js-module-name (name var-name))) |
338 |
| - info)] |
339 |
| - ; We need a way to write bindings out to source maps and javascript |
340 |
| - ; without getting wrapped in an emit-wrap calls, otherwise we get |
341 |
| - ; e.g. (function greet(return x, return y) {}). |
342 |
| - (if (:binding-form? arg) |
343 |
| - ; Emit the arg map so shadowing is properly handled when munging |
344 |
| - ; (prevents duplicate fn-param-names) |
345 |
| - (emits (munge arg)) |
346 |
| - (when-not (= :statement (:context env)) |
347 |
| - (emit-wrap env |
348 |
| - (emits |
349 |
| - (cond-> info |
350 |
| - (not= form 'js/-Infinity) munge))))))) |
| 333 | + [{:keys [info env form] :as ast}] |
| 334 | + (if-let [const-expr (:const-expr ast)] |
| 335 | + (emit const-expr) |
| 336 | + (let [var-name (:name info) |
| 337 | + info (if (= (namespace var-name) "js") |
| 338 | + (let [js-module-name (get-in @env/*compiler* [:js-module-index (name var-name)])] |
| 339 | + (or js-module-name (name var-name))) |
| 340 | + info)] |
| 341 | + ; We need a way to write bindings out to source maps and javascript |
| 342 | + ; without getting wrapped in an emit-wrap calls, otherwise we get |
| 343 | + ; e.g. (function greet(return x, return y) {}). |
| 344 | + (if (:binding-form? ast) |
| 345 | + ; Emit the arg map so shadowing is properly handled when munging |
| 346 | + ; (prevents duplicate fn-param-names) |
| 347 | + (emits (munge ast)) |
| 348 | + (when-not (= :statement (:context env)) |
| 349 | + (emit-wrap env |
| 350 | + (emits |
| 351 | + (cond-> info |
| 352 | + (not= form 'js/-Infinity) munge)))))))) |
351 | 353 |
|
352 | 354 | (defmethod emit* :var-special
|
353 | 355 | [{:keys [env var sym meta] :as arg}]
|
|
0 commit comments