Reduct  v1.0.4-3-gdaf0d70
A functional and immutable language.
Loading...
Searching...
No Matches
closure.h
Go to the documentation of this file.
1#ifndef REDUCT_CLOSURE_H
2#define REDUCT_CLOSURE_H 1
3
4struct reduct_item;
5
6#include "defs.h"
7#include "function.h"
8
9/**
10 * @file closure.h
11 * @brief Closure management.
12 * @defgroup closure Closure
13 *
14 * A closure is a function instance that has captured variables from its enclosing scope.
15 *
16 * @{
17 */
18
19#define REDUCT_CLOSURE_SMALL_MAX 4 ///< The maximum number of small constants.
20
21/**
22 * @brief Closure structure.
23 * @struct reduct_closure_t
24 */
25typedef struct reduct_closure
26{
27 reduct_function_t* function; ///< Pointer to the prototype function item.
28 reduct_handle_t* constants; ///< The array of constant slots forming the constant template.
31
32/**
33 * @brief Deinitialize a closure structure.
34 *
35 * @param closure The closure to deinitialize.
36 */
38
39/**
40 * @brief Allocate a new closure.
41 *
42 * @param reduct The Reduct structure.
43 * @param function The prototype function item.
44 * @return A pointer to the newly allocated closure.
45 */
46REDUCT_API reduct_closure_t* reduct_closure_new(struct reduct* reduct, reduct_function_t* function);
47
48/** @} */
49
50#endif
reduct_uint64_t reduct_handle_t
Handle type.
Definition defs.h:189
#define REDUCT_API
Definition defs.h:7
Compiled function.
REDUCT_API reduct_closure_t * reduct_closure_new(struct reduct *reduct, reduct_function_t *function)
Allocate a new closure.
#define REDUCT_CLOSURE_SMALL_MAX
The maximum number of small constants.
Definition closure.h:19
REDUCT_API void reduct_closure_deinit(reduct_closure_t *closure)
Deinitialize a closure structure.
Definition closure_impl.h:8
Closure structure.
Definition closure.h:26
reduct_handle_t * constants
The array of constant slots forming the constant template.
Definition closure.h:28
reduct_function_t * function
Pointer to the prototype function item.
Definition closure.h:27
Compiled function structure.
Definition function.h:78