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

Side by Side Diff: src/parsing/preparser.h

Issue 1522693002: [es6] strict eval/arguments and strong undefined in AssignmentPattern (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
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_PARSING_PREPARSER_H 5 #ifndef V8_PARSING_PREPARSER_H
6 #define V8_PARSING_PREPARSER_H 6 #define V8_PARSING_PREPARSER_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 static PreParserExpression BinaryOperation(PreParserExpression left, 119 static PreParserExpression BinaryOperation(PreParserExpression left,
120 Token::Value op, 120 Token::Value op,
121 PreParserExpression right) { 121 PreParserExpression right) {
122 return PreParserExpression( 122 return PreParserExpression(
123 TypeField::encode(kBinaryOperationExpression) | 123 TypeField::encode(kBinaryOperationExpression) |
124 HasRestField::encode(op == Token::COMMA && 124 HasRestField::encode(op == Token::COMMA &&
125 right->IsSpreadExpression())); 125 right->IsSpreadExpression()));
126 } 126 }
127 127
128 static PreParserExpression AssignmentPattern() { 128 static PreParserExpression Assignment() {
129 return PreParserExpression(TypeField::encode(kExpression) | 129 return PreParserExpression(TypeField::encode(kExpression) |
130 ExpressionTypeField::encode(kAssignmentPattern)); 130 ExpressionTypeField::encode(kAssignment));
131 } 131 }
132 132
133 static PreParserExpression ObjectLiteral() { 133 static PreParserExpression ObjectLiteral() {
134 return PreParserExpression(TypeField::encode(kObjectLiteralExpression)); 134 return PreParserExpression(TypeField::encode(kObjectLiteralExpression));
135 } 135 }
136 136
137 static PreParserExpression ArrayLiteral() { 137 static PreParserExpression ArrayLiteral() {
138 return PreParserExpression(TypeField::encode(kArrayLiteralExpression)); 138 return PreParserExpression(TypeField::encode(kArrayLiteralExpression));
139 } 139 }
140 140
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 bool IsIdentifier() const { 189 bool IsIdentifier() const {
190 return TypeField::decode(code_) == kIdentifierExpression; 190 return TypeField::decode(code_) == kIdentifierExpression;
191 } 191 }
192 192
193 PreParserIdentifier AsIdentifier() const { 193 PreParserIdentifier AsIdentifier() const {
194 DCHECK(IsIdentifier()); 194 DCHECK(IsIdentifier());
195 return PreParserIdentifier(IdentifierTypeField::decode(code_)); 195 return PreParserIdentifier(IdentifierTypeField::decode(code_));
196 } 196 }
197 197
198 bool IsAssignmentPattern() const { 198 bool IsAssignment() const {
199 return TypeField::decode(code_) == kExpression && 199 return TypeField::decode(code_) == kExpression &&
200 ExpressionTypeField::decode(code_) == kAssignmentPattern; 200 ExpressionTypeField::decode(code_) == kAssignment;
201 } 201 }
202 202
203 bool IsObjectLiteral() const { 203 bool IsObjectLiteral() const {
204 return TypeField::decode(code_) == kObjectLiteralExpression; 204 return TypeField::decode(code_) == kObjectLiteralExpression;
205 } 205 }
206 206
207 bool IsArrayLiteral() const { 207 bool IsArrayLiteral() const {
208 return TypeField::decode(code_) == kArrayLiteralExpression; 208 return TypeField::decode(code_) == kArrayLiteralExpression;
209 } 209 }
210 210
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 kArrayLiteralExpression 301 kArrayLiteralExpression
302 }; 302 };
303 303
304 enum ExpressionType { 304 enum ExpressionType {
305 kThisExpression, 305 kThisExpression,
306 kThisPropertyExpression, 306 kThisPropertyExpression,
307 kPropertyExpression, 307 kPropertyExpression,
308 kCallExpression, 308 kCallExpression,
309 kSuperCallReference, 309 kSuperCallReference,
310 kNoTemplateTagExpression, 310 kNoTemplateTagExpression,
311 kAssignmentPattern 311 kAssignment
312 }; 312 };
313 313
314 explicit PreParserExpression(uint32_t expression_code) 314 explicit PreParserExpression(uint32_t expression_code)
315 : code_(expression_code) {} 315 : code_(expression_code) {}
316 316
317 // The first three bits are for the Type. 317 // The first three bits are for the Type.
318 typedef BitField<Type, 0, 3> TypeField; 318 typedef BitField<Type, 0, 3> TypeField;
319 319
320 // The rest of the bits are interpreted depending on the value 320 // The rest of the bits are interpreted depending on the value
321 // of the Type field, so they can share the storage. 321 // of the Type field, so they can share the storage.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return PreParserExpression::Default(); 491 return PreParserExpression::Default();
492 } 492 }
493 PreParserExpression NewRewritableAssignmentExpression( 493 PreParserExpression NewRewritableAssignmentExpression(
494 PreParserExpression expression) { 494 PreParserExpression expression) {
495 return expression; 495 return expression;
496 } 496 }
497 PreParserExpression NewAssignment(Token::Value op, 497 PreParserExpression NewAssignment(Token::Value op,
498 PreParserExpression left, 498 PreParserExpression left,
499 PreParserExpression right, 499 PreParserExpression right,
500 int pos) { 500 int pos) {
501 return PreParserExpression::Default(); 501 return PreParserExpression::Assignment();
502 }
503 PreParserExpression NewAssignmentPattern(PreParserExpression pattern,
504 int pos) {
505 DCHECK(pattern->IsObjectLiteral() || pattern->IsArrayLiteral());
506 return PreParserExpression::AssignmentPattern();
507 } 502 }
508 PreParserExpression NewYield(PreParserExpression generator_object, 503 PreParserExpression NewYield(PreParserExpression generator_object,
509 PreParserExpression expression, 504 PreParserExpression expression,
510 Yield::Kind yield_kind, 505 Yield::Kind yield_kind,
511 int pos) { 506 int pos) {
512 return PreParserExpression::Default(); 507 return PreParserExpression::Default();
513 } 508 }
514 PreParserExpression NewConditional(PreParserExpression condition, 509 PreParserExpression NewConditional(PreParserExpression condition,
515 PreParserExpression then_expression, 510 PreParserExpression then_expression,
516 PreParserExpression else_expression, 511 PreParserExpression else_expression,
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 const PreParserFormalParameters& parameters, FunctionKind kind, 1141 const PreParserFormalParameters& parameters, FunctionKind kind,
1147 FunctionLiteral::FunctionType function_type, bool* ok) { 1142 FunctionLiteral::FunctionType function_type, bool* ok) {
1148 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, 1143 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters,
1149 kind, function_type, ok); 1144 kind, function_type, ok);
1150 } 1145 }
1151 1146
1152 } // namespace internal 1147 } // namespace internal
1153 } // namespace v8 1148 } // namespace v8
1154 1149
1155 #endif // V8_PARSING_PREPARSER_H 1150 #endif // V8_PARSING_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698