From edbe98a63a704b0cb2db52f3ed6473f631e04e41 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 19 Mar 2020 21:16:12 +0000 Subject: [PATCH 5/9] internal: Document the WC_FUNCDEF data layout for anonymous functions with arguments (follow-up to 29492) --- Src/parse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/parse.c b/Src/parse.c index 666595ef1..acbf42a9c 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -175,6 +175,10 @@ struct heredocs *hdocs; * - followed by number of patterns for body * - followed by codes for body * - followed by strings for body + * - if number of names is 0, followed by: + * - the offset to the end of the funcdef + * - the number of arguments to the function + * - the arguments to the function * * WC_FOR * - data contains type (list, ...) and offset to after body @@ -1734,8 +1738,9 @@ par_funcdef(int *cmplx) ecbuf[p] = WCB_FUNCDEF(ecused - 1 - p); + /* If it's an anonymous function... */ if (num == 0) { - /* Unnamed function */ + /* ... look for arguments to it. */ int parg = ecadd(0); ecadd(0); while (tok == STRING) { @@ -2110,8 +2115,9 @@ par_simple(int *cmplx, int nr) ecbuf[p] = WCB_FUNCDEF(ecused - 1 - p); + /* If it's an anonymous function... */ if (argc == 0) { - /* Unnamed function */ + /* ... look for arguments to it. */ int parg = ecadd(0); ecadd(0); while (tok == STRING || IS_REDIROP(tok)) {