Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed May 7, 2023
1 parent 58dbd4c commit d547395
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions boa_engine/src/vm/call_frame/env_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ impl EnvStackEntry {
}

/// Set the loop return value for the current `EnvStackEntry`.
pub(crate) fn set_loop_return_value(&mut self, value: &JsValue) -> bool {
pub(crate) fn set_loop_return_value(&mut self, value: JsValue) -> bool {
if let EnvEntryKind::Loop { value: v, .. } = &mut self.kind {
*v = value.clone();
*v = value;
true
} else {
false
Expand Down
6 changes: 3 additions & 3 deletions boa_engine/src/vm/opcode/control_flow/break.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ impl Operation for Break {
};

if found_target {
set_loop_result = env_entry.set_loop_return_value(&value);
set_loop_result = env_entry.set_loop_return_value(value.clone());
continue;
}

if (jump_address == env_entry.exit_address())
|| (env_entry.is_finally_env() && jump_address == env_entry.start_address())
{
found_target = true;
set_loop_result = env_entry.set_loop_return_value(&value);
set_loop_result = env_entry.set_loop_return_value(value.clone());
continue;
}

// Checks for the break if we have jumped from inside of a finally block
if jump_address == env_entry.exit_address() {
found_target = true;
set_loop_result = env_entry.set_loop_return_value(&value);
set_loop_result = env_entry.set_loop_return_value(value.clone());
continue;
}
envs_to_pop += env_entry.env_num();
Expand Down
6 changes: 3 additions & 3 deletions boa_engine/src/vm/opcode/control_flow/continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Operation for Continue {
};

if found_target {
set_loop_result = env_entry.set_loop_return_value(&value);
set_loop_result = env_entry.set_loop_return_value(value.clone());
continue;
}

Expand All @@ -48,15 +48,15 @@ impl Operation for Continue {
|| (jump_address == target_address && jump_address == env_entry.start_address())
{
found_target = true;
set_loop_result = env_entry.set_loop_return_value(&value);
set_loop_result = env_entry.set_loop_return_value(value.clone());
continue;
}

envs_to_pop += env_entry.env_num();
// The below check determines whether we have continued from inside of a finally block.
if jump_address > target_address && jump_address == env_entry.exit_address() {
found_target = true;
set_loop_result = env_entry.set_loop_return_value(&value);
set_loop_result = env_entry.set_loop_return_value(value.clone());
context.vm.frame_mut().env_stack.pop();
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions boa_engine/src/vm/opcode/iteration/loop_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ impl Operation for LoopEnd {
const INSTRUCTION: &'static str = "INST - LoopEnd";

fn execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
//cleanup_loop_environment(context);
let mut envs_to_pop = 0_usize;
while let Some(env_entry) = context.vm.frame_mut().env_stack.pop() {
envs_to_pop += env_entry.env_num();
Expand Down Expand Up @@ -118,7 +117,7 @@ impl Operation for LoopUpdateReturnValue {
.env_stack
.last_mut()
.expect("loop environment must be present")
.set_loop_return_value(&value);
.set_loop_return_value(value);
Ok(CompletionType::Normal)
}
}

0 comments on commit d547395

Please sign in to comment.