/** * Hash the given type and return the "singleton" version * of it. */ type_t *identify_new_type(type_t *type) { type_t *result = typehash_insert(type); if (result != type) { obstack_free(&type_obst, type); } return result; }
type_t* make_pointer_type(type_t *points_to) { type_t *type = allocate_type(TYPE_POINTER); type->pointer.points_to = points_to; type_t *normalized_type = typehash_insert(type); if (normalized_type != type) { obstack_free(type_obst, type); } return normalized_type; }
type_t* make_atomic_type(atomic_type_kind_t akind) { type_t *type = allocate_type(TYPE_ATOMIC); type->atomic.akind = akind; type_t *normalized_type = typehash_insert(type); if (normalized_type != type) { obstack_free(type_obst, type); } return normalized_type; }
static type_t *create_concrete_typevar_binding_type(bind_typevariables_type_t *type) { int changed = 0; type_argument_t *new_arguments; type_argument_t *last_argument = NULL; type_argument_t *type_argument = type->type_arguments; while (type_argument != NULL) { type_t *type = type_argument->type; type_t *new_type = create_concrete_type(type); if (new_type != type) { changed = 1; } type_argument_t *new_argument = obstack_alloc(type_obst, sizeof(new_argument[0])); memset(new_argument, 0, sizeof(new_argument[0])); new_argument->type = new_type; if (last_argument != NULL) { last_argument->next = new_argument; } else { new_arguments = new_argument; } last_argument = new_argument; type_argument = type_argument->next; } if (!changed) { assert(new_arguments != NULL); obstack_free(type_obst, new_arguments); return (type_t*) type; } type_t *new_type = allocate_type(TYPE_BIND_TYPEVARIABLES); new_type->bind_typevariables.polymorphic_type = type->polymorphic_type; new_type->bind_typevariables.type_arguments = new_arguments; type_t *normalized_type = typehash_insert(new_type); if (normalized_type != new_type) { obstack_free(type_obst, new_type); } return normalized_type; }
static type_t *create_concrete_array_type(array_type_t *type) { type_t *element_type = create_concrete_type(type->element_type); if (element_type == type->element_type) return (type_t*) type; type_t *new_type = allocate_type(TYPE_ARRAY); new_type->array.element_type = element_type; new_type->array.size_expression = type->size_expression; type_t *normalized_type = typehash_insert((type_t*) new_type); if (normalized_type != (type_t*) new_type) { obstack_free(type_obst, new_type); } return normalized_type; }
static type_t *create_concrete_pointer_type(pointer_type_t *type) { type_t *points_to = create_concrete_type(type->points_to); if (points_to == type->points_to) return (type_t*) type; type_t *new_type = allocate_type(TYPE_POINTER); new_type->pointer.points_to = points_to; type_t *normalized_type = typehash_insert((type_t*) new_type); if (normalized_type != new_type) { obstack_free(type_obst, new_type); } return normalized_type; }