Skip to content

Commit

Permalink
Rename LoopContinue to IncrementLoopIteration
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 25, 2023
1 parent 04b7b21 commit b653639
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions boa_engine/src/bytecompiler/statement/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ByteCompiler<'_, '_> {
}
}

self.emit_opcode(Opcode::LoopContinue);
self.emit_opcode(Opcode::IncrementLoopIteration);

if let Some(final_expr) = for_loop.final_expr() {
self.compile_expr(final_expr, false);
Expand Down Expand Up @@ -154,7 +154,7 @@ impl ByteCompiler<'_, '_> {

let start_address = self.next_opcode_location();
self.push_loop_control_info_for_of_in_loop(label, start_address, use_expr);
self.emit_opcode(Opcode::LoopContinue);
self.emit_opcode(Opcode::IncrementLoopIteration);

self.emit_opcode(Opcode::IteratorNext);
self.emit_opcode(Opcode::IteratorDone);
Expand Down Expand Up @@ -277,7 +277,7 @@ impl ByteCompiler<'_, '_> {
} else {
self.push_loop_control_info_for_of_in_loop(label, start_address, use_expr);
}
self.emit_opcode(Opcode::LoopContinue);
self.emit_opcode(Opcode::IncrementLoopIteration);

self.emit_opcode(Opcode::IteratorNext);
if for_of_loop.r#await() {
Expand Down Expand Up @@ -409,7 +409,7 @@ impl ByteCompiler<'_, '_> {
use_expr: bool,
) {
let start_address = self.next_opcode_location();
self.emit_opcode(Opcode::LoopContinue);
self.emit_opcode(Opcode::IncrementLoopIteration);
self.push_loop_control_info(label, start_address, use_expr);

self.compile_expr(while_loop.condition(), true);
Expand All @@ -436,7 +436,7 @@ impl ByteCompiler<'_, '_> {
self.push_loop_control_info(label, start_address, use_expr);

let condition_label_address = self.next_opcode_location();
self.emit_opcode(Opcode::LoopContinue);
self.emit_opcode(Opcode::IncrementLoopIteration);
self.compile_expr(do_while_loop.cond(), true);
let exit = self.jump_if_false();

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ impl CodeBlock {
| Opcode::Super
| Opcode::Return
| Opcode::PopEnvironment
| Opcode::LoopContinue
| Opcode::IncrementLoopIteration
| Opcode::CreateForInIterator
| Opcode::GetIterator
| Opcode::GetAsyncIterator
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/flowgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl CodeBlock {
| Opcode::ToBoolean
| Opcode::This
| Opcode::Super
| Opcode::LoopContinue
| Opcode::IncrementLoopIteration
| Opcode::CreateForInIterator
| Opcode::GetIterator
| Opcode::GetAsyncIterator
Expand Down
12 changes: 6 additions & 6 deletions boa_engine/src/vm/opcode/iteration/loop_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use crate::{
Context, JsResult,
};

/// `LoopContinue` implements the Opcode Operation for `Opcode::LoopContinue`.
/// `IncrementLoopIteration` implements the Opcode Operation for `Opcode::IncrementLoopIteration`.
///
/// Operation:
/// - Pushes a clean environment onto the frame's `EnvEntryStack`.
/// - Increment loop itearation count.
#[derive(Debug, Clone, Copy)]
pub(crate) struct LoopContinue;
pub(crate) struct IncrementLoopIteration;

impl Operation for LoopContinue {
const NAME: &'static str = "LoopContinue";
const INSTRUCTION: &'static str = "INST - LoopContinue";
impl Operation for IncrementLoopIteration {
const NAME: &'static str = "IncrementLoopIteration";
const INSTRUCTION: &'static str = "INST - IncrementLoopIteration";

fn execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
let previous_iteration_count = context.vm.frame_mut().loop_iteration_count;
Expand Down
6 changes: 4 additions & 2 deletions boa_engine/src/vm/opcode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,12 +1368,14 @@ generate_impl! {
/// Stack: **=>**
PopEnvironment,

/// Clean up environments when a loop continues.
/// Increment loop itearation count.
///
/// Used for limiting the loop iteration.
///
/// Operands:
///
/// Stack: **=>**
LoopContinue,
IncrementLoopIteration,

/// Creates the ForInIterator of an object.
///
Expand Down

0 comments on commit b653639

Please sign in to comment.