Ruby 4.1.0dev (2026-10-28 revision 130c9ec44bd35c7319cdc99c301419188510e3a9)
node.h
1#ifndef PRISM_INTERNAL_NODE_H
2#define PRISM_INTERNAL_NODE_H
3
4#include "prism/node.h"
5
7
8#include "prism/arena.h"
9
10/* The offset of the start of the given location. */
11#define PM_LOCATION_START(location_) ((location_)->start)
12
13/* The offset just past the end of the given location. */
14#define PM_LOCATION_END(location_) ((location_)->start + (location_)->length)
15
16/*
17 * Slow path for pm_node_list_append_inline: grow the list and append the node.
18 * Do not call directly — use pm_node_list_append_inline instead.
19 */
20void pm_node_list_append_slow(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node);
21
22/*
23 * Append a new node onto the end of the node list, handling the common case
24 * inline and growing the list through pm_node_list_append_slow. This is the
25 * version for prism's own code; others call the exported pm_node_list_append.
26 */
27static PRISM_FORCE_INLINE void
28pm_node_list_append_inline(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) {
29 if (list->size < list->capacity) {
30 list->nodes[list->size++] = node;
31 } else {
32 pm_node_list_append_slow(arena, list, node);
33 }
34}
35
36/* Prepend a new node onto the beginning of the node list. */
37void pm_node_list_prepend(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node);
38
39/* Concatenate the given node list onto the end of the other node list. */
40void pm_node_list_concat(pm_arena_t *arena, pm_node_list_t *list, pm_node_list_t *other);
41
42#endif
A bump allocator for the prism parser.
#define PRISM_FORCE_INLINE
Force a function to be inlined at every call site.
Functions related to nodes in the AST.
A list of nodes in the source, most often used for lists of children.
Definition ast.h:592
size_t size
The number of nodes in the list.
Definition ast.h:594
struct pm_node ** nodes
The nodes in the list.
Definition ast.h:600
size_t capacity
The capacity of the list that has been allocated.
Definition ast.h:597
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1090