Mercurial > lbo > hg > ylisp
view src/func.h @ 127:dbed1593881c
func: Implement yfunc_destroy()
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sun, 01 Sep 2019 19:21:46 +0200 |
parents | 63650268d006 |
children | 07ff95760f4a |
line wrap: on
line source
#ifndef src_func_h #define src_func_h #include "types.h" #include "base/str.h" #include "base/vec.h" /** * @file func.h * @brief Executable functions. * @addtogroup language * @{ */ /// 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. * * TODO: Extend to allow reference capture for closures? */ typedef struct { /// Expressions (yexpr_t) making up the function body. 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. yvec_t body; /// Name of the function. ystr_t name; /// Vector of yarg_desc_t values, each describing an argument, in order of /// appearance. yvec_t args; } yfunc_t; /** * @brief Free resources associated with func. */ void yfunc_destroy(yfunc_t* func); /** * @} */ #endif