Commit 7a15c464 authored by Raymond Toy's avatar Raymond Toy
Browse files

Merge branch 'issue-173-pprint-def-assem-routine' into 'master'

Fix #173: Add pprinter for define-assembly-routine

Closes #173

See merge request !126
parents 9d32d69a b2f6ab4c
Loading
Loading
Loading
Loading
Loading
+38 −1
Changes for src/code/pprint.lisp: 38 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1920,6 +1920,42 @@ When annotations are present, invoke them at the right positions."
	  (pprint-newline :mandatory stream)))
      (pprint-exit-if-list-exhausted)
      (pprint-newline :mandatory stream))))

(defun pprint-define-assembly (stream list &rest noise)
  (declare (ignore noise))
  (pprint-logical-block (stream list :prefix "(" :suffix ")")
    ;; Output "define-assembly-routine"
    (output-object (pprint-pop) stream)
    (pprint-exit-if-list-exhausted)
    (write-char #\space stream)
    ;; Output routine name and options.
    (pprint-logical-block (stream (pprint-pop) :prefix "(" :suffix ")")
      ;; Output the routine name
      (output-object (pprint-pop) stream)
      (pprint-exit-if-list-exhausted)
      (pprint-newline :mandatory stream)
      (pprint-indent :block 0 stream)
      ;; Output options, one per line, neatly lined up and indented
      ;; below the routine name.
      (loop
       (output-object (pprint-pop) stream)
       (pprint-exit-if-list-exhausted)
       (pprint-newline :mandatory stream)))
    ;; Now output the args, results, and temps used by the assembly
    ;; routine.  Instead of lining up with the routine name, let's
    ;; just indent it 4 spaces from the "define-assembly-routine" so
    ;; it doesn't look so top-heavy.
    (pprint-indent :block 4 stream)
    (pprint-newline :mandatory stream)
    (pprint-logical-block (stream (pprint-pop) :prefix "(" :suffix ")")
      (loop
       (output-object (pprint-pop) stream)
       (pprint-exit-if-list-exhausted)
       (pprint-newline :mandatory stream)))
    ;; Now print out the assembly code as if it were a tagbody.  Then
    ;; labels are outdented by one to make them easy to see.
    (pprint-newline :mandatory stream)
    (pprint-tagbody-guts stream)))

;;;; Interface seen by regular (ugly) printer and initialization routines.

@@ -2037,7 +2073,8 @@ When annotations are present, invoke them at the right positions."
    (stream::with-stream-class pprint-with-like)
    (lisp::with-array-data pprint-with-like)
    (c:define-vop pprint-define-vop)
    (c:sc-case pprint-sc-case)))
    (c:sc-case pprint-sc-case)
    (c:define-assembly-routine pprint-define-assembly)))

(defun pprint-init ()
  (setf *initial-pprint-dispatch* (make-pprint-dispatch-table))