mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-18 11:52:22 -07:00
Add @(entry_point_only) for procedures
This commit is contained in:
@@ -908,6 +908,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
||||
break;
|
||||
}
|
||||
|
||||
e->Procedure.entry_point_only = ac.entry_point_only;
|
||||
e->Procedure.is_export = ac.is_export;
|
||||
e->deprecated_message = ac.deprecated_message;
|
||||
e->warning_message = ac.warning_message;
|
||||
|
||||
@@ -7195,6 +7195,14 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
|
||||
}
|
||||
}
|
||||
add_entity_use(c, operand->expr, initial_entity);
|
||||
|
||||
if (initial_entity->Procedure.entry_point_only) {
|
||||
if (c->curr_proc_decl && c->curr_proc_decl->entity == c->info->entry_point) {
|
||||
// Okay
|
||||
} else {
|
||||
error(operand->expr, "Procedures with the attribute '@(entry_point_only)' can only be called directly from the user-level entry point procedure");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (operand->mode != Addressing_ProcGroup) {
|
||||
|
||||
@@ -3413,6 +3413,9 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
|
||||
error(elem, "Expected a string value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
} else if (name == "entry_point_only") {
|
||||
ac->entry_point_only = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ struct AttributeContext {
|
||||
bool init : 1;
|
||||
bool fini : 1;
|
||||
bool set_cold : 1;
|
||||
bool entry_point_only : 1;
|
||||
u32 optimization_mode; // ProcedureOptimizationMode
|
||||
i64 foreign_import_priority_index;
|
||||
String extra_linker_flags;
|
||||
|
||||
@@ -250,6 +250,7 @@ struct Entity {
|
||||
bool is_export : 1;
|
||||
bool generated_from_polymorphic : 1;
|
||||
bool target_feature_disabled : 1;
|
||||
bool entry_point_only : 1;
|
||||
String target_feature;
|
||||
} Procedure;
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user