mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-07 19:14:19 +00:00
Even more gb_internal everywhere
This commit is contained in:
@@ -20,7 +20,7 @@ struct ExprInfo {
|
||||
ExactValue value;
|
||||
};
|
||||
|
||||
gb_inline ExprInfo *make_expr_info(AddressingMode mode, Type *type, ExactValue const &value, bool is_lhs) {
|
||||
gb_internal gb_inline ExprInfo *make_expr_info(AddressingMode mode, Type *type, ExactValue const &value, bool is_lhs) {
|
||||
ExprInfo *ei = gb_alloc_item(permanent_allocator(), ExprInfo);
|
||||
ei->mode = mode;
|
||||
ei->type = type;
|
||||
@@ -130,7 +130,7 @@ struct AttributeContext {
|
||||
String enable_target_feature; // will be enabled for the procedure only
|
||||
};
|
||||
|
||||
AttributeContext make_attribute_context(String link_prefix) {
|
||||
gb_internal gb_inline AttributeContext make_attribute_context(String link_prefix) {
|
||||
AttributeContext ac = {};
|
||||
ac.link_prefix = link_prefix;
|
||||
return ac;
|
||||
@@ -139,7 +139,7 @@ AttributeContext make_attribute_context(String link_prefix) {
|
||||
#define DECL_ATTRIBUTE_PROC(_name) bool _name(CheckerContext *c, Ast *elem, String name, Ast *value, AttributeContext *ac)
|
||||
typedef DECL_ATTRIBUTE_PROC(DeclAttributeProc);
|
||||
|
||||
void check_decl_attributes(CheckerContext *c, Array<Ast *> const &attributes, DeclAttributeProc *proc, AttributeContext *ac);
|
||||
gb_internal void check_decl_attributes(CheckerContext *c, Array<Ast *> const &attributes, DeclAttributeProc *proc, AttributeContext *ac);
|
||||
|
||||
|
||||
// DeclInfo is used to store information of certain declarations to allow for "any order" usage
|
||||
@@ -443,59 +443,59 @@ gb_global AstPackage *config_pkg = nullptr;
|
||||
|
||||
|
||||
// CheckerInfo API
|
||||
TypeAndValue type_and_value_of_expr (Ast *expr);
|
||||
Type * type_of_expr (Ast *expr);
|
||||
Entity * implicit_entity_of_node(Ast *clause);
|
||||
DeclInfo * decl_info_of_ident (Ast *ident);
|
||||
DeclInfo * decl_info_of_entity (Entity * e);
|
||||
AstFile * ast_file_of_filename (CheckerInfo *i, String filename);
|
||||
gb_internal TypeAndValue type_and_value_of_expr (Ast *expr);
|
||||
gb_internal Type * type_of_expr (Ast *expr);
|
||||
gb_internal Entity * implicit_entity_of_node(Ast *clause);
|
||||
gb_internal DeclInfo * decl_info_of_ident (Ast *ident);
|
||||
gb_internal DeclInfo * decl_info_of_entity (Entity * e);
|
||||
gb_internal AstFile * ast_file_of_filename (CheckerInfo *i, String filename);
|
||||
// IMPORTANT: Only to use once checking is done
|
||||
isize type_info_index (CheckerInfo *i, Type *type, bool error_on_failure);
|
||||
gb_internal isize type_info_index (CheckerInfo *i, Type *type, bool error_on_failure);
|
||||
|
||||
// Will return nullptr if not found
|
||||
Entity *entity_of_node(Ast *expr);
|
||||
gb_internal Entity *entity_of_node(Ast *expr);
|
||||
|
||||
|
||||
Entity *scope_lookup_current(Scope *s, String const &name);
|
||||
Entity *scope_lookup (Scope *s, String const &name);
|
||||
void scope_lookup_parent (Scope *s, String const &name, Scope **scope_, Entity **entity_);
|
||||
Entity *scope_insert (Scope *s, Entity *entity, bool use_mutex=true);
|
||||
gb_internal Entity *scope_lookup_current(Scope *s, String const &name);
|
||||
gb_internal Entity *scope_lookup (Scope *s, String const &name);
|
||||
gb_internal void scope_lookup_parent (Scope *s, String const &name, Scope **scope_, Entity **entity_);
|
||||
gb_internal Entity *scope_insert (Scope *s, Entity *entity, bool use_mutex=true);
|
||||
|
||||
|
||||
void add_type_and_value (CheckerInfo *i, Ast *expression, AddressingMode mode, Type *type, ExactValue value);
|
||||
ExprInfo *check_get_expr_info (CheckerContext *c, Ast *expr);
|
||||
void add_untyped (CheckerContext *c, Ast *expression, AddressingMode mode, Type *basic_type, ExactValue value);
|
||||
void add_entity_use (CheckerContext *c, Ast *identifier, Entity *entity);
|
||||
void add_implicit_entity (CheckerContext *c, Ast *node, Entity *e);
|
||||
void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported=true);
|
||||
void add_type_info_type (CheckerContext *c, Type *t);
|
||||
gb_internal void add_type_and_value (CheckerInfo *i, Ast *expression, AddressingMode mode, Type *type, ExactValue value);
|
||||
gb_internal ExprInfo *check_get_expr_info (CheckerContext *c, Ast *expr);
|
||||
gb_internal void add_untyped (CheckerContext *c, Ast *expression, AddressingMode mode, Type *basic_type, ExactValue value);
|
||||
gb_internal void add_entity_use (CheckerContext *c, Ast *identifier, Entity *entity);
|
||||
gb_internal void add_implicit_entity (CheckerContext *c, Ast *node, Entity *e);
|
||||
gb_internal void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported=true);
|
||||
gb_internal void add_type_info_type (CheckerContext *c, Type *t);
|
||||
|
||||
void check_add_import_decl(CheckerContext *c, Ast *decl);
|
||||
void check_add_foreign_import_decl(CheckerContext *c, Ast *decl);
|
||||
gb_internal void check_add_import_decl(CheckerContext *c, Ast *decl);
|
||||
gb_internal void check_add_foreign_import_decl(CheckerContext *c, Ast *decl);
|
||||
|
||||
|
||||
void check_entity_decl(CheckerContext *c, Entity *e, DeclInfo *d, Type *named_type);
|
||||
void check_const_decl(CheckerContext *c, Entity *e, Ast *type_expr, Ast *init_expr, Type *named_type);
|
||||
void check_type_decl(CheckerContext *c, Entity *e, Ast *type_expr, Type *def);
|
||||
gb_internal void check_entity_decl(CheckerContext *c, Entity *e, DeclInfo *d, Type *named_type);
|
||||
gb_internal void check_const_decl(CheckerContext *c, Entity *e, Ast *type_expr, Ast *init_expr, Type *named_type);
|
||||
gb_internal void check_type_decl(CheckerContext *c, Entity *e, Ast *type_expr, Type *def);
|
||||
|
||||
bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global = false);
|
||||
void check_collect_entities(CheckerContext *c, Slice<Ast *> const &nodes);
|
||||
void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws);
|
||||
void check_delayed_file_import_entity(CheckerContext *c, Ast *decl);
|
||||
gb_internal bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global = false);
|
||||
gb_internal void check_collect_entities(CheckerContext *c, Slice<Ast *> const &nodes);
|
||||
gb_internal void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws);
|
||||
gb_internal void check_delayed_file_import_entity(CheckerContext *c, Ast *decl);
|
||||
|
||||
CheckerTypePath *new_checker_type_path();
|
||||
void destroy_checker_type_path(CheckerTypePath *tp);
|
||||
gb_internal CheckerTypePath *new_checker_type_path();
|
||||
gb_internal void destroy_checker_type_path(CheckerTypePath *tp);
|
||||
|
||||
void check_type_path_push(CheckerContext *c, Entity *e);
|
||||
Entity *check_type_path_pop (CheckerContext *c);
|
||||
gb_internal void check_type_path_push(CheckerContext *c, Entity *e);
|
||||
gb_internal Entity *check_type_path_pop (CheckerContext *c);
|
||||
|
||||
CheckerPolyPath *new_checker_poly_path();
|
||||
void destroy_checker_poly_path(CheckerPolyPath *);
|
||||
gb_internal CheckerPolyPath *new_checker_poly_path();
|
||||
gb_internal void destroy_checker_poly_path(CheckerPolyPath *);
|
||||
|
||||
void check_poly_path_push(CheckerContext *c, Type *t);
|
||||
Type *check_poly_path_pop (CheckerContext *c);
|
||||
gb_internal void check_poly_path_push(CheckerContext *c, Type *t);
|
||||
gb_internal Type *check_poly_path_pop (CheckerContext *c);
|
||||
|
||||
void init_core_context(Checker *c);
|
||||
void init_mem_allocator(Checker *c);
|
||||
gb_internal void init_core_context(Checker *c);
|
||||
gb_internal void init_mem_allocator(Checker *c);
|
||||
|
||||
void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped);
|
||||
gb_internal void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped);
|
||||
|
||||
@@ -26,7 +26,7 @@ enum EntityKind {
|
||||
Entity_Count,
|
||||
};
|
||||
|
||||
String const entity_strings[] = {
|
||||
gb_global String const entity_strings[] = {
|
||||
#define ENTITY_KIND(k) {cast(u8 *)#k, gb_size_of(#k)-1},
|
||||
ENTITY_KINDS
|
||||
#undef ENTITY_KIND
|
||||
@@ -116,7 +116,7 @@ struct ParameterValue {
|
||||
};
|
||||
};
|
||||
|
||||
bool has_parameter_value(ParameterValue const ¶m_value) {
|
||||
gb_internal gb_inline bool has_parameter_value(ParameterValue const ¶m_value) {
|
||||
if (param_value.kind != ParameterValue_Invalid) {
|
||||
return true;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ struct TypeNameObjCMetadata {
|
||||
Array<TypeNameObjCMetadataEntry> value_entries;
|
||||
};
|
||||
|
||||
TypeNameObjCMetadata *create_type_name_obj_c_metadata() {
|
||||
gb_internal TypeNameObjCMetadata *create_type_name_obj_c_metadata() {
|
||||
TypeNameObjCMetadata *md = gb_alloc_item(permanent_allocator(), TypeNameObjCMetadata);
|
||||
md->mutex = gb_alloc_item(permanent_allocator(), BlockingMutex);
|
||||
mutex_init(md->mutex);
|
||||
@@ -266,7 +266,7 @@ struct Entity {
|
||||
};
|
||||
};
|
||||
|
||||
bool is_entity_kind_exported(EntityKind kind, bool allow_builtin = false) {
|
||||
gb_internal bool is_entity_kind_exported(EntityKind kind, bool allow_builtin = false) {
|
||||
switch (kind) {
|
||||
case Entity_Builtin:
|
||||
return allow_builtin;
|
||||
@@ -278,7 +278,7 @@ bool is_entity_kind_exported(EntityKind kind, bool allow_builtin = false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_entity_exported(Entity *e, bool allow_builtin = false) {
|
||||
gb_internal bool is_entity_exported(Entity *e, bool allow_builtin = false) {
|
||||
// TODO(bill): Determine the actual exportation rules for imports of entities
|
||||
GB_ASSERT(e != nullptr);
|
||||
if (!is_entity_kind_exported(e->kind, allow_builtin)) {
|
||||
@@ -300,7 +300,7 @@ bool is_entity_exported(Entity *e, bool allow_builtin = false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool entity_has_deferred_procedure(Entity *e) {
|
||||
gb_internal bool entity_has_deferred_procedure(Entity *e) {
|
||||
GB_ASSERT(e != nullptr);
|
||||
if (e->kind == Entity_Procedure) {
|
||||
return e->Procedure.deferred_procedure.entity != nullptr;
|
||||
@@ -311,7 +311,7 @@ bool entity_has_deferred_procedure(Entity *e) {
|
||||
|
||||
gb_global std::atomic<u64> global_entity_id;
|
||||
|
||||
Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) {
|
||||
gb_internal Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) {
|
||||
gbAllocator a = permanent_allocator();
|
||||
Entity *entity = gb_alloc_item(a, Entity);
|
||||
entity->kind = kind;
|
||||
@@ -323,13 +323,13 @@ Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) {
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_variable(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) {
|
||||
gb_internal Entity *alloc_entity_variable(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) {
|
||||
Entity *entity = alloc_entity(Entity_Variable, scope, token, type);
|
||||
entity->state = state;
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast *using_expr) {
|
||||
gb_internal Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast *using_expr) {
|
||||
GB_ASSERT(parent != nullptr);
|
||||
token.pos = parent->token.pos;
|
||||
Entity *entity = alloc_entity(Entity_Variable, parent->scope, token, type);
|
||||
@@ -343,19 +343,19 @@ Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast
|
||||
}
|
||||
|
||||
|
||||
Entity *alloc_entity_constant(Scope *scope, Token token, Type *type, ExactValue value) {
|
||||
gb_internal Entity *alloc_entity_constant(Scope *scope, Token token, Type *type, ExactValue value) {
|
||||
Entity *entity = alloc_entity(Entity_Constant, scope, token, type);
|
||||
entity->Constant.value = value;
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_type_name(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) {
|
||||
gb_internal Entity *alloc_entity_type_name(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) {
|
||||
Entity *entity = alloc_entity(Entity_TypeName, scope, token, type);
|
||||
entity->state = state;
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using, bool is_value) {
|
||||
gb_internal Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using, bool is_value) {
|
||||
Entity *entity = alloc_entity_variable(scope, token, type);
|
||||
entity->flags |= EntityFlag_Used;
|
||||
entity->flags |= EntityFlag_Param;
|
||||
@@ -366,7 +366,7 @@ Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using,
|
||||
}
|
||||
|
||||
|
||||
Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactValue value, bool poly_const) {
|
||||
gb_internal Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactValue value, bool poly_const) {
|
||||
Entity *entity = alloc_entity_constant(scope, token, type, value);
|
||||
entity->flags |= EntityFlag_Used;
|
||||
if (poly_const) entity->flags |= EntityFlag_PolyConst;
|
||||
@@ -375,7 +375,7 @@ Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactVal
|
||||
}
|
||||
|
||||
|
||||
Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using, i32 field_index, EntityState state = EntityState_Unresolved) {
|
||||
gb_internal Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using, i32 field_index, EntityState state = EntityState_Unresolved) {
|
||||
Entity *entity = alloc_entity_variable(scope, token, type);
|
||||
entity->Variable.field_index = field_index;
|
||||
if (is_using) entity->flags |= EntityFlag_Using;
|
||||
@@ -384,7 +384,7 @@ Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using,
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field_index) {
|
||||
gb_internal Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field_index) {
|
||||
Entity *entity = alloc_entity_variable(scope, token, type);
|
||||
entity->Variable.field_index = field_index;
|
||||
entity->flags |= EntityFlag_Field;
|
||||
@@ -393,26 +393,26 @@ Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_procedure(Scope *scope, Token token, Type *signature_type, u64 tags) {
|
||||
gb_internal Entity *alloc_entity_procedure(Scope *scope, Token token, Type *signature_type, u64 tags) {
|
||||
Entity *entity = alloc_entity(Entity_Procedure, scope, token, signature_type);
|
||||
entity->Procedure.tags = tags;
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_proc_group(Scope *scope, Token token, Type *type) {
|
||||
gb_internal Entity *alloc_entity_proc_group(Scope *scope, Token token, Type *type) {
|
||||
Entity *entity = alloc_entity(Entity_ProcGroup, scope, token, type);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
Entity *alloc_entity_builtin(Scope *scope, Token token, Type *type, i32 id) {
|
||||
gb_internal Entity *alloc_entity_builtin(Scope *scope, Token token, Type *type, i32 id) {
|
||||
Entity *entity = alloc_entity(Entity_Builtin, scope, token, type);
|
||||
entity->Builtin.id = id;
|
||||
entity->state = EntityState_Resolved;
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type,
|
||||
gb_internal Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type,
|
||||
String path, String name, Scope *import_scope) {
|
||||
Entity *entity = alloc_entity(Entity_ImportName, scope, token, type);
|
||||
entity->ImportName.path = path;
|
||||
@@ -422,7 +422,7 @@ Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type,
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type,
|
||||
gb_internal Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type,
|
||||
Slice<String> paths, String name) {
|
||||
Entity *entity = alloc_entity(Entity_LibraryName, scope, token, type);
|
||||
entity->LibraryName.paths = paths;
|
||||
@@ -435,12 +435,12 @@ Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type,
|
||||
|
||||
|
||||
|
||||
Entity *alloc_entity_nil(String name, Type *type) {
|
||||
gb_internal Entity *alloc_entity_nil(String name, Type *type) {
|
||||
Entity *entity = alloc_entity(Entity_Nil, nullptr, make_token_ident(name), type);
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_label(Scope *scope, Token token, Type *type, Ast *node, Ast *parent) {
|
||||
gb_internal Entity *alloc_entity_label(Scope *scope, Token token, Type *type, Ast *node, Ast *parent) {
|
||||
Entity *entity = alloc_entity(Entity_Label, scope, token, type);
|
||||
entity->Label.node = node;
|
||||
entity->Label.parent = parent;
|
||||
@@ -448,15 +448,15 @@ Entity *alloc_entity_label(Scope *scope, Token token, Type *type, Ast *node, Ast
|
||||
return entity;
|
||||
}
|
||||
|
||||
Entity *alloc_entity_dummy_variable(Scope *scope, Token token) {
|
||||
gb_internal Entity *alloc_entity_dummy_variable(Scope *scope, Token token) {
|
||||
token.string = str_lit("_");
|
||||
return alloc_entity_variable(scope, token, nullptr);
|
||||
}
|
||||
|
||||
|
||||
Entity *entity_from_expr(Ast *expr);
|
||||
gb_internal Entity *entity_from_expr(Ast *expr);
|
||||
|
||||
Entity *strip_entity_wrapping(Entity *e) {
|
||||
gb_internal Entity *strip_entity_wrapping(Entity *e) {
|
||||
if (e == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ Entity *strip_entity_wrapping(Entity *e) {
|
||||
return e;
|
||||
}
|
||||
|
||||
Entity *strip_entity_wrapping(Ast *expr) {
|
||||
gb_internal Entity *strip_entity_wrapping(Ast *expr) {
|
||||
Entity *e = entity_from_expr(expr);
|
||||
return strip_entity_wrapping(e);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ struct Ast;
|
||||
struct HashKey;
|
||||
struct Type;
|
||||
struct Entity;
|
||||
bool are_types_identical(Type *x, Type *y);
|
||||
gb_internal bool are_types_identical(Type *x, Type *y);
|
||||
|
||||
struct Complex128 {
|
||||
f64 real, imag;
|
||||
@@ -969,10 +969,10 @@ gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y)
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity *strip_entity_wrapping(Ast *expr);
|
||||
Entity *strip_entity_wrapping(Entity *e);
|
||||
gb_internal Entity *strip_entity_wrapping(Ast *expr);
|
||||
gb_internal Entity *strip_entity_wrapping(Entity *e);
|
||||
|
||||
gbString write_expr_to_string(gbString str, Ast *node, bool shorthand);
|
||||
gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthand);
|
||||
|
||||
gb_internal gbString write_exact_value_to_string(gbString str, ExactValue const &v, isize string_limit=36) {
|
||||
switch (v.kind) {
|
||||
|
||||
428
src/types.cpp
428
src/types.cpp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user