Skip to content

Commit

Permalink
Make if statements return their completion values
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed Mar 25, 2023
1 parent 8d16940 commit 823028a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions boa_engine/src/bytecompiler/statement/if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::bytecompiler::ByteCompiler;
use boa_ast::statement::If;

impl ByteCompiler<'_, '_> {
pub(crate) fn compile_if(&mut self, node: &If, configurable_globals: bool) {
pub(crate) fn compile_if(&mut self, node: &If, use_expr: bool, configurable_globals: bool) {
self.compile_expr(node.cond(), true);
let jelse = self.jump_if_false();

self.compile_stmt(node.body(), false, configurable_globals);
self.compile_stmt(node.body(), use_expr, configurable_globals);

match node.else_node() {
None => {
Expand All @@ -15,7 +15,7 @@ impl ByteCompiler<'_, '_> {
Some(else_body) => {
let exit = self.jump();
self.patch_jump(jelse);
self.compile_stmt(else_body, false, configurable_globals);
self.compile_stmt(else_body, use_expr, configurable_globals);
self.patch_jump(exit);
}
}
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/bytecompiler/statement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl ByteCompiler<'_, '_> {
pub fn compile_stmt(&mut self, node: &Statement, use_expr: bool, configurable_globals: bool) {
match node {
Statement::Var(var) => self.compile_var_decl(var),
Statement::If(node) => self.compile_if(node, configurable_globals),
Statement::If(node) => self.compile_if(node, use_expr, configurable_globals),
Statement::ForLoop(for_loop) => {
self.compile_for_loop(for_loop, None, configurable_globals);
}
Expand Down

0 comments on commit 823028a

Please sign in to comment.