herb 0.8.3-arm64-darwin → 0.8.5-arm64-darwin

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/config.yml +7 -0
  3. data/ext/herb/error_helpers.c +26 -1
  4. data/ext/herb/extension_helpers.c +1 -1
  5. data/ext/herb/nodes.c +2 -2
  6. data/lib/herb/3.0/herb.bundle +0 -0
  7. data/lib/herb/3.1/herb.bundle +0 -0
  8. data/lib/herb/3.2/herb.bundle +0 -0
  9. data/lib/herb/3.3/herb.bundle +0 -0
  10. data/lib/herb/3.4/herb.bundle +0 -0
  11. data/lib/herb/ast/helpers.rb +5 -0
  12. data/lib/herb/engine/compiler.rb +1 -0
  13. data/lib/herb/engine/debug_visitor.rb +24 -1
  14. data/lib/herb/errors.rb +53 -44
  15. data/lib/herb/version.rb +1 -1
  16. data/sig/herb/ast/helpers.rbs +3 -0
  17. data/sig/herb/engine/debug_visitor.rbs +5 -0
  18. data/sig/herb/errors.rbs +10 -0
  19. data/sig/serialized_ast_errors.rbs +3 -0
  20. data/src/analyze.c +39 -28
  21. data/src/analyze_helpers.c +179 -84
  22. data/src/analyzed_ruby.c +26 -25
  23. data/src/ast_node.c +1 -1
  24. data/src/ast_nodes.c +157 -53
  25. data/src/ast_pretty_print.c +16 -15
  26. data/src/errors.c +42 -5
  27. data/src/extract.c +4 -3
  28. data/src/herb.c +2 -2
  29. data/src/include/analyze_helpers.h +1 -0
  30. data/src/include/analyzed_ruby.h +19 -18
  31. data/src/include/errors.h +8 -0
  32. data/src/include/version.h +1 -1
  33. data/src/lexer.c +3 -3
  34. data/src/parser.c +10 -8
  35. data/src/parser_helpers.c +9 -9
  36. data/src/pretty_print.c +6 -6
  37. data/src/visitor.c +26 -26
  38. data/templates/ext/herb/error_helpers.c.erb +1 -1
  39. data/templates/ext/herb/nodes.c.erb +1 -1
  40. data/templates/java/error_helpers.c.erb +1 -1
  41. data/templates/java/nodes.c.erb +2 -2
  42. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
  43. data/templates/javascript/packages/node/extension/nodes.cpp.erb +1 -1
  44. data/templates/lib/herb/errors.rb.erb +8 -5
  45. data/templates/rust/src/ast/nodes.rs.erb +2 -2
  46. data/templates/src/ast_nodes.c.erb +7 -3
  47. data/templates/src/ast_pretty_print.c.erb +16 -15
  48. data/templates/src/errors.c.erb +5 -5
  49. data/templates/src/visitor.c.erb +1 -1
  50. data/templates/wasm/error_helpers.cpp.erb +1 -1
  51. data/templates/wasm/nodes.cpp.erb +1 -1
  52. metadata +1 -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 < hb_array_size(document_node->children); 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 < hb_array_size(html_open_tag_node->children); 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 < hb_array_size(html_close_tag_node->children); 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 < hb_array_size(html_element_node->body); 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 < hb_array_size(html_attribute_value_node->children); 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 < hb_array_size(html_attribute_name_node->children); 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 < hb_array_size(html_comment_node->children); 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 < hb_array_size(html_doctype_node->children); 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 < hb_array_size(xml_declaration_node->children); 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 < hb_array_size(cdata_node->children); 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 < hb_array_size(erb_else_node->statements); 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 < hb_array_size(erb_if_node->statements); 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 < hb_array_size(erb_block_node->body); 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 < hb_array_size(erb_when_node->statements); 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 < hb_array_size(erb_case_node->children); 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 < hb_array_size(erb_case_node->conditions); 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 < hb_array_size(erb_case_match_node->children); 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 < hb_array_size(erb_case_match_node->conditions); 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 < hb_array_size(erb_while_node->statements); 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 < hb_array_size(erb_until_node->statements); 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 < hb_array_size(erb_for_node->statements); 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 < hb_array_size(erb_rescue_node->statements); 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 < hb_array_size(erb_ensure_node->statements); 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 < hb_array_size(erb_begin_node->statements); 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 < hb_array_size(erb_unless_node->statements); 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 < hb_array_size(erb_in_node->statements); 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 < hb_array_size(array); 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 < hb_array_size(array); 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 < hb_array_size(array); 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) {
@@ -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) hb_array_size(array));
78
+ jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, (jint) array->size);
79
79
 
80
- for (size_t i = 0; i < hb_array_size(array); 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 < hb_array_size(array); 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 < hb_array_size(array); 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);
@@ -46,6 +46,7 @@ module Herb
46
46
  <%- errors.each do |error| -%>
47
47
  class <%= error.name -%> < Error
48
48
  include Colors
49
+ <%- if error.fields.any? -%>
49
50
 
50
51
  <%- error.fields.each do |field| -%>
51
52
  attr_reader :<%= field.name %> #: <%= field.ruby_type %>
@@ -54,25 +55,27 @@ module Herb
54
55
  #: (<%= [*base_arguments.map(&:last), *error.fields.map(&:ruby_type)].join(", ") %>) -> void
55
56
  def initialize(<%= [*base_arguments.map(&:first), *error.fields.map(&:name)].join(", ") %>)
56
57
  super(<%= base_arguments.map(&:first).join(", ") %>)
57
-
58
58
  <%- error.fields.each do |field| -%>
59
59
  @<%= field.name %> = <%= field.name %>
60
60
  <%- end -%>
61
61
  end
62
+ <%- end -%>
62
63
 
63
64
  #: () -> String
64
65
  def inspect
65
66
  tree_inspect.rstrip.gsub(/\s+$/, "")
66
67
  end
68
+ <%- if error.fields.any? -%>
67
69
 
68
70
  #: () -> serialized_<%= error.human %>
69
71
  def to_hash
70
- super.merge({
71
- <%- error.fields.each do |field| -%>
72
- <%= field.name %>: <%= field.name %>,
72
+ super.merge(
73
+ <%- error.fields.each_with_index do |field, index| -%>
74
+ <%= field.name %>: <%= field.name %><%= index < error.fields.size - 1 ? "," : "" %>
73
75
  <%- end -%>
74
- }) #: Herb::serialized_<%= error.human %>
76
+ ) #: Herb::serialized_<%= error.human %>
75
77
  end
78
+ <%- end -%>
76
79
 
77
80
  #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
78
81
  def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
@@ -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 = hb_array_size(errors_array);
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 = hb_array_size(children_array);
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
- <%= node.human %>-><%= field.name %> = <%= field.name %>;
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 < hb_array_size(node->errors); 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 < hb_array_size(<%= node.human %>-><%= field.name %>); 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
  }
@@ -1,3 +1,4 @@
1
+ #include "include/analyze_helpers.h"
1
2
  #include "include/ast_node.h"
2
3
  #include "include/ast_nodes.h"
3
4
  #include "include/errors.h"
@@ -62,21 +63,21 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
62
63
 
63
64
  <%- when Herb::Template::AnalyzedRubyField -%>
64
65
  if (<%= node.human %>-><%= field.name %>) {
65
- pretty_print_boolean_property(hb_string("if_node"), <%= node.human %>-><%= field.name %>->has_if_node, indent, relative_indent, false, buffer);
66
- pretty_print_boolean_property(hb_string("elsif_node"), <%= node.human %>-><%= field.name %>->has_elsif_node, indent, relative_indent, false, buffer);
67
- pretty_print_boolean_property(hb_string("else_node"), <%= node.human %>-><%= field.name %>->has_else_node, indent, relative_indent, false, buffer);
68
- pretty_print_boolean_property(hb_string("end"), <%= node.human %>-><%= field.name %>->has_end, indent, relative_indent, false, buffer);
69
- pretty_print_boolean_property(hb_string("block_node"), <%= node.human %>-><%= field.name %>->has_block_node, indent, relative_indent, false, buffer);
70
- pretty_print_boolean_property(hb_string("block_closing"), <%= node.human %>-><%= field.name %>->has_block_closing, indent, relative_indent, false, buffer);
71
- pretty_print_boolean_property(hb_string("case_node"), <%= node.human %>-><%= field.name %>->has_case_node, indent, relative_indent, false, buffer);
72
- pretty_print_boolean_property(hb_string("when_node"), <%= node.human %>-><%= field.name %>->has_when_node, indent, relative_indent, false, buffer);
73
- pretty_print_boolean_property(hb_string("for_node"), <%= node.human %>-><%= field.name %>->has_for_node, indent, relative_indent, false, buffer);
74
- pretty_print_boolean_property(hb_string("while_node"), <%= node.human %>-><%= field.name %>->has_while_node, indent, relative_indent, false, buffer);
75
- pretty_print_boolean_property(hb_string("until_node"), <%= node.human %>-><%= field.name %>->has_until_node, indent, relative_indent, false, buffer);
76
- pretty_print_boolean_property(hb_string("begin_node"), <%= node.human %>-><%= field.name %>->has_begin_node, indent, relative_indent, false, buffer);
77
- pretty_print_boolean_property(hb_string("rescue_node"), <%= node.human %>-><%= field.name %>->has_rescue_node, indent, relative_indent, false, buffer);
78
- pretty_print_boolean_property(hb_string("ensure_node"), <%= node.human %>-><%= field.name %>->has_ensure_node, indent, relative_indent, <%= last %>, buffer);
79
- pretty_print_boolean_property(hb_string("unless_node"), <%= node.human %>-><%= field.name %>->has_unless_node, indent, relative_indent, <%= last %>, buffer);
66
+ pretty_print_boolean_property(hb_string("if_node"), has_if_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
67
+ pretty_print_boolean_property(hb_string("elsif_node"), has_elsif_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
68
+ pretty_print_boolean_property(hb_string("else_node"), has_else_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
69
+ pretty_print_boolean_property(hb_string("end"), has_end(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
70
+ pretty_print_boolean_property(hb_string("block_node"), has_block_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
71
+ pretty_print_boolean_property(hb_string("block_closing"), has_block_closing(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
72
+ pretty_print_boolean_property(hb_string("case_node"), has_case_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
73
+ pretty_print_boolean_property(hb_string("when_node"), has_when_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
74
+ pretty_print_boolean_property(hb_string("for_node"), has_for_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
75
+ pretty_print_boolean_property(hb_string("while_node"), has_while_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
76
+ pretty_print_boolean_property(hb_string("until_node"), has_until_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
77
+ pretty_print_boolean_property(hb_string("begin_node"), has_begin_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
78
+ pretty_print_boolean_property(hb_string("rescue_node"), has_rescue_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
79
+ pretty_print_boolean_property(hb_string("ensure_node"), has_ensure_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
80
+ pretty_print_boolean_property(hb_string("unless_node"), has_unless_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
80
81
  } else {
81
82
  pretty_print_label(hb_string("<%= field.name %>"), indent, relative_indent, <%= last %>, buffer);
82
83
  hb_buffer_append(buffer, " ∅\n");
@@ -167,7 +167,7 @@ void error_pretty_print_array(
167
167
  return;
168
168
  }
169
169
 
170
- if (hb_array_size(array) == 0) {
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", hb_array_size(array));
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 < hb_array_size(array); 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 == hb_array_size(array) - 1) {
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 != hb_array_size(array) - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
199
+ if (i != array->size - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
200
200
  }
201
201
  }
202
202
  }
@@ -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 < hb_array_size(<%= node.human %>-><%= field.name %>); 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 < hb_array_size(array); 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 < hb_array_size(array); 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.3
4
+ version: 0.8.5
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Marco Roth