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

Side by Side Diff: src/preparser.h

Issue 1431873006: Use a single Token::INIT for all variable initialization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm, simplify fvar code 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 | « src/pattern-rewriter.cc ('k') | src/token.h » ('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/bailout-reason.h" 8 #include "src/bailout-reason.h"
9 #include "src/expression-classifier.h" 9 #include "src/expression-classifier.h"
10 #include "src/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 if (op == Token::ASSIGN && this->IsThisProperty(expression)) { 3006 if (op == Token::ASSIGN && this->IsThisProperty(expression)) {
3007 function_state_->AddProperty(); 3007 function_state_->AddProperty();
3008 } 3008 }
3009 3009
3010 this->CheckAssigningFunctionLiteralToProperty(expression, right); 3010 this->CheckAssigningFunctionLiteralToProperty(expression, right);
3011 3011
3012 if (fni_ != NULL) { 3012 if (fni_ != NULL) {
3013 // Check if the right hand side is a call to avoid inferring a 3013 // Check if the right hand side is a call to avoid inferring a
3014 // name if we're dealing with "a = function(){...}();"-like 3014 // name if we're dealing with "a = function(){...}();"-like
3015 // expression. 3015 // expression.
3016 if ((op == Token::INIT_VAR 3016 if ((op == Token::INIT || op == Token::ASSIGN) &&
3017 || op == Token::INIT_CONST_LEGACY 3017 (!right->IsCall() && !right->IsCallNew())) {
3018 || op == Token::ASSIGN)
3019 && (!right->IsCall() && !right->IsCallNew())) {
3020 fni_->Infer(); 3018 fni_->Infer();
3021 } else { 3019 } else {
3022 fni_->RemoveLastFunction(); 3020 fni_->RemoveLastFunction();
3023 } 3021 }
3024 fni_->Leave(); 3022 fni_->Leave();
3025 } 3023 }
3026 3024
3027 return factory()->NewAssignment(op, expression, right, pos); 3025 return factory()->NewAssignment(op, expression, right, pos);
3028 } 3026 }
3029 3027
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 args = Traits::PrepareSpreadArguments(args); 3320 args = Traits::PrepareSpreadArguments(args);
3323 result = Traits::SpreadCall(result, args, pos); 3321 result = Traits::SpreadCall(result, args, pos);
3324 } else { 3322 } else {
3325 result = factory()->NewCall(result, args, pos); 3323 result = factory()->NewCall(result, args, pos);
3326 } 3324 }
3327 3325
3328 // Explicit calls to the super constructor using super() perform an 3326 // Explicit calls to the super constructor using super() perform an
3329 // implicit binding assignment to the 'this' variable. 3327 // implicit binding assignment to the 'this' variable.
3330 if (is_super_call) { 3328 if (is_super_call) {
3331 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); 3329 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos);
3332 result = factory()->NewAssignment(Token::INIT_CONST, this_expr, 3330 result =
3333 result, pos); 3331 factory()->NewAssignment(Token::INIT, this_expr, result, pos);
3334 } 3332 }
3335 3333
3336 if (fni_ != NULL) fni_->RemoveLastFunction(); 3334 if (fni_ != NULL) fni_->RemoveLastFunction();
3337 break; 3335 break;
3338 } 3336 }
3339 3337
3340 case Token::PERIOD: { 3338 case Token::PERIOD: {
3341 BindingPatternUnexpectedToken(classifier); 3339 BindingPatternUnexpectedToken(classifier);
3342 ArrowFormalParametersUnexpectedToken(classifier); 3340 ArrowFormalParametersUnexpectedToken(classifier);
3343 Consume(Token::PERIOD); 3341 Consume(Token::PERIOD);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3610 if (spread_pos.IsValid()) { 3608 if (spread_pos.IsValid()) {
3611 args = Traits::PrepareSpreadArguments(args); 3609 args = Traits::PrepareSpreadArguments(args);
3612 expr = Traits::SpreadCall(expr, args, pos); 3610 expr = Traits::SpreadCall(expr, args, pos);
3613 } else { 3611 } else {
3614 expr = factory()->NewCall(expr, args, pos); 3612 expr = factory()->NewCall(expr, args, pos);
3615 } 3613 }
3616 3614
3617 // Explicit calls to the super constructor using super() perform an implicit 3615 // Explicit calls to the super constructor using super() perform an implicit
3618 // binding assignment to the 'this' variable. 3616 // binding assignment to the 'this' variable.
3619 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); 3617 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos);
3620 return factory()->NewAssignment(Token::INIT_CONST, this_expr, expr, pos); 3618 return factory()->NewAssignment(Token::INIT, this_expr, expr, pos);
3621 } 3619 }
3622 3620
3623 3621
3624 template <class Traits> 3622 template <class Traits>
3625 typename ParserBase<Traits>::ExpressionT 3623 typename ParserBase<Traits>::ExpressionT
3626 ParserBase<Traits>::ParseSuperExpression(bool is_new, 3624 ParserBase<Traits>::ParseSuperExpression(bool is_new,
3627 ExpressionClassifier* classifier, 3625 ExpressionClassifier* classifier,
3628 bool* ok) { 3626 bool* ok) {
3629 int pos = position(); 3627 int pos = position();
3630 Expect(Token::SUPER, CHECK_OK); 3628 Expect(Token::SUPER, CHECK_OK);
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 return; 4197 return;
4200 } 4198 }
4201 has_seen_constructor_ = true; 4199 has_seen_constructor_ = true;
4202 return; 4200 return;
4203 } 4201 }
4204 } 4202 }
4205 } // namespace internal 4203 } // namespace internal
4206 } // namespace v8 4204 } // namespace v8
4207 4205
4208 #endif // V8_PREPARSER_H 4206 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/pattern-rewriter.cc ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698