Multiple small fixes

- Foreign functions can now have names for parameters
- Fix property renaming crash
- Properly output texture sampling calls
This commit is contained in:
2024-06-28 08:56:13 +02:00
parent 402d9d67a4
commit 884444d25b
6 changed files with 319 additions and 282 deletions

View File

@@ -80,18 +80,40 @@ emit_block :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
emit_call :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
indent(state, indentation);
print_to_builder(*state.builder, "%(", node.name);
if node.children.count > 0 {
if node.name == "sample" {
assert(node.children.count > 0);
args := node.children[0];
for child : args.children {
emit_node(state, args.children[0], 0);
append(*state.builder, ".");
print_to_builder(*state.builder, "%(", node.name);
for i : 1..args.children.count - 1 {
child := args.children[i];
emit_node(state, child, 0);
if it_index != args.children.count - 1 {
if i != args.children.count - 1 {
append(*state.builder, ", ");
}
}
} else {
print_to_builder(*state.builder, "%(", node.name);
if node.children.count > 0 {
args := node.children[0];
for child : args.children {
emit_node(state, child, 0);
if it_index != args.children.count - 1 {
append(*state.builder, ", ");
}
}
}
}
append(*state.builder, ")");