Ruby: prism/node.h Source File

Ruby 3.3.7p123 (2025-01-15 revision be31f993d7fa0219d85f7b3c694d454da4ecc10b)

node.h
Go to the documentation of this file.
1
6#ifndef PRISM_NODE_H
7#define PRISM_NODE_H
8
9#include "prism/defines.h"
10#include "prism/parser.h"
11
18void pm_node_list_append(pm_node_list_t *list, pm_node_t *node);
19
26 PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node);
27
33 typedef struct {
35 size_t memsize;
36
38 size_t node_count;
39} pm_memsize_t;
40
47 PRISM_EXPORTED_FUNCTION void pm_node_memsize(pm_node_t *node, pm_memsize_t *memsize);
48
55 PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_type);
56
57#endif
pm_node_type_t
uint16_t pm_node_type_t
This is the type of node embedded in the node struct.
Definition ast.h:1023
pm_node_list_t
struct pm_node_list pm_node_list_t
A list of nodes in the source, most often used for lists of children.
pm_node_t
struct pm_node pm_node_t
This is the base structure that represents a node in the syntax tree.
parser.h
The parser used to parse Ruby source.
pm_parser_t
struct pm_parser pm_parser_t
The parser used to parse Ruby source.
Definition parser.h:259
defines.h
Macro definitions used throughout the prism library.
PRISM_EXPORTED_FUNCTION
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition defines.h:32
pm_node_destroy
PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node)
Deallocate a node and all of its children.
Definition node.c:61
pm_node_memsize
PRISM_EXPORTED_FUNCTION void pm_node_memsize(pm_node_t *node, pm_memsize_t *memsize)
Calculates the memory footprint of a given node.
Definition node.c:2480
pm_node_type_to_str
PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_type)
Returns a string representation of the given node type.
Definition node.c:2489
pm_node_list_append
void pm_node_list_append(pm_node_list_t *list, pm_node_t *node)
Append a new node onto the end of the node list.
Definition node.c:30
pm_memsize_t
This struct stores the information gathered by the pm_node_memsize function.
Definition node.h:33
pm_memsize_t::memsize
size_t memsize
The total memory footprint of the node and all of its children.
Definition node.h:35
pm_memsize_t::node_count
size_t node_count
The number of children the node has.
Definition node.h:38
pm_node
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1061