From 07d2c8333b29d8e37055a2d12dfeab23d17f88f0 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 29 Jul 2014 22:00:25 +0900 Subject: [PATCH] Traverse indirect procedure signatures via applied references. --- lib/chibi/doc.scm | 16 +++++++++++++--- lib/chibi/type-inference.scm | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/chibi/doc.scm b/lib/chibi/doc.scm index 06b75ccb..6224dc1f 100644 --- a/lib/chibi/doc.scm +++ b/lib/chibi/doc.scm @@ -709,9 +709,19 @@ div#footer {padding-bottom: 50px} (cur (collect)) (ids (append (get-ids cur) ids))) ;; ";;/" attaches the docs to the preceding form - (if (equal? line "/") - (lp '() '() (append cur res) ids depth last-line) - (lp '() cur res ids depth last-line)))))) + ;; rather than the next + (cond + ((equal? line "/") + (lp '() '() (append cur res) ids depth last-line)) + (else + (cond + ((and (not (equal? line "")) + (eqv? #\/ (string-ref line 0))) + (display "WARNING: ;;/ line should be empty" + (current-error-port)) + (write line (current-error-port)) + (newline (current-error-port)))) + (lp '() cur res ids depth last-line))))))) ((eqv? #\) (peek-char in)) (read-char in) (if (zero? depth) diff --git a/lib/chibi/type-inference.scm b/lib/chibi/type-inference.scm index 9280f912..407f456e 100644 --- a/lib/chibi/type-inference.scm +++ b/lib/chibi/type-inference.scm @@ -307,11 +307,20 @@ (define (procedure-signature x . o) (define (ast-sig x) (cond - ((lambda? x) (cdr (lambda-type x))) + ((lambda? x) + (cons (lambda-return-type x) + (if (pair? (lambda-param-types x)) + (lambda-param-types x) + (lambda-params x)))) ((seq? x) (ast-sig (last (seq-ls x)))) - ((and (pair? x) (lambda? (car x))) (ast-sig (lambda-body x))) - ;; ((and (pair? x) (ref? (car x)) (lambda? (cdr (ref-cell (car x))))) - ;; (ast-sig (lambda-body (cdr (ref-cell (car x)))))) + ((and (pair? x) (lambda? (car x))) (ast-sig (lambda-body (car x)))) + ;; TODO: improve the type inference so this isn't needed + ((and (pair? x) (ref? (car x)) + (pair? o) (apply procedure-analysis (ref-name (car x)) o)) + => (lambda (lam) + (and (lambda? lam) + (or (lambda-return-type lam) + (ast-sig (lambda-body lam)))))) (else #f))) (cond ((opcode? x)