|
197 | 197 | (sorted-map))))))))))
|
198 | 198 | (emit* ast))
|
199 | 199 |
|
200 |
| -(defn emits [& xs] |
201 |
| - (doseq [^Object x xs] |
202 |
| - (cond |
203 |
| - (nil? x) nil |
204 |
| - #?(:clj (map? x) :cljs (ana/cljs-map? x)) (emit x) |
205 |
| - #?(:clj (seq? x) :cljs (ana/cljs-seq? x)) (apply emits x) |
206 |
| - #?(:clj (fn? x) :cljs ^boolean (goog/isFunction x)) (x) |
207 |
| - :else (let [^String s (cond-> x (not (string? x)) .toString)] |
| 200 | +(defn emits |
| 201 | + ([]) |
| 202 | + ([^Object a] |
| 203 | + (cond |
| 204 | + (nil? a) nil |
| 205 | + #?(:clj (map? a) :cljs (ana/cljs-map? a)) (emit a) |
| 206 | + #?(:clj (seq? a) :cljs (ana/cljs-seq? a)) (apply emits a) |
| 207 | + #?(:clj (fn? a) :cljs ^boolean (goog/isFunction a)) (a) |
| 208 | + :else (let [^String s (cond-> a (not (string? a)) .toString)] |
208 | 209 | (when-not (nil? *source-map-data*)
|
209 | 210 | (swap! *source-map-data*
|
210 | 211 | update-in [:gen-col] #(+ % (count s))))
|
211 | 212 | #?(:clj (.write ^Writer *out* s)
|
212 |
| - :cljs (print s))))) |
213 |
| - nil) |
214 |
| - |
215 |
| -(defn emitln [& xs] |
216 |
| - (apply emits xs) |
217 |
| - (binding [*flush-on-newline* false] |
218 |
| - (println)) |
| 213 | + :cljs (print s)))) |
| 214 | + nil) |
| 215 | + ([a b] |
| 216 | + (emits a) (emits b)) |
| 217 | + ([a b c] |
| 218 | + (emits a) (emits b) (emits c)) |
| 219 | + ([a b c d] |
| 220 | + (emits a) (emits b) (emits c) (emits d)) |
| 221 | + ([a b c d e] |
| 222 | + (emits a) (emits b) (emits c) (emits d) (emits e)) |
| 223 | + ([a b c d e & xs] |
| 224 | + (emits a) (emits b) (emits c) (emits d) (emits e) |
| 225 | + (doseq [x xs] (emits x)))) |
| 226 | + |
| 227 | +(defn ^:private _emitln [] |
| 228 | + (newline) |
219 | 229 | (when *source-map-data*
|
220 | 230 | (swap! *source-map-data*
|
221 | 231 | (fn [{:keys [gen-line] :as m}]
|
|
224 | 234 | :gen-col 0))))
|
225 | 235 | nil)
|
226 | 236 |
|
| 237 | +(defn emitln |
| 238 | + ([] (_emitln)) |
| 239 | + ([a] |
| 240 | + (emits a) (_emitln)) |
| 241 | + ([a b] |
| 242 | + (emits a) (emits b) (_emitln)) |
| 243 | + ([a b c] |
| 244 | + (emits a) (emits b) (emits c) (_emitln)) |
| 245 | + ([a b c d] |
| 246 | + (emits a) (emits b) (emits c) (emits d) (_emitln)) |
| 247 | + ([a b c d e] |
| 248 | + (emits a) (emits b) (emits c) (emits d) (emits e) (_emitln)) |
| 249 | + ([a b c d e & xs] |
| 250 | + (emits a) (emits b) (emits c) (emits d) (emits e) |
| 251 | + (doseq [x xs] (emits x)) |
| 252 | + (_emitln))) |
| 253 | + |
227 | 254 | (defn ^String emit-str [expr]
|
228 | 255 | (with-out-str (emit expr)))
|
229 | 256 |
|
|
0 commit comments