Make TRANSFORM return OBJ if it's already TO-TYPE
This commit is contained in:
parent
1307e31268
commit
7639263bed
1 changed files with 10 additions and 6 deletions
|
@ -57,12 +57,16 @@ that has been somehow created using OBJ as a starting point."
|
|||
(let* ((from-type (case (type-of obj)
|
||||
((bit number integer fixnum) 'integer)
|
||||
(t (type-of obj))))
|
||||
(path (transform-path from-type to-type)))
|
||||
(if (listp path)
|
||||
(loop :for intermediate :in path
|
||||
:do (setf obj (%direct-transform obj intermediate))
|
||||
:finally (return (%direct-transform obj to-type)))
|
||||
(%direct-transform obj to-type))))
|
||||
(path (if (typep obj to-type)
|
||||
obj
|
||||
(transform-path from-type to-type))))
|
||||
(cond ((listp path)
|
||||
(loop :for intermediate :in path
|
||||
:do (setf obj (%direct-transform obj intermediate))
|
||||
:finally (return (%direct-transform obj to-type))))
|
||||
((eql obj path)
|
||||
obj)
|
||||
(t (%direct-transform obj to-type)))))
|
||||
|
||||
(defmacro define-transformation ((var-name (from-type to-type)) &body body)
|
||||
"Defines a transformation rule for objects going from FROM-TYPE to TO-TYPE.
|
||||
|
|
Loading…
Add table
Reference in a new issue