[glsl-in] Make sure functions ends with return

This commit is contained in:
Pelle Johnsen
2020-11-11 07:58:53 +00:00
committed by Dzmitry Malyshau
parent f8876dac73
commit 249e0bd4ac

View File

@@ -1092,12 +1092,17 @@ pomelo! {
}
}
function_definition ::= function_prototype(mut f) compound_statement_no_new_scope(cs) {
function_definition ::= function_prototype(mut f) compound_statement_no_new_scope(mut cs) {
std::mem::swap(&mut f.expressions, &mut extra.context.expressions);
std::mem::swap(&mut f.local_variables, &mut extra.context.local_variables);
extra.context.clear_scopes();
extra.context.lookup_global_var_exps.clear();
extra.context.typifier = Typifier::new();
// make sure function ends with return
match cs.last() {
Some(Statement::Return {..}) => {}
_ => {cs.push(Statement::Return { value:None });}
}
f.body = cs;
f.fill_global_use(&extra.module.global_variables);
f