- (setf (combination-args inside) nil)
- (setf (combination-args outside)
- (append before-args inside-args after-args))
- (change-ref-leaf (lvar-uses inside-fun)
- (find-free-fun 'list "???"))
- (setf (combination-fun-info inside) (info :function :info 'list)
- (combination-kind inside) :known)
- (setf (node-derived-type inside) *wild-type*)
- (flush-dest lvar)
- (values))))))
+ (setf (combination-args inside) nil)
+ (setf (combination-args outside)
+ (append before-args inside-args after-args))
+ (change-ref-leaf (lvar-uses inside-fun)
+ (find-free-fun 'list "???"))
+ (setf (combination-fun-info inside) (info :function :info 'list)
+ (combination-kind inside) :known)
+ (setf (node-derived-type inside) *wild-type*)
+ (flush-dest lvar)
+ (values))))))
+
+(defun extract-fun-args (lvar fun num-args)
+ (declare (type lvar lvar)
+ (type (or symbol list) fun)
+ (type index num-args))
+ (let ((fun (if (listp fun) fun (list fun))))
+ (let ((inside (lvar-uses lvar)))
+ (unless (combination-p inside)
+ (give-up-ir1-transform))
+ (let ((inside-fun (combination-fun inside)))
+ (unless (member (lvar-fun-name inside-fun) fun)
+ (give-up-ir1-transform))
+ (let ((inside-args (combination-args inside)))
+ (unless (= (length inside-args) num-args)
+ (give-up-ir1-transform))
+ (values (lvar-fun-name inside-fun) inside-args))))))