mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix procedure grouping
This commit is contained in:
+17
-20
@@ -362,10 +362,10 @@ pop :: proc "contextless" (array: ^$T/[dynamic]$E) -> E {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear :: inline proc "contextless" (array: ^$T/[dynamic]$E) {
|
clear_dynamic_array :: inline proc "contextless" (array: ^$T/[dynamic]$E) {
|
||||||
if array != nil do (cast(^raw.Dynamic_Array)array).len = 0;
|
if array != nil do (cast(^raw.Dynamic_Array)array).len = 0;
|
||||||
}
|
}
|
||||||
clear :: inline proc "contextless" (m: ^$T/map[$K]$V) {
|
clear_map :: inline proc "contextless" (m: ^$T/map[$K]$V) {
|
||||||
if m == nil do return;
|
if m == nil do return;
|
||||||
raw_map := cast(^raw.Map)m;
|
raw_map := cast(^raw.Map)m;
|
||||||
hashes := cast(^raw.Dynamic_Array)&raw_map.hashes;
|
hashes := cast(^raw.Dynamic_Array)&raw_map.hashes;
|
||||||
@@ -374,6 +374,8 @@ clear :: inline proc "contextless" (m: ^$T/map[$K]$V) {
|
|||||||
entries.len = 0;
|
entries.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear :: proc[clear_dynamic_array, clear_map];
|
||||||
|
|
||||||
reserve :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #caller_location) -> bool {
|
reserve :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #caller_location) -> bool {
|
||||||
if array == nil do return false;
|
if array == nil do return false;
|
||||||
a := cast(^raw.Dynamic_Array)array;
|
a := cast(^raw.Dynamic_Array)array;
|
||||||
@@ -472,24 +474,26 @@ new_clone :: inline proc(data: $T, loc := #caller_location) -> ^T {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
free :: proc(ptr: rawptr, loc := #caller_location) {
|
free_string :: proc(str: string, loc := #caller_location) {
|
||||||
free_ptr(ptr, loc);
|
|
||||||
}
|
|
||||||
free :: proc(str: $T/string, loc := #caller_location) {
|
|
||||||
free_ptr((^raw.String)(&str).data, loc);
|
free_ptr((^raw.String)(&str).data, loc);
|
||||||
}
|
}
|
||||||
free :: proc(array: $T/[dynamic]$E, loc := #caller_location) {
|
free_dynamic_array :: proc(array: $T/[dynamic]$E, loc := #caller_location) {
|
||||||
free_ptr((^raw.Dynamic_Array)(&array).data, loc);
|
free_ptr((^raw.Dynamic_Array)(&array).data, loc);
|
||||||
}
|
}
|
||||||
free :: proc(slice: $T/[]$E, loc := #caller_location) {
|
free_slice :: proc(array: $T/[]$E, loc := #caller_location) {
|
||||||
free_ptr((^raw.Slice)(&slice).data, loc);
|
free_ptr((^raw.Slice)(&array).data, loc);
|
||||||
}
|
}
|
||||||
free :: proc(m: $T/map[$K]$V, loc := #caller_location) {
|
free_map :: proc(m: $T/map[$K]$V, loc := #caller_location) {
|
||||||
raw := cast(^raw.Map)&m;
|
raw := cast(^raw.Map)&m;
|
||||||
free(raw.hashes, loc);
|
free_dynamic_array(raw.hashes, loc);
|
||||||
free(raw.entries.data, loc);
|
free_ptr(raw.entries.data, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free :: proc[
|
||||||
|
free_ptr, free_string, free_dynamic_array, free_slice, free_map,
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
// NOTE(bill): This code works but I will prefer having `make` a built-in procedure
|
// NOTE(bill): This code works but I will prefer having `make` a built-in procedure
|
||||||
// to have better error messages
|
// to have better error messages
|
||||||
/*
|
/*
|
||||||
@@ -498,14 +502,7 @@ make :: proc(T: type/[]$E, len: int, using loc := #caller_location) -> T {
|
|||||||
__slice_expr_error(file_path, int(line), int(column), 0, len, cap);
|
__slice_expr_error(file_path, int(line), int(column), 0, len, cap);
|
||||||
data := cast(^E)alloc(len * size_of(E), align_of(E));
|
data := cast(^E)alloc(len * size_of(E), align_of(E));
|
||||||
for i in 0..len do (data+i)^ = E{};
|
for i in 0..len do (data+i)^ = E{};
|
||||||
s := raw.Slice{data = data, len = len, cap = len};
|
s := raw.Slice{data = data, len = len};
|
||||||
return (cast(^T)&s)^;
|
|
||||||
}
|
|
||||||
make :: proc(T: type/[]$E, len, cap: int, using loc := #caller_location) -> T {
|
|
||||||
__slice_expr_error(file_path, int(line), int(column), 0, len, cap);
|
|
||||||
data := cast(^E)alloc(len * size_of(E), align_of(E));
|
|
||||||
for i in 0..len do (data+i)^ = E{};
|
|
||||||
s := raw.Slice{data = data, len = len, cap = len};
|
|
||||||
return (cast(^T)&s)^;
|
return (cast(^T)&s)^;
|
||||||
}
|
}
|
||||||
make :: proc(T: type/[dynamic]$E, len: int = 8, using loc := #caller_location) -> T {
|
make :: proc(T: type/[dynamic]$E, len: int = 8, using loc := #caller_location) -> T {
|
||||||
|
|||||||
@@ -999,6 +999,11 @@ Entity *check_ident(Checker *c, Operand *o, AstNode *n, Type *named_type, Type *
|
|||||||
|
|
||||||
if (e->kind == Entity_ProcedureGrouping) {
|
if (e->kind == Entity_ProcedureGrouping) {
|
||||||
auto *pge = &e->ProcedureGrouping;
|
auto *pge = &e->ProcedureGrouping;
|
||||||
|
|
||||||
|
DeclInfo *d = decl_info_of_entity(&c->info, e);
|
||||||
|
check_entity_decl(c, e, d, nullptr);
|
||||||
|
|
||||||
|
|
||||||
Entity **procs = pge->entities.data;
|
Entity **procs = pge->entities.data;
|
||||||
isize overload_count = pge->entities.count;
|
isize overload_count = pge->entities.count;
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
|
|||||||
+1
-1
@@ -1472,7 +1472,7 @@ PtrSet<Entity *> generate_minimum_dependency_set(CheckerInfo *info, Entity *star
|
|||||||
Entity *e = info->definitions.entries[i].value;
|
Entity *e = info->definitions.entries[i].value;
|
||||||
// if (e->scope->is_global && !is_type_poly_proc(e->type)) { // TODO(bill): is the check enough?
|
// if (e->scope->is_global && !is_type_poly_proc(e->type)) { // TODO(bill): is the check enough?
|
||||||
if (e->scope->is_global) { // TODO(bill): is the check enough?
|
if (e->scope->is_global) { // TODO(bill): is the check enough?
|
||||||
if (!is_type_poly_proc(e->type)) {
|
if (e->type == nullptr || !is_type_poly_proc(e->type)) {
|
||||||
// NOTE(bill): Require runtime stuff
|
// NOTE(bill): Require runtime stuff
|
||||||
add_dependency_to_map(&map, info, e);
|
add_dependency_to_map(&map, info, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user