Fix lvalue/rvalue binaries. Fix structured buffer output.

This commit is contained in:
2025-09-29 22:22:00 +02:00
parent 2e23b37405
commit 0c0e31db38
23 changed files with 244 additions and 103 deletions

View File

@@ -401,7 +401,7 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
indent(*state.builder, indentation);
if node.token.kind != .TOKEN_ASSIGN && node.token.kind != .TOKEN_LEFTBRACKET {
if node.parent.kind == .Binary && node.parent.token.kind != .TOKEN_ASSIGN {
if (node.parent.kind == .Binary && node.parent.token.kind != .TOKEN_ASSIGN) || node.parent.kind == .Access {
append(*state.builder, "(");
}
}
@@ -422,10 +422,8 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
emit_node(state, rhs, 0);
}
if node.token.kind != .TOKEN_ASSIGN && node.token.kind != .TOKEN_LEFTBRACKET {
if node.parent.kind == .Binary && node.parent.token.kind != .TOKEN_ASSIGN {
if (node.parent.kind == .Binary && node.parent.token.kind != .TOKEN_ASSIGN) || node.parent.kind == .Access {
append(*state.builder, ")");
}
}
@@ -577,10 +575,8 @@ emit_buffer :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
element := from_handle(state.ctx.type_variables, variable.element_type);
emit_struct(state, node, indentation, element.typename);
// print_to_builder(*state.builder, "struct %\n", element.name);
print_to_builder(*state.builder, "StructuredBuffer<%> % : register(t%);\n\n", element.typename, variable.name, variable.resource_index);
}
emit_declaration :: (state : *Codegen_State, node : *AST_Node) {