2023-12-20 19:54:58 +00:00
|
|
|
#ifndef RZ_FUN_H
|
|
|
|
#define RZ_FUN_H
|
|
|
|
|
|
|
|
#include "commons.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "err.h"
|
|
|
|
|
|
|
|
struct sym;
|
2023-12-23 20:17:12 +00:00
|
|
|
struct locals;
|
|
|
|
struct value;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int id;
|
|
|
|
struct value* value;
|
|
|
|
} closure_entry_t;
|
2023-12-20 19:54:58 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2023-12-24 19:24:41 +00:00
|
|
|
program_t* program;
|
2023-12-23 20:17:12 +00:00
|
|
|
err_t* err;
|
2023-12-20 19:54:58 +00:00
|
|
|
struct sym* sym;
|
|
|
|
struct tysy* tysy;
|
2023-12-23 20:17:12 +00:00
|
|
|
struct locals* locals;
|
|
|
|
int base;
|
|
|
|
int arg_base;
|
|
|
|
struct {
|
|
|
|
size_t size;
|
|
|
|
size_t cap;
|
|
|
|
closure_entry_t** data;
|
|
|
|
} closure;
|
|
|
|
|
2023-12-20 19:54:58 +00:00
|
|
|
} fun_t;
|
|
|
|
|
|
|
|
void fun_init(fun_t* fun, struct tysy* tysy, err_t* err);
|
2023-12-23 20:17:12 +00:00
|
|
|
fun_t* fun_new_clone(fun_t* fun);
|
2023-12-20 19:54:58 +00:00
|
|
|
void fun_free(fun_t* fun);
|
|
|
|
|
2023-12-23 20:17:12 +00:00
|
|
|
void fun_capture(fun_t* fun, int id, struct value* value);
|
|
|
|
closure_entry_t* fun_try_find_closure(fun_t* fun, int id);
|
2023-12-20 19:54:58 +00:00
|
|
|
|
|
|
|
#endif
|