aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-02-23 20:40:48 +0000
committergingerBill <bill@gingerbill.org>2021-02-23 20:40:48 +0000
commit8f9111e5526d7bf4c58cfd127d45b1d229a3d9d3 (patch)
treeec89180590e1505b2d5e59a0481be5dfe5d37058 /src
parent731e6ca3a6eda8039b36a81b5ac3683b89a487d4 (diff)
Build tag to make all declarations within a file private to the package `//+private`
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp7
-rw-r--r--src/entity.cpp3
-rw-r--r--src/parser.cpp2
-rw-r--r--src/parser.hpp1
4 files changed, 10 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index e77efc023..656ac8838 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -3503,9 +3503,10 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ
gbString sel_str = expr_to_string(selector);
error(op_expr, "'%s' is not exported by '%.*s'", sel_str, LIT(import_name));
gb_string_free(sel_str);
- operand->mode = Addressing_Invalid;
- operand->expr = node;
- return nullptr;
+ // NOTE(bill): make the state valid still, even if it's "invalid"
+ // operand->mode = Addressing_Invalid;
+ // operand->expr = node;
+ // return nullptr;
}
if (entity->kind == Entity_ProcGroup) {
diff --git a/src/entity.cpp b/src/entity.cpp
index 0aece39c3..1712c7f98 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -199,6 +199,9 @@ bool is_entity_exported(Entity *e, bool allow_builtin = false) {
if (e->flags & EntityFlag_NotExported) {
return false;
}
+ if (e->file != nullptr && e->file->is_private) {
+ return false;
+ }
String name = e->token.string;
switch (name.len) {
diff --git a/src/parser.cpp b/src/parser.cpp
index a60c5033d..9e5055f73 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -5176,6 +5176,8 @@ bool parse_file(Parser *p, AstFile *f) {
if (!parse_build_tag(tok, lc)) {
return false;
}
+ } else if (lc == "+private") {
+ f->is_private = true;
}
}
}
diff --git a/src/parser.hpp b/src/parser.hpp
index 1efb23416..abc4cc625 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -109,6 +109,7 @@ struct AstFile {
f64 time_to_tokenize; // seconds
f64 time_to_parse; // seconds
+ bool is_private;
bool is_test;
CommentGroup *lead_comment; // Comment (block) before the decl