codegen will not generate 'jmp' if 'if' and 'elsif' is the last condition
This commit is contained in:
parent
02148f4766
commit
9c9bb52818
|
@ -523,6 +523,8 @@ void nasal_codegen::conditional_gen(nasal_ast& ast)
|
||||||
gen(op_jmpfalse,0);
|
gen(op_jmpfalse,0);
|
||||||
block_gen(tmp.get_children()[1]);
|
block_gen(tmp.get_children()[1]);
|
||||||
jmp_label.push_back(exec_code.size());
|
jmp_label.push_back(exec_code.size());
|
||||||
|
// without 'else' the last condition doesn't need to jmp
|
||||||
|
if(i!=size-1)
|
||||||
gen(op_jmp,0);
|
gen(op_jmp,0);
|
||||||
exec_code[ptr].index=exec_code.size();
|
exec_code[ptr].index=exec_code.size();
|
||||||
}
|
}
|
||||||
|
@ -532,8 +534,8 @@ void nasal_codegen::conditional_gen(nasal_ast& ast)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(std::vector<int>::iterator j=jmp_label.begin();j!=jmp_label.end();++j)
|
for(std::vector<int>::iterator i=jmp_label.begin();i!=jmp_label.end();++i)
|
||||||
exec_code[*j].index=exec_code.size();
|
exec_code[*i].index=exec_code.size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue