|
206 | 206 | [buffer] |
207 | 207 | (let [nl (first buffer) |
208 | 208 | block (.-block nl) |
209 | | - ;;_ (pdebug "nl-block=" (python/id (.-block nl)) " " (.-block nl)) |
210 | 209 | comparator (fn [token] |
211 | | - (if (instance? Newline token) |
212 | | - (let [is-ancestor? (ancestor? (.-block token) block)] |
213 | | - #_(pdebug "token=" [(.-kind token) (.-block token)] |
214 | | - " block=" block |
215 | | - " is-ancestor?=" is-ancestor?) |
216 | | - is-ancestor?) |
217 | | - false))] |
| 210 | + (and (instance? Newline token) |
| 211 | + (ancestor? (.-block token) block)))] |
218 | 212 | (split-queue-with comparator (pop buffer)))) |
219 | 213 |
|
220 | 214 | (defprotocol PrettyWriter |
|
300 | 294 | EndBlock (.-suffix (.-block token)))] |
301 | 295 | (.write writer s)))) |
302 | 296 |
|
303 | | - ;; Write a single line and possibly emit a trailing conditional newline. |
| 297 | + ;; Write a single line and possibly emit a conditional newline. |
304 | 298 | (write-line [] |
305 | 299 | (let [{:keys [buffer]} @state |
306 | 300 | [s buf] (split-at-newline buffer)] |
307 | | - #_(pdebug {:buffer (map repr buf) :s (map repr s)}) |
308 | 301 | (when (seq s) |
309 | 302 | (write-tokens s)) |
310 | 303 | (vswap! state #(assoc % :buffer buf)) |
311 | 304 | ;; check if buffer still exceeds length; if so, we'll need to emit newlines |
312 | 305 | (when (seq buf) |
313 | 306 | (let [[section remainder] (get-section buf) |
314 | | - ;;_ (pdebug {:section (map repr section) |
315 | | - ;; :remainder (map repr remainder)}) |
316 | 307 | maybe-nl (first buf) |
317 | 308 | buf (if (emit-nl? maybe-nl section) |
318 | 309 | (do |
|
321 | 312 | buf)] |
322 | 313 | (if-not (tokens-fit? buf) |
323 | 314 | (do |
324 | | - #_(pdebug "writing section " (map repr section)) |
325 | 315 | (write-tokens section) |
326 | 316 | (vswap! state #(assoc % :buffer remainder))) |
327 | 317 | (vswap! state #(assoc % :buffer buf))))))) |
|
654 | 644 | [obj] |
655 | 645 | (print-map "#py {" "}" (.items obj))) |
656 | 646 |
|
| 647 | +;; Disambiguate `Var` from `IDeref` |
| 648 | +(defmethod simple-dispatch basilisp.lang.runtime/Var |
| 649 | + [obj] |
| 650 | + (pr obj)) |
| 651 | + |
657 | 652 | (defmethod simple-dispatch basilisp.lang.interfaces/IDeref |
658 | 653 | [obj] |
659 | 654 | (let [classname (.-__name__ (.-__class__ obj)) |
|
0 commit comments