Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: src/regexp/regexp-parser.cc

Issue 2639403008: Revert of [regexp] Create property on result for each named capture (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap-symbols.h ('k') | test/mjsunit/harmony/regexp-named-captures.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/regexp/regexp-parser.h" 5 #include "src/regexp/regexp-parser.h"
6 6
7 #include "src/char-predicates-inl.h" 7 #include "src/char-predicates-inl.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 return name; 763 return name;
764 } 764 }
765 765
766 bool RegExpParser::CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name, 766 bool RegExpParser::CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name,
767 int index) { 767 int index) {
768 DCHECK(FLAG_harmony_regexp_named_captures); 768 DCHECK(FLAG_harmony_regexp_named_captures);
769 DCHECK(unicode()); 769 DCHECK(unicode());
770 DCHECK(0 < index && index <= captures_started_); 770 DCHECK(0 < index && index <= captures_started_);
771 DCHECK_NOT_NULL(name); 771 DCHECK_NOT_NULL(name);
772 772
773 // Disallow captures named '__proto__'.
774 static const char16_t proto_string[] = u"__proto__";
775 if (name->size() == arraysize(proto_string) - 1) {
776 if (std::equal(name->begin(), name->end(), &proto_string[0])) {
777 ReportError(CStrVector("Illegal capture group name"));
778 return false;
779 }
780 }
781
782 if (named_captures_ == nullptr) { 773 if (named_captures_ == nullptr) {
783 named_captures_ = new (zone()) ZoneList<RegExpCapture*>(1, zone()); 774 named_captures_ = new (zone()) ZoneList<RegExpCapture*>(1, zone());
784 } else { 775 } else {
785 // Check for duplicates and bail if we find any. 776 // Check for duplicates and bail if we find any.
786 for (const auto& named_capture : *named_captures_) { 777 for (const auto& named_capture : *named_captures_) {
787 if (*named_capture->name() == *name) { 778 if (*named_capture->name() == *name) {
788 ReportError(CStrVector("Duplicate capture group name")); 779 ReportError(CStrVector("Duplicate capture group name"));
789 return false; 780 return false;
790 } 781 }
791 } 782 }
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 return false; 1793 return false;
1803 } 1794 }
1804 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), 1795 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom),
1805 zone()); 1796 zone());
1806 LAST(ADD_TERM); 1797 LAST(ADD_TERM);
1807 return true; 1798 return true;
1808 } 1799 }
1809 1800
1810 } // namespace internal 1801 } // namespace internal
1811 } // namespace v8 1802 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap-symbols.h ('k') | test/mjsunit/harmony/regexp-named-captures.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698