X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext_validate.c;h=8add34d5ec53be4697a038b4e467e59c24517596;hp=cf0695f0138ca19c34c9fd21088dd296295e7d46;hb=5359ad5c181e5772f350fe1cba060cbed3a05b91;hpb=d3171526ab7658114cac4ebe1098af4b038e576e diff --git a/src/context_validate.c b/src/context_validate.c index cf0695f..8add34d 100644 --- a/src/context_validate.c +++ b/src/context_validate.c @@ -13,11 +13,12 @@ #include "php_psi_macros.h" #include "php_psi_redirs.h" +#include "parser.h" #include "calc.h" #include "marshal.h" #include "engine.h" -static int validate_lib(PSI_Data *data, void **dlopened) { +static int validate_lib(struct psi_data *data, void **dlopened) { char lib[MAXPATHLEN]; const char *ptr = data->psi.file.ln; size_t len; @@ -45,14 +46,14 @@ static inline int locate_decl_type_alias(decl_typedefs *defs, decl_type *type) { size_t i; struct psi_std_type *stdtyp; - if (type->real) { + if (type->real.def) { return 1; } if (defs) for (i = 0; i < defs->count; ++i) { decl_arg *def = defs->list[i]; if (def->type->type != type->type && !strcmp(def->var->name, type->name)) { - type->real = def->type; + type->real.def = def; return 1; } } @@ -69,12 +70,12 @@ static inline int locate_decl_type_alias(decl_typedefs *defs, decl_type *type) { static inline int locate_decl_type_struct(decl_structs *structs, decl_type *type) { size_t i; - if (type->strct) { + if (type->real.strct) { return 1; } if (structs) for (i = 0; i < structs->count; ++i) { if (!strcmp(structs->list[i]->name, type->name)) { - type->strct = structs->list[i]; + type->real.strct = structs->list[i]; return 1; } } @@ -84,12 +85,12 @@ static inline int locate_decl_type_struct(decl_structs *structs, decl_type *type static inline int locate_decl_type_union(decl_unions *unions, decl_type *type) { size_t i; - if (type->unn) { + if (type->real.unn) { return 1; } if (unions) for (i = 0; i < unions->count; ++i) { if (!strcmp(unions->list[i]->name, type->name)) { - type->unn = unions->list[i]; + type->real.unn = unions->list[i]; return 1; } } @@ -99,36 +100,51 @@ static inline int locate_decl_type_union(decl_unions *unions, decl_type *type) { static inline int locate_decl_type_enum(decl_enums *enums, decl_type *type) { size_t i; - if (type->enm) { + if (type->real.enm) { return 1; } if (enums) for (i = 0; i < enums->count; ++i) { if (!strcmp(enums->list[i]->name, type->name)) { - type->enm = enums->list[i]; + type->real.enm = enums->list[i]; return 1; } } return 0; } -static inline int validate_decl_struct(PSI_Data *data, decl_struct *s); -static inline int validate_decl_union(PSI_Data *data, decl_union *u); -static inline int validate_decl_enum(PSI_Data *data, decl_enum *e); +static inline int locate_decl_type_decl(decls *decls, decl_type *type) { + size_t i; -static inline int validate_decl_type(PSI_Data *data, decl_type *type) { - switch (type->type) { - case PSI_T_CHAR: - case PSI_T_SHORT: - case PSI_T_INT: - case PSI_T_LONG: - case PSI_T_NAME: + if (type->real.func) { + return 1; + } + if (decls) for (i = 0; i < decls->count; ++i) { + if (!strcmp(decls->list[i]->func->var->name, type->name)) { + type->real.func = decls->list[i]; + return 1; + } + } + + return 0; +} + +static inline int validate_decl_nodl(struct psi_data *data, decl *decl); +static inline int validate_decl_struct(struct psi_data *data, decl_struct *s); +static inline int validate_decl_union(struct psi_data *data, decl_union *u); +static inline int validate_decl_enum(struct psi_data *data, decl_enum *e); + +static inline int validate_decl_type(struct psi_data *data, decl_type *type, decl_arg *def) { + if (weak_decl_type(type)) { if (!locate_decl_type_alias(data->defs, type)) { return 0; } - if (type->real) { - return validate_decl_type(data, type->real); + if (type->real.def) { + return validate_decl_type(data, type->real.def->type, type->real.def); } return 1; + } + + switch (type->type) { case PSI_T_STRUCT: if (!locate_decl_type_struct(data->structs, type)) { return 0; @@ -143,27 +159,53 @@ static inline int validate_decl_type(PSI_Data *data, decl_type *type) { if (!locate_decl_type_enum(data->enums, type)) { return 0; } + break; + case PSI_T_FUNCTION: + if (!locate_decl_type_decl(data->decls, type)) { + return 0; + } + if (!validate_decl_nodl(data, type->real.func)) { + return 0; + } + break; } return 1; } -static inline int validate_decl_typedef(PSI_Data *data, decl_arg *def) { - if (!validate_decl_type(data, def->type)) { +static inline int validate_decl_typedef(struct psi_data *data, decl_arg *def) { + if (!validate_decl_type(data, def->type, def)) { + const char *pre; + + switch (def->type->type) { + case PSI_T_STRUCT: pre = "struct "; break; + case PSI_T_UNION: pre = "union "; break; + case PSI_T_ENUM: pre = "enum "; break; + default: pre = ""; break; + } data->error(data, def->token, PSI_WARNING, "Type '%s' cannot be aliased to %s'%s'", - def->type->name, def->type->type == PSI_T_STRUCT?"struct ":"", - def->var->name); + def->var->name, pre, def->type->name); return 0; } + if (def->type->type == PSI_T_VOID) { + if (def->var->pointer_level) { + def->type->type = PSI_T_POINTER; + } else { + data->error(data, def->token, PSI_WARNING, + "Type '%s' cannot be aliased to 'void'", + def->type->name); + return 0; + } + } return 1; } -static inline int validate_constant(PSI_Data *data, constant *c) { +static inline int validate_constant(struct psi_data *data, constant *c) { /* FIXME */ return 1; } -static inline int validate_decl_arg(PSI_Data *data, decl_arg *arg) { - if (!validate_decl_type(data, arg->type)) { +static inline int validate_decl_arg(struct psi_data *data, decl_arg *arg) { + if (!validate_decl_type(data, arg->type, NULL)) { data->error(data, arg->type->token, PSI_WARNING, "Cannot use '%s' as type for '%s'", arg->type->name, arg->var->name); @@ -201,32 +243,41 @@ static inline void psi_sort_struct_args(void **args, size_t count) { psi_sort_struct_arg_cmp, psi_sort_struct_arg_swp); } -static inline int validate_decl_struct_darg(PSI_Data *data, decl_arg *darg, void *current) { +static inline int validate_decl_struct_darg(struct psi_data *data, decl_arg *darg, void *current) { decl_type *real = real_decl_type(darg->type); /* pre-validate any structs/unions/enums */ switch (real->type) { case PSI_T_STRUCT: - if (current && current == real->strct) { + if (current && current == real->real.strct) { return 1; } - if (!validate_decl_struct(data, real->strct)) { + if (!locate_decl_type_struct(data->structs, real)) { + return 0; + } + if (!validate_decl_struct(data, real->real.strct)) { return 0; } break; case PSI_T_UNION: - if (current && current == real->unn) { + if (current && current == real->real.unn) { return 1; } - if (!validate_decl_union(data, real->unn)) { + if (!locate_decl_type_union(data->unions, real)) { + return 0; + } + if (!validate_decl_union(data, real->real.unn)) { return 0; } break; case PSI_T_ENUM: - if (current && current == real->enm) { + if (current && current == real->real.enm) { return 1; } - if (!validate_decl_enum(data, real->enm)) { + if (!locate_decl_type_enum(data->enums, real)) { + return 0; + } + if (!validate_decl_enum(data, real->real.enm)) { return 0; } break; @@ -250,10 +301,10 @@ static inline size_t sizeof_decl_arg(decl_arg *darg) { } else { switch (real->type) { case PSI_T_UNION: - size = real->unn->size; + size = real->real.unn->size; break; case PSI_T_STRUCT: - size = real->strct->size; + size = real->real.strct->size; break; case PSI_T_ENUM: default: @@ -307,10 +358,10 @@ static inline size_t alignof_decl_type(decl_type *t) { switch (real->type) { case PSI_T_STRUCT: - align = alignof_decl_struct(real->strct); + align = alignof_decl_struct(real->real.strct); break; case PSI_T_UNION: - align = alignof_decl_union(real->unn); + align = alignof_decl_union(real->real.unn); break; case PSI_T_ENUM: default: @@ -343,12 +394,12 @@ static inline size_t align_decl_arg(decl_arg *darg, size_t *pos, size_t *len) { return align; } -static inline int validate_decl_struct(PSI_Data *data, decl_struct *s) { +static inline int validate_decl_struct(struct psi_data *data, decl_struct *s) { size_t i, pos, len, size, align; if (!s->size && !s->args->count) { data->error(data, s->token, PSI_WARNING, - "Cannot compute size of empty struct %s", + "Cannot compute size of empty struct '%s'", s->name); return 0; } @@ -414,7 +465,7 @@ static inline int validate_decl_struct(PSI_Data *data, decl_struct *s) { return 1; } -static inline int validate_decl_union(PSI_Data *data, decl_union *u) { +static inline int validate_decl_union(struct psi_data *data, decl_union *u) { size_t i, pos, len, size = 0, align; if (!u->size && !u->args->count) { @@ -486,7 +537,7 @@ static const char * const abi_ccs[] = { "stdcall", "fastcall", }; -static inline int validate_decl_abi(PSI_Data *data, decl_abi *abi) { +static inline int validate_decl_abi(struct psi_data *data, decl_abi *abi) { size_t i; for (i = 0; i < sizeof(abi_ccs)/sizeof(char*); ++i) { @@ -496,7 +547,7 @@ static inline int validate_decl_abi(PSI_Data *data, decl_abi *abi) { } return 0; } -static inline int validate_decl_func(PSI_Data *data, void *dl, decl *decl, decl_arg *func) +static inline int validate_decl_func(struct psi_data *data, void *dl, decl *decl, decl_arg *func) { struct psi_func_redir *redir; @@ -505,9 +556,6 @@ static inline int validate_decl_func(PSI_Data *data, void *dl, decl *decl, decl_ return 0; } - if (!validate_decl_arg(data, func)) { - return 0; - } for (redir = &psi_func_redirs[0]; redir->name; ++redir) { if (!strcmp(func->var->name, redir->name)) { decl->call.sym = redir->func; @@ -526,14 +574,13 @@ static inline int validate_decl_func(PSI_Data *data, void *dl, decl *decl, decl_ } return 1; } - -static inline int validate_decl(PSI_Data *data, void *dl, decl *decl) { +static inline int validate_decl_nodl(struct psi_data *data, decl *decl) { if (!validate_decl_abi(data, decl->abi)) { data->error(data, decl->abi->token, PSI_WARNING, "Invalid calling convention: '%s'", decl->abi->token->text); return 0; } - if (!validate_decl_func(data, dl, decl, decl->func)) { + if (!validate_decl_arg(data, decl->func)) { return 0; } if (decl->args) { @@ -547,6 +594,15 @@ static inline int validate_decl(PSI_Data *data, void *dl, decl *decl) { } return 1; } +static inline int validate_decl(struct psi_data *data, void *dl, decl *decl) { + if (!validate_decl_nodl(data, decl)) { + return 0; + } + if (!validate_decl_func(data, dl, decl, decl->func)) { + return 0; + } + return 1; +} static inline decl_arg *locate_decl_var_arg(decl_var *var, decl_args *args, decl_arg *func) { size_t i; @@ -613,7 +669,7 @@ static inline decl_enum_item *locate_num_exp_enum_item(num_exp *exp, decl_enums } return NULL; } -static inline int validate_num_exp(PSI_Data *data, num_exp *exp, decl_args *dargs, decl_arg *func, decl_enum *enm) { +static inline int validate_num_exp(struct psi_data *data, num_exp *exp, decl_args *dargs, decl_arg *func, decl_enum *enm) { if (exp->operand) { switch (exp->operator) { case PSI_T_PLUS: @@ -659,7 +715,7 @@ static inline int validate_num_exp(PSI_Data *data, num_exp *exp, decl_args *darg } } -static inline int validate_decl_enum(PSI_Data *data, decl_enum *e) { +static inline int validate_decl_enum(struct psi_data *data, decl_enum *e) { size_t j; if (!e->items || !e->items->count) { @@ -693,32 +749,18 @@ static inline int validate_decl_enum(PSI_Data *data, decl_enum *e) { static inline int validate_set_value_handler(set_value *set) { switch (set->func->type) { - case PSI_T_TO_BOOL: - set->func->handler = psi_to_bool; - break; - case PSI_T_TO_INT: - set->func->handler = psi_to_int; - break; - case PSI_T_TO_FLOAT: - set->func->handler = psi_to_double; - break; - case PSI_T_TO_STRING: - set->func->handler = psi_to_string; - break; - case PSI_T_TO_ARRAY: - set->func->handler = psi_to_array; - break; - case PSI_T_TO_OBJECT: - set->func->handler = psi_to_object; - break; - case PSI_T_VOID: - set->func->handler = psi_to_void; - break; + case PSI_T_TO_BOOL: set->func->handler = psi_to_bool; break; + case PSI_T_TO_INT: set->func->handler = psi_to_int; break; + case PSI_T_TO_FLOAT: set->func->handler = psi_to_double; break; + case PSI_T_TO_STRING: set->func->handler = psi_to_string; break; + case PSI_T_TO_ARRAY: set->func->handler = psi_to_array; break; + case PSI_T_TO_OBJECT: set->func->handler = psi_to_object; break; + case PSI_T_VOID: set->func->handler = psi_to_void; break; + case PSI_T_ZVAL: set->func->handler = psi_to_zval; break; case PSI_T_ELLIPSIS: if (set->outer.set && set->outer.set->func->type == PSI_T_TO_ARRAY) { set->func->handler = psi_to_recursive; set->inner = set->outer.set->inner; - set->count = set->outer.set->count; break; } /* no break */ @@ -740,7 +782,7 @@ static inline void decl_var_arg_v(decl_args *args, va_list argp) { } } } -static inline int validate_set_value_ex(PSI_Data *data, set_value *set, decl_arg *ref, decl_args *ref_list) { +static inline int validate_set_value_ex(struct psi_data *data, set_value *set, decl_arg *ref, decl_args *ref_list) { size_t i; decl_type *ref_type; decl_var *set_var = set->vars->vars[0]; @@ -763,7 +805,7 @@ static inline int validate_set_value_ex(PSI_Data *data, set_value *set, decl_arg } ref_type = real_decl_type(ref->type); - if (set->count) { + if (set->inner && set->inner->count) { int is_to_array = (set->func->type == PSI_T_TO_ARRAY); int is_pointer_to_struct = (ref_type->type == PSI_T_STRUCT && ref->var->pointer_level); @@ -779,23 +821,23 @@ static inline int validate_set_value_ex(PSI_Data *data, set_value *set, decl_arg } } - if (ref_type->type == PSI_T_STRUCT) { + if (set->inner && ref_type->type == PSI_T_STRUCT) { /* to_array(struct, to_...) */ - if (!set->outer.set || set->outer.set->inner != set->inner) { - for (i = 0; i < set->count; ++i) { - decl_var *sub_var = set->inner[i]->vars->vars[0]; - decl_arg *sub_ref = locate_struct_member(ref_type->strct, sub_var); + if (!set->outer.set || set->outer.set->inner->vals != set->inner->vals) { + for (i = 0; i < set->inner->count; ++i) { + decl_var *sub_var = set->inner->vals[i]->vars->vars[0]; + decl_arg *sub_ref = locate_struct_member(ref_type->real.strct, sub_var); if (sub_ref) { - if (!validate_set_value_ex(data, set->inner[i], sub_ref, ref_type->strct->args)) { + if (!validate_set_value_ex(data, set->inner->vals[i], sub_ref, ref_type->real.strct->args)) { return 0; } } } } - } else if (set->count == 1) { + } else if (set->inner && set->inner->count == 1) { /* to_array(ptr, to_string(*ptr)) */ - decl_var *sub_var = set->inner[0]->vars->vars[0]; + decl_var *sub_var = set->inner->vals[0]->vars->vars[0]; decl_arg *sub_ref = locate_decl_var_arg(sub_var, ref_list, ref); if (sub_ref) { @@ -803,18 +845,18 @@ static inline int validate_set_value_ex(PSI_Data *data, set_value *set, decl_arg data->error(data, sub_var->token, E_WARNING, "Inner `set` statement casts on pointers must reference the same variable"); return 0; } - if (!validate_set_value_ex(data, set->inner[0], sub_ref, ref_list)) { + if (!validate_set_value_ex(data, set->inner->vals[0], sub_ref, ref_list)) { return 0; } } - } else if (set->count > 1) { + } else if (set->inner && set->inner->count > 1) { data->error(data, set->func->token, E_WARNING, "Inner `set` statement casts on pointers may only occur once"); return 0; } return 1; } -static inline int validate_set_value(PSI_Data *data, set_value *set, ...) { +static inline int validate_set_value(struct psi_data *data, set_value *set, ...) { va_list argp; decl_args args = {0}; int check; @@ -843,7 +885,7 @@ static inline decl *locate_impl_decl(decls *decls, return_stmt *ret) { return NULL; } -static inline int validate_impl_ret_stmt(PSI_Data *data, impl *impl) { +static inline int validate_impl_ret_stmt(struct psi_data *data, impl *impl) { return_stmt *ret; /* we must have exactly one ret stmt delcaring the native func to call */ @@ -875,12 +917,80 @@ static inline int validate_impl_ret_stmt(PSI_Data *data, impl *impl) { return 0; } - impl->decl->impl = impl; + //impl->decl->impl = impl; return 1; } -static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { +static inline impl_arg *locate_impl_var_arg(impl_var *var, impl_args *args) { + size_t i; + + for (i = 0; i < args->count; ++i) { + impl_arg *iarg = args->args[i]; + + if (!strcmp(var->name, iarg->var->name)) { + return var->arg = iarg; + } + } + + return NULL; +} + +static inline int validate_let_func(struct psi_data *data, let_func *func, impl *impl) { + if (impl->func->args) { + if (!locate_impl_var_arg(func->var, impl->func->args)) { + data->error(data, func->var->token, PSI_WARNING, + "Unknown variable '$%s' of `let` statement" + " for cast '%s' of implementation '%s'", + func->var->name, func->name, impl->func->name); + return 0; + } + } + switch (func->type) { + case PSI_T_BOOLVAL: func->handler = psi_let_boolval; break; + case PSI_T_INTVAL: func->handler = psi_let_intval; break; + case PSI_T_FLOATVAL: func->handler = psi_let_floatval; break; + case PSI_T_STRVAL: func->handler = psi_let_strval; break; + case PSI_T_STRLEN: func->handler = psi_let_strlen; break; + case PSI_T_PATHVAL: func->handler = psi_let_pathval; break; + case PSI_T_ARRVAL: func->handler = psi_let_arrval; break; + case PSI_T_OBJVAL: func->handler = psi_let_objval; break; + case PSI_T_ZVAL: func->handler = psi_let_zval; break; + EMPTY_SWITCH_DEFAULT_CASE(); + } + return 1; +} + +static inline int validate_let_callback(struct psi_data *data, decl_var *cb_var, let_callback *cb, impl *impl) { + size_t i; + decl *cb_func; + decl_type *cb_type = real_decl_type(cb_var->arg->type); + + if (!validate_let_func(data, cb->func, impl)) { + return 0; + } + + if (cb_type->type != PSI_T_FUNCTION) { + data->error(data, cb_var->token, PSI_WARNING, "Not a function: %s", cb_var->name); + return 0; + } + cb_func = cb_type->real.func; + for (i = 0; i < cb->args->count; ++i) { + if (!validate_set_value(data, cb->args->vals[i], cb_func->args->count, cb_func->args->args, 0)) { + return 0; + } + } + + if (!validate_decl_nodl(data, cb_func)) { + return 0; + } + + cb->decl = cb_func; + + return 1; +} + +static inline int validate_impl_let_stmts(struct psi_data *data, impl *impl) { size_t i, j; /* we can have multiple let stmts */ @@ -888,7 +998,6 @@ static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { for (i = 0; i < impl->stmts->let.count; ++i) { let_stmt *let = impl->stmts->let.list[i]; decl_var *let_var; - int check = 0; if (let->val && let->val->kind == PSI_LET_TMP) { let_var = let->val->data.var; @@ -931,22 +1040,13 @@ static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { return 0; } break; - case PSI_LET_FUNC: - if (impl->func->args) { - for (j = 0; j < impl->func->args->count; ++j) { - impl_arg *iarg = impl->func->args->args[j]; - - if (!strcmp(let->val->data.func->var->name, iarg->var->name)) { - let->val->data.func->arg = iarg; - check = 1; - break; - } - } + case PSI_LET_CALLBACK: + if (!validate_let_callback(data, let->var, let->val->data.callback, impl)) { + return 0; } - if (!check) { - data->error(data, let->var->token, PSI_WARNING, "Unknown value '$%s' of `let` statement" - " for variable '%s' of implementation '%s'", - let->val->data.func->var->name, let->var->name, impl->func->name); + break; + case PSI_LET_FUNC: + if (!validate_let_func(data, let->val->data.func, impl)) { return 0; } break; @@ -962,7 +1062,6 @@ static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { let_stmt *let = impl->stmts->let.list[j]; if (!strcmp(let->var->name, darg->var->name)) { - darg->let = let; check = 1; break; } @@ -979,7 +1078,7 @@ static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { return 1; } -static inline int validate_impl_set_stmts(PSI_Data *data, impl *impl) { +static inline int validate_impl_set_stmts(struct psi_data *data, impl *impl) { size_t i, j, k; /* we can have any count of set stmts; processing out vars */ /* check that set stmts reference known variables */ @@ -1063,7 +1162,7 @@ static inline decl *locate_free_decl(decls *decls, free_call *f) { return NULL; } -static inline int validate_impl_free_stmts(PSI_Data *data, impl *impl) { +static inline int validate_impl_free_stmts(struct psi_data *data, impl *impl) { size_t i, j, k, l; /* we can have any count of free stmts; freeing any out vars */ for (i = 0; i < impl->stmts->fre.count; ++i) { @@ -1115,7 +1214,7 @@ static inline int validate_impl_free_stmts(PSI_Data *data, impl *impl) { } return 1; } -static inline int validate_impl_stmts(PSI_Data *data, impl *impl) { +static inline int validate_impl_stmts(struct psi_data *data, impl *impl) { if (!impl->stmts) { data->error(data, impl->func->token, PSI_WARNING, "Missing body for implementation %s!", @@ -1140,7 +1239,7 @@ static inline int validate_impl_stmts(PSI_Data *data, impl *impl) { return 1; } -static inline int validate_impl_args(PSI_Data *data, impl *impl) { +static inline int validate_impl_args(struct psi_data *data, impl *impl) { int def = 0; size_t i; @@ -1161,7 +1260,7 @@ static inline int validate_impl_args(PSI_Data *data, impl *impl) { return 1; } -static inline int validate_impl(PSI_Data *data, impl *impl) { +static inline int validate_impl(struct psi_data *data, impl *impl) { if (!validate_impl_args(data, impl)) { return 0; } @@ -1169,9 +1268,9 @@ static inline int validate_impl(PSI_Data *data, impl *impl) { } -int PSI_ContextValidate(PSI_Context *C, PSI_Parser *P) +int psi_context_validate(struct psi_context *C, struct psi_parser *P) { - PSI_Data *D; + struct psi_data *D; void *dlopened = NULL; size_t i, count = C->count++, check_round, check_count; decl_typedefs *check_defs = P->defs; @@ -1181,7 +1280,7 @@ int PSI_ContextValidate(PSI_Context *C, PSI_Parser *P) unsigned silent = C->flags & PSI_PARSER_SILENT; C->data = realloc(C->data, C->count * sizeof(*C->data)); - D = PSI_DataExchange(&C->data[count], PSI_DATA(P)); + D = psi_data_exchange(&C->data[count], PSI_DATA(P)); #define REVALIDATE(what) do { \ if (check_round && check_ ##what) { \ @@ -1277,7 +1376,7 @@ int PSI_ContextValidate(PSI_Context *C, PSI_Parser *P) return 1; } -int PSI_ContextValidateData(PSI_Data *dest, PSI_Data *source) +int psi_context_validate_data(struct psi_data *dest, struct psi_data *source) { size_t i; int errors = 0;