Ruby: prism/static_literals.h Source File

Ruby 3.4.8p72 (2025-12-17 revision 995b59f66677d44767ce9faac6957e5543617ff9)

static_literals.h
Go to the documentation of this file.
1
6#ifndef PRISM_STATIC_LITERALS_H
7#define PRISM_STATIC_LITERALS_H
8
9#include "prism/defines.h"
10#include "prism/ast.h"
11#include "prism/util/pm_newline_list.h"
12
13#include <assert.h>
14#include <stdbool.h>
15
19 typedef struct {
21 pm_node_t **nodes;
22
24 uint32_t size;
25
27 uint32_t capacity;
28} pm_node_hash_t;
29
38 typedef struct {
42 pm_node_hash_t integer_nodes;
43
47 pm_node_hash_t float_nodes;
48
52 pm_node_hash_t number_nodes;
53
57 pm_node_hash_t string_nodes;
58
62 pm_node_hash_t regexp_nodes;
63
67 pm_node_hash_t symbol_nodes;
68
72 pm_node_t *true_node;
73
77 pm_node_t *false_node;
78
82 pm_node_t *nil_node;
83
88 pm_node_t *source_encoding_node;
89} pm_static_literals_t;
90
101 pm_node_t * pm_static_literals_add(const pm_newline_list_t *newline_list, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace);
102
108void pm_static_literals_free(pm_static_literals_t *literals);
109
119void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node);
120
121#endif
assert.h
pm_newline_list.h
A list of byte offsets of newlines in a string.
defines.h
Macro definitions used throughout the prism library.
pm_static_literal_inspect
void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node)
Create a string-based representation of the given static literal.
Definition static_literals.c:607
pm_static_literals_add
pm_node_t * pm_static_literals_add(const pm_newline_list_t *newline_list, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace)
Add a node to the set of static literals.
Definition static_literals.c:356
pm_static_literals_free
void pm_static_literals_free(pm_static_literals_t *literals)
Free the internal memory associated with the given static literals set.
Definition static_literals.c:462
stdbool.h
C99 shim for <stdbool.h>
pm_buffer_t
A pm_buffer_t is a simple memory buffer that stores data in a contiguous block of memory.
Definition pm_buffer.h:22
pm_newline_list_t
A list of offsets of newlines in a string.
Definition pm_newline_list.h:28
pm_node_hash_t
An internal hash table for a set of nodes.
Definition static_literals.h:19
pm_node_hash_t::nodes
pm_node_t ** nodes
The array of nodes in the hash table.
Definition static_literals.h:21
pm_node_hash_t::size
uint32_t size
The size of the hash table.
Definition static_literals.h:24
pm_node_hash_t::capacity
uint32_t capacity
The space that has been allocated in the hash table.
Definition static_literals.h:27
pm_node
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1068
pm_static_literals_t
Certain sets of nodes (hash keys and when clauses) check for duplicate nodes to alert the user of pot...
Definition static_literals.h:38
pm_static_literals_t::string_nodes
pm_node_hash_t string_nodes
This is the set of StringNode and SourceFileNode instances.
Definition static_literals.h:57
pm_static_literals_t::false_node
pm_node_t * false_node
A pointer to the last FalseNode instance that was inserted, or NULL.
Definition static_literals.h:77
pm_static_literals_t::regexp_nodes
pm_node_hash_t regexp_nodes
This is the set of RegularExpressionNode instances.
Definition static_literals.h:62
pm_static_literals_t::source_encoding_node
pm_node_t * source_encoding_node
A pointer to the last SourceEncodingNode instance that was inserted, or NULL.
Definition static_literals.h:88
pm_static_literals_t::nil_node
pm_node_t * nil_node
A pointer to the last NilNode instance that was inserted, or NULL.
Definition static_literals.h:82
pm_static_literals_t::number_nodes
pm_node_hash_t number_nodes
This is the set of RationalNode and ImaginaryNode instances.
Definition static_literals.h:52
pm_static_literals_t::true_node
pm_node_t * true_node
A pointer to the last TrueNode instance that was inserted, or NULL.
Definition static_literals.h:72
pm_static_literals_t::symbol_nodes
pm_node_hash_t symbol_nodes
This is the set of SymbolNode instances.
Definition static_literals.h:67
pm_static_literals_t::float_nodes
pm_node_hash_t float_nodes
This is the set of FloatNode instances.
Definition static_literals.h:47
pm_static_literals_t::integer_nodes
pm_node_hash_t integer_nodes
This is the set of IntegerNode and SourceLineNode instances.
Definition static_literals.h:42