[−][src]Enum boa::value::Value
A Javascript value
Variants
null
- A null value, for when a value doesn't exist.
undefined
- An undefined value, for when a field or index doesn't exist.
Boolean(bool)
boolean
- A true
/ false
value, for if a certain criteria is met.
String(RcString)
String
- A UTF-8 string, such as "Hello, world"
.
Rational(f64)
Number
- A 64-bit floating point number, such as 3.1415
Integer(i32)
Number
- A 32-bit integer, such as 42
.
BigInt(RcBigInt)
BigInt
- holds any arbitrary large signed integer.
Object(GcObject)
Object
- An object, such as Math
, represented by a binary tree of string keys to Javascript values.
Symbol(RcSymbol)
Symbol
- A Symbol Primitive type.
Implementations
impl Value
[src]
pub fn strict_equals(&self, other: &Self) -> bool
[src]
Strict equality comparison.
This method is executed when doing strict equality comparisons with the ===
operator.
For more information, check https://tc39.es/ecma262/#sec-strict-equality-comparison.
pub fn equals(&self, other: &Self, context: &mut Context) -> Result<bool>
[src]
Abstract equality comparison.
This method is executed when doing abstract equality comparisons with the ==
operator.
For more information, check https://tc39.es/ecma262/#sec-abstract-equality-comparison
impl Value
[src]
pub fn add(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn sub(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn mul(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn div(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn rem(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn pow(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn bitand(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn bitor(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn bitxor(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn shl(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn shr(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn ushr(&self, other: &Self, context: &mut Context) -> Result<Value>
[src]
pub fn neg(&self, context: &mut Context) -> Result<Value>
[src]
pub fn not(&self, _: &mut Context) -> Result<bool>
[src]
pub fn abstract_relation(
&self,
other: &Self,
left_first: bool,
context: &mut Context
) -> Result<AbstractRelation>
[src]
&self,
other: &Self,
left_first: bool,
context: &mut Context
) -> Result<AbstractRelation>
Abstract relational comparison
The comparison x < y
, where x
and y
are values, produces true
, false
,
or undefined
(which indicates that at least one operand is NaN
).
In addition to x
and y
the algorithm takes a Boolean flag named LeftFirst
as a parameter.
The flag is used to control the order in which operations with potentially visible side-effects
are performed upon x
and y
. It is necessary because ECMAScript specifies left to right evaluation
of expressions. The default value of LeftFirst is true
and indicates that the x
parameter
corresponds to an expression that occurs to the left of the y
parameter's corresponding expression.
If LeftFirst
is false
, the reverse is the case and operations must be performed upon y
before x
.
More Information:
pub fn lt(&self, other: &Self, context: &mut Context) -> Result<bool>
[src]
The less than operator (<
) returns true
if the left operand is less than the right operand,
and false
otherwise.
More Information:
pub fn le(&self, other: &Self, context: &mut Context) -> Result<bool>
[src]
The less than or equal operator (<=
) returns true
if the left operand is less than
or equal to the right operand, and false
otherwise.
More Information:
pub fn gt(&self, other: &Self, context: &mut Context) -> Result<bool>
[src]
The greater than operator (>
) returns true
if the left operand is greater than
the right operand, and false
otherwise.
More Information:
pub fn ge(&self, other: &Self, context: &mut Context) -> Result<bool>
[src]
The greater than or equal operator (>=
) returns true
if the left operand is greater than
or equal to the right operand, and false
otherwise.
More Information:
impl Value
[src]
pub fn get_type(&self) -> Type
[src]
Get the type of the value.
This is similar to typeof as described at https://tc39.es/ecma262/#sec-typeof-operator but instead of returning a string it returns a Type enum which implements fmt::Display to allow getting the string if required using to_string().
impl Value
[src]
pub fn undefined() -> Self
[src]
Creates a new undefined
value.
pub fn null() -> Self
[src]
Creates a new null
value.
pub fn nan() -> Self
[src]
Creates a new number with NaN
value.
pub fn string<S>(value: S) -> Self where
S: Into<RcString>,
[src]
S: Into<RcString>,
Creates a new string value.
pub fn rational<N>(value: N) -> Self where
N: Into<f64>,
[src]
N: Into<f64>,
Creates a new number value.
pub fn integer<I>(value: I) -> Self where
I: Into<i32>,
[src]
I: Into<i32>,
Creates a new number value.
pub fn number<N>(value: N) -> Self where
N: Into<f64>,
[src]
N: Into<f64>,
Creates a new number value.
pub fn bigint<B>(value: B) -> Self where
B: Into<RcBigInt>,
[src]
B: Into<RcBigInt>,
Creates a new bigint value.
pub fn boolean(value: bool) -> Self
[src]
Creates a new boolean value.
pub fn object(object: Object) -> Self
[src]
Creates a new object value.
pub fn symbol(symbol: RcSymbol) -> Self
[src]
Creates a new symbol value.
pub fn new_object(context: &Context) -> Self
[src]
Returns a new empty object
pub fn from_json(json: JSONValue, context: &mut Context) -> Self
[src]
Convert from a JSON value to a JS value
pub fn to_json(&self, context: &mut Context) -> Result<JSONValue>
[src]
Converts the Value
to JSON
.
pub fn is_extensible(&self) -> bool
[src]
This will tell us if we can exten an object or not, not properly implemented yet
For now always returns true.
For scalar types it should be false, for objects check the private field for extensibilaty. By default true.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal would turn extensible
to false
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze would also turn extensible
to false
pub fn is_object(&self) -> bool
[src]
Returns true if the value is an object
pub fn as_object(&self) -> Option<GcObject>
[src]
pub fn is_symbol(&self) -> bool
[src]
Returns true if the value is a symbol.
pub fn as_symbol(&self) -> Option<RcSymbol>
[src]
pub fn is_function(&self) -> bool
[src]
Returns true if the value is a function
pub fn is_undefined(&self) -> bool
[src]
Returns true if the value is undefined.
pub fn is_null(&self) -> bool
[src]
Returns true if the value is null.
pub fn is_null_or_undefined(&self) -> bool
[src]
Returns true if the value is null or undefined.
pub fn is_double(&self) -> bool
[src]
Returns true if the value is a 64-bit floating-point number.
pub fn is_integer(&self) -> bool
[src]
Returns true if the value is integer.
pub fn is_number(&self) -> bool
[src]
Returns true if the value is a number.
pub fn as_number(&self) -> Option<f64>
[src]
pub fn is_string(&self) -> bool
[src]
Returns true if the value is a string.
pub fn as_string(&self) -> Option<&RcString>
[src]
Returns the string if the values is a string, otherwise None
.
pub fn is_boolean(&self) -> bool
[src]
Returns true if the value is a boolean.
pub fn as_boolean(&self) -> Option<bool>
[src]
pub fn is_bigint(&self) -> bool
[src]
Returns true if the value is a bigint.
pub fn as_bigint(&self) -> Option<&BigInt>
[src]
Returns an optional reference to a BigInt
if the value is a BigInt primitive.
pub fn to_boolean(&self) -> bool
[src]
pub fn remove_property<Key>(&self, key: Key) -> bool where
Key: Into<PropertyKey>,
[src]
Key: Into<PropertyKey>,
Removes a property from a Value object.
It will return a boolean based on if the value was removed, if there was no value to remove false is returned.
pub fn get_property<Key>(&self, key: Key) -> Option<PropertyDescriptor> where
Key: Into<PropertyKey>,
[src]
Key: Into<PropertyKey>,
Resolve the property in the object.
A copy of the Property is returned.
pub fn get_field<K>(&self, key: K, context: &mut Context) -> Result<Self> where
K: Into<PropertyKey>,
[src]
K: Into<PropertyKey>,
Resolve the property in the object and get its value, or undefined if this is not an object or the field doesn't exist
get_field receives a Property from get_prop(). It should then return the [[Get]]
result value if that's set, otherwise fall back to [[Value]]
TODO: this function should use the get Value if its set
pub fn has_field<K>(&self, key: K) -> bool where
K: Into<PropertyKey>,
[src]
K: Into<PropertyKey>,
Check to see if the Value has the field, mainly used by environment records.
pub fn set_field<K, V>(
&self,
key: K,
value: V,
context: &mut Context
) -> Result<Value> where
K: Into<PropertyKey>,
V: Into<Value>,
[src]
&self,
key: K,
value: V,
context: &mut Context
) -> Result<Value> where
K: Into<PropertyKey>,
V: Into<Value>,
Set the field in the value
pub fn set_data(&self, data: ObjectData)
[src]
Set the kind of an object.
pub fn set_property<K, P>(&self, key: K, property: P) where
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
[src]
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
Set the property in the value.
pub fn to_primitive(
&self,
context: &mut Context,
preferred_type: PreferredType
) -> Result<Value>
[src]
&self,
context: &mut Context,
preferred_type: PreferredType
) -> Result<Value>
The abstract operation ToPrimitive takes an input argument and an optional argument PreferredType.
pub fn to_bigint(&self, context: &mut Context) -> Result<RcBigInt>
[src]
Converts the value to a BigInt
.
This function is equivelent to BigInt(value)
in JavaScript.
pub fn display(&self) -> ValueDisplay<'_>
[src]
Returns an object that implements Display
.
Examples
use boa::Value; let value = Value::number(3); println!("{}", value.display());
pub fn to_string(&self, context: &mut Context) -> Result<RcString>
[src]
Converts the value to a string.
This function is equivalent to String(value)
in JavaScript.
pub fn to_object(&self, context: &mut Context) -> Result<GcObject>
[src]
Converts the value to an Object.
This function is equivalent to Object(value)
in JavaScript
pub fn to_property_key(&self, context: &mut Context) -> Result<PropertyKey>
[src]
Converts the value to a PropertyKey
, that can be used as a key for properties.
pub fn to_numeric(&self, context: &mut Context) -> Result<Numeric>
[src]
It returns value converted to a numeric value of type Number
or BigInt
.
pub fn to_u32(&self, context: &mut Context) -> Result<u32>
[src]
Converts a value to an integral 32 bit unsigned integer.
This function is equivalent to value | 0
in JavaScript
pub fn to_i32(&self, context: &mut Context) -> Result<i32>
[src]
Converts a value to an integral 32 bit signed integer.
pub fn to_index(&self, context: &mut Context) -> Result<usize>
[src]
Converts a value to a non-negative integer if it is a valid integer index value.
pub fn to_length(&self, context: &mut Context) -> Result<usize>
[src]
Converts argument to an integer suitable for use as the length of an array-like object.
pub fn to_integer(&self, context: &mut Context) -> Result<f64>
[src]
Converts a value to an integral Number value.
pub fn to_number(&self, context: &mut Context) -> Result<f64>
[src]
Converts a value to a double precision floating point.
This function is equivalent to the unary +
operator (+value
) in JavaScript
pub fn to_numeric_number(&self, context: &mut Context) -> Result<f64>
[src]
This is a more specialized version of to_numeric
, including BigInt
.
This function is equivalent to Number(value)
in JavaScript
pub fn require_object_coercible(&self, context: &mut Context) -> Result<&Value>
[src]
Check if the Value
can be converted to an Object
The abstract operation RequireObjectCoercible
takes argument argument.
It throws an error if argument is a value that cannot be converted to an Object using ToObject
.
It is defined by Table 15
More information:
pub fn to_property_descriptor(
&self,
context: &mut Context
) -> Result<PropertyDescriptor>
[src]
&self,
context: &mut Context
) -> Result<PropertyDescriptor>
pub fn to_integer_or_infinity(
&self,
context: &mut Context
) -> Result<IntegerOrInfinity>
[src]
&self,
context: &mut Context
) -> Result<IntegerOrInfinity>
Converts argument to an integer, +∞, or -∞.
Trait Implementations
impl Clone for Value
[src]
impl Debug for Value
[src]
impl Default for Value
[src]
impl Drop for Value
[src]
impl Eq for Value
[src]
impl Finalize for Value
[src]
impl<T> From<&'_ [T]> for Value where
T: Clone + Into<Value>,
[src]
T: Clone + Into<Value>,
impl From<&'_ Box<str, Global>> for Value
[src]
impl From<&'_ PropertyKey> for Value
[src]
pub fn from(property_key: &PropertyKey) -> Value
[src]
impl From<&'_ Value> for Value
[src]
impl From<&'_ str> for Value
[src]
impl From<()> for Value
[src]
impl From<BigInt> for Value
[src]
impl From<Box<str, Global>> for Value
[src]
impl From<GcObject> for Value
[src]
impl From<Numeric> for Value
[src]
impl From<Object> for Value
[src]
impl<T> From<Option<T>> for Value where
T: Into<Value>,
[src]
T: Into<Value>,
impl From<PropertyKey> for Value
[src]
pub fn from(property_key: PropertyKey) -> Value
[src]
impl From<RcBigInt> for Value
[src]
impl From<RcString> for Value
[src]
impl From<RcSymbol> for Value
[src]
impl From<String> for Value
[src]
impl<T> From<Vec<T, Global>> for Value where
T: Into<Value>,
[src]
T: Into<Value>,
impl From<bool> for Value
[src]
impl From<char> for Value
[src]
impl From<f64> for Value
[src]
impl From<i32> for Value
[src]
impl From<u32> for Value
[src]
impl From<usize> for Value
[src]
impl Hash for Value
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Value> for Value
[src]
pub fn eq(&self, other: &Self) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Trace for Value
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Value
[src]
impl !Send for Value
[src]
impl !Sync for Value
[src]
impl Unpin for Value
[src]
impl !UnwindSafe for Value
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> NativeObject for T where
T: Any + Debug + Trace,
[src]
T: Any + Debug + Trace,
pub fn as_any(&Self) -> &(dyn Any + 'static)
[src]
pub fn as_mut_any(&mut Self) -> &mut (dyn Any + 'static)
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,