Feb 17, 2008, 4:37:21 PM (13 years ago)

checkpoint work in progress, mainly some final cleanup, reorg, don't try to track atoms, keep track of source through transforms; reporting implementation in library;cover.lisp

1 edited


  • branches/gz-working/compiler/nx0.lisp

    r8477 r8505  
    7878(defvar *nx-operators* ())
    7979(defvar *nx-warnings* nil)
    80 (defvar *nx-current-source-note* nil)
     80(defvar *nx-current-code-note* nil)
    12541254                                 (policy *default-compiler-policy*)
    12551255                                 load-time-eval-token
    1256                                  source-note)
     1256                                 code-note)
    12571257  (if q
    12581258     (setf (afunc-parent p) q))
    12871287                         (parse-body (%cddr lambda-form) *nx-lexical-environment* t)
    12881288      (setf (afunc-lambdaform p) lambda-form)
    1289       (setf (afunc-acode p) (nx1-lambda (%cadr lambda-form) body decls source-note))
     1289      (setf (afunc-acode p) (nx1-lambda (%cadr lambda-form) body decls code-note))
    12901290      (nx1-transitively-punt-bindings *nx-punted-vars*)
    12911291      (setf (afunc-blocks p) *nx-blocks*)
    1312 (defun nx1-lambda (ll body decls &optional source-note &aux (l ll) methvar)
    1313   (when source-note
     1312(defun nx1-lambda (ll body decls &optional code-note &aux (l ll) methvar)
     1313  (when code-note
    13141314    (setf (afunc-lfun-info *nx-current-function*)
    1315           (list* 'function-source-note source-note (afunc-lfun-info *nx-current-function*))))
     1315          (list* 'function-source-note code-note (afunc-lfun-info *nx-current-function*))))
    13161316  (let* ((old-env *nx-lexical-environment*)
    13171317         (*nx-bound-vars* *nx-bound-vars*)
    1318          (*nx-current-source-note* (and (or *compile-code-coverage* *record-pc-mapping*) source-note)))
     1318         (*nx-current-code-note* (and (or *compile-code-coverage* *record-pc-mapping*) code-note)))
    13201320    (with-nx-declarations (pending)
    15731573(defun nx1-transformed-form (form env &optional original)
    1574   (if *nx-current-source-note*
    1575     (let* ((original (or original form))
    1576            (new-note (nx-ensure-source-note original *nx-current-source-note*))
    1577            (*nx-current-source-note* new-note))
     1574  (if *nx-current-code-note*
     1575    ;; It is possible for the form to be a source form when the original is not: macros
     1576    ;; often insert wrappings, e.g. (when (foo) (bar)) becomes (IF (foo) (PROGN (bar))),
     1577    ;; and (PROGN (bar)) transforms into (bar), which is a source form.
     1578    (let* ((new-note (nx-ensure-code-note form original *nx-current-code-note*))
     1579           (*nx-current-code-note* new-note))
    15781580      (unless new-note
    15791581        (compiler-bug "No source note for ~s -> ~s" original form))
    1580       (make-acode (%nx1-operator with-source-note)
     1582      (make-acode (%nx1-operator with-code-note)
    15811583                  new-note
    15821584                  (nx1-transformed-form-aux form env)))
    20022004(defun nx-transform (form &optional (environment *nx-lexical-environment*))
    2003   (let* (sym transforms lexdefs changed enabled macro-function compiler-macro)
     2005  (let* (sym transforms lexdefs changed enabled macro-function compiler-macro source)
     2006    (when (or (null *nx-source-note-map*) (gethash form *nx-source-note-map*))
     2007      (setq source t))
    20042008    (tagbody
    20052009       (go START)
    20062010     LOOP
     2011       (unless source (setq source (gethash form *nx-source-note-map*)))
    20072012       (setq changed t)
    20082013       (when (and (consp form)
    20142019         (multiple-value-bind (newform win) (nx-transform-symbol form environment)
    20152020           (unless win (go DONE))
    2016            (setq form newform changed (or changed win))
     2021           (setq form newform)
    20172022           (go LOOP)))
    20182023       (when (atom form) (go DONE))
    20232028           (if (constantp thing)
    20242029             (progn
    2025                (setq form thing form thing)
     2030               (setq form thing)
    20262031               (go LOOP))
    20272032             (multiple-value-bind (newform win) (nx-transform thing environment)
    20282033               (when win
     2034                 (unless source (setq source (gethash newform *nx-source-note-map*)))
    20292035                 (setq changed t)
    20302036                 (if (and (self-evaluating-p newform)
    20472053           (when (and enabled (functionp (fboundp sym)))
    20482054             (multiple-value-setq (form win) (nx-transform-arglist form environment))
    2049              (if win (setq changed t)))))
     2055             (when win
     2056               (unless source (setq source (gethash form *nx-source-note-map*)))
     2057               (setq changed t)))))
    20502058       (when (and enabled
    20512059                  (not (nx-declared-notinline-p sym environment)))
    20522060         (multiple-value-bind (value folded) (nx-constant-fold form environment)
    2053            (when folded (setq form value changed t)  (unless (and (consp form) (eq (car form) sym)) (go START))))
     2061           (when folded
     2062             (setq form value changed t)
     2063             (unless source (setq source (gethash form *nx-source-note-map*)))
     2064             (unless (and (consp form) (eq (car form) sym)) (go START))))
    20542065         (when compiler-macro
    20552066           (multiple-value-bind (newform win) (compiler-macroexpand-1 form environment)
    20682079                                      (and #-bccl (boundp '%structure-refs%)
    20692080                                           (gethash sym %structure-refs%))))
    2070              (setq form (defstruct-ref-transform transforms (%cdr form)) changed T)
     2081             (setq form (defstruct-ref-transform transforms (%cdr form)) changed t)
     2082             (unless source (setq source (gethash form *nx-source-note-map*)))
    20712083             (go START))
    20722084           (when (setq transforms (assq sym *nx-synonyms*))
    20782090         (nx-record-xref-info :macro-calls (function-name macro-function))
    20792091         (setq form (macroexpand-1 form environment) changed t)
     2092         (unless source (setq source (gethash form *nx-source-note-map*)))
    20802093         (go START))
    20812094     DONE)
     2095    (when (and source (neq source t) (not (gethash form *nx-source-note-map*)))
     2096      ;; Neither the initial nor final form has source, but somewhere in the middle we encountered one.
     2097      (setf (gethash form *nx-source-note-map*) source))
    20822098    (values form changed)))
Note: See TracChangeset for help on using the changeset viewer.