Skip to content

Commit

Permalink
Merge 706d8a7 into 7b3f42d
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat authored Jul 29, 2020
2 parents 7b3f42d + 706d8a7 commit 0ff082a
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 181 deletions.
20 changes: 18 additions & 2 deletions boa/src/builtins/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
map::ordered_map::OrderedMap,
property::Property,
value::{RcBigInt, RcString, RcSymbol, ResultValue, Value},
BigInt,
BigInt, RegExp,
},
exec::Interpreter,
BoaProfiler,
Expand Down Expand Up @@ -71,6 +71,7 @@ pub struct Object {
pub enum ObjectData {
Array,
Map(OrderedMap<Value, Value>),
RegExp(RegExp),
BigInt(RcBigInt),
Boolean(bool),
Function(Function),
Expand All @@ -87,8 +88,9 @@ impl Display for ObjectData {
f,
"{}",
match self {
Self::Function(_) => "Function",
Self::Array => "Array",
Self::Function(_) => "Function",
Self::RegExp(_) => "RegExp",
Self::Map(_) => "Map",
Self::String(_) => "String",
Self::Symbol(_) => "Symbol",
Expand Down Expand Up @@ -381,6 +383,20 @@ impl Object {
}
}

/// Checks if it a `RegExp` object.
#[inline]
pub fn is_regexp(&self) -> bool {
matches!(self.data, ObjectData::RegExp(_))
}

#[inline]
pub fn as_regexp(&self) -> Option<&RegExp> {
match self.data {
ObjectData::RegExp(ref regexp) => Some(regexp),
_ => None,
}
}

/// Checks if it an ordinary object.
#[inline]
pub fn is_ordinary(&self) -> bool {
Expand Down
Loading

0 comments on commit 0ff082a

Please sign in to comment.