Add Properties prefix. Fix semantic check regression.

This commit is contained in:
2024-09-26 16:47:34 +02:00
parent e365067354
commit 90fb1a035e
5 changed files with 28 additions and 17 deletions

View File

@@ -91,11 +91,15 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
field := h2tv(state.type_variables, find_result.type_variable);
indent(state, indentation);
print_to_builder(*state.builder, "% ", dx11_type_to_string(field));
print("% %", node.parent.kind, node.parent.parent.kind);
if node.parent.parent.kind == .Properties {
// append(*state.builder, "__PROPERTIES__");
if field.struct_field_parent {
parent_tv := h2tv(state.type_variables, field.struct_field_parent.type_variable);
if parent_tv.typename == "properties" {
append(*state.builder, "__PROPERTIES__");
}
}
print_to_builder(*state.builder, "%", node.name);
@@ -379,6 +383,13 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
is_properties := type_var.typename == "properties";
if !is_properties {
if type_var.struct_field_parent {
parent_tv := h2tv(state.type_variables, type_var.struct_field_parent.type_variable);
if parent_tv.typename == "properties" {
append(*state.builder, "__PROPERTIES__");
}
}
print_to_builder(*state.builder, "%", node.name);
}

View File

@@ -1391,7 +1391,7 @@ create_call_constraint :: (checker : *Semantic_Checker, node : *AST_Node, type_v
for arg : arg_vars {
function_param := function.children[it_index];
if !types_compatible(checker, arg.var, function_param) {
if !types_compatible(checker, arg.var, function_param, true) {
if all_args_match {
arg_node = arg.node;
}
@@ -1571,7 +1571,7 @@ Unification_Result :: enum {
Unification_Failure;
}
types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rhs : Type_Variable_Handle) -> bool {
types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rhs : Type_Variable_Handle, param_matching : bool = false) -> bool {
lhs_var := h2tv(checker, lhs);
rhs_var := h2tv(checker, rhs);
@@ -1580,6 +1580,7 @@ types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rh
case .Half; #through;
case .Float; #through;
case .Double; {
if !param_matching {
if rhs_var.type == .Struct {
if rhs_var.typename == {
case "float2"; #through;
@@ -1589,6 +1590,7 @@ types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rh
}
}
}
}
return rhs_var.type == .Int || rhs_var.type == .Half ||
rhs_var.type == .Float || rhs_var.type == .Double;
}

View File

@@ -1,6 +1,6 @@
cbuffer __PROPERTIES : register(b0)
{
float4 color;
float4 __PROPERTIES__color;
}
@@ -11,6 +11,6 @@ float3 vs_main(float3 pos : POSITION) : SV_POSITION
float4 ps_main() : SV_TARGET
{
return color;
return __PROPERTIES__color;
}

View File

@@ -1,6 +1,6 @@
cbuffer __PROPERTIES : register(b0)
{
float4 color;
float4 __PROPERTIES__color;
}
@@ -11,6 +11,6 @@ float3 vs_main(float3 pos : POSITION, float2 uv : TEXCOORD0) : SV_POSITION
float4 ps_main() : SV_TARGET
{
return color;
return __PROPERTIES__color;
}

View File

@@ -6,8 +6,6 @@ test/empty_struct.shd semant
test/empty_vertex_main.shd semant
test/empty_vertex_main_with_position_parameter.shd semant
test/field_assignment.shd semant
test/field_without_type_specifier.shd semant
test/float_suffix.shd semant
test/function_call.shd semant
test/function_call_out_of_order_declaration.shd semant
test/function_call_return.shd semant