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

Side by Side Diff: src/preparser.h

Issue 917933007: Make super() a syntax error in base class constructor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: expand tests slightly Created 5 years, 10 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 | « no previous file | test/cctest/test-parsing.cc » ('j') | test/cctest/test-parsing.cc » ('J')
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 2734 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 // TODO(arv): Handle eval scopes similarly. 2745 // TODO(arv): Handle eval scopes similarly.
2746 2746
2747 FunctionKind kind = function_state->kind(); 2747 FunctionKind kind = function_state->kind();
2748 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || 2748 if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
2749 i::IsConstructor(kind)) { 2749 i::IsConstructor(kind)) {
2750 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { 2750 if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
2751 scope_->RecordSuperPropertyUsage(); 2751 scope_->RecordSuperPropertyUsage();
2752 return this->SuperReference(scope_, factory()); 2752 return this->SuperReference(scope_, factory());
2753 } 2753 }
2754 // new super() is never allowed. 2754 // new super() is never allowed.
2755 // super() is only allowed in constructor 2755 // super() is only allowed in derived constructor
2756 if (!is_new && peek() == Token::LPAREN && i::IsConstructor(kind)) { 2756 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) {
2757 scope_->RecordSuperConstructorCallUsage(); 2757 scope_->RecordSuperConstructorCallUsage();
2758 return this->SuperReference(scope_, factory()); 2758 return this->SuperReference(scope_, factory());
2759 } 2759 }
2760 } 2760 }
2761 2761
2762 ReportMessageAt(scanner()->location(), "unexpected_super"); 2762 ReportMessageAt(scanner()->location(), "unexpected_super");
2763 *ok = false; 2763 *ok = false;
2764 return this->EmptyExpression(); 2764 return this->EmptyExpression();
2765 } 2765 }
2766 2766
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 *ok = false; 3077 *ok = false;
3078 return; 3078 return;
3079 } 3079 }
3080 has_seen_constructor_ = true; 3080 has_seen_constructor_ = true;
3081 return; 3081 return;
3082 } 3082 }
3083 } 3083 }
3084 } } // v8::internal 3084 } } // v8::internal
3085 3085
3086 #endif // V8_PREPARSER_H 3086 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698