Index: src/js/regexp.js |
diff --git a/src/js/regexp.js b/src/js/regexp.js |
index e2b332d749f73dda29121913984b222e7feac3db..79e38ed272cf64e770c1656ecc5cfdf18398b4df 100644 |
--- a/src/js/regexp.js |
+++ b/src/js/regexp.js |
@@ -14,6 +14,8 @@ |
var GlobalRegExp = global.RegExp; |
var InternalPackedArray = utils.InternalPackedArray; |
var MakeTypeError; |
+var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol"); |
+var regExpSourceSymbol = utils.ImportNow("regexp_source_symbol"); |
utils.ImportFromExperimental(function(from) { |
FLAG_harmony_tolength = from.FLAG_harmony_tolength; |
@@ -332,10 +334,14 @@ |
// ES6 21.2.5.4, 21.2.5.5, 21.2.5.7, 21.2.5.12, 21.2.5.15. |
function GetRegExpFlagGetter(name, mask) { |
var getter = function() { |
- if (!IS_REGEXP(this)) { |
+ if (!IS_SPEC_OBJECT(this)) { |
throw MakeTypeError(kRegExpNonObject, name, TO_STRING(this)); |
} |
- return !!(%_RegExpFlags(this) & mask); |
+ var flags = this[regExpFlagsSymbol]; |
+ if (IS_UNDEFINED(flags)) { |
+ throw MakeTypeError(kRegExpNonRegExp, TO_STRING(this)); |
+ } |
+ return !!(flags & mask); |
}; |
%FunctionSetName(getter, name); |
%SetNativeFlag(getter); |
@@ -345,11 +351,15 @@ |
// ES6 21.2.5.10. |
function RegExpGetSource() { |
- if (!IS_REGEXP(this)) { |
+ if (!IS_SPEC_OBJECT(this)) { |
throw MakeTypeError(kRegExpNonObject, "RegExp.prototype.source", |
TO_STRING(this)); |
} |
- return %_RegExpSource(this); |
+ var source = this[regExpSourceSymbol]; |
+ if (IS_UNDEFINED(source)) { |
+ throw MakeTypeError(kRegExpNonRegExp, TO_STRING(this)); |
+ } |
+ return source; |
} |
%SetNativeFlag(RegExpGetSource); |