commit 84edc0f7c3394bf46b59e52a7ee48f9a7605b9d6
parent ba94026d37ce868f230a3f8bba4b9cfce442851b
Author: Bor Grošelj Simić <bgs@turminal.net>
Date: Sat, 21 May 2022 03:03:05 +0200
use 'struct identifiers' for lists of identifiers
Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
Diffstat:
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/check.h b/include/check.h
@@ -96,15 +96,10 @@ struct declarations {
struct declarations *next;
};
-struct imports {
- struct identifier ident;
- struct imports *next;
-};
-
struct unit {
struct identifier *ns;
struct declarations *declarations;
- struct imports *imports;
+ struct identifiers *imports;
};
enum idecl_type {
diff --git a/include/identifier.h b/include/identifier.h
@@ -9,6 +9,11 @@ struct identifier {
struct identifier *ns;
};
+struct identifiers {
+ struct identifier ident;
+ struct identifiers *next;
+};
+
uint32_t identifier_hash(uint32_t init, const struct identifier *ident);
char *identifier_unparse(const struct identifier *ident);
int identifier_unparse_static(
diff --git a/src/check.c b/src/check.c
@@ -3797,7 +3797,7 @@ check_internal(struct type_store *ts,
struct scopes *subunit_scopes = NULL;
struct scopes **next = &subunit_scopes;
struct scope *su_scope = NULL;
- struct imports **inext = &unit->imports;
+ struct identifiers **inext = &unit->imports;
ctx.scope = NULL;
ctx.unit = scope_push(&ctx.scope, SCOPE_UNIT);
@@ -3816,7 +3816,7 @@ check_internal(struct type_store *ts,
load_import(&ctx, imports, ts, su_scope);
bool found = false;
- for (struct imports *uimports = unit->imports;
+ for (struct identifiers *uimports = unit->imports;
uimports; uimports = uimports->next) {
if (identifier_eq(&uimports->ident, &imports->ident)) {
found = true;
@@ -3824,8 +3824,8 @@ check_internal(struct type_store *ts,
}
}
if (!found) {
- struct imports *uimport = *inext =
- xcalloc(1, sizeof(struct imports));
+ struct identifiers *uimport = *inext =
+ xcalloc(1, sizeof(struct identifiers));
identifier_dup(&uimport->ident, &imports->ident);
inext = &uimport->next;
}
diff --git a/src/typedef.c b/src/typedef.c
@@ -433,7 +433,7 @@ emit_decl_type(struct declaration *decl, FILE *out)
void
emit_typedefs(struct unit *unit, FILE *out)
{
- for (struct imports *imports = unit->imports;
+ for (struct identifiers *imports = unit->imports;
imports; imports = imports->next) {
char *ident = identifier_unparse(&imports->ident);
fprintf(out, "use %s;\n", ident);