~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/cmp/cmptag.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-06-21 09:21:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060621092121-txz1f21lj0wh0f67
Tags: 0.9h-20060617-1
* New upstream version
* Updated standards version without real changes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
(in-package "COMPILER")
15
15
 
16
 
;;; During Pass 1, *tags* holds a list of tag objects and the symbols 'CB'
17
 
;;; (Closure Boundary), 'LB' (Level Boundary) or 'UNWIND-PROTECT'.
18
 
;;; 'CB' will be pushed on *tags* when the compiler begins to process
19
 
;;;  a closure.
20
 
;;; 'LB' will be pushed on *tags* when *level* is incremented.
21
 
;;; 'UNWIND-PROTECT' is pushed when entering an unwind-protect.
22
16
;;;  A dummy variable is created to hold the tag identifier and one tag
23
17
;;;  structure (containing reference to such variable) is created for each
24
18
;;;  label in the body.
71
65
            (setq end w)))))))
72
66
 
73
67
;; FIXME! The variable name should not be a usable one!
74
 
(defun c1tagbody (body &aux (*tags* *tags*)
 
68
(defun c1tagbody (body &aux (*cmp-env* (cmp-env-copy))
75
69
                       (tag-var (make-var :name 'TAGBODY :kind NIL))
76
70
                       (tag-index 0))
77
71
  ;;; Establish tags.
80
74
         #'(lambda (x)
81
75
             (if (not (consp x))
82
76
               (let ((tag (make-tag :name x :var tag-var :index tag-index)))
83
 
                 (push tag *tags*)
 
77
                 (cmp-env-register-tag tag)
84
78
                 (incf tag-index)
85
79
                 tag)
86
80
               x))
176
170
 
177
171
(defun c1go (args)
178
172
  (check-args-number 'GO args 1 1)
179
 
  (unless (or (symbolp (car args)) (integerp (car args)))
180
 
    (cmperr "The tag name ~s is not a symbol nor an integer." (car args)))
181
 
  (do ((tags *tags* (cdr tags))
182
 
       (name (car args))
183
 
       (ccb) (clb) (unw) (tag) (var))
184
 
      ((endp tags) (cmperr "The tag ~s is undefined." name))
185
 
    (declare (type var var))
186
 
    (setq tag (car tags))
187
 
    (case tag
188
 
      (CB (setq ccb t))
189
 
      (LB (setq clb t))
190
 
      (UNWIND-PROTECT (setq unw T))
191
 
      (T (when (eql (tag-name tag) name)
192
 
           (setq var (tag-var tag))
193
 
           (cond (ccb (setf (tag-ref-ccb tag) t
194
 
                            (var-ref-ccb var) T
195
 
                            (var-kind var) 'CLOSURE))
196
 
                 (clb (setf (tag-ref-clb tag) t
197
 
                            (var-ref-clb var) t
198
 
                            (var-kind var) 'LEXICAL))
199
 
                 (unw (unless (var-kind var)
200
 
                        (setf (var-kind var) :OBJECT))))
201
 
           (incf (var-ref var))
202
 
           (incf (tag-ref tag))
203
 
           (return (add-to-read-nodes var (make-c1form* 'GO :args tag
204
 
                                                        (or ccb clb unw))))
205
 
           )))))
 
173
  (let ((name (first args)))
 
174
    (unless (or (symbolp name) (integerp name))
 
175
      (cmperr "The tag name ~s is not a symbol nor an integer." name))
 
176
    (multiple-value-bind (tag ccb clb unw)
 
177
        (cmp-env-search-tag name)
 
178
      (unless tag
 
179
        (cmperr "Undefined tag ~A" name))
 
180
      (setq var (tag-var tag))
 
181
      (cond (ccb (setf (tag-ref-ccb tag) t
 
182
                       (var-ref-ccb var) T
 
183
                       (var-kind var) 'CLOSURE))
 
184
            (clb (setf (tag-ref-clb tag) t
 
185
                       (var-ref-clb var) t
 
186
                       (var-kind var) 'LEXICAL))
 
187
            (unw (unless (var-kind var)
 
188
                   (setf (var-kind var) :OBJECT))))
 
189
      (incf (var-ref var))
 
190
      (incf (tag-ref tag))
 
191
      (add-to-read-nodes var (make-c1form* 'GO :args tag (or ccb clb unw))))))
206
192
 
207
193
(defun c2go (tag nonlocal)
208
194
  (if nonlocal