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

Side by Side Diff: src/preparser.h

Issue 1358423002: [es6] Introduce spec compliant IsConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix stupid fuzzer failure (constructor bit set on sloppy/strict arguments). Fix MIPS/MIPS64 typos, … Created 5 years, 3 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/preparser.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_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 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 int end_pos = scanner()->peek_location().end_pos; 2221 int end_pos = scanner()->peek_location().end_pos;
2222 ExpressionT result = this->EmptyExpression(); 2222 ExpressionT result = this->EmptyExpression();
2223 Token::Value token = peek(); 2223 Token::Value token = peek();
2224 switch (token) { 2224 switch (token) {
2225 case Token::THIS: { 2225 case Token::THIS: {
2226 BindingPatternUnexpectedToken(classifier); 2226 BindingPatternUnexpectedToken(classifier);
2227 Consume(Token::THIS); 2227 Consume(Token::THIS);
2228 if (FLAG_strong_this && is_strong(language_mode())) { 2228 if (FLAG_strong_this && is_strong(language_mode())) {
2229 // Constructors' usages of 'this' in strong mode are parsed separately. 2229 // Constructors' usages of 'this' in strong mode are parsed separately.
2230 // TODO(rossberg): this does not work with arrow functions yet. 2230 // TODO(rossberg): this does not work with arrow functions yet.
2231 if (i::IsConstructor(function_state_->kind())) { 2231 if (IsClassConstructor(function_state_->kind())) {
2232 ReportMessage(MessageTemplate::kStrongConstructorThis); 2232 ReportMessage(MessageTemplate::kStrongConstructorThis);
2233 *ok = false; 2233 *ok = false;
2234 break; 2234 break;
2235 } 2235 }
2236 } 2236 }
2237 result = this->ThisExpression(scope_, factory(), beg_pos); 2237 result = this->ThisExpression(scope_, factory(), beg_pos);
2238 break; 2238 break;
2239 } 2239 }
2240 2240
2241 case Token::NULL_LITERAL: 2241 case Token::NULL_LITERAL:
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 typename ParserBase<Traits>::ExpressionT 3605 typename ParserBase<Traits>::ExpressionT
3606 ParserBase<Traits>::ParseSuperExpression(bool is_new, 3606 ParserBase<Traits>::ParseSuperExpression(bool is_new,
3607 ExpressionClassifier* classifier, 3607 ExpressionClassifier* classifier,
3608 bool* ok) { 3608 bool* ok) {
3609 int pos = position(); 3609 int pos = position();
3610 Expect(Token::SUPER, CHECK_OK); 3610 Expect(Token::SUPER, CHECK_OK);
3611 3611
3612 Scope* scope = scope_->ReceiverScope(); 3612 Scope* scope = scope_->ReceiverScope();
3613 FunctionKind kind = scope->function_kind(); 3613 FunctionKind kind = scope->function_kind();
3614 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || 3614 if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
3615 i::IsConstructor(kind)) { 3615 IsClassConstructor(kind)) {
3616 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { 3616 if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
3617 scope->RecordSuperPropertyUsage(); 3617 scope->RecordSuperPropertyUsage();
3618 return this->SuperPropertyReference(scope_, factory(), pos); 3618 return this->SuperPropertyReference(scope_, factory(), pos);
3619 } 3619 }
3620 // new super() is never allowed. 3620 // new super() is never allowed.
3621 // super() is only allowed in derived constructor 3621 // super() is only allowed in derived constructor
3622 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) { 3622 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) {
3623 if (is_strong(language_mode())) { 3623 if (is_strong(language_mode())) {
3624 // Super calls in strong mode are parsed separately. 3624 // Super calls in strong mode are parsed separately.
3625 ReportMessageAt(scanner()->location(), 3625 ReportMessageAt(scanner()->location(),
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
4178 *ok = false; 4178 *ok = false;
4179 return; 4179 return;
4180 } 4180 }
4181 has_seen_constructor_ = true; 4181 has_seen_constructor_ = true;
4182 return; 4182 return;
4183 } 4183 }
4184 } 4184 }
4185 } } // v8::internal 4185 } } // v8::internal
4186 4186
4187 #endif // V8_PREPARSER_H 4187 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698