X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fdecl_type.c;h=00112b314570d8a9f5ecfc47f0637173c86c12af;hb=a88d91ed2154bdb6d2198e44c6f3868a5b398287;hp=c64b24d00b56313b53c4be1586784158b594026a;hpb=cffcbdd1df9f6d5dcf78f49a3d1b44cefe21b2f5;p=m6w6%2Fext-psi diff --git a/src/types/decl_type.c b/src/types/decl_type.c index c64b24d..00112b3 100644 --- a/src/types/decl_type.c +++ b/src/types/decl_type.c @@ -213,18 +213,23 @@ bool psi_decl_type_get_decl(struct psi_decl_type *type, struct psi_plist *decls) } bool psi_decl_type_validate(struct psi_data *data, struct psi_decl_type *type, - bool is_pointer, struct psi_validate_stack *type_stack) + struct psi_decl_arg *def, struct psi_validate_scope *scope) { if (psi_decl_type_is_weak(type)) { if (!psi_decl_type_get_alias(type, data->types)) { - if (!psi_validate_stack_has_type(type_stack, type->name)) { + if (!psi_validate_scope_has_type(scope, type->name)) { return false; } - type->real.def = psi_validate_stack_get_type(type_stack, type->name); + type->real.def = psi_validate_scope_get_type(scope, type->name); } if (type->real.def) { - return psi_decl_type_validate(data, type->real.def->type, - is_pointer, type_stack); + if (!psi_decl_type_validate(data, type->real.def->type, + type->real.def, scope)) { + return false; + } + if (def) { + def->var->pointer_level += type->real.def->var->pointer_level; + } } return true; } @@ -232,9 +237,9 @@ bool psi_decl_type_validate(struct psi_data *data, struct psi_decl_type *type, switch (type->type) { case PSI_T_STRUCT: if (!psi_decl_type_get_struct(type, data->structs)) { - if (psi_validate_stack_has_struct(type_stack, type->name)) { - type->real.strct = psi_validate_stack_get_struct(type_stack, type->name); - } else if (is_pointer) { + if (psi_validate_scope_has_struct(scope, type->name)) { + type->real.strct = psi_validate_scope_get_struct(scope, type->name); + } else if (def && def->var->pointer_level) { return true; } else { data->error(data, type->token, PSI_WARNING, @@ -242,15 +247,15 @@ bool psi_decl_type_validate(struct psi_data *data, struct psi_decl_type *type, return false; } } - if (!psi_decl_struct_validate(data, type->real.strct, type_stack)) { + if (!psi_decl_struct_validate(data, type->real.strct, scope)) { return false; } break; case PSI_T_UNION: if (!psi_decl_type_get_union(type, data->unions)) { - if (psi_validate_stack_has_union(type_stack, type->name)) { - type->real.unn = psi_validate_stack_get_union(type_stack, type->name); - } else if (is_pointer) { + if (psi_validate_scope_has_union(scope, type->name)) { + type->real.unn = psi_validate_scope_get_union(scope, type->name); + } else if (def && def->var->pointer_level) { return true; } else { data->error(data, type->token, PSI_WARNING, @@ -258,7 +263,7 @@ bool psi_decl_type_validate(struct psi_data *data, struct psi_decl_type *type, return false; } } - if (!psi_decl_union_validate(data, type->real.unn, type_stack)) { + if (!psi_decl_union_validate(data, type->real.unn, scope)) { return false; } break; @@ -275,7 +280,7 @@ bool psi_decl_type_validate(struct psi_data *data, struct psi_decl_type *type, "Unknown decl '%s'", type->name); return false; } - if (!psi_decl_validate_nodl(data, type->real.func, type_stack)) { + if (!psi_decl_validate_nodl(data, type->real.func, scope)) { return false; } break; @@ -359,6 +364,10 @@ void psi_decl_type_dump(int fd, struct psi_decl_type *t, unsigned level) } break; + case PSI_T_FUNCTION: + psi_decl_type_dump(fd, t->real.func->func->type, level); + return; + default: break; }