[−][src]Enum boa::builtins::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 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 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,
interpreter: &mut Interpreter
) -> Result<bool, Value>
[src]
&self,
other: &Self,
interpreter: &mut Interpreter
) -> Result<bool, Value>
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 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 as_num_to_power(&self, other: Self) -> Self
[src]
Helper function to convert the Value
to a number and compute its power.
pub fn new_object(global: Option<&Value>) -> Self
[src]
Returns a new empty object
pub fn new_object_from_prototype(proto: Value, data: ObjectData) -> Self
[src]
Similar to new_object
, but you can pass a prototype to create from, plus a kind
pub fn from_json(json: JSONValue, interpreter: &mut Interpreter) -> Self
[src]
Convert from a JSON value to a JS value
pub fn to_json(&self, interpreter: &mut Interpreter) -> Result<JSONValue, Value>
[src]
Conversts 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<GcCellRef<Object>>
[src]
pub fn as_object_mut(&self) -> Option<GcCellRefMut<Object>>
[src]
pub fn is_symbol(&self) -> bool
[src]
Returns true if the value is a symbol.
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 is_string(&self) -> bool
[src]
Returns true if the value is a string.
pub fn is_boolean(&self) -> bool
[src]
Returns true if the value is a boolean.
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 is_true(&self) -> bool
[src]
Returns true if the value is true.
pub fn to_number(&self) -> f64
[src]
Converts the value into a 64-bit floating point number
pub fn to_integer(&self) -> i32
[src]
Converts the value into a 32-bit integer
pub fn to_boolean(&self) -> bool
[src]
Creates a new boolean value from the input
pub fn remove_property(&self, field: &str) -> bool
[src]
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(&self, field: &str) -> Option<Property>
[src]
Resolve the property in the object.
A copy of the Property is returned.
pub fn update_property(
&self,
field: &str,
value: Option<Value>,
enumerable: Option<bool>,
writable: Option<bool>,
configurable: Option<bool>
)
[src]
&self,
field: &str,
value: Option<Value>,
enumerable: Option<bool>,
writable: Option<bool>,
configurable: Option<bool>
)
update_prop will overwrite individual Property fields, unlike Set_prop, which will overwrite prop with a new Property Mostly used internally for now
pub fn get_internal_slot(&self, field: &str) -> Value
[src]
Resolve the property in the object.
Returns a copy of the Property.
pub fn get_field<F>(&self, field: F) -> Self where
F: Into<Value>,
[src]
F: Into<Value>,
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 recieves 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_internal_state(&self) -> bool
[src]
Check whether an object has an internal state set.
pub fn get_internal_state(&self) -> Option<InternalStateCell>
[src]
Get the internal state of an object.
pub fn with_internal_state_ref<S, R, F>(&self, f: F) -> R where
S: Any + InternalState,
F: FnOnce(&S) -> R,
[src]
S: Any + InternalState,
F: FnOnce(&S) -> R,
Run a function with a reference to the internal state.
Panics
This will panic if this value doesn't have an internal state or if the internal state doesn't
have the concrete type S
.
pub fn with_internal_state_mut<S, R, F>(&self, f: F) -> R where
S: Any + InternalState,
F: FnOnce(&mut S) -> R,
[src]
S: Any + InternalState,
F: FnOnce(&mut S) -> R,
Run a function with a mutable reference to the internal state.
Panics
This will panic if this value doesn't have an internal state or if the internal state doesn't
have the concrete type S
.
pub fn has_field(&self, field: &str) -> bool
[src]
Check to see if the Value has the field, mainly used by environment records.
pub fn set_field<F, V>(&self, field: F, val: V) -> Value where
F: Into<Value>,
V: Into<Value>,
[src]
F: Into<Value>,
V: Into<Value>,
Set the field in the value Field could be a Symbol, so we need to accept a Value (not a string)
pub fn set_internal_slot(&self, field: &str, value: Value) -> Value
[src]
Set the private field in the value
pub fn set_data(&self, data: ObjectData)
[src]
Set the kind of an object.
pub fn set_property<S>(&self, field: S, property: Property) -> Property where
S: Into<RcString>,
[src]
S: Into<RcString>,
Set the property in the value.
pub fn set_internal_state<T: Any + InternalState>(&self, state: T)
[src]
Set internal state of an Object. Discards the previous state if it was set.
pub fn from_func(function: Function) -> Value
[src]
Consume the function and return a Value
Trait Implementations
impl Add<Value> for Value
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self
[src]
impl BitAnd<Value> for Value
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, other: Self) -> Self
[src]
impl BitOr<Value> for Value
[src]
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, other: Self) -> Self
[src]
impl BitXor<Value> for Value
[src]
type Output = Self
The resulting type after applying the ^
operator.
fn bitxor(self, other: Self) -> Self
[src]
impl Clone for Value
[src]
impl Debug for Value
[src]
impl Default for Value
[src]
impl Display for Value
[src]
impl Div<Value> for Value
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: Self) -> Self
[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>> for Value
[src]
impl<'_> From<&'_ Property> for Value
[src]
impl<'_> From<&'_ Value> for Value
[src]
impl<'_> From<&'_ Value> for f64
[src]
impl<'_> From<&'_ Value> for i32
[src]
impl<'_> From<&'_ Value> for usize
[src]
impl<'_> From<&'_ Value> for bool
[src]
impl<'_> From<&'_ str> for Value
[src]
impl<'a> From<&'a Value> for Property
[src]
fn from(value: &Value) -> Self
[src]
Attempt to fetch values "configurable", "enumerable", "writable" from the value, if they're not there default to false
impl From<()> for Value
[src]
impl From<BigInt> for Value
[src]
impl From<Box<str>> 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<RcBigInt> for Value
[src]
impl From<RcString> for Value
[src]
impl From<String> for Value
[src]
impl<T> From<Vec<T>> 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<usize> for Value
[src]
impl Hash for Value
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Mul<Value> for Value
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self
[src]
impl Neg for Value
[src]
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl Not for Value
[src]
impl PartialEq<Value> for Value
[src]
impl Rem<Value> for Value
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: Self) -> Self
[src]
impl Shl<Value> for Value
[src]
type Output = Self
The resulting type after applying the <<
operator.
fn shl(self, other: Self) -> Self
[src]
impl Shr<Value> for Value
[src]
type Output = Self
The resulting type after applying the >>
operator.
fn shr(self, other: Self) -> Self
[src]
impl Sub<Value> for Value
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self
[src]
impl Trace for Value
[src]
unsafe fn trace(&self)
[src]
unsafe fn root(&self)
[src]
unsafe fn unroot(&self)
[src]
fn finalize_glue(&self)
[src]
impl<'_> TryFrom<&'_ Value> for char
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl !UnwindSafe for Value
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,
fn borrow_mut(&mut self) -> &mut T
[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, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
[src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
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.
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>,