Clean up generate_minimum_dependency_set code

This commit is contained in:
gingerBill
2022-02-28 15:29:08 +00:00
parent 15d783e920
commit 4f3b5d8dcb

View File

@@ -2204,21 +2204,25 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
ptr_set_init(&c->info.minimum_dependency_set, heap_allocator(), min_dep_set_cap);
ptr_set_init(&c->info.minimum_dependency_type_info_set, heap_allocator());
String required_runtime_entities[] = {
#define FORCE_ADD_RUNTIME_ENTITIES(condition, ...) do { \
if (condition) { \
String entities[] = {__VA_ARGS__}; \
for (isize i = 0; i < gb_count_of(entities); i++) { \
force_add_dependency_entity(c, c->info.runtime_package->scope, entities[i]); \
} \
} \
} while (0)
// required runtime entities
FORCE_ADD_RUNTIME_ENTITIES(true,
// Odin types
str_lit("Type_Info"),
str_lit("Source_Code_Location"),
str_lit("Context"),
str_lit("Allocator"),
str_lit("Logger"),
// Global variables
str_lit("args__"),
str_lit("type_table"),
// Odin internal procedures
str_lit("__init_context"),
str_lit("__type_info_of"),
str_lit("cstring_to_string"),
str_lit("_cleanup_runtime"),
@@ -2251,35 +2255,36 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
// WASM Specific
str_lit("__ashlti3"),
str_lit("__multi3"),
};
for (isize i = 0; i < gb_count_of(required_runtime_entities); i++) {
force_add_dependency_entity(c, c->info.runtime_package->scope, required_runtime_entities[i]);
}
);
if (build_context.no_crt) {
String required_no_crt_entities[] = {
// NOTE(bill): Only if these exist
str_lit("_tls_index"),
str_lit("_fltused"),
};
for (isize i = 0; i < gb_count_of(required_no_crt_entities); i++) {
force_add_dependency_entity(c, c->info.runtime_package->scope, required_no_crt_entities[i]);
}
}
FORCE_ADD_RUNTIME_ENTITIES(!build_context.disallow_rtti,
// Odin types
str_lit("Type_Info"),
if (!build_context.no_bounds_check) {
String bounds_check_entities[] = {
// Bounds checking related procedures
str_lit("bounds_check_error"),
str_lit("matrix_bounds_check_error"),
str_lit("slice_expr_error_hi"),
str_lit("slice_expr_error_lo_hi"),
str_lit("multi_pointer_slice_expr_error"),
};
for (isize i = 0; i < gb_count_of(bounds_check_entities); i++) {
force_add_dependency_entity(c, c->info.runtime_package->scope, bounds_check_entities[i]);
}
}
// Global variables
str_lit("type_table"),
str_lit("__type_info_of"),
);
FORCE_ADD_RUNTIME_ENTITIES(!build_context.no_entry_point,
// Global variables
str_lit("args__"),
);
FORCE_ADD_RUNTIME_ENTITIES(build_context.no_crt,
// NOTE(bill): Only if these exist
str_lit("_tls_index"),
str_lit("_fltused"),
);
FORCE_ADD_RUNTIME_ENTITIES(!build_context.no_bounds_check,
// Bounds checking related procedures
str_lit("bounds_check_error"),
str_lit("matrix_bounds_check_error"),
str_lit("slice_expr_error_hi"),
str_lit("slice_expr_error_lo_hi"),
str_lit("multi_pointer_slice_expr_error"),
);
for_array(i, c->info.definitions) {
Entity *e = c->info.definitions[i];
@@ -2401,6 +2406,8 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
start->flags |= EntityFlag_Used;
add_dependency_to_set(c, start);
}
#undef FORCE_ADD_RUNTIME_ENTITIES
}
bool is_entity_a_dependency(Entity *e) {