diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-12 18:55:46 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-12 19:06:03 +0300 |
| commit | 2157fdbaca0b80e488c4f77ad5c0d04b051175cf (patch) | |
| tree | 6a6ba7be30b2eb32219cd9aa2eb30c3bddacd5b4 /src/scope.c | |
| parent | ce6ba9e8d260e43d11518688363229755a212472 (diff) | |
| download | ek-2157fdbaca0b80e488c4f77ad5c0d04b051175cf.tar.gz ek-2157fdbaca0b80e488c4f77ad5c0d04b051175cf.zip | |
make defer work better with generic code
Diffstat (limited to 'src/scope.c')
| -rw-r--r-- | src/scope.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/scope.c b/src/scope.c index 5cd7075..f17b8ed 100644 --- a/src/scope.c +++ b/src/scope.c @@ -113,7 +113,8 @@ struct visible *create_type(struct scope *scope, char *id, struct ast *type) return n; } -struct expanded *create_expanded(struct scope *scope, struct ast *def, struct type *types, struct ast *expd) +struct expanded *create_expanded(struct scope *scope, struct ast *def, + struct type *types, struct ast *expd) { struct expanded *n = calloc(1, sizeof(struct expanded)); if (!n) @@ -257,14 +258,15 @@ int scope_add_trait(struct scope *scope, struct ast *trait) return 0; } -int scope_add_expd_struct(struct scope *scope, struct ast *def, struct type *types, struct ast *expd) +int scope_add_expd_struct(struct scope *scope, struct ast *def, + struct type *types, struct ast *expd) { assert(def->k == AST_STRUCT_DEF); assert(file_scope_find_expd_struct(scope, def, types) == NULL); create_expanded(scope, def, types, expd); if (scope->parent && - scope_flags(scope, SCOPE_FILE) && ast_flags(def, AST_FLAG_PUBLIC)) + scope_flags(scope, SCOPE_FILE) && ast_flags(def, AST_FLAG_PUBLIC)) return scope_add_expd_struct(scope->parent, def, types, expd); return 0; @@ -284,7 +286,8 @@ static struct ast *scope_find_visible(struct visible *v, char *id) return NULL; } -static struct ast *scope_find_expanded(struct expanded *e, struct ast *def, struct type *types) +static struct ast *scope_find_expanded(struct expanded *e, struct ast *def, + struct type *types) { if (!e) return NULL; @@ -411,7 +414,8 @@ struct ast *file_scope_find_var(struct scope *scope, char *id) return NULL; } -struct ast *scope_find_expd_struct(struct scope *scope, struct ast *def, struct type *types) +struct ast *scope_find_expd_struct(struct scope *scope, struct ast *def, + struct type *types) { assert(def->k == AST_STRUCT_DEF); struct ast *exists = scope_find_expanded(scope->expanded, def, types); @@ -422,7 +426,8 @@ struct ast *scope_find_expd_struct(struct scope *scope, struct ast *def, struct return exists; } -struct ast *file_scope_find_expd_struct(struct scope *scope, struct ast *def, struct type *types) +struct ast *file_scope_find_expd_struct(struct scope *scope, struct ast *def, + struct type *types) { assert(def->k == AST_STRUCT_DEF); struct ast *found = scope_find_expd_struct(scope, def, types); |
