зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1271147 - Merge RegExpCreate and regexp_construct self-hosting builtins. r=till
This commit is contained in:
Родитель
6eada43d60
Коммит
b5fe01d3ac
|
@ -81,7 +81,7 @@ internalIntlRegExps.currencyDigitsRE = null;
|
||||||
function getUnicodeLocaleExtensionSequenceRE() {
|
function getUnicodeLocaleExtensionSequenceRE() {
|
||||||
return internalIntlRegExps.unicodeLocaleExtensionSequenceRE ||
|
return internalIntlRegExps.unicodeLocaleExtensionSequenceRE ||
|
||||||
(internalIntlRegExps.unicodeLocaleExtensionSequenceRE =
|
(internalIntlRegExps.unicodeLocaleExtensionSequenceRE =
|
||||||
regexp_construct("-u(?:-[a-z0-9]{2,8})+"));
|
RegExpCreate("-u(?:-[a-z0-9]{2,8})+"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ function getLanguageTagRE() {
|
||||||
var languageTag = "^(?:" + langtag + "|" + privateuse + "|" + grandfathered + ")$";
|
var languageTag = "^(?:" + langtag + "|" + privateuse + "|" + grandfathered + ")$";
|
||||||
|
|
||||||
// Language tags are case insensitive (RFC 5646 section 2.1.1).
|
// Language tags are case insensitive (RFC 5646 section 2.1.1).
|
||||||
return (internalIntlRegExps.languageTagRE = regexp_construct(languageTag, "i"));
|
return (internalIntlRegExps.languageTagRE = RegExpCreate(languageTag, "i"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ function getDuplicateVariantRE() {
|
||||||
// regular expression to address this. (Note that there's no worry about
|
// regular expression to address this. (Note that there's no worry about
|
||||||
// case transformation accepting invalid characters here: users have
|
// case transformation accepting invalid characters here: users have
|
||||||
// already verified the string is alphanumeric Latin plus "-".)
|
// already verified the string is alphanumeric Latin plus "-".)
|
||||||
return (internalIntlRegExps.duplicateVariantRE = regexp_construct(duplicateVariant, "i"));
|
return (internalIntlRegExps.duplicateVariantRE = RegExpCreate(duplicateVariant, "i"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ function getDuplicateSingletonRE() {
|
||||||
// expression to address this. (Note that there's no worry about case
|
// expression to address this. (Note that there's no worry about case
|
||||||
// transformation accepting invalid characters here: users have already
|
// transformation accepting invalid characters here: users have already
|
||||||
// verified the string is alphanumeric Latin plus "-".)
|
// verified the string is alphanumeric Latin plus "-".)
|
||||||
return (internalIntlRegExps.duplicateSingletonRE = regexp_construct(duplicateSingleton, "i"));
|
return (internalIntlRegExps.duplicateSingletonRE = RegExpCreate(duplicateSingleton, "i"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ function DefaultLocale() {
|
||||||
*/
|
*/
|
||||||
function getIsWellFormedCurrencyCodeRE() {
|
function getIsWellFormedCurrencyCodeRE() {
|
||||||
return internalIntlRegExps.isWellFormedCurrencyCodeRE ||
|
return internalIntlRegExps.isWellFormedCurrencyCodeRE ||
|
||||||
(internalIntlRegExps.isWellFormedCurrencyCodeRE = regexp_construct("[^A-Z]"));
|
(internalIntlRegExps.isWellFormedCurrencyCodeRE = RegExpCreate("[^A-Z]"));
|
||||||
}
|
}
|
||||||
function IsWellFormedCurrencyCode(currency) {
|
function IsWellFormedCurrencyCode(currency) {
|
||||||
var c = ToString(currency);
|
var c = ToString(currency);
|
||||||
|
@ -1936,7 +1936,7 @@ var currencyDigits = {
|
||||||
*/
|
*/
|
||||||
function getCurrencyDigitsRE() {
|
function getCurrencyDigitsRE() {
|
||||||
return internalIntlRegExps.currencyDigitsRE ||
|
return internalIntlRegExps.currencyDigitsRE ||
|
||||||
(internalIntlRegExps.currencyDigitsRE = regexp_construct("^[A-Z]{3}$"));
|
(internalIntlRegExps.currencyDigitsRE = RegExpCreate("^[A-Z]{3}$"));
|
||||||
}
|
}
|
||||||
function CurrencyDigits(currency) {
|
function CurrencyDigits(currency) {
|
||||||
assert(typeof currency === "string", "CurrencyDigits");
|
assert(typeof currency === "string", "CurrencyDigits");
|
||||||
|
|
|
@ -243,7 +243,7 @@ js::RegExpCreate(JSContext* cx, HandleValue patternValue, HandleValue flagsValue
|
||||||
MutableHandleValue rval)
|
MutableHandleValue rval)
|
||||||
{
|
{
|
||||||
/* Step 1. */
|
/* Step 1. */
|
||||||
Rooted<RegExpObject*> regexp(cx, RegExpAlloc(cx, nullptr));
|
Rooted<RegExpObject*> regexp(cx, RegExpAlloc(cx));
|
||||||
if (!regexp)
|
if (!regexp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -492,31 +492,6 @@ js::regexp_construct(JSContext* cx, unsigned argc, Value* vp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
js::regexp_construct_self_hosting(JSContext* cx, unsigned argc, Value* vp)
|
|
||||||
{
|
|
||||||
CallArgs args = CallArgsFromVp(argc, vp);
|
|
||||||
|
|
||||||
MOZ_ASSERT(args.length() == 1 || args.length() == 2);
|
|
||||||
MOZ_ASSERT(args[0].isString());
|
|
||||||
MOZ_ASSERT_IF(args.length() == 2, args[1].isString());
|
|
||||||
MOZ_ASSERT(!args.isConstructing());
|
|
||||||
|
|
||||||
/* Steps 1-6 are not required since pattern is always string. */
|
|
||||||
|
|
||||||
/* Steps 7-10. */
|
|
||||||
Rooted<RegExpObject*> regexp(cx, RegExpAlloc(cx));
|
|
||||||
if (!regexp)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!RegExpInitializeIgnoringLastIndex(cx, regexp, args[0], args.get(1)))
|
|
||||||
return false;
|
|
||||||
regexp->zeroLastIndex(cx);
|
|
||||||
|
|
||||||
args.rval().setObject(*regexp);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ES 2017 draft rev 6a13789aa9e7c6de4e96b7d3e24d9e6eba6584ad 21.2.3.1
|
* ES 2017 draft rev 6a13789aa9e7c6de4e96b7d3e24d9e6eba6584ad 21.2.3.1
|
||||||
* steps 4, 7-8.
|
* steps 4, 7-8.
|
||||||
|
|
|
@ -87,16 +87,6 @@ regexp_exec_no_statics(JSContext* cx, unsigned argc, Value* vp);
|
||||||
extern bool
|
extern bool
|
||||||
regexp_test_no_statics(JSContext* cx, unsigned argc, Value* vp);
|
regexp_test_no_statics(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
||||||
/*
|
|
||||||
* Behaves like RegExp(string) or RegExp(string, string), for self-hosted JS.
|
|
||||||
* pattern and flags should be string, and should be called without |new|.
|
|
||||||
*
|
|
||||||
* Usage: re = regexp_construct(pattern)
|
|
||||||
* re = regexp_construct(pattern, flags)
|
|
||||||
*/
|
|
||||||
extern bool
|
|
||||||
regexp_construct_self_hosting(JSContext* cx, unsigned argc, Value* vp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Behaves like RegExp(pattern, string).
|
* Behaves like RegExp(pattern, string).
|
||||||
* pattern should be a RegExp object, and flags should be a string,
|
* pattern should be a RegExp object, and flags should be a string,
|
||||||
|
|
|
@ -47,7 +47,7 @@ function String_match(regexp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4.
|
// Step 4.
|
||||||
var rx = RegExpCreate(regexp, undefined);
|
var rx = RegExpCreate(regexp);
|
||||||
|
|
||||||
// Step 5 (optimized case).
|
// Step 5 (optimized case).
|
||||||
if (IsStringMatchOptimizable())
|
if (IsStringMatchOptimizable())
|
||||||
|
@ -240,7 +240,7 @@ function String_search(regexp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4.
|
// Step 4.
|
||||||
var rx = RegExpCreate(regexp, undefined);
|
var rx = RegExpCreate(regexp);
|
||||||
|
|
||||||
// Step 5.
|
// Step 5.
|
||||||
return callContentFunction(GetMethod(rx, std_search), rx, string);
|
return callContentFunction(GetMethod(rx, std_search), rx, string);
|
||||||
|
|
|
@ -1565,11 +1565,11 @@ intrinsic_RegExpCreate(JSContext* cx, unsigned argc, Value* vp)
|
||||||
{
|
{
|
||||||
CallArgs args = CallArgsFromVp(argc, vp);
|
CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
|
|
||||||
MOZ_ASSERT(args.length() == 2);
|
MOZ_ASSERT(args.length() == 1 || args.length() == 2);
|
||||||
MOZ_ASSERT(args[1].isString() || args[1].isUndefined());
|
MOZ_ASSERT_IF(args.length() == 2, args[1].isString() || args[1].isUndefined());
|
||||||
MOZ_ASSERT(!args.isConstructing());
|
MOZ_ASSERT(!args.isConstructing());
|
||||||
|
|
||||||
return RegExpCreate(cx, args[0], args[1], args.rval());
|
return RegExpCreate(cx, args[0], args.get(1), args.rval());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -2540,7 +2540,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||||
// See builtin/RegExp.h for descriptions of the regexp_* functions.
|
// See builtin/RegExp.h for descriptions of the regexp_* functions.
|
||||||
JS_FN("regexp_exec_no_statics", regexp_exec_no_statics, 2,0),
|
JS_FN("regexp_exec_no_statics", regexp_exec_no_statics, 2,0),
|
||||||
JS_FN("regexp_test_no_statics", regexp_test_no_statics, 2,0),
|
JS_FN("regexp_test_no_statics", regexp_test_no_statics, 2,0),
|
||||||
JS_FN("regexp_construct", regexp_construct_self_hosting, 2,0),
|
|
||||||
JS_FN("regexp_construct_no_sticky", regexp_construct_no_sticky, 2,0),
|
JS_FN("regexp_construct_no_sticky", regexp_construct_no_sticky, 2,0),
|
||||||
|
|
||||||
JS_FN("IsModule", intrinsic_IsInstanceOfBuiltin<ModuleObject>, 1, 0),
|
JS_FN("IsModule", intrinsic_IsInstanceOfBuiltin<ModuleObject>, 1, 0),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче