tree_sitter_c2rust/core_wrapper/core/
node.rs

1use crate::core_transpiled::util::*;
2use crate::core_transpiled::*;
3use :: c2rust_bitfields;
4use std::os;
5pub type __uint8_t = libc::c_uchar;
6pub type __int16_t = libc::c_short;
7pub type __uint16_t = libc::c_ushort;
8pub type __int32_t = libc::c_int;
9pub type __uint32_t = libc::c_uint;
10pub type int16_t = __int16_t;
11pub type int32_t = __int32_t;
12pub type uint8_t = __uint8_t;
13pub type uint16_t = __uint16_t;
14pub type uint32_t = __uint32_t;
15pub type TSStateId = uint16_t;
16pub type TSFieldId = uint16_t;
17#[derive(Copy, Clone)]
18#[repr(C)]
19pub struct C2RustUnnamed {
20    pub states: *const bool,
21    pub symbol_map: *const TSSymbol,
22    pub create: Option<unsafe extern "C" fn() -> *mut libc::c_void>,
23    pub destroy: Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
24    pub scan: Option<unsafe extern "C" fn(*mut libc::c_void, *mut TSLexer, *const bool) -> bool>,
25    pub serialize:
26        Option<unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_char) -> libc::c_uint>,
27    pub deserialize:
28        Option<unsafe extern "C" fn(*mut libc::c_void, *const libc::c_char, libc::c_uint) -> ()>,
29}
30#[derive(Copy, Clone)]
31#[repr(C)]
32pub struct C2RustUnnamed_0 {
33    pub count: uint8_t,
34    pub reusable: bool,
35}
36#[derive(Copy, Clone)]
37#[repr(C)]
38pub struct C2RustUnnamed_1 {
39    pub type_: uint8_t,
40    pub child_count: uint8_t,
41    pub symbol: TSSymbol,
42    pub dynamic_precedence: int16_t,
43    pub production_id: uint16_t,
44}
45#[derive(Copy, Clone)]
46#[repr(C)]
47pub struct C2RustUnnamed_2 {
48    pub type_: uint8_t,
49    pub state: TSStateId,
50    pub extra: bool,
51    pub repetition: bool,
52}
53type C2RustUnnamed_3 = crate::core_transpiled::util::ScannerStateWithLookahead;
54type C2RustUnnamed_4 = crate::core_transpiled::util::LongShortData;
55type C2RustUnnamed_5 = crate::core_transpiled::util::ScannerStateLookaheadMeta;
56type C2RustUnnamed_6 = crate::core_transpiled::util::ScannerStateLookaheadFirstLeaf;
57#[derive(Copy, Clone)]
58#[repr(C)]
59pub struct TSNode {
60    pub context: [uint32_t; 4],
61    pub id: *const libc::c_void,
62    pub tree: *const TSTree,
63}
64#[derive(Copy, Clone)]
65#[repr(C)]
66pub struct NodeChildIterator {
67    pub parent: Subtree,
68    pub tree: *const TSTree,
69    pub position: Length,
70    pub child_index: uint32_t,
71    pub structural_child_index: uint32_t,
72    pub alias_sequence: *const TSSymbol,
73}
74#[inline]
75unsafe extern "C" fn ts_subtree_symbol(mut self_0: Subtree) -> TSSymbol {
76    return (if (self_0.data).is_inline() as libc::c_int != 0 {
77        self_0.data.symbol as libc::c_int
78    } else {
79        (*self_0.ptr).symbol as libc::c_int
80    }) as TSSymbol;
81}
82#[inline]
83unsafe extern "C" fn ts_subtree_size(mut self_0: Subtree) -> Length {
84    if (self_0.data).is_inline() {
85        let mut result: Length = {
86            let mut init = Length {
87                bytes: self_0.data.size_bytes as uint32_t,
88                extent: {
89                    let mut init = TSPoint {
90                        row: 0 as libc::c_int as uint32_t,
91                        column: self_0.data.size_bytes as uint32_t,
92                    };
93                    init
94                },
95            };
96            init
97        };
98        return result;
99    } else {
100        return (*self_0.ptr).size;
101    };
102}
103#[inline]
104unsafe extern "C" fn point_add(mut a: TSPoint, mut b: TSPoint) -> TSPoint {
105    if b.row > 0 as libc::c_int as libc::c_uint {
106        return point__new((a.row).wrapping_add(b.row), b.column);
107    } else {
108        return point__new(a.row, (a.column).wrapping_add(b.column));
109    };
110}
111#[inline]
112unsafe extern "C" fn point__new(mut row: libc::c_uint, mut column: libc::c_uint) -> TSPoint {
113    let mut result: TSPoint = {
114        let mut init = TSPoint {
115            row: row,
116            column: column,
117        };
118        init
119    };
120    return result;
121}
122#[inline]
123unsafe extern "C" fn ts_subtree_named(mut self_0: Subtree) -> bool {
124    return if (self_0.data).is_inline() as libc::c_int != 0 {
125        (self_0.data).named() as libc::c_int
126    } else {
127        (*self_0.ptr).named() as libc::c_int
128    } != 0;
129}
130#[inline]
131unsafe extern "C" fn ts_subtree_missing(mut self_0: Subtree) -> bool {
132    return if (self_0.data).is_inline() as libc::c_int != 0 {
133        (self_0.data).is_missing() as libc::c_int
134    } else {
135        (*self_0.ptr).is_missing() as libc::c_int
136    } != 0;
137}
138#[inline]
139unsafe extern "C" fn ts_subtree_extra(mut self_0: Subtree) -> bool {
140    return if (self_0.data).is_inline() as libc::c_int != 0 {
141        (self_0.data).extra() as libc::c_int
142    } else {
143        (*self_0.ptr).extra() as libc::c_int
144    } != 0;
145}
146#[inline]
147unsafe extern "C" fn ts_subtree_has_changes(mut self_0: Subtree) -> bool {
148    return if (self_0.data).is_inline() as libc::c_int != 0 {
149        (self_0.data).has_changes() as libc::c_int
150    } else {
151        (*self_0.ptr).has_changes() as libc::c_int
152    } != 0;
153}
154#[inline]
155unsafe extern "C" fn ts_subtree_error_cost(mut self_0: Subtree) -> uint32_t {
156    if ts_subtree_missing(self_0) {
157        return (110 as libc::c_int + 500 as libc::c_int) as uint32_t;
158    } else {
159        return if (self_0.data).is_inline() as libc::c_int != 0 {
160            0 as libc::c_int as libc::c_uint
161        } else {
162            (*self_0.ptr).error_cost
163        };
164    };
165}
166#[inline]
167unsafe extern "C" fn ts_subtree_parse_state(mut self_0: Subtree) -> TSStateId {
168    return (if (self_0.data).is_inline() as libc::c_int != 0 {
169        self_0.data.parse_state as libc::c_int
170    } else {
171        (*self_0.ptr).parse_state as libc::c_int
172    }) as TSStateId;
173}
174#[inline]
175unsafe extern "C" fn ts_subtree_visible(mut self_0: Subtree) -> bool {
176    return if (self_0.data).is_inline() as libc::c_int != 0 {
177        (self_0.data).visible() as libc::c_int
178    } else {
179        (*self_0.ptr).visible() as libc::c_int
180    } != 0;
181}
182#[inline]
183unsafe extern "C" fn ts_subtree_child_count(mut self_0: Subtree) -> uint32_t {
184    return if (self_0.data).is_inline() as libc::c_int != 0 {
185        0 as libc::c_int as libc::c_uint
186    } else {
187        (*self_0.ptr).child_count
188    };
189}
190#[inline]
191unsafe extern "C" fn length_zero() -> Length {
192    let mut result: Length = {
193        let mut init = Length {
194            bytes: 0 as libc::c_int as uint32_t,
195            extent: {
196                let mut init = TSPoint {
197                    row: 0 as libc::c_int as uint32_t,
198                    column: 0 as libc::c_int as uint32_t,
199                };
200                init
201            },
202        };
203        init
204    };
205    return result;
206}
207#[inline]
208unsafe extern "C" fn length_add(mut len1: Length, mut len2: Length) -> Length {
209    let mut result: Length = Length {
210        bytes: 0,
211        extent: TSPoint { row: 0, column: 0 },
212    };
213    result.bytes = (len1.bytes).wrapping_add(len2.bytes);
214    result.extent = point_add(len1.extent, len2.extent);
215    return result;
216}
217#[inline]
218unsafe extern "C" fn ts_subtree_padding(mut self_0: Subtree) -> Length {
219    if (self_0.data).is_inline() {
220        let mut result: Length = {
221            let mut init = Length {
222                bytes: self_0.data.padding_bytes as uint32_t,
223                extent: {
224                    let mut init = TSPoint {
225                        row: (self_0.data).padding_rows() as uint32_t,
226                        column: self_0.data.padding_columns as uint32_t,
227                    };
228                    init
229                },
230            };
231            init
232        };
233        return result;
234    } else {
235        return (*self_0.ptr).padding;
236    };
237}
238#[inline]
239unsafe extern "C" fn ts_subtree_total_bytes(mut self_0: Subtree) -> uint32_t {
240    return (ts_subtree_total_size(self_0)).bytes;
241}
242#[inline]
243unsafe extern "C" fn ts_subtree_total_size(mut self_0: Subtree) -> Length {
244    return length_add(ts_subtree_padding(self_0), ts_subtree_size(self_0));
245}
246#[inline]
247unsafe extern "C" fn ts_subtree_visible_descendant_count(mut self_0: Subtree) -> uint32_t {
248    return if (self_0.data).is_inline() as libc::c_int != 0
249        || (*self_0.ptr).child_count == 0 as libc::c_int as libc::c_uint
250    {
251        0 as libc::c_int as libc::c_uint
252    } else {
253        (*self_0.ptr)
254            .c2rust_unnamed
255            .c2rust_unnamed
256            .visible_descendant_count
257    };
258}
259#[inline]
260unsafe extern "C" fn point_lt(mut a: TSPoint, mut b: TSPoint) -> bool {
261    return a.row < b.row || a.row == b.row && a.column < b.column;
262}
263#[inline]
264unsafe extern "C" fn point_lte(mut a: TSPoint, mut b: TSPoint) -> bool {
265    return a.row < b.row || a.row == b.row && a.column <= b.column;
266}
267#[inline]
268unsafe extern "C" fn point_eq(mut a: TSPoint, mut b: TSPoint) -> bool {
269    return a.row == b.row && a.column == b.column;
270}
271#[inline]
272unsafe extern "C" fn point_sub(mut a: TSPoint, mut b: TSPoint) -> TSPoint {
273    if a.row > b.row {
274        return point__new((a.row).wrapping_sub(b.row), a.column);
275    } else {
276        return point__new(
277            0 as libc::c_int as libc::c_uint,
278            (a.column).wrapping_sub(b.column),
279        );
280    };
281}
282#[inline]
283unsafe extern "C" fn ts_language_alias_sequence(
284    mut self_0: *const TSLanguage,
285    mut production_id: uint32_t,
286) -> *const TSSymbol {
287    return if production_id != 0 {
288        &*((*self_0).alias_sequences).offset(
289            production_id.wrapping_mul((*self_0).max_alias_sequence_length as libc::c_uint)
290                as isize,
291        ) as *const TSSymbol
292    } else {
293        0 as *const TSSymbol
294    };
295}
296#[inline]
297unsafe extern "C" fn ts_language_field_map(
298    mut self_0: *const TSLanguage,
299    mut production_id: uint32_t,
300    mut start: *mut *const TSFieldMapEntry,
301    mut end: *mut *const TSFieldMapEntry,
302) {
303    if (*self_0).field_count == 0 as libc::c_int as libc::c_uint {
304        *start = 0 as *const TSFieldMapEntry;
305        *end = 0 as *const TSFieldMapEntry;
306        return;
307    }
308    let mut slice: TSFieldMapSlice = *((*self_0).field_map_slices).offset(production_id as isize);
309    *start = &*((*self_0).field_map_entries).offset(slice.index as isize) as *const TSFieldMapEntry;
310    *end = (&*((*self_0).field_map_entries).offset(slice.index as isize) as *const TSFieldMapEntry)
311        .offset(slice.length as libc::c_int as isize);
312}
313#[no_mangle]
314pub unsafe extern "C" fn ts_node_new(
315    mut tree: *const TSTree,
316    mut subtree: *const Subtree,
317    mut position: Length,
318    mut alias: TSSymbol,
319) -> TSNode {
320    return {
321        let mut init = TSNode {
322            context: [
323                position.bytes,
324                position.extent.row,
325                position.extent.column,
326                alias as uint32_t,
327            ],
328            id: subtree as *const libc::c_void,
329            tree: tree,
330        };
331        init
332    };
333}
334#[inline]
335unsafe extern "C" fn ts_node__null() -> TSNode {
336    return ts_node_new(
337        0 as *const TSTree,
338        0 as *const Subtree,
339        length_zero(),
340        0 as libc::c_int as TSSymbol,
341    );
342}
343#[no_mangle]
344pub unsafe extern "C" fn ts_node_start_byte(mut self_0: TSNode) -> uint32_t {
345    return self_0.context[0 as libc::c_int as usize];
346}
347#[no_mangle]
348pub unsafe extern "C" fn ts_node_start_point(mut self_0: TSNode) -> TSPoint {
349    return {
350        let mut init = TSPoint {
351            row: self_0.context[1 as libc::c_int as usize],
352            column: self_0.context[2 as libc::c_int as usize],
353        };
354        init
355    };
356}
357#[inline]
358unsafe extern "C" fn ts_node__alias(mut self_0: *const TSNode) -> uint32_t {
359    return (*self_0).context[3 as libc::c_int as usize];
360}
361#[inline]
362unsafe extern "C" fn ts_node__subtree(mut self_0: TSNode) -> Subtree {
363    return *(self_0.id as *const Subtree);
364}
365#[inline]
366unsafe extern "C" fn ts_node_iterate_children(mut node: *const TSNode) -> NodeChildIterator {
367    let mut subtree: Subtree = ts_node__subtree(*node);
368    if ts_subtree_child_count(subtree) == 0 as libc::c_int as libc::c_uint {
369        return {
370            let mut init = NodeChildIterator {
371                parent: Subtree {
372                    ptr: 0 as *const SubtreeHeapData,
373                },
374                tree: (*node).tree,
375                position: length_zero(),
376                child_index: 0 as libc::c_int as uint32_t,
377                structural_child_index: 0 as libc::c_int as uint32_t,
378                alias_sequence: 0 as *const TSSymbol,
379            };
380            init
381        };
382    }
383    let mut alias_sequence: *const TSSymbol = ts_language_alias_sequence(
384        (*(*node).tree).language,
385        (*subtree.ptr).c2rust_unnamed.c2rust_unnamed.production_id as uint32_t,
386    );
387    return {
388        let mut init = NodeChildIterator {
389            parent: subtree,
390            tree: (*node).tree,
391            position: {
392                let mut init = Length {
393                    bytes: ts_node_start_byte(*node),
394                    extent: ts_node_start_point(*node),
395                };
396                init
397            },
398            child_index: 0 as libc::c_int as uint32_t,
399            structural_child_index: 0 as libc::c_int as uint32_t,
400            alias_sequence: alias_sequence,
401        };
402        init
403    };
404}
405#[inline]
406unsafe extern "C" fn ts_node_child_iterator_done(mut self_0: *mut NodeChildIterator) -> bool {
407    return (*self_0).child_index == (*(*self_0).parent.ptr).child_count;
408}
409#[inline]
410unsafe extern "C" fn ts_node_child_iterator_next(
411    mut self_0: *mut NodeChildIterator,
412    mut result: *mut TSNode,
413) -> bool {
414    if ((*self_0).parent.ptr).is_null() || ts_node_child_iterator_done(self_0) as libc::c_int != 0 {
415        return 0 as libc::c_int != 0;
416    }
417    let mut child: *const Subtree = &mut *if ((*self_0).parent.data).is_inline() as libc::c_int != 0
418    {
419        0 as *mut Subtree
420    } else {
421        ((*self_0).parent.ptr as *mut Subtree)
422            .offset(-((*(*self_0).parent.ptr).child_count as isize))
423    }
424    .offset((*self_0).child_index as isize) as *mut Subtree;
425    let mut alias_symbol: TSSymbol = 0 as libc::c_int as TSSymbol;
426    if !ts_subtree_extra(*child) {
427        if !((*self_0).alias_sequence).is_null() {
428            alias_symbol =
429                *((*self_0).alias_sequence).offset((*self_0).structural_child_index as isize);
430        }
431        (*self_0).structural_child_index = ((*self_0).structural_child_index).wrapping_add(1);
432    }
433    if (*self_0).child_index > 0 as libc::c_int as libc::c_uint {
434        (*self_0).position = length_add((*self_0).position, ts_subtree_padding(*child));
435    }
436    *result = ts_node_new((*self_0).tree, child, (*self_0).position, alias_symbol);
437    (*self_0).position = length_add((*self_0).position, ts_subtree_size(*child));
438    (*self_0).child_index = ((*self_0).child_index).wrapping_add(1);
439    return 1 as libc::c_int != 0;
440}
441#[inline]
442unsafe extern "C" fn ts_node__is_relevant(mut self_0: TSNode, mut include_anonymous: bool) -> bool {
443    let mut tree: Subtree = ts_node__subtree(self_0);
444    if include_anonymous {
445        return ts_subtree_visible(tree) as libc::c_int != 0 || ts_node__alias(&mut self_0) != 0;
446    } else {
447        let mut alias: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
448        if alias != 0 {
449            return (ts_language_symbol_metadata((*self_0.tree).language, alias)).named;
450        } else {
451            return ts_subtree_visible(tree) as libc::c_int != 0
452                && ts_subtree_named(tree) as libc::c_int != 0;
453        }
454    };
455}
456#[inline]
457unsafe extern "C" fn ts_node__relevant_child_count(
458    mut self_0: TSNode,
459    mut include_anonymous: bool,
460) -> uint32_t {
461    let mut tree: Subtree = ts_node__subtree(self_0);
462    if ts_subtree_child_count(tree) > 0 as libc::c_int as libc::c_uint {
463        if include_anonymous {
464            return (*tree.ptr)
465                .c2rust_unnamed
466                .c2rust_unnamed
467                .visible_child_count;
468        } else {
469            return (*tree.ptr).c2rust_unnamed.c2rust_unnamed.named_child_count;
470        }
471    } else {
472        return 0 as libc::c_int as uint32_t;
473    };
474}
475#[inline]
476unsafe extern "C" fn ts_node__child(
477    mut self_0: TSNode,
478    mut child_index: uint32_t,
479    mut include_anonymous: bool,
480) -> TSNode {
481    let mut result: TSNode = self_0;
482    let mut did_descend: bool = 1 as libc::c_int != 0;
483    while did_descend {
484        did_descend = 0 as libc::c_int != 0;
485        let mut child: TSNode = TSNode {
486            context: [0; 4],
487            id: 0 as *const libc::c_void,
488            tree: 0 as *const TSTree,
489        };
490        let mut index: uint32_t = 0 as libc::c_int as uint32_t;
491        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut result);
492        while ts_node_child_iterator_next(&mut iterator, &mut child) {
493            if ts_node__is_relevant(child, include_anonymous) {
494                if index == child_index {
495                    return child;
496                }
497                index = index.wrapping_add(1);
498            } else {
499                let mut grandchild_index: uint32_t = child_index.wrapping_sub(index);
500                let mut grandchild_count: uint32_t =
501                    ts_node__relevant_child_count(child, include_anonymous);
502                if grandchild_index < grandchild_count {
503                    did_descend = 1 as libc::c_int != 0;
504                    result = child;
505                    child_index = grandchild_index;
506                    break;
507                } else {
508                    index = (index as libc::c_uint).wrapping_add(grandchild_count) as uint32_t
509                        as uint32_t;
510                }
511            }
512        }
513    }
514    return ts_node__null();
515}
516unsafe extern "C" fn ts_subtree_has_trailing_empty_descendant(
517    mut self_0: Subtree,
518    mut other: Subtree,
519) -> bool {
520    let mut i: libc::c_uint =
521        (ts_subtree_child_count(self_0)).wrapping_sub(1 as libc::c_int as libc::c_uint);
522    while i.wrapping_add(1 as libc::c_int as libc::c_uint) > 0 as libc::c_int as libc::c_uint {
523        let mut child: Subtree = *if (self_0.data).is_inline() as libc::c_int != 0 {
524            0 as *mut Subtree
525        } else {
526            (self_0.ptr as *mut Subtree).offset(-((*self_0.ptr).child_count as isize))
527        }
528        .offset(i as isize);
529        if ts_subtree_total_bytes(child) > 0 as libc::c_int as libc::c_uint {
530            break;
531        }
532        if child.ptr == other.ptr
533            || ts_subtree_has_trailing_empty_descendant(child, other) as libc::c_int != 0
534        {
535            return 1 as libc::c_int != 0;
536        }
537        i = i.wrapping_sub(1);
538    }
539    return 0 as libc::c_int != 0;
540}
541#[inline]
542unsafe extern "C" fn ts_node__prev_sibling(
543    mut self_0: TSNode,
544    mut include_anonymous: bool,
545) -> TSNode {
546    let mut self_subtree: Subtree = ts_node__subtree(self_0);
547    let mut self_is_empty: bool =
548        ts_subtree_total_bytes(self_subtree) == 0 as libc::c_int as libc::c_uint;
549    let mut target_end_byte: uint32_t = ts_node_end_byte(self_0);
550    let mut node: TSNode = ts_node_parent(self_0);
551    let mut earlier_node: TSNode = ts_node__null();
552    let mut earlier_node_is_relevant: bool = 0 as libc::c_int != 0;
553    while !ts_node_is_null(node) {
554        let mut earlier_child: TSNode = ts_node__null();
555        let mut earlier_child_is_relevant: bool = 0 as libc::c_int != 0;
556        let mut found_child_containing_target: bool = 0 as libc::c_int != 0;
557        let mut child: TSNode = TSNode {
558            context: [0; 4],
559            id: 0 as *const libc::c_void,
560            tree: 0 as *const TSTree,
561        };
562        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
563        while ts_node_child_iterator_next(&mut iterator, &mut child) {
564            if child.id == self_0.id {
565                break;
566            }
567            if iterator.position.bytes > target_end_byte {
568                found_child_containing_target = 1 as libc::c_int != 0;
569                break;
570            } else if iterator.position.bytes == target_end_byte
571                && (!self_is_empty
572                    || ts_subtree_has_trailing_empty_descendant(
573                        ts_node__subtree(child),
574                        self_subtree,
575                    ) as libc::c_int
576                        != 0)
577            {
578                found_child_containing_target = 1 as libc::c_int != 0;
579                break;
580            } else if ts_node__is_relevant(child, include_anonymous) {
581                earlier_child = child;
582                earlier_child_is_relevant = 1 as libc::c_int != 0;
583            } else if ts_node__relevant_child_count(child, include_anonymous)
584                > 0 as libc::c_int as libc::c_uint
585            {
586                earlier_child = child;
587                earlier_child_is_relevant = 0 as libc::c_int != 0;
588            }
589        }
590        if found_child_containing_target {
591            if !ts_node_is_null(earlier_child) {
592                earlier_node = earlier_child;
593                earlier_node_is_relevant = earlier_child_is_relevant;
594            }
595            node = child;
596        } else if earlier_child_is_relevant {
597            return earlier_child;
598        } else {
599            if !ts_node_is_null(earlier_child) {
600                node = earlier_child;
601            } else if earlier_node_is_relevant {
602                return earlier_node;
603            } else {
604                node = earlier_node;
605                earlier_node = ts_node__null();
606                earlier_node_is_relevant = 0 as libc::c_int != 0;
607            }
608        }
609    }
610    return ts_node__null();
611}
612#[inline]
613unsafe extern "C" fn ts_node__next_sibling(
614    mut self_0: TSNode,
615    mut include_anonymous: bool,
616) -> TSNode {
617    let mut target_end_byte: uint32_t = ts_node_end_byte(self_0);
618    let mut node: TSNode = ts_node_parent(self_0);
619    let mut later_node: TSNode = ts_node__null();
620    let mut later_node_is_relevant: bool = 0 as libc::c_int != 0;
621    while !ts_node_is_null(node) {
622        let mut later_child: TSNode = ts_node__null();
623        let mut later_child_is_relevant: bool = 0 as libc::c_int != 0;
624        let mut child_containing_target: TSNode = ts_node__null();
625        let mut child: TSNode = TSNode {
626            context: [0; 4],
627            id: 0 as *const libc::c_void,
628            tree: 0 as *const TSTree,
629        };
630        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
631        while ts_node_child_iterator_next(&mut iterator, &mut child) {
632            if iterator.position.bytes <= target_end_byte {
633                continue;
634            }
635            let mut start_byte: uint32_t = ts_node_start_byte(self_0);
636            let mut child_start_byte: uint32_t = ts_node_start_byte(child);
637            let mut is_empty: bool = start_byte == target_end_byte;
638            let mut contains_target: bool = if is_empty as libc::c_int != 0 {
639                (child_start_byte < start_byte) as libc::c_int
640            } else {
641                (child_start_byte <= start_byte) as libc::c_int
642            } != 0;
643            if contains_target {
644                if (ts_node__subtree(child)).ptr != (ts_node__subtree(self_0)).ptr {
645                    child_containing_target = child;
646                }
647            } else if ts_node__is_relevant(child, include_anonymous) {
648                later_child = child;
649                later_child_is_relevant = 1 as libc::c_int != 0;
650                break;
651            } else {
652                if !(ts_node__relevant_child_count(child, include_anonymous)
653                    > 0 as libc::c_int as libc::c_uint)
654                {
655                    continue;
656                }
657                later_child = child;
658                later_child_is_relevant = 0 as libc::c_int != 0;
659                break;
660            }
661        }
662        if !ts_node_is_null(child_containing_target) {
663            if !ts_node_is_null(later_child) {
664                later_node = later_child;
665                later_node_is_relevant = later_child_is_relevant;
666            }
667            node = child_containing_target;
668        } else if later_child_is_relevant {
669            return later_child;
670        } else {
671            if !ts_node_is_null(later_child) {
672                node = later_child;
673            } else if later_node_is_relevant {
674                return later_node;
675            } else {
676                node = later_node;
677            }
678        }
679    }
680    return ts_node__null();
681}
682#[inline]
683unsafe extern "C" fn ts_node__first_child_for_byte(
684    mut self_0: TSNode,
685    mut goal: uint32_t,
686    mut include_anonymous: bool,
687) -> TSNode {
688    let mut node: TSNode = self_0;
689    let mut did_descend: bool = 1 as libc::c_int != 0;
690    let mut last_iterator: NodeChildIterator = NodeChildIterator {
691        parent: Subtree {
692            data: SubtreeInlineData {
693                is_inline_visible_named_extra_has_changes_is_missing_is_keyword: [0; 1],
694                symbol: 0,
695                parse_state: 0,
696                padding_columns: 0,
697                padding_rows_lookahead_bytes: [0; 1],
698                padding_bytes: 0,
699                size_bytes: 0,
700            },
701        },
702        tree: 0 as *const TSTree,
703        position: Length {
704            bytes: 0,
705            extent: TSPoint { row: 0, column: 0 },
706        },
707        child_index: 0,
708        structural_child_index: 0,
709        alias_sequence: 0 as *const TSSymbol,
710    };
711    let mut has_last_iterator: bool = 0 as libc::c_int != 0;
712    while did_descend {
713        did_descend = 0 as libc::c_int != 0;
714        let mut child: TSNode = TSNode {
715            context: [0; 4],
716            id: 0 as *const libc::c_void,
717            tree: 0 as *const TSTree,
718        };
719        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
720        loop {
721            while ts_node_child_iterator_next(&mut iterator, &mut child) {
722                if !(ts_node_end_byte(child) > goal) {
723                    continue;
724                }
725                if ts_node__is_relevant(child, include_anonymous) {
726                    return child;
727                } else {
728                    if !(ts_node_child_count(child) > 0 as libc::c_int as libc::c_uint) {
729                        continue;
730                    }
731                    if iterator.child_index < ts_subtree_child_count(ts_node__subtree(child)) {
732                        last_iterator = iterator;
733                        has_last_iterator = 1 as libc::c_int != 0;
734                    }
735                    did_descend = 1 as libc::c_int != 0;
736                    node = child;
737                    break;
738                }
739            }
740            if !(!did_descend && has_last_iterator as libc::c_int != 0) {
741                break;
742            }
743            iterator = last_iterator;
744            has_last_iterator = 0 as libc::c_int != 0;
745        }
746    }
747    return ts_node__null();
748}
749#[inline]
750unsafe extern "C" fn ts_node__descendant_for_byte_range(
751    mut self_0: TSNode,
752    mut range_start: uint32_t,
753    mut range_end: uint32_t,
754    mut include_anonymous: bool,
755) -> TSNode {
756    let mut node: TSNode = self_0;
757    let mut last_visible_node: TSNode = self_0;
758    let mut did_descend: bool = 1 as libc::c_int != 0;
759    while did_descend {
760        did_descend = 0 as libc::c_int != 0;
761        let mut child: TSNode = TSNode {
762            context: [0; 4],
763            id: 0 as *const libc::c_void,
764            tree: 0 as *const TSTree,
765        };
766        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
767        while ts_node_child_iterator_next(&mut iterator, &mut child) {
768            let mut node_end: uint32_t = iterator.position.bytes;
769            if node_end < range_end {
770                continue;
771            }
772            let mut is_empty: bool = ts_node_start_byte(child) == node_end;
773            if if is_empty as libc::c_int != 0 {
774                (node_end < range_start) as libc::c_int
775            } else {
776                (node_end <= range_start) as libc::c_int
777            } != 0
778            {
779                continue;
780            }
781            if range_start < ts_node_start_byte(child) {
782                break;
783            }
784            node = child;
785            if ts_node__is_relevant(node, include_anonymous) {
786                last_visible_node = node;
787            }
788            did_descend = 1 as libc::c_int != 0;
789            break;
790        }
791    }
792    return last_visible_node;
793}
794#[inline]
795unsafe extern "C" fn ts_node__descendant_for_point_range(
796    mut self_0: TSNode,
797    mut range_start: TSPoint,
798    mut range_end: TSPoint,
799    mut include_anonymous: bool,
800) -> TSNode {
801    let mut node: TSNode = self_0;
802    let mut last_visible_node: TSNode = self_0;
803    let mut did_descend: bool = 1 as libc::c_int != 0;
804    while did_descend {
805        did_descend = 0 as libc::c_int != 0;
806        let mut child: TSNode = TSNode {
807            context: [0; 4],
808            id: 0 as *const libc::c_void,
809            tree: 0 as *const TSTree,
810        };
811        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut node);
812        while ts_node_child_iterator_next(&mut iterator, &mut child) {
813            let mut node_end: TSPoint = iterator.position.extent;
814            if point_lt(node_end, range_end) {
815                continue;
816            }
817            let mut is_empty: bool = point_eq(ts_node_start_point(child), node_end);
818            if if is_empty as libc::c_int != 0 {
819                point_lt(node_end, range_start) as libc::c_int
820            } else {
821                point_lte(node_end, range_start) as libc::c_int
822            } != 0
823            {
824                continue;
825            }
826            if point_lt(range_start, ts_node_start_point(child)) {
827                break;
828            }
829            node = child;
830            if ts_node__is_relevant(node, include_anonymous) {
831                last_visible_node = node;
832            }
833            did_descend = 1 as libc::c_int != 0;
834            break;
835        }
836    }
837    return last_visible_node;
838}
839#[no_mangle]
840pub unsafe extern "C" fn ts_node_end_byte(mut self_0: TSNode) -> uint32_t {
841    return (ts_node_start_byte(self_0))
842        .wrapping_add((ts_subtree_size(ts_node__subtree(self_0))).bytes);
843}
844#[no_mangle]
845pub unsafe extern "C" fn ts_node_end_point(mut self_0: TSNode) -> TSPoint {
846    return point_add(
847        ts_node_start_point(self_0),
848        (ts_subtree_size(ts_node__subtree(self_0))).extent,
849    );
850}
851#[no_mangle]
852pub unsafe extern "C" fn ts_node_symbol(mut self_0: TSNode) -> TSSymbol {
853    let mut symbol: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
854    if symbol == 0 {
855        symbol = ts_subtree_symbol(ts_node__subtree(self_0));
856    }
857    return ts_language_public_symbol((*self_0.tree).language, symbol);
858}
859#[no_mangle]
860pub unsafe extern "C" fn ts_node_type(mut self_0: TSNode) -> *const libc::c_char {
861    let mut symbol: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
862    if symbol == 0 {
863        symbol = ts_subtree_symbol(ts_node__subtree(self_0));
864    }
865    return ts_language_symbol_name((*self_0.tree).language, symbol);
866}
867#[no_mangle]
868pub unsafe extern "C" fn ts_node_language(mut self_0: TSNode) -> *const TSLanguage {
869    return (*self_0.tree).language;
870}
871#[no_mangle]
872pub unsafe extern "C" fn ts_node_grammar_symbol(mut self_0: TSNode) -> TSSymbol {
873    return ts_subtree_symbol(ts_node__subtree(self_0));
874}
875#[no_mangle]
876pub unsafe extern "C" fn ts_node_grammar_type(mut self_0: TSNode) -> *const libc::c_char {
877    let mut symbol: TSSymbol = ts_subtree_symbol(ts_node__subtree(self_0));
878    return ts_language_symbol_name((*self_0.tree).language, symbol);
879}
880#[no_mangle]
881pub unsafe extern "C" fn ts_node_string(mut self_0: TSNode) -> *mut libc::c_char {
882    let mut alias_symbol: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
883    return ts_subtree_string(
884        ts_node__subtree(self_0),
885        alias_symbol,
886        (ts_language_symbol_metadata((*self_0.tree).language, alias_symbol)).visible,
887        (*self_0.tree).language,
888        0 as libc::c_int != 0,
889    );
890}
891#[no_mangle]
892pub unsafe extern "C" fn ts_node_eq(mut self_0: TSNode, mut other: TSNode) -> bool {
893    return self_0.tree == other.tree && self_0.id == other.id;
894}
895#[no_mangle]
896pub unsafe extern "C" fn ts_node_is_null(mut self_0: TSNode) -> bool {
897    return (self_0.id).is_null();
898}
899#[no_mangle]
900pub unsafe extern "C" fn ts_node_is_extra(mut self_0: TSNode) -> bool {
901    return ts_subtree_extra(ts_node__subtree(self_0));
902}
903#[no_mangle]
904pub unsafe extern "C" fn ts_node_is_named(mut self_0: TSNode) -> bool {
905    let mut alias: TSSymbol = ts_node__alias(&mut self_0) as TSSymbol;
906    return if alias as libc::c_int != 0 {
907        (ts_language_symbol_metadata((*self_0.tree).language, alias)).named as libc::c_int
908    } else {
909        ts_subtree_named(ts_node__subtree(self_0)) as libc::c_int
910    } != 0;
911}
912#[no_mangle]
913pub unsafe extern "C" fn ts_node_is_missing(mut self_0: TSNode) -> bool {
914    return ts_subtree_missing(ts_node__subtree(self_0));
915}
916#[no_mangle]
917pub unsafe extern "C" fn ts_node_has_changes(mut self_0: TSNode) -> bool {
918    return ts_subtree_has_changes(ts_node__subtree(self_0));
919}
920#[no_mangle]
921pub unsafe extern "C" fn ts_node_has_error(mut self_0: TSNode) -> bool {
922    return ts_subtree_error_cost(ts_node__subtree(self_0)) > 0 as libc::c_int as libc::c_uint;
923}
924#[no_mangle]
925pub unsafe extern "C" fn ts_node_is_error(mut self_0: TSNode) -> bool {
926    let mut symbol: TSSymbol = ts_node_symbol(self_0);
927    return symbol as libc::c_int == -(1 as libc::c_int) as TSSymbol as libc::c_int;
928}
929#[no_mangle]
930pub unsafe extern "C" fn ts_node_descendant_count(mut self_0: TSNode) -> uint32_t {
931    return (ts_subtree_visible_descendant_count(ts_node__subtree(self_0)))
932        .wrapping_add(1 as libc::c_int as libc::c_uint);
933}
934#[no_mangle]
935pub unsafe extern "C" fn ts_node_parse_state(mut self_0: TSNode) -> TSStateId {
936    return ts_subtree_parse_state(ts_node__subtree(self_0));
937}
938#[no_mangle]
939pub unsafe extern "C" fn ts_node_next_parse_state(mut self_0: TSNode) -> TSStateId {
940    let mut language: *const TSLanguage = (*self_0.tree).language;
941    let mut state: uint16_t = ts_node_parse_state(self_0);
942    if state as libc::c_int == 32767 as libc::c_int * 2 as libc::c_int + 1 as libc::c_int {
943        return (32767 as libc::c_int * 2 as libc::c_int + 1 as libc::c_int) as TSStateId;
944    }
945    let mut symbol: uint16_t = ts_node_grammar_symbol(self_0);
946    return ts_language_next_state(language, state, symbol);
947}
948#[no_mangle]
949pub unsafe extern "C" fn ts_node_parent(mut self_0: TSNode) -> TSNode {
950    let mut node: TSNode = ts_tree_root_node(self_0.tree);
951    if node.id == self_0.id {
952        return ts_node__null();
953    }
954    loop {
955        let mut next_node: TSNode = ts_node_child_with_descendant(node, self_0);
956        if next_node.id == self_0.id || ts_node_is_null(next_node) as libc::c_int != 0 {
957            break;
958        }
959        node = next_node;
960    }
961    return node;
962}
963#[no_mangle]
964pub unsafe extern "C" fn ts_node_child_containing_descendant(
965    mut self_0: TSNode,
966    mut descendant: TSNode,
967) -> TSNode {
968    let mut start_byte: uint32_t = ts_node_start_byte(descendant);
969    let mut end_byte: uint32_t = ts_node_end_byte(descendant);
970    let mut is_empty: bool = start_byte == end_byte;
971    loop {
972        let mut iter: NodeChildIterator = ts_node_iterate_children(&mut self_0);
973        loop {
974            if !ts_node_child_iterator_next(&mut iter, &mut self_0)
975                || ts_node_start_byte(self_0) > start_byte
976                || self_0.id == descendant.id
977            {
978                return ts_node__null();
979            }
980            if is_empty as libc::c_int != 0
981                && iter.position.bytes >= end_byte
982                && ts_node_child_count(self_0) > 0 as libc::c_int as libc::c_uint
983            {
984                let mut child: TSNode = ts_node_child_with_descendant(self_0, descendant);
985                if !ts_node_is_null(child) {
986                    return if ts_node__is_relevant(self_0, 1 as libc::c_int != 0) as libc::c_int
987                        != 0
988                    {
989                        self_0
990                    } else {
991                        child
992                    };
993                }
994            }
995            if !((if is_empty as libc::c_int != 0 {
996                (iter.position.bytes <= end_byte) as libc::c_int
997            } else {
998                (iter.position.bytes < end_byte) as libc::c_int
999            }) != 0
1000                || ts_node_child_count(self_0) == 0 as libc::c_int as libc::c_uint)
1001            {
1002                break;
1003            }
1004        }
1005        if ts_node__is_relevant(self_0, 1 as libc::c_int != 0) {
1006            break;
1007        }
1008    }
1009    return self_0;
1010}
1011#[no_mangle]
1012pub unsafe extern "C" fn ts_node_child_with_descendant(
1013    mut self_0: TSNode,
1014    mut descendant: TSNode,
1015) -> TSNode {
1016    let mut start_byte: uint32_t = ts_node_start_byte(descendant);
1017    let mut end_byte: uint32_t = ts_node_end_byte(descendant);
1018    let mut is_empty: bool = start_byte == end_byte;
1019    loop {
1020        let mut iter: NodeChildIterator = ts_node_iterate_children(&mut self_0);
1021        loop {
1022            if !ts_node_child_iterator_next(&mut iter, &mut self_0)
1023                || ts_node_start_byte(self_0) > start_byte
1024            {
1025                return ts_node__null();
1026            }
1027            if self_0.id == descendant.id {
1028                return self_0;
1029            }
1030            if is_empty as libc::c_int != 0
1031                && iter.position.bytes >= end_byte
1032                && ts_node_child_count(self_0) > 0 as libc::c_int as libc::c_uint
1033            {
1034                let mut child: TSNode = ts_node_child_with_descendant(self_0, descendant);
1035                if !ts_node_is_null(child) {
1036                    return if ts_node__is_relevant(self_0, 1 as libc::c_int != 0) as libc::c_int
1037                        != 0
1038                    {
1039                        self_0
1040                    } else {
1041                        child
1042                    };
1043                }
1044            }
1045            if !((if is_empty as libc::c_int != 0 {
1046                (iter.position.bytes <= end_byte) as libc::c_int
1047            } else {
1048                (iter.position.bytes < end_byte) as libc::c_int
1049            }) != 0
1050                || ts_node_child_count(self_0) == 0 as libc::c_int as libc::c_uint)
1051            {
1052                break;
1053            }
1054        }
1055        if ts_node__is_relevant(self_0, 1 as libc::c_int != 0) {
1056            break;
1057        }
1058    }
1059    return self_0;
1060}
1061#[no_mangle]
1062pub unsafe extern "C" fn ts_node_child(mut self_0: TSNode, mut child_index: uint32_t) -> TSNode {
1063    return ts_node__child(self_0, child_index, 1 as libc::c_int != 0);
1064}
1065#[no_mangle]
1066pub unsafe extern "C" fn ts_node_named_child(
1067    mut self_0: TSNode,
1068    mut child_index: uint32_t,
1069) -> TSNode {
1070    return ts_node__child(self_0, child_index, 0 as libc::c_int != 0);
1071}
1072#[no_mangle]
1073pub unsafe extern "C" fn ts_node_child_by_field_id(
1074    mut self_0: TSNode,
1075    mut field_id: TSFieldId,
1076) -> TSNode {
1077    let mut field_map: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
1078    let mut field_map_end: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
1079    let mut child: TSNode = TSNode {
1080        context: [0; 4],
1081        id: 0 as *const libc::c_void,
1082        tree: 0 as *const TSTree,
1083    };
1084    let mut iterator: NodeChildIterator = NodeChildIterator {
1085        parent: Subtree {
1086            data: SubtreeInlineData {
1087                is_inline_visible_named_extra_has_changes_is_missing_is_keyword: [0; 1],
1088                symbol: 0,
1089                parse_state: 0,
1090                padding_columns: 0,
1091                padding_rows_lookahead_bytes: [0; 1],
1092                padding_bytes: 0,
1093                size_bytes: 0,
1094            },
1095        },
1096        tree: 0 as *const TSTree,
1097        position: Length {
1098            bytes: 0,
1099            extent: TSPoint { row: 0, column: 0 },
1100        },
1101        child_index: 0,
1102        structural_child_index: 0,
1103        alias_sequence: 0 as *const TSSymbol,
1104    };
1105    '_recur: loop {
1106        if field_id == 0 || ts_node_child_count(self_0) == 0 as libc::c_int as libc::c_uint {
1107            return ts_node__null();
1108        }
1109        field_map = 0 as *const TSFieldMapEntry;
1110        field_map_end = 0 as *const TSFieldMapEntry;
1111        ts_language_field_map(
1112            (*self_0.tree).language,
1113            (*(ts_node__subtree(self_0)).ptr)
1114                .c2rust_unnamed
1115                .c2rust_unnamed
1116                .production_id as uint32_t,
1117            &mut field_map,
1118            &mut field_map_end,
1119        );
1120        if field_map == field_map_end {
1121            return ts_node__null();
1122        }
1123        while ((*field_map).field_id as libc::c_int) < field_id as libc::c_int {
1124            field_map = field_map.offset(1);
1125            if field_map == field_map_end {
1126                return ts_node__null();
1127            }
1128        }
1129        while (*field_map_end.offset(-(1 as libc::c_int) as isize)).field_id as libc::c_int
1130            > field_id as libc::c_int
1131        {
1132            field_map_end = field_map_end.offset(-1);
1133            if field_map == field_map_end {
1134                return ts_node__null();
1135            }
1136        }
1137        child = TSNode {
1138            context: [0; 4],
1139            id: 0 as *const libc::c_void,
1140            tree: 0 as *const TSTree,
1141        };
1142        iterator = ts_node_iterate_children(&mut self_0);
1143        loop {
1144            if !ts_node_child_iterator_next(&mut iterator, &mut child) {
1145                break '_recur;
1146            }
1147            if ts_subtree_extra(ts_node__subtree(child)) {
1148                continue;
1149            }
1150            let mut index: uint32_t =
1151                (iterator.structural_child_index).wrapping_sub(1 as libc::c_int as libc::c_uint);
1152            if index < (*field_map).child_index as libc::c_uint {
1153                continue;
1154            }
1155            if (*field_map).inherited {
1156                if field_map.offset(1 as libc::c_int as isize) == field_map_end {
1157                    self_0 = child;
1158                    break;
1159                } else {
1160                    let mut result: TSNode = ts_node_child_by_field_id(child, field_id);
1161                    if !(result.id).is_null() {
1162                        return result;
1163                    }
1164                    field_map = field_map.offset(1);
1165                    if field_map == field_map_end {
1166                        return ts_node__null();
1167                    }
1168                }
1169            } else if ts_node__is_relevant(child, 1 as libc::c_int != 0) {
1170                return child;
1171            } else {
1172                if ts_node_child_count(child) > 0 as libc::c_int as libc::c_uint {
1173                    return ts_node_child(child, 0 as libc::c_int as uint32_t);
1174                } else {
1175                    field_map = field_map.offset(1);
1176                    if field_map == field_map_end {
1177                        return ts_node__null();
1178                    }
1179                }
1180            }
1181        }
1182    }
1183    return ts_node__null();
1184}
1185#[inline]
1186unsafe extern "C" fn ts_node__field_name_from_language(
1187    mut self_0: TSNode,
1188    mut structural_child_index: uint32_t,
1189) -> *const libc::c_char {
1190    let mut field_map: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
1191    let mut field_map_end: *const TSFieldMapEntry = 0 as *const TSFieldMapEntry;
1192    ts_language_field_map(
1193        (*self_0.tree).language,
1194        (*(ts_node__subtree(self_0)).ptr)
1195            .c2rust_unnamed
1196            .c2rust_unnamed
1197            .production_id as uint32_t,
1198        &mut field_map,
1199        &mut field_map_end,
1200    );
1201    while field_map != field_map_end {
1202        if !(*field_map).inherited
1203            && (*field_map).child_index as libc::c_uint == structural_child_index
1204        {
1205            return *((*(*self_0.tree).language).field_names)
1206                .offset((*field_map).field_id as isize);
1207        }
1208        field_map = field_map.offset(1);
1209    }
1210    return 0 as *const libc::c_char;
1211}
1212#[no_mangle]
1213pub unsafe extern "C" fn ts_node_field_name_for_child(
1214    mut self_0: TSNode,
1215    mut child_index: uint32_t,
1216) -> *const libc::c_char {
1217    let mut result: TSNode = self_0;
1218    let mut did_descend: bool = 1 as libc::c_int != 0;
1219    let mut inherited_field_name: *const libc::c_char = 0 as *const libc::c_char;
1220    while did_descend {
1221        did_descend = 0 as libc::c_int != 0;
1222        let mut child: TSNode = TSNode {
1223            context: [0; 4],
1224            id: 0 as *const libc::c_void,
1225            tree: 0 as *const TSTree,
1226        };
1227        let mut index: uint32_t = 0 as libc::c_int as uint32_t;
1228        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut result);
1229        while ts_node_child_iterator_next(&mut iterator, &mut child) {
1230            if ts_node__is_relevant(child, 1 as libc::c_int != 0) {
1231                if index == child_index {
1232                    if ts_node_is_extra(child) {
1233                        return 0 as *const libc::c_char;
1234                    }
1235                    let mut field_name: *const libc::c_char = ts_node__field_name_from_language(
1236                        result,
1237                        (iterator.structural_child_index)
1238                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
1239                    );
1240                    if !field_name.is_null() {
1241                        return field_name;
1242                    }
1243                    return inherited_field_name;
1244                }
1245                index = index.wrapping_add(1);
1246            } else {
1247                let mut grandchild_index: uint32_t = child_index.wrapping_sub(index);
1248                let mut grandchild_count: uint32_t =
1249                    ts_node__relevant_child_count(child, 1 as libc::c_int != 0);
1250                if grandchild_index < grandchild_count {
1251                    let mut field_name_0: *const libc::c_char = ts_node__field_name_from_language(
1252                        result,
1253                        (iterator.structural_child_index)
1254                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
1255                    );
1256                    if !field_name_0.is_null() {
1257                        inherited_field_name = field_name_0;
1258                    }
1259                    did_descend = 1 as libc::c_int != 0;
1260                    result = child;
1261                    child_index = grandchild_index;
1262                    break;
1263                } else {
1264                    index = (index as libc::c_uint).wrapping_add(grandchild_count) as uint32_t
1265                        as uint32_t;
1266                }
1267            }
1268        }
1269    }
1270    return 0 as *const libc::c_char;
1271}
1272#[no_mangle]
1273pub unsafe extern "C" fn ts_node_field_name_for_named_child(
1274    mut self_0: TSNode,
1275    mut named_child_index: uint32_t,
1276) -> *const libc::c_char {
1277    let mut result: TSNode = self_0;
1278    let mut did_descend: bool = 1 as libc::c_int != 0;
1279    let mut inherited_field_name: *const libc::c_char = 0 as *const libc::c_char;
1280    while did_descend {
1281        did_descend = 0 as libc::c_int != 0;
1282        let mut child: TSNode = TSNode {
1283            context: [0; 4],
1284            id: 0 as *const libc::c_void,
1285            tree: 0 as *const TSTree,
1286        };
1287        let mut index: uint32_t = 0 as libc::c_int as uint32_t;
1288        let mut iterator: NodeChildIterator = ts_node_iterate_children(&mut result);
1289        while ts_node_child_iterator_next(&mut iterator, &mut child) {
1290            if ts_node__is_relevant(child, 0 as libc::c_int != 0) {
1291                if index == named_child_index {
1292                    if ts_node_is_extra(child) {
1293                        return 0 as *const libc::c_char;
1294                    }
1295                    let mut field_name: *const libc::c_char = ts_node__field_name_from_language(
1296                        result,
1297                        (iterator.structural_child_index)
1298                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
1299                    );
1300                    if !field_name.is_null() {
1301                        return field_name;
1302                    }
1303                    return inherited_field_name;
1304                }
1305                index = index.wrapping_add(1);
1306            } else {
1307                let mut named_grandchild_index: uint32_t = named_child_index.wrapping_sub(index);
1308                let mut grandchild_count: uint32_t =
1309                    ts_node__relevant_child_count(child, 0 as libc::c_int != 0);
1310                if named_grandchild_index < grandchild_count {
1311                    let mut field_name_0: *const libc::c_char = ts_node__field_name_from_language(
1312                        result,
1313                        (iterator.structural_child_index)
1314                            .wrapping_sub(1 as libc::c_int as libc::c_uint),
1315                    );
1316                    if !field_name_0.is_null() {
1317                        inherited_field_name = field_name_0;
1318                    }
1319                    did_descend = 1 as libc::c_int != 0;
1320                    result = child;
1321                    named_child_index = named_grandchild_index;
1322                    break;
1323                } else {
1324                    index = (index as libc::c_uint).wrapping_add(grandchild_count) as uint32_t
1325                        as uint32_t;
1326                }
1327            }
1328        }
1329    }
1330    return 0 as *const libc::c_char;
1331}
1332#[no_mangle]
1333pub unsafe extern "C" fn ts_node_child_by_field_name(
1334    mut self_0: TSNode,
1335    mut name: *const libc::c_char,
1336    mut name_length: uint32_t,
1337) -> TSNode {
1338    let mut field_id: TSFieldId =
1339        ts_language_field_id_for_name((*self_0.tree).language, name, name_length);
1340    return ts_node_child_by_field_id(self_0, field_id);
1341}
1342#[no_mangle]
1343pub unsafe extern "C" fn ts_node_child_count(mut self_0: TSNode) -> uint32_t {
1344    let mut tree: Subtree = ts_node__subtree(self_0);
1345    if ts_subtree_child_count(tree) > 0 as libc::c_int as libc::c_uint {
1346        return (*tree.ptr)
1347            .c2rust_unnamed
1348            .c2rust_unnamed
1349            .visible_child_count;
1350    } else {
1351        return 0 as libc::c_int as uint32_t;
1352    };
1353}
1354#[no_mangle]
1355pub unsafe extern "C" fn ts_node_named_child_count(mut self_0: TSNode) -> uint32_t {
1356    let mut tree: Subtree = ts_node__subtree(self_0);
1357    if ts_subtree_child_count(tree) > 0 as libc::c_int as libc::c_uint {
1358        return (*tree.ptr).c2rust_unnamed.c2rust_unnamed.named_child_count;
1359    } else {
1360        return 0 as libc::c_int as uint32_t;
1361    };
1362}
1363#[no_mangle]
1364pub unsafe extern "C" fn ts_node_next_sibling(mut self_0: TSNode) -> TSNode {
1365    return ts_node__next_sibling(self_0, 1 as libc::c_int != 0);
1366}
1367#[no_mangle]
1368pub unsafe extern "C" fn ts_node_next_named_sibling(mut self_0: TSNode) -> TSNode {
1369    return ts_node__next_sibling(self_0, 0 as libc::c_int != 0);
1370}
1371#[no_mangle]
1372pub unsafe extern "C" fn ts_node_prev_sibling(mut self_0: TSNode) -> TSNode {
1373    return ts_node__prev_sibling(self_0, 1 as libc::c_int != 0);
1374}
1375#[no_mangle]
1376pub unsafe extern "C" fn ts_node_prev_named_sibling(mut self_0: TSNode) -> TSNode {
1377    return ts_node__prev_sibling(self_0, 0 as libc::c_int != 0);
1378}
1379#[no_mangle]
1380pub unsafe extern "C" fn ts_node_first_child_for_byte(
1381    mut self_0: TSNode,
1382    mut byte: uint32_t,
1383) -> TSNode {
1384    return ts_node__first_child_for_byte(self_0, byte, 1 as libc::c_int != 0);
1385}
1386#[no_mangle]
1387pub unsafe extern "C" fn ts_node_first_named_child_for_byte(
1388    mut self_0: TSNode,
1389    mut byte: uint32_t,
1390) -> TSNode {
1391    return ts_node__first_child_for_byte(self_0, byte, 0 as libc::c_int != 0);
1392}
1393#[no_mangle]
1394pub unsafe extern "C" fn ts_node_descendant_for_byte_range(
1395    mut self_0: TSNode,
1396    mut start: uint32_t,
1397    mut end: uint32_t,
1398) -> TSNode {
1399    return ts_node__descendant_for_byte_range(self_0, start, end, 1 as libc::c_int != 0);
1400}
1401#[no_mangle]
1402pub unsafe extern "C" fn ts_node_named_descendant_for_byte_range(
1403    mut self_0: TSNode,
1404    mut start: uint32_t,
1405    mut end: uint32_t,
1406) -> TSNode {
1407    return ts_node__descendant_for_byte_range(self_0, start, end, 0 as libc::c_int != 0);
1408}
1409#[no_mangle]
1410pub unsafe extern "C" fn ts_node_descendant_for_point_range(
1411    mut self_0: TSNode,
1412    mut start: TSPoint,
1413    mut end: TSPoint,
1414) -> TSNode {
1415    return ts_node__descendant_for_point_range(self_0, start, end, 1 as libc::c_int != 0);
1416}
1417#[no_mangle]
1418pub unsafe extern "C" fn ts_node_named_descendant_for_point_range(
1419    mut self_0: TSNode,
1420    mut start: TSPoint,
1421    mut end: TSPoint,
1422) -> TSNode {
1423    return ts_node__descendant_for_point_range(self_0, start, end, 0 as libc::c_int != 0);
1424}
1425#[no_mangle]
1426pub unsafe extern "C" fn ts_node_edit(mut self_0: *mut TSNode, mut edit: *const TSInputEdit) {
1427    let mut start_byte: uint32_t = ts_node_start_byte(*self_0);
1428    let mut start_point: TSPoint = ts_node_start_point(*self_0);
1429    if start_byte >= (*edit).old_end_byte {
1430        start_byte =
1431            ((*edit).new_end_byte).wrapping_add(start_byte.wrapping_sub((*edit).old_end_byte));
1432        start_point = point_add(
1433            (*edit).new_end_point,
1434            point_sub(start_point, (*edit).old_end_point),
1435        );
1436    } else if start_byte > (*edit).start_byte {
1437        start_byte = (*edit).new_end_byte;
1438        start_point = (*edit).new_end_point;
1439    }
1440    (*self_0).context[0 as libc::c_int as usize] = start_byte;
1441    (*self_0).context[1 as libc::c_int as usize] = start_point.row;
1442    (*self_0).context[2 as libc::c_int as usize] = start_point.column;
1443}