Commit fe274800 authored by Robert Goldman's avatar Robert Goldman

Revise pseudo-accessors; add constructor.

parent 78da6e12
......@@ -14,7 +14,7 @@
#:component-depends-on
#:input-files #:output-files #:output-file #:operation-done-p
#:action-status #:action-stamp #:action-done-p
#:action-op #:action-component
#:action-operation #:action-component
#:component-operation-time #:mark-operation-done #:compute-action-stamp
#:perform #:perform-with-restarts #:retry #:accept
#:action-path #:find-action #:stamp #:done-p
......@@ -34,23 +34,27 @@ of steps to be performed while building a system."
and a class-name or class designates the canonical instance of the designated class."
'(or operation null symbol class)))
;;; these are pseudo accessors -- let us abstract away the CONS cell representation of plan
;;; actions.
(with-upgradability ()
(defun make-action (&key operation component)
(assert (and operation component))
(cons operation component))
(defun action-operation (action)
(car action))
(defun action-component (action)
(cdr action)))
;;;; Reified representation for storage or debugging. Note: it drops the operation-original-initargs
(with-upgradability ()
(defun action-path (action)
"A readable data structure that identifies the action."
(destructuring-bind (o . c) action (cons (type-of o) (component-find-path c))))
(let ((o (action-operation action))
(c (action-component action)))
(cons (type-of o) (component-find-path c))))
(defun find-action (path)
"Reconstitute an action from its action-path"
(destructuring-bind (o . c) path (cons (make-operation o) (find-component () c)))))
;;; these are pseudo accessors -- let us abstract away the CONS cell representation of plan
;;; actions.
(with-upgradability ()
(defun action-op (action)
(car action))
(defun action-component (action)
(cdr action)))
(destructuring-bind (o . c) path (make-action :operation (make-operation o) :component (find-component () c)))))
;;;; Convenience methods
(with-upgradability ()
......@@ -100,7 +104,7 @@ and a class-name or class designates the canonical instance of the designated cl
(defmethod ,function (,@prefix (,operation operation) ,component ,@suffix ,@more-args)
(if (typep ,component 'component)
(error "No defined method for ~S on ~/asdf-action:format-action/"
',function (cons ,operation ,component))
',function (make-action :operation ,operation :component ,component))
(if-let (,found (find-component () ,component))
,(next-method operation found)
,if-no-component))))))))
......@@ -423,7 +427,7 @@ in some previous image, or T if it needs to be done.")
selfward-operation non-propagating-operation))
(sysdef-error
(compatfmt "~@<Required method ~S not implemented for ~/asdf-action:format-action/~@:>")
'perform (cons o c))))
'perform (make-action :operation o :component c))))
;; The restarts of the perform-with-restarts variant matter in an interactive context.
;; The retry strategies of p-w-r itself, and/or the background workers of a multiprocess build
......
......@@ -342,7 +342,7 @@ initialized with SEED."
(defmethod call-while-visiting-action ((plan plan-traversal) operation component fun)
(with-accessors ((action-set plan-visiting-action-set)
(action-list plan-visiting-action-list)) plan
(let ((action (cons operation component)))
(let ((action (make-action :operation operation :component component)))
(when (gethash action action-set)
(error 'circular-dependency :actions
(member action (reverse action-list) :test 'equal)))
......@@ -439,7 +439,7 @@ initialized with SEED."
(defmethod (setf plan-action-status) :after
(new-status (p sequential-plan) (o operation) (c component))
(when (action-planned-p new-status)
(push (cons o c) (plan-actions-r p)))))
(push (make-action :operation o :component c) (plan-actions-r p)))))
;;;; High-level interface: traverse, perform-plan, plan-operates-on-p
......@@ -474,7 +474,7 @@ initialized with SEED."
(defmethod perform-plan ((steps list) &key force &allow-other-keys)
(loop* :for action :in steps
:as o = (action-op action)
:as o = (action-operation action)
:as c = (action-component action)
:when (or force (not (nth-value 1 (compute-action-stamp nil o c))))
:do (perform-with-restarts o c)))
......@@ -520,7 +520,7 @@ initialized with SEED."
"Given a list of actions, build a plan with these actions as roots."
(let ((plan (apply 'make-instance (or plan-class 'filtered-sequential-plan) keys)))
(loop* :for action :in actions
:as o = (action-op action)
:as o = (action-operation action)
:as c = (action-component action)
:do (traverse-action plan o c t))
plan))
......@@ -535,10 +535,10 @@ initialized with SEED."
(defmethod plan-actions ((plan filtered-sequential-plan))
(with-slots (keep-operation keep-component) plan
(loop* :for action :in (call-next-method)
:as o = (action-op action)
:as o = (action-operation action)
:as c = (action-component action)
:when (and (typep o keep-operation) (typep c keep-component))
:collect (cons o c))))
:collect (make-action :operation o :component c))))
(defun* (required-components) (system &rest keys &key (goal-operation 'load-op) &allow-other-keys)
"Given a SYSTEM and a GOAL-OPERATION (default LOAD-OP), traverse the dependencies and
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment