Fix function overload resolution. Add static array not working.

This commit is contained in:
2024-06-25 08:54:02 +02:00
parent d2614b3ba9
commit 3bbbc1d556
6 changed files with 161 additions and 89 deletions

View File

@@ -151,10 +151,9 @@ emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, e
indent(state, indentation);
if function_variable.return_var {
return_variable := h2tv(state.type_variables, function_variable.return_var);
if function_variable.return_type_variable {
return_variable := h2tv(state.type_variables, function_variable.return_type_variable);
print_to_builder(*state.builder, "% ", type_to_string(return_variable));
print("shiet: %\n", return_variable.*);
} else {
append(*state.builder, "void ");
}
@@ -319,6 +318,57 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
}
}
emit_field_list :: (state : *Codegen_State, field_list : *AST_Node, indentation : int) {
for child : field_list.children {
emit_node(state, child, 1);
if it_index < field_list.children.count {
append(*state.builder, ";\n");
}
}
}
emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
print_to_builder(*state.builder, "struct %", node.name);
current_scope := state.current_scope;
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
field_list := node.children[0];
if field_list.children.count > 0 {
append(*state.builder, "\n{\n");
} else {
append(*state.builder, " {");
}
emit_field_list(state, field_list, indentation);
append(*state.builder, "}\n\n");
state.current_scope = current_scope;
}
emit_cbuffer :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
variable := h2tv(state.type_variables, node.type_variable);
print_to_builder(*state.builder, "cbuffer % : register(b%)", variable.name, variable.buffer_index);
current_scope := state.current_scope;
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
field_list := node.children[0];
if field_list.children.count > 0 {
append(*state.builder, "\n{\n");
} else {
append(*state.builder, " {");
}
emit_field_list(state, field_list, indentation);
append(*state.builder, "}\n\n");
state.current_scope = current_scope;
}
emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
if node.kind == {
case .Function; {
@@ -327,31 +377,11 @@ emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
case .Properties; {
emit_properties(state, node, 0);
}
case .CBuffer; {
emit_cbuffer(state, node, 0);
}
case .Struct; {
print_to_builder(*state.builder, "struct %", node.name);
current_scope := state.current_scope;
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
field_list := node.children[0];
if field_list.children.count > 0 {
append(*state.builder, "\n{\n");
} else {
append(*state.builder, " {");
}
for child : field_list.children {
emit_node(state, child, 1);
if it_index < field_list.children.count {
append(*state.builder, ";\n");
}
}
append(*state.builder, "}\n\n");
state.current_scope = current_scope;
emit_struct(state, node, 0);
}
}
}