X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fvalidate.c;h=64815272cc28a445a5050634dc68b00f318e20e7;hp=1d55b13f26ca8a5b4c4d6e11ad7686b381017ec8;hb=c0873cbbe9e5a83305adbc2bbd94aede5437f33d;hpb=02e801eabbe26a129ea05e6723c94e10bb653dab diff --git a/src/validate.c b/src/validate.c index 1d55b13..6481527 100644 --- a/src/validate.c +++ b/src/validate.c @@ -76,7 +76,7 @@ static bool psi_validate_type(struct psi_validate_scope *scope, { struct psi_decl_arg *def = ptr; - PSI_DEBUG_PRINT(dst, "typedef %s", def->var->name); + PSI_DEBUG_PRINT(dst, "typedef %s", def->var->name->val); return psi_decl_arg_validate_typedef(dst, def, scope); } @@ -85,7 +85,7 @@ static bool psi_validate_struct(struct psi_validate_scope *scope, { struct psi_decl_struct *str = ptr; - PSI_DEBUG_PRINT(dst, "struct %s", str->name); + PSI_DEBUG_PRINT(dst, "struct %s", str->name->val); if (psi_decl_struct_validate(dst, str, scope)) { PSI_DEBUG_PRINT(dst, "::(%zu, %zu)", str->align, str->size); return true; @@ -98,7 +98,7 @@ static bool psi_validate_union(struct psi_validate_scope *scope, { struct psi_decl_union *unn = ptr; - PSI_DEBUG_PRINT(dst, "union %s", unn->name); + PSI_DEBUG_PRINT(dst, "union %s", unn->name->val); if (psi_decl_union_validate(dst, unn, scope)) { PSI_DEBUG_PRINT(dst, "::(%zu, %zu)", unn->align, unn->size); return true; @@ -111,7 +111,7 @@ static bool psi_validate_enum(struct psi_validate_scope *scope, { struct psi_decl_enum *enm = ptr; - PSI_DEBUG_PRINT(dst, "enum %s", enm->name); + PSI_DEBUG_PRINT(dst, "enum %s", enm->name->val); return psi_decl_enum_validate(dst, enm); } @@ -120,7 +120,7 @@ static bool psi_validate_extvar(struct psi_validate_scope *scope, { struct psi_decl_extvar *evar = ptr; - PSI_DEBUG_PRINT(dst, "extvar %s", evar->arg->var->name); + PSI_DEBUG_PRINT(dst, "extvar %s", evar->arg->var->name->val); if (psi_decl_extvar_validate(dst, evar, scope)) { dst->decls = psi_plist_add(dst->decls, &evar->getter); dst->decls = psi_plist_add(dst->decls, &evar->setter); @@ -134,7 +134,7 @@ static bool psi_validate_decl(struct psi_validate_scope *scope, { struct psi_decl *decl = ptr; - PSI_DEBUG_PRINT(dst, "decl %s", decl->func->var->name); + PSI_DEBUG_PRINT(dst, "decl %s", decl->func->var->name->val); return psi_decl_validate(dst, decl, scope); } @@ -143,7 +143,7 @@ static bool psi_validate_const(struct psi_validate_scope *scope, { struct psi_const *cnst = ptr; - PSI_DEBUG_PRINT(dst, "constant %s", cnst->name); + PSI_DEBUG_PRINT(dst, "constant %s", cnst->name->val); return psi_const_validate(dst, cnst, scope); } @@ -152,7 +152,7 @@ static bool psi_validate_impl(struct psi_validate_scope *scope, { struct psi_impl *impl = ptr; - PSI_DEBUG_PRINT(dst, "impl %s", impl->func->name); + PSI_DEBUG_PRINT(dst, "impl %s", impl->func->name->val); return psi_impl_validate(dst, impl, scope); } @@ -203,17 +203,20 @@ bool psi_validate(struct psi_validate_scope *scope, } /* nothing changed; bail out */ - if (count_all && (dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) { - /* one last error-spitting round, if not explicitly suppressed */ - dst->flags ^= PSI_SILENT; - check_count = ~0; + if (count_all) { + src->errors += count_all; - PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu" - " type checks remaining, errors follow\n", count_all); - continue; + if ((dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) { + /* one last error-spitting round, if not explicitly suppressed */ + dst->flags ^= PSI_SILENT; + check_count = ~0; + + PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu" + " type checks remaining, errors follow\n", count_all); + continue; + } } - src->errors += count_all; break; } @@ -223,5 +226,30 @@ bool psi_validate(struct psi_validate_scope *scope, psi_validate_list(scope, dst, &consts, psi_validate_const); psi_validate_list(scope, dst, &impls, psi_validate_impl); + if (types.cur != types.src) { + psi_plist_free(types.cur); + } + if (structs.cur != structs.src) { + psi_plist_free(structs.cur); + } + if (unions.cur != unions.src) { + psi_plist_free(unions.cur); + } + if (enums.cur != enums.src) { + psi_plist_free(enums.cur); + } + if (vars.cur != vars.src) { + psi_plist_free(vars.cur); + } + if (decls.cur != decls.src) { + psi_plist_free(decls.cur); + } + if (consts.cur != consts.src) { + psi_plist_free(consts.cur); + } + if (impls.cur != impls.src) { + psi_plist_free(impls.cur); + } + return true; }