herb 0.8.2-x86-linux-musl → 0.8.4-x86-linux-musl
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 +4 -4
- data/ext/herb/error_helpers.c +1 -1
- data/ext/herb/extconf.rb +1 -1
- data/ext/herb/extension.c +1 -1
- data/ext/herb/extension_helpers.c +1 -1
- data/ext/herb/nodes.c +2 -2
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/engine/debug_visitor.rb +24 -1
- data/lib/herb/engine/error_formatter.rb +13 -5
- data/lib/herb/version.rb +1 -1
- data/sig/herb/engine/debug_visitor.rbs +5 -0
- data/src/analyze.c +69 -27
- data/src/ast_node.c +30 -1
- data/src/ast_nodes.c +157 -53
- data/src/errors.c +5 -5
- data/src/extract.c +7 -73
- data/src/herb.c +9 -9
- data/src/include/ast_node.h +2 -0
- data/src/include/extract.h +0 -1
- data/src/include/herb.h +8 -7
- data/src/include/macros.h +8 -0
- data/src/include/position.h +5 -0
- data/src/include/prism_helpers.h +5 -1
- data/src/include/version.h +1 -1
- data/src/parser.c +6 -6
- data/src/parser_helpers.c +4 -4
- data/src/position.c +27 -0
- data/src/pretty_print.c +6 -6
- data/src/prism_helpers.c +14 -15
- data/src/util/hb_system.c +3 -3
- data/src/visitor.c +26 -26
- data/templates/ext/herb/error_helpers.c.erb +1 -1
- data/templates/ext/herb/nodes.c.erb +1 -1
- data/templates/java/error_helpers.c.erb +1 -1
- data/templates/java/nodes.c.erb +2 -2
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +1 -1
- data/templates/rust/src/ast/nodes.rs.erb +2 -2
- data/templates/src/ast_nodes.c.erb +7 -3
- data/templates/src/errors.c.erb +5 -5
- data/templates/src/visitor.c.erb +1 -1
- data/templates/wasm/error_helpers.cpp.erb +1 -1
- data/templates/wasm/nodes.cpp.erb +1 -1
- metadata +2 -1
data/src/visitor.c
CHANGED
|
@@ -24,7 +24,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
24
24
|
const AST_DOCUMENT_NODE_T* document_node = ((const AST_DOCUMENT_NODE_T *) node);
|
|
25
25
|
|
|
26
26
|
if (document_node->children != NULL) {
|
|
27
|
-
for (size_t index = 0; index <
|
|
27
|
+
for (size_t index = 0; index < document_node->children->size; index++) {
|
|
28
28
|
herb_visit_node(hb_array_get(document_node->children, index), visitor, data);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -35,7 +35,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
35
35
|
const AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node = ((const AST_HTML_OPEN_TAG_NODE_T *) node);
|
|
36
36
|
|
|
37
37
|
if (html_open_tag_node->children != NULL) {
|
|
38
|
-
for (size_t index = 0; index <
|
|
38
|
+
for (size_t index = 0; index < html_open_tag_node->children->size; index++) {
|
|
39
39
|
herb_visit_node(hb_array_get(html_open_tag_node->children, index), visitor, data);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
46
46
|
const AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = ((const AST_HTML_CLOSE_TAG_NODE_T *) node);
|
|
47
47
|
|
|
48
48
|
if (html_close_tag_node->children != NULL) {
|
|
49
|
-
for (size_t index = 0; index <
|
|
49
|
+
for (size_t index = 0; index < html_close_tag_node->children->size; index++) {
|
|
50
50
|
herb_visit_node(hb_array_get(html_close_tag_node->children, index), visitor, data);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -61,7 +61,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (html_element_node->body != NULL) {
|
|
64
|
-
for (size_t index = 0; index <
|
|
64
|
+
for (size_t index = 0; index < html_element_node->body->size; index++) {
|
|
65
65
|
herb_visit_node(hb_array_get(html_element_node->body, index), visitor, data);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -76,7 +76,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
76
76
|
const AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = ((const AST_HTML_ATTRIBUTE_VALUE_NODE_T *) node);
|
|
77
77
|
|
|
78
78
|
if (html_attribute_value_node->children != NULL) {
|
|
79
|
-
for (size_t index = 0; index <
|
|
79
|
+
for (size_t index = 0; index < html_attribute_value_node->children->size; index++) {
|
|
80
80
|
herb_visit_node(hb_array_get(html_attribute_value_node->children, index), visitor, data);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -87,7 +87,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
87
87
|
const AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = ((const AST_HTML_ATTRIBUTE_NAME_NODE_T *) node);
|
|
88
88
|
|
|
89
89
|
if (html_attribute_name_node->children != NULL) {
|
|
90
|
-
for (size_t index = 0; index <
|
|
90
|
+
for (size_t index = 0; index < html_attribute_name_node->children->size; index++) {
|
|
91
91
|
herb_visit_node(hb_array_get(html_attribute_name_node->children, index), visitor, data);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -111,7 +111,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
111
111
|
const AST_HTML_COMMENT_NODE_T* html_comment_node = ((const AST_HTML_COMMENT_NODE_T *) node);
|
|
112
112
|
|
|
113
113
|
if (html_comment_node->children != NULL) {
|
|
114
|
-
for (size_t index = 0; index <
|
|
114
|
+
for (size_t index = 0; index < html_comment_node->children->size; index++) {
|
|
115
115
|
herb_visit_node(hb_array_get(html_comment_node->children, index), visitor, data);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -122,7 +122,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
122
122
|
const AST_HTML_DOCTYPE_NODE_T* html_doctype_node = ((const AST_HTML_DOCTYPE_NODE_T *) node);
|
|
123
123
|
|
|
124
124
|
if (html_doctype_node->children != NULL) {
|
|
125
|
-
for (size_t index = 0; index <
|
|
125
|
+
for (size_t index = 0; index < html_doctype_node->children->size; index++) {
|
|
126
126
|
herb_visit_node(hb_array_get(html_doctype_node->children, index), visitor, data);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -133,7 +133,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
133
133
|
const AST_XML_DECLARATION_NODE_T* xml_declaration_node = ((const AST_XML_DECLARATION_NODE_T *) node);
|
|
134
134
|
|
|
135
135
|
if (xml_declaration_node->children != NULL) {
|
|
136
|
-
for (size_t index = 0; index <
|
|
136
|
+
for (size_t index = 0; index < xml_declaration_node->children->size; index++) {
|
|
137
137
|
herb_visit_node(hb_array_get(xml_declaration_node->children, index), visitor, data);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -144,7 +144,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
144
144
|
const AST_CDATA_NODE_T* cdata_node = ((const AST_CDATA_NODE_T *) node);
|
|
145
145
|
|
|
146
146
|
if (cdata_node->children != NULL) {
|
|
147
|
-
for (size_t index = 0; index <
|
|
147
|
+
for (size_t index = 0; index < cdata_node->children->size; index++) {
|
|
148
148
|
herb_visit_node(hb_array_get(cdata_node->children, index), visitor, data);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -155,7 +155,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
155
155
|
const AST_ERB_ELSE_NODE_T* erb_else_node = ((const AST_ERB_ELSE_NODE_T *) node);
|
|
156
156
|
|
|
157
157
|
if (erb_else_node->statements != NULL) {
|
|
158
|
-
for (size_t index = 0; index <
|
|
158
|
+
for (size_t index = 0; index < erb_else_node->statements->size; index++) {
|
|
159
159
|
herb_visit_node(hb_array_get(erb_else_node->statements, index), visitor, data);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -166,7 +166,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
166
166
|
const AST_ERB_IF_NODE_T* erb_if_node = ((const AST_ERB_IF_NODE_T *) node);
|
|
167
167
|
|
|
168
168
|
if (erb_if_node->statements != NULL) {
|
|
169
|
-
for (size_t index = 0; index <
|
|
169
|
+
for (size_t index = 0; index < erb_if_node->statements->size; index++) {
|
|
170
170
|
herb_visit_node(hb_array_get(erb_if_node->statements, index), visitor, data);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -185,7 +185,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
185
185
|
const AST_ERB_BLOCK_NODE_T* erb_block_node = ((const AST_ERB_BLOCK_NODE_T *) node);
|
|
186
186
|
|
|
187
187
|
if (erb_block_node->body != NULL) {
|
|
188
|
-
for (size_t index = 0; index <
|
|
188
|
+
for (size_t index = 0; index < erb_block_node->body->size; index++) {
|
|
189
189
|
herb_visit_node(hb_array_get(erb_block_node->body, index), visitor, data);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -200,7 +200,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
200
200
|
const AST_ERB_WHEN_NODE_T* erb_when_node = ((const AST_ERB_WHEN_NODE_T *) node);
|
|
201
201
|
|
|
202
202
|
if (erb_when_node->statements != NULL) {
|
|
203
|
-
for (size_t index = 0; index <
|
|
203
|
+
for (size_t index = 0; index < erb_when_node->statements->size; index++) {
|
|
204
204
|
herb_visit_node(hb_array_get(erb_when_node->statements, index), visitor, data);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -211,13 +211,13 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
211
211
|
const AST_ERB_CASE_NODE_T* erb_case_node = ((const AST_ERB_CASE_NODE_T *) node);
|
|
212
212
|
|
|
213
213
|
if (erb_case_node->children != NULL) {
|
|
214
|
-
for (size_t index = 0; index <
|
|
214
|
+
for (size_t index = 0; index < erb_case_node->children->size; index++) {
|
|
215
215
|
herb_visit_node(hb_array_get(erb_case_node->children, index), visitor, data);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
if (erb_case_node->conditions != NULL) {
|
|
220
|
-
for (size_t index = 0; index <
|
|
220
|
+
for (size_t index = 0; index < erb_case_node->conditions->size; index++) {
|
|
221
221
|
herb_visit_node(hb_array_get(erb_case_node->conditions, index), visitor, data);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -236,13 +236,13 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
236
236
|
const AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node = ((const AST_ERB_CASE_MATCH_NODE_T *) node);
|
|
237
237
|
|
|
238
238
|
if (erb_case_match_node->children != NULL) {
|
|
239
|
-
for (size_t index = 0; index <
|
|
239
|
+
for (size_t index = 0; index < erb_case_match_node->children->size; index++) {
|
|
240
240
|
herb_visit_node(hb_array_get(erb_case_match_node->children, index), visitor, data);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
if (erb_case_match_node->conditions != NULL) {
|
|
245
|
-
for (size_t index = 0; index <
|
|
245
|
+
for (size_t index = 0; index < erb_case_match_node->conditions->size; index++) {
|
|
246
246
|
herb_visit_node(hb_array_get(erb_case_match_node->conditions, index), visitor, data);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
@@ -261,7 +261,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
261
261
|
const AST_ERB_WHILE_NODE_T* erb_while_node = ((const AST_ERB_WHILE_NODE_T *) node);
|
|
262
262
|
|
|
263
263
|
if (erb_while_node->statements != NULL) {
|
|
264
|
-
for (size_t index = 0; index <
|
|
264
|
+
for (size_t index = 0; index < erb_while_node->statements->size; index++) {
|
|
265
265
|
herb_visit_node(hb_array_get(erb_while_node->statements, index), visitor, data);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
@@ -276,7 +276,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
276
276
|
const AST_ERB_UNTIL_NODE_T* erb_until_node = ((const AST_ERB_UNTIL_NODE_T *) node);
|
|
277
277
|
|
|
278
278
|
if (erb_until_node->statements != NULL) {
|
|
279
|
-
for (size_t index = 0; index <
|
|
279
|
+
for (size_t index = 0; index < erb_until_node->statements->size; index++) {
|
|
280
280
|
herb_visit_node(hb_array_get(erb_until_node->statements, index), visitor, data);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -291,7 +291,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
291
291
|
const AST_ERB_FOR_NODE_T* erb_for_node = ((const AST_ERB_FOR_NODE_T *) node);
|
|
292
292
|
|
|
293
293
|
if (erb_for_node->statements != NULL) {
|
|
294
|
-
for (size_t index = 0; index <
|
|
294
|
+
for (size_t index = 0; index < erb_for_node->statements->size; index++) {
|
|
295
295
|
herb_visit_node(hb_array_get(erb_for_node->statements, index), visitor, data);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -306,7 +306,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
306
306
|
const AST_ERB_RESCUE_NODE_T* erb_rescue_node = ((const AST_ERB_RESCUE_NODE_T *) node);
|
|
307
307
|
|
|
308
308
|
if (erb_rescue_node->statements != NULL) {
|
|
309
|
-
for (size_t index = 0; index <
|
|
309
|
+
for (size_t index = 0; index < erb_rescue_node->statements->size; index++) {
|
|
310
310
|
herb_visit_node(hb_array_get(erb_rescue_node->statements, index), visitor, data);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -321,7 +321,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
321
321
|
const AST_ERB_ENSURE_NODE_T* erb_ensure_node = ((const AST_ERB_ENSURE_NODE_T *) node);
|
|
322
322
|
|
|
323
323
|
if (erb_ensure_node->statements != NULL) {
|
|
324
|
-
for (size_t index = 0; index <
|
|
324
|
+
for (size_t index = 0; index < erb_ensure_node->statements->size; index++) {
|
|
325
325
|
herb_visit_node(hb_array_get(erb_ensure_node->statements, index), visitor, data);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
@@ -332,7 +332,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
332
332
|
const AST_ERB_BEGIN_NODE_T* erb_begin_node = ((const AST_ERB_BEGIN_NODE_T *) node);
|
|
333
333
|
|
|
334
334
|
if (erb_begin_node->statements != NULL) {
|
|
335
|
-
for (size_t index = 0; index <
|
|
335
|
+
for (size_t index = 0; index < erb_begin_node->statements->size; index++) {
|
|
336
336
|
herb_visit_node(hb_array_get(erb_begin_node->statements, index), visitor, data);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
@@ -359,7 +359,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
359
359
|
const AST_ERB_UNLESS_NODE_T* erb_unless_node = ((const AST_ERB_UNLESS_NODE_T *) node);
|
|
360
360
|
|
|
361
361
|
if (erb_unless_node->statements != NULL) {
|
|
362
|
-
for (size_t index = 0; index <
|
|
362
|
+
for (size_t index = 0; index < erb_unless_node->statements->size; index++) {
|
|
363
363
|
herb_visit_node(hb_array_get(erb_unless_node->statements, index), visitor, data);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
@@ -378,7 +378,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
378
378
|
const AST_ERB_IN_NODE_T* erb_in_node = ((const AST_ERB_IN_NODE_T *) node);
|
|
379
379
|
|
|
380
380
|
if (erb_in_node->statements != NULL) {
|
|
381
|
-
for (size_t index = 0; index <
|
|
381
|
+
for (size_t index = 0; index < erb_in_node->statements->size; index++) {
|
|
382
382
|
herb_visit_node(hb_array_get(erb_in_node->statements, index), visitor, data);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
@@ -71,7 +71,7 @@ VALUE rb_errors_array_from_c_array(hb_array_T* array) {
|
|
|
71
71
|
VALUE rb_array = rb_ary_new();
|
|
72
72
|
|
|
73
73
|
if (array) {
|
|
74
|
-
for (size_t i = 0; i <
|
|
74
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
75
75
|
ERROR_T* child_node = (ERROR_T*) hb_array_get(array, i);
|
|
76
76
|
|
|
77
77
|
if (child_node) {
|
|
@@ -81,7 +81,7 @@ static VALUE rb_nodes_array_from_c_array(hb_array_T* array) {
|
|
|
81
81
|
VALUE rb_array = rb_ary_new();
|
|
82
82
|
|
|
83
83
|
if (array) {
|
|
84
|
-
for (size_t i = 0; i <
|
|
84
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
85
85
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
86
86
|
|
|
87
87
|
if (child_node) {
|
|
@@ -46,7 +46,7 @@ jobject ErrorsArrayFromCArray(JNIEnv* env, hb_array_T* array) {
|
|
|
46
46
|
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, 0);
|
|
47
47
|
|
|
48
48
|
if (array) {
|
|
49
|
-
for (size_t i = 0; i <
|
|
49
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
50
50
|
ERROR_T* error = (ERROR_T*) hb_array_get(array, i);
|
|
51
51
|
|
|
52
52
|
if (error) {
|
data/templates/java/nodes.c.erb
CHANGED
|
@@ -75,9 +75,9 @@ jobject NodesArrayFromCArray(JNIEnv* env, hb_array_T* array) {
|
|
|
75
75
|
return (*env)->NewObject(env, arrayListClass, arrayListConstructor, 0);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, (jint)
|
|
78
|
+
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, (jint) array->size);
|
|
79
79
|
|
|
80
|
-
for (size_t i = 0; i <
|
|
80
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
81
81
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
82
82
|
|
|
83
83
|
if (child_node) {
|
|
@@ -80,7 +80,7 @@ napi_value ErrorsArrayFromCArray(napi_env env, hb_array_T* array) {
|
|
|
80
80
|
napi_create_array(env, &result);
|
|
81
81
|
|
|
82
82
|
if (array) {
|
|
83
|
-
for (size_t i = 0; i <
|
|
83
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
84
84
|
ERROR_T* error = (ERROR_T*) hb_array_get(array, i);
|
|
85
85
|
if (error) {
|
|
86
86
|
napi_value js_error = ErrorFromCStruct(env, error);
|
|
@@ -78,7 +78,7 @@ napi_value NodesArrayFromCArray(napi_env env, hb_array_T* array) {
|
|
|
78
78
|
napi_create_array(env, &result);
|
|
79
79
|
|
|
80
80
|
if (array) {
|
|
81
|
-
for (size_t i = 0; i <
|
|
81
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
82
82
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
83
83
|
if (child_node) {
|
|
84
84
|
napi_value js_child = NodeFromCStruct(env, child_node);
|
|
@@ -51,7 +51,7 @@ unsafe fn convert_errors(errors_array: *mut hb_array_T) -> Vec<AnyError> {
|
|
|
51
51
|
return Vec::new();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
let count =
|
|
54
|
+
let count = (*errors_array).size;
|
|
55
55
|
let mut errors = Vec::with_capacity(count);
|
|
56
56
|
|
|
57
57
|
for index in 0..count {
|
|
@@ -110,7 +110,7 @@ unsafe fn convert_children(children_array: *mut hb_array_T) -> Vec<AnyNode> {
|
|
|
110
110
|
return Vec::new();
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
let count =
|
|
113
|
+
let count = (*children_array).size;
|
|
114
114
|
let mut children = Vec::with_capacity(count);
|
|
115
115
|
|
|
116
116
|
for index in 0..count {
|
|
@@ -27,7 +27,11 @@
|
|
|
27
27
|
<%- when Herb::Template::NodeField -%>
|
|
28
28
|
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
29
29
|
<%- when Herb::Template::ArrayField -%>
|
|
30
|
-
<%=
|
|
30
|
+
if (<%= field.name %> == NULL) {
|
|
31
|
+
<%= node.human %>-><%= field.name %> = hb_array_init(8);
|
|
32
|
+
} else {
|
|
33
|
+
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
34
|
+
}
|
|
31
35
|
<%- when Herb::Template::BooleanField -%>
|
|
32
36
|
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
33
37
|
<%- when Herb::Template::ElementSourceField -%>
|
|
@@ -73,7 +77,7 @@ void ast_free_base_node(AST_NODE_T* node) {
|
|
|
73
77
|
if (node == NULL) { return; }
|
|
74
78
|
|
|
75
79
|
if (node->errors) {
|
|
76
|
-
for (size_t i = 0; i <
|
|
80
|
+
for (size_t i = 0; i < node->errors->size; i++) {
|
|
77
81
|
ERROR_T* child = hb_array_get(node->errors, i);
|
|
78
82
|
if (child != NULL) { error_free(child); }
|
|
79
83
|
}
|
|
@@ -99,7 +103,7 @@ static void ast_free_<%= node.human %>(<%= node.struct_type %>* <%= node.human %
|
|
|
99
103
|
ast_node_free((AST_NODE_T*) <%= node.human %>-><%= field.name %>);
|
|
100
104
|
<%- when Herb::Template::ArrayField -%>
|
|
101
105
|
if (<%= node.human %>-><%= field.name %> != NULL) {
|
|
102
|
-
for (size_t i = 0; i <
|
|
106
|
+
for (size_t i = 0; i < <%= node.human %>-><%= field.name %>->size; i++) {
|
|
103
107
|
AST_NODE_T* child = hb_array_get(<%= node.human %>-><%= field.name %>, i);
|
|
104
108
|
if (child) { ast_node_free(child); }
|
|
105
109
|
}
|
data/templates/src/errors.c.erb
CHANGED
|
@@ -167,7 +167,7 @@ void error_pretty_print_array(
|
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
if (
|
|
170
|
+
if (array->size == 0) {
|
|
171
171
|
pretty_print_property(hb_string(name), hb_string("[]"), indent, relative_indent, last_property, buffer);
|
|
172
172
|
|
|
173
173
|
return;
|
|
@@ -178,17 +178,17 @@ void error_pretty_print_array(
|
|
|
178
178
|
hb_buffer_append(buffer, "(");
|
|
179
179
|
|
|
180
180
|
char count[16];
|
|
181
|
-
sprintf(count, "%zu",
|
|
181
|
+
sprintf(count, "%zu", array->size);
|
|
182
182
|
hb_buffer_append(buffer, count);
|
|
183
183
|
hb_buffer_append(buffer, ")\n");
|
|
184
184
|
|
|
185
185
|
if (indent < 20) {
|
|
186
|
-
for (size_t i = 0; i <
|
|
186
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
187
187
|
ERROR_T* child = hb_array_get(array, i);
|
|
188
188
|
pretty_print_indent(buffer, indent);
|
|
189
189
|
pretty_print_indent(buffer, relative_indent + 1);
|
|
190
190
|
|
|
191
|
-
if (i ==
|
|
191
|
+
if (i == array->size - 1) {
|
|
192
192
|
hb_buffer_append(buffer, "└── ");
|
|
193
193
|
} else {
|
|
194
194
|
hb_buffer_append(buffer, "├── ");
|
|
@@ -196,7 +196,7 @@ void error_pretty_print_array(
|
|
|
196
196
|
|
|
197
197
|
error_pretty_print(child, indent + 1, relative_indent + 1, buffer);
|
|
198
198
|
|
|
199
|
-
if (i !=
|
|
199
|
+
if (i != array->size - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
data/templates/src/visitor.c.erb
CHANGED
|
@@ -31,7 +31,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
31
31
|
|
|
32
32
|
<%- when Herb::Template::ArrayField -%>
|
|
33
33
|
if (<%= node.human %>-><%= field.name %> != NULL) {
|
|
34
|
-
for (size_t index = 0; index <
|
|
34
|
+
for (size_t index = 0; index < <%= node.human %>-><%= field.name %>->size; index++) {
|
|
35
35
|
herb_visit_node(hb_array_get(<%= node.human %>-><%= field.name %>, index), visitor, data);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -66,7 +66,7 @@ val ErrorsArrayFromCArray(hb_array_T* array) {
|
|
|
66
66
|
val result = Array.new_();
|
|
67
67
|
|
|
68
68
|
if (array) {
|
|
69
|
-
for (size_t i = 0; i <
|
|
69
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
70
70
|
ERROR_T* error = (ERROR_T*)hb_array_get(array, i);
|
|
71
71
|
if (error) {
|
|
72
72
|
result.call<void>("push", ErrorFromCStruct(error));
|
|
@@ -67,7 +67,7 @@ val NodesArrayFromCArray(hb_array_T* array) {
|
|
|
67
67
|
|
|
68
68
|
val jsArray = val::array();
|
|
69
69
|
|
|
70
|
-
for (size_t i = 0; i <
|
|
70
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
71
71
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
72
72
|
|
|
73
73
|
if (child_node) {
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: herb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.4
|
|
5
5
|
platform: x86-linux-musl
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -161,6 +161,7 @@ files:
|
|
|
161
161
|
- src/parser.c
|
|
162
162
|
- src/parser_helpers.c
|
|
163
163
|
- src/parser_match_tags.c
|
|
164
|
+
- src/position.c
|
|
164
165
|
- src/pretty_print.c
|
|
165
166
|
- src/prism_helpers.c
|
|
166
167
|
- src/range.c
|