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

Side by Side Diff: src/ast/ast.h

Issue 1522353002: [regexp] break recursion in mutually recursive capture/back references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: new test expectations Created 5 years 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 | « no previous file | src/parsing/parser.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 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 3168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 3179
3180 class RegExpBackReference final : public RegExpTree { 3180 class RegExpBackReference final : public RegExpTree {
3181 public: 3181 public:
3182 explicit RegExpBackReference(RegExpCapture* capture) 3182 explicit RegExpBackReference(RegExpCapture* capture)
3183 : capture_(capture) { } 3183 : capture_(capture) { }
3184 void* Accept(RegExpVisitor* visitor, void* data) override; 3184 void* Accept(RegExpVisitor* visitor, void* data) override;
3185 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; 3185 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
3186 RegExpBackReference* AsBackReference() override; 3186 RegExpBackReference* AsBackReference() override;
3187 bool IsBackReference() override; 3187 bool IsBackReference() override;
3188 int min_match() override { return 0; } 3188 int min_match() override { return 0; }
3189 // The capture may not be completely parsed yet, if the reference occurs 3189 // The back reference may be recursive, e.g. /(\2)(\1)/. To avoid infinite
3190 // before the capture. In the ordinary case, nothing has been captured yet, 3190 // recursion, we give up. Ignorance is bliss.
3191 // so the back reference must have the length 0. If the back reference is 3191 int max_match() override { return kInfinity; }
3192 // inside a lookbehind, effectively making it a forward reference, we return
3193 // 0 since lookbehinds have a length of 0.
3194 int max_match() override {
3195 return capture_->body() ? capture_->max_match() : 0;
3196 }
3197 int index() { return capture_->index(); } 3192 int index() { return capture_->index(); }
3198 RegExpCapture* capture() { return capture_; } 3193 RegExpCapture* capture() { return capture_; }
3199 private: 3194 private:
3200 RegExpCapture* capture_; 3195 RegExpCapture* capture_;
3201 }; 3196 };
3202 3197
3203 3198
3204 class RegExpEmpty final : public RegExpTree { 3199 class RegExpEmpty final : public RegExpTree {
3205 public: 3200 public:
3206 RegExpEmpty() { } 3201 RegExpEmpty() { }
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 // the parser-level zone. 3710 // the parser-level zone.
3716 Zone* parser_zone_; 3711 Zone* parser_zone_;
3717 AstValueFactory* ast_value_factory_; 3712 AstValueFactory* ast_value_factory_;
3718 }; 3713 };
3719 3714
3720 3715
3721 } // namespace internal 3716 } // namespace internal
3722 } // namespace v8 3717 } // namespace v8
3723 3718
3724 #endif // V8_AST_AST_H_ 3719 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698