mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Fix patch (yeah... I know)
This commit is contained in:
+8
-28
@@ -45,7 +45,6 @@ struct CallArgumentData {
|
|||||||
Entity *gen_entity;
|
Entity *gen_entity;
|
||||||
i64 score;
|
i64 score;
|
||||||
Type * result_type;
|
Type * result_type;
|
||||||
Type * proc_type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PolyProcData {
|
struct PolyProcData {
|
||||||
@@ -7016,10 +7015,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
||||||
if (entity_to_use != nullptr) {
|
add_entity_use(c, ident, entity_to_use);
|
||||||
add_entity_use(c, ident, entity_to_use);
|
|
||||||
data.proc_type = entity_to_use->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -7095,7 +7091,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
auto valids = array_make<ValidIndexAndScore>(heap_allocator(), 0, procs.count);
|
auto valids = array_make<ValidIndexAndScore>(heap_allocator(), 0, procs.count);
|
||||||
defer (array_free(&valids));
|
defer (array_free(&valids));
|
||||||
|
|
||||||
auto proc_entities = array_make<Entity *>(heap_allocator(), 0, procs.count*2);
|
auto proc_entities = array_make<Entity *>(heap_allocator(), 0, procs.count*2 + 1);
|
||||||
defer (array_free(&proc_entities));
|
defer (array_free(&proc_entities));
|
||||||
for_array(i, procs) {
|
for_array(i, procs) {
|
||||||
array_add(&proc_entities, procs[i]);
|
array_add(&proc_entities, procs[i]);
|
||||||
@@ -7152,6 +7148,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
gb_sort_array(valids.data, valids.count, valid_index_and_score_cmp);
|
gb_sort_array(valids.data, valids.count, valid_index_and_score_cmp);
|
||||||
i64 best_score = valids[0].score;
|
i64 best_score = valids[0].score;
|
||||||
Entity *best_entity = proc_entities[valids[0].index];
|
Entity *best_entity = proc_entities[valids[0].index];
|
||||||
|
GB_ASSERT(best_entity != nullptr);
|
||||||
for (isize i = 1; i < valids.count; i++) {
|
for (isize i = 1; i < valids.count; i++) {
|
||||||
if (best_score > valids[i].score) {
|
if (best_score > valids[i].score) {
|
||||||
valids.count = i;
|
valids.count = i;
|
||||||
@@ -7236,6 +7233,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
|
|
||||||
for (isize i = 0; i < valids.count; i++) {
|
for (isize i = 0; i < valids.count; i++) {
|
||||||
Entity *proc = proc_entities[valids[i].index];
|
Entity *proc = proc_entities[valids[i].index];
|
||||||
|
GB_ASSERT(proc != nullptr);
|
||||||
TokenPos pos = proc->token.pos;
|
TokenPos pos = proc->token.pos;
|
||||||
Type *t = base_type(proc->type); GB_ASSERT(t->kind == Type_Proc);
|
Type *t = base_type(proc->type); GB_ASSERT(t->kind == Type_Proc);
|
||||||
gbString pt = nullptr;
|
gbString pt = nullptr;
|
||||||
@@ -7284,15 +7282,13 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity *e = proc_entities[valids[0].index];
|
Entity *e = proc_entities[valids[0].index];
|
||||||
|
GB_ASSERT(e != nullptr);
|
||||||
|
|
||||||
proc_type = e->type;
|
proc_type = e->type;
|
||||||
CallArgumentData data = {};
|
CallArgumentData data = {};
|
||||||
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
||||||
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
||||||
if (entity_to_use != nullptr) {
|
add_entity_use(c, ident, entity_to_use);
|
||||||
add_entity_use(c, ident, entity_to_use);
|
|
||||||
data.proc_type = entity_to_use->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.gen_entity != nullptr) {
|
if (data.gen_entity != nullptr) {
|
||||||
Entity *e = data.gen_entity;
|
Entity *e = data.gen_entity;
|
||||||
@@ -7323,10 +7319,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
CallArgumentData data = {};
|
CallArgumentData data = {};
|
||||||
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
||||||
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
||||||
if (entity_to_use != nullptr) {
|
add_entity_use(c, ident, entity_to_use);
|
||||||
add_entity_use(c, ident, entity_to_use);
|
|
||||||
data.proc_type = entity_to_use->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.gen_entity != nullptr) {
|
if (data.gen_entity != nullptr) {
|
||||||
Entity *e = data.gen_entity;
|
Entity *e = data.gen_entity;
|
||||||
@@ -7830,10 +7823,6 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
Type *pt = base_type(proc_type);
|
Type *pt = base_type(proc_type);
|
||||||
if (data.proc_type != nullptr) {
|
|
||||||
pt = base_type(data.proc_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
||||||
if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) {
|
if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) {
|
||||||
@@ -7841,15 +7830,6 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
|
||||||
init_core_context(c->checker);
|
|
||||||
GB_ASSERT(t_context != nullptr);
|
|
||||||
GB_ASSERT(t_context->kind == Type_Named);
|
|
||||||
add_declaration_dependency(c, t_context->Named.type_name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (result_type == nullptr) {
|
if (result_type == nullptr) {
|
||||||
operand->mode = Addressing_NoValue;
|
operand->mode = Addressing_NoValue;
|
||||||
} else {
|
} else {
|
||||||
@@ -7897,7 +7877,7 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr
|
|||||||
operand->mode = Addressing_OptionalOk;
|
operand->mode = Addressing_OptionalOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value);
|
// add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value);
|
||||||
|
|
||||||
return Expr_Expr;
|
return Expr_Expr;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1682,14 +1682,14 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (false) {
|
success = false;
|
||||||
|
#if 0
|
||||||
gbString got = type_to_string(op.type);
|
gbString got = type_to_string(op.type);
|
||||||
gbString expected = type_to_string(type);
|
gbString expected = type_to_string(type);
|
||||||
error(op.expr, "Cannot assigned type to parameter, got type '%s', expected '%s'", got, expected);
|
error(op.expr, "Cannot assigned type to parameter, got type '%s', expected '%s'", got, expected);
|
||||||
gb_string_free(expected);
|
gb_string_free(expected);
|
||||||
gb_string_free(got);
|
gb_string_free(got);
|
||||||
}
|
#endif
|
||||||
success = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-14
@@ -4387,23 +4387,27 @@ void check_unchecked_bodies(Checker *c) {
|
|||||||
// NOTE(2021-02-26, bill): Actually fix this race condition
|
// NOTE(2021-02-26, bill): Actually fix this race condition
|
||||||
for_array(i, c->info.minimum_dependency_set.entries) {
|
for_array(i, c->info.minimum_dependency_set.entries) {
|
||||||
Entity *e = c->info.minimum_dependency_set.entries[i].ptr;
|
Entity *e = c->info.minimum_dependency_set.entries[i].ptr;
|
||||||
if (e != nullptr && e->kind == Entity_Procedure) {
|
if (e == nullptr || e->kind != Entity_Procedure) {
|
||||||
if (!e->Procedure.is_foreign && (e->flags & EntityFlag_ProcBodyChecked) == 0) {
|
continue;
|
||||||
GB_ASSERT(e->decl_info != nullptr);
|
}
|
||||||
|
if (e->Procedure.is_foreign) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((e->flags & EntityFlag_ProcBodyChecked) == 0) {
|
||||||
|
GB_ASSERT(e->decl_info != nullptr);
|
||||||
|
|
||||||
ProcInfo pi = {};
|
ProcInfo pi = {};
|
||||||
pi.file = e->file;
|
pi.file = e->file;
|
||||||
pi.token = e->token;
|
pi.token = e->token;
|
||||||
pi.decl = e->decl_info;
|
pi.decl = e->decl_info;
|
||||||
pi.type = e->type;
|
pi.type = e->type;
|
||||||
|
|
||||||
Ast *pl = e->decl_info->proc_lit;
|
Ast *pl = e->decl_info->proc_lit;
|
||||||
GB_ASSERT(pl != nullptr);
|
GB_ASSERT(pl != nullptr);
|
||||||
pi.body = pl->ProcLit.body;
|
pi.body = pl->ProcLit.body;
|
||||||
pi.tags = pl->ProcLit.tags;
|
pi.tags = pl->ProcLit.tags;
|
||||||
|
|
||||||
check_proc_info(c, pi);
|
check_proc_info(c, pi);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user