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

Side by Side Diff: src/preparser.h

Issue 631433002: Classes runtime (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 1182
1183 static bool IsBoilerplateProperty(PreParserExpression property) { 1183 static bool IsBoilerplateProperty(PreParserExpression property) {
1184 // PreParser doesn't count boilerplate properties. 1184 // PreParser doesn't count boilerplate properties.
1185 return false; 1185 return false;
1186 } 1186 }
1187 1187
1188 static bool IsArrayIndex(PreParserIdentifier string, uint32_t* index) { 1188 static bool IsArrayIndex(PreParserIdentifier string, uint32_t* index) {
1189 return false; 1189 return false;
1190 } 1190 }
1191 1191
1192 bool IsConstructorProperty(PreParserExpression property) { return false; }
1193
1194 static PreParserExpression GetPropertyValue(PreParserExpression property) {
1195 UNREACHABLE();
1196 return PreParserExpression::Default();
1197 }
1198
1192 // Functions for encapsulating the differences between parsing and preparsing; 1199 // Functions for encapsulating the differences between parsing and preparsing;
1193 // operations interleaved with the recursive descent. 1200 // operations interleaved with the recursive descent.
1194 static void PushLiteralName(FuncNameInferrer* fni, PreParserIdentifier id) { 1201 static void PushLiteralName(FuncNameInferrer* fni, PreParserIdentifier id) {
1195 // PreParser should not use FuncNameInferrer. 1202 // PreParser should not use FuncNameInferrer.
1196 UNREACHABLE(); 1203 UNREACHABLE();
1197 } 1204 }
1198 static void PushPropertyName(FuncNameInferrer* fni, 1205 static void PushPropertyName(FuncNameInferrer* fni,
1199 PreParserExpression expression) { 1206 PreParserExpression expression) {
1200 // PreParser should not use FuncNameInferrer. 1207 // PreParser should not use FuncNameInferrer.
1201 UNREACHABLE(); 1208 UNREACHABLE();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 static PreParserExpression ThisExpression(PreParserScope* scope, 1314 static PreParserExpression ThisExpression(PreParserScope* scope,
1308 PreParserFactory* factory) { 1315 PreParserFactory* factory) {
1309 return PreParserExpression::This(); 1316 return PreParserExpression::This();
1310 } 1317 }
1311 1318
1312 static PreParserExpression SuperReference(PreParserScope* scope, 1319 static PreParserExpression SuperReference(PreParserScope* scope,
1313 PreParserFactory* factory) { 1320 PreParserFactory* factory) {
1314 return PreParserExpression::Super(); 1321 return PreParserExpression::Super();
1315 } 1322 }
1316 1323
1317 static PreParserExpression ClassLiteral(PreParserIdentifier name, 1324 static PreParserExpression ClassExpression(PreParserIdentifier name,
1318 PreParserExpression extends, 1325 PreParserExpression extends,
1319 PreParserExpression constructor, 1326 PreParserExpression constructor,
1320 PreParserExpressionList properties, 1327 PreParserExpressionList properties,
1321 int position, 1328 int position,
1322 PreParserFactory* factory) { 1329 PreParserFactory* factory) {
1323 return PreParserExpression::Default(); 1330 return PreParserExpression::Default();
1324 } 1331 }
1325 1332
1326 static PreParserExpression ExpressionFromLiteral( 1333 static PreParserExpression ExpressionFromLiteral(
1327 Token::Value token, int pos, Scanner* scanner, 1334 Token::Value token, int pos, Scanner* scanner,
1328 PreParserFactory* factory) { 1335 PreParserFactory* factory) {
1329 return PreParserExpression::Default(); 1336 return PreParserExpression::Default();
1330 } 1337 }
1331 1338
1332 static PreParserExpression ExpressionFromIdentifier( 1339 static PreParserExpression ExpressionFromIdentifier(
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 1972
1966 } else if (is_generator || 1973 } else if (is_generator ||
1967 (allow_harmony_object_literals_ && peek() == Token::LPAREN)) { 1974 (allow_harmony_object_literals_ && peek() == Token::LPAREN)) {
1968 // Concise Method 1975 // Concise Method
1969 1976
1970 if (is_static && this->IsPrototype(name)) { 1977 if (is_static && this->IsPrototype(name)) {
1971 ReportMessageAt(scanner()->location(), "static_prototype"); 1978 ReportMessageAt(scanner()->location(), "static_prototype");
1972 *ok = false; 1979 *ok = false;
1973 return this->EmptyObjectLiteralProperty(); 1980 return this->EmptyObjectLiteralProperty();
1974 } 1981 }
1975 if (is_generator && in_class && !is_static && this->IsConstructor(name)) {
1976 ReportMessageAt(scanner()->location(), "constructor_special_method");
1977 *ok = false;
1978 return this->EmptyObjectLiteralProperty();
1979 }
1980 1982
1981 checker->CheckProperty(name_token, kValueProperty,
1982 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1983 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod 1983 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod
1984 : FunctionKind::kConciseMethod; 1984 : FunctionKind::kConciseMethod;
1985 1985
1986 if (in_class && !is_static && this->IsConstructor(name)) {
1987 if (is_generator) {
1988 ReportMessageAt(scanner()->location(), "constructor_special_method");
1989 *ok = false;
1990 return this->EmptyObjectLiteralProperty();
1991 }
1992
1993 kind = FunctionKind::kConstructorMethod;
1994 }
1995
1996 checker->CheckProperty(name_token, kValueProperty,
1997 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1998
1986 value = this->ParseFunctionLiteral( 1999 value = this->ParseFunctionLiteral(
1987 name, scanner()->location(), 2000 name, scanner()->location(),
1988 false, // reserved words are allowed here 2001 false, // reserved words are allowed here
1989 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, 2002 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
1990 FunctionLiteral::NORMAL_ARITY, 2003 FunctionLiteral::NORMAL_ARITY,
1991 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2004 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1992 2005
1993 } else if (in_class && name_is_static && !is_static) { 2006 } else if (in_class && name_is_static && !is_static) {
1994 // static MethodDefinition 2007 // static MethodDefinition
1995 return ParsePropertyDefinition(checker, true, true, ok); 2008 return ParsePropertyDefinition(checker, true, true, ok);
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
2750 scope_->SetScopeName(name); 2763 scope_->SetScopeName(name);
2751 2764
2752 ExpressionT extends = this->EmptyExpression(); 2765 ExpressionT extends = this->EmptyExpression();
2753 if (Check(Token::EXTENDS)) { 2766 if (Check(Token::EXTENDS)) {
2754 extends = this->ParseLeftHandSideExpression(CHECK_OK); 2767 extends = this->ParseLeftHandSideExpression(CHECK_OK);
2755 } 2768 }
2756 2769
2757 ObjectLiteralChecker checker(this, STRICT); 2770 ObjectLiteralChecker checker(this, STRICT);
2758 typename Traits::Type::PropertyList properties = 2771 typename Traits::Type::PropertyList properties =
2759 this->NewPropertyList(4, zone_); 2772 this->NewPropertyList(4, zone_);
2760 FunctionLiteralT constructor = this->EmptyFunctionLiteral(); 2773 ExpressionT constructor = this->EmptyExpression();
2761 2774
2762 Expect(Token::LBRACE, CHECK_OK); 2775 Expect(Token::LBRACE, CHECK_OK);
2763 while (peek() != Token::RBRACE) { 2776 while (peek() != Token::RBRACE) {
2764 if (Check(Token::SEMICOLON)) continue; 2777 if (Check(Token::SEMICOLON)) continue;
2765 if (fni_ != NULL) fni_->Enter(); 2778 if (fni_ != NULL) fni_->Enter();
2766 2779
2767 const bool in_class = true; 2780 const bool in_class = true;
2768 const bool is_static = false; 2781 const bool is_static = false;
2769 ObjectLiteralPropertyT property = 2782 ObjectLiteralPropertyT property =
2770 this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK); 2783 this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK);
2771 2784
2772 properties->Add(property, zone()); 2785 if (this->IsConstructorProperty(property)) {
2786 constructor = this->GetPropertyValue(property);
2787 } else {
2788 properties->Add(property, zone());
2789 }
2773 2790
2774 if (fni_ != NULL) { 2791 if (fni_ != NULL) {
2775 fni_->Infer(); 2792 fni_->Infer();
2776 fni_->Leave(); 2793 fni_->Leave();
2777 } 2794 }
2778 } 2795 }
2779 Expect(Token::RBRACE, CHECK_OK); 2796 Expect(Token::RBRACE, CHECK_OK);
2780 2797
2781 return this->ClassLiteral(name, extends, constructor, properties, pos, 2798 return this->ClassExpression(name, extends, constructor, properties, pos,
2782 factory()); 2799 factory());
2783 } 2800 }
2784 2801
2785 2802
2786 template <typename Traits> 2803 template <typename Traits>
2787 typename ParserBase<Traits>::ExpressionT 2804 typename ParserBase<Traits>::ExpressionT
2788 ParserBase<Traits>::CheckAndRewriteReferenceExpression( 2805 ParserBase<Traits>::CheckAndRewriteReferenceExpression(
2789 ExpressionT expression, 2806 ExpressionT expression,
2790 Scanner::Location location, const char* message, bool* ok) { 2807 Scanner::Location location, const char* message, bool* ok) {
2791 if (strict_mode() == STRICT && this->IsIdentifier(expression) && 2808 if (strict_mode() == STRICT && this->IsIdentifier(expression) &&
2792 this->IsEvalOrArguments(this->AsIdentifier(expression))) { 2809 this->IsEvalOrArguments(this->AsIdentifier(expression))) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 DCHECK(IsAccessorAccessorConflict(old_type, type)); 2852 DCHECK(IsAccessorAccessorConflict(old_type, type));
2836 // Both accessors of the same type. 2853 // Both accessors of the same type.
2837 parser()->ReportMessage("accessor_get_set"); 2854 parser()->ReportMessage("accessor_get_set");
2838 } 2855 }
2839 *ok = false; 2856 *ok = false;
2840 } 2857 }
2841 } 2858 }
2842 } } // v8::internal 2859 } } // v8::internal
2843 2860
2844 #endif // V8_PREPARSER_H 2861 #endif // V8_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698