Ruby 3.3.0p0 (2023-12-25 revision 5124f9ac7513eb590c37717337c430cb93caa151)
Data Structures | Functions
node.h File Reference

Functions related to nodes in the AST. More...

#include "prism/defines.h"
#include "prism/parser.h"

Go to the source code of this file.

Data Structures

struct  pm_memsize_t
 This struct stores the information gathered by the pm_node_memsize function. More...
 

Functions

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.
 
PRISM_EXPORTED_FUNCTION void pm_node_destroy (pm_parser_t *parser, struct pm_node *node)
 Deallocate a node and all of its children.
 
PRISM_EXPORTED_FUNCTION void pm_node_memsize (pm_node_t *node, pm_memsize_t *memsize)
 Calculates the memory footprint of a given node.
 
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.
 

Detailed Description

Functions related to nodes in the AST.

Definition in file node.h.

Function Documentation

◆ pm_node_destroy()

PRISM_EXPORTED_FUNCTION void pm_node_destroy ( pm_parser_t * parser,
pm_node_t * node )

Deallocate a node and all of its children.

Parameters
parserThe parser that owns the node.
nodeThe node to deallocate.

Deallocate a node and all of its children.

Similarly to pm_node_alloc, we're not using the parser argument, but it's there to allow for the future possibility of pre-allocating larger memory pools.

Definition at line 61 of file node.c.

◆ 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.

Parameters
listThe list to append to.
nodeThe node to append.

Definition at line 30 of file node.c.

◆ 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.

Parameters
nodeThe node to calculate the memory footprint of.
memsizeThe memory footprint of the node and all of its children.

Definition at line 2480 of file node.c.

◆ 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.

Parameters
node_typeThe node type to convert to a string.
Returns
A string representation of the given node type.

Definition at line 2489 of file node.c.