harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 422f2db26233f1649c30b4579650852e0c955179
parent 76f2bae5498ab6d017ac612f290037cfb1c6b9e0
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 31 Jan 2021 09:37:45 -0500

all: s/TYPE_STORAGE_TAGGED_UNION/TYPE_STORAGE_TAGGED/g

Diffstat:
Minclude/types.h | 2+-
Msrc/check.c | 8++++----
Msrc/dump.c | 4++--
Msrc/eval.c | 6+++---
Msrc/gen.c | 16++++++++--------
Msrc/lex.c | 2+-
Msrc/parse.c | 2+-
Msrc/qtype.c | 10+++++-----
Msrc/type_store.c | 14+++++++-------
Msrc/typedef.c | 4++--
Msrc/types.c | 24++++++++++++------------
11 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/include/types.h b/include/types.h @@ -34,7 +34,7 @@ enum type_storage { TYPE_STORAGE_SLICE, TYPE_STORAGE_STRING, TYPE_STORAGE_STRUCT, - TYPE_STORAGE_TAGGED_UNION, + TYPE_STORAGE_TAGGED, TYPE_STORAGE_UNION, }; diff --git a/src/check.c b/src/check.c @@ -551,7 +551,7 @@ check_expr_cast(struct context *ctx, if (aexpr->cast.kind == C_ASSERTION || aexpr->cast.kind == C_TEST) { const struct type *primary = type_dealias(expr->cast.value->result); expect(&aexpr->cast.value->loc, - primary->storage == TYPE_STORAGE_TAGGED_UNION, + primary->storage == TYPE_STORAGE_TAGGED, "Expected a tagged union type"); bool found = false; for (const struct type_tagged_union *t = &primary->tagged; @@ -687,7 +687,7 @@ check_expr_constant(struct context *ctx, case TYPE_STORAGE_FUNCTION: case TYPE_STORAGE_POINTER: case TYPE_STORAGE_SLICE: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: assert(0); // Invariant } @@ -900,7 +900,7 @@ check_expr_match(struct context *ctx, bool is_ptr = type->storage == TYPE_STORAGE_POINTER && type->pointer.flags & PTR_NULLABLE; expect(&aexpr->match.value->loc, - type->storage == TYPE_STORAGE_TAGGED_UNION || is_ptr, + type->storage == TYPE_STORAGE_TAGGED || is_ptr, "match value must be tagged union or nullable pointer type"); struct type_tagged_union result_type = {0}; @@ -930,7 +930,7 @@ check_expr_match(struct context *ctx, expect(&acase->type->loc, is_ptr, "Not matching on pointer type"); break; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: expect(&acase->type->loc, !is_ptr, "Not matching on tagged union type"); expect(&acase->type->loc, diff --git a/src/dump.c b/src/dump.c @@ -108,7 +108,7 @@ dump_const(const struct expression *expr) case TYPE_STORAGE_CHAR: case TYPE_STORAGE_FUNCTION: case TYPE_STORAGE_POINTER: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: assert(0); // Invariant } } @@ -167,7 +167,7 @@ dump_type(const struct type *type) fprintf(stderr, "%s", ident); free(ident); break; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: fprintf(stderr, "("); for (const struct type_tagged_union *tu = &type->tagged; tu; tu = tu->next) { diff --git a/src/eval.c b/src/eval.c @@ -53,7 +53,7 @@ itrunc(const struct type *type, uintmax_t val) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_VOID: assert(0); @@ -256,7 +256,7 @@ eval_const(struct context *ctx, struct expression *in, struct expression *out) break; case TYPE_STORAGE_STRUCT: case TYPE_STORAGE_UNION: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: assert(0); // TODO case TYPE_STORAGE_BOOL: case TYPE_STORAGE_CHAR: @@ -337,7 +337,7 @@ eval_cast(struct context *ctx, struct expression *in, struct expression *out) case TYPE_STORAGE_ENUM: case TYPE_STORAGE_NULL: case TYPE_STORAGE_RUNE: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: assert(0); // TODO case TYPE_STORAGE_ALIAS: assert(0); // Handled above diff --git a/src/gen.c b/src/gen.c @@ -920,7 +920,7 @@ gen_cast_to_tagged(struct gen_context *ctx, gen_temp(ctx, &ptr, &qbe_long, "ptr.%d"); constl(&offs, expr->result->align); - if (type_dealias(from)->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type_dealias(from)->storage == TYPE_STORAGE_TAGGED) { gen_expression(ctx, expr->cast.value, &ptr); gen_copy(ctx, out, &ptr); return; @@ -949,7 +949,7 @@ gen_cast_from_tagged(struct gen_context *ctx, const struct qbe_value *out, const struct type *to) { - if (type_dealias(to)->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type_dealias(to)->storage == TYPE_STORAGE_TAGGED) { assert(0); // TODO } @@ -1053,10 +1053,10 @@ gen_expr_cast(struct gen_context *ctx, if (to->storage == from->storage && to->size == from->size) { gen_expression(ctx, expr->cast.value, out); return; - } else if (to->storage == TYPE_STORAGE_TAGGED_UNION) { + } else if (to->storage == TYPE_STORAGE_TAGGED) { gen_cast_to_tagged(ctx, expr, out, from); return; - } else if (from->storage == TYPE_STORAGE_TAGGED_UNION) { + } else if (from->storage == TYPE_STORAGE_TAGGED) { gen_cast_from_tagged(ctx, expr, out, to); return; } @@ -1175,7 +1175,7 @@ gen_expr_cast(struct gen_context *ctx, pushi(ctx->current, &result, Q_COPY, &in, NULL); break; case TYPE_STORAGE_ALIAS: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: assert(0); // Handled above case TYPE_STORAGE_BOOL: case TYPE_STORAGE_FUNCTION: @@ -1537,7 +1537,7 @@ gen_match_tagged(struct gen_context *ctx, const struct type_tagged_union *tu; struct type_tagged_union synthetic = {0}; - if (_case->type->storage != TYPE_STORAGE_TAGGED_UNION) { + if (_case->type->storage != TYPE_STORAGE_TAGGED) { synthetic.type = _case->type; tu = &synthetic; } else { @@ -1663,7 +1663,7 @@ gen_expr_match(struct gen_context *ctx, { const struct type *mtype = type_dealias(expr->match.value->result); switch (mtype->storage) { - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: gen_match_tagged(ctx, expr, out); break; case TYPE_STORAGE_POINTER: @@ -2313,7 +2313,7 @@ gen_data_item(struct gen_context *ctx, struct expression *expr, break; case TYPE_STORAGE_ENUM: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: assert(0); // TODO case TYPE_STORAGE_ALIAS: diff --git a/src/lex.c b/src/lex.c @@ -1050,7 +1050,7 @@ token_str(const struct token *tok) case TYPE_STORAGE_NULL: case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_VOID: assert(0); diff --git a/src/parse.c b/src/parse.c @@ -529,7 +529,7 @@ parse_tagged_union_type(struct lexer *lexer) { trenter(TR_PARSE, "tagged union"); struct ast_type *type = mktype(&lexer->loc); - type->storage = TYPE_STORAGE_TAGGED_UNION; + type->storage = TYPE_STORAGE_TAGGED; struct ast_tagged_union_type *next = &type->tagged_union; next->type = parse_type(lexer); struct token tok = {0}; diff --git a/src/qtype.c b/src/qtype.c @@ -45,7 +45,7 @@ qstype_for_type(const struct type *type) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_FUNCTION: assert(0); // Invariant @@ -84,7 +84,7 @@ qxtype_for_type(const struct type *type) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_FUNCTION: return qstype_for_type(type); @@ -186,7 +186,7 @@ lookup_aggregate(struct gen_context *ctx, const struct type *type) field->type = &qbe_long; // XXX: ARCH field->count = 3; break; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: def->type.align = type->align; field->type = &qbe_word; // XXX: ARCH field->count = 1; @@ -264,7 +264,7 @@ qtype_for_type(struct gen_context *ctx, const struct type *type, bool extended) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: return lookup_aggregate(ctx, type); case TYPE_STORAGE_FUNCTION: @@ -307,7 +307,7 @@ type_is_aggregate(const struct type *type) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_FUNCTION: return true; diff --git a/src/type_store.c b/src/type_store.c @@ -76,7 +76,7 @@ builtin_type_for_storage(enum type_storage storage, bool is_const) case TYPE_STORAGE_POINTER: case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_ENUM: return NULL; @@ -192,7 +192,7 @@ sum_tagged_memb(struct type_store *store, size_t nmemb = 0; for (; u; u = u->next) { const struct type *type = u->type; - if (type->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type->storage == TYPE_STORAGE_TAGGED) { nmemb += sum_tagged_memb(store, &type->tagged); } else { ++nmemb; @@ -209,7 +209,7 @@ sum_atagged_memb(struct type_store *store, for (; u; u = u->next) { const struct type *type = type_store_lookup_atype(store, u->type); - if (type->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type->storage == TYPE_STORAGE_TAGGED) { nmemb += sum_tagged_memb(store, &type->tagged); } else { ++nmemb; @@ -226,7 +226,7 @@ collect_tagged_memb(struct type_store *store, { for (; src; src = src->next) { const struct type *type = src->type; - if (type->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type->storage == TYPE_STORAGE_TAGGED) { collect_tagged_memb(store, ta, &type->tagged, i); continue; } @@ -246,7 +246,7 @@ collect_atagged_memb(struct type_store *store, for (; atu; atu = atu->next) { const struct type *type = type_store_lookup_atype(store, atu->type); - if (type->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type->storage == TYPE_STORAGE_TAGGED) { collect_tagged_memb(store, ta, &type->tagged, i); continue; } @@ -486,7 +486,7 @@ type_init_from_atype(struct type_store *store, &type->align, &type->struct_union.fields, &atype->struct_union); break; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: tagged_init_from_atype(store, type, atype); break; } @@ -618,7 +618,7 @@ type_store_lookup_tagged(struct type_store *store, struct type_tagged_union *tags) { struct type type = { - .storage = TYPE_STORAGE_TAGGED_UNION, + .storage = TYPE_STORAGE_TAGGED, }; size_t nmemb = sum_tagged_memb(store, tags); struct type_tagged_union **tu = diff --git a/src/typedef.c b/src/typedef.c @@ -95,7 +95,7 @@ emit_const(const struct expression *expr, FILE *out) case TYPE_STORAGE_CHAR: case TYPE_STORAGE_FUNCTION: case TYPE_STORAGE_POINTER: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: assert(0); // Invariant } } @@ -196,7 +196,7 @@ emit_type(const struct type *type, FILE *out) fprintf(out, "%s", ident); free(ident); break; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: fprintf(out, "("); for (const struct type_tagged_union *tu = &type->tagged; tu; tu = tu->next) { diff --git a/src/types.c b/src/types.c @@ -91,7 +91,7 @@ type_storage_unparse(enum type_storage storage) return "str"; case TYPE_STORAGE_STRUCT: return "struct"; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: return "tagged union"; case TYPE_STORAGE_U16: return "u16"; @@ -124,7 +124,7 @@ type_is_integer(const struct type *type) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_BOOL: case TYPE_STORAGE_NULL: @@ -164,7 +164,7 @@ type_is_numeric(const struct type *type) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_BOOL: case TYPE_STORAGE_CHAR: @@ -212,7 +212,7 @@ storage_is_signed(enum type_storage storage) case TYPE_STORAGE_SLICE: case TYPE_STORAGE_STRING: case TYPE_STORAGE_STRUCT: - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_UNION: case TYPE_STORAGE_BOOL: case TYPE_STORAGE_CHAR: @@ -320,7 +320,7 @@ type_hash(const struct type *type) hash = fnv1a_u32(hash, field->offset); } break; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: // Invariant: subtypes must be sorted by ID and must not include // any other tagged union types, nor any duplicates. for (const struct type_tagged_union *tu = &type->tagged; @@ -350,7 +350,7 @@ static const struct type * tagged_select_subtype(const struct type *tagged, const struct type *subtype) { tagged = type_dealias(tagged); - assert(tagged->storage == TYPE_STORAGE_TAGGED_UNION); + assert(tagged->storage == TYPE_STORAGE_TAGGED); size_t nassign = 0; const struct type *selected = NULL; @@ -463,7 +463,7 @@ type_is_assignable(const struct type *to, const struct type *from) return from->storage == TYPE_STORAGE_ARRAY && to->array.length == SIZE_UNDEFINED && from->array.length != SIZE_UNDEFINED; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: // XXX: Needs work! return tagged_select_subtype(to, from) != NULL || true; // The following types are only assignable from themselves, and are @@ -485,7 +485,7 @@ type_is_assignable(const struct type *to, const struct type *from) static bool castable_to_tagged(const struct type *to, const struct type *from) { - if (type_dealias(from)->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type_dealias(from)->storage == TYPE_STORAGE_TAGGED) { return true; } @@ -507,7 +507,7 @@ castable_to_tagged(const struct type *to, const struct type *from) static bool castable_from_tagged(const struct type *to, const struct type *from) { - if (type_dealias(to)->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type_dealias(to)->storage == TYPE_STORAGE_TAGGED) { return true; } @@ -529,9 +529,9 @@ castable_from_tagged(const struct type *to, const struct type *from) bool type_is_castable(const struct type *to, const struct type *from) { - if (type_dealias(to)->storage == TYPE_STORAGE_TAGGED_UNION) { + if (type_dealias(to)->storage == TYPE_STORAGE_TAGGED) { return castable_to_tagged(to, from); - } else if (type_dealias(from)->storage == TYPE_STORAGE_TAGGED_UNION) { + } else if (type_dealias(from)->storage == TYPE_STORAGE_TAGGED) { return castable_from_tagged(to, from); } @@ -594,7 +594,7 @@ type_is_castable(const struct type *to, const struct type *from) case TYPE_STORAGE_STRING: case TYPE_STORAGE_NULL: return false; - case TYPE_STORAGE_TAGGED_UNION: + case TYPE_STORAGE_TAGGED: case TYPE_STORAGE_ALIAS: assert(0); // Handled above }