| OLD | NEW |
| 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 3162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3173 bool is_positive_; | 3173 bool is_positive_; |
| 3174 int capture_count_; | 3174 int capture_count_; |
| 3175 int capture_from_; | 3175 int capture_from_; |
| 3176 Type type_; | 3176 Type type_; |
| 3177 }; | 3177 }; |
| 3178 | 3178 |
| 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), max_match_(kUninitialized) {} |
| 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 int max_match() override; |
| 3190 // before the capture. In the ordinary case, nothing has been captured yet, | |
| 3191 // so the back reference must have the length 0. If the back reference is | |
| 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(); } | 3190 int index() { return capture_->index(); } |
| 3198 RegExpCapture* capture() { return capture_; } | 3191 RegExpCapture* capture() { return capture_; } |
| 3199 private: | 3192 private: |
| 3193 static const int kUninitialized = -1; |
| 3194 static const int kRecursionMarker = -2; |
| 3195 |
| 3200 RegExpCapture* capture_; | 3196 RegExpCapture* capture_; |
| 3197 int max_match_; |
| 3201 }; | 3198 }; |
| 3202 | 3199 |
| 3203 | 3200 |
| 3204 class RegExpEmpty final : public RegExpTree { | 3201 class RegExpEmpty final : public RegExpTree { |
| 3205 public: | 3202 public: |
| 3206 RegExpEmpty() { } | 3203 RegExpEmpty() { } |
| 3207 void* Accept(RegExpVisitor* visitor, void* data) override; | 3204 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 3208 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 3205 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 3209 RegExpEmpty* AsEmpty() override; | 3206 RegExpEmpty* AsEmpty() override; |
| 3210 bool IsEmpty() override; | 3207 bool IsEmpty() override; |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3715 // the parser-level zone. | 3712 // the parser-level zone. |
| 3716 Zone* parser_zone_; | 3713 Zone* parser_zone_; |
| 3717 AstValueFactory* ast_value_factory_; | 3714 AstValueFactory* ast_value_factory_; |
| 3718 }; | 3715 }; |
| 3719 | 3716 |
| 3720 | 3717 |
| 3721 } // namespace internal | 3718 } // namespace internal |
| 3722 } // namespace v8 | 3719 } // namespace v8 |
| 3723 | 3720 |
| 3724 #endif // V8_AST_AST_H_ | 3721 #endif // V8_AST_AST_H_ |
| OLD | NEW |