1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

Function call flattening bugfix

This commit is contained in:
Jacob Eberhardt 2017-10-28 14:10:51 +02:00
parent 572250a4ad
commit 884c71c288

View file

@ -471,19 +471,24 @@ impl Flattener {
Statement::Return(x) => { Statement::Return(x) => {
let result = x.apply_substitution(&temp_substitution) let result = x.apply_substitution(&temp_substitution)
.apply_substitution(&self.substitution); .apply_substitution(&self.substitution);
println!("substitutions:\n {:?}", &self.substitution);
return result; return result;
} }
Statement::Definition(var, rhs) => { Statement::Definition(var, rhs) => {
let new_rhs = rhs.apply_substitution(&temp_substitution) let new_rhs = rhs.apply_substitution(&temp_substitution)
.apply_substitution(&self.substitution); .apply_substitution(&self.substitution);
let subsvar = self.use_variable(&var);
temp_substitution.insert(var.clone(), subsvar.clone());
statements_flattened.push( statements_flattened.push(
Statement::Definition(self.use_variable(&var), new_rhs), Statement::Definition(subsvar, new_rhs),
); );
} }
Statement::Compiler(var, rhs) => { Statement::Compiler(var, rhs) => {
let new_rhs = rhs.apply_substitution(&temp_substitution) let new_rhs = rhs.apply_substitution(&temp_substitution)
.apply_substitution(&self.substitution); .apply_substitution(&self.substitution);
statements_flattened.push(Statement::Compiler(self.use_variable(&var), new_rhs)); let subsvar = self.use_variable(&var);
temp_substitution.insert(var.clone(), subsvar.clone());
statements_flattened.push(Statement::Compiler(subsvar, new_rhs));
} }
Statement::Condition(lhs, rhs) => { Statement::Condition(lhs, rhs) => {
let new_lhs = lhs.apply_substitution(&temp_substitution) let new_lhs = lhs.apply_substitution(&temp_substitution)