Ruby  3.4.0dev (2024-11-22 revision 37a72b0150ec36b4ea27175039afc28c62207b0c)
prism_compile.h (37a72b0150ec36b4ea27175039afc28c62207b0c)
1 #include "prism/prism.h"
2 #include "ruby/encoding.h"
3 
12 typedef struct pm_local_index_struct {
13  int index, level;
15 
16 // A declaration for the struct that lives in compile.c.
17 struct iseq_link_anchor;
18 
19 // ScopeNodes are helper nodes, and will never be part of the AST. We manually
20 // declare them here to avoid generating them.
21 typedef struct pm_scope_node {
22  pm_node_t base;
23  struct pm_scope_node *previous;
24  pm_node_t *ast_node;
25  pm_node_t *parameters;
26  pm_node_t *body;
27  pm_constant_id_list_t locals;
28 
29  const pm_parser_t *parser;
30  rb_encoding *encoding;
31 
41 
48 
49  // The size of the local table on the iseq which includes locals and hidden
50  // variables.
51  int local_table_for_iseq_size;
52 
53  ID *constants;
54  st_table *index_lookup_table;
55 
56  // The current coverage setting, passed down through the various scopes.
57  int coverage_enabled;
58 
65 
66 void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous);
67 void pm_scope_node_destroy(pm_scope_node_t *scope_node);
68 
69 typedef struct {
72 
75 
78 
81 
83  bool parsed;
85 
86 VALUE pm_load_file(pm_parse_result_t *result, VALUE filepath, bool load_error);
87 VALUE pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
88 VALUE pm_load_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
89 VALUE pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *script_lines);
90 VALUE pm_parse_stdin(pm_parse_result_t *result);
91 void pm_parse_result_free(pm_parse_result_t *result);
92 
93 rb_iseq_t *pm_iseq_new(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type, int *error_state);
94 rb_iseq_t *pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state);
95 rb_iseq_t *pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state);
96 rb_iseq_t *pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, int *error_state);
97 rb_iseq_t *pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type, const rb_compile_option_t *option, int *error_state);
98 
99 VALUE pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node);
Encoding relates APIs.
The main header file for the prism parser.
A list of constant IDs.
the getlocal and setlocal instructions require two parameters.
Definition: prism_compile.h:12
This is the base structure that represents a node in the syntax tree.
Definition: ast.h:1069
The options that can be passed to the parser.
Definition: options.h:77
bool parsed
Whether or not this parse result has performed its parsing yet.
Definition: prism_compile.h:83
pm_scope_node_t node
The resulting scope node that will hold the generated AST.
Definition: prism_compile.h:80
pm_string_t input
The input that represents the source to be parsed.
Definition: prism_compile.h:77
pm_parser_t parser
The parser that will do the actual parsing.
Definition: prism_compile.h:71
pm_options_t options
The options that will be passed to the parser.
Definition: prism_compile.h:74
This struct represents the overall parser.
Definition: parser.h:640
rb_encoding * filepath_encoding
This is the encoding of the actual filepath object that will be used when a FILE node is compiled or ...
Definition: prism_compile.h:47
struct iseq_link_anchor * pre_execution_anchor
This will only be set on the top-level scope node.
Definition: prism_compile.h:63
VALUE * script_lines
This is a pointer to the list of script lines for the ISEQs that will be associated with this scope n...
Definition: prism_compile.h:40
A generic string type that can have various ownership semantics.
Definition: pm_string.h:33
Definition: st.h:79
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition: value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40