mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-18 20:02:22 -07:00
Fix overloading bug due to comparison of named types
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#import "os.odin";
|
||||
#import "halloc.odin";
|
||||
|
||||
|
||||
main :: proc() {
|
||||
/*
|
||||
/*
|
||||
|
||||
@@ -396,8 +396,8 @@ PIXELFORMATDESCRIPTOR :: struct #ordered {
|
||||
damage_mask: u32,
|
||||
}
|
||||
|
||||
GetDC :: proc(h: HANDLE) -> HDC #foreign user32;
|
||||
SetPixelFormat :: proc(hdc: HDC, pixel_format: i32, pfd: ^PIXELFORMATDESCRIPTOR ) -> BOOL #foreign gdi32;
|
||||
GetDC :: proc(h: HWND) -> HDC #foreign user32;
|
||||
SetPixelFormat :: proc(hdc: HDC, pixel_format: i32, pfd: ^PIXELFORMATDESCRIPTOR) -> BOOL #foreign gdi32;
|
||||
ChoosePixelFormat :: proc(hdc: HDC, pfd: ^PIXELFORMATDESCRIPTOR) -> i32 #foreign gdi32;
|
||||
SwapBuffers :: proc(hdc: HDC) -> BOOL #foreign gdi32;
|
||||
ReleaseDC :: proc(wnd: HWND, hdc: HDC) -> i32 #foreign user32;
|
||||
@@ -412,6 +412,7 @@ wglCreateContext :: proc(hdc: HDC) -> HGLRC #foreign opengl32;
|
||||
wglMakeCurrent :: proc(hdc: HDC, hglrc: HGLRC) -> BOOL #foreign opengl32;
|
||||
wglGetProcAddress :: proc(c_str: ^u8) -> PROC #foreign opengl32;
|
||||
wglDeleteContext :: proc(hglrc: HGLRC) -> BOOL #foreign opengl32;
|
||||
wglChoosePixelFormatARB :: proc(hdc: HDC, attribi_list: ^i32, attribf_list: ^f32, max_formats: u32, formats: ^i32, num_formats: u32) -> BOOL #foreign opengl32;
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-4
@@ -183,10 +183,7 @@ i64 check_distance_between_types(Checker *c, Operand *operand, Type *type) {
|
||||
|
||||
// TODO(bill): Should I allow this implicit conversion at all?!
|
||||
// rawptr <- ^T
|
||||
if (is_type_rawptr(dst) && is_type_pointer(src)) {
|
||||
if (dst != type) {
|
||||
return -1;
|
||||
}
|
||||
if (are_types_identical(type, t_rawptr) && is_type_pointer(src)) {
|
||||
return 5;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1242,6 +1242,9 @@ void check_procedure_overloading(Checker *c, Entity *e) {
|
||||
ProcTypeOverloadKind kind = are_proc_types_overload_safe(p->type, q->type);
|
||||
switch (kind) {
|
||||
case ProcOverload_Identical:
|
||||
error(p->token, "Overloaded procedure `%.*s` as the same type as another procedure in this scope", LIT(name));
|
||||
is_invalid = true;
|
||||
break;
|
||||
case ProcOverload_CallingConvention:
|
||||
error(p->token, "Overloaded procedure `%.*s` as the same type as another procedure in this scope", LIT(name));
|
||||
is_invalid = true;
|
||||
|
||||
+22
-14
@@ -888,7 +888,7 @@ bool are_types_identical(Type *x, Type *y) {
|
||||
|
||||
case Type_Named:
|
||||
if (y->kind == Type_Named) {
|
||||
return x->Named.base == y->Named.base;
|
||||
return x->Named.type_name == y->Named.type_name;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -923,7 +923,6 @@ bool are_types_identical(Type *x, Type *y) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1023,41 +1022,50 @@ typedef enum ProcTypeOverloadKind {
|
||||
ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y) {
|
||||
if (!is_type_proc(x)) return ProcOverload_NotProcedure;
|
||||
if (!is_type_proc(y)) return ProcOverload_NotProcedure;
|
||||
TypeProc *px = &base_type(x)->Proc;
|
||||
TypeProc *py = &base_type(y)->Proc;
|
||||
TypeProc px = base_type(x)->Proc;
|
||||
TypeProc py = base_type(y)->Proc;
|
||||
|
||||
if (px->calling_convention != py->calling_convention) {
|
||||
if (px.calling_convention != py.calling_convention) {
|
||||
return ProcOverload_CallingConvention;
|
||||
}
|
||||
|
||||
if (px->param_count != py->param_count) {
|
||||
if (px.param_count != py.param_count) {
|
||||
return ProcOverload_ParamCount;
|
||||
}
|
||||
|
||||
for (isize i = 0; i < px->param_count; i++) {
|
||||
Entity *ex = px->params->Tuple.variables[i];
|
||||
Entity *ey = py->params->Tuple.variables[i];
|
||||
for (isize i = 0; i < px.param_count; i++) {
|
||||
Entity *ex = px.params->Tuple.variables[i];
|
||||
Entity *ey = py.params->Tuple.variables[i];
|
||||
if (!are_types_identical(ex->type, ey->type)) {
|
||||
return ProcOverload_ParamTypes;
|
||||
}
|
||||
}
|
||||
// IMPORTANT TODO(bill): Determine the rules for overloading procedures with variadic parameters
|
||||
if (px->variadic != py->variadic) {
|
||||
if (px.variadic != py.variadic) {
|
||||
return ProcOverload_ParamVariadic;
|
||||
}
|
||||
|
||||
if (px->result_count != py->result_count) {
|
||||
if (px.result_count != py.result_count) {
|
||||
return ProcOverload_ResultCount;
|
||||
}
|
||||
|
||||
for (isize i = 0; i < px->result_count; i++) {
|
||||
Entity *ex = px->results->Tuple.variables[i];
|
||||
Entity *ey = py->results->Tuple.variables[i];
|
||||
for (isize i = 0; i < px.result_count; i++) {
|
||||
Entity *ex = px.results->Tuple.variables[i];
|
||||
Entity *ey = py.results->Tuple.variables[i];
|
||||
if (!are_types_identical(ex->type, ey->type)) {
|
||||
return ProcOverload_ResultTypes;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Entity *ex = px.params->Tuple.variables[0];
|
||||
Entity *ey = py.params->Tuple.variables[0];
|
||||
bool ok = are_types_identical(ex->type, ey->type);
|
||||
if (ok) {
|
||||
gb_printf_err("Here\n");
|
||||
}
|
||||
}
|
||||
|
||||
return ProcOverload_Identical;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user