Browse Source

Fixing build for changes in clippy for Rust 1.61 (#2082)

This fixes the CI after the upgrade to Rust 1.61. I had to "allow" the `use_self` lint, due to https://github.com/rust-lang/rust-clippy/issues/8845 and https://github.com/rust-lang/rust-clippy/issues/6902.

It removed some false negatives, though, so I fixed some of the usage.
pull/2081/head
Iban Eguia 3 years ago
parent
commit
456da4949a
  1. 60
      boa_engine/src/builtins/intl/tests.rs
  2. 24
      boa_engine/src/builtins/typed_array/mod.rs
  3. 3
      boa_engine/src/lib.rs
  4. 4
      boa_engine/src/syntax/ast/keyword.rs
  5. 30
      boa_engine/src/syntax/ast/node/declaration/mod.rs
  6. 10
      boa_engine/src/value/equality.rs
  7. 16
      boa_engine/src/value/integer.rs
  8. 79
      boa_engine/src/value/mod.rs
  9. 564
      boa_engine/src/vm/opcode.rs
  10. 2
      boa_tester/src/main.rs

60
boa_engine/src/builtins/intl/tests.rs

@ -28,7 +28,7 @@ fn best_avail_loc() {
); );
let locale_part = "fr".to_string(); let locale_part = "fr".to_string();
let no_extensions_locale = JsString::new(locale_part.clone() + &"-CA".to_string()); let no_extensions_locale = JsString::new(locale_part.clone() + "-CA");
let available_locales = vec![JsString::new(locale_part.clone())]; let available_locales = vec![JsString::new(locale_part.clone())];
assert_eq!( assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,), best_available_locale(&available_locales, &no_extensions_locale,),
@ -38,7 +38,7 @@ fn best_avail_loc() {
let ja_kana_t = JsString::new("ja-Kana-JP-t"); let ja_kana_t = JsString::new("ja-Kana-JP-t");
let ja_kana = JsString::new("ja-Kana-JP"); let ja_kana = JsString::new("ja-Kana-JP");
let no_extensions_locale = JsString::new("ja-Kana-JP-t-it-latn-it"); let no_extensions_locale = JsString::new("ja-Kana-JP-t-it-latn-it");
let available_locales = vec![ja_kana_t.clone(), ja_kana.clone()]; let available_locales = vec![ja_kana_t, ja_kana.clone()];
assert_eq!( assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,), best_available_locale(&available_locales, &no_extensions_locale,),
Some(ja_kana) Some(ja_kana)
@ -108,7 +108,7 @@ fn insert_unicode_ext() {
fn uni_ext_comp() { fn uni_ext_comp() {
let ext = JsString::new("-u-ca-japanese-hc-h12"); let ext = JsString::new("-u-ca-japanese-hc-h12");
let components = unicode_extension_components(&ext); let components = unicode_extension_components(&ext);
assert_eq!(components.attributes.is_empty(), true); assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 2); assert_eq!(components.keywords.len(), 2);
assert_eq!(components.keywords[0].key, "ca"); assert_eq!(components.keywords[0].key, "ca");
assert_eq!(components.keywords[0].value, "japanese"); assert_eq!(components.keywords[0].value, "japanese");
@ -126,7 +126,7 @@ fn uni_ext_comp() {
let ext = JsString::new("-u-ca-buddhist-kk-nu-thai"); let ext = JsString::new("-u-ca-buddhist-kk-nu-thai");
let components = unicode_extension_components(&ext); let components = unicode_extension_components(&ext);
assert_eq!(components.attributes.is_empty(), true); assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 3); assert_eq!(components.keywords.len(), 3);
assert_eq!(components.keywords[0].key, "ca"); assert_eq!(components.keywords[0].key, "ca");
assert_eq!(components.keywords[0].value, "buddhist"); assert_eq!(components.keywords[0].value, "buddhist");
@ -137,7 +137,7 @@ fn uni_ext_comp() {
let ext = JsString::new("-u-ca-islamic-civil"); let ext = JsString::new("-u-ca-islamic-civil");
let components = unicode_extension_components(&ext); let components = unicode_extension_components(&ext);
assert_eq!(components.attributes.is_empty(), true); assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 1); assert_eq!(components.keywords.len(), 1);
assert_eq!(components.keywords[0].key, "ca"); assert_eq!(components.keywords[0].key, "ca");
assert_eq!(components.keywords[0].value, "islamic-civil"); assert_eq!(components.keywords[0].value, "islamic-civil");
@ -167,7 +167,7 @@ fn locale_resolution() {
); );
assert_eq!(locale_record.locale, default_locale()); assert_eq!(locale_record.locale, default_locale());
assert_eq!(locale_record.data_locale, default_locale()); assert_eq!(locale_record.data_locale, default_locale());
assert_eq!(locale_record.properties.is_empty(), true); assert!(locale_record.properties.is_empty());
// test best fit // test best fit
let available_locales = Vec::<JsString>::new(); let available_locales = Vec::<JsString>::new();
@ -189,7 +189,7 @@ fn locale_resolution() {
); );
assert_eq!(locale_record.locale, default_locale()); assert_eq!(locale_record.locale, default_locale());
assert_eq!(locale_record.data_locale, default_locale()); assert_eq!(locale_record.data_locale, default_locale());
assert_eq!(locale_record.properties.is_empty(), true); assert!(locale_record.properties.is_empty());
// available: [es-ES], requested: [es-ES] // available: [es-ES], requested: [es-ES]
let available_locales = vec![JsString::new("es-ES")]; let available_locales = vec![JsString::new("es-ES")];
@ -211,7 +211,7 @@ fn locale_resolution() {
); );
assert_eq!(locale_record.locale, "es-ES"); assert_eq!(locale_record.locale, "es-ES");
assert_eq!(locale_record.data_locale, "es-ES"); assert_eq!(locale_record.data_locale, "es-ES");
assert_eq!(locale_record.properties.is_empty(), true); assert!(locale_record.properties.is_empty());
// available: [zh-CN], requested: [] // available: [zh-CN], requested: []
let available_locales = vec![JsString::new("zh-CN")]; let available_locales = vec![JsString::new("zh-CN")];
@ -233,7 +233,7 @@ fn locale_resolution() {
); );
assert_eq!(locale_record.locale, default_locale()); assert_eq!(locale_record.locale, default_locale());
assert_eq!(locale_record.data_locale, default_locale()); assert_eq!(locale_record.data_locale, default_locale());
assert_eq!(locale_record.properties.is_empty(), true); assert!(locale_record.properties.is_empty());
} }
#[test] #[test]
@ -319,7 +319,7 @@ fn get_opt() {
let other_locale_str = JsString::new("de-DE"); let other_locale_str = JsString::new("de-DE");
let values = vec![other_locale_str]; let values = vec![other_locale_str];
options_obj options_obj
.set("Locale", locale_value.clone(), true, &mut context) .set("Locale", locale_value, true, &mut context)
.expect("Setting a property should not fail"); .expect("Setting a property should not fail");
let option_type = GetOptionType::String; let option_type = GetOptionType::String;
let get_option_result = get_option( let get_option_result = get_option(
@ -330,7 +330,7 @@ fn get_opt() {
&fallback, &fallback,
&mut context, &mut context,
); );
assert_eq!(get_option_result.is_err(), true); assert!(get_option_result.is_err());
let value = JsValue::undefined(); let value = JsValue::undefined();
let minimum = 1.0; let minimum = 1.0;
@ -345,21 +345,21 @@ fn get_opt() {
let maximum = 10.0; let maximum = 10.0;
let fallback = Some(5.0); let fallback = Some(5.0);
let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context); let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result.is_err(), true); assert!(get_option_result.is_err());
let value = JsValue::new(0); let value = JsValue::new(0);
let minimum = 1.0; let minimum = 1.0;
let maximum = 10.0; let maximum = 10.0;
let fallback = Some(5.0); let fallback = Some(5.0);
let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context); let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result.is_err(), true); assert!(get_option_result.is_err());
let value = JsValue::new(11); let value = JsValue::new(11);
let minimum = 1.0; let minimum = 1.0;
let maximum = 10.0; let maximum = 10.0;
let fallback = Some(5.0); let fallback = Some(5.0);
let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context); let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result.is_err(), true); assert!(get_option_result.is_err());
let value_f64 = 7.0; let value_f64 = 7.0;
let value = JsValue::new(value_f64); let value = JsValue::new(value_f64);
@ -375,14 +375,8 @@ fn get_opt() {
let maximum = 10.0; let maximum = 10.0;
let fallback_val = 5.0; let fallback_val = 5.0;
let fallback = Some(fallback_val); let fallback = Some(fallback_val);
let get_option_result = get_number_option( let get_option_result =
&options, get_number_option(&options, property, minimum, maximum, fallback, &mut context);
&property,
minimum,
maximum,
fallback,
&mut context,
);
assert_eq!(get_option_result, Ok(fallback)); assert_eq!(get_option_result, Ok(fallback));
let options = JsObject::empty(); let options = JsObject::empty();
@ -390,19 +384,13 @@ fn get_opt() {
let value = JsValue::new(value_f64); let value = JsValue::new(value_f64);
let property = "fractionalSecondDigits"; let property = "fractionalSecondDigits";
options options
.set(property, value.clone(), true, &mut context) .set(property, value, true, &mut context)
.expect("Setting a property should not fail"); .expect("Setting a property should not fail");
let minimum = 1.0; let minimum = 1.0;
let maximum = 10.0; let maximum = 10.0;
let fallback = Some(5.0); let fallback = Some(5.0);
let get_option_result = get_number_option( let get_option_result =
&options, get_number_option(&options, property, minimum, maximum, fallback, &mut context);
&property,
minimum,
maximum,
fallback,
&mut context,
);
assert_eq!(get_option_result, Ok(Some(value_f64))); assert_eq!(get_option_result, Ok(Some(value_f64)));
} }
@ -420,7 +408,7 @@ fn to_date_time_opts() {
&DateTimeReqs::Date, &DateTimeReqs::Date,
&mut context, &mut context,
); );
assert_eq!(date_time_opts.is_err(), true); assert!(date_time_opts.is_err());
let options_obj = JsObject::empty(); let options_obj = JsObject::empty();
options_obj options_obj
@ -432,7 +420,7 @@ fn to_date_time_opts() {
&DateTimeReqs::Time, &DateTimeReqs::Time,
&mut context, &mut context,
); );
assert_eq!(date_time_opts.is_err(), true); assert!(date_time_opts.is_err());
let date_time_opts = to_date_time_options( let date_time_opts = to_date_time_options(
&JsValue::undefined(), &JsValue::undefined(),
@ -453,7 +441,7 @@ fn to_date_time_opts() {
); );
assert_eq!( assert_eq!(
date_time_opts.get("day", &mut context), date_time_opts.get("day", &mut context),
Ok(numeric_jsstring.clone()) Ok(numeric_jsstring)
); );
let date_time_opts = to_date_time_options( let date_time_opts = to_date_time_options(
@ -475,7 +463,7 @@ fn to_date_time_opts() {
); );
assert_eq!( assert_eq!(
date_time_opts.get("second", &mut context), date_time_opts.get("second", &mut context),
Ok(numeric_jsstring.clone()) Ok(numeric_jsstring)
); );
let date_time_opts = to_date_time_options( let date_time_opts = to_date_time_options(
@ -509,6 +497,6 @@ fn to_date_time_opts() {
); );
assert_eq!( assert_eq!(
date_time_opts.get("second", &mut context), date_time_opts.get("second", &mut context),
Ok(numeric_jsstring.clone()) Ok(numeric_jsstring)
); );
} }

24
boa_engine/src/builtins/typed_array/mod.rs

@ -3438,22 +3438,22 @@ impl TypedArrayKind {
#[inline] #[inline]
pub(crate) const fn name(&self) -> &str { pub(crate) const fn name(&self) -> &str {
match self { match self {
TypedArrayKind::Int8 => "Int8Array", Self::Int8 => "Int8Array",
TypedArrayKind::Uint8 => "Uint8Array", Self::Uint8 => "Uint8Array",
TypedArrayKind::Uint8Clamped => "Uint8ClampedArray", Self::Uint8Clamped => "Uint8ClampedArray",
TypedArrayKind::Int16 => "Int16Array", Self::Int16 => "Int16Array",
TypedArrayKind::Uint16 => "Uint16Array", Self::Uint16 => "Uint16Array",
TypedArrayKind::Int32 => "Int32Array", Self::Int32 => "Int32Array",
TypedArrayKind::Uint32 => "Uint32Array", Self::Uint32 => "Uint32Array",
TypedArrayKind::BigInt64 => "BigInt64Array", Self::BigInt64 => "BigInt64Array",
TypedArrayKind::BigUint64 => "BigUint64Array", Self::BigUint64 => "BigUint64Array",
TypedArrayKind::Float32 => "Float32Array", Self::Float32 => "Float32Array",
TypedArrayKind::Float64 => "Float64Array", Self::Float64 => "Float64Array",
} }
} }
pub(crate) fn is_big_int_element_type(self) -> bool { pub(crate) fn is_big_int_element_type(self) -> bool {
matches!(self, TypedArrayKind::BigUint64 | TypedArrayKind::BigInt64) matches!(self, Self::BigUint64 | Self::BigInt64)
} }
} }

3
boa_engine/src/lib.rs

@ -26,7 +26,6 @@
clippy::all, clippy::all,
clippy::cast_lossless, clippy::cast_lossless,
clippy::redundant_closure_for_method_calls, clippy::redundant_closure_for_method_calls,
clippy::use_self,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::trivially_copy_pass_by_ref, clippy::trivially_copy_pass_by_ref,
clippy::needless_pass_by_value, clippy::needless_pass_by_value,
@ -49,6 +48,7 @@
nonstandard_style, nonstandard_style,
)] )]
#![allow( #![allow(
clippy::use_self, // TODO: deny once false positives are fixed
clippy::module_name_repetitions, clippy::module_name_repetitions,
clippy::cast_possible_truncation, clippy::cast_possible_truncation,
clippy::cast_sign_loss, clippy::cast_sign_loss,
@ -99,7 +99,6 @@ pub use crate::{
}; };
/// The result of a Javascript expression is represented like this so it can succeed (`Ok`) or fail (`Err`) /// The result of a Javascript expression is represented like this so it can succeed (`Ok`) or fail (`Err`)
#[must_use]
pub type JsResult<T> = StdResult<T, JsValue>; pub type JsResult<T> = StdResult<T, JsValue>;
/// Execute the code using an existing `Context`. /// Execute the code using an existing `Context`.

4
boa_engine/src/syntax/ast/keyword.rs

@ -485,8 +485,8 @@ impl Keyword {
/// Gets the keyword as a binary operation, if this keyword is the `in` keyword. /// Gets the keyword as a binary operation, if this keyword is the `in` keyword.
pub fn as_binop(self) -> Option<BinOp> { pub fn as_binop(self) -> Option<BinOp> {
match self { match self {
Keyword::In => Some(BinOp::Comp(CompOp::In)), Self::In => Some(BinOp::Comp(CompOp::In)),
Keyword::InstanceOf => Some(BinOp::Comp(CompOp::InstanceOf)), Self::InstanceOf => Some(BinOp::Comp(CompOp::InstanceOf)),
_ => None, _ => None,
} }
} }

30
boa_engine/src/syntax/ast/node/declaration/mod.rs

@ -546,8 +546,8 @@ pub enum BindingPatternTypeObject {
impl ToInternedString for BindingPatternTypeObject { impl ToInternedString for BindingPatternTypeObject {
fn to_interned_string(&self, interner: &Interner) -> String { fn to_interned_string(&self, interner: &Interner) -> String {
match self { match self {
BindingPatternTypeObject::Empty => String::new(), Self::Empty => String::new(),
BindingPatternTypeObject::SingleName { Self::SingleName {
ident, ident,
property_name, property_name,
default_init, default_init,
@ -576,18 +576,18 @@ impl ToInternedString for BindingPatternTypeObject {
} }
buf buf
} }
BindingPatternTypeObject::RestProperty { Self::RestProperty {
ident: property_name, ident: property_name,
excluded_keys: _, excluded_keys: _,
} => { } => {
format!(" ... {}", interner.resolve_expect(*property_name)) format!(" ... {}", interner.resolve_expect(*property_name))
} }
BindingPatternTypeObject::RestGetConstField { Self::RestGetConstField {
get_const_field, .. get_const_field, ..
} => { } => {
format!(" ... {}", get_const_field.to_interned_string(interner)) format!(" ... {}", get_const_field.to_interned_string(interner))
} }
BindingPatternTypeObject::BindingPattern { Self::BindingPattern {
ident: property_name, ident: property_name,
pattern, pattern,
default_init, default_init,
@ -733,9 +733,9 @@ pub enum BindingPatternTypeArray {
impl ToInternedString for BindingPatternTypeArray { impl ToInternedString for BindingPatternTypeArray {
fn to_interned_string(&self, interner: &Interner) -> String { fn to_interned_string(&self, interner: &Interner) -> String {
match self { match self {
BindingPatternTypeArray::Empty => String::new(), Self::Empty => String::new(),
BindingPatternTypeArray::Elision => " ".to_owned(), Self::Elision => " ".to_owned(),
BindingPatternTypeArray::SingleName { Self::SingleName {
ident, ident,
default_init, default_init,
} => { } => {
@ -745,25 +745,25 @@ impl ToInternedString for BindingPatternTypeArray {
} }
buf buf
} }
BindingPatternTypeArray::GetField { get_field } => { Self::GetField { get_field } => {
format!(" {}", get_field.to_interned_string(interner)) format!(" {}", get_field.to_interned_string(interner))
} }
BindingPatternTypeArray::GetConstField { get_const_field } => { Self::GetConstField { get_const_field } => {
format!(" {}", get_const_field.to_interned_string(interner)) format!(" {}", get_const_field.to_interned_string(interner))
} }
BindingPatternTypeArray::BindingPattern { pattern } => { Self::BindingPattern { pattern } => {
format!(" {}", pattern.to_interned_string(interner)) format!(" {}", pattern.to_interned_string(interner))
} }
BindingPatternTypeArray::SingleNameRest { ident } => { Self::SingleNameRest { ident } => {
format!(" ... {}", interner.resolve_expect(*ident)) format!(" ... {}", interner.resolve_expect(*ident))
} }
BindingPatternTypeArray::GetFieldRest { get_field } => { Self::GetFieldRest { get_field } => {
format!(" ... {}", get_field.to_interned_string(interner)) format!(" ... {}", get_field.to_interned_string(interner))
} }
BindingPatternTypeArray::GetConstFieldRest { get_const_field } => { Self::GetConstFieldRest { get_const_field } => {
format!(" ... {}", get_const_field.to_interned_string(interner)) format!(" ... {}", get_const_field.to_interned_string(interner))
} }
BindingPatternTypeArray::BindingPatternRest { pattern } => { Self::BindingPatternRest { pattern } => {
format!(" ... {}", pattern.to_interned_string(interner)) format!(" ... {}", pattern.to_interned_string(interner))
} }
} }

10
boa_engine/src/value/equality.rs

@ -189,11 +189,11 @@ impl JsValue {
fn same_value_non_numeric(x: &Self, y: &Self) -> bool { fn same_value_non_numeric(x: &Self, y: &Self) -> bool {
debug_assert!(x.get_type() == y.get_type()); debug_assert!(x.get_type() == y.get_type());
match (x, y) { match (x, y) {
(JsValue::Null, JsValue::Null) | (JsValue::Undefined, JsValue::Undefined) => true, (Self::Null, Self::Null) | (Self::Undefined, Self::Undefined) => true,
(JsValue::String(ref x), JsValue::String(ref y)) => x == y, (Self::String(ref x), Self::String(ref y)) => x == y,
(JsValue::Boolean(x), JsValue::Boolean(y)) => x == y, (Self::Boolean(x), Self::Boolean(y)) => x == y,
(JsValue::Object(ref x), JsValue::Object(ref y)) => JsObject::equals(x, y), (Self::Object(ref x), Self::Object(ref y)) => JsObject::equals(x, y),
(JsValue::Symbol(ref x), JsValue::Symbol(ref y)) => x == y, (Self::Symbol(ref x), Self::Symbol(ref y)) => x == y,
_ => false, _ => false,
} }
} }

16
boa_engine/src/value/integer.rs

@ -15,16 +15,16 @@ impl IntegerOrInfinity {
assert!(min <= max); assert!(min <= max);
match self { match self {
IntegerOrInfinity::Integer(i) => i.clamp(min, max), Self::Integer(i) => i.clamp(min, max),
IntegerOrInfinity::PositiveInfinity => max, Self::PositiveInfinity => max,
IntegerOrInfinity::NegativeInfinity => min, Self::NegativeInfinity => min,
} }
} }
/// Gets the wrapped `i64` if the variant is an `Integer`. /// Gets the wrapped `i64` if the variant is an `Integer`.
pub fn as_integer(self) -> Option<i64> { pub fn as_integer(self) -> Option<i64> {
match self { match self {
IntegerOrInfinity::Integer(i) => Some(i), Self::Integer(i) => Some(i),
_ => None, _ => None,
} }
} }
@ -33,7 +33,7 @@ impl IntegerOrInfinity {
impl PartialEq<i64> for IntegerOrInfinity { impl PartialEq<i64> for IntegerOrInfinity {
fn eq(&self, other: &i64) -> bool { fn eq(&self, other: &i64) -> bool {
match self { match self {
IntegerOrInfinity::Integer(i) => i == other, Self::Integer(i) => i == other,
_ => false, _ => false,
} }
} }
@ -51,9 +51,9 @@ impl PartialEq<IntegerOrInfinity> for i64 {
impl PartialOrd<i64> for IntegerOrInfinity { impl PartialOrd<i64> for IntegerOrInfinity {
fn partial_cmp(&self, other: &i64) -> Option<Ordering> { fn partial_cmp(&self, other: &i64) -> Option<Ordering> {
match self { match self {
IntegerOrInfinity::PositiveInfinity => Some(Ordering::Greater), Self::PositiveInfinity => Some(Ordering::Greater),
IntegerOrInfinity::Integer(i) => i.partial_cmp(other), Self::Integer(i) => i.partial_cmp(other),
IntegerOrInfinity::NegativeInfinity => Some(Ordering::Less), Self::NegativeInfinity => Some(Ordering::Less),
} }
} }
} }

79
boa_engine/src/value/mod.rs

@ -278,7 +278,6 @@ impl JsValue {
/// [spec]: https://tc39.es/ecma262/#sec-toboolean /// [spec]: https://tc39.es/ecma262/#sec-toboolean
pub fn to_boolean(&self) -> bool { pub fn to_boolean(&self) -> bool {
match *self { match *self {
Self::Undefined | Self::Null => false,
Self::Symbol(_) | Self::Object(_) => true, Self::Symbol(_) | Self::Object(_) => true,
Self::String(ref s) if !s.is_empty() => true, Self::String(ref s) if !s.is_empty() => true,
Self::Rational(n) if n != 0.0 && !n.is_nan() => true, Self::Rational(n) if n != 0.0 && !n.is_nan() => true,
@ -387,9 +386,9 @@ impl JsValue {
/// [spec]: https://tc39.es/ecma262/#sec-tobigint /// [spec]: https://tc39.es/ecma262/#sec-tobigint
pub fn to_bigint(&self, context: &mut Context) -> JsResult<JsBigInt> { pub fn to_bigint(&self, context: &mut Context) -> JsResult<JsBigInt> {
match self { match self {
JsValue::Null => context.throw_type_error("cannot convert null to a BigInt"), Self::Null => context.throw_type_error("cannot convert null to a BigInt"),
JsValue::Undefined => context.throw_type_error("cannot convert undefined to a BigInt"), Self::Undefined => context.throw_type_error("cannot convert undefined to a BigInt"),
JsValue::String(ref string) => { Self::String(ref string) => {
if let Some(value) = JsBigInt::from_string(string) { if let Some(value) = JsBigInt::from_string(string) {
Ok(value) Ok(value)
} else { } else {
@ -398,17 +397,17 @@ impl JsValue {
)) ))
} }
} }
JsValue::Boolean(true) => Ok(JsBigInt::one()), Self::Boolean(true) => Ok(JsBigInt::one()),
JsValue::Boolean(false) => Ok(JsBigInt::zero()), Self::Boolean(false) => Ok(JsBigInt::zero()),
JsValue::Integer(_) | JsValue::Rational(_) => { Self::Integer(_) | Self::Rational(_) => {
context.throw_type_error("cannot convert Number to a BigInt") context.throw_type_error("cannot convert Number to a BigInt")
} }
JsValue::BigInt(b) => Ok(b.clone()), Self::BigInt(b) => Ok(b.clone()),
JsValue::Object(_) => { Self::Object(_) => {
let primitive = self.to_primitive(context, PreferredType::Number)?; let primitive = self.to_primitive(context, PreferredType::Number)?;
primitive.to_bigint(context) primitive.to_bigint(context)
} }
JsValue::Symbol(_) => context.throw_type_error("cannot convert Symbol to a BigInt"), Self::Symbol(_) => context.throw_type_error("cannot convert Symbol to a BigInt"),
} }
} }
@ -439,15 +438,15 @@ impl JsValue {
/// This function is equivalent to `String(value)` in JavaScript. /// This function is equivalent to `String(value)` in JavaScript.
pub fn to_string(&self, context: &mut Context) -> JsResult<JsString> { pub fn to_string(&self, context: &mut Context) -> JsResult<JsString> {
match self { match self {
JsValue::Null => Ok("null".into()), Self::Null => Ok("null".into()),
JsValue::Undefined => Ok("undefined".into()), Self::Undefined => Ok("undefined".into()),
JsValue::Boolean(boolean) => Ok(boolean.to_string().into()), Self::Boolean(boolean) => Ok(boolean.to_string().into()),
JsValue::Rational(rational) => Ok(Number::to_native_string(*rational).into()), Self::Rational(rational) => Ok(Number::to_native_string(*rational).into()),
JsValue::Integer(integer) => Ok(integer.to_string().into()), Self::Integer(integer) => Ok(integer.to_string().into()),
JsValue::String(string) => Ok(string.clone()), Self::String(string) => Ok(string.clone()),
JsValue::Symbol(_) => context.throw_type_error("can't convert symbol to string"), Self::Symbol(_) => context.throw_type_error("can't convert symbol to string"),
JsValue::BigInt(ref bigint) => Ok(bigint.to_string().into()), Self::BigInt(ref bigint) => Ok(bigint.to_string().into()),
JsValue::Object(_) => { Self::Object(_) => {
let primitive = self.to_primitive(context, PreferredType::String)?; let primitive = self.to_primitive(context, PreferredType::String)?;
primitive.to_string(context) primitive.to_string(context)
} }
@ -461,31 +460,31 @@ impl JsValue {
/// See: <https://tc39.es/ecma262/#sec-toobject> /// See: <https://tc39.es/ecma262/#sec-toobject>
pub fn to_object(&self, context: &mut Context) -> JsResult<JsObject> { pub fn to_object(&self, context: &mut Context) -> JsResult<JsObject> {
match self { match self {
JsValue::Undefined | JsValue::Null => { Self::Undefined | Self::Null => {
context.throw_type_error("cannot convert 'null' or 'undefined' to object") context.throw_type_error("cannot convert 'null' or 'undefined' to object")
} }
JsValue::Boolean(boolean) => { Self::Boolean(boolean) => {
let prototype = context.intrinsics().constructors().boolean().prototype(); let prototype = context.intrinsics().constructors().boolean().prototype();
Ok(JsObject::from_proto_and_data( Ok(JsObject::from_proto_and_data(
prototype, prototype,
ObjectData::boolean(*boolean), ObjectData::boolean(*boolean),
)) ))
} }
JsValue::Integer(integer) => { Self::Integer(integer) => {
let prototype = context.intrinsics().constructors().number().prototype(); let prototype = context.intrinsics().constructors().number().prototype();
Ok(JsObject::from_proto_and_data( Ok(JsObject::from_proto_and_data(
prototype, prototype,
ObjectData::number(f64::from(*integer)), ObjectData::number(f64::from(*integer)),
)) ))
} }
JsValue::Rational(rational) => { Self::Rational(rational) => {
let prototype = context.intrinsics().constructors().number().prototype(); let prototype = context.intrinsics().constructors().number().prototype();
Ok(JsObject::from_proto_and_data( Ok(JsObject::from_proto_and_data(
prototype, prototype,
ObjectData::number(*rational), ObjectData::number(*rational),
)) ))
} }
JsValue::String(ref string) => { Self::String(ref string) => {
let prototype = context.intrinsics().constructors().string().prototype(); let prototype = context.intrinsics().constructors().string().prototype();
let object = let object =
@ -501,14 +500,14 @@ impl JsValue {
); );
Ok(object) Ok(object)
} }
JsValue::Symbol(ref symbol) => { Self::Symbol(ref symbol) => {
let prototype = context.intrinsics().constructors().symbol().prototype(); let prototype = context.intrinsics().constructors().symbol().prototype();
Ok(JsObject::from_proto_and_data( Ok(JsObject::from_proto_and_data(
prototype, prototype,
ObjectData::symbol(symbol.clone()), ObjectData::symbol(symbol.clone()),
)) ))
} }
JsValue::BigInt(ref bigint) => { Self::BigInt(ref bigint) => {
let prototype = context let prototype = context
.intrinsics() .intrinsics()
.constructors() .constructors()
@ -519,7 +518,7 @@ impl JsValue {
ObjectData::big_int(bigint.clone()), ObjectData::big_int(bigint.clone()),
)) ))
} }
JsValue::Object(jsobject) => Ok(jsobject.clone()), Self::Object(jsobject) => Ok(jsobject.clone()),
} }
} }
@ -529,12 +528,12 @@ impl JsValue {
pub fn to_property_key(&self, context: &mut Context) -> JsResult<PropertyKey> { pub fn to_property_key(&self, context: &mut Context) -> JsResult<PropertyKey> {
Ok(match self { Ok(match self {
// Fast path: // Fast path:
JsValue::String(string) => string.clone().into(), Self::String(string) => string.clone().into(),
JsValue::Symbol(symbol) => symbol.clone().into(), Self::Symbol(symbol) => symbol.clone().into(),
// Slow path: // Slow path:
_ => match self.to_primitive(context, PreferredType::String)? { _ => match self.to_primitive(context, PreferredType::String)? {
JsValue::String(ref string) => string.clone().into(), Self::String(ref string) => string.clone().into(),
JsValue::Symbol(ref symbol) => symbol.clone().into(), Self::Symbol(ref symbol) => symbol.clone().into(),
primitive => primitive.to_string(context)?.into(), primitive => primitive.to_string(context)?.into(),
}, },
}) })
@ -853,15 +852,15 @@ impl JsValue {
/// See: <https://tc39.es/ecma262/#sec-tonumber> /// See: <https://tc39.es/ecma262/#sec-tonumber>
pub fn to_number(&self, context: &mut Context) -> JsResult<f64> { pub fn to_number(&self, context: &mut Context) -> JsResult<f64> {
match *self { match *self {
JsValue::Null => Ok(0.0), Self::Null => Ok(0.0),
JsValue::Undefined => Ok(f64::NAN), Self::Undefined => Ok(f64::NAN),
JsValue::Boolean(b) => Ok(if b { 1.0 } else { 0.0 }), Self::Boolean(b) => Ok(if b { 1.0 } else { 0.0 }),
JsValue::String(ref string) => Ok(string.string_to_number()), Self::String(ref string) => Ok(string.string_to_number()),
JsValue::Rational(number) => Ok(number), Self::Rational(number) => Ok(number),
JsValue::Integer(integer) => Ok(f64::from(integer)), Self::Integer(integer) => Ok(f64::from(integer)),
JsValue::Symbol(_) => context.throw_type_error("argument must not be a symbol"), Self::Symbol(_) => context.throw_type_error("argument must not be a symbol"),
JsValue::BigInt(_) => context.throw_type_error("argument must not be a bigint"), Self::BigInt(_) => context.throw_type_error("argument must not be a bigint"),
JsValue::Object(_) => { Self::Object(_) => {
let primitive = self.to_primitive(context, PreferredType::Number)?; let primitive = self.to_primitive(context, PreferredType::Number)?;
primitive.to_number(context) primitive.to_number(context)
} }

564
boa_engine/src/vm/opcode.rs

@ -1059,294 +1059,294 @@ impl Opcode {
pub fn as_str(self) -> &'static str { pub fn as_str(self) -> &'static str {
match self { match self {
Opcode::Pop => "Pop", Self::Pop => "Pop",
Opcode::Dup => "Dup", Self::Dup => "Dup",
Opcode::Swap => "Swap", Self::Swap => "Swap",
Opcode::PushZero => "PushZero", Self::PushZero => "PushZero",
Opcode::PushOne => "PushOne", Self::PushOne => "PushOne",
Opcode::PushInt8 => "PushInt8", Self::PushInt8 => "PushInt8",
Opcode::PushInt16 => "PushInt16", Self::PushInt16 => "PushInt16",
Opcode::PushInt32 => "PushInt32", Self::PushInt32 => "PushInt32",
Opcode::PushRational => "PushRational", Self::PushRational => "PushRational",
Opcode::PushNaN => "PushNaN", Self::PushNaN => "PushNaN",
Opcode::PushPositiveInfinity => "PushPositiveInfinity", Self::PushPositiveInfinity => "PushPositiveInfinity",
Opcode::PushNegativeInfinity => "PushNegativeInfinity", Self::PushNegativeInfinity => "PushNegativeInfinity",
Opcode::PushNull => "PushNull", Self::PushNull => "PushNull",
Opcode::PushTrue => "PushTrue", Self::PushTrue => "PushTrue",
Opcode::PushFalse => "PushFalse", Self::PushFalse => "PushFalse",
Opcode::PushUndefined => "PushUndefined", Self::PushUndefined => "PushUndefined",
Opcode::PushLiteral => "PushLiteral", Self::PushLiteral => "PushLiteral",
Opcode::PushEmptyObject => "PushEmptyObject", Self::PushEmptyObject => "PushEmptyObject",
Opcode::PushClassPrototype => "PushClassPrototype", Self::PushClassPrototype => "PushClassPrototype",
Opcode::PushNewArray => "PushNewArray", Self::PushNewArray => "PushNewArray",
Opcode::PushValueToArray => "PushValueToArray", Self::PushValueToArray => "PushValueToArray",
Opcode::PushElisionToArray => "PushElisionToArray", Self::PushElisionToArray => "PushElisionToArray",
Opcode::PushIteratorToArray => "PushIteratorToArray", Self::PushIteratorToArray => "PushIteratorToArray",
Opcode::Add => "Add", Self::Add => "Add",
Opcode::Sub => "Sub", Self::Sub => "Sub",
Opcode::Div => "Div", Self::Div => "Div",
Opcode::Mul => "Mul", Self::Mul => "Mul",
Opcode::Mod => "Mod", Self::Mod => "Mod",
Opcode::Pow => "Pow", Self::Pow => "Pow",
Opcode::ShiftRight => "ShiftRight", Self::ShiftRight => "ShiftRight",
Opcode::ShiftLeft => "ShiftLeft", Self::ShiftLeft => "ShiftLeft",
Opcode::UnsignedShiftRight => "UnsignedShiftRight", Self::UnsignedShiftRight => "UnsignedShiftRight",
Opcode::BitOr => "BitOr", Self::BitOr => "BitOr",
Opcode::BitAnd => "BitAnd", Self::BitAnd => "BitAnd",
Opcode::BitXor => "BitXor", Self::BitXor => "BitXor",
Opcode::BitNot => "BitNot", Self::BitNot => "BitNot",
Opcode::In => "In", Self::In => "In",
Opcode::Eq => "Eq", Self::Eq => "Eq",
Opcode::StrictEq => "StrictEq", Self::StrictEq => "StrictEq",
Opcode::NotEq => "NotEq", Self::NotEq => "NotEq",
Opcode::StrictNotEq => "StrictNotEq", Self::StrictNotEq => "StrictNotEq",
Opcode::GreaterThan => "GreaterThan", Self::GreaterThan => "GreaterThan",
Opcode::GreaterThanOrEq => "GreaterThanOrEq", Self::GreaterThanOrEq => "GreaterThanOrEq",
Opcode::LessThan => "LessThan", Self::LessThan => "LessThan",
Opcode::LessThanOrEq => "LessThanOrEq", Self::LessThanOrEq => "LessThanOrEq",
Opcode::InstanceOf => "InstanceOf", Self::InstanceOf => "InstanceOf",
Opcode::TypeOf => "TypeOf", Self::TypeOf => "TypeOf",
Opcode::Void => "Void", Self::Void => "Void",
Opcode::LogicalNot => "LogicalNot", Self::LogicalNot => "LogicalNot",
Opcode::LogicalAnd => "LogicalAnd", Self::LogicalAnd => "LogicalAnd",
Opcode::LogicalOr => "LogicalOr", Self::LogicalOr => "LogicalOr",
Opcode::Coalesce => "Coalesce", Self::Coalesce => "Coalesce",
Opcode::Pos => "Pos", Self::Pos => "Pos",
Opcode::Neg => "Neg", Self::Neg => "Neg",
Opcode::Inc => "Inc", Self::Inc => "Inc",
Opcode::IncPost => "IncPost", Self::IncPost => "IncPost",
Opcode::Dec => "Dec", Self::Dec => "Dec",
Opcode::DecPost => "DecPost", Self::DecPost => "DecPost",
Opcode::DefInitArg => "DefInitArg", Self::DefInitArg => "DefInitArg",
Opcode::DefVar => "DefVar", Self::DefVar => "DefVar",
Opcode::DefInitVar => "DefInitVar", Self::DefInitVar => "DefInitVar",
Opcode::DefLet => "DefLet", Self::DefLet => "DefLet",
Opcode::DefInitLet => "DefInitLet", Self::DefInitLet => "DefInitLet",
Opcode::DefInitConst => "DefInitConst", Self::DefInitConst => "DefInitConst",
Opcode::GetName => "GetName", Self::GetName => "GetName",
Opcode::GetNameOrUndefined => "GetNameOrUndefined", Self::GetNameOrUndefined => "GetNameOrUndefined",
Opcode::SetName => "SetName", Self::SetName => "SetName",
Opcode::GetPropertyByName => "GetPropertyByName", Self::GetPropertyByName => "GetPropertyByName",
Opcode::GetPropertyByValue => "GetPropertyByValue", Self::GetPropertyByValue => "GetPropertyByValue",
Opcode::SetPropertyByName => "SetPropertyByName", Self::SetPropertyByName => "SetPropertyByName",
Opcode::DefineOwnPropertyByName => "DefineOwnPropertyByName", Self::DefineOwnPropertyByName => "DefineOwnPropertyByName",
Opcode::DefineClassMethodByName => "DefineClassMethodByName", Self::DefineClassMethodByName => "DefineClassMethodByName",
Opcode::SetPropertyByValue => "SetPropertyByValue", Self::SetPropertyByValue => "SetPropertyByValue",
Opcode::DefineOwnPropertyByValue => "DefineOwnPropertyByValue", Self::DefineOwnPropertyByValue => "DefineOwnPropertyByValue",
Opcode::DefineClassMethodByValue => "DefineClassMethodByValue", Self::DefineClassMethodByValue => "DefineClassMethodByValue",
Opcode::SetPropertyGetterByName => "SetPropertyGetterByName", Self::SetPropertyGetterByName => "SetPropertyGetterByName",
Opcode::DefineClassGetterByName => "DefineClassGetterByName", Self::DefineClassGetterByName => "DefineClassGetterByName",
Opcode::SetPropertyGetterByValue => "SetPropertyGetterByValue", Self::SetPropertyGetterByValue => "SetPropertyGetterByValue",
Opcode::DefineClassGetterByValue => "DefineClassGetterByValue", Self::DefineClassGetterByValue => "DefineClassGetterByValue",
Opcode::SetPropertySetterByName => "SetPropertySetterByName", Self::SetPropertySetterByName => "SetPropertySetterByName",
Opcode::DefineClassSetterByName => "DefineClassSetterByName", Self::DefineClassSetterByName => "DefineClassSetterByName",
Opcode::SetPropertySetterByValue => "SetPropertySetterByValue", Self::SetPropertySetterByValue => "SetPropertySetterByValue",
Opcode::DefineClassSetterByValue => "DefineClassSetterByValue", Self::DefineClassSetterByValue => "DefineClassSetterByValue",
Opcode::SetPrivateValue => "SetPrivateValue", Self::SetPrivateValue => "SetPrivateValue",
Opcode::SetPrivateSetter => "SetPrivateSetter", Self::SetPrivateSetter => "SetPrivateSetter",
Opcode::SetPrivateGetter => "SetPrivateGetter", Self::SetPrivateGetter => "SetPrivateGetter",
Opcode::GetPrivateField => "GetPrivateByName", Self::GetPrivateField => "GetPrivateByName",
Opcode::PushClassComputedFieldName => "PushClassComputedFieldName", Self::PushClassComputedFieldName => "PushClassComputedFieldName",
Opcode::DeletePropertyByName => "DeletePropertyByName", Self::DeletePropertyByName => "DeletePropertyByName",
Opcode::DeletePropertyByValue => "DeletePropertyByValue", Self::DeletePropertyByValue => "DeletePropertyByValue",
Opcode::CopyDataProperties => "CopyDataProperties", Self::CopyDataProperties => "CopyDataProperties",
Opcode::ToPropertyKey => "ToPropertyKey", Self::ToPropertyKey => "ToPropertyKey",
Opcode::Jump => "Jump", Self::Jump => "Jump",
Opcode::JumpIfFalse => "JumpIfFalse", Self::JumpIfFalse => "JumpIfFalse",
Opcode::JumpIfNotUndefined => "JumpIfNotUndefined", Self::JumpIfNotUndefined => "JumpIfNotUndefined",
Opcode::Throw => "Throw", Self::Throw => "Throw",
Opcode::TryStart => "TryStart", Self::TryStart => "TryStart",
Opcode::TryEnd => "TryEnd", Self::TryEnd => "TryEnd",
Opcode::CatchStart => "CatchStart", Self::CatchStart => "CatchStart",
Opcode::CatchEnd => "CatchEnd", Self::CatchEnd => "CatchEnd",
Opcode::CatchEnd2 => "CatchEnd2", Self::CatchEnd2 => "CatchEnd2",
Opcode::FinallyStart => "FinallyStart", Self::FinallyStart => "FinallyStart",
Opcode::FinallyEnd => "FinallyEnd", Self::FinallyEnd => "FinallyEnd",
Opcode::FinallySetJump => "FinallySetJump", Self::FinallySetJump => "FinallySetJump",
Opcode::ToBoolean => "ToBoolean", Self::ToBoolean => "ToBoolean",
Opcode::This => "This", Self::This => "This",
Opcode::Case => "Case", Self::Case => "Case",
Opcode::Default => "Default", Self::Default => "Default",
Opcode::GetFunction => "GetFunction", Self::GetFunction => "GetFunction",
Opcode::GetGenerator => "GetGenerator", Self::GetGenerator => "GetGenerator",
Opcode::CallEval => "CallEval", Self::CallEval => "CallEval",
Opcode::CallEvalWithRest => "CallEvalWithRest", Self::CallEvalWithRest => "CallEvalWithRest",
Opcode::Call => "Call", Self::Call => "Call",
Opcode::CallWithRest => "CallWithRest", Self::CallWithRest => "CallWithRest",
Opcode::New => "New", Self::New => "New",
Opcode::NewWithRest => "NewWithRest", Self::NewWithRest => "NewWithRest",
Opcode::Return => "Return", Self::Return => "Return",
Opcode::PushDeclarativeEnvironment => "PushDeclarativeEnvironment", Self::PushDeclarativeEnvironment => "PushDeclarativeEnvironment",
Opcode::PushFunctionEnvironment => "PushFunctionEnvironment", Self::PushFunctionEnvironment => "PushFunctionEnvironment",
Opcode::PopEnvironment => "PopEnvironment", Self::PopEnvironment => "PopEnvironment",
Opcode::LoopStart => "LoopStart", Self::LoopStart => "LoopStart",
Opcode::LoopContinue => "LoopContinue", Self::LoopContinue => "LoopContinue",
Opcode::LoopEnd => "LoopEnd", Self::LoopEnd => "LoopEnd",
Opcode::ForInLoopInitIterator => "ForInLoopInitIterator", Self::ForInLoopInitIterator => "ForInLoopInitIterator",
Opcode::InitIterator => "InitIterator", Self::InitIterator => "InitIterator",
Opcode::IteratorNext => "IteratorNext", Self::IteratorNext => "IteratorNext",
Opcode::IteratorNextFull => "IteratorNextFull", Self::IteratorNextFull => "IteratorNextFull",
Opcode::IteratorClose => "IteratorClose", Self::IteratorClose => "IteratorClose",
Opcode::IteratorToArray => "IteratorToArray", Self::IteratorToArray => "IteratorToArray",
Opcode::ForInLoopNext => "ForInLoopNext", Self::ForInLoopNext => "ForInLoopNext",
Opcode::ConcatToString => "ConcatToString", Self::ConcatToString => "ConcatToString",
Opcode::RequireObjectCoercible => "RequireObjectCoercible", Self::RequireObjectCoercible => "RequireObjectCoercible",
Opcode::ValueNotNullOrUndefined => "ValueNotNullOrUndefined", Self::ValueNotNullOrUndefined => "ValueNotNullOrUndefined",
Opcode::RestParameterInit => "FunctionRestParameter", Self::RestParameterInit => "FunctionRestParameter",
Opcode::RestParameterPop => "RestParameterPop", Self::RestParameterPop => "RestParameterPop",
Opcode::PopOnReturnAdd => "PopOnReturnAdd", Self::PopOnReturnAdd => "PopOnReturnAdd",
Opcode::PopOnReturnSub => "PopOnReturnSub", Self::PopOnReturnSub => "PopOnReturnSub",
Opcode::Yield => "Yield", Self::Yield => "Yield",
Opcode::GeneratorNext => "GeneratorNext", Self::GeneratorNext => "GeneratorNext",
Opcode::GeneratorNextDelegate => "GeneratorNextDelegate", Self::GeneratorNextDelegate => "GeneratorNextDelegate",
Opcode::Nop => "Nop", Self::Nop => "Nop",
} }
} }
/// Name of the profiler event for this opcode /// Name of the profiler event for this opcode
pub fn as_instruction_str(self) -> &'static str { pub fn as_instruction_str(self) -> &'static str {
match self { match self {
Opcode::Pop => "INST - Pop", Self::Pop => "INST - Pop",
Opcode::Dup => "INST - Dup", Self::Dup => "INST - Dup",
Opcode::Swap => "INST - Swap", Self::Swap => "INST - Swap",
Opcode::PushZero => "INST - PushZero", Self::PushZero => "INST - PushZero",
Opcode::PushOne => "INST - PushOne", Self::PushOne => "INST - PushOne",
Opcode::PushInt8 => "INST - PushInt8", Self::PushInt8 => "INST - PushInt8",
Opcode::PushInt16 => "INST - PushInt16", Self::PushInt16 => "INST - PushInt16",
Opcode::PushInt32 => "INST - PushInt32", Self::PushInt32 => "INST - PushInt32",
Opcode::PushRational => "INST - PushRational", Self::PushRational => "INST - PushRational",
Opcode::PushNaN => "INST - PushNaN", Self::PushNaN => "INST - PushNaN",
Opcode::PushPositiveInfinity => "INST - PushPositiveInfinity", Self::PushPositiveInfinity => "INST - PushPositiveInfinity",
Opcode::PushNegativeInfinity => "INST - PushNegativeInfinity", Self::PushNegativeInfinity => "INST - PushNegativeInfinity",
Opcode::PushNull => "INST - PushNull", Self::PushNull => "INST - PushNull",
Opcode::PushTrue => "INST - PushTrue", Self::PushTrue => "INST - PushTrue",
Opcode::PushFalse => "INST - PushFalse", Self::PushFalse => "INST - PushFalse",
Opcode::PushUndefined => "INST - PushUndefined", Self::PushUndefined => "INST - PushUndefined",
Opcode::PushLiteral => "INST - PushLiteral", Self::PushLiteral => "INST - PushLiteral",
Opcode::PushEmptyObject => "INST - PushEmptyObject", Self::PushEmptyObject => "INST - PushEmptyObject",
Opcode::PushNewArray => "INST - PushNewArray", Self::PushNewArray => "INST - PushNewArray",
Opcode::PushValueToArray => "INST - PushValueToArray", Self::PushValueToArray => "INST - PushValueToArray",
Opcode::PushElisionToArray => "INST - PushElisionToArray", Self::PushElisionToArray => "INST - PushElisionToArray",
Opcode::PushIteratorToArray => "INST - PushIteratorToArray", Self::PushIteratorToArray => "INST - PushIteratorToArray",
Opcode::Add => "INST - Add", Self::Add => "INST - Add",
Opcode::Sub => "INST - Sub", Self::Sub => "INST - Sub",
Opcode::Div => "INST - Div", Self::Div => "INST - Div",
Opcode::Mul => "INST - Mul", Self::Mul => "INST - Mul",
Opcode::Mod => "INST - Mod", Self::Mod => "INST - Mod",
Opcode::Pow => "INST - Pow", Self::Pow => "INST - Pow",
Opcode::ShiftRight => "INST - ShiftRight", Self::ShiftRight => "INST - ShiftRight",
Opcode::ShiftLeft => "INST - ShiftLeft", Self::ShiftLeft => "INST - ShiftLeft",
Opcode::UnsignedShiftRight => "INST - UnsignedShiftRight", Self::UnsignedShiftRight => "INST - UnsignedShiftRight",
Opcode::BitOr => "INST - BitOr", Self::BitOr => "INST - BitOr",
Opcode::BitAnd => "INST - BitAnd", Self::BitAnd => "INST - BitAnd",
Opcode::BitXor => "INST - BitXor", Self::BitXor => "INST - BitXor",
Opcode::BitNot => "INST - BitNot", Self::BitNot => "INST - BitNot",
Opcode::In => "INST - In", Self::In => "INST - In",
Opcode::Eq => "INST - Eq", Self::Eq => "INST - Eq",
Opcode::StrictEq => "INST - StrictEq", Self::StrictEq => "INST - StrictEq",
Opcode::NotEq => "INST - NotEq", Self::NotEq => "INST - NotEq",
Opcode::StrictNotEq => "INST - StrictNotEq", Self::StrictNotEq => "INST - StrictNotEq",
Opcode::GreaterThan => "INST - GreaterThan", Self::GreaterThan => "INST - GreaterThan",
Opcode::GreaterThanOrEq => "INST - GreaterThanOrEq", Self::GreaterThanOrEq => "INST - GreaterThanOrEq",
Opcode::LessThan => "INST - LessThan", Self::LessThan => "INST - LessThan",
Opcode::LessThanOrEq => "INST - LessThanOrEq", Self::LessThanOrEq => "INST - LessThanOrEq",
Opcode::InstanceOf => "INST - InstanceOf", Self::InstanceOf => "INST - InstanceOf",
Opcode::TypeOf => "INST - TypeOf", Self::TypeOf => "INST - TypeOf",
Opcode::Void => "INST - Void", Self::Void => "INST - Void",
Opcode::LogicalNot => "INST - LogicalNot", Self::LogicalNot => "INST - LogicalNot",
Opcode::LogicalAnd => "INST - LogicalAnd", Self::LogicalAnd => "INST - LogicalAnd",
Opcode::LogicalOr => "INST - LogicalOr", Self::LogicalOr => "INST - LogicalOr",
Opcode::Coalesce => "INST - Coalesce", Self::Coalesce => "INST - Coalesce",
Opcode::Pos => "INST - Pos", Self::Pos => "INST - Pos",
Opcode::Neg => "INST - Neg", Self::Neg => "INST - Neg",
Opcode::Inc => "INST - Inc", Self::Inc => "INST - Inc",
Opcode::IncPost => "INST - IncPost", Self::IncPost => "INST - IncPost",
Opcode::Dec => "INST - Dec", Self::Dec => "INST - Dec",
Opcode::DecPost => "INST - DecPost", Self::DecPost => "INST - DecPost",
Opcode::DefInitArg => "INST - DefInitArg", Self::DefInitArg => "INST - DefInitArg",
Opcode::DefVar => "INST - DefVar", Self::DefVar => "INST - DefVar",
Opcode::DefInitVar => "INST - DefInitVar", Self::DefInitVar => "INST - DefInitVar",
Opcode::DefLet => "INST - DefLet", Self::DefLet => "INST - DefLet",
Opcode::DefInitLet => "INST - DefInitLet", Self::DefInitLet => "INST - DefInitLet",
Opcode::DefInitConst => "INST - DefInitConst", Self::DefInitConst => "INST - DefInitConst",
Opcode::GetName => "INST - GetName", Self::GetName => "INST - GetName",
Opcode::GetNameOrUndefined => "INST - GetNameOrUndefined", Self::GetNameOrUndefined => "INST - GetNameOrUndefined",
Opcode::SetName => "INST - SetName", Self::SetName => "INST - SetName",
Opcode::GetPropertyByName => "INST - GetPropertyByName", Self::GetPropertyByName => "INST - GetPropertyByName",
Opcode::GetPropertyByValue => "INST - GetPropertyByValue", Self::GetPropertyByValue => "INST - GetPropertyByValue",
Opcode::SetPropertyByName => "INST - SetPropertyByName", Self::SetPropertyByName => "INST - SetPropertyByName",
Opcode::DefineOwnPropertyByName => "INST - DefineOwnPropertyByName", Self::DefineOwnPropertyByName => "INST - DefineOwnPropertyByName",
Opcode::SetPropertyByValue => "INST - SetPropertyByValue", Self::SetPropertyByValue => "INST - SetPropertyByValue",
Opcode::DefineOwnPropertyByValue => "INST - DefineOwnPropertyByValue", Self::DefineOwnPropertyByValue => "INST - DefineOwnPropertyByValue",
Opcode::SetPropertyGetterByName => "INST - SetPropertyGetterByName", Self::SetPropertyGetterByName => "INST - SetPropertyGetterByName",
Opcode::SetPropertyGetterByValue => "INST - SetPropertyGetterByValue", Self::SetPropertyGetterByValue => "INST - SetPropertyGetterByValue",
Opcode::SetPropertySetterByName => "INST - SetPropertySetterByName", Self::SetPropertySetterByName => "INST - SetPropertySetterByName",
Opcode::SetPropertySetterByValue => "INST - SetPropertySetterByValue", Self::SetPropertySetterByValue => "INST - SetPropertySetterByValue",
Opcode::DeletePropertyByName => "INST - DeletePropertyByName", Self::DeletePropertyByName => "INST - DeletePropertyByName",
Opcode::DeletePropertyByValue => "INST - DeletePropertyByValue", Self::DeletePropertyByValue => "INST - DeletePropertyByValue",
Opcode::CopyDataProperties => "INST - CopyDataProperties", Self::CopyDataProperties => "INST - CopyDataProperties",
Opcode::Jump => "INST - Jump", Self::Jump => "INST - Jump",
Opcode::JumpIfFalse => "INST - JumpIfFalse", Self::JumpIfFalse => "INST - JumpIfFalse",
Opcode::JumpIfNotUndefined => "INST - JumpIfNotUndefined", Self::JumpIfNotUndefined => "INST - JumpIfNotUndefined",
Opcode::Throw => "INST - Throw", Self::Throw => "INST - Throw",
Opcode::TryStart => "INST - TryStart", Self::TryStart => "INST - TryStart",
Opcode::TryEnd => "INST - TryEnd", Self::TryEnd => "INST - TryEnd",
Opcode::CatchStart => "INST - CatchStart", Self::CatchStart => "INST - CatchStart",
Opcode::CatchEnd => "INST - CatchEnd", Self::CatchEnd => "INST - CatchEnd",
Opcode::CatchEnd2 => "INST - CatchEnd2", Self::CatchEnd2 => "INST - CatchEnd2",
Opcode::FinallyStart => "INST - FinallyStart", Self::FinallyStart => "INST - FinallyStart",
Opcode::FinallyEnd => "INST - FinallyEnd", Self::FinallyEnd => "INST - FinallyEnd",
Opcode::FinallySetJump => "INST - FinallySetJump", Self::FinallySetJump => "INST - FinallySetJump",
Opcode::ToBoolean => "INST - ToBoolean", Self::ToBoolean => "INST - ToBoolean",
Opcode::This => "INST - This", Self::This => "INST - This",
Opcode::Case => "INST - Case", Self::Case => "INST - Case",
Opcode::Default => "INST - Default", Self::Default => "INST - Default",
Opcode::GetFunction => "INST - GetFunction", Self::GetFunction => "INST - GetFunction",
Opcode::GetGenerator => "INST - GetGenerator", Self::GetGenerator => "INST - GetGenerator",
Opcode::CallEval => "INST - CallEval", Self::CallEval => "INST - CallEval",
Opcode::CallEvalWithRest => "INST - CallEvalWithRest", Self::CallEvalWithRest => "INST - CallEvalWithRest",
Opcode::Call => "INST - Call", Self::Call => "INST - Call",
Opcode::CallWithRest => "INST - CallWithRest", Self::CallWithRest => "INST - CallWithRest",
Opcode::New => "INST - New", Self::New => "INST - New",
Opcode::NewWithRest => "INST - NewWithRest", Self::NewWithRest => "INST - NewWithRest",
Opcode::Return => "INST - Return", Self::Return => "INST - Return",
Opcode::PushDeclarativeEnvironment => "INST - PushDeclarativeEnvironment", Self::PushDeclarativeEnvironment => "INST - PushDeclarativeEnvironment",
Opcode::PushFunctionEnvironment => "INST - PushFunctionEnvironment", Self::PushFunctionEnvironment => "INST - PushFunctionEnvironment",
Opcode::PopEnvironment => "INST - PopEnvironment", Self::PopEnvironment => "INST - PopEnvironment",
Opcode::LoopStart => "INST - LoopStart", Self::LoopStart => "INST - LoopStart",
Opcode::LoopContinue => "INST - LoopContinue", Self::LoopContinue => "INST - LoopContinue",
Opcode::LoopEnd => "INST - LoopEnd", Self::LoopEnd => "INST - LoopEnd",
Opcode::ForInLoopInitIterator => "INST - ForInLoopInitIterator", Self::ForInLoopInitIterator => "INST - ForInLoopInitIterator",
Opcode::InitIterator => "INST - InitIterator", Self::InitIterator => "INST - InitIterator",
Opcode::IteratorNext => "INST - IteratorNext", Self::IteratorNext => "INST - IteratorNext",
Opcode::IteratorNextFull => "INST - IteratorNextFull", Self::IteratorNextFull => "INST - IteratorNextFull",
Opcode::IteratorClose => "INST - IteratorClose", Self::IteratorClose => "INST - IteratorClose",
Opcode::IteratorToArray => "INST - IteratorToArray", Self::IteratorToArray => "INST - IteratorToArray",
Opcode::ForInLoopNext => "INST - ForInLoopNext", Self::ForInLoopNext => "INST - ForInLoopNext",
Opcode::ConcatToString => "INST - ConcatToString", Self::ConcatToString => "INST - ConcatToString",
Opcode::RequireObjectCoercible => "INST - RequireObjectCoercible", Self::RequireObjectCoercible => "INST - RequireObjectCoercible",
Opcode::ValueNotNullOrUndefined => "INST - ValueNotNullOrUndefined", Self::ValueNotNullOrUndefined => "INST - ValueNotNullOrUndefined",
Opcode::RestParameterInit => "INST - FunctionRestParameter", Self::RestParameterInit => "INST - FunctionRestParameter",
Opcode::RestParameterPop => "INST - RestParameterPop", Self::RestParameterPop => "INST - RestParameterPop",
Opcode::PopOnReturnAdd => "INST - PopOnReturnAdd", Self::PopOnReturnAdd => "INST - PopOnReturnAdd",
Opcode::PopOnReturnSub => "INST - PopOnReturnSub", Self::PopOnReturnSub => "INST - PopOnReturnSub",
Opcode::Yield => "INST - Yield", Self::Yield => "INST - Yield",
Opcode::GeneratorNext => "INST - GeneratorNext", Self::GeneratorNext => "INST - GeneratorNext",
Opcode::GeneratorNextDelegate => "INST - GeneratorNextDelegate", Self::GeneratorNextDelegate => "INST - GeneratorNextDelegate",
Opcode::Nop => "INST - Nop", Self::Nop => "INST - Nop",
Opcode::PushClassPrototype => "INST - PushClassPrototype", Self::PushClassPrototype => "INST - PushClassPrototype",
Opcode::DefineClassMethodByName => "INST - DefineClassMethodByName", Self::DefineClassMethodByName => "INST - DefineClassMethodByName",
Opcode::DefineClassMethodByValue => "INST - DefineClassMethodByValue", Self::DefineClassMethodByValue => "INST - DefineClassMethodByValue",
Opcode::DefineClassGetterByName => "INST - DefineClassGetterByName", Self::DefineClassGetterByName => "INST - DefineClassGetterByName",
Opcode::DefineClassGetterByValue => "INST - DefineClassGetterByValue", Self::DefineClassGetterByValue => "INST - DefineClassGetterByValue",
Opcode::DefineClassSetterByName => "INST - DefineClassSetterByName", Self::DefineClassSetterByName => "INST - DefineClassSetterByName",
Opcode::DefineClassSetterByValue => "INST - DefineClassSetterByValue", Self::DefineClassSetterByValue => "INST - DefineClassSetterByValue",
Opcode::SetPrivateValue => "INST - SetPrivateValue", Self::SetPrivateValue => "INST - SetPrivateValue",
Opcode::SetPrivateSetter => "INST - SetPrivateSetter", Self::SetPrivateSetter => "INST - SetPrivateSetter",
Opcode::SetPrivateGetter => "INST - SetPrivateGetter", Self::SetPrivateGetter => "INST - SetPrivateGetter",
Opcode::GetPrivateField => "INST - GetPrivateField", Self::GetPrivateField => "INST - GetPrivateField",
Opcode::PushClassComputedFieldName => "INST - PushClassComputedFieldName", Self::PushClassComputedFieldName => "INST - PushClassComputedFieldName",
Opcode::ToPropertyKey => "INST - ToPropertyKey", Self::ToPropertyKey => "INST - ToPropertyKey",
} }
} }
} }

2
boa_tester/src/main.rs

@ -22,7 +22,6 @@
clippy::all, clippy::all,
clippy::cast_lossless, clippy::cast_lossless,
clippy::redundant_closure_for_method_calls, clippy::redundant_closure_for_method_calls,
clippy::use_self,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::trivially_copy_pass_by_ref, clippy::trivially_copy_pass_by_ref,
clippy::needless_pass_by_value, clippy::needless_pass_by_value,
@ -45,6 +44,7 @@
nonstandard_style, nonstandard_style,
)] )]
#![allow( #![allow(
clippy::use_self, // TODO: deny once false positives are fixed
clippy::module_name_repetitions, clippy::module_name_repetitions,
clippy::cast_possible_truncation, clippy::cast_possible_truncation,
clippy::cast_sign_loss, clippy::cast_sign_loss,

Loading…
Cancel
Save