|
|
@@ -18,10 +18,6 @@ namespace Js
|
|
|
lastIndexOrFlag(0)
|
|
|
{
|
|
|
Assert(type->GetTypeId() == TypeIds_RegEx);
|
|
|
-
|
|
|
- // See JavascriptRegExp::IsWritable for special non-writable properties
|
|
|
- // The JavascriptLibrary should have cleared the bits already
|
|
|
- Assert(!this->GetTypeHandler()->GetHasOnlyWritableDataProperties());
|
|
|
Assert(!this->GetType()->AreThisAndPrototypesEnsuredToHaveOnlyWritableDataProperties());
|
|
|
|
|
|
#if ENABLE_REGEX_CONFIG_OPTIONS
|
|
|
@@ -508,12 +504,6 @@ namespace Js
|
|
|
|
|
|
Assert(!(callInfo.Flags & CallFlags_New));
|
|
|
|
|
|
- // enforce 'this' arg generic
|
|
|
- if (args.Info.Count == 0)
|
|
|
- {
|
|
|
- JavascriptError::ThrowTypeError(scriptContext, JSERR_This_NeedRegExp, L"RegExp.prototype.exec");
|
|
|
- }
|
|
|
-
|
|
|
JavascriptRegExp * pRegEx = GetJavascriptRegExp(args, L"RegExp.prototype.exec", scriptContext);
|
|
|
|
|
|
JavascriptString * pStr;
|
|
|
@@ -541,12 +531,6 @@ namespace Js
|
|
|
ScriptContext* scriptContext = function->GetScriptContext();
|
|
|
Assert(!(callInfo.Flags & CallFlags_New));
|
|
|
|
|
|
- // enforce 'this' arg generic
|
|
|
- if (args.Info.Count == 0)
|
|
|
- {
|
|
|
- JavascriptError::ThrowTypeError(scriptContext, JSERR_This_NeedRegExp, L"RegExp.prototype.test");
|
|
|
- }
|
|
|
-
|
|
|
JavascriptRegExp* pRegEx = GetJavascriptRegExp(args, L"RegExp.prototype.test", scriptContext);
|
|
|
JavascriptString * pStr;
|
|
|
|
|
|
@@ -577,12 +561,6 @@ namespace Js
|
|
|
|
|
|
Assert(!(callInfo.Flags & CallFlags_New));
|
|
|
|
|
|
- // enforce 'this' arg generic
|
|
|
- if (args.Info.Count == 0)
|
|
|
- {
|
|
|
- JavascriptError::ThrowTypeError(scriptContext, JSERR_This_NeedRegExp, L"RegExp.prototype.toString");
|
|
|
- }
|
|
|
-
|
|
|
JavascriptRegExp* obj = GetJavascriptRegExp(args, L"RegExp.prototype.toString", scriptContext);
|
|
|
|
|
|
return obj->ToString();
|
|
|
@@ -597,6 +575,77 @@ namespace Js
|
|
|
return args[0];
|
|
|
}
|
|
|
|
|
|
+ Var JavascriptRegExp::EntryGetterOptions(RecyclableObject* function, CallInfo callInfo, ...)
|
|
|
+ {
|
|
|
+ PROBE_STACK(function->GetScriptContext(), Js::Constants::MinStackDefault);
|
|
|
+ ARGUMENTS(args, callInfo);
|
|
|
+ Assert(!(callInfo.Flags & CallFlags_New));
|
|
|
+
|
|
|
+ return GetJavascriptRegExp(args, L"RegExp.prototype.options", function->GetScriptContext())->GetOptions();
|
|
|
+ }
|
|
|
+
|
|
|
+ Var JavascriptRegExp::GetOptions()
|
|
|
+ {
|
|
|
+ Var options;
|
|
|
+
|
|
|
+ ScriptContext* scriptContext = this->GetLibrary()->GetScriptContext();
|
|
|
+ BEGIN_TEMP_ALLOCATOR(tempAlloc, scriptContext, L"JavascriptRegExp")
|
|
|
+ {
|
|
|
+ StringBuilder<ArenaAllocator> bs(tempAlloc, 4);
|
|
|
+
|
|
|
+ if(GetPattern()->IsGlobal())
|
|
|
+ {
|
|
|
+ bs.Append(L'g');
|
|
|
+ }
|
|
|
+ if(GetPattern()->IsIgnoreCase())
|
|
|
+ {
|
|
|
+ bs.Append(L'i');
|
|
|
+ }
|
|
|
+ if(GetPattern()->IsMultiline())
|
|
|
+ {
|
|
|
+ bs.Append(L'm');
|
|
|
+ }
|
|
|
+ if (GetPattern()->IsUnicode())
|
|
|
+ {
|
|
|
+ bs.Append(L'u');
|
|
|
+ }
|
|
|
+ if (GetPattern()->IsSticky())
|
|
|
+ {
|
|
|
+ bs.Append(L'y');
|
|
|
+ }
|
|
|
+ options = Js::JavascriptString::NewCopyBuffer(bs.Detach(), bs.Count(), scriptContext);
|
|
|
+ }
|
|
|
+ END_TEMP_ALLOCATOR(tempAlloc, scriptContext);
|
|
|
+
|
|
|
+ return options;
|
|
|
+ }
|
|
|
+
|
|
|
+ Var JavascriptRegExp::EntryGetterSource(RecyclableObject* function, CallInfo callInfo, ...)
|
|
|
+ {
|
|
|
+ PROBE_STACK(function->GetScriptContext(), Js::Constants::MinStackDefault);
|
|
|
+ ARGUMENTS(args, callInfo);
|
|
|
+ Assert(!(callInfo.Flags & CallFlags_New));
|
|
|
+
|
|
|
+ return GetJavascriptRegExp(args, L"RegExp.prototype.source", function->GetScriptContext())->ToString(true);
|
|
|
+ }
|
|
|
+
|
|
|
+#define DEFINE_FLAG_GETTER(methodName, propertyName, patternMethodName) \
|
|
|
+ Var JavascriptRegExp::##methodName##(RecyclableObject* function, CallInfo callInfo, ...) \
|
|
|
+ { \
|
|
|
+ PROBE_STACK(function->GetScriptContext(), Js::Constants::MinStackDefault); \
|
|
|
+ ARGUMENTS(args, callInfo); \
|
|
|
+ Assert(!(callInfo.Flags & CallFlags_New)); \
|
|
|
+ \
|
|
|
+ JavascriptRegExp* pRegEx = GetJavascriptRegExp(args, L"RegExp.prototype." L#propertyName, function->GetScriptContext()); \
|
|
|
+ return pRegEx->GetLibrary()->CreateBoolean(pRegEx->GetPattern()->##patternMethodName##()); \
|
|
|
+ }
|
|
|
+
|
|
|
+ DEFINE_FLAG_GETTER(EntryGetterGlobal, global, IsGlobal)
|
|
|
+ DEFINE_FLAG_GETTER(EntryGetterIgnoreCase, ignoreCase, IsIgnoreCase)
|
|
|
+ DEFINE_FLAG_GETTER(EntryGetterMultiline, multiline, IsMultiline)
|
|
|
+ DEFINE_FLAG_GETTER(EntryGetterSticky, sticky, IsSticky)
|
|
|
+ DEFINE_FLAG_GETTER(EntryGetterUnicode, unicode, IsUnicode)
|
|
|
+
|
|
|
JavascriptRegExp * JavascriptRegExp::BoxStackInstance(JavascriptRegExp * instance)
|
|
|
{
|
|
|
Assert(ThreadContext::IsOnStack(instance));
|
|
|
@@ -640,30 +689,30 @@ namespace Js
|
|
|
|
|
|
BOOL JavascriptRegExp::HasProperty(PropertyId propertyId)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define HAS_PROPERTY(ownProperty) \
|
|
|
+ return (ownProperty ? true : DynamicObject::HasProperty(propertyId));
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
+ return true;
|
|
|
case PropertyIds::global:
|
|
|
case PropertyIds::multiline:
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- return true;
|
|
|
+ HAS_PROPERTY(!scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return DynamicObject::HasProperty(propertyId);
|
|
|
+ HAS_PROPERTY(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled())
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return DynamicObject::HasProperty(propertyId);
|
|
|
+ HAS_PROPERTY(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled())
|
|
|
default:
|
|
|
return DynamicObject::HasProperty(propertyId);
|
|
|
}
|
|
|
+
|
|
|
+#undef HAS_PROPERTY
|
|
|
}
|
|
|
|
|
|
BOOL JavascriptRegExp::GetPropertyReference(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext)
|
|
|
@@ -698,6 +747,20 @@ namespace Js
|
|
|
|
|
|
bool JavascriptRegExp::GetPropertyBuiltIns(PropertyId propertyId, Var* value, BOOL* result)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define GET_FLAG(patternMethod) \
|
|
|
+ if (!scriptConfig->IsES6RegExPrototypePropertiesEnabled()) \
|
|
|
+ { \
|
|
|
+ *value = this->GetLibrary()->CreateBoolean(this->GetPattern()->##patternMethod##()); \
|
|
|
+ *result = true; \
|
|
|
+ return true; \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ return false; \
|
|
|
+ }
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
@@ -710,21 +773,19 @@ namespace Js
|
|
|
*result = true;
|
|
|
return true;
|
|
|
case PropertyIds::global:
|
|
|
- *value = this->GetLibrary()->CreateBoolean(this->GetPattern()->IsGlobal());
|
|
|
- *result = true;
|
|
|
- return true;
|
|
|
+ GET_FLAG(IsGlobal)
|
|
|
case PropertyIds::multiline:
|
|
|
- *value = this->GetLibrary()->CreateBoolean(this->GetPattern()->IsMultiline());
|
|
|
- *result = true;
|
|
|
- return true;
|
|
|
+ GET_FLAG(IsMultiline)
|
|
|
case PropertyIds::ignoreCase:
|
|
|
- *value = this->GetLibrary()->CreateBoolean(this->GetPattern()->IsIgnoreCase());
|
|
|
- *result = true;
|
|
|
- return true;
|
|
|
+ GET_FLAG(IsIgnoreCase)
|
|
|
case PropertyIds::unicode:
|
|
|
- if (GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
+ GET_FLAG(IsUnicode)
|
|
|
+ case PropertyIds::sticky:
|
|
|
+ GET_FLAG(IsSticky)
|
|
|
+ case PropertyIds::source:
|
|
|
+ if (!scriptConfig->IsES6RegExPrototypePropertiesEnabled())
|
|
|
{
|
|
|
- *value = this->GetLibrary()->CreateBoolean(this->GetPattern()->IsUnicode());
|
|
|
+ *value = this->ToString(true);
|
|
|
*result = true;
|
|
|
return true;
|
|
|
}
|
|
|
@@ -732,10 +793,10 @@ namespace Js
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
- case PropertyIds::sticky:
|
|
|
- if (GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
+ case PropertyIds::options:
|
|
|
+ if (!scriptConfig->IsES6RegExPrototypePropertiesEnabled())
|
|
|
{
|
|
|
- *value = this->GetLibrary()->CreateBoolean(this->GetPattern()->IsSticky());
|
|
|
+ *value = GetOptions();
|
|
|
*result = true;
|
|
|
return true;
|
|
|
}
|
|
|
@@ -743,48 +804,11 @@ namespace Js
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
- case PropertyIds::source:
|
|
|
- {
|
|
|
- *value = this->ToString(true);
|
|
|
- *result = true;
|
|
|
- return true;
|
|
|
- }
|
|
|
- case PropertyIds::options:
|
|
|
- {
|
|
|
- ScriptContext* scriptContext = this->GetLibrary()->GetScriptContext();
|
|
|
- BEGIN_TEMP_ALLOCATOR(tempAlloc, scriptContext, L"JavascriptRegExp")
|
|
|
- {
|
|
|
- StringBuilder<ArenaAllocator> bs(tempAlloc, 4);
|
|
|
-
|
|
|
- if(GetPattern()->IsGlobal())
|
|
|
- {
|
|
|
- bs.Append(L'g');
|
|
|
- }
|
|
|
- if(GetPattern()->IsIgnoreCase())
|
|
|
- {
|
|
|
- bs.Append(L'i');
|
|
|
- }
|
|
|
- if(GetPattern()->IsMultiline())
|
|
|
- {
|
|
|
- bs.Append(L'm');
|
|
|
- }
|
|
|
- if (GetPattern()->IsUnicode())
|
|
|
- {
|
|
|
- bs.Append(L'u');
|
|
|
- }
|
|
|
- if (GetPattern()->IsSticky())
|
|
|
- {
|
|
|
- bs.Append(L'y');
|
|
|
- }
|
|
|
- *value = Js::JavascriptString::NewCopyBuffer(bs.Detach(), bs.Count(), scriptContext);
|
|
|
- }
|
|
|
- END_TEMP_ALLOCATOR(tempAlloc, scriptContext);
|
|
|
- *result = true;
|
|
|
- return true;
|
|
|
- }
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+#undef GET_FLAG
|
|
|
}
|
|
|
|
|
|
BOOL JavascriptRegExp::SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info)
|
|
|
@@ -814,6 +838,17 @@ namespace Js
|
|
|
|
|
|
bool JavascriptRegExp::SetPropertyBuiltIns(PropertyId propertyId, Var value, PropertyOperationFlags flags, BOOL* result)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define SET_PROPERTY(ownProperty) \
|
|
|
+ if (ownProperty) \
|
|
|
+ { \
|
|
|
+ JavascriptError::ThrowCantAssignIfStrictMode(flags, this->GetScriptContext()); \
|
|
|
+ *result = false; \
|
|
|
+ return true; \
|
|
|
+ } \
|
|
|
+ return false;
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
@@ -826,28 +861,16 @@ namespace Js
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- JavascriptError::ThrowCantAssignIfStrictMode(flags, this->GetScriptContext());
|
|
|
- *result = false;
|
|
|
- return true;
|
|
|
+ SET_PROPERTY(!scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- JavascriptError::ThrowCantAssignIfStrictMode(flags, this->GetScriptContext());
|
|
|
- *result = false;
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ SET_PROPERTY(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- JavascriptError::ThrowCantAssignIfStrictMode(flags, this->GetScriptContext());
|
|
|
- *result = false;
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ SET_PROPERTY(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+#undef SET_PROPERTY
|
|
|
}
|
|
|
|
|
|
BOOL JavascriptRegExp::InitProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info)
|
|
|
@@ -857,33 +880,35 @@ namespace Js
|
|
|
|
|
|
BOOL JavascriptRegExp::DeleteProperty(PropertyId propertyId, PropertyOperationFlags propertyOperationFlags)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define DELETE_PROPERTY(ownProperty) \
|
|
|
+ if (ownProperty) \
|
|
|
+ { \
|
|
|
+ JavascriptError::ThrowCantDeleteIfStrictMode(propertyOperationFlags, this->GetScriptContext(), this->GetScriptContext()->GetPropertyName(propertyId)->GetBuffer()); \
|
|
|
+ return false; \
|
|
|
+ } \
|
|
|
+ return DynamicObject::DeleteProperty(propertyId, propertyOperationFlags);
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
+ DELETE_PROPERTY(true);
|
|
|
case PropertyIds::global:
|
|
|
case PropertyIds::multiline:
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- JavascriptError::ThrowCantDeleteIfStrictMode(propertyOperationFlags, this->GetScriptContext(), this->GetScriptContext()->GetPropertyName(propertyId)->GetBuffer());
|
|
|
- return false;
|
|
|
+ DELETE_PROPERTY(!scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- JavascriptError::ThrowCantDeleteIfStrictMode(propertyOperationFlags, this->GetScriptContext(), this->GetScriptContext()->GetPropertyName(propertyId)->GetBuffer());
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::DeleteProperty(propertyId, propertyOperationFlags);
|
|
|
+ DELETE_PROPERTY(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- JavascriptError::ThrowCantDeleteIfStrictMode(propertyOperationFlags, this->GetScriptContext(), this->GetScriptContext()->GetPropertyName(propertyId)->GetBuffer());
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::DeleteProperty(propertyId, propertyOperationFlags);
|
|
|
+ DELETE_PROPERTY(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
default:
|
|
|
return DynamicObject::DeleteProperty(propertyId, propertyOperationFlags);
|
|
|
}
|
|
|
+
|
|
|
+#undef DELETE_PROPERTY
|
|
|
}
|
|
|
|
|
|
DescriptorFlags JavascriptRegExp::GetSetter(PropertyId propertyId, Var* setterValue, PropertyValueInfo* info, ScriptContext* requestContext)
|
|
|
@@ -913,36 +938,36 @@ namespace Js
|
|
|
|
|
|
bool JavascriptRegExp::GetSetterBuiltIns(PropertyId propertyId, PropertyValueInfo* info, DescriptorFlags* result)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define GET_SETTER(ownProperty) \
|
|
|
+ if (ownProperty) \
|
|
|
+ { \
|
|
|
+ PropertyValueInfo::SetNoCache(info, this); \
|
|
|
+ *result = JavascriptRegExp::IsWritable(propertyId) ? WritableData : Data; \
|
|
|
+ return true; \
|
|
|
+ } \
|
|
|
+ return false;
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
+ GET_SETTER(true);
|
|
|
case PropertyIds::global:
|
|
|
case PropertyIds::multiline:
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- PropertyValueInfo::SetNoCache(info, this);
|
|
|
- *result = JavascriptRegExp::IsWritable(propertyId) ? WritableData : Data;
|
|
|
- return true;
|
|
|
+ GET_SETTER(!scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- PropertyValueInfo::SetNoCache(info, this);
|
|
|
- *result = JavascriptRegExp::IsWritable(propertyId) ? WritableData : Data;
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ GET_SETTER(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- PropertyValueInfo::SetNoCache(info, this);
|
|
|
- *result = JavascriptRegExp::IsWritable(propertyId) ? WritableData : Data;
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ GET_SETTER(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+#undef GET_SETTER
|
|
|
}
|
|
|
|
|
|
BOOL JavascriptRegExp::GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
|
|
|
@@ -960,62 +985,67 @@ namespace Js
|
|
|
|
|
|
BOOL JavascriptRegExp::IsEnumerable(PropertyId propertyId)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define IS_ENUMERABLE(ownProperty) \
|
|
|
+ return (ownProperty ? false : DynamicObject::IsEnumerable(propertyId));
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
+ return false;
|
|
|
case PropertyIds::global:
|
|
|
case PropertyIds::multiline:
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- return false;
|
|
|
+ IS_ENUMERABLE(!scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::IsEnumerable(propertyId);
|
|
|
+ IS_ENUMERABLE(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::IsEnumerable(propertyId);
|
|
|
+ IS_ENUMERABLE(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
default:
|
|
|
return DynamicObject::IsEnumerable(propertyId);
|
|
|
}
|
|
|
+
|
|
|
+#undef IS_ENUMERABLE
|
|
|
}
|
|
|
|
|
|
BOOL JavascriptRegExp::IsConfigurable(PropertyId propertyId)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define IS_CONFIGURABLE(ownProperty) \
|
|
|
+ return (ownProperty ? false : DynamicObject::IsConfigurable(propertyId));
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
+ return false;
|
|
|
case PropertyIds::global:
|
|
|
case PropertyIds::multiline:
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- return false;
|
|
|
+ IS_CONFIGURABLE(!scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::IsConfigurable(propertyId);
|
|
|
+ IS_CONFIGURABLE(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::IsConfigurable(propertyId);
|
|
|
+ IS_CONFIGURABLE(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
default:
|
|
|
return DynamicObject::IsConfigurable(propertyId);
|
|
|
}
|
|
|
+
|
|
|
+#undef IS_CONFIGURABLE
|
|
|
}
|
|
|
|
|
|
BOOL JavascriptRegExp::IsWritable(PropertyId propertyId)
|
|
|
{
|
|
|
+ const ScriptConfiguration* scriptConfig = this->GetScriptContext()->GetConfig();
|
|
|
+
|
|
|
+#define IS_WRITABLE(ownProperty) \
|
|
|
+ return (ownProperty ? false : DynamicObject::IsWritable(propertyId));
|
|
|
+
|
|
|
switch (propertyId)
|
|
|
{
|
|
|
case PropertyIds::lastIndex:
|
|
|
@@ -1025,22 +1055,16 @@ namespace Js
|
|
|
case PropertyIds::ignoreCase:
|
|
|
case PropertyIds::source:
|
|
|
case PropertyIds::options:
|
|
|
- return false;
|
|
|
+ IS_WRITABLE(!scriptConfig->IsES6RegExPrototypePropertiesEnabled())
|
|
|
case PropertyIds::unicode:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::IsWritable(propertyId);
|
|
|
+ IS_WRITABLE(scriptConfig->IsES6UnicodeExtensionsEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
case PropertyIds::sticky:
|
|
|
- if (this->GetScriptContext()->GetConfig()->IsES6RegExStickyEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return DynamicObject::IsWritable(propertyId);
|
|
|
+ IS_WRITABLE(scriptConfig->IsES6RegExStickyEnabled() && !scriptConfig->IsES6RegExPrototypePropertiesEnabled());
|
|
|
default:
|
|
|
return DynamicObject::IsWritable(propertyId);
|
|
|
}
|
|
|
+
|
|
|
+#undef IS_WRITABLE
|
|
|
}
|
|
|
BOOL JavascriptRegExp::GetSpecialPropertyName(uint32 index, Var *propertyName, ScriptContext * requestContext)
|
|
|
{
|
|
|
@@ -1057,6 +1081,11 @@ namespace Js
|
|
|
// Returns the number of special non-enumerable properties this type has.
|
|
|
uint JavascriptRegExp::GetSpecialPropertyCount() const
|
|
|
{
|
|
|
+ if (GetScriptContext()->GetConfig()->IsES6RegExPrototypePropertiesEnabled())
|
|
|
+ {
|
|
|
+ return 1; // lastIndex
|
|
|
+ }
|
|
|
+
|
|
|
uint specialPropertyCount = defaultSpecialPropertyIdsCount;
|
|
|
|
|
|
if (GetScriptContext()->GetConfig()->IsES6UnicodeExtensionsEnabled())
|