diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-08-30 11:34:50 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-08-30 11:34:50 +0900 |
| commit | 6488032643944c0ca09a1d33689ccd93ea37f7af (patch) | |
| tree | 02978bf8dc3be65f215513bb3ab4f62113038e12 | |
| parent | 9109277a574a424ff666d27d61156786bc380505 (diff) | |
| download | ducc-6488032643944c0ca09a1d33689ccd93ea37f7af.tar.gz ducc-6488032643944c0ca09a1d33689ccd93ea37f7af.tar.zst ducc-6488032643944c0ca09a1d33689ccd93ea37f7af.zip | |
refactor: define enum StorageClass
| -rw-r--r-- | src/ast.h | 14 | ||||
| -rw-r--r-- | src/parse.c | 6 |
2 files changed, 17 insertions, 3 deletions
@@ -3,6 +3,18 @@ #include "std.h" +enum StorageClass { + StorageClass_unspecified, + StorageClass_auto, + StorageClass_constexpr, + StorageClass_extern, + StorageClass_register, + StorageClass_static, + StorageClass_thread_local, + StorageClass_typedef, +}; +typedef enum StorageClass StorageClass; + enum TypeKind { TypeKind_unknown, @@ -32,11 +44,11 @@ typedef struct TypeRef TypeRef; struct Type { TypeKind kind; + StorageClass storage_class; // Check `base` instead of `kind` to test if the type is an array or a pointer. struct Type* base; int array_size; TypeRef ref; - BOOL is_static; }; typedef struct Type Type; diff --git a/src/parse.c b/src/parse.c index fe623a5..bafb156 100644 --- a/src/parse.c +++ b/src/parse.c @@ -589,7 +589,9 @@ static Type* parse_type(Parser* p) { } ty = type_new_ptr(ty); } - ty->is_static = has_static; + if (has_static) { + ty->storage_class = StorageClass_static; + } return ty; } @@ -1265,7 +1267,7 @@ static AstNode* parse_func_decl_or_def(Parser* p) { func->node_stack_size = p->lvars.data[p->lvars.len - 1].stack_offset + type_sizeof(p->lvars.data[p->lvars.len - 1].ty); } - func->node_function_is_static = ty->is_static; + func->node_function_is_static = ty->storage_class == StorageClass_static; return func; } |
