delete what nothing calls

walk-generic-toplevel and non-empty-list? had no caller left, a type
variable's id was never read, and every expression's type was recorded
in a table nothing looked up.
This commit is contained in:
2026-10-20 12:19:41 +03:00
parent 16a1c3b487
commit 9a3c01e96b
4 changed files with 3 additions and 33 deletions

View File

@@ -215,11 +215,6 @@ forms, and what remains."
acc))))))
(else (loop (cdr fs) (cons (car fs) acc))))))
(define (walk-generic-toplevel form)
(cond ((atom? form) (atom-to-fmt-c form))
((list? form) (map walk-generic-toplevel form))
(else (sex-error form "malformed form" form))))
(define (walk-expr form)
(match form
((? vector?) (walk-initializer (vector->list form)))

View File

@@ -62,9 +62,8 @@
;;; unused until a `fn' grows type parameters, and five lines now
;;; against an IR change later.
(define-record-type <tvar>
(%make-tvar id ref classes rigid?)
(%make-tvar ref classes rigid?)
tvar?
(id tvar-id)
(ref tvar-ref tvar-ref-set!)
(classes tvar-classes tvar-classes-set!)
(rigid? tvar-rigid?))
@@ -132,11 +131,8 @@
(%make-unknown)
unknown-type?)
(define tvar-counter 0)
(define (fresh-tvar . classes)
(set! tvar-counter (+ tvar-counter 1))
(%make-tvar tvar-counter #f (if (null? classes) (list) (car classes)) #f))
(%make-tvar #f (if (null? classes) (list) (car classes)) #f))
;;; Follow a bound variable to what it stands for, compressing the path
;;; on the way out. Every procedure that looks at a type's shape starts

View File

@@ -1181,16 +1181,12 @@
;;; member access.
;;; The type of an expression as a surface type, or #f when nothing
;;; here can say. Every form it visits is recorded in `form-type', so
;;; asking once types the whole subtree.
;;; here can say.
;;;
;;; 42 -> int (. p x) -> that field's type
;;; "hi" -> (* const char) (& p) -> (* (struct point))
;;; (area 3 4) -> what `area' returns
(define (expression-type expr env)
(set-form-type! expr (compute-expression-type expr env)))
(define (compute-expression-type expr env)
(cond
((and (number? expr) (exact? expr)) 'int)
((number? expr) 'double)
@@ -1948,9 +1944,6 @@
form))
;;; Utils
(define (non-empty-list? form)
(and (list? form)
(not (null? form))))
(define (sex-fn? form)
"The `form` must be toplevel.

View File

@@ -24,7 +24,6 @@
form-end-line
copy-form-source!
stamp-form-source!
set-form-type!
sex-error
sex-warning
(with-directory set-working-directory))
@@ -126,19 +125,6 @@
;;; The file `parse-all' is currently reading. Bound by the reader
(define current-source-file (make-parameter "<unknown>"))
;;; What type a form has, once something has worked it out. Keyed by
;;; cons cell like the sources above, so one form has one type: a body
;;; typed at two instantiations has to be copied before the second.
(define +form-types+ (make-hash-table eq?))
(define (set-form-type! form type)
(when (pair? form)
(hash-table-set! +form-types+ form type))
type)
(define (form-type form)
(hash-table-ref/default +form-types+ form #f))
(define (set-form-source! form file line #!optional (end-line line))
(hash-table-set! +form-sources+ form (list file line end-line)))