diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-01-21 20:32:39 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-01-21 20:32:39 +0200 |
| commit | e8f78907830c525dccf1f4a5e6f97a15780c54ef (patch) | |
| tree | 616bf72243e22cfb034cf2fab4bb99a927db61da /src/scope.c | |
| parent | 284be00c81407735cc8ddec1f1353b867b2deffd (diff) | |
| download | ek-e8f78907830c525dccf1f4a5e6f97a15780c54ef.tar.gz ek-e8f78907830c525dccf1f4a5e6f97a15780c54ef.zip | |
add type visibility checks
+ Essentially require that each type used in a public symbol only use
types that are exported out of the file as well
Diffstat (limited to 'src/scope.c')
| -rw-r--r-- | src/scope.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/scope.c b/src/scope.c index 1eae065..4c9097f 100644 --- a/src/scope.c +++ b/src/scope.c @@ -17,12 +17,6 @@ #include <ek/scope.h> #include <ek/actualize.h> -static bool same_src_scope(struct scope *a, struct scope *b) -{ - /** @todo a bit ridiculous, is there a less hacky way? */ - return a->fctx.fbuf == b->fctx.fbuf; -} - struct scope *create_scope() { /* if I ever try making the parser multithreaded, this should be atomic. */ @@ -123,9 +117,6 @@ static bool scope_add_recurse(struct scope *scope, struct ast *node) if (!ast_flags(node, AST_FLAG_PUBLIC)) return false; - if (same_src_scope(scope, node->scope)) - return true; - return scope_flags(scope, SCOPE_PUBLIC); } @@ -459,6 +450,9 @@ void scope_add_scope(struct scope *parent, struct scope *child) bool is_exported_type(struct scope *scope, struct ast *def) { + if (scope_flags(scope, SCOPE_ROOT)) + return true; + struct ast **found = exported_find(&scope->exported_types, def); if (found) return true; @@ -471,6 +465,9 @@ bool is_exported_type(struct scope *scope, struct ast *def) bool is_exported_symbol(struct scope *scope, struct ast *def) { + if (scope_flags(scope, SCOPE_ROOT)) + return true; + struct ast **found = exported_find(&scope->exported_symbols, def); if (found) return true; @@ -483,6 +480,9 @@ bool is_exported_symbol(struct scope *scope, struct ast *def) bool is_exported_macro(struct scope *scope, struct ast *def) { + if (scope_flags(scope, SCOPE_ROOT)) + return true; + struct ast **found = exported_find(&scope->exported_macros, def); if (found) return true; |
