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;
|
Unresolved_Expression;
|
||||||
|
|
||||||
Struct;
|
Struct;
|
||||||
|
Properties;
|
||||||
|
CBuffer;
|
||||||
Array;
|
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;
|
name := ifx node.name.count == 0 then "properties" else node.name;
|
||||||
type_var := declare_struct(checker, node, name);
|
type_var := declare_struct(checker, node, name);
|
||||||
var := h2tv(checker, type_var);
|
var := h2tv(checker, type_var);
|
||||||
|
var.type = .Properties;
|
||||||
var.typename = "properties";
|
var.typename = "properties";
|
||||||
var.buffer_index = PROPERTIES_BUFFER_INDEX;
|
var.buffer_index = PROPERTIES_BUFFER_INDEX;
|
||||||
return type_var;
|
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 {
|
declare_cbuffer :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_Handle {
|
||||||
type_var := declare_struct(checker, node);
|
type_var := declare_struct(checker, node);
|
||||||
var := h2tv(checker, type_var);
|
var := h2tv(checker, type_var);
|
||||||
var.typename = "constant_buffer";
|
var.type = .CBuffer;
|
||||||
current_custom_buffer_index += 1;
|
current_custom_buffer_index += 1;
|
||||||
var.buffer_index = current_custom_buffer_index;
|
var.buffer_index = current_custom_buffer_index;
|
||||||
return type_var;
|
return type_var;
|
||||||
@@ -1006,23 +1009,21 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
|
|||||||
add_symbol_to_scope(checker, checker.current_scope, name_to_check, symbol);
|
add_symbol_to_scope(checker, checker.current_scope, name_to_check, symbol);
|
||||||
} else {
|
} else {
|
||||||
//@Note(niels): This is some ugly code, but it's probably fine for now.
|
//@Note(niels): This is some ugly code, but it's probably fine for now.
|
||||||
for child : node.children {
|
field_list := node.children[0];
|
||||||
if child.kind != .FieldList {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for function : find_result.functions {
|
for function : find_result.functions {
|
||||||
func_var := h2tv(checker, function.type_variable);
|
func_var := h2tv(checker, function.type_variable);
|
||||||
if func_var.child_count != child.children.count {
|
if func_var.source_node.children[0].children.count != field_list.children.count {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
all_same : bool = true;
|
all_same : bool = true;
|
||||||
for i : 0..func_var.child_count - 1 {
|
for i : 0..func_var.child_count - 1 {
|
||||||
arg := func_var.children[i];
|
arg := func_var.children[i];
|
||||||
node_child := child.children[it_index];
|
node_child := field_list.children[it_index];
|
||||||
arg_type := get_type_from_identifier(checker, checker.current_scope, node_child);
|
|
||||||
|
|
||||||
|
typename : string;
|
||||||
|
arg_type := get_type_from_identifier(checker, checker.current_scope, node_child, *typename);
|
||||||
other_arg := h2tv(checker, arg);
|
other_arg := h2tv(checker, arg);
|
||||||
|
|
||||||
if arg_type != other_arg.type {
|
if arg_type != other_arg.type {
|
||||||
@@ -1030,7 +1031,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if arg_type == .Struct && other_arg.type == .Struct {
|
if arg_type == .Struct && other_arg.type == .Struct {
|
||||||
if node_child.token.ident_value != other_arg.typename {
|
if typename != other_arg.typename {
|
||||||
all_same = false;
|
all_same = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1059,7 +1060,6 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
|
|||||||
|
|
||||||
array_add(*find_result.functions, function);
|
array_add(*find_result.functions, function);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !builtin {
|
if !builtin {
|
||||||
scope, scope_handle := push_scope(checker, name_to_check, .Function);
|
scope, scope_handle := push_scope(checker, name_to_check, .Function);
|
||||||
@@ -1216,14 +1216,15 @@ create_variable :: (checker : *Semantic_Checker, node : *AST_Node, field_parent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if node.children.count > 0 {
|
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);
|
field_access_on_primitive_type(checker, node, find_result.type_variable);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
lookup_name : string = variable.typename;
|
lookup_name : string = variable.typename;
|
||||||
if variable.typename == "properties" {
|
// if variable.typename == "properties" {
|
||||||
lookup_name = variable.name;
|
// lookup_name = variable.name;
|
||||||
}
|
// }
|
||||||
|
print("Lookup: %\n", lookup_name);
|
||||||
struct_symbol := find_symbol(checker, lookup_name, checker.current_scope);
|
struct_symbol := find_symbol(checker, lookup_name, checker.current_scope);
|
||||||
type_variable := h2tv(checker, struct_symbol.type_variable);
|
type_variable := h2tv(checker, struct_symbol.type_variable);
|
||||||
|
|
||||||
@@ -1891,6 +1892,8 @@ pretty_print_scope :: (checker : *Semantic_Checker, scope : *Scope, builder : *S
|
|||||||
case .Function; {
|
case .Function; {
|
||||||
pretty_print_function(checker, builder, key, type_variable, 1);
|
pretty_print_function(checker, builder, key, type_variable, 1);
|
||||||
}
|
}
|
||||||
|
case .CBuffer; #through;
|
||||||
|
case .Properties; #through;
|
||||||
case .Struct; {
|
case .Struct; {
|
||||||
if type_variable.typename.count > 0 && type_variable.kind != .Declaration {
|
if type_variable.typename.count > 0 && type_variable.kind != .Declaration {
|
||||||
indent(builder, indentation + 1);
|
indent(builder, indentation + 1);
|
||||||
@@ -1915,6 +1918,8 @@ pretty_print_scope :: (checker : *Semantic_Checker, scope : *Scope, builder : *S
|
|||||||
case .Function; {
|
case .Function; {
|
||||||
pretty_print_function(checker, builder, key, type_variable, 1);
|
pretty_print_function(checker, builder, key, type_variable, 1);
|
||||||
}
|
}
|
||||||
|
case .CBuffer; #through;
|
||||||
|
case .Properties; #through;
|
||||||
case .Struct; {
|
case .Struct; {
|
||||||
if type_variable.typename.count > 0 && type_variable.kind != .Declaration {
|
if type_variable.typename.count > 0 && type_variable.kind != .Declaration {
|
||||||
indent(builder, indentation + 1);
|
indent(builder, indentation + 1);
|
||||||
@@ -2107,7 +2112,8 @@ pretty_print_type_variable :: (checker : *Semantic_Checker, type_variable : *Typ
|
|||||||
rep_var := h2tv(checker, rep);
|
rep_var := h2tv(checker, rep);
|
||||||
if is_proper(type_variable) {
|
if is_proper(type_variable) {
|
||||||
print_to_builder(builder, proper_type_to_string(checker, type_variable, temp));
|
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 {
|
if type_variable.kind == .Declaration {
|
||||||
append(builder, "{");
|
append(builder, "{");
|
||||||
|
|
||||||
|
|||||||
@@ -96,10 +96,22 @@ int4x4 :: struct {
|
|||||||
#foreign transpose :: (float4x4) -> float4x4;
|
#foreign transpose :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
//~ nbr: Multiplies
|
//~ nbr: Multiplies
|
||||||
#foreign mul :: (float2, float2) -> float2;
|
#foreign mul :: (float2, float2) -> float;
|
||||||
#foreign mul :: (float3, float3) -> float3;
|
#foreign mul :: (float3, float3) -> float;
|
||||||
#foreign mul :: (float4, float4) -> float4;
|
#foreign mul :: (float4, float4) -> float;
|
||||||
#foreign mul :: (float4x4, float4x4) -> float4x4;
|
#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
|
//~ nbr: General
|
||||||
#foreign abs :: (float) -> float;
|
#foreign abs :: (float) -> float;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
Camera_Data :: constant_buffer {
|
camera :: constant_buffer {
|
||||||
projection : float4x4;
|
projection : float4x4;
|
||||||
view : float4x4;
|
view : float4x4;
|
||||||
}
|
}
|
||||||
|
|
||||||
vertex main :: (pos : float4 @position) -> float4 @position {
|
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 {
|
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