mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-12 14:21:25 -07:00
@(export) foreign import to be package scope level
This commit is contained in:
+2
-1
@@ -857,6 +857,7 @@ gb_internal Entity *init_entity_foreign_library(CheckerContext *ctx, Entity *e)
|
||||
} else {
|
||||
String name = ident->Ident.token.string;
|
||||
Entity *found = scope_lookup(ctx->scope, name);
|
||||
|
||||
if (found == nullptr) {
|
||||
if (is_blank_ident(name)) {
|
||||
// NOTE(bill): link against nothing
|
||||
@@ -864,7 +865,7 @@ gb_internal Entity *init_entity_foreign_library(CheckerContext *ctx, Entity *e)
|
||||
error(ident, "Undeclared name: %.*s", LIT(name));
|
||||
}
|
||||
} else if (found->kind != Entity_LibraryName) {
|
||||
error(ident, "'%.*s' cannot be used as a library name", LIT(name));
|
||||
error(ident, "'%.*s' cannot be used as a library name %d", LIT(name), found->kind);
|
||||
} else {
|
||||
// TODO(bill): Extra stuff to do with library names?
|
||||
*foreign_library = found;
|
||||
|
||||
+10
-1
@@ -5016,6 +5016,9 @@ gb_internal DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) {
|
||||
error(elem, "Expected a string value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
} else if (name == "export") {
|
||||
ac->is_export = true;
|
||||
return true;
|
||||
} else if (name == "force" || name == "require") {
|
||||
if (value != nullptr) {
|
||||
error(elem, "Expected no parameter for '%.*s'", LIT(name));
|
||||
@@ -5185,10 +5188,16 @@ gb_internal void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) {
|
||||
fl->fullpaths, library_name);
|
||||
e->LibraryName.decl = decl;
|
||||
add_entity_flags_from_file(ctx, e, parent_scope);
|
||||
add_entity(ctx, parent_scope, nullptr, e);
|
||||
|
||||
AttributeContext ac = {};
|
||||
check_decl_attributes(ctx, fl->attributes, foreign_import_decl_attribute, &ac);
|
||||
|
||||
if (ac.is_export) {
|
||||
add_entity(ctx, parent_scope->pkg->scope, nullptr, e);
|
||||
} else {
|
||||
add_entity(ctx, parent_scope, nullptr, e);
|
||||
}
|
||||
|
||||
if (ac.require_declaration) {
|
||||
mpsc_enqueue(&ctx->info->required_foreign_imports_through_force_queue, e);
|
||||
add_entity_use(ctx, nullptr, e);
|
||||
|
||||
Reference in New Issue
Block a user