Try some things to figure out why overload resolution is broken.
This commit is contained in:
@@ -34,6 +34,8 @@ Semantic_Type :: enum {
|
||||
Unresolved_Expression;
|
||||
|
||||
Struct;
|
||||
Properties;
|
||||
CBuffer;
|
||||
Array;
|
||||
}
|
||||
|
||||
@@ -927,6 +929,7 @@ declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Va
|
||||
name := ifx node.name.count == 0 then "properties" else node.name;
|
||||
type_var := declare_struct(checker, node, name);
|
||||
var := h2tv(checker, type_var);
|
||||
var.type = .Properties;
|
||||
var.typename = "properties";
|
||||
var.buffer_index = PROPERTIES_BUFFER_INDEX;
|
||||
return type_var;
|
||||
@@ -935,7 +938,7 @@ declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Va
|
||||
declare_cbuffer :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_Handle {
|
||||
type_var := declare_struct(checker, node);
|
||||
var := h2tv(checker, type_var);
|
||||
var.typename = "constant_buffer";
|
||||
var.type = .CBuffer;
|
||||
current_custom_buffer_index += 1;
|
||||
var.buffer_index = current_custom_buffer_index;
|
||||
return type_var;
|
||||
@@ -1006,59 +1009,56 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
|
||||
add_symbol_to_scope(checker, checker.current_scope, name_to_check, symbol);
|
||||
} else {
|
||||
//@Note(niels): This is some ugly code, but it's probably fine for now.
|
||||
for child : node.children {
|
||||
if child.kind != .FieldList {
|
||||
field_list := node.children[0];
|
||||
|
||||
for function : find_result.functions {
|
||||
func_var := h2tv(checker, function.type_variable);
|
||||
if func_var.source_node.children[0].children.count != field_list.children.count {
|
||||
continue;
|
||||
}
|
||||
|
||||
for function : find_result.functions {
|
||||
func_var := h2tv(checker, function.type_variable);
|
||||
if func_var.child_count != child.children.count {
|
||||
continue;
|
||||
}
|
||||
|
||||
all_same : bool = true;
|
||||
for i : 0..func_var.child_count - 1 {
|
||||
arg := func_var.children[i];
|
||||
node_child := child.children[it_index];
|
||||
arg_type := get_type_from_identifier(checker, checker.current_scope, node_child);
|
||||
all_same : bool = true;
|
||||
for i : 0..func_var.child_count - 1 {
|
||||
arg := func_var.children[i];
|
||||
node_child := field_list.children[it_index];
|
||||
|
||||
other_arg := h2tv(checker, arg);
|
||||
typename : string;
|
||||
arg_type := get_type_from_identifier(checker, checker.current_scope, node_child, *typename);
|
||||
other_arg := h2tv(checker, arg);
|
||||
|
||||
if arg_type != other_arg.type {
|
||||
all_same = false;
|
||||
break;
|
||||
} else {
|
||||
if arg_type == .Struct && other_arg.type == .Struct {
|
||||
if node_child.token.ident_value != other_arg.typename {
|
||||
all_same = false;
|
||||
break;
|
||||
}
|
||||
if arg_type != other_arg.type {
|
||||
all_same = false;
|
||||
break;
|
||||
} else {
|
||||
if arg_type == .Struct && other_arg.type == .Struct {
|
||||
if typename != other_arg.typename {
|
||||
all_same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if all_same {
|
||||
symbol_redeclaration(checker, node, find_result);
|
||||
return 0;
|
||||
} else {
|
||||
function : Defined_Symbol;
|
||||
function.name = name_to_check;
|
||||
function.source_node = node;
|
||||
function.type_variable = handle;
|
||||
|
||||
array_add(*find_result.functions, function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function : Defined_Symbol;
|
||||
function.name = name_to_check;
|
||||
function.source_node = node;
|
||||
function.type_variable = handle;
|
||||
|
||||
array_add(*find_result.functions, function);
|
||||
if all_same {
|
||||
symbol_redeclaration(checker, node, find_result);
|
||||
return 0;
|
||||
} else {
|
||||
function : Defined_Symbol;
|
||||
function.name = name_to_check;
|
||||
function.source_node = node;
|
||||
function.type_variable = handle;
|
||||
|
||||
array_add(*find_result.functions, function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function : Defined_Symbol;
|
||||
function.name = name_to_check;
|
||||
function.source_node = node;
|
||||
function.type_variable = handle;
|
||||
|
||||
array_add(*find_result.functions, function);
|
||||
}
|
||||
|
||||
if !builtin {
|
||||
@@ -1216,14 +1216,15 @@ create_variable :: (checker : *Semantic_Checker, node : *AST_Node, field_parent
|
||||
}
|
||||
|
||||
if node.children.count > 0 {
|
||||
if variable.type != .Struct {
|
||||
if variable.type != .Struct && variable.type != .Properties && variable.type != .CBuffer {
|
||||
field_access_on_primitive_type(checker, node, find_result.type_variable);
|
||||
return 0;
|
||||
} else {
|
||||
lookup_name : string = variable.typename;
|
||||
if variable.typename == "properties" {
|
||||
lookup_name = variable.name;
|
||||
}
|
||||
// if variable.typename == "properties" {
|
||||
// lookup_name = variable.name;
|
||||
// }
|
||||
print("Lookup: %\n", lookup_name);
|
||||
struct_symbol := find_symbol(checker, lookup_name, checker.current_scope);
|
||||
type_variable := h2tv(checker, struct_symbol.type_variable);
|
||||
|
||||
@@ -1891,6 +1892,8 @@ pretty_print_scope :: (checker : *Semantic_Checker, scope : *Scope, builder : *S
|
||||
case .Function; {
|
||||
pretty_print_function(checker, builder, key, type_variable, 1);
|
||||
}
|
||||
case .CBuffer; #through;
|
||||
case .Properties; #through;
|
||||
case .Struct; {
|
||||
if type_variable.typename.count > 0 && type_variable.kind != .Declaration {
|
||||
indent(builder, indentation + 1);
|
||||
@@ -1915,6 +1918,8 @@ pretty_print_scope :: (checker : *Semantic_Checker, scope : *Scope, builder : *S
|
||||
case .Function; {
|
||||
pretty_print_function(checker, builder, key, type_variable, 1);
|
||||
}
|
||||
case .CBuffer; #through;
|
||||
case .Properties; #through;
|
||||
case .Struct; {
|
||||
if type_variable.typename.count > 0 && type_variable.kind != .Declaration {
|
||||
indent(builder, indentation + 1);
|
||||
@@ -2107,7 +2112,8 @@ pretty_print_type_variable :: (checker : *Semantic_Checker, type_variable : *Typ
|
||||
rep_var := h2tv(checker, rep);
|
||||
if is_proper(type_variable) {
|
||||
print_to_builder(builder, proper_type_to_string(checker, type_variable, temp));
|
||||
} else if type_variable.type == .Struct {
|
||||
} else if type_variable.type == .Struct || type_variable.type == .Properties ||
|
||||
type_variable.type == .CBuffer {
|
||||
if type_variable.kind == .Declaration {
|
||||
append(builder, "{");
|
||||
|
||||
|
||||
@@ -96,10 +96,22 @@ int4x4 :: struct {
|
||||
#foreign transpose :: (float4x4) -> float4x4;
|
||||
|
||||
//~ nbr: Multiplies
|
||||
#foreign mul :: (float2, float2) -> float2;
|
||||
#foreign mul :: (float3, float3) -> float3;
|
||||
#foreign mul :: (float4, float4) -> float4;
|
||||
#foreign mul :: (float2, float2) -> float;
|
||||
#foreign mul :: (float3, float3) -> float;
|
||||
#foreign mul :: (float4, float4) -> float;
|
||||
#foreign mul :: (float4x4, float4x4) -> float4x4;
|
||||
#foreign mul :: (float, float2) -> float2;
|
||||
#foreign mul :: (float, float3) -> float3;
|
||||
#foreign mul :: (float, float4) -> float4;
|
||||
|
||||
#foreign mul :: (float, float4x4) -> float4x4;
|
||||
#foreign mul :: (float4x4, float) -> float4x4;
|
||||
#foreign mul :: (float4x4, float4) -> float4;
|
||||
#foreign mul :: (float2, float) -> float2;
|
||||
#foreign mul :: (float3, float) -> float3;
|
||||
#foreign mul :: (float4, float) -> float4;
|
||||
|
||||
#foreign mul :: (float4, float4x4) -> float4x4;
|
||||
|
||||
//~ nbr: General
|
||||
#foreign abs :: (float) -> float;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
Camera_Data :: constant_buffer {
|
||||
camera :: constant_buffer {
|
||||
projection : float4x4;
|
||||
view : float4x4;
|
||||
}
|
||||
|
||||
vertex main :: (pos : float4 @position) -> float4 @position {
|
||||
return mul(projection, mul(view, pos));
|
||||
return mul(camera.projection, mul(camera.view, pos));
|
||||
}
|
||||
|
||||
pixel main :: () -> float4 @target {
|
||||
return float(0.5, 0.5, 0.5, 1.0);
|
||||
return float4(0.5, 0.5, 0.5, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user