pub trait ExprExt {
Show 18 methods
// Required method
fn as_expr(&self) -> &Expr;
// Provided methods
fn is_immutable_value(&self) -> bool { ... }
fn is_number(&self) -> bool { ... }
fn is_str(&self) -> bool { ... }
fn is_array_lit(&self) -> bool { ... }
fn is_nan(&self) -> bool { ... }
fn is_undefined(&self, ctx: &ExprCtx) -> bool { ... }
fn is_void(&self) -> bool { ... }
fn is_global_ref_to(&self, ctx: &ExprCtx, id: &str) -> bool { ... }
fn is_one_of_global_ref_to(&self, ctx: &ExprCtx, ids: &[&str]) -> bool { ... }
fn as_pure_bool(&self, ctx: &ExprCtx) -> BoolValue { ... }
fn cast_to_bool(&self, ctx: &ExprCtx) -> (Purity, BoolValue) { ... }
fn cast_to_number(&self, ctx: &ExprCtx) -> (Purity, Value<f64>) { ... }
fn as_pure_number(&self, ctx: &ExprCtx) -> Value<f64> { ... }
fn as_pure_string(&self, ctx: &ExprCtx) -> Value<Cow<'_, str>> { ... }
fn get_type(&self) -> Value<Type> { ... }
fn is_pure_callee(&self, ctx: &ExprCtx) -> bool { ... }
fn may_have_side_effects(&self, ctx: &ExprCtx) -> bool { ... }
}
Expand description
Extension methods for [Expr].
Required Methods§
Provided Methods§
sourcefn is_immutable_value(&self) -> bool
fn is_immutable_value(&self) -> bool
Returns true if this is an immutable value.
fn is_number(&self) -> bool
fn is_str(&self) -> bool
fn is_array_lit(&self) -> bool
fn is_undefined(&self, ctx: &ExprCtx) -> bool
fn is_void(&self) -> bool
sourcefn is_global_ref_to(&self, ctx: &ExprCtx, id: &str) -> bool
fn is_global_ref_to(&self, ctx: &ExprCtx, id: &str) -> bool
Returns true
if id
references a global object.
sourcefn is_one_of_global_ref_to(&self, ctx: &ExprCtx, ids: &[&str]) -> bool
fn is_one_of_global_ref_to(&self, ctx: &ExprCtx, ids: &[&str]) -> bool
Returns true
if id
references a global object.
sourcefn as_pure_bool(&self, ctx: &ExprCtx) -> BoolValue
fn as_pure_bool(&self, ctx: &ExprCtx) -> BoolValue
Get bool value of self
if it does not have any side effects.
sourcefn cast_to_bool(&self, ctx: &ExprCtx) -> (Purity, BoolValue)
fn cast_to_bool(&self, ctx: &ExprCtx) -> (Purity, BoolValue)
This method emulates the Boolean()
JavaScript cast function.
Note: unlike getPureBooleanValue this function does not return None
for expressions with side-effects.
fn cast_to_number(&self, ctx: &ExprCtx) -> (Purity, Value<f64>)
sourcefn as_pure_number(&self, ctx: &ExprCtx) -> Value<f64>
fn as_pure_number(&self, ctx: &ExprCtx) -> Value<f64>
Emulates javascript Number() cast function.
Note: This method returns Known only if it’s pure.
sourcefn as_pure_string(&self, ctx: &ExprCtx) -> Value<Cow<'_, str>>
fn as_pure_string(&self, ctx: &ExprCtx) -> Value<Cow<'_, str>>
Returns Known only if it’s pure.
sourcefn get_type(&self) -> Value<Type>
fn get_type(&self) -> Value<Type>
Apply the supplied predicate against all possible result Nodes of the expression.