Make methods for nodes to list their potential next nodes
This commit is contained in:
parent
4bf1316536
commit
ebe27cf026
1 changed files with 13 additions and 0 deletions
|
@ -36,6 +36,12 @@
|
|||
(%source :accessor source :initarg :source :initform nil)
|
||||
(%comment :accessor comment :initarg :comment :initform nil)))
|
||||
|
||||
(defun nodep (obj)
|
||||
(typep obj 'node))
|
||||
|
||||
(defmethod node-nexts ((node node))
|
||||
(list (normal-next node)))
|
||||
|
||||
(defmethod generate-code :before ((node node))
|
||||
(produce-comment (format nil "~A" node)))
|
||||
|
||||
|
@ -66,6 +72,9 @@
|
|||
(defclass node-branch (node)
|
||||
((%branch-next :accessor branch-next :initarg :branch-next)))
|
||||
|
||||
(defmethod node-nexts ((node node-branch))
|
||||
(list (normal-next node) (branch-next node)))
|
||||
|
||||
(defmethod generate-code ((node node-branch))
|
||||
(let ((*instruction-source* node)
|
||||
(else-label (make-label :name-prefix "ELSE")))
|
||||
|
@ -83,6 +92,10 @@
|
|||
:documentation "A reference to a variable being set to the loop index.")
|
||||
(%loopee-node :accessor loopee-node :initarg :loopee-node)))
|
||||
|
||||
(defmethod node-nexts ((node node-dotimes))
|
||||
(append (list (loopee-node node))
|
||||
(call-next-method)))
|
||||
|
||||
(defmethod generate-code ((node node-dotimes))
|
||||
(let ((*instruction-source* node)
|
||||
(loop-label (make-label :name-prefix "LOOPBACK")))
|
||||
|
|
Loading…
Add table
Reference in a new issue