Minimize Ast flags usage

This commit is contained in:
gingerBill
2020-11-16 01:42:30 +00:00
parent 939878df50
commit adf6c85fd3
2 changed files with 16 additions and 16 deletions
+8 -8
View File
@@ -3012,8 +3012,8 @@ void check_builtin_attributes(CheckerContext *ctx, Entity *e, Array<Ast *> *attr
} }
void check_collect_value_decl(CheckerContext *c, Ast *decl) { void check_collect_value_decl(CheckerContext *c, Ast *decl) {
if (decl->been_handled) return; if (decl->state_flags & StateFlag_BeenHandled) return;
decl->been_handled = true; decl->state_flags |= StateFlag_BeenHandled;
ast_node(vd, ValueDecl, decl); ast_node(vd, ValueDecl, decl);
@@ -3231,8 +3231,8 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) {
} }
void check_add_foreign_block_decl(CheckerContext *ctx, Ast *decl) { void check_add_foreign_block_decl(CheckerContext *ctx, Ast *decl) {
if (decl->been_handled) return; if (decl->state_flags & StateFlag_BeenHandled) return;
decl->been_handled = true; decl->state_flags |= StateFlag_BeenHandled;
ast_node(fb, ForeignBlockDecl, decl); ast_node(fb, ForeignBlockDecl, decl);
Ast *foreign_library = fb->foreign_library; Ast *foreign_library = fb->foreign_library;
@@ -3616,8 +3616,8 @@ Array<ImportPathItem> find_import_path(Checker *c, AstPackage *start, AstPackage
} }
#endif #endif
void check_add_import_decl(CheckerContext *ctx, Ast *decl) { void check_add_import_decl(CheckerContext *ctx, Ast *decl) {
if (decl->been_handled) return; if (decl->state_flags & StateFlag_BeenHandled) return;
decl->been_handled = true; decl->state_flags |= StateFlag_BeenHandled;
ast_node(id, ImportDecl, decl); ast_node(id, ImportDecl, decl);
Token token = id->relpath; Token token = id->relpath;
@@ -3731,8 +3731,8 @@ DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) {
} }
void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) {
if (decl->been_handled) return; if (decl->state_flags & StateFlag_BeenHandled) return;
decl->been_handled = true; decl->state_flags |= StateFlag_BeenHandled;
ast_node(fl, ForeignImportDecl, decl); ast_node(fl, ForeignImportDecl, decl);
+8 -8
View File
@@ -217,14 +217,16 @@ enum ProcCallingConvention {
ProcCC_ForeignBlockDefault = -1, ProcCC_ForeignBlockDefault = -1,
}; };
enum StateFlag { enum StateFlag : u16 {
StateFlag_bounds_check = 1<<0, StateFlag_bounds_check = 1<<0,
StateFlag_no_bounds_check = 1<<1, StateFlag_no_bounds_check = 1<<1,
StateFlag_no_deferred = 1<<5, StateFlag_no_deferred = 1<<5,
StateFlag_BeenHandled = 1<<15,
}; };
enum ViralStateFlag { enum ViralStateFlag : u16 {
ViralStateFlag_ContainsDeferredProcedure = 1<<0, ViralStateFlag_ContainsDeferredProcedure = 1<<0,
}; };
@@ -638,9 +640,8 @@ isize const ast_variant_sizes[] = {
struct AstCommonStuff { struct AstCommonStuff {
AstKind kind; AstKind kind;
u32 state_flags; u16 state_flags;
u32 viral_state_flags; u16 viral_state_flags;
bool been_handled;
AstFile * file; AstFile * file;
Scope * scope; Scope * scope;
TypeAndValue tav; TypeAndValue tav;
@@ -648,9 +649,8 @@ struct AstCommonStuff {
struct Ast { struct Ast {
AstKind kind; AstKind kind;
u32 state_flags; u16 state_flags;
u32 viral_state_flags; u16 viral_state_flags;
bool been_handled;
AstFile * file; AstFile * file;
Scope * scope; Scope * scope;
TypeAndValue tav; TypeAndValue tav;