1 ;;;;------------------------------------------------------------------
3 ;;;; Copyright (C) 2000, 2004,
4 ;;;; Department of Computer Science, University of Tromso, Norway
6 ;;;; Filename: symtab.lisp
7 ;;;; Description: Assembly symbolic lookups.
8 ;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
9 ;;;; Created at: Tue Aug 22 10:01:38 2000
10 ;;;; Distribution: See the accompanying file COPYING.
12 ;;;; $Id: symtab.lisp,v 1.3 2004/02/10 00:04:19 ffjeld Exp $
14 ;;;;------------------------------------------------------------------
18 ;;; A symtab is a stack-organized list of "frames", where each frame
21 (define-condition unresolved-labels
()
22 ((labels :initarg labels
23 :reader unresolved-labels-labels
))
24 (:report
(lambda (condition stream
)
25 (format stream
"Unable to resolve labels ~A."
26 (unresolved-labels-labels condition
)))))
31 (defun symtab-add-frame (symtab)
34 (defun symtab-lookup-label (symtab label
)
35 (or (symtab-try-lookup-label symtab label
)
36 (error 'unresolved-labels
'labels
(list label
))))
38 (defun symtab-try-lookup-label (symtab label
)
39 (declare (special *symtab-lookup
*))
40 (or (cdr (assoc label symtab
))
41 (if (and (boundp '*symtab-lookup
*)
43 (funcall *symtab-lookup
* label
)
46 (defun symtab-def-label (symtab label value
)
47 (when (symtab-try-lookup-label symtab label
)
48 (error "Label ~A multiply defined." label
))
49 (acons label value symtab
))
51 (defun symtab-collapse-frames (symtab)