}
static inline int validate_let_func_type(struct psi_data *data,
- struct psi_let_func *func, struct psi_impl *impl)
+ struct psi_let_func *func, struct psi_validate_scope *scope)
{
switch (func->type) {
case PSI_T_BOOLVAL:
default:
data->error(data, func->var->token, PSI_WARNING,
"Unknown `let` cast function '%s' of implementation '%s'",
- func->name, impl->func->name);
+ func->name, scope->impl->func->name);
return false;
}
}
static inline bool validate_let_func_inner(struct psi_data *data,
- struct psi_let_exp *exp, struct psi_let_func *func,
- struct psi_impl *impl)
+ struct psi_let_func *func, struct psi_validate_scope *scope)
{
+ struct psi_let_exp *exp = scope->current_let;
+
if (func->inner) {
struct psi_decl_var *let_var = psi_let_exp_get_decl_var(exp);
struct psi_decl_type *var_typ;
/* remove expr for portability with different struct members */
psi_plist_del(func->inner, --i, NULL);
psi_let_exp_free(&inner);
- } else if (!psi_let_exp_validate(data, inner, impl)) {
- return false;
+ } else {
+ scope->current_let = inner;
+ if (!psi_let_exp_validate(data, inner, scope)) {
+ scope->current_let = exp;
+ return false;
+ }
+ scope->current_let = exp;
}
}
} else if (func->type == PSI_T_ARRVAL
" reference the same variable");
return false;
}
- if (!psi_let_exp_validate(data, inner, impl)) {
+ scope->current_let = inner;
+ if (!psi_let_exp_validate(data, inner, scope)) {
+ scope->current_let = exp;
return false;
}
+ scope->current_let = exp;
} else {
data->error(data, let_var->token, PSI_WARNING,
"Inner let statement's values must refer to a structure or"
return true;
}
-bool psi_let_func_validate(struct psi_data *data, struct psi_let_exp *val,
- struct psi_let_func *func, struct psi_impl *impl)
+bool psi_let_func_validate(struct psi_data *data, struct psi_let_func *func,
+ struct psi_validate_scope *scope)
{
- if (impl->func->args) {
+ if (scope->impl->func->args) {
/* FIXME, func->var does not need to be referring to a func arg */
- psi_impl_get_arg(impl, func->var);
+ psi_impl_get_arg(scope->impl, func->var);
}
- if (!psi_impl_var_validate(data, func->var, impl, val, NULL)) {
+ if (!psi_impl_var_validate(data, func->var, scope)) {
return false;
}
- if (!validate_let_func_type(data, func, impl)) {
+ if (!validate_let_func_type(data, func, scope)) {
return false;
}
- if (!validate_let_func_inner(data, val, func, impl)) {
+ if (!validate_let_func_inner(data, func, scope)) {
return false;
}
return 1;
struct psi_call_frame *frame);
void exec_let_func_arrval_seq(struct psi_let_func *func,
- struct psi_decl_arg *darg, struct psi_decl_type *darg_type,
+ struct psi_decl_arg *darg,
struct psi_call_frame_argument *frame_arg,
struct psi_let_exp *inner_let_exp, void *container,
struct psi_call_frame *frame)
{
- zval *zval_ptr;
+ zval *zval_ptr = NULL;
psi_marshal_let let_fn;
size_t i = 0, size;
struct psi_decl_var *dvar;
impl_val val = {0}, *ptr, *sub;
if (let_fn) {
- ptr = let_fn(&val, darg_type, 0, NULL, zval_ptr, &temp);
+ ptr = let_fn(&val, darg, 0, NULL, zval_ptr, &temp);
if (temp) {
psi_call_frame_push_auto(frame, temp);
}
{
void *container = NULL;
struct psi_call_frame_argument *frame_arg;
- struct psi_decl_type *darg_type;
struct psi_plist *darg_members;
- darg_members = psi_decl_type_get_args(darg->type, &darg_type);
+ darg_members = psi_decl_type_get_args(darg->type, NULL);
frame_arg = psi_call_frame_get_argument(frame, func->var->fqn);
if (frame_arg->zval_ptr && Z_TYPE_P(frame_arg->zval_ptr) != IS_ARRAY) {
container = ecalloc(arcount + 1, psi_decl_var_get_size(inner->var));
inner->var->pointer_level -= inner->is_reference;
- exec_let_func_arrval_seq(func, darg, darg_type, frame_arg, inner,
- container, frame);
+ exec_let_func_arrval_seq(func, darg, frame_arg, inner, container, frame);
} else {
assert(0);
}
assert(iarg);
- frame_sym->ival_ptr = let_fn(&frame_sym->temp_val,
- psi_decl_type_get_real(darg->type),
+ frame_sym->ival_ptr = let_fn(&frame_sym->temp_val, darg,
iarg->spec ? iarg->spec->type->type : 0, iarg->ival_ptr,
iarg->zval_ptr, &temp);
if (temp) {