mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add //+private file to complement //+private (//+private package)
This commit is contained in:
+6
-3
@@ -3467,9 +3467,12 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) {
|
|||||||
|
|
||||||
if (entity_visibility_kind == EntityVisiblity_Public &&
|
if (entity_visibility_kind == EntityVisiblity_Public &&
|
||||||
(c->scope->flags&ScopeFlag_File) &&
|
(c->scope->flags&ScopeFlag_File) &&
|
||||||
c->scope->file &&
|
c->scope->file) {
|
||||||
(c->scope->file->flags & AstFile_IsPrivate)) {
|
if (c->scope->file->flags & AstFile_IsPrivatePkg) {
|
||||||
entity_visibility_kind = EntityVisiblity_PrivateToPackage;
|
entity_visibility_kind = EntityVisiblity_PrivateToPackage;
|
||||||
|
} else if (c->scope->file->flags & AstFile_IsPrivateFile) {
|
||||||
|
entity_visibility_kind = EntityVisiblity_PrivateToFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity_visibility_kind != EntityVisiblity_Public && !(c->scope->flags&ScopeFlag_File)) {
|
if (entity_visibility_kind != EntityVisiblity_Public && !(c->scope->flags&ScopeFlag_File)) {
|
||||||
|
|||||||
+1
-1
@@ -245,7 +245,7 @@ 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->flags & AstFile_IsPrivate) != 0) {
|
if (e->file != nullptr && (e->file->flags & (AstFile_IsPrivatePkg|AstFile_IsPrivateFile)) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -5535,8 +5535,16 @@ 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") {
|
} else if (string_starts_with(lc, str_lit("+private"))) {
|
||||||
f->flags |= AstFile_IsPrivate;
|
f->flags |= AstFile_IsPrivatePkg;
|
||||||
|
String command = string_trim_starts_with(lc, str_lit("+private "));
|
||||||
|
if (lc == "+private") {
|
||||||
|
f->flags |= AstFile_IsPrivatePkg;
|
||||||
|
} else if (command == "package") {
|
||||||
|
f->flags |= AstFile_IsPrivatePkg;
|
||||||
|
} else if (command == "file") {
|
||||||
|
f->flags |= AstFile_IsPrivateFile;
|
||||||
|
}
|
||||||
} else if (lc == "+lazy") {
|
} else if (lc == "+lazy") {
|
||||||
if (build_context.ignore_lazy) {
|
if (build_context.ignore_lazy) {
|
||||||
// Ignore
|
// Ignore
|
||||||
|
|||||||
+5
-3
@@ -78,9 +78,11 @@ struct ImportedFile {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum AstFileFlag : u32 {
|
enum AstFileFlag : u32 {
|
||||||
AstFile_IsPrivate = 1<<0,
|
AstFile_IsPrivatePkg = 1<<0,
|
||||||
AstFile_IsTest = 1<<1,
|
AstFile_IsPrivateFile = 1<<1,
|
||||||
AstFile_IsLazy = 1<<2,
|
|
||||||
|
AstFile_IsTest = 1<<3,
|
||||||
|
AstFile_IsLazy = 1<<4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AstDelayQueueKind {
|
enum AstDelayQueueKind {
|
||||||
|
|||||||
+10
-2
@@ -195,8 +195,6 @@ template <isize N> bool operator > (String const &a, char const (&b)[N]) { retu
|
|||||||
template <isize N> bool operator <= (String const &a, char const (&b)[N]) { return str_le(a, make_string(cast(u8 *)b, N-1)); }
|
template <isize N> bool operator <= (String const &a, char const (&b)[N]) { return str_le(a, make_string(cast(u8 *)b, N-1)); }
|
||||||
template <isize N> bool operator >= (String const &a, char const (&b)[N]) { return str_ge(a, make_string(cast(u8 *)b, N-1)); }
|
template <isize N> bool operator >= (String const &a, char const (&b)[N]) { return str_ge(a, make_string(cast(u8 *)b, N-1)); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gb_inline bool string_starts_with(String const &s, String const &prefix) {
|
gb_inline bool string_starts_with(String const &s, String const &prefix) {
|
||||||
if (prefix.len > s.len) {
|
if (prefix.len > s.len) {
|
||||||
return false;
|
return false;
|
||||||
@@ -230,6 +228,16 @@ gb_inline bool string_ends_with(String const &s, u8 suffix) {
|
|||||||
return s[s.len-1] == suffix;
|
return s[s.len-1] == suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gb_inline String string_trim_starts_with(String const &s, String const &prefix) {
|
||||||
|
if (string_starts_with(s, prefix)) {
|
||||||
|
return substring(s, prefix.len, s.len);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gb_inline isize string_extension_position(String const &str) {
|
gb_inline isize string_extension_position(String const &str) {
|
||||||
isize dot_pos = -1;
|
isize dot_pos = -1;
|
||||||
isize i = str.len;
|
isize i = str.len;
|
||||||
|
|||||||
Reference in New Issue
Block a user