Rizin
unix-like reverse engineering framework and cli tools
binding.c
Go to the documentation of this file.
1 #include <emscripten.h>
2 #include <tree_sitter/api.h>
3 #include <stdio.h>
4 #include "array.h"
5 #include "point.h"
6 
7 /*****************************/
8 /* Section - Data marshaling */
9 /*****************************/
10 
11 static const uint32_t INPUT_BUFFER_SIZE = 10 * 1024;
12 
13 const void *TRANSFER_BUFFER[12] = {
14  NULL, NULL, NULL, NULL,
15  NULL, NULL, NULL, NULL,
16  NULL, NULL, NULL, NULL,
17 };
18 
19 void *ts_init() {
22  return TRANSFER_BUFFER;
23 }
24 
26  return unit << 1;
27 }
28 
30  return byte >> 1;
31 }
32 
33 static inline void marshal_node(const void **buffer, TSNode node) {
34  buffer[0] = (const void *)node.id;
35  buffer[1] = (const void *)byte_to_code_unit(node.context[0]);
36  buffer[2] = (const void *)node.context[1];
37  buffer[3] = (const void *)byte_to_code_unit(node.context[2]);
38  buffer[4] = (const void *)node.context[3];
39 }
40 
41 static inline TSNode unmarshal_node(const TSTree *tree) {
42  TSNode node;
43  node.id = TRANSFER_BUFFER[0];
45  node.context[1] = (uint32_t)TRANSFER_BUFFER[2];
47  node.context[3] = (uint32_t)TRANSFER_BUFFER[4];
48  node.tree = tree;
49  return node;
50 }
51 
52 static inline void marshal_cursor(const TSTreeCursor *cursor) {
53  TRANSFER_BUFFER[0] = (const void *)cursor->id;
54  TRANSFER_BUFFER[1] = (const void *)cursor->context[0];
55  TRANSFER_BUFFER[2] = (const void *)cursor->context[1];
56 }
57 
58 static inline TSTreeCursor unmarshal_cursor(const void **buffer, const TSTree *tree) {
59  TSTreeCursor cursor;
60  cursor.id = buffer[0];
61  cursor.context[0] = (uint32_t)buffer[1];
62  cursor.context[1] = (uint32_t)buffer[2];
63  cursor.tree = tree;
64  return cursor;
65 }
66 
67 static void marshal_point(TSPoint point) {
68  TRANSFER_BUFFER[0] = (const void *)point.row;
69  TRANSFER_BUFFER[1] = (const void *)byte_to_code_unit(point.column);
70 }
71 
72 static TSPoint unmarshal_point(const void **address) {
73  TSPoint point;
74  point.row = (uint32_t)address[0];
75  point.column = code_unit_to_byte((uint32_t)address[1]);
76  return point;
77 }
78 
79 static void marshal_range(TSRange *range) {
80  range->start_byte = byte_to_code_unit(range->start_byte);
81  range->end_byte = byte_to_code_unit(range->end_byte);
82  range->start_point.column = byte_to_code_unit(range->start_point.column);
83  range->end_point.column = byte_to_code_unit(range->end_point.column);
84 }
85 
86 static void unmarshal_range(TSRange *range) {
87  range->start_byte = code_unit_to_byte(range->start_byte);
88  range->end_byte = code_unit_to_byte(range->end_byte);
89  range->start_point.column = code_unit_to_byte(range->start_point.column);
90  range->end_point.column = code_unit_to_byte(range->end_point.column);
91 }
92 
94  TSInputEdit edit;
95  const void **address = TRANSFER_BUFFER;
96  edit.start_point = unmarshal_point(address); address += 2;
97  edit.old_end_point = unmarshal_point(address); address += 2;
98  edit.new_end_point = unmarshal_point(address); address += 2;
99  edit.start_byte = code_unit_to_byte((uint32_t)*address); address += 1;
100  edit.old_end_byte = code_unit_to_byte((uint32_t)*address); address += 1;
101  edit.new_end_byte = code_unit_to_byte((uint32_t)*address); address += 1;
102  return edit;
103 }
104 
105 /********************/
106 /* Section - Parser */
107 /********************/
108 
110  char *input_buffer,
111  uint32_t index,
112  uint32_t row,
113  uint32_t column,
114  uint32_t *length_read
115 );
116 
118  bool is_lex_message,
119  const char *message
120 );
121 
122 static const char *call_parse_callback(
123  void *payload,
124  uint32_t byte,
125  TSPoint position,
126  uint32_t *bytes_read
127 ) {
128  char *buffer = (char *)payload;
130  buffer,
131  byte_to_code_unit(byte),
132  position.row,
133  byte_to_code_unit(position.column),
134  bytes_read
135  );
136  *bytes_read = code_unit_to_byte(*bytes_read);
137  if (*bytes_read >= INPUT_BUFFER_SIZE) {
138  *bytes_read = INPUT_BUFFER_SIZE - 2;
139  }
140  return buffer;
141 }
142 
143 static void call_log_callback(
144  void *payload,
145  TSLogType log_type,
146  const char *message
147 ) {
149 }
150 
153  char *input_buffer = calloc(INPUT_BUFFER_SIZE, sizeof(char));
154  TRANSFER_BUFFER[0] = parser;
155  TRANSFER_BUFFER[1] = input_buffer;
156 }
157 
158 void ts_parser_enable_logger_wasm(TSParser *self, bool should_log) {
159  TSLogger logger = {self, should_log ? call_log_callback : NULL};
160  ts_parser_set_logger(self, logger);
161 }
162 
164  TSParser *self,
165  char *input_buffer,
166  const TSTree *old_tree,
167  TSRange *ranges,
168  uint32_t range_count
169 ) {
170  TSInput input = {
171  input_buffer,
174  };
175  if (range_count) {
176  for (unsigned i = 0; i < range_count; i++) {
177  unmarshal_range(&ranges[i]);
178  }
179  ts_parser_set_included_ranges(self, ranges, range_count);
180  free(ranges);
181  } else {
183  }
184  return ts_parser_parse(self, old_tree, input);
185 }
186 
187 /**********************/
188 /* Section - Language */
189 /**********************/
190 
192  const TSSymbolType symbolType = ts_language_symbol_type(self, typeId);
193  return symbolType == TSSymbolTypeRegular;
194 }
195 
197  const TSSymbolType symbolType = ts_language_symbol_type(self, typeId);
198  return symbolType <= TSSymbolTypeAnonymous;
199 }
200 
201 /******************/
202 /* Section - Tree */
203 /******************/
204 
205 void ts_tree_root_node_wasm(const TSTree *tree) {
207 }
208 
210  TSInputEdit edit = unmarshal_edit();
211  ts_tree_edit(tree, &edit);
212 }
213 
215  unsigned range_count;
216  TSRange *ranges = ts_tree_get_changed_ranges(tree, other, &range_count);
217  for (unsigned i = 0; i < range_count; i++) {
218  marshal_range(&ranges[i]);
219  }
220  TRANSFER_BUFFER[0] = (const void *)range_count;
221  TRANSFER_BUFFER[1] = (const void *)ranges;
222 }
223 
224 /************************/
225 /* Section - TreeCursor */
226 /************************/
227 
228 void ts_tree_cursor_new_wasm(const TSTree *tree) {
229  TSNode node = unmarshal_node(tree);
230  TSTreeCursor cursor = ts_tree_cursor_new(node);
231  marshal_cursor(&cursor);
232 }
233 
236  ts_tree_cursor_delete(&cursor);
237 }
238 
240  TSNode node = unmarshal_node(tree);
241  TSTreeCursor cursor = unmarshal_cursor(&TRANSFER_BUFFER[5], tree);
242  ts_tree_cursor_reset(&cursor, node);
243  marshal_cursor(&cursor);
244 }
245 
248  bool result = ts_tree_cursor_goto_first_child(&cursor);
249  marshal_cursor(&cursor);
250  return result;
251 }
252 
255  bool result = ts_tree_cursor_goto_next_sibling(&cursor);
256  marshal_cursor(&cursor);
257  return result;
258 }
259 
262  bool result = ts_tree_cursor_goto_parent(&cursor);
263  marshal_cursor(&cursor);
264  return result;
265 }
266 
269  TSNode node = ts_tree_cursor_current_node(&cursor);
270  return ts_node_symbol(node);
271 }
272 
275  TSNode node = ts_tree_cursor_current_node(&cursor);
276  return ts_node_is_named(node);
277 }
278 
281  TSNode node = ts_tree_cursor_current_node(&cursor);
282  return ts_node_is_missing(node);
283 }
284 
287  TSNode node = ts_tree_cursor_current_node(&cursor);
288  return (uint32_t)node.id;
289 }
290 
293  TSNode node = ts_tree_cursor_current_node(&cursor);
295 }
296 
299  TSNode node = ts_tree_cursor_current_node(&cursor);
301 }
302 
305  TSNode node = ts_tree_cursor_current_node(&cursor);
307 }
308 
311  TSNode node = ts_tree_cursor_current_node(&cursor);
312  return byte_to_code_unit(ts_node_end_byte(node));
313 }
314 
317  return ts_tree_cursor_current_field_id(&cursor);
318 }
319 
323 }
324 
325 /******************/
326 /* Section - Node */
327 /******************/
328 
331 
333  TSNode node = unmarshal_node(tree);
334  return ts_node_symbol(node);
335 }
336 
338  TSNode node = unmarshal_node(tree);
339  return ts_node_child_count(node);
340 }
341 
343  TSNode node = unmarshal_node(tree);
344  return ts_node_named_child_count(node);
345 }
346 
347 void ts_node_child_wasm(const TSTree *tree, uint32_t index) {
348  TSNode node = unmarshal_node(tree);
350 }
351 
352 void ts_node_named_child_wasm(const TSTree *tree, uint32_t index) {
353  TSNode node = unmarshal_node(tree);
355 }
356 
358  TSNode node = unmarshal_node(tree);
360 }
361 
363  TSNode node = unmarshal_node(tree);
365 }
366 
368  TSNode node = unmarshal_node(tree);
370 }
371 
373  TSNode node = unmarshal_node(tree);
375 }
376 
378  TSNode node = unmarshal_node(tree);
380 }
381 
382 void ts_node_parent_wasm(const TSTree *tree) {
383  TSNode node = unmarshal_node(tree);
385 }
386 
388  TSNode node = unmarshal_node(tree);
389  const void **address = TRANSFER_BUFFER + 5;
390  uint32_t start = code_unit_to_byte((uint32_t)address[0]);
391  uint32_t end = code_unit_to_byte((uint32_t)address[1]);
393 }
394 
396  TSNode node = unmarshal_node(tree);
397  const void **address = TRANSFER_BUFFER + 5;
398  uint32_t start = code_unit_to_byte((uint32_t)address[0]);
399  uint32_t end = code_unit_to_byte((uint32_t)address[1]);
401 }
402 
404  TSNode node = unmarshal_node(tree);
405  const void **address = TRANSFER_BUFFER + 5;
406  TSPoint start = unmarshal_point(address); address += 2;
407  TSPoint end = unmarshal_point(address);
409 }
410 
412  TSNode node = unmarshal_node(tree);
413  const void **address = TRANSFER_BUFFER + 5;
414  TSPoint start = unmarshal_point(address); address += 2;
415  TSPoint end = unmarshal_point(address);
417 }
418 
419 void ts_node_start_point_wasm(const TSTree *tree) {
420  TSNode node = unmarshal_node(tree);
422 }
423 
424 void ts_node_end_point_wasm(const TSTree *tree) {
425  TSNode node = unmarshal_node(tree);
427 }
428 
430  TSNode node = unmarshal_node(tree);
432 }
433 
435  TSNode node = unmarshal_node(tree);
436  return byte_to_code_unit(ts_node_end_byte(node));
437 }
438 
439 char *ts_node_to_string_wasm(const TSTree *tree) {
440  TSNode node = unmarshal_node(tree);
441  return ts_node_string(node);
442 }
443 
444 void ts_node_children_wasm(const TSTree *tree) {
445  TSNode node = unmarshal_node(tree);
447  const void **result = NULL;
448  if (count > 0) {
449  result = calloc(sizeof(void *), 5 * count);
450  const void **address = result;
454  for (uint32_t i = 1; i < count; i++) {
455  address += 5;
458  marshal_node(address, child);
459  }
460  }
461  TRANSFER_BUFFER[0] = (const void *)count;
462  TRANSFER_BUFFER[1] = result;
463 }
464 
466  TSNode node = unmarshal_node(tree);
468  const void **result = NULL;
469  if (count > 0) {
470  result = calloc(sizeof(void *), 5 * count);
471  const void **address = result;
474  uint32_t i = 0;
475  for (;;) {
477  if (ts_node_is_named(child)) {
478  marshal_node(address, child);
479  address += 5;
480  i++;
481  if (i == count) break;
482  }
484  }
485  }
486  TRANSFER_BUFFER[0] = (const void *)count;
487  TRANSFER_BUFFER[1] = result;
488 }
489 
491  for (unsigned i = 0; i < length; i++) {
492  if (set[i] == value) return true;
493  if (set[i] > value) break;
494  }
495  return false;
496 }
497 
499  const TSTree *tree,
500  const uint32_t *symbols,
501  uint32_t symbol_count,
502  uint32_t start_row,
503  uint32_t start_column,
504  uint32_t end_row,
505  uint32_t end_column
506 ) {
507  TSNode node = unmarshal_node(tree);
508  TSPoint start_point = {start_row, code_unit_to_byte(start_column)};
509  TSPoint end_point = {end_row, code_unit_to_byte(end_column)};
510  if (end_point.row == 0 && end_point.column == 0) {
511  end_point = (TSPoint) {UINT32_MAX, UINT32_MAX};
512  }
513 
514  Array(const void *) result = array_new();
515 
516  // Walk the tree depth first looking for matching nodes.
518  bool already_visited_children = false;
519  while (true) {
521 
522  if (!already_visited_children) {
523  // If this node is before the selected range, then avoid
524  // descending into it.
525  if (point_lte(ts_node_end_point(descendant), start_point)) {
527  already_visited_children = false;
528  } else {
530  already_visited_children = true;
531  }
532  continue;
533  }
534 
535  // If this node is after the selected range, then stop walking.
536  if (point_lte(end_point, ts_node_start_point(descendant))) break;
537 
538  // Add the node to the result if its type matches one of the given
539  // node types.
540  if (symbols_contain(symbols, symbol_count, ts_node_symbol(descendant))) {
541  array_grow_by(&result, 5);
542  marshal_node(result.contents + result.size - 5, descendant);
543  }
544 
545  // Continue walking.
547  already_visited_children = false;
549  already_visited_children = false;
550  } else {
552  already_visited_children = true;
553  }
554  } else {
556  already_visited_children = false;
557  } else {
559  }
560  }
561  }
562 
563  TRANSFER_BUFFER[0] = (const void *)(result.size / 5);
564  TRANSFER_BUFFER[1] = result.contents;
565 }
566 
567 int ts_node_is_named_wasm(const TSTree *tree) {
568  TSNode node = unmarshal_node(tree);
569  return ts_node_is_named(node);
570 }
571 
573  TSNode node = unmarshal_node(tree);
574  return ts_node_has_changes(node);
575 }
576 
577 int ts_node_has_error_wasm(const TSTree *tree) {
578  TSNode node = unmarshal_node(tree);
579  return ts_node_has_error(node);
580 }
581 
582 int ts_node_is_missing_wasm(const TSTree *tree) {
583  TSNode node = unmarshal_node(tree);
584  return ts_node_is_missing(node);
585 }
586 
587 /******************/
588 /* Section - Query */
589 /******************/
590 
592  const TSQuery *self,
593  const TSTree *tree,
594  uint32_t start_row,
595  uint32_t start_column,
596  uint32_t end_row,
597  uint32_t end_column,
598  uint32_t match_limit
599 ) {
601  if (match_limit == 0) {
603  } else {
605  }
606 
607  TSNode node = unmarshal_node(tree);
608  TSPoint start_point = {start_row, code_unit_to_byte(start_column)};
609  TSPoint end_point = {end_row, code_unit_to_byte(end_column)};
610  ts_query_cursor_set_point_range(scratch_query_cursor, start_point, end_point);
612 
613  uint32_t index = 0;
614  uint32_t match_count = 0;
615  Array(const void *) result = array_new();
616 
619  match_count++;
620  array_grow_by(&result, 2 + 6 * match.capture_count);
621  result.contents[index++] = (const void *)(uint32_t)match.pattern_index;
622  result.contents[index++] = (const void *)(uint32_t)match.capture_count;
623  for (unsigned i = 0; i < match.capture_count; i++) {
624  const TSQueryCapture *capture = &match.captures[i];
625  result.contents[index++] = (const void *)capture->index;
626  marshal_node(result.contents + index, capture->node);
627  index += 5;
628  }
629  }
630 
631  bool did_exceed_match_limit =
633  TRANSFER_BUFFER[0] = (const void *)(match_count);
634  TRANSFER_BUFFER[1] = result.contents;
635  TRANSFER_BUFFER[2] = (const void *)(did_exceed_match_limit);
636 }
637 
639  const TSQuery *self,
640  const TSTree *tree,
641  uint32_t start_row,
642  uint32_t start_column,
643  uint32_t end_row,
644  uint32_t end_column,
645  uint32_t match_limit
646 ) {
648  if (match_limit == 0) {
650  } else {
652  }
653 
654  TSNode node = unmarshal_node(tree);
655  TSPoint start_point = {start_row, code_unit_to_byte(start_column)};
656  TSPoint end_point = {end_row, code_unit_to_byte(end_column)};
657  ts_query_cursor_set_point_range(scratch_query_cursor, start_point, end_point);
659 
660  unsigned index = 0;
661  unsigned capture_count = 0;
662  Array(const void *) result = array_new();
663 
665  uint32_t capture_index;
668  &match,
669  &capture_index
670  )) {
671  capture_count++;
672 
673  array_grow_by(&result, 3 + 6 * match.capture_count);
674  result.contents[index++] = (const void *)(uint32_t)match.pattern_index;
675  result.contents[index++] = (const void *)(uint32_t)match.capture_count;
676  result.contents[index++] = (const void *)(uint32_t)capture_index;
677  for (unsigned i = 0; i < match.capture_count; i++) {
678  const TSQueryCapture *capture = &match.captures[i];
679  result.contents[index++] = (const void *)capture->index;
680  marshal_node(result.contents + index, capture->node);
681  index += 5;
682  }
683  }
684 
685  bool did_exceed_match_limit =
687  TRANSFER_BUFFER[0] = (const void *)(capture_count);
688  TRANSFER_BUFFER[1] = result.contents;
689  TRANSFER_BUFFER[2] = (const void *)(did_exceed_match_limit);
690 }
lzma_index ** i
Definition: index.h:629
void ts_query_cursor_exec(TSQueryCursor *, const TSQuery *, TSNode)
Definition: query.c:2859
TSNode ts_node_descendant_for_byte_range(TSNode, uint32_t, uint32_t)
Definition: node.c:644
bool ts_node_has_changes(TSNode)
Definition: node.c:453
void ts_tree_edit(TSTree *self, const TSInputEdit *edit)
Definition: tree.c:44
TSRange * ts_tree_get_changed_ranges(const TSTree *old_tree, const TSTree *new_tree, uint32_t *length)
Definition: tree.c:78
TSNode ts_node_child_by_field_id(TSNode, TSFieldId)
Definition: node.c:500
TSTree * ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input)
Definition: parser.c:1844
#define TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION
Definition: api.h:30
void ts_query_cursor_set_match_limit(TSQueryCursor *, uint32_t)
Definition: query.c:2855
bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *)
Definition: tree_cursor.c:206
void ts_tree_cursor_delete(TSTreeCursor *)
Definition: tree_cursor.c:94
TSLogType
Definition: api.h:73
@ TSLogTypeLex
Definition: api.h:75
TSNode ts_node_named_child(TSNode, uint32_t)
Definition: node.c:496
TSNode ts_node_next_named_sibling(TSNode)
Definition: node.c:624
uint32_t ts_node_start_byte(TSNode)
Definition: node.c:36
char * ts_node_string(TSNode)
Definition: node.c:426
TSNode ts_node_child(TSNode, uint32_t)
Definition: node.c:492
uint32_t ts_node_named_child_count(TSNode)
Definition: node.c:611
void ts_tree_cursor_reset(TSTreeCursor *, TSNode)
Definition: tree_cursor.c:76
bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *)
Definition: query.c:2847
TSNode ts_node_prev_named_sibling(TSNode)
Definition: node.c:632
TSNode ts_node_prev_sibling(TSNode)
Definition: node.c:628
TSSymbol ts_node_symbol(TSNode)
Definition: node.c:414
bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges, uint32_t length)
Definition: parser.c:1811
TSPoint ts_node_start_point(TSNode)
Definition: node.c:40
#define TREE_SITTER_LANGUAGE_VERSION
Definition: api.h:24
bool ts_query_cursor_next_match(TSQueryCursor *, TSQueryMatch *match)
Definition: query.c:3690
bool ts_node_is_missing(TSNode)
Definition: node.c:449
TSTreeCursor ts_tree_cursor_new(TSNode)
Definition: tree_cursor.c:70
@ TSInputEncodingUTF16
Definition: api.h:46
TSNode ts_tree_root_node(const TSTree *self)
Definition: tree.c:36
bool ts_tree_cursor_goto_parent(TSTreeCursor *)
Definition: tree_cursor.c:239
void ts_parser_set_logger(TSParser *self, TSLogger logger)
Definition: parser.c:1779
TSQueryCursor * ts_query_cursor_new(void)
Definition: query.c:2820
uint32_t ts_node_child_count(TSNode)
Definition: node.c:602
bool ts_node_has_error(TSNode)
Definition: node.c:457
uint32_t ts_node_end_byte(TSNode)
Definition: node.c:406
TSParser * ts_parser_new(void)
Definition: parser.c:1704
TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *)
Definition: tree_cursor.c:431
bool ts_node_is_named(TSNode)
Definition: node.c:442
bool ts_query_cursor_next_capture(TSQueryCursor *, TSQueryMatch *match, uint32_t *capture_index)
Definition: query.c:3746
TSSymbolType
Definition: api.h:49
@ TSSymbolTypeRegular
Definition: api.h:50
@ TSSymbolTypeAnonymous
Definition: api.h:51
TSNode ts_node_parent(TSNode)
Definition: node.c:461
TSNode ts_node_named_descendant_for_point_range(TSNode, TSPoint, TSPoint)
Definition: node.c:668
TSSymbolType ts_language_symbol_type(const TSLanguage *, TSSymbol)
Definition: language.c:93
TSNode ts_tree_cursor_current_node(const TSTreeCursor *)
Definition: tree_cursor.c:262
void ts_query_cursor_set_point_range(TSQueryCursor *, TSPoint, TSPoint)
Definition: query.c:2888
TSNode ts_node_descendant_for_point_range(TSNode, TSPoint, TSPoint)
Definition: node.c:660
TSNode ts_node_next_sibling(TSNode)
Definition: node.c:620
TSPoint ts_node_end_point(TSNode)
Definition: node.c:410
TSNode ts_node_named_descendant_for_byte_range(TSNode, uint32_t, uint32_t)
Definition: node.c:652
bool ts_tree_cursor_goto_first_child(TSTreeCursor *)
Definition: tree_cursor.c:101
#define array_new()
Definition: array.h:25
#define Array(T)
Definition: array.h:15
#define array_grow_by(self, count)
Definition: array.h:49
RzList * symbols(RzBinFile *bf)
Definition: bin_ne.c:102
static TSInputEdit unmarshal_edit()
Definition: binding.c:93
bool ts_tree_cursor_current_node_is_named_wasm(const TSTree *tree)
Definition: binding.c:273
void ts_tree_cursor_start_position_wasm(const TSTree *tree)
Definition: binding.c:291
void ts_tree_edit_wasm(TSTree *tree)
Definition: binding.c:209
uint32_t ts_tree_cursor_current_field_id_wasm(const TSTree *tree)
Definition: binding.c:315
void ts_node_descendant_for_position_wasm(const TSTree *tree)
Definition: binding.c:403
uint32_t ts_node_start_index_wasm(const TSTree *tree)
Definition: binding.c:429
uint32_t ts_node_end_index_wasm(const TSTree *tree)
Definition: binding.c:434
void ts_tree_cursor_end_position_wasm(const TSTree *tree)
Definition: binding.c:297
int ts_node_is_named_wasm(const TSTree *tree)
Definition: binding.c:567
static TSNode unmarshal_node(const TSTree *tree)
Definition: binding.c:41
static TSQueryCursor * scratch_query_cursor
Definition: binding.c:330
bool ts_tree_cursor_current_node_is_missing_wasm(const TSTree *tree)
Definition: binding.c:279
void ts_node_descendants_of_type_wasm(const TSTree *tree, const uint32_t *symbols, uint32_t symbol_count, uint32_t start_row, uint32_t start_column, uint32_t end_row, uint32_t end_column)
Definition: binding.c:498
bool symbols_contain(const uint32_t *set, uint32_t length, uint32_t value)
Definition: binding.c:490
void ts_node_child_wasm(const TSTree *tree, uint32_t index)
Definition: binding.c:347
int ts_node_has_changes_wasm(const TSTree *tree)
Definition: binding.c:572
uint32_t ts_tree_cursor_end_index_wasm(const TSTree *tree)
Definition: binding.c:309
void ts_parser_new_wasm()
Definition: binding.c:151
void ts_node_named_children_wasm(const TSTree *tree)
Definition: binding.c:465
void ts_node_named_descendant_for_index_wasm(const TSTree *tree)
Definition: binding.c:395
uint32_t ts_node_named_child_count_wasm(const TSTree *tree)
Definition: binding.c:342
void ts_tree_get_changed_ranges_wasm(TSTree *tree, TSTree *other)
Definition: binding.c:214
uint32_t ts_tree_cursor_start_index_wasm(const TSTree *tree)
Definition: binding.c:303
uint32_t ts_node_child_count_wasm(const TSTree *tree)
Definition: binding.c:337
static void marshal_cursor(const TSTreeCursor *cursor)
Definition: binding.c:52
static TSPoint unmarshal_point(const void **address)
Definition: binding.c:72
static void unmarshal_range(TSRange *range)
Definition: binding.c:86
void ts_node_parent_wasm(const TSTree *tree)
Definition: binding.c:382
void ts_parser_enable_logger_wasm(TSParser *self, bool should_log)
Definition: binding.c:158
void tree_sitter_log_callback(bool is_lex_message, const char *message)
void tree_sitter_parse_callback(char *input_buffer, uint32_t index, uint32_t row, uint32_t column, uint32_t *length_read)
int ts_node_is_missing_wasm(const TSTree *tree)
Definition: binding.c:582
uint16_t ts_node_symbol_wasm(const TSTree *tree)
Definition: binding.c:332
void ts_node_start_point_wasm(const TSTree *tree)
Definition: binding.c:419
void * ts_init()
Definition: binding.c:19
void ts_node_named_descendant_for_position_wasm(const TSTree *tree)
Definition: binding.c:411
void ts_node_children_wasm(const TSTree *tree)
Definition: binding.c:444
void ts_tree_cursor_current_node_wasm(const TSTree *tree)
Definition: binding.c:320
void ts_tree_root_node_wasm(const TSTree *tree)
Definition: binding.c:205
void ts_node_prev_sibling_wasm(const TSTree *tree)
Definition: binding.c:367
static void marshal_range(TSRange *range)
Definition: binding.c:79
void ts_query_matches_wasm(const TSQuery *self, const TSTree *tree, uint32_t start_row, uint32_t start_column, uint32_t end_row, uint32_t end_column, uint32_t match_limit)
Definition: binding.c:591
static const char * call_parse_callback(void *payload, uint32_t byte, TSPoint position, uint32_t *bytes_read)
Definition: binding.c:122
int ts_language_type_is_named_wasm(const TSLanguage *self, TSSymbol typeId)
Definition: binding.c:191
const void * TRANSFER_BUFFER[12]
Definition: binding.c:13
void ts_query_captures_wasm(const TSQuery *self, const TSTree *tree, uint32_t start_row, uint32_t start_column, uint32_t end_row, uint32_t end_column, uint32_t match_limit)
Definition: binding.c:638
bool ts_tree_cursor_goto_parent_wasm(const TSTree *tree)
Definition: binding.c:260
static const uint32_t INPUT_BUFFER_SIZE
Definition: binding.c:11
void ts_node_end_point_wasm(const TSTree *tree)
Definition: binding.c:424
static TSTreeCursor unmarshal_cursor(const void **buffer, const TSTree *tree)
Definition: binding.c:58
bool ts_tree_cursor_goto_first_child_wasm(const TSTree *tree)
Definition: binding.c:246
static void marshal_point(TSPoint point)
Definition: binding.c:67
void ts_tree_cursor_delete_wasm(const TSTree *tree)
Definition: binding.c:234
static void call_log_callback(void *payload, TSLogType log_type, const char *message)
Definition: binding.c:143
void ts_node_next_sibling_wasm(const TSTree *tree)
Definition: binding.c:362
void ts_tree_cursor_new_wasm(const TSTree *tree)
Definition: binding.c:228
uint16_t ts_tree_cursor_current_node_type_id_wasm(const TSTree *tree)
Definition: binding.c:267
void ts_node_named_child_wasm(const TSTree *tree, uint32_t index)
Definition: binding.c:352
int ts_language_type_is_visible_wasm(const TSLanguage *self, TSSymbol typeId)
Definition: binding.c:196
bool ts_tree_cursor_goto_next_sibling_wasm(const TSTree *tree)
Definition: binding.c:253
static void marshal_node(const void **buffer, TSNode node)
Definition: binding.c:33
TSTree * ts_parser_parse_wasm(TSParser *self, char *input_buffer, const TSTree *old_tree, TSRange *ranges, uint32_t range_count)
Definition: binding.c:163
void ts_tree_cursor_reset_wasm(const TSTree *tree)
Definition: binding.c:239
const uint32_t ts_tree_cursor_current_node_id_wasm(const TSTree *tree)
Definition: binding.c:285
char * ts_node_to_string_wasm(const TSTree *tree)
Definition: binding.c:439
void ts_node_next_named_sibling_wasm(const TSTree *tree)
Definition: binding.c:372
int ts_node_has_error_wasm(const TSTree *tree)
Definition: binding.c:577
void ts_node_descendant_for_index_wasm(const TSTree *tree)
Definition: binding.c:387
static uint32_t byte_to_code_unit(uint32_t byte)
Definition: binding.c:29
static TSTreeCursor scratch_cursor
Definition: binding.c:329
void ts_node_child_by_field_id_wasm(const TSTree *tree, uint32_t field_id)
Definition: binding.c:357
static uint32_t code_unit_to_byte(uint32_t unit)
Definition: binding.c:25
void ts_node_prev_named_sibling_wasm(const TSTree *tree)
Definition: binding.c:377
struct buffer buffer
static int value
Definition: cmd_api.c:93
#define NULL
Definition: cris-opc.c:27
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
Definition: sflib.h:133
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
unsigned char match[65280+2]
Definition: gun.c:165
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
static bool point_lte(TSPoint a, TSPoint b)
Definition: point.h:28
@ field_id
Definition: parser.c:1736
uint16_t TSSymbol
Definition: parser.h:19
unsigned short uint16_t
Definition: sftypes.h:30
unsigned int uint32_t
Definition: sftypes.h:29
#define UINT32_MAX
uint32_t old_end_byte
Definition: api.h:85
uint32_t start_byte
Definition: api.h:84
uint32_t new_end_byte
Definition: api.h:86
TSPoint old_end_point
Definition: api.h:88
TSPoint start_point
Definition: api.h:87
TSPoint new_end_point
Definition: api.h:89
Definition: api.h:67
Definition: api.h:78
Definition: api.h:92
uint32_t context[4]
Definition: api.h:93
const TSTree * tree
Definition: api.h:95
const void * id
Definition: api.h:94
Definition: api.h:55
uint32_t row
Definition: api.h:56
uint32_t column
Definition: api.h:57
TSNode node
Definition: api.h:105
uint32_t index
Definition: api.h:106
Definition: query.c:270
Definition: api.h:60
uint32_t context[2]
Definition: api.h:101
const void * tree
Definition: api.h:99
const void * id
Definition: api.h:100
Definition: tree.h:15
Definition: buffer.h:15
Definition: engine.c:71
Definition: zran.c:68
char * message
Definition: main.c:12
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)