types.c
// Go down one level into a struct/union/array and return an new iterator
Go down one level into a struct/union/array and return an new iterator
Go down one level into a struct / union / array and return an new iterator
TypeIterator *type_iterator_descend(TypeIterator *it) {
    if (type_iterator_done(it))
        panic("Attempt to call descend on a done type iterator");
    if (is_scalar_type(it->type)) {
        TypeIterator *child = type_iterator(it->type);
        child->offset = it->offset;
        child->parent = it;
        return child;
    }
    if (it->type->type == TYPE_ARRAY) {
        TypeIterator *child = type_iterator(it->type->target);
        child->offset = it->offset;
        child->start_offset = it->offset;
        child->parent = it;
        return child;;
    }
    else if (it->type->type == TYPE_STRUCT_OR_UNION) {
        TypeIterator *child = type_iterator(it->type->struct_or_union_desc->members[it->index]->type);
        child->bit_field_offset = it->type->struct_or_union_desc->members[it->index]->bit_field_offset;
        child->bit_field_size = it->type->struct_or_union_desc->members[it->index]->bit_field_size;
        child->offset = it->offset;
        child->start_offset = it->offset;
        child->parent = it;
        return child;
    }
    else
        panic("Unhandled type in type_iterator_descend");
}
TypeIterator * type_iterator_descend ( TypeIterator * it ) { if ( type_iterator_done ( it ) ) panic ( " " ) ; if ( is_scalar_type ( it -> type ) ) { TypeIterator * child = type_iterator ( it -> type ) ; child -> offset = it -> offset ; child -> parent = it ; return child ; } if ( it -> type -> type == TYPE_ARRAY ) { TypeIterator * child = type_iterator ( it -> type -> target ) ; child -> offset = it -> offset ; child -> start_offset = it -> offset ; child -> parent = it ; return child ; ; } else if ( it -> type -> type == TYPE_STRUCT_OR_UNION ) { TypeIterator * child = type_iterator ( it -> type -> struct_or_union_desc -> members [ it -> index ] -> type ) ; child -> bit_field_offset = it -> type -> struct_or_union_desc -> members [ it -> index ] -> bit_field_offset ; child -> bit_field_size = it -> type -> struct_or_union_desc -> members [ it -> index ] -> bit_field_size ; child -> offset = it -> offset ; child -> start_offset = it -> offset ; child -> parent = it ; return child ; } else panic ( " " ) ; }
Go down one level into a struct/union/array and return an new iterator
Go down one level into a struct / union / array and return an new iterator