Mercurial > lbo > hg > ylisp
changeset 81:e5d39401bc29
func: Describe function arguments in yfunc_t.
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Mon, 26 Aug 2019 08:45:27 +0200 |
parents | 8ef8c191a3a1 |
children | 7f331aa5abd1 |
files | src/func.h |
diffstat | 1 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/func.h Mon Aug 26 08:40:28 2019 +0200 +++ b/src/func.h Mon Aug 26 08:45:27 2019 +0200 @@ -13,6 +13,16 @@ * @{ */ +/// Descriptor of a function argument. +typedef struct { + /// Name of the argument. Useful for debugging. + ystr_t argname; + /// Reference (usually anonymous/numeric) to the value slot of this + /// argument. It is created during the compile stage, and will be used + /// during execution. + yref_t argref; +} yarg_desc_t; + /** * @brief Compiled function code. Functions are usually inserted in the global * value table and referenced there. @@ -20,13 +30,15 @@ * TODO: Extend to allow reference capture for closures? */ typedef struct { - /// Name of a function. + /// Expressions making up the function. Often a list; the value of the last + /// expression is the value of the invoked function. `args` describes the + /// references in `body` that are to be bound before calling. + yexpr_t body; + /// Name of the function. ystr_t name; - /// How many arguments it expects. - size_t nargs; - /// Expressions making up the function. Often a list; the value of the last - //expression is the value of the invoked function. - yexpr_t body; + /// Vector of yarg_desc_t values, each describing an argument, in order of + /// appearance. + yvec_t args; } yfunc_t; /**