25 lines
912 B
Common Lisp
25 lines
912 B
Common Lisp
(in-package #:user-side-compiler)
|
|
|
|
(defclass label ()
|
|
((%name :accessor name :initarg :name)
|
|
(%address :accessor address :initform nil :initarg :address)))
|
|
|
|
(defmethod print-object ((object label) stream)
|
|
(with-accessors ((name name) (address address)) object
|
|
(print-unreadable-object (object stream :type t)
|
|
(write-string name stream)
|
|
(unless (null address)
|
|
(format stream " @ 0x~4,'0X" address)))))
|
|
|
|
(defvar *label-counter* 0)
|
|
|
|
(defun make-label-name (prefix)
|
|
(format nil "~A~D" prefix (incf *label-counter*)))
|
|
|
|
(defun make-label (&key name name-prefix address)
|
|
(when (and (not (null name)) (not (null name-prefix)))
|
|
(warn "MAKE-LABEL with both name (~A) and prefix (~A) specified (useless)."
|
|
name name-prefix))
|
|
(when (null name)
|
|
(setf name (make-label-name (if (null name-prefix) "L" name-prefix))))
|
|
(make-instance 'label :name name :address address))
|