From 6bb891dc6137885182f86aa147dba428e1149a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 22 Oct 2009 22:33:53 +0200 Subject: [PATCH] Adjust `unbound-variable' GOOPS heuristic for `goops.scm'. * module/language/tree-il/analyze.scm (goops-toplevel-definition): Add ENV argument. Deal with GOOPS macros expanded within `goops.scm'. (report-possibly-unbound-variables): Adjust. --- module/language/tree-il/analyze.scm | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm index 352462f44..d6895591c 100644 --- a/module/language/tree-il/analyze.scm +++ b/module/language/tree-il/analyze.scm @@ -633,21 +633,29 @@ (defs toplevel-info-defs) ;; (VARIABLE-NAME ...) (locs toplevel-info-locs)) ;; (LOCATION ...) -(define (goops-toplevel-definition proc args) +(define (goops-toplevel-definition proc args env) ;; If application of PROC to ARGS is a GOOPS top-level definition, return ;; the name of the variable being defined; otherwise return #f. This ;; assumes knowledge of the current implementation of `define-class' et al. + (define (toplevel-define-arg args) + (and (pair? args) (pair? (cdr args)) (null? (cddr args)) + (record-case (car args) + (( exp) + (and (symbol? exp) exp)) + (else #f)))) + (record-case proc (( mod public? name) (and (equal? mod '(oop goops)) (not public?) (eq? name 'toplevel-define!) - (pair? args) (pair? (cdr args)) (null? (cddr args)) - (record-case (car args) - (( exp) - (and (symbol? exp) - exp)) - (else #f)))) + (toplevel-define-arg args))) + (( name) + ;; This may be the result of expanding one of the GOOPS macros within + ;; `oop/goops.scm'. + (and (eq? name 'toplevel-define!) + (eq? env (resolve-module '(oop goops))) + (toplevel-define-arg args))) (else #f))) ;; TODO: Combine with `report-unused-variables' so we don't traverse the tree @@ -703,7 +711,8 @@ (( proc args) ;; Check for a dynamic top-level definition, as is ;; done by code expanded from GOOPS macros. - (let ((name (goops-toplevel-definition proc args))) + (let ((name (goops-toplevel-definition proc args + env))) (if (symbol? name) (make-toplevel-info (alist-delete name refs eq?)