~ chicken-core (chicken-5) 3b657536494a064452caba57275801970fbcccc4
commit 3b657536494a064452caba57275801970fbcccc4
Author: Peter Bex <peter@more-magic.net>
AuthorDate: Wed Jun 16 08:32:28 2021 +0200
Commit: megane <meganeka@gmail.com>
CommitDate: Thu Jun 17 15:19:07 2021 +0300
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.
Signed-off-by: megane <meganeka@gmail.com>
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 -> <boolean> If true: variable names an extended binding
; unused -> <boolean> 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 -> <boolean> 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
Trap