From bf48a7f9dbb26e3461d1090da63ca9496d902287 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Wed, 16 Jun 2021 08:32:28 +0200 Subject: [PATCH 1/3] Add information to the db for rest args which are explicitly consed Before, this would only be stored as an "explicit-rest" property on the procedure variable. In contexts where you only have the variable it was difficult to find out whether the rest arg was explicitly consed. Rest-ops only hold a reference to the rest arg variable, not the procedure. --- batch-driver.scm | 2 +- core.scm | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/batch-driver.scm b/batch-driver.scm index 78296c9d..3f456531 100644 --- a/batch-driver.scm +++ b/batch-driver.scm @@ -147,7 +147,7 @@ ((potential-values) (set! pvals (cdar es))) ((replacable home contains contained-in use-expr closure-size rest-parameter - captured-variables explicit-rest rest-cdr rest-null?) + captured-variables explicit-rest rest-cdr rest-null? consed-rest-arg) (printf "\t~a=~s" (caar es) (cdar es)) ) ((derived-rest-vars) (set! derived-rvars (cdar es))) diff --git a/core.scm b/core.scm index 2a380f03..c484071c 100644 --- a/core.scm +++ b/core.scm @@ -263,6 +263,7 @@ ; extended-binding -> If true: variable names an extended binding ; unused -> If true: variable is a formal parameter that is never used ; rest-parameter -> #f | 'list If true: variable holds rest-argument list +; consed-rest-arg -> If true: variable is a rest variable in a procedure called with consed rest list ; rest-cdr -> (rvar . n) Variable references the cdr of rest list rvar after n cdrs (0 = rest list itself) ; rest-null? -> (rvar . n) Variable checks if the cdr of rest list rvar after n cdrs is empty (0 = rest list itself) ; derived-rest-vars -> (v1 v2 ...) Other variables aliasing or referencing cdrs of a rest variable @@ -2435,7 +2436,8 @@ (cond ((and has (not (rassoc sym callback-names eq?))) (db-put! db (first lparams) 'has-unused-parameters #t) ) (rest - (db-put! db (first lparams) 'explicit-rest #t) ) ) ) ) ) ) ) ) ) + (db-put! db (first lparams) 'explicit-rest #t) + (db-put! db rest 'consed-rest-arg #t) ) ) ) ) ) ) ) ) ) ;; Make 'removable, if it has no references and is not assigned to, and one of the following: ;; - it has either a value that does not cause any side-effects -- 2.20.1