]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve env_storage
authorfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 4 Apr 2019 10:59:01 +0000 (12:59 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 4 Apr 2019 10:59:01 +0000 (12:59 +0200)
include/env.h
src/oo/env_utils.c
src/parse/scan0.c
src/parse/scan1.c

index 8889fbf83031d50c254c4337d4be52861a6bc11a..ade845ade40480007c63afcc5e18b4ae3ac8b3d4 100644 (file)
@@ -51,7 +51,7 @@ ANEW ANN m_str tl2str(const Env, const Type_List); // in type_decl.c
 ANN m_bool compat_func(const __restrict__ Func_Def, const __restrict__ Func_Def);
 ANN Type known_type(const Env env, const Type_Decl*);
 ANN m_bool env_access(const Env env, const ae_flag flag);
-ANN void env_storage(const Env env, ae_flag* flag);
+ANN m_bool env_storage(const Env env, ae_flag flag);
 ANN void env_add_type(const Env, const Type);
 ANN Type find_type(const Env, ID_List);
 ANN m_bool already_defined(const Env env, const Symbol s, const uint pos);
index f218fdce02c18792a4408db4e3d8b6cf95bfc844..27651ba7af8b4147484292e7b3174762e7b5d963 100644 (file)
@@ -33,9 +33,9 @@ ANN m_bool env_access(const Env env, const ae_flag flag) {
   return GW_OK;
 }
 
-ANN void env_storage(const Env env, ae_flag* flag) {
-  if(env->class_def && GET(*flag, ae_flag_global))
-    *flag &= (uint)~ae_flag_global;
+ANN m_bool env_storage(const Env env, ae_flag flag) {
+  CHECK_BB(env_access(env, flag))
+  return !(env->class_def && GET(flag, ae_flag_global)) ? GW_OK :GW_ERROR;
 }
 
 ANN static Type find_typeof(const Env env, ID_List path) {
index 2da929b18f2279b619de8a6e24b7b04c3bef4162..499dfd023568fa47145e17eebc4f5e9ce3da255b 100644 (file)
@@ -70,8 +70,7 @@ ANN static m_bool scan0_stmt_type(const Env env, const Stmt_Type stmt) { GWDEBUG
 }
 
 ANN m_bool scan0_stmt_enum(const Env env, const Stmt_Enum stmt) { GWDEBUG_EXE
-  CHECK_BB(env_access(env, stmt->flag))
-  env_storage(env, &stmt->flag);
+  CHECK_BB(env_storage(env, stmt->flag))
   if(stmt->xid) {
     const Value v = nspc_lookup_value1(env->curr, stmt->xid);
     if(v)
@@ -107,8 +106,7 @@ ANN static Type union_type(const Env env, const Nspc nspc, const Symbol s, const
 }
 
 ANN static m_bool scan0_stmt_union(const Env env, const Stmt_Union stmt) { GWDEBUG_EXE
-  CHECK_BB(env_access(env, stmt->flag))
-  env_storage(env, &stmt->flag);
+  CHECK_BB(env_storage(env, stmt->flag))
   if(stmt->xid) {
     CHECK_BB(scan0_defined(env, stmt->xid, stmt->self->pos))
     const Nspc nspc = !GET_FLAG(stmt, global) ?
@@ -151,8 +149,7 @@ ANN static m_bool scan0_Stmt_List(const Env env, Stmt_List l) { GWDEBUG_EXE
 }
 
 ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def class_def) { GWDEBUG_EXE
-  CHECK_BB(env_access(env, class_def->flag))
-  env_storage(env, &class_def->flag);
+  CHECK_BB(env_storage(env, class_def->flag))
   if(GET_FLAG(class_def, global)) {
     vector_add(&env->scope->nspc_stack, (vtype)env->curr);
     env->curr = env->global_nspc;
index 8dd975be5f037ea44a0f590e6048d87d6f281789..e839bd496e915e355eeba67fba5c5e57d07f4757 100644 (file)
@@ -50,8 +50,7 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) {
 }
 
 ANN m_bool scan1_exp_decl(const Env env, Exp_Decl* decl) { GWDEBUG_EXE
-  CHECK_BB(env_access(env, decl->td->flag))
-  env_storage(env, &decl->td->flag);
+  CHECK_BB(env_storage(env, decl->td->flag))
   Var_Decl_List list = decl->list;
   ((Exp_Decl*)decl)->type = scan1_exp_decl_type(env, (Exp_Decl*)decl);
   CHECK_OB(decl->type)
@@ -268,8 +267,7 @@ ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) { GWDEBUG_EXE
 }
 
 ANN m_bool scan1_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
-  CHECK_BB(env_access(env, f->flag))
-  env_storage(env, &f->flag);
+  CHECK_BB(env_storage(env, f->flag))
   if(tmpl_list_base(f->tmpl))
     return GW_OK;
   const Func former = env->func;