diff --git a/src/builtins/BuiltinRegExp.cpp b/src/builtins/BuiltinRegExp.cpp index 623c737b2..a048edd0b 100644 --- a/src/builtins/BuiltinRegExp.cpp +++ b/src/builtins/BuiltinRegExp.cpp @@ -679,6 +679,11 @@ static Value builtinRegExpUnicodeGetter(ExecutionState& state, Value thisValue, return builtinRegExpOptionGetterHelper(state, thisValue, RegExpObject::Option::Unicode); } +static Value builtinRegExpUnicodeSetsGetter(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional newTarget) +{ + return builtinRegExpOptionGetterHelper(state, thisValue, RegExpObject::Option::UnicodeSets); +} + // Legacy RegExp Features (non-standard) static Value builtinRegExpInputGetter(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional newTarget) @@ -928,6 +933,13 @@ void GlobalObject::installRegExp(ExecutionState& state) m_regexpPrototype->directDefineOwnProperty(state, ObjectPropertyName(state, strings->unicode), desc); } + { + Value getter = new NativeFunctionObject(state, NativeFunctionInfo(strings->getUnicodeSets, builtinRegExpUnicodeSetsGetter, 0, NativeFunctionInfo::Strict)); + JSGetterSetter gs(getter, Value()); + ObjectPropertyDescriptor desc(gs, ObjectPropertyDescriptor::ConfigurablePresent); + m_regexpPrototype->directDefineOwnProperty(state, ObjectPropertyName(state, strings->unicodeSets), desc); + } + m_regexpPrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->constructor), ObjectPropertyDescriptor(m_regexp, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent))); m_regexp->setFunctionPrototype(state, m_regexpPrototype); diff --git a/src/runtime/RegExpObject.cpp b/src/runtime/RegExpObject.cpp index b8fc3fa9b..4b1ad6c53 100644 --- a/src/runtime/RegExpObject.cpp +++ b/src/runtime/RegExpObject.cpp @@ -223,6 +223,8 @@ RegExpObject::Option RegExpObject::parseOption(ExecutionState& state, String* op case 'u': if (tempOption & Option::Unicode) ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, "RegExp has multiple 'u' flags"); + if (tempOption & Option::UnicodeSets) + ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, "RegExp already have 'v' flag"); tempOption = (Option)(tempOption | Option::Unicode); break; case 'y': @@ -238,6 +240,8 @@ RegExpObject::Option RegExpObject::parseOption(ExecutionState& state, String* op case 'v': if (tempOption & Option::UnicodeSets) ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, "RegExp has multiple 'v' flags"); + if (tempOption & Option::Unicode) + ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, "RegExp already have 'u' flag"); tempOption = (Option)(tempOption | Option::UnicodeSets); break; case 'd': diff --git a/src/runtime/StaticStrings.cpp b/src/runtime/StaticStrings.cpp index e82666ec0..f22df35f4 100644 --- a/src/runtime/StaticStrings.cpp +++ b/src/runtime/StaticStrings.cpp @@ -117,6 +117,7 @@ void StaticStrings::initStaticStrings() INIT_STATIC_STRING(getTextInfo, "get textInfo"); INIT_STATIC_STRING(getTimeZones, "get timeZones"); INIT_STATIC_STRING(getUnicode, "get unicode"); + INIT_STATIC_STRING(getUnicodeSets, "get unicodeSets"); INIT_STATIC_STRING(getWeekInfo, "get weekInfo"); INIT_STATIC_STRING(get__proto__, "get __proto__"); INIT_STATIC_STRING(getbyteLength, "get byteLength"); diff --git a/src/runtime/StaticStrings.h b/src/runtime/StaticStrings.h index d231e560a..2408ed927 100644 --- a/src/runtime/StaticStrings.h +++ b/src/runtime/StaticStrings.h @@ -1023,6 +1023,7 @@ class StaticStrings { AtomicString getTextInfo; AtomicString getTimeZones; AtomicString getUnicode; + AtomicString getUnicodeSets; AtomicString getWeekInfo; AtomicString get__proto__; AtomicString getbyteLength;