2023-10-25 17:23:57 +03:00
|
|
|
#include "prism/prism.h"
|
|
|
|
|
2024-01-15 23:59:11 +03:00
|
|
|
/**
|
|
|
|
* the getlocal and setlocal instructions require two parameters. level is how
|
|
|
|
* many hops up the iseq stack one needs to go before finding the correct local
|
|
|
|
* table. The index is the index in that table where our variable is.
|
|
|
|
*
|
|
|
|
* Because these are always calculated and used together, we'll bind them
|
|
|
|
* together as a tuple.
|
|
|
|
*/
|
|
|
|
typedef struct pm_local_index_struct {
|
|
|
|
int index, level;
|
|
|
|
} pm_local_index_t;
|
|
|
|
|
2023-10-25 17:23:57 +03:00
|
|
|
// ScopeNodes are helper nodes, and will never be part of the AST. We manually
|
|
|
|
// declare them here to avoid generating them.
|
|
|
|
typedef struct pm_scope_node {
|
|
|
|
pm_node_t base;
|
|
|
|
struct pm_scope_node *previous;
|
|
|
|
pm_node_t *ast_node;
|
2023-12-06 18:05:14 +03:00
|
|
|
pm_node_t *parameters;
|
2023-10-25 17:23:57 +03:00
|
|
|
pm_node_t *body;
|
|
|
|
pm_constant_id_list_t locals;
|
|
|
|
pm_parser_t *parser;
|
|
|
|
|
2023-12-06 18:05:14 +03:00
|
|
|
// The size of the local table
|
|
|
|
// on the iseq which includes
|
|
|
|
// locals and hidden variables
|
|
|
|
int local_table_for_iseq_size;
|
2023-12-01 00:18:14 +03:00
|
|
|
|
2023-10-25 23:37:37 +03:00
|
|
|
ID *constants;
|
|
|
|
st_table *index_lookup_table;
|
2023-10-25 17:23:57 +03:00
|
|
|
} pm_scope_node_t;
|
|
|
|
|
|
|
|
void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous, pm_parser_t *parser);
|
2024-01-18 19:55:31 +03:00
|
|
|
void pm_scope_node_destroy(pm_scope_node_t *scope_node);
|
2023-12-08 02:47:36 +03:00
|
|
|
bool *rb_ruby_prism_ptr(void);
|