prism 2.0.0-arm-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +881 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +58 -0
- data/LICENSE.md +7 -0
- data/Makefile +145 -0
- data/README.md +81 -0
- data/config.yml +4752 -0
- data/docs/build_system.md +119 -0
- data/docs/configuration.md +69 -0
- data/docs/cruby_compilation.md +27 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +121 -0
- data/docs/fuzzing.md +81 -0
- data/docs/heredocs.md +36 -0
- data/docs/javascript.md +133 -0
- data/docs/local_variable_depth.md +229 -0
- data/docs/mapping.md +117 -0
- data/docs/parser_translation.md +24 -0
- data/docs/parsing_rules.md +22 -0
- data/docs/releasing.md +147 -0
- data/docs/relocation.md +32 -0
- data/docs/ripper_translation.md +63 -0
- data/docs/ruby_api.md +45 -0
- data/docs/ruby_parser_translation.md +19 -0
- data/docs/serialization.md +244 -0
- data/docs/testing.md +72 -0
- data/ext/prism/api_node.c +7005 -0
- data/ext/prism/extconf.rb +126 -0
- data/ext/prism/extension.c +1768 -0
- data/ext/prism/extension.h +19 -0
- data/include/prism/arena.h +45 -0
- data/include/prism/arena.hpp +42 -0
- data/include/prism/ast.h +10381 -0
- data/include/prism/ast.hpp +641 -0
- data/include/prism/buffer.h +60 -0
- data/include/prism/buffer.hpp +55 -0
- data/include/prism/comments.h +72 -0
- data/include/prism/compiler/accel.h +26 -0
- data/include/prism/compiler/align.h +36 -0
- data/include/prism/compiler/assume.h +25 -0
- data/include/prism/compiler/branch.h +26 -0
- data/include/prism/compiler/bswap.h +46 -0
- data/include/prism/compiler/cplusplus.hpp +16 -0
- data/include/prism/compiler/endianness.h +34 -0
- data/include/prism/compiler/exceptions.hpp +17 -0
- data/include/prism/compiler/exported.h +24 -0
- data/include/prism/compiler/fallthrough.h +22 -0
- data/include/prism/compiler/filesystem.h +32 -0
- data/include/prism/compiler/flex_array.h +19 -0
- data/include/prism/compiler/force_inline.h +21 -0
- data/include/prism/compiler/format.h +27 -0
- data/include/prism/compiler/inline.h +17 -0
- data/include/prism/compiler/lifetimebound.hpp +25 -0
- data/include/prism/compiler/nodiscard.h +22 -0
- data/include/prism/compiler/nonnull.h +18 -0
- data/include/prism/compiler/unused.h +18 -0
- data/include/prism/constant_pool.h +106 -0
- data/include/prism/diagnostic.h +111 -0
- data/include/prism/errors_format.h +61 -0
- data/include/prism/excludes.h +29 -0
- data/include/prism/integer.h +41 -0
- data/include/prism/internal/allocator.h +68 -0
- data/include/prism/internal/allocator_debug.h +88 -0
- data/include/prism/internal/arena.h +108 -0
- data/include/prism/internal/bit.h +42 -0
- data/include/prism/internal/buffer.h +94 -0
- data/include/prism/internal/char.h +145 -0
- data/include/prism/internal/comments.h +53 -0
- data/include/prism/internal/constant_pool.h +152 -0
- data/include/prism/internal/diagnostic.h +389 -0
- data/include/prism/internal/encoding.h +242 -0
- data/include/prism/internal/integer.h +68 -0
- data/include/prism/internal/isinf.h +16 -0
- data/include/prism/internal/line_offset_list.h +34 -0
- data/include/prism/internal/list.h +62 -0
- data/include/prism/internal/magic_comments.h +23 -0
- data/include/prism/internal/memchr.h +15 -0
- data/include/prism/internal/node.h +42 -0
- data/include/prism/internal/options.h +232 -0
- data/include/prism/internal/parser.h +1004 -0
- data/include/prism/internal/regexp.h +26 -0
- data/include/prism/internal/serialize.h +39 -0
- data/include/prism/internal/source.h +72 -0
- data/include/prism/internal/static_literals.h +100 -0
- data/include/prism/internal/stringy.h +30 -0
- data/include/prism/internal/strncasecmp.h +18 -0
- data/include/prism/internal/strpbrk.h +33 -0
- data/include/prism/internal/tokens.h +11 -0
- data/include/prism/internal/xxh3.h +16 -0
- data/include/prism/json.h +40 -0
- data/include/prism/line_offset_list.h +69 -0
- data/include/prism/magic_comments.h +53 -0
- data/include/prism/node.h +139 -0
- data/include/prism/node.hpp +272 -0
- data/include/prism/node_type.hpp +38 -0
- data/include/prism/options.h +363 -0
- data/include/prism/options.hpp +43 -0
- data/include/prism/parser.h +433 -0
- data/include/prism/parser.hpp +274 -0
- data/include/prism/prettyprint.h +39 -0
- data/include/prism/serialize.h +123 -0
- data/include/prism/source.h +163 -0
- data/include/prism/stream.h +36 -0
- data/include/prism/string_query.h +82 -0
- data/include/prism/stringy.h +61 -0
- data/include/prism/stringy.hpp +31 -0
- data/include/prism/version.h +46 -0
- data/include/prism.h +123 -0
- data/include/prism.hpp +24 -0
- data/lib/prism/3.3/prism.so +0 -0
- data/lib/prism/3.4/prism.so +0 -0
- data/lib/prism/4.0/prism.so +0 -0
- data/lib/prism/compiler.rb +815 -0
- data/lib/prism/desugar_compiler.rb +463 -0
- data/lib/prism/dispatcher.rb +2383 -0
- data/lib/prism/dot_visitor.rb +4848 -0
- data/lib/prism/dsl.rb +1369 -0
- data/lib/prism/ffi.rb +746 -0
- data/lib/prism/inspect_visitor.rb +2425 -0
- data/lib/prism/lex_compat.rb +953 -0
- data/lib/prism/mutation_compiler.rb +780 -0
- data/lib/prism/node.rb +33940 -0
- data/lib/prism/node_ext.rb +504 -0
- data/lib/prism/node_find.rb +215 -0
- data/lib/prism/parse_result/errors.rb +72 -0
- data/lib/prism/parse_result/newlines.rb +423 -0
- data/lib/prism/parse_result.rb +1236 -0
- data/lib/prism/pattern.rb +314 -0
- data/lib/prism/polyfill/append_as_bytes.rb +15 -0
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/scan_byte.rb +14 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/polyfill/warn.rb +36 -0
- data/lib/prism/reflection.rb +427 -0
- data/lib/prism/relocation.rb +567 -0
- data/lib/prism/serialize.rb +4589 -0
- data/lib/prism/string_query.rb +54 -0
- data/lib/prism/translation/parser/builder.rb +70 -0
- data/lib/prism/translation/parser/compiler.rb +2226 -0
- data/lib/prism/translation/parser/lexer.rb +769 -0
- data/lib/prism/translation/parser.rb +376 -0
- data/lib/prism/translation/parser_current.rb +26 -0
- data/lib/prism/translation/parser_versions.rb +36 -0
- data/lib/prism/translation/ripper/filter.rb +53 -0
- data/lib/prism/translation/ripper/lexer.rb +133 -0
- data/lib/prism/translation/ripper/sexp.rb +118 -0
- data/lib/prism/translation/ripper/shim.rb +7 -0
- data/lib/prism/translation/ripper.rb +4278 -0
- data/lib/prism/translation/ruby_parser.rb +1721 -0
- data/lib/prism/translation.rb +20 -0
- data/lib/prism/visitor.rb +1440 -0
- data/lib/prism.rb +168 -0
- data/prism.gemspec +251 -0
- data/rbi/generated/prism/compiler.rbi +489 -0
- data/rbi/generated/prism/desugar_compiler.rbi +306 -0
- data/rbi/generated/prism/dispatcher.rbi +1138 -0
- data/rbi/generated/prism/dot_visitor.rbi +618 -0
- data/rbi/generated/prism/dsl.rbi +751 -0
- data/rbi/generated/prism/inspect_visitor.rbi +503 -0
- data/rbi/generated/prism/lex_compat.rbi +162 -0
- data/rbi/generated/prism/mutation_compiler.rbi +464 -0
- data/rbi/generated/prism/node.rbi +15143 -0
- data/rbi/generated/prism/node_ext.rbi +259 -0
- data/rbi/generated/prism/node_find.rbi +79 -0
- data/rbi/generated/prism/parse_result/errors.rbi +21 -0
- data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
- data/rbi/generated/prism/parse_result.rbi +776 -0
- data/rbi/generated/prism/pattern.rbi +134 -0
- data/rbi/generated/prism/reflection.rbi +89 -0
- data/rbi/generated/prism/relocation.rbi +329 -0
- data/rbi/generated/prism/serialize.rbi +185 -0
- data/rbi/generated/prism/string_query.rbi +43 -0
- data/rbi/generated/prism/translation.rbi +7 -0
- data/rbi/generated/prism/visitor.rbi +650 -0
- data/rbi/generated/prism.rbi +86 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser_versions.rbi +28 -0
- data/rbi/prism/translation/ripper.rbi +15 -0
- data/rbi/rubyvm/node_find.rbi +14 -0
- data/sig/generated/prism/compiler.rbs +492 -0
- data/sig/generated/prism/desugar_compiler.rbs +305 -0
- data/sig/generated/prism/dispatcher.rbs +1292 -0
- data/sig/generated/prism/dot_visitor.rbs +635 -0
- data/sig/generated/prism/dsl.rbs +928 -0
- data/sig/generated/prism/inspect_visitor.rbs +509 -0
- data/sig/generated/prism/lex_compat.rbs +166 -0
- data/sig/generated/prism/mutation_compiler.rbs +464 -0
- data/sig/generated/prism/node.rbs +21632 -0
- data/sig/generated/prism/node_ext.rbs +290 -0
- data/sig/generated/prism/node_find.rbs +90 -0
- data/sig/generated/prism/parse_result/errors.rbs +22 -0
- data/sig/generated/prism/parse_result/newlines.rbs +223 -0
- data/sig/generated/prism/parse_result.rbs +871 -0
- data/sig/generated/prism/pattern.rbs +156 -0
- data/sig/generated/prism/reflection.rbs +101 -0
- data/sig/generated/prism/relocation.rbs +428 -0
- data/sig/generated/prism/serialize.rbs +200 -0
- data/sig/generated/prism/string_query.rbs +43 -0
- data/sig/generated/prism/translation.rbs +8 -0
- data/sig/generated/prism/visitor.rbs +1111 -0
- data/sig/generated/prism.rbs +84 -0
- data/sig/manifest.yaml +2 -0
- data/src/arena.c +117 -0
- data/src/buffer.c +389 -0
- data/src/char.c +289 -0
- data/src/comments.c +454 -0
- data/src/constant_pool.c +406 -0
- data/src/diagnostic.c +894 -0
- data/src/encoding.c +5345 -0
- data/src/errors_format.c +519 -0
- data/src/integer.c +681 -0
- data/src/json.c +5733 -0
- data/src/line_offset_list.c +100 -0
- data/src/list.c +24 -0
- data/src/memchr.c +37 -0
- data/src/node.c +4363 -0
- data/src/options.c +445 -0
- data/src/parser.c +371 -0
- data/src/prettyprint.c +9024 -0
- data/src/prism.c +23901 -0
- data/src/regexp.c +1705 -0
- data/src/serialize.c +2660 -0
- data/src/source.c +524 -0
- data/src/static_literals.c +685 -0
- data/src/string_query.c +180 -0
- data/src/stringy.c +61 -0
- data/src/strncasecmp.c +37 -0
- data/src/strpbrk.c +447 -0
- data/src/tokens.c +724 -0
- data/src/xxh3.c +292 -0
- metadata +276 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file node.hpp
|
|
3
|
+
*
|
|
4
|
+
* Checked casts between node structs, iteration over lists of nodes, and
|
|
5
|
+
* walking the tree from C++.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef PRISM_NODE_HPP
|
|
8
|
+
#define PRISM_NODE_HPP
|
|
9
|
+
|
|
10
|
+
#include "prism/compiler/cplusplus.hpp"
|
|
11
|
+
#include "prism/compiler/exceptions.hpp"
|
|
12
|
+
#include "prism/compiler/lifetimebound.hpp"
|
|
13
|
+
|
|
14
|
+
#include "prism/ast.hpp"
|
|
15
|
+
#include "prism/node.h"
|
|
16
|
+
#include "prism/node_type.hpp"
|
|
17
|
+
|
|
18
|
+
#include <cassert>
|
|
19
|
+
#include <cstddef>
|
|
20
|
+
#include <exception>
|
|
21
|
+
#include <functional>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include <type_traits>
|
|
24
|
+
|
|
25
|
+
namespace prism {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether the given node, which must not be null, is of the given struct
|
|
29
|
+
*
|
|
30
|
+
* @tparam T The node struct type to check against.
|
|
31
|
+
* @param node The node to check.
|
|
32
|
+
* @return True if the node is of the given struct, false otherwise.
|
|
33
|
+
*/
|
|
34
|
+
template <typename T> [[nodiscard]] bool
|
|
35
|
+
isa(const pm_node_t *node) noexcept {
|
|
36
|
+
static_assert(is_node_v<T>, "isa<T> requires a node struct declared in ast.h");
|
|
37
|
+
assert(node != nullptr);
|
|
38
|
+
return node->type == node_type_v<T>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Cast the given node, which must not be null and must be of the given struct,
|
|
43
|
+
* to that struct. The type is checked in debug builds.
|
|
44
|
+
*
|
|
45
|
+
* @tparam T The node struct type to cast to.
|
|
46
|
+
* @param node The node to cast.
|
|
47
|
+
* @return The node cast to the given struct.
|
|
48
|
+
*/
|
|
49
|
+
template <typename T> [[nodiscard]] T *
|
|
50
|
+
cast(pm_node_t *node) noexcept {
|
|
51
|
+
assert(isa<T>(node));
|
|
52
|
+
return reinterpret_cast<T *>(node);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Cast the given node, which must not be null and must be of the given struct,
|
|
57
|
+
* to that struct. The type is checked in debug builds.
|
|
58
|
+
*
|
|
59
|
+
* @tparam T The node struct type to cast to.
|
|
60
|
+
* @param node The node to cast.
|
|
61
|
+
* @return The node cast to the given struct.
|
|
62
|
+
*/
|
|
63
|
+
template <typename T> [[nodiscard]] const T *
|
|
64
|
+
cast(const pm_node_t *node) noexcept {
|
|
65
|
+
assert(isa<T>(node));
|
|
66
|
+
return reinterpret_cast<const T *>(node);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Cast the given node to the given struct if it is of that struct, and return
|
|
71
|
+
* null otherwise. The node may be null, in which case this returns null.
|
|
72
|
+
*
|
|
73
|
+
* @tparam T The node struct type to cast to.
|
|
74
|
+
* @param node The node to cast.
|
|
75
|
+
* @return The node cast to the given struct if it is of that struct, or null
|
|
76
|
+
* otherwise.
|
|
77
|
+
*/
|
|
78
|
+
template <typename T> [[nodiscard]] T *
|
|
79
|
+
dyn_cast(pm_node_t *node) noexcept {
|
|
80
|
+
return (node != nullptr && isa<T>(node)) ? reinterpret_cast<T *>(node) : nullptr;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Cast the given node to the given struct if it is of that struct, and return
|
|
85
|
+
* null otherwise. The node may be null, in which case this returns null.
|
|
86
|
+
*
|
|
87
|
+
* @tparam T The node struct type to cast to.
|
|
88
|
+
* @param node The node to cast.
|
|
89
|
+
* @return The node cast to the given struct if it is of that struct, or null
|
|
90
|
+
* otherwise.
|
|
91
|
+
*/
|
|
92
|
+
template <typename T> [[nodiscard]] const T *
|
|
93
|
+
dyn_cast(const pm_node_t *node) noexcept {
|
|
94
|
+
return (node != nullptr && isa<T>(node)) ? reinterpret_cast<const T *>(node) : nullptr;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Return the pm_node_t embedded at the start of the given node struct.
|
|
99
|
+
*
|
|
100
|
+
* @tparam T The node struct type.
|
|
101
|
+
* @param node The node struct to upcast.
|
|
102
|
+
* @return The pm_node_t embedded at the start of the node struct.
|
|
103
|
+
*/
|
|
104
|
+
template <typename T> [[nodiscard]] pm_node_t *
|
|
105
|
+
upcast(T *node) noexcept {
|
|
106
|
+
static_assert(is_node_v<T>, "upcast requires a node struct declared in ast.h");
|
|
107
|
+
return &node->base;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Return the pm_node_t embedded at the start of the given node struct.
|
|
112
|
+
*
|
|
113
|
+
* @tparam T The node struct type.
|
|
114
|
+
* @param node The node struct to upcast.
|
|
115
|
+
* @return The pm_node_t embedded at the start of the node struct.
|
|
116
|
+
*/
|
|
117
|
+
template <typename T> [[nodiscard]] const pm_node_t *
|
|
118
|
+
upcast(const T *node) noexcept {
|
|
119
|
+
static_assert(is_node_v<T>, "upcast requires a node struct declared in ast.h");
|
|
120
|
+
return &node->base;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The nodes in a list, usable in a range-based for loop. It refers to the list
|
|
125
|
+
* rather than copying it, so the list must outlive it.
|
|
126
|
+
*/
|
|
127
|
+
class node_range {
|
|
128
|
+
public:
|
|
129
|
+
/**
|
|
130
|
+
* Create a range over the nodes in the given list.
|
|
131
|
+
*
|
|
132
|
+
* @param list The list of nodes to create a range for.
|
|
133
|
+
*/
|
|
134
|
+
explicit node_range(const pm_node_list_t &list PRISM_LIFETIMEBOUND) noexcept : list_(&list) {}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A pointer to the first node.
|
|
138
|
+
*
|
|
139
|
+
* @return A pointer to the first node, or null if the list is empty.
|
|
140
|
+
*/
|
|
141
|
+
pm_node_t *const *begin() const noexcept { return list_->nodes; }
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A pointer one past the last node.
|
|
145
|
+
*
|
|
146
|
+
* @return A pointer one past the last node, or null if the list is empty.
|
|
147
|
+
*/
|
|
148
|
+
pm_node_t *const *end() const noexcept { return list_->nodes + list_->size; }
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The number of nodes.
|
|
152
|
+
*
|
|
153
|
+
* @return The number of nodes.
|
|
154
|
+
*/
|
|
155
|
+
std::size_t size() const noexcept { return list_->size; }
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Whether there are no nodes.
|
|
159
|
+
*
|
|
160
|
+
* @return True if there are no nodes, false otherwise.
|
|
161
|
+
*/
|
|
162
|
+
[[nodiscard]] bool empty() const noexcept { return list_->size == 0; }
|
|
163
|
+
|
|
164
|
+
private:
|
|
165
|
+
const pm_node_list_t *list_;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
namespace detail {
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The state shared between a walk and its C callback, passed through the C
|
|
172
|
+
* function's void * data parameter.
|
|
173
|
+
*/
|
|
174
|
+
template <typename F> struct visit_context {
|
|
175
|
+
/**
|
|
176
|
+
* The context for a visit, holding the visitor and any exception thrown.
|
|
177
|
+
*
|
|
178
|
+
* @param visitor The visitor callable to be used for each node.
|
|
179
|
+
*/
|
|
180
|
+
explicit visit_context(F *visitor) noexcept : callable(visitor) {}
|
|
181
|
+
|
|
182
|
+
/** The visitor that the walk calls for each node. */
|
|
183
|
+
F *callable;
|
|
184
|
+
|
|
185
|
+
#ifdef PRISM_HAS_EXCEPTIONS
|
|
186
|
+
/** The exception thrown by the visitor, if any. */
|
|
187
|
+
std::exception_ptr exception;
|
|
188
|
+
#endif
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Forwards the C visitor callback to a C++ callable. An exception cannot unwind
|
|
193
|
+
* through the C frames that call this function, so one thrown by the callable
|
|
194
|
+
* is caught here and the walk is stopped. The function that started the walk
|
|
195
|
+
* rethrows it once the C walk has returned. Without exceptions, the callable
|
|
196
|
+
* cannot throw, so it is called directly.
|
|
197
|
+
*
|
|
198
|
+
* @tparam F The type of the visitor callable.
|
|
199
|
+
* @param node The current node being visited.
|
|
200
|
+
* @param data The visit context containing the visitor and exception state.
|
|
201
|
+
* @return The result of the visit, indicating whether to descend, skip, or stop.
|
|
202
|
+
*/
|
|
203
|
+
template <typename F> pm_visit_result_t
|
|
204
|
+
visit_callback(const pm_node_t *node, void *data) noexcept {
|
|
205
|
+
visit_context<F> *context = static_cast<visit_context<F> *>(data);
|
|
206
|
+
|
|
207
|
+
#ifdef PRISM_HAS_EXCEPTIONS
|
|
208
|
+
try {
|
|
209
|
+
return std::invoke(*context->callable, node);
|
|
210
|
+
} catch (...) {
|
|
211
|
+
context->exception = std::current_exception();
|
|
212
|
+
return PM_VISIT_STOP;
|
|
213
|
+
}
|
|
214
|
+
#else
|
|
215
|
+
return std::invoke(*context->callable, node);
|
|
216
|
+
#endif
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Walk the tree rooted at the given node in pre-order, calling the visitor with
|
|
223
|
+
* each node. The visitor returns PM_VISIT_DESCEND to continue into that node's
|
|
224
|
+
* children, PM_VISIT_SKIP to continue past them, or PM_VISIT_STOP to end the
|
|
225
|
+
* walk. Returns false if the walk was stopped. If the visitor throws, the walk
|
|
226
|
+
* stops and the exception propagates from this function.
|
|
227
|
+
*
|
|
228
|
+
* @tparam F The type of the visitor callable.
|
|
229
|
+
* @param node The root node to start the walk from.
|
|
230
|
+
* @param visitor The visitor callable to invoke for each node.
|
|
231
|
+
* @return True if the walk completed, false if it was stopped.
|
|
232
|
+
*/
|
|
233
|
+
template <typename F> bool
|
|
234
|
+
visit_node(const pm_node_t *node, F &&visitor) {
|
|
235
|
+
static_assert(std::is_invocable_r_v<pm_visit_result_t, F &, const pm_node_t *>, "visit_node requires a callable taking const pm_node_t * and returning pm_visit_result_t");
|
|
236
|
+
detail::visit_context<std::remove_reference_t<F>> context(std::addressof(visitor));
|
|
237
|
+
bool completed = pm_visit_node(node, detail::visit_callback<std::remove_reference_t<F>>, &context);
|
|
238
|
+
|
|
239
|
+
#ifdef PRISM_HAS_EXCEPTIONS
|
|
240
|
+
if (context.exception) std::rethrow_exception(context.exception);
|
|
241
|
+
#endif
|
|
242
|
+
|
|
243
|
+
return completed;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Walk the children of the given node, as visit_node does for every node whose
|
|
248
|
+
* visitor returns PM_VISIT_DESCEND. Returns false if the walk was stopped. If
|
|
249
|
+
* the visitor throws, the walk stops and the exception propagates from this
|
|
250
|
+
* function.
|
|
251
|
+
*
|
|
252
|
+
* @tparam F The type of the visitor callable.
|
|
253
|
+
* @param node The node whose children to walk.
|
|
254
|
+
* @param visitor The visitor callable to invoke for each child node.
|
|
255
|
+
* @return True if the walk completed, false if it was stopped.
|
|
256
|
+
*/
|
|
257
|
+
template <typename F> bool
|
|
258
|
+
visit_child_nodes(const pm_node_t *node, F &&visitor) {
|
|
259
|
+
static_assert(std::is_invocable_r_v<pm_visit_result_t, F &, const pm_node_t *>, "visit_child_nodes requires a callable taking const pm_node_t * and returning pm_visit_result_t");
|
|
260
|
+
detail::visit_context<std::remove_reference_t<F>> context(std::addressof(visitor));
|
|
261
|
+
bool completed = pm_visit_child_nodes(node, detail::visit_callback<std::remove_reference_t<F>>, &context);
|
|
262
|
+
|
|
263
|
+
#ifdef PRISM_HAS_EXCEPTIONS
|
|
264
|
+
if (context.exception) std::rethrow_exception(context.exception);
|
|
265
|
+
#endif
|
|
266
|
+
|
|
267
|
+
return completed;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
#endif
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file node_type.hpp
|
|
3
|
+
*
|
|
4
|
+
* The traits that map node structs to node types. The specialization for each
|
|
5
|
+
* node struct is generated into ast.hpp.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef PRISM_NODE_TYPE_HPP
|
|
8
|
+
#define PRISM_NODE_TYPE_HPP
|
|
9
|
+
|
|
10
|
+
#include "prism/compiler/cplusplus.hpp"
|
|
11
|
+
|
|
12
|
+
#include "prism/ast.h"
|
|
13
|
+
|
|
14
|
+
#include <type_traits>
|
|
15
|
+
|
|
16
|
+
namespace prism {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Maps a node struct to its node type, as in node_type<pm_call_node_t>::value
|
|
20
|
+
* being PM_CALL_NODE. Only the node structs declared in ast.h have a value.
|
|
21
|
+
*/
|
|
22
|
+
template <typename T> struct node_type {};
|
|
23
|
+
|
|
24
|
+
/** The node type of the given node struct. */
|
|
25
|
+
template <typename T> inline constexpr pm_node_type_t node_type_v = node_type<T>::value;
|
|
26
|
+
|
|
27
|
+
/** Whether the given type is one of the node structs declared in ast.h. */
|
|
28
|
+
template <typename T, typename = void> struct is_node : std::false_type {};
|
|
29
|
+
|
|
30
|
+
/** Whether the given type is one of the node structs declared in ast.h. */
|
|
31
|
+
template <typename T> struct is_node<T, std::void_t<decltype(node_type<T>::value)>> : std::true_type {};
|
|
32
|
+
|
|
33
|
+
/** Whether the given type is one of the node structs declared in ast.h. */
|
|
34
|
+
template <typename T> inline constexpr bool is_node_v = is_node<T>::value;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#endif
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file options.h
|
|
3
|
+
*
|
|
4
|
+
* The options that can be passed to parsing.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_OPTIONS_H
|
|
7
|
+
#define PRISM_OPTIONS_H
|
|
8
|
+
|
|
9
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
#include "prism/compiler/nodiscard.h"
|
|
11
|
+
#include "prism/compiler/nonnull.h"
|
|
12
|
+
|
|
13
|
+
#include "prism/stringy.h"
|
|
14
|
+
|
|
15
|
+
#include <stdbool.h>
|
|
16
|
+
#include <stddef.h>
|
|
17
|
+
|
|
18
|
+
#ifdef __cplusplus
|
|
19
|
+
extern "C" {
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A scope of locals surrounding the code that is being parsed.
|
|
24
|
+
*/
|
|
25
|
+
typedef struct pm_options_scope_t pm_options_scope_t;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The options that can be passed to the parser.
|
|
29
|
+
*/
|
|
30
|
+
typedef struct pm_options_t pm_options_t;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* String literals should not be frozen.
|
|
34
|
+
*/
|
|
35
|
+
#define PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED ((int8_t) -1)
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* String literals may be frozen or mutable depending on the implementation
|
|
39
|
+
* default.
|
|
40
|
+
*/
|
|
41
|
+
#define PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET ((int8_t) 0)
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* String literals should be made frozen.
|
|
45
|
+
*/
|
|
46
|
+
#define PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED ((int8_t) 1)
|
|
47
|
+
|
|
48
|
+
/** The default value for parameters. */
|
|
49
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_NONE = 0x0;
|
|
50
|
+
|
|
51
|
+
/** When the scope is forwarding with the * parameter. */
|
|
52
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_POSITIONALS = 0x1;
|
|
53
|
+
|
|
54
|
+
/** When the scope is forwarding with the ** parameter. */
|
|
55
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_KEYWORDS = 0x2;
|
|
56
|
+
|
|
57
|
+
/** When the scope is forwarding with the & parameter. */
|
|
58
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_BLOCK = 0x4;
|
|
59
|
+
|
|
60
|
+
/** When the scope is forwarding with the ... parameter. */
|
|
61
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_ALL = 0x8;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The callback called when additional switches are found in a shebang comment
|
|
65
|
+
* that need to be processed by the runtime.
|
|
66
|
+
*
|
|
67
|
+
* @param options The options struct that may be updated by this callback.
|
|
68
|
+
* Certain fields will be checked for changes, specifically encoding,
|
|
69
|
+
* command_line, and frozen_string_literal.
|
|
70
|
+
* @param source The source of the shebang comment.
|
|
71
|
+
* @param length The length of the source.
|
|
72
|
+
* @param shebang_callback_data Any additional data that should be passed along
|
|
73
|
+
* to the callback.
|
|
74
|
+
*/
|
|
75
|
+
typedef void (*pm_options_shebang_callback_t)(pm_options_t *options, const uint8_t *source, size_t length, void *shebang_callback_data);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A bit representing whether or not the command line -a option was set. -a
|
|
79
|
+
* splits the input line $_ into $F.
|
|
80
|
+
*/
|
|
81
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_A = 0x1;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A bit representing whether or not the command line -e option was set. -e
|
|
85
|
+
* allow the user to specify a script to be executed. This is necessary for
|
|
86
|
+
* prism to know because certain warnings are not generated when -e is used.
|
|
87
|
+
*/
|
|
88
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_E = 0x2;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A bit representing whether or not the command line -l option was set. -l
|
|
92
|
+
* chomps the input line by default.
|
|
93
|
+
*/
|
|
94
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_L = 0x4;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A bit representing whether or not the command line -n option was set. -n
|
|
98
|
+
* wraps the script in a while gets loop.
|
|
99
|
+
*/
|
|
100
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_N = 0x8;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A bit representing whether or not the command line -p option was set. -p
|
|
104
|
+
* prints the value of $_ at the end of each loop.
|
|
105
|
+
*/
|
|
106
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_P = 0x10;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A bit representing whether or not the command line -x option was set. -x
|
|
110
|
+
* searches the input file for a shebang that includes "ruby".
|
|
111
|
+
*/
|
|
112
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_X = 0x20;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Allocate a new options struct. If the options struct cannot be allocated,
|
|
116
|
+
* this function aborts the process.
|
|
117
|
+
*
|
|
118
|
+
* @returns A new options struct with default values. It is the responsibility
|
|
119
|
+
* of the caller to free this struct using pm_options_free().
|
|
120
|
+
*/
|
|
121
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_options_t * pm_options_new(void);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Free both the held memory of the given options struct and the struct itself.
|
|
125
|
+
*
|
|
126
|
+
* @param options The options struct to free.
|
|
127
|
+
*/
|
|
128
|
+
PRISM_EXPORTED_FUNCTION void pm_options_free(pm_options_t *options) PRISM_NONNULL(1);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Set the shebang callback option on the given options struct.
|
|
132
|
+
*
|
|
133
|
+
* @param options The options struct to set the shebang callback on.
|
|
134
|
+
* @param shebang_callback The shebang callback to set.
|
|
135
|
+
* @param shebang_callback_data Any additional data that should be passed along
|
|
136
|
+
* to the callback.
|
|
137
|
+
*/
|
|
138
|
+
PRISM_EXPORTED_FUNCTION void pm_options_shebang_callback_set(pm_options_t *options, pm_options_shebang_callback_t shebang_callback, void *shebang_callback_data) PRISM_NONNULL(1);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get the filepath option on the given options struct.
|
|
142
|
+
*
|
|
143
|
+
* @param options The options struct to get the filepath from.
|
|
144
|
+
* @returns The filepath.
|
|
145
|
+
*/
|
|
146
|
+
PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_filepath(const pm_options_t *options) PRISM_NONNULL(1);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Set the filepath option on the given options struct.
|
|
150
|
+
*
|
|
151
|
+
* @param options The options struct to set the filepath on.
|
|
152
|
+
* @param filepath The filepath to set.
|
|
153
|
+
*/
|
|
154
|
+
PRISM_EXPORTED_FUNCTION void pm_options_filepath_set(pm_options_t *options, const char *filepath) PRISM_NONNULL(1);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Set the line option on the given options struct.
|
|
158
|
+
*
|
|
159
|
+
* @param options The options struct to set the line on.
|
|
160
|
+
* @param line The line to set.
|
|
161
|
+
*/
|
|
162
|
+
PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, int32_t line) PRISM_NONNULL(1);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Set the encoding option on the given options struct.
|
|
166
|
+
*
|
|
167
|
+
* @param options The options struct to set the encoding on.
|
|
168
|
+
* @param encoding The encoding to set.
|
|
169
|
+
*/
|
|
170
|
+
PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, const char *encoding) PRISM_NONNULL(1);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Set the encoding_locked option on the given options struct.
|
|
174
|
+
*
|
|
175
|
+
* @param options The options struct to set the encoding_locked value on.
|
|
176
|
+
* @param encoding_locked The encoding_locked value to set.
|
|
177
|
+
*/
|
|
178
|
+
PRISM_EXPORTED_FUNCTION void pm_options_encoding_locked_set(pm_options_t *options, bool encoding_locked) PRISM_NONNULL(1);
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Set the frozen string literal option on the given options struct.
|
|
182
|
+
*
|
|
183
|
+
* @param options The options struct to set the frozen string literal value on.
|
|
184
|
+
* @param frozen_string_literal The frozen string literal value to set.
|
|
185
|
+
*/
|
|
186
|
+
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal) PRISM_NONNULL(1);
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Sets the command line option on the given options struct.
|
|
190
|
+
*
|
|
191
|
+
* @param options The options struct to set the command line option on.
|
|
192
|
+
* @param command_line The command_line value to set.
|
|
193
|
+
*/
|
|
194
|
+
PRISM_EXPORTED_FUNCTION void pm_options_command_line_set(pm_options_t *options, uint8_t command_line) PRISM_NONNULL(1);
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Set the version option on the given options struct by parsing the given
|
|
198
|
+
* string. If the string contains an invalid option, this returns false.
|
|
199
|
+
* Otherwise, it returns true.
|
|
200
|
+
*
|
|
201
|
+
* @param options The options struct to set the version on.
|
|
202
|
+
* @param version The version to set.
|
|
203
|
+
* @param length The length of the version string.
|
|
204
|
+
* @returns Whether or not the version was parsed successfully.
|
|
205
|
+
*/
|
|
206
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const char *version, size_t length) PRISM_NONNULL(1);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Set the version option on the given options struct to the lowest version of
|
|
210
|
+
* Ruby that prism supports.
|
|
211
|
+
*
|
|
212
|
+
* @param options The options struct to set the version on.
|
|
213
|
+
*/
|
|
214
|
+
PRISM_EXPORTED_FUNCTION void pm_options_version_set_lowest(pm_options_t *options) PRISM_NONNULL(1);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Set the version option on the given options struct to the highest version of
|
|
218
|
+
* Ruby that prism supports.
|
|
219
|
+
*
|
|
220
|
+
* @param options The options struct to set the version on.
|
|
221
|
+
*/
|
|
222
|
+
PRISM_EXPORTED_FUNCTION void pm_options_version_set_highest(pm_options_t *options) PRISM_NONNULL(1);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Set the main script option on the given options struct.
|
|
226
|
+
*
|
|
227
|
+
* @param options The options struct to set the main script value on.
|
|
228
|
+
* @param main_script The main script value to set.
|
|
229
|
+
*/
|
|
230
|
+
PRISM_EXPORTED_FUNCTION void pm_options_main_script_set(pm_options_t *options, bool main_script) PRISM_NONNULL(1);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Set the partial script option on the given options struct.
|
|
234
|
+
*
|
|
235
|
+
* @param options The options struct to set the partial script value on.
|
|
236
|
+
* @param partial_script The partial script value to set.
|
|
237
|
+
*/
|
|
238
|
+
PRISM_EXPORTED_FUNCTION void pm_options_partial_script_set(pm_options_t *options, bool partial_script) PRISM_NONNULL(1);
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get the freeze option on the given options struct.
|
|
242
|
+
*
|
|
243
|
+
* @param options The options struct to get the freeze value from.
|
|
244
|
+
* @returns The freeze value.
|
|
245
|
+
*/
|
|
246
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_freeze(const pm_options_t *options) PRISM_NONNULL(1);
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Set the freeze option on the given options struct.
|
|
250
|
+
*
|
|
251
|
+
* @param options The options struct to set the freeze value on.
|
|
252
|
+
* @param freeze The freeze value to set.
|
|
253
|
+
*/
|
|
254
|
+
PRISM_EXPORTED_FUNCTION void pm_options_freeze_set(pm_options_t *options, bool freeze) PRISM_NONNULL(1);
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Get the attach_comments option on the given options struct.
|
|
258
|
+
*
|
|
259
|
+
* @param options The options struct to get the attach_comments value from.
|
|
260
|
+
* @returns The attach_comments value.
|
|
261
|
+
*/
|
|
262
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_attach_comments(const pm_options_t *options) PRISM_NONNULL(1);
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Set the attach_comments option on the given options struct. When this is
|
|
266
|
+
* set, the parser's comment list is sorted by start offset after parsing and
|
|
267
|
+
* every comment is assigned an owning node. Without it, comments are left in
|
|
268
|
+
* the order they were lexed and no nodes own any comments.
|
|
269
|
+
*
|
|
270
|
+
* @param options The options struct to set the attach_comments value on.
|
|
271
|
+
* @param attach_comments The attach_comments value to set.
|
|
272
|
+
*/
|
|
273
|
+
PRISM_EXPORTED_FUNCTION void pm_options_attach_comments_set(pm_options_t *options, bool attach_comments) PRISM_NONNULL(1);
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Get the raise_error option on the given options struct.
|
|
277
|
+
*
|
|
278
|
+
* @param options The options struct to get the raise_error value from.
|
|
279
|
+
* @returns The raise_error value.
|
|
280
|
+
*/
|
|
281
|
+
PRISM_EXPORTED_FUNCTION uint8_t pm_options_raise_error(const pm_options_t *options) PRISM_NONNULL(1);
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Set the raise_error option on the given options struct.
|
|
285
|
+
*
|
|
286
|
+
* @param options The options struct to set the raise_error value on.
|
|
287
|
+
* @param raise_error The raise_error value to set.
|
|
288
|
+
*/
|
|
289
|
+
PRISM_EXPORTED_FUNCTION void pm_options_raise_error_set(pm_options_t *options, uint8_t raise_error) PRISM_NONNULL(1);
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Allocate and zero out the scopes array on the given options struct.
|
|
293
|
+
*
|
|
294
|
+
* @param options The options struct to initialize the scopes array on.
|
|
295
|
+
* @param scopes_count The number of scopes to allocate.
|
|
296
|
+
* @returns Whether or not the scopes array was initialized successfully.
|
|
297
|
+
*/
|
|
298
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_scopes_init(pm_options_t *options, size_t scopes_count) PRISM_NONNULL(1);
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Return a constant pointer to the scope at the given index within the given
|
|
302
|
+
* options.
|
|
303
|
+
*
|
|
304
|
+
* @param options The options struct to get the scope from.
|
|
305
|
+
* @param index The index of the scope to get.
|
|
306
|
+
* @returns A constant pointer to the scope at the given index.
|
|
307
|
+
*/
|
|
308
|
+
PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope(const pm_options_t *options, size_t index) PRISM_NONNULL(1);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Return a mutable pointer to the scope at the given index within the given
|
|
312
|
+
* options.
|
|
313
|
+
*
|
|
314
|
+
* @param options The options struct to get the scope from.
|
|
315
|
+
* @param index The index of the scope to get.
|
|
316
|
+
* @returns A mutable pointer to the scope at the given index.
|
|
317
|
+
*/
|
|
318
|
+
PRISM_EXPORTED_FUNCTION pm_options_scope_t * pm_options_scope_mut(pm_options_t *options, size_t index) PRISM_NONNULL(1);
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Create a new options scope struct. This will hold a set of locals that are in
|
|
322
|
+
* scope surrounding the code that is being parsed. If the scope was unable to
|
|
323
|
+
* allocate its locals, this function will abort the process.
|
|
324
|
+
*
|
|
325
|
+
* @param scope The scope struct to initialize.
|
|
326
|
+
* @param locals_count The number of locals to allocate.
|
|
327
|
+
*/
|
|
328
|
+
PRISM_EXPORTED_FUNCTION void pm_options_scope_init(pm_options_scope_t *scope, size_t locals_count) PRISM_NONNULL(1);
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Return a constant pointer to the local at the given index within the given
|
|
332
|
+
* scope.
|
|
333
|
+
*
|
|
334
|
+
* @param scope The scope struct to get the local from.
|
|
335
|
+
* @param index The index of the local to get.
|
|
336
|
+
* @returns A constant pointer to the local at the given index.
|
|
337
|
+
*/
|
|
338
|
+
PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_scope_local(const pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1);
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Return a mutable pointer to the local at the given index within the given
|
|
342
|
+
* scope, for setting the local's name with pm_string_init. The parser copies
|
|
343
|
+
* the name when it is created, so its bytes must remain valid until then.
|
|
344
|
+
*
|
|
345
|
+
* @param scope The scope struct to get the local from.
|
|
346
|
+
* @param index The index of the local to get.
|
|
347
|
+
* @returns A mutable pointer to the local at the given index.
|
|
348
|
+
*/
|
|
349
|
+
PRISM_EXPORTED_FUNCTION pm_string_t * pm_options_scope_local_mut(pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1);
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Set the forwarding option on the given scope struct.
|
|
353
|
+
*
|
|
354
|
+
* @param scope The scope struct to set the forwarding on.
|
|
355
|
+
* @param forwarding The forwarding value to set.
|
|
356
|
+
*/
|
|
357
|
+
PRISM_EXPORTED_FUNCTION void pm_options_scope_forwarding_set(pm_options_scope_t *scope, uint8_t forwarding) PRISM_NONNULL(1);
|
|
358
|
+
|
|
359
|
+
#ifdef __cplusplus
|
|
360
|
+
}
|
|
361
|
+
#endif
|
|
362
|
+
|
|
363
|
+
#endif
|