Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: engine setup #24

Closed
wants to merge 21 commits into from
Closed
11 changes: 10 additions & 1 deletion nova_vm/src/types/language/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ impl Value {
matches!(self, Value::Symbol(_))
}

pub fn is_empty_string(self) -> bool {
if let Value::SmallString(s) = self {
s.len() == 0
sno2 marked this conversation as resolved.
Show resolved Hide resolved
} else {
false
}
}

/// 7.1.1 ToPrimitive ( input [ , preferredType ] )
/// https://tc39.es/ecma262/#sec-toprimitive
pub fn to_primitive(
Expand Down Expand Up @@ -197,12 +205,13 @@ impl Value {
}

// 2. If argument is one of undefined, null, +0𝔽, -0𝔽, NaN, 0ℤ, or the empty String, return false.
// TODO: checks for 0ℤ and empty String
// TODO: checks for 0ℤ
if argument.is_undefined()
|| argument.is_null()
|| argument.is_pos_zero(agent)
|| argument.is_neg_zero(agent)
|| argument.is_nan(agent)
|| argument.is_empty_string()
{
return Ok(false.into());
}
Expand Down
Loading