(defvar *context* nil "Current assembly context")
(defgeneric context-emit (context vector)
(:documentation "Emit a vector of bytes into the assembly context"))
(defgeneric context-address (context)
(:documentation "Returns current virtual address of the context"))
(defgeneric (setf context-address) (address context)
(:documentation "Set the current virtual address of the context"))
(defgeneric context-find-label (context symbol)
(:documentation "Returns a promise for the address of a symbol, or nil."))
(defgeneric context-set-label (context symbol &optional address)
(:documentation "Set the address of a label. If not supplied, the current address is used."))
(defgeneric context-emit-instruction (context vector)
(:documentation "Emit an instruction into the assembly context. This
exists to provide additional information to the context.")
(:method (context vector) (context-emit context vector)))
(defgeneric link (context)
(:documentation "Prepare and return final, assembled output.")
(:method (context) (resolve-vector (context-code-vector context))))