From fa9f6aadfe5e8165bc096cc592ed443233529bfe Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 29 Apr 2022 23:37:52 +0200 Subject: [PATCH] :art: mark arg value --- include/env/value.h | 3 ++- src/parse/check.c | 2 +- src/parse/scan2.c | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/env/value.h b/include/env/value.h index dcae4d85..67d26942 100644 --- a/include/env/value.h +++ b/include/env/value.h @@ -19,7 +19,8 @@ enum vflag { vflag_member = 1 << 6, vflag_inner = 1 << 7, // value is in a scope vflag_release = 1 << 8, - vflag_assigned = 1 << 9 + vflag_assigned = 1 << 9, + vflag_arg = 1 << 10 // vflag_used = 1 << 3 } __attribute__((packed)); diff --git a/src/parse/check.c b/src/parse/check.c index d1338583..814f18ca 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -306,7 +306,7 @@ ANN static Value check_non_res_value(const Env env, const Symbol *data) { return v; } else if (SAFE_FLAG(env->class_def, global) || (env->func && GET_FLAG(env->func->def->base, global))) { - if (!value || !is_value_global(env, value)) + if (!value || !(is_value_global(env, value) || vflag(value, vflag_arg))) ERR_O(prim_pos(data), _("non-global variable '%s' used from global function/class."), s_name(var)) diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 6ce4a975..e45c28a2 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -49,14 +49,13 @@ ANN m_bool scan2_exp_decl(const Env env, const Exp_Decl *decl) { ANN static m_bool scan2_args(const Func_Def f) { Arg_List args = f->base->args; - const bool global = GET_FLAG(f->base, global); for(uint32_t i = 0; i < args->len; i++) { Arg *arg = mp_vector_at(args, Arg, i); const Value v = arg->var_decl.value; v->from->offset = f->stack_depth; - //f->stack_depth += v->type->size; + // when can there be no type? f->stack_depth += v->type ? v->type->size : SZ_INT; - if (global) SET_FLAG(v, global); + set_vflag(v, vflag_arg); } return GW_OK; } -- 2.43.0