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

Side by Side Diff: src/ast.cc

Issue 1418963009: Experimental support for RegExp lookbehind. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix arm64 debug code assertion Created 5 years, 1 month 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/ast.h ('k') | src/bootstrapper.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/ast.h" 5 #include "src/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 #include "src/builtins.h" 8 #include "src/builtins.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/contexts.h" 10 #include "src/contexts.h"
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 Interval RegExpAlternative::CaptureRegisters() { 843 Interval RegExpAlternative::CaptureRegisters() {
844 return ListCaptureRegisters(nodes()); 844 return ListCaptureRegisters(nodes());
845 } 845 }
846 846
847 847
848 Interval RegExpDisjunction::CaptureRegisters() { 848 Interval RegExpDisjunction::CaptureRegisters() {
849 return ListCaptureRegisters(alternatives()); 849 return ListCaptureRegisters(alternatives());
850 } 850 }
851 851
852 852
853 Interval RegExpLookahead::CaptureRegisters() { 853 Interval RegExpLookaround::CaptureRegisters() {
854 return body()->CaptureRegisters(); 854 return body()->CaptureRegisters();
855 } 855 }
856 856
857 857
858 Interval RegExpCapture::CaptureRegisters() { 858 Interval RegExpCapture::CaptureRegisters() {
859 Interval self(StartRegister(index()), EndRegister(index())); 859 Interval self(StartRegister(index()), EndRegister(index()));
860 return self.Union(body()->CaptureRegisters()); 860 return self.Union(body()->CaptureRegisters());
861 } 861 }
862 862
863 863
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 bool RegExpDisjunction::IsAnchoredAtEnd() { 911 bool RegExpDisjunction::IsAnchoredAtEnd() {
912 ZoneList<RegExpTree*>* alternatives = this->alternatives(); 912 ZoneList<RegExpTree*>* alternatives = this->alternatives();
913 for (int i = 0; i < alternatives->length(); i++) { 913 for (int i = 0; i < alternatives->length(); i++) {
914 if (!alternatives->at(i)->IsAnchoredAtEnd()) 914 if (!alternatives->at(i)->IsAnchoredAtEnd())
915 return false; 915 return false;
916 } 916 }
917 return true; 917 return true;
918 } 918 }
919 919
920 920
921 bool RegExpLookahead::IsAnchoredAtStart() { 921 bool RegExpLookaround::IsAnchoredAtStart() {
922 return is_positive() && body()->IsAnchoredAtStart(); 922 return is_positive() && type() == LOOKAHEAD && body()->IsAnchoredAtStart();
923 } 923 }
924 924
925 925
926 bool RegExpCapture::IsAnchoredAtStart() { 926 bool RegExpCapture::IsAnchoredAtStart() {
927 return body()->IsAnchoredAtStart(); 927 return body()->IsAnchoredAtStart();
928 } 928 }
929 929
930 930
931 bool RegExpCapture::IsAnchoredAtEnd() { 931 bool RegExpCapture::IsAnchoredAtEnd() {
932 return body()->IsAnchoredAtEnd(); 932 return body()->IsAnchoredAtEnd();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1061
1062 1062
1063 void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) { 1063 void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) {
1064 os_ << "(^ "; 1064 os_ << "(^ ";
1065 that->body()->Accept(this, data); 1065 that->body()->Accept(this, data);
1066 os_ << ")"; 1066 os_ << ")";
1067 return NULL; 1067 return NULL;
1068 } 1068 }
1069 1069
1070 1070
1071 void* RegExpUnparser::VisitLookahead(RegExpLookahead* that, void* data) { 1071 void* RegExpUnparser::VisitLookaround(RegExpLookaround* that, void* data) {
1072 os_ << "(-> " << (that->is_positive() ? "+ " : "- "); 1072 os_ << "(";
1073 os_ << (that->type() == RegExpLookaround::LOOKAHEAD ? "->" : "<-");
1074 os_ << (that->is_positive() ? " + " : " - ");
1073 that->body()->Accept(this, data); 1075 that->body()->Accept(this, data);
1074 os_ << ")"; 1076 os_ << ")";
1075 return NULL; 1077 return NULL;
1076 } 1078 }
1077 1079
1078 1080
1079 void* RegExpUnparser::VisitBackReference(RegExpBackReference* that, 1081 void* RegExpUnparser::VisitBackReference(RegExpBackReference* that,
1080 void* data) { 1082 void* data) {
1081 os_ << "(<- " << that->index() << ")"; 1083 os_ << "(<- " << that->index() << ")";
1082 return NULL; 1084 return NULL;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 bool Literal::Match(void* literal1, void* literal2) { 1154 bool Literal::Match(void* literal1, void* literal2) {
1153 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1155 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1154 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1156 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1155 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 1157 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
1156 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1158 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1157 } 1159 }
1158 1160
1159 1161
1160 } // namespace internal 1162 } // namespace internal
1161 } // namespace v8 1163 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698