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

Side by Side Diff: src/ast.h

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 | « no previous file | src/ast.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_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 class RegExpAlternative; 113 class RegExpAlternative;
114 class RegExpAssertion; 114 class RegExpAssertion;
115 class RegExpAtom; 115 class RegExpAtom;
116 class RegExpBackReference; 116 class RegExpBackReference;
117 class RegExpCapture; 117 class RegExpCapture;
118 class RegExpCharacterClass; 118 class RegExpCharacterClass;
119 class RegExpCompiler; 119 class RegExpCompiler;
120 class RegExpDisjunction; 120 class RegExpDisjunction;
121 class RegExpEmpty; 121 class RegExpEmpty;
122 class RegExpLookahead; 122 class RegExpLookaround;
123 class RegExpQuantifier; 123 class RegExpQuantifier;
124 class RegExpText; 124 class RegExpText;
125 125
126 #define DEF_FORWARD_DECLARATION(type) class type; 126 #define DEF_FORWARD_DECLARATION(type) class type;
127 AST_NODE_LIST(DEF_FORWARD_DECLARATION) 127 AST_NODE_LIST(DEF_FORWARD_DECLARATION)
128 #undef DEF_FORWARD_DECLARATION 128 #undef DEF_FORWARD_DECLARATION
129 129
130 130
131 // Typedef only introduced to avoid unreadable code. 131 // Typedef only introduced to avoid unreadable code.
132 typedef ZoneList<Handle<String>> ZoneStringList; 132 typedef ZoneList<Handle<String>> ZoneStringList;
(...skipping 2935 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 int min_; 3068 int min_;
3069 int max_; 3069 int max_;
3070 int min_match_; 3070 int min_match_;
3071 int max_match_; 3071 int max_match_;
3072 QuantifierType quantifier_type_; 3072 QuantifierType quantifier_type_;
3073 }; 3073 };
3074 3074
3075 3075
3076 class RegExpCapture final : public RegExpTree { 3076 class RegExpCapture final : public RegExpTree {
3077 public: 3077 public:
3078 explicit RegExpCapture(RegExpTree* body, int index) 3078 explicit RegExpCapture(int index) : body_(NULL), index_(index) {}
3079 : body_(body), index_(index) { }
3080 void* Accept(RegExpVisitor* visitor, void* data) override; 3079 void* Accept(RegExpVisitor* visitor, void* data) override;
3081 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; 3080 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
3082 static RegExpNode* ToNode(RegExpTree* body, 3081 static RegExpNode* ToNode(RegExpTree* body,
3083 int index, 3082 int index,
3084 RegExpCompiler* compiler, 3083 RegExpCompiler* compiler,
3085 RegExpNode* on_success); 3084 RegExpNode* on_success);
3086 RegExpCapture* AsCapture() override; 3085 RegExpCapture* AsCapture() override;
3087 bool IsAnchoredAtStart() override; 3086 bool IsAnchoredAtStart() override;
3088 bool IsAnchoredAtEnd() override; 3087 bool IsAnchoredAtEnd() override;
3089 Interval CaptureRegisters() override; 3088 Interval CaptureRegisters() override;
3090 bool IsCapture() override; 3089 bool IsCapture() override;
3091 int min_match() override { return body_->min_match(); } 3090 int min_match() override { return body_->min_match(); }
3092 int max_match() override { return body_->max_match(); } 3091 int max_match() override { return body_->max_match(); }
3093 RegExpTree* body() { return body_; } 3092 RegExpTree* body() { return body_; }
3093 void set_body(RegExpTree* body) { body_ = body; }
3094 int index() { return index_; } 3094 int index() { return index_; }
3095 static int StartRegister(int index) { return index * 2; } 3095 static int StartRegister(int index) { return index * 2; }
3096 static int EndRegister(int index) { return index * 2 + 1; } 3096 static int EndRegister(int index) { return index * 2 + 1; }
3097 3097
3098 private: 3098 private:
3099 RegExpTree* body_; 3099 RegExpTree* body_;
3100 int index_; 3100 int index_;
3101 }; 3101 };
3102 3102
3103 3103
3104 class RegExpLookahead final : public RegExpTree { 3104 class RegExpLookaround final : public RegExpTree {
3105 public: 3105 public:
3106 RegExpLookahead(RegExpTree* body, 3106 enum Type { LOOKAHEAD, LOOKBEHIND };
3107 bool is_positive, 3107
3108 int capture_count, 3108 RegExpLookaround(RegExpTree* body, bool is_positive, int capture_count,
3109 int capture_from) 3109 int capture_from, Type type)
3110 : body_(body), 3110 : body_(body),
3111 is_positive_(is_positive), 3111 is_positive_(is_positive),
3112 capture_count_(capture_count), 3112 capture_count_(capture_count),
3113 capture_from_(capture_from) { } 3113 capture_from_(capture_from),
3114 type_(type) {}
3114 3115
3115 void* Accept(RegExpVisitor* visitor, void* data) override; 3116 void* Accept(RegExpVisitor* visitor, void* data) override;
3116 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; 3117 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
3117 RegExpLookahead* AsLookahead() override; 3118 RegExpLookaround* AsLookaround() override;
3118 Interval CaptureRegisters() override; 3119 Interval CaptureRegisters() override;
3119 bool IsLookahead() override; 3120 bool IsLookaround() override;
3120 bool IsAnchoredAtStart() override; 3121 bool IsAnchoredAtStart() override;
3121 int min_match() override { return 0; } 3122 int min_match() override { return 0; }
3122 int max_match() override { return 0; } 3123 int max_match() override { return 0; }
3123 RegExpTree* body() { return body_; } 3124 RegExpTree* body() { return body_; }
3124 bool is_positive() { return is_positive_; } 3125 bool is_positive() { return is_positive_; }
3125 int capture_count() { return capture_count_; } 3126 int capture_count() { return capture_count_; }
3126 int capture_from() { return capture_from_; } 3127 int capture_from() { return capture_from_; }
3128 Type type() { return type_; }
3127 3129
3128 private: 3130 private:
3129 RegExpTree* body_; 3131 RegExpTree* body_;
3130 bool is_positive_; 3132 bool is_positive_;
3131 int capture_count_; 3133 int capture_count_;
3132 int capture_from_; 3134 int capture_from_;
3135 Type type_;
3133 }; 3136 };
3134 3137
3135 3138
3136 class RegExpBackReference final : public RegExpTree { 3139 class RegExpBackReference final : public RegExpTree {
3137 public: 3140 public:
3138 explicit RegExpBackReference(RegExpCapture* capture) 3141 explicit RegExpBackReference(RegExpCapture* capture)
3139 : capture_(capture) { } 3142 : capture_(capture) { }
3140 void* Accept(RegExpVisitor* visitor, void* data) override; 3143 void* Accept(RegExpVisitor* visitor, void* data) override;
3141 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; 3144 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
3142 RegExpBackReference* AsBackReference() override; 3145 RegExpBackReference* AsBackReference() override;
3143 bool IsBackReference() override; 3146 bool IsBackReference() override;
3144 int min_match() override { return 0; } 3147 int min_match() override { return 0; }
3145 int max_match() override { return capture_->max_match(); } 3148 // The capture may not be completely parsed yet, if the reference occurs
3149 // before the capture. In the ordinary case, nothing has been captured yet,
3150 // so the back reference must have the length 0. If the back reference is
3151 // inside a lookbehind, effectively making it a forward reference, we return
3152 // 0 since lookbehinds have a length of 0.
3153 int max_match() override {
3154 return capture_->body() ? capture_->max_match() : 0;
3155 }
3146 int index() { return capture_->index(); } 3156 int index() { return capture_->index(); }
3147 RegExpCapture* capture() { return capture_; } 3157 RegExpCapture* capture() { return capture_; }
3148 private: 3158 private:
3149 RegExpCapture* capture_; 3159 RegExpCapture* capture_;
3150 }; 3160 };
3151 3161
3152 3162
3153 class RegExpEmpty final : public RegExpTree { 3163 class RegExpEmpty final : public RegExpTree {
3154 public: 3164 public:
3155 RegExpEmpty() { } 3165 RegExpEmpty() { }
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 // the parser-level zone. 3670 // the parser-level zone.
3661 Zone* parser_zone_; 3671 Zone* parser_zone_;
3662 AstValueFactory* ast_value_factory_; 3672 AstValueFactory* ast_value_factory_;
3663 }; 3673 };
3664 3674
3665 3675
3666 } // namespace internal 3676 } // namespace internal
3667 } // namespace v8 3677 } // namespace v8
3668 3678
3669 #endif // V8_AST_H_ 3679 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698