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

Side by Side Diff: src/preparser.h

Issue 1125183008: [es6] Spread in array literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 5 years, 7 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/parser.cc ('k') | src/runtime.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 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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 bool allow_harmony_computed_property_names() const { 116 bool allow_harmony_computed_property_names() const {
117 return allow_harmony_computed_property_names_; 117 return allow_harmony_computed_property_names_;
118 } 118 }
119 bool allow_harmony_rest_params() const { 119 bool allow_harmony_rest_params() const {
120 return allow_harmony_rest_params_; 120 return allow_harmony_rest_params_;
121 } 121 }
122 bool allow_harmony_spreadcalls() const { return allow_harmony_spreadcalls_; } 122 bool allow_harmony_spreadcalls() const { return allow_harmony_spreadcalls_; }
123 bool allow_harmony_destructuring() const { 123 bool allow_harmony_destructuring() const {
124 return allow_harmony_destructuring_; 124 return allow_harmony_destructuring_;
125 } 125 }
126 bool allow_harmony_spread_arrays() const {
127 return allow_harmony_spread_arrays_;
128 }
126 129
127 bool allow_strong_mode() const { return allow_strong_mode_; } 130 bool allow_strong_mode() const { return allow_strong_mode_; }
128 131
129 // Setters that determine whether certain syntactical constructs are 132 // Setters that determine whether certain syntactical constructs are
130 // allowed to be parsed by this instance of the parser. 133 // allowed to be parsed by this instance of the parser.
131 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } 134 void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
132 void set_allow_natives(bool allow) { allow_natives_ = allow; } 135 void set_allow_natives(bool allow) { allow_natives_ = allow; }
133 void set_allow_harmony_arrow_functions(bool allow) { 136 void set_allow_harmony_arrow_functions(bool allow) {
134 allow_harmony_arrow_functions_ = allow; 137 allow_harmony_arrow_functions_ = allow;
135 } 138 }
(...skipping 18 matching lines...) Expand all
154 void set_allow_harmony_rest_params(bool allow) { 157 void set_allow_harmony_rest_params(bool allow) {
155 allow_harmony_rest_params_ = allow; 158 allow_harmony_rest_params_ = allow;
156 } 159 }
157 void set_allow_harmony_spreadcalls(bool allow) { 160 void set_allow_harmony_spreadcalls(bool allow) {
158 allow_harmony_spreadcalls_ = allow; 161 allow_harmony_spreadcalls_ = allow;
159 } 162 }
160 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } 163 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; }
161 void set_allow_harmony_destructuring(bool allow) { 164 void set_allow_harmony_destructuring(bool allow) {
162 allow_harmony_destructuring_ = allow; 165 allow_harmony_destructuring_ = allow;
163 } 166 }
164 167 void set_allow_harmony_spread_arrays(bool allow) {
168 allow_harmony_spread_arrays_ = allow;
169 }
165 170
166 protected: 171 protected:
167 enum AllowRestrictedIdentifiers { 172 enum AllowRestrictedIdentifiers {
168 kAllowRestrictedIdentifiers, 173 kAllowRestrictedIdentifiers,
169 kDontAllowRestrictedIdentifiers 174 kDontAllowRestrictedIdentifiers
170 }; 175 };
171 176
172 enum Mode { 177 enum Mode {
173 PARSE_LAZILY, 178 PARSE_LAZILY,
174 PARSE_EAGERLY 179 PARSE_EAGERLY
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1009
1005 bool allow_lazy_; 1010 bool allow_lazy_;
1006 bool allow_natives_; 1011 bool allow_natives_;
1007 bool allow_harmony_arrow_functions_; 1012 bool allow_harmony_arrow_functions_;
1008 bool allow_harmony_object_literals_; 1013 bool allow_harmony_object_literals_;
1009 bool allow_harmony_sloppy_; 1014 bool allow_harmony_sloppy_;
1010 bool allow_harmony_computed_property_names_; 1015 bool allow_harmony_computed_property_names_;
1011 bool allow_harmony_rest_params_; 1016 bool allow_harmony_rest_params_;
1012 bool allow_harmony_spreadcalls_; 1017 bool allow_harmony_spreadcalls_;
1013 bool allow_harmony_destructuring_; 1018 bool allow_harmony_destructuring_;
1019 bool allow_harmony_spread_arrays_;
1014 bool allow_strong_mode_; 1020 bool allow_strong_mode_;
1015 }; 1021 };
1016 1022
1017 1023
1018 class PreParserIdentifier { 1024 class PreParserIdentifier {
1019 public: 1025 public:
1020 PreParserIdentifier() : type_(kUnknownIdentifier) {} 1026 PreParserIdentifier() : type_(kUnknownIdentifier) {}
1021 static PreParserIdentifier Default() { 1027 static PreParserIdentifier Default() {
1022 return PreParserIdentifier(kUnknownIdentifier); 1028 return PreParserIdentifier(kUnknownIdentifier);
1023 } 1029 }
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 ExpressionT elem = this->EmptyExpression(); 2507 ExpressionT elem = this->EmptyExpression();
2502 if (peek() == Token::COMMA) { 2508 if (peek() == Token::COMMA) {
2503 if (is_strong(language_mode())) { 2509 if (is_strong(language_mode())) {
2504 ReportMessageAt(scanner()->peek_location(), 2510 ReportMessageAt(scanner()->peek_location(),
2505 MessageTemplate::kStrongEllision); 2511 MessageTemplate::kStrongEllision);
2506 *ok = false; 2512 *ok = false;
2507 return this->EmptyExpression(); 2513 return this->EmptyExpression();
2508 } 2514 }
2509 elem = this->GetLiteralTheHole(peek_position(), factory()); 2515 elem = this->GetLiteralTheHole(peek_position(), factory());
2510 } else if (peek() == Token::ELLIPSIS) { 2516 } else if (peek() == Token::ELLIPSIS) {
2511 ExpressionUnexpectedToken(classifier); 2517 if (!allow_harmony_spread_arrays()) {
2518 ExpressionUnexpectedToken(classifier);
2519 }
2512 int start_pos = peek_position(); 2520 int start_pos = peek_position();
2513 Consume(Token::ELLIPSIS); 2521 Consume(Token::ELLIPSIS);
2514 ExpressionT argument = 2522 ExpressionT argument =
2515 this->ParseAssignmentExpression(true, classifier, CHECK_OK); 2523 this->ParseAssignmentExpression(true, classifier, CHECK_OK);
2516
2517 elem = factory()->NewSpread(argument, start_pos); 2524 elem = factory()->NewSpread(argument, start_pos);
2518 seen_spread = true; 2525 seen_spread = true;
2519 } else { 2526 } else {
2520 elem = this->ParseAssignmentExpression(true, classifier, CHECK_OK); 2527 elem = this->ParseAssignmentExpression(true, classifier, CHECK_OK);
2521 } 2528 }
2522 values->Add(elem, zone_); 2529 values->Add(elem, zone_);
2523 if (peek() != Token::RBRACK) { 2530 if (peek() != Token::RBRACK) {
2524 if (seen_spread) { 2531 if (seen_spread) {
2525 BindingPatternUnexpectedToken(classifier); 2532 BindingPatternUnexpectedToken(classifier);
2526 } 2533 }
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 *ok = false; 4027 *ok = false;
4021 return; 4028 return;
4022 } 4029 }
4023 has_seen_constructor_ = true; 4030 has_seen_constructor_ = true;
4024 return; 4031 return;
4025 } 4032 }
4026 } 4033 }
4027 } } // v8::internal 4034 } } // v8::internal
4028 4035
4029 #endif // V8_PREPARSER_H 4036 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698