Ensure IBLOCK names are unique

This commit is contained in:
John Lorentzson 2025-07-03 15:59:41 +02:00
parent 7171398c07
commit 094f01d258

View file

@ -40,6 +40,19 @@
;;; Compilation setup
(defun make-iblock-names-unique (start-iblock)
(let ((encountered '()))
(do-iblocks (iblock start-iblock)
(let ((existing (assoc (name iblock) encountered :test #'equalp)))
(if existing
(progn
(setf (name iblock)
(format nil "~A_~A" (name iblock) (incf (cdr existing)))))
(progn
(push (cons (copy-seq (name iblock)) 1) encountered)
(setf (name iblock)
(format nil "~A_1" (name iblock)))))))))
(defun fix-iblock-flow (start-iblock)
(let ((reached '())
(last nil)
@ -77,7 +90,9 @@
,@body)
(when ,add-return-p
(build-insert-end (make-instance 'ir-return) ,builder))
(fix-iblock-flow ,iblock))))
(fix-iblock-flow ,iblock)
(unless (null (next ,iblock))
(make-iblock-names-unique (next ,iblock))))))
;;; Some quick example code