Skip to content

Commit

Permalink
Apply review
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Sep 30, 2023
1 parent 58e3a7d commit 1fba8c2
Show file tree
Hide file tree
Showing 31 changed files with 128 additions and 128 deletions.
8 changes: 4 additions & 4 deletions boa_engine/src/bytecompiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {

match varying_kind {
VaryingOperandKind::U8 => {}
VaryingOperandKind::U16 => self.emit_opcode(Opcode::ModifierU16),
VaryingOperandKind::U32 => self.emit_opcode(Opcode::ModifierU32),
VaryingOperandKind::U16 => self.emit_opcode(Opcode::U16Operands),
VaryingOperandKind::U32 => self.emit_opcode(Opcode::U32Operands),
}
self.emit_opcode(opcode);
for operand in operands {
Expand All @@ -497,11 +497,11 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
self.emit_opcode(opcode);
self.emit_u8(operand);
} else if let Ok(operand) = u16::try_from(operand) {
self.emit_opcode(Opcode::ModifierU16);
self.emit_opcode(Opcode::U16Operands);
self.emit_opcode(opcode);
self.emit_u16(operand);
} else {
self.emit_opcode(Opcode::ModifierU32);
self.emit_opcode(Opcode::U32Operands);
self.emit_opcode(opcode);
self.emit_u32(operand);
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ impl CodeBlock {
| Instruction::SetReturnValue
| Instruction::Nop => String::new(),

Instruction::ModifierU16
| Instruction::ModifierU32
Instruction::U16Operands
| Instruction::U32Operands
| Instruction::Reserved1
| Instruction::Reserved2
| Instruction::Reserved3
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/flowgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ impl CodeBlock {
Instruction::Return => {
graph.add_node(previous_pc, NodeShape::Diamond, label.into(), Color::Red);
}
Instruction::ModifierU16
| Instruction::ModifierU32
Instruction::U16Operands
| Instruction::U32Operands
| Instruction::Reserved1
| Instruction::Reserved2
| Instruction::Reserved3
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/binary_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ impl Operation for InPrivate {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/vm/opcode/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ impl Operation for CallEval {
Self::operation(context, argument_count as usize)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let argument_count = context.vm.read::<u16>() as usize;
Self::operation(context, argument_count)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let argument_count = context.vm.read::<u32>();
Self::operation(context, argument_count as usize)
}
Expand Down Expand Up @@ -221,12 +221,12 @@ impl Operation for Call {
Self::operation(context, argument_count as usize)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let argument_count = context.vm.read::<u16>() as usize;
Self::operation(context, argument_count)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let argument_count = context.vm.read::<u32>();
Self::operation(context, argument_count as usize)
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/concat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ impl Operation for ConcatToString {
Self::operation(context, value_count)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let value_count = context.vm.read::<u16>() as usize;
Self::operation(context, value_count)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let value_count = context.vm.read::<u32>() as usize;
Self::operation(context, value_count)
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/control_flow/throw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ impl Operation for ThrowNewTypeError {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/copy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ impl Operation for CopyDataProperties {
Self::operation(context, excluded_key_count, excluded_key_count_computed)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let excluded_key_count = context.vm.read::<u16>() as usize;
let excluded_key_count_computed = context.vm.read::<u16>() as usize;
Self::operation(context, excluded_key_count, excluded_key_count_computed)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let excluded_key_count = context.vm.read::<u32>() as usize;
let excluded_key_count_computed = context.vm.read::<u32>() as usize;
Self::operation(context, excluded_key_count, excluded_key_count_computed)
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/vm/opcode/define/class/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ impl Operation for DefineClassStaticGetterByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down Expand Up @@ -129,12 +129,12 @@ impl Operation for DefineClassGetterByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/vm/opcode/define/class/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ impl Operation for DefineClassStaticMethodByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down Expand Up @@ -121,12 +121,12 @@ impl Operation for DefineClassMethodByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/vm/opcode/define/class/setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ impl Operation for DefineClassStaticSetterByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down Expand Up @@ -132,12 +132,12 @@ impl Operation for DefineClassSetterByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down
12 changes: 6 additions & 6 deletions boa_engine/src/vm/opcode/define/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ impl Operation for DefVar {
Self::operation(context, index as usize)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>();
Self::operation(context, index as usize)
}
Expand Down Expand Up @@ -88,12 +88,12 @@ impl Operation for DefInitVar {
Self::operation(context, index as usize)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>();
Self::operation(context, index as usize)
}
Expand Down Expand Up @@ -130,12 +130,12 @@ impl Operation for PutLexicalValue {
Self::operation(context, index as usize)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>();
Self::operation(context, index as usize)
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/define/own_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ impl Operation for DefineOwnPropertyByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/vm/opcode/delete/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ impl Operation for DeletePropertyByName {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down Expand Up @@ -103,12 +103,12 @@ impl Operation for DeleteName {
Self::operation(context, index as usize)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>();
Self::operation(context, index as usize)
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ impl Operation for SuperCall {
Self::operation(context, value_count)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let value_count = context.vm.read::<u16>() as usize;
Self::operation(context, value_count)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let value_count = context.vm.read::<u32>() as usize;
Self::operation(context, value_count)
}
Expand Down
16 changes: 8 additions & 8 deletions boa_engine/src/vm/opcode/get/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ impl Operation for GetArrowFunction {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down Expand Up @@ -66,12 +66,12 @@ impl Operation for GetAsyncArrowFunction {
Self::operation(context, index)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
Self::operation(context, index)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
Self::operation(context, index)
}
Expand Down Expand Up @@ -108,13 +108,13 @@ impl Operation for GetFunction {
Self::operation(context, index, method)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
let method = context.vm.read::<u8>() != 0;
Self::operation(context, index, method)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
let method = context.vm.read::<u8>() != 0;
Self::operation(context, index, method)
Expand Down Expand Up @@ -152,13 +152,13 @@ impl Operation for GetFunctionAsync {
Self::operation(context, index, method)
}

fn u16_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u16>() as usize;
let method = context.vm.read::<u8>() != 0;
Self::operation(context, index, method)
}

fn u32_execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult<CompletionType> {
let index = context.vm.read::<u32>() as usize;
let method = context.vm.read::<u8>() != 0;
Self::operation(context, index, method)
Expand Down
Loading

0 comments on commit 1fba8c2

Please sign in to comment.