Skip to content

Commit

Permalink
Merge e2ff60e into 795adc5
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 24, 2020
2 parents 795adc5 + e2ff60e commit c5e2070
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 177 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 `BigInt` 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 c5e2070

Please sign in to comment.