diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-13 01:11:10 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-13 01:11:10 +0100 |
commit | 3398bc2d5456701d259dca6c93860d6842194b3c (patch) | |
tree | f5d1d75bb4b9e0e7837d990465b74f255ce7c1b6 | |
parent | 4a647eb328c1260c05d5ac9cdcc239086d07e51b (diff) | |
download | geiser-guile-3398bc2d5456701d259dca6c93860d6842194b3c.tar.gz geiser-guile-3398bc2d5456701d259dca6c93860d6842194b3c.tar.bz2 |
Inconsequential refactorings.
-rw-r--r-- | geiser/introspection.scm | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/geiser/introspection.scm b/geiser/introspection.scm index efe9a09..62d3ce5 100644 --- a/geiser/introspection.scm +++ b/geiser/introspection.scm @@ -32,13 +32,10 @@ (define (arguments sym . syms) (let loop ((sym sym) (syms syms)) - (cond ((proc-args sym) => (lambda (args) (cons sym args))) + (cond ((obj-args (resolve-symbol sym)) => (lambda (args) (cons sym args))) ((null? syms) #f) (else (loop (car syms) (cdr syms)))))) -(define (proc-args proc) - (obj-args (resolve-symbol proc))) - (define (resolve-symbol sym) (and (symbol? sym) (module-bound? (current-module) sym) @@ -51,6 +48,15 @@ ((macro? obj) (macro-args obj)) (else #f))) +(define (symbol-module sym) + (call/cc + (lambda (k) + (apropos-fold (lambda (module name var init) + (if (eq? name sym) (k (module-name module)) init)) + #f + (symbol->string sym) + (apropos-fold-accessible (current-module)))))) + (define (program-args program) (let* ((arity (program-arity program)) (arg-no (first arity)) @@ -99,38 +105,17 @@ (apropos-internal (string-append "^" prefix))) string<?)) +(define (symbol-location sym) + (cond ((symbol-module sym) => make-location-from-module-name) + (else '()))) + (define (make-location file line) (list (cons 'file (if (string? file) file '())) (cons 'line (if (number? line) (+ 1 line) '())))) -(define (program-line prog) - (let ((src (program-source prog 0))) - (and src (source:line src)))) - (define module-filename (@@ (ice-9 session) module-filename)) -(define (program-file prog) - (let* ((mod (and prog (program-module prog))) - (name (and mod (module-name mod)))) - (and name (module-filename name)))) - -(define (program-location prog) - (make-location (program-file prog) (program-line prog))) - -(define (symbol-module sym) - (call/cc - (lambda (k) - (apropos-fold (lambda (module name var init) - (if (eq? name sym) (k (module-name module)) init)) - #f - (symbol->string sym) - (apropos-fold-accessible (current-module)))))) - (define (make-location-from-module-name name) (make-location (module-filename name) #f)) -(define (symbol-location sym) - (cond ((symbol-module sym) => make-location-from-module-name) - (else '()))) - ;;; introspection.scm ends here |