Ruby 4.1.0dev (2026-09-17 revision e6ec1555444994dc3ccc807cf6d5213281911857)
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/*
11 * Slow path for pm_node_list_append: grow the list and append the node.
12 * Do not call directly — use pm_node_list_append instead.
13 */
14void pm_node_list_append_slow(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node);
15
16/* Append a new node onto the end of the node list. */
17static PRISM_FORCE_INLINE void
18pm_node_list_append(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) {
19 if (list->size < list->capacity) {
20 list->nodes[list->size++] = node;
21 } else {
22 pm_node_list_append_slow(arena, list, node);
23 }
24}
25
26/* Prepend a new node onto the beginning of the node list. */
27void pm_node_list_prepend(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node);
28
29/* Concatenate the given node list onto the end of the other node list. */
30void pm_node_list_concat(pm_arena_t *arena, pm_node_list_t *list, pm_node_list_t *other);
31
32#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:585
size_t size
The number of nodes in the list.
Definition ast.h:587
struct pm_node ** nodes
The nodes in the list.
Definition ast.h:593
size_t capacity
The capacity of the list that has been allocated.
Definition ast.h:590
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1083