[qfcc] Process block result even when independent

If the block's result is just a variable reference, it won't match any
expression in the block's list so it needs to be processed independently
in such cases. The `mix(genFType x, genFType y, float a)` inline now
gets as far as spir-v code gen although there are still many issues to
fix (parameter symbols, `return` handling, etc).
This commit is contained in:
Bill Currie 2024-12-11 18:24:23 +09:00
parent 5b13bcf11c
commit 5380c2b04c
2 changed files with 19 additions and 0 deletions

View file

@ -486,6 +486,18 @@ print_xvalue (dstring_t *dstr, const expr_t *e, int level, int id,
b, '=', a, e->loc.line);
}
static void
print_process (dstring_t *dstr, const expr_t *e, int level, int id,
const expr_t *next)
{
int indent = level * 2 + 2;
_print_expr (dstr, e->process.expr, level, id, next);
dasprintf (dstr, "%*se_%p -> \"e_%p\";\n", indent, "", e, e->process.expr);
dasprintf (dstr, "%*se_%p [label=\"%s\\n%d\"];\n", indent, "", e,
"<process>", e->loc.line);
}
static void
print_subexpr (dstring_t *dstr, const expr_t *e, int level, int id, const expr_t *next)
{
@ -947,6 +959,7 @@ _print_expr (dstring_t *dstr, const expr_t *e, int level, int id,
[ex_select] = print_select,
[ex_intrinsic] = print_intrinsic,
[ex_xvalue] = print_xvalue,
[ex_process] = print_process,
};
int indent = level * 2 + 2;

View file

@ -270,6 +270,12 @@ proc_block (const expr_t *expr, rua_ctx_t *ctx)
current_symtab = old_scope;
return err;
}
if (!result && expr->block.result) {
result = expr_process (expr->block.result, ctx);
if (is_error (result)) {
return result;
}
}
scoped_src_loc (expr);
auto block = new_block_expr (nullptr);