Add Properties prefix. Fix semantic check regression.
This commit is contained in:
17
Codegen.jai
17
Codegen.jai
@@ -91,11 +91,15 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
|||||||
field := h2tv(state.type_variables, find_result.type_variable);
|
field := h2tv(state.type_variables, find_result.type_variable);
|
||||||
|
|
||||||
indent(state, indentation);
|
indent(state, indentation);
|
||||||
|
|
||||||
print_to_builder(*state.builder, "% ", dx11_type_to_string(field));
|
print_to_builder(*state.builder, "% ", dx11_type_to_string(field));
|
||||||
|
|
||||||
print("% %", node.parent.kind, node.parent.parent.kind);
|
if field.struct_field_parent {
|
||||||
if node.parent.parent.kind == .Properties {
|
parent_tv := h2tv(state.type_variables, field.struct_field_parent.type_variable);
|
||||||
// append(*state.builder, "__PROPERTIES__");
|
|
||||||
|
if parent_tv.typename == "properties" {
|
||||||
|
append(*state.builder, "__PROPERTIES__");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print_to_builder(*state.builder, "%", node.name);
|
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";
|
is_properties := type_var.typename == "properties";
|
||||||
|
|
||||||
if !is_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);
|
print_to_builder(*state.builder, "%", node.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1391,7 +1391,7 @@ create_call_constraint :: (checker : *Semantic_Checker, node : *AST_Node, type_v
|
|||||||
for arg : arg_vars {
|
for arg : arg_vars {
|
||||||
function_param := function.children[it_index];
|
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 {
|
if all_args_match {
|
||||||
arg_node = arg.node;
|
arg_node = arg.node;
|
||||||
}
|
}
|
||||||
@@ -1571,7 +1571,7 @@ Unification_Result :: enum {
|
|||||||
Unification_Failure;
|
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);
|
lhs_var := h2tv(checker, lhs);
|
||||||
rhs_var := h2tv(checker, rhs);
|
rhs_var := h2tv(checker, rhs);
|
||||||
|
|
||||||
@@ -1580,6 +1580,7 @@ types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rh
|
|||||||
case .Half; #through;
|
case .Half; #through;
|
||||||
case .Float; #through;
|
case .Float; #through;
|
||||||
case .Double; {
|
case .Double; {
|
||||||
|
if !param_matching {
|
||||||
if rhs_var.type == .Struct {
|
if rhs_var.type == .Struct {
|
||||||
if rhs_var.typename == {
|
if rhs_var.typename == {
|
||||||
case "float2"; #through;
|
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 ||
|
return rhs_var.type == .Int || rhs_var.type == .Half ||
|
||||||
rhs_var.type == .Float || rhs_var.type == .Double;
|
rhs_var.type == .Float || rhs_var.type == .Double;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cbuffer __PROPERTIES : register(b0)
|
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
|
float4 ps_main() : SV_TARGET
|
||||||
{
|
{
|
||||||
return color;
|
return __PROPERTIES__color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cbuffer __PROPERTIES : register(b0)
|
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
|
float4 ps_main() : SV_TARGET
|
||||||
{
|
{
|
||||||
return color;
|
return __PROPERTIES__color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ test/empty_struct.shd semant
|
|||||||
test/empty_vertex_main.shd semant
|
test/empty_vertex_main.shd semant
|
||||||
test/empty_vertex_main_with_position_parameter.shd semant
|
test/empty_vertex_main_with_position_parameter.shd semant
|
||||||
test/field_assignment.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.shd semant
|
||||||
test/function_call_out_of_order_declaration.shd semant
|
test/function_call_out_of_order_declaration.shd semant
|
||||||
test/function_call_return.shd semant
|
test/function_call_return.shd semant
|
||||||
|
|||||||
Reference in New Issue
Block a user