mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Build tag to make all declarations within a file private to the package //+private
This commit is contained in:
+4
-3
@@ -3503,9 +3503,10 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ
|
|||||||
gbString sel_str = expr_to_string(selector);
|
gbString sel_str = expr_to_string(selector);
|
||||||
error(op_expr, "'%s' is not exported by '%.*s'", sel_str, LIT(import_name));
|
error(op_expr, "'%s' is not exported by '%.*s'", sel_str, LIT(import_name));
|
||||||
gb_string_free(sel_str);
|
gb_string_free(sel_str);
|
||||||
operand->mode = Addressing_Invalid;
|
// NOTE(bill): make the state valid still, even if it's "invalid"
|
||||||
operand->expr = node;
|
// operand->mode = Addressing_Invalid;
|
||||||
return nullptr;
|
// operand->expr = node;
|
||||||
|
// return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity->kind == Entity_ProcGroup) {
|
if (entity->kind == Entity_ProcGroup) {
|
||||||
|
|||||||
@@ -199,6 +199,9 @@ bool is_entity_exported(Entity *e, bool allow_builtin = false) {
|
|||||||
if (e->flags & EntityFlag_NotExported) {
|
if (e->flags & EntityFlag_NotExported) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (e->file != nullptr && e->file->is_private) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String name = e->token.string;
|
String name = e->token.string;
|
||||||
switch (name.len) {
|
switch (name.len) {
|
||||||
|
|||||||
@@ -5176,6 +5176,8 @@ bool parse_file(Parser *p, AstFile *f) {
|
|||||||
if (!parse_build_tag(tok, lc)) {
|
if (!parse_build_tag(tok, lc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (lc == "+private") {
|
||||||
|
f->is_private = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ struct AstFile {
|
|||||||
f64 time_to_tokenize; // seconds
|
f64 time_to_tokenize; // seconds
|
||||||
f64 time_to_parse; // seconds
|
f64 time_to_parse; // seconds
|
||||||
|
|
||||||
|
bool is_private;
|
||||||
bool is_test;
|
bool is_test;
|
||||||
|
|
||||||
CommentGroup *lead_comment; // Comment (block) before the decl
|
CommentGroup *lead_comment; // Comment (block) before the decl
|
||||||
|
|||||||
Reference in New Issue
Block a user