Skip to content

Commit ba163ac

Browse files
committed
wip
1 parent b91c39e commit ba163ac

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/sci/impl/async_macro.cljc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,21 @@
3838
(list 'sci.impl.async-await/finally promise-expr callback))
3939

4040
(defn mark-promise
41-
"Mark a form as promise-producing. This marker is detected by promise-form?
42-
and stripped away by the analyzer."
41+
"Mark a form as promise-producing using metadata."
4342
[form]
44-
(list 'sci.impl.async-await/promise form))
43+
(vary-meta form assoc :sci.impl/promise true))
4544

4645
(defn- promise-form?
4746
"Check if form is already a promise-producing expression.
48-
Detects calls to sci.impl.async-await helpers and the promise marker."
47+
Detects metadata marker or calls to sci.impl.async-await helpers."
4948
[form]
50-
(and (seq? form)
51-
(let [op (first form)]
52-
(or (= 'sci.impl.async-await/then op)
53-
(= 'sci.impl.async-await/catch op)
54-
(= 'sci.impl.async-await/finally op)
55-
(= 'sci.impl.async-await/resolve op)
56-
(= 'sci.impl.async-await/promise op)))))
49+
(or (:sci.impl/promise (meta form))
50+
(and (seq? form)
51+
(let [op (first form)]
52+
(or (= 'sci.impl.async-await/then op)
53+
(= 'sci.impl.async-await/catch op)
54+
(= 'sci.impl.async-await/finally op)
55+
(= 'sci.impl.async-await/resolve op))))))
5756

5857
(defn- ensure-promise-result
5958
"Ensure async function body returns a promise.
@@ -300,8 +299,7 @@
300299
expanded (if (and (seq? body)
301300
(symbol? op)
302301
(not (contains? locals op)) ;; Don't expand if locally bound
303-
(not (#{'await 'let* 'loop* 'do 'fn* 'if 'quote 'try 'case*
304-
'sci.impl.async-await/promise} op)))
302+
(not (#{'await 'let* 'loop* 'do 'fn* 'if 'quote 'try 'case*} op)))
305303
(macroexpand/macroexpand-1 ctx body)
306304
body)]
307305
(if (not= expanded body)

src/sci/impl/namespaces.cljc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@
11271127
(js/Reflect.has obj k)))
11281128

11291129
;; Promise helpers for async/await transformation (CLJS only)
1130-
;; These provide efficient interop and serve as markers for promise-form? detection
1130+
;; These provide efficient interop as inlined functions
11311131
#?(:cljs
11321132
(do
11331133
(defn promise-resolve
@@ -2132,8 +2132,4 @@
21322132
'catch (new-var 'catch promise-catch async-await-namespace
21332133
{:sci.impl/inlined promise-catch})
21342134
'finally (new-var 'finally promise-finally async-await-namespace
2135-
{:sci.impl/inlined promise-finally})
2136-
;; Identity macro used as marker for promise-producing forms
2137-
;; Gets expanded away, leaving just the body
2138-
'promise (new-var 'promise (fn [_ _ body] body) async-await-namespace
2139-
{:macro true})}])}))
2135+
{:sci.impl/inlined promise-finally})}])}))

0 commit comments

Comments
 (0)