Ruby: prism/node.h File Reference

Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)

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

  parser | The parser that owns the node.
  node | The 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

  list | The list to append to.
  node | The 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

  node | The node to calculate the memory footprint of.
  memsize | The 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_type | The node type to convert to a string.

Returns
  A string representation of the given node type.

Definition at line 2489 of file node.c.