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

Side by Side Diff: src/preparser.h

Issue 561913002: Class syntax parsing (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | 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/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 28 matching lines...) Expand all
39 // // In particular... 39 // // In particular...
40 // struct Type { 40 // struct Type {
41 // // Used by FunctionState and BlockState. 41 // // Used by FunctionState and BlockState.
42 // typedef Scope; 42 // typedef Scope;
43 // typedef GeneratorVariable; 43 // typedef GeneratorVariable;
44 // typedef Zone; 44 // typedef Zone;
45 // // Return types for traversing functions. 45 // // Return types for traversing functions.
46 // typedef Identifier; 46 // typedef Identifier;
47 // typedef Expression; 47 // typedef Expression;
48 // typedef FunctionLiteral; 48 // typedef FunctionLiteral;
49 // typedef ClassLiteral;
49 // typedef ObjectLiteralProperty; 50 // typedef ObjectLiteralProperty;
50 // typedef Literal; 51 // typedef Literal;
51 // typedef ExpressionList; 52 // typedef ExpressionList;
52 // typedef PropertyList; 53 // typedef PropertyList;
53 // // For constructing objects returned by the traversing functions. 54 // // For constructing objects returned by the traversing functions.
54 // typedef Factory; 55 // typedef Factory;
55 // }; 56 // };
56 // // ... 57 // // ...
57 // }; 58 // };
58 59
59 template <typename Traits> 60 template <typename Traits>
60 class ParserBase : public Traits { 61 class ParserBase : public Traits {
61 public: 62 public:
62 // Shorten type names defined by Traits. 63 // Shorten type names defined by Traits.
63 typedef typename Traits::Type::Expression ExpressionT; 64 typedef typename Traits::Type::Expression ExpressionT;
64 typedef typename Traits::Type::Identifier IdentifierT; 65 typedef typename Traits::Type::Identifier IdentifierT;
65 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; 66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
67 typedef typename Traits::Type::ClassLiteral ClassLiteralT;
66 typedef typename Traits::Type::Literal LiteralT; 68 typedef typename Traits::Type::Literal LiteralT;
67 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; 69 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
68 70
69 ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension, 71 ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension,
70 ParserRecorder* log, typename Traits::Type::Zone* zone, 72 ParserRecorder* log, typename Traits::Type::Zone* zone,
71 AstNode::IdGen* ast_node_id_gen, 73 AstNode::IdGen* ast_node_id_gen,
72 typename Traits::Type::Parser this_object) 74 typename Traits::Type::Parser this_object)
73 : Traits(this_object), 75 : Traits(this_object),
74 parenthesized_function_(false), 76 parenthesized_function_(false),
75 scope_(NULL), 77 scope_(NULL),
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // Parses an identifier and determines whether or not it is 'get' or 'set'. 478 // Parses an identifier and determines whether or not it is 'get' or 'set'.
477 IdentifierT ParseIdentifierNameOrGetOrSet(bool* is_get, 479 IdentifierT ParseIdentifierNameOrGetOrSet(bool* is_get,
478 bool* is_set, 480 bool* is_set,
479 bool* ok); 481 bool* ok);
480 482
481 ExpressionT ParseRegExpLiteral(bool seen_equal, bool* ok); 483 ExpressionT ParseRegExpLiteral(bool seen_equal, bool* ok);
482 484
483 ExpressionT ParsePrimaryExpression(bool* ok); 485 ExpressionT ParsePrimaryExpression(bool* ok);
484 ExpressionT ParseExpression(bool accept_IN, bool* ok); 486 ExpressionT ParseExpression(bool accept_IN, bool* ok);
485 ExpressionT ParseArrayLiteral(bool* ok); 487 ExpressionT ParseArrayLiteral(bool* ok);
488 IdentifierT ParsePropertyName(bool* is_get, bool* is_set, bool* is_static,
489 bool* ok);
486 ExpressionT ParseObjectLiteral(bool* ok); 490 ExpressionT ParseObjectLiteral(bool* ok);
487 ObjectLiteralPropertyT ParsePropertyDefinition(ObjectLiteralChecker* checker, 491 ObjectLiteralPropertyT ParsePropertyDefinition(ObjectLiteralChecker* checker,
492 bool in_class, bool is_static,
488 bool* ok); 493 bool* ok);
489 IdentifierT ParsePropertyName(bool* is_getter, bool* is_setter, bool* ok);
490 typename Traits::Type::ExpressionList ParseArguments(bool* ok); 494 typename Traits::Type::ExpressionList ParseArguments(bool* ok);
491 ExpressionT ParseAssignmentExpression(bool accept_IN, bool* ok); 495 ExpressionT ParseAssignmentExpression(bool accept_IN, bool* ok);
492 ExpressionT ParseYieldExpression(bool* ok); 496 ExpressionT ParseYieldExpression(bool* ok);
493 ExpressionT ParseConditionalExpression(bool accept_IN, bool* ok); 497 ExpressionT ParseConditionalExpression(bool accept_IN, bool* ok);
494 ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool* ok); 498 ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
495 ExpressionT ParseUnaryExpression(bool* ok); 499 ExpressionT ParseUnaryExpression(bool* ok);
496 ExpressionT ParsePostfixExpression(bool* ok); 500 ExpressionT ParsePostfixExpression(bool* ok);
497 ExpressionT ParseLeftHandSideExpression(bool* ok); 501 ExpressionT ParseLeftHandSideExpression(bool* ok);
498 ExpressionT ParseMemberWithNewPrefixesExpression(bool* ok); 502 ExpressionT ParseMemberWithNewPrefixesExpression(bool* ok);
499 ExpressionT ParseMemberExpression(bool* ok); 503 ExpressionT ParseMemberExpression(bool* ok);
500 ExpressionT ParseMemberExpressionContinuation(ExpressionT expression, 504 ExpressionT ParseMemberExpressionContinuation(ExpressionT expression,
501 bool* ok); 505 bool* ok);
502 ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, 506 ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast,
503 bool* ok); 507 bool* ok);
508 ClassLiteralT ParseClassLiteral(IdentifierT name,
509 Scanner::Location function_name_location,
510 bool name_is_strict_reserved, int pos,
511 bool* ok);
504 512
505 // Checks if the expression is a valid reference expression (e.g., on the 513 // Checks if the expression is a valid reference expression (e.g., on the
506 // left-hand side of assignments). Although ruled out by ECMA as early errors, 514 // left-hand side of assignments). Although ruled out by ECMA as early errors,
507 // we allow calls for web compatibility and rewrite them to a runtime throw. 515 // we allow calls for web compatibility and rewrite them to a runtime throw.
508 ExpressionT CheckAndRewriteReferenceExpression( 516 ExpressionT CheckAndRewriteReferenceExpression(
509 ExpressionT expression, 517 ExpressionT expression,
510 Scanner::Location location, const char* message, bool* ok); 518 Scanner::Location location, const char* message, bool* ok);
511 519
512 // Used to detect duplicates in object literals. Each of the values 520 // Used to detect duplicates in object literals. Each of the values
513 // kGetterProperty, kSetterProperty and kValueProperty represents 521 // kGetterProperty, kSetterProperty and kValueProperty represents
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 617 }
610 static PreParserIdentifier FutureStrictReserved() { 618 static PreParserIdentifier FutureStrictReserved() {
611 return PreParserIdentifier(kFutureStrictReservedIdentifier); 619 return PreParserIdentifier(kFutureStrictReservedIdentifier);
612 } 620 }
613 static PreParserIdentifier Let() { 621 static PreParserIdentifier Let() {
614 return PreParserIdentifier(kLetIdentifier); 622 return PreParserIdentifier(kLetIdentifier);
615 } 623 }
616 static PreParserIdentifier Yield() { 624 static PreParserIdentifier Yield() {
617 return PreParserIdentifier(kYieldIdentifier); 625 return PreParserIdentifier(kYieldIdentifier);
618 } 626 }
627 static PreParserIdentifier Prototype() {
628 return PreParserIdentifier(kPrototypeIdentifier);
629 }
630 static PreParserIdentifier Constructor() {
631 return PreParserIdentifier(kConstructorIdentifier);
632 }
619 bool IsEval() const { return type_ == kEvalIdentifier; } 633 bool IsEval() const { return type_ == kEvalIdentifier; }
620 bool IsArguments() const { return type_ == kArgumentsIdentifier; } 634 bool IsArguments() const { return type_ == kArgumentsIdentifier; }
635 bool IsYield() const { return type_ == kYieldIdentifier; }
636 bool IsPrototype() const { return type_ == kPrototypeIdentifier; }
637 bool IsConstructor() const { return type_ == kConstructorIdentifier; }
621 bool IsEvalOrArguments() const { return type_ >= kEvalIdentifier; } 638 bool IsEvalOrArguments() const { return type_ >= kEvalIdentifier; }
marja 2014/09/15 09:24:29 Nit: I'd just get rid of the >= trickery altogethe
rossberg 2014/09/15 12:32:48 I agree.
arv (Not doing code reviews) 2014/09/15 15:12:32 Done.
622 bool IsYield() const { return type_ == kYieldIdentifier; }
623 bool IsFutureReserved() const { return type_ == kFutureReservedIdentifier; } 639 bool IsFutureReserved() const { return type_ == kFutureReservedIdentifier; }
624 bool IsFutureStrictReserved() const { 640 bool IsFutureStrictReserved() const {
625 return type_ == kFutureStrictReservedIdentifier; 641 return type_ == kFutureStrictReservedIdentifier;
626 } 642 }
627 bool IsValidStrictVariable() const { return type_ == kUnknownIdentifier; } 643 bool IsValidStrictVariable() const { return type_ == kUnknownIdentifier; }
628 644
629 // Allow identifier->name()[->length()] to work. The preparser 645 // Allow identifier->name()[->length()] to work. The preparser
630 // does not need the actual positions/lengths of the identifiers. 646 // does not need the actual positions/lengths of the identifiers.
631 const PreParserIdentifier* operator->() const { return this; } 647 const PreParserIdentifier* operator->() const { return this; }
632 const PreParserIdentifier raw_name() const { return *this; } 648 const PreParserIdentifier raw_name() const { return *this; }
633 649
634 int position() const { return 0; } 650 int position() const { return 0; }
635 int length() const { return 0; } 651 int length() const { return 0; }
636 652
637 private: 653 private:
638 enum Type { 654 enum Type {
639 kUnknownIdentifier, 655 kUnknownIdentifier,
640 kFutureReservedIdentifier, 656 kFutureReservedIdentifier,
641 kFutureStrictReservedIdentifier, 657 kFutureStrictReservedIdentifier,
642 kLetIdentifier, 658 kLetIdentifier,
643 kYieldIdentifier, 659 kYieldIdentifier,
660 kPrototypeIdentifier,
661 kConstructorIdentifier,
644 kEvalIdentifier, 662 kEvalIdentifier,
645 kArgumentsIdentifier 663 kArgumentsIdentifier
646 }; 664 };
647 explicit PreParserIdentifier(Type type) : type_(type) {} 665 explicit PreParserIdentifier(Type type) : type_(type) {}
648 Type type_; 666 Type type_;
649 667
650 friend class PreParserExpression; 668 friend class PreParserExpression;
651 friend class PreParserScope; 669 friend class PreParserScope;
652 }; 670 };
653 671
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 public: 942 public:
925 explicit PreParserScope(PreParserScope* outer_scope, ScopeType scope_type, 943 explicit PreParserScope(PreParserScope* outer_scope, ScopeType scope_type,
926 void* = NULL) 944 void* = NULL)
927 : scope_type_(scope_type) { 945 : scope_type_(scope_type) {
928 strict_mode_ = outer_scope ? outer_scope->strict_mode() : SLOPPY; 946 strict_mode_ = outer_scope ? outer_scope->strict_mode() : SLOPPY;
929 } 947 }
930 948
931 ScopeType type() { return scope_type_; } 949 ScopeType type() { return scope_type_; }
932 StrictMode strict_mode() const { return strict_mode_; } 950 StrictMode strict_mode() const { return strict_mode_; }
933 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } 951 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; }
952 void SetScopeName(PreParserIdentifier name) {}
934 953
935 // When PreParser is in use, lazy compilation is already being done, 954 // When PreParser is in use, lazy compilation is already being done,
936 // things cannot get lazier than that. 955 // things cannot get lazier than that.
937 bool AllowsLazyCompilation() const { return false; } 956 bool AllowsLazyCompilation() const { return false; }
938 957
939 void set_start_position(int position) {} 958 void set_start_position(int position) {}
940 void set_end_position(int position) {} 959 void set_end_position(int position) {}
941 960
942 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; } 961 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; }
943 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {} 962 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {}
(...skipping 24 matching lines...) Expand all
968 int pos) { 987 int pos) {
969 return PreParserExpression::Default(); 988 return PreParserExpression::Default();
970 } 989 }
971 PreParserExpression NewArrayLiteral(PreParserExpressionList values, 990 PreParserExpression NewArrayLiteral(PreParserExpressionList values,
972 int literal_index, 991 int literal_index,
973 int pos) { 992 int pos) {
974 return PreParserExpression::Default(); 993 return PreParserExpression::Default();
975 } 994 }
976 PreParserExpression NewObjectLiteralProperty(bool is_getter, 995 PreParserExpression NewObjectLiteralProperty(bool is_getter,
977 PreParserExpression value, 996 PreParserExpression value,
978 int pos) { 997 int pos, bool is_static) {
979 return PreParserExpression::Default(); 998 return PreParserExpression::Default();
980 } 999 }
981 PreParserExpression NewObjectLiteralProperty(PreParserExpression key, 1000 PreParserExpression NewObjectLiteralProperty(PreParserExpression key,
982 PreParserExpression value) { 1001 PreParserExpression value,
1002 bool is_static) {
983 return PreParserExpression::Default(); 1003 return PreParserExpression::Default();
984 } 1004 }
985 PreParserExpression NewObjectLiteral(PreParserExpressionList properties, 1005 PreParserExpression NewObjectLiteral(PreParserExpressionList properties,
986 int literal_index, 1006 int literal_index,
987 int boilerplate_properties, 1007 int boilerplate_properties,
988 bool has_function, 1008 bool has_function,
989 int pos) { 1009 int pos) {
990 return PreParserExpression::Default(); 1010 return PreParserExpression::Default();
991 } 1011 }
992 PreParserExpression NewVariableProxy(void* generator_variable) { 1012 PreParserExpression NewVariableProxy(void* variable) {
993 return PreParserExpression::Default(); 1013 return PreParserExpression::Default();
994 } 1014 }
995 PreParserExpression NewProperty(PreParserExpression obj, 1015 PreParserExpression NewProperty(PreParserExpression obj,
996 PreParserExpression key, 1016 PreParserExpression key,
997 int pos) { 1017 int pos) {
998 if (obj.IsThis()) { 1018 if (obj.IsThis()) {
999 return PreParserExpression::ThisProperty(); 1019 return PreParserExpression::ThisProperty();
1000 } 1020 }
1001 return PreParserExpression::Property(); 1021 return PreParserExpression::Property();
1002 } 1022 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 const PreParserScope& scope, PreParserStatementList body, 1078 const PreParserScope& scope, PreParserStatementList body,
1059 int materialized_literal_count, int expected_property_count, 1079 int materialized_literal_count, int expected_property_count,
1060 int handler_count, int parameter_count, 1080 int handler_count, int parameter_count,
1061 FunctionLiteral::ParameterFlag has_duplicate_parameters, 1081 FunctionLiteral::ParameterFlag has_duplicate_parameters,
1062 FunctionLiteral::FunctionType function_type, 1082 FunctionLiteral::FunctionType function_type,
1063 FunctionLiteral::IsFunctionFlag is_function, 1083 FunctionLiteral::IsFunctionFlag is_function,
1064 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, 1084 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
1065 int position) { 1085 int position) {
1066 return PreParserExpression::Default(); 1086 return PreParserExpression::Default();
1067 } 1087 }
1088 PreParserExpression NewClassLiteral(PreParserIdentifier name,
1089 PreParserExpression extends,
1090 PreParserExpression constructor,
1091 PreParserExpressionList properties,
1092 AstValueFactory* ast_value_factory,
1093 int position) {
1094 return PreParserExpression::Default();
1095 }
1068 1096
1069 // Return the object itself as AstVisitor and implement the needed 1097 // Return the object itself as AstVisitor and implement the needed
1070 // dummy method right in this class. 1098 // dummy method right in this class.
1071 PreParserFactory* visitor() { return this; } 1099 PreParserFactory* visitor() { return this; }
1072 BailoutReason dont_optimize_reason() { return kNoReason; } 1100 BailoutReason dont_optimize_reason() { return kNoReason; }
1073 int* ast_properties() { 1101 int* ast_properties() {
1074 static int dummy = 42; 1102 static int dummy = 42;
1075 return &dummy; 1103 return &dummy;
1076 } 1104 }
1077 }; 1105 };
(...skipping 18 matching lines...) Expand all
1096 typedef void Zone; 1124 typedef void Zone;
1097 1125
1098 typedef int AstProperties; 1126 typedef int AstProperties;
1099 typedef Vector<PreParserIdentifier> ParameterIdentifierVector; 1127 typedef Vector<PreParserIdentifier> ParameterIdentifierVector;
1100 1128
1101 // Return types for traversing functions. 1129 // Return types for traversing functions.
1102 typedef PreParserIdentifier Identifier; 1130 typedef PreParserIdentifier Identifier;
1103 typedef PreParserExpression Expression; 1131 typedef PreParserExpression Expression;
1104 typedef PreParserExpression YieldExpression; 1132 typedef PreParserExpression YieldExpression;
1105 typedef PreParserExpression FunctionLiteral; 1133 typedef PreParserExpression FunctionLiteral;
1134 typedef PreParserExpression ClassLiteral;
1106 typedef PreParserExpression ObjectLiteralProperty; 1135 typedef PreParserExpression ObjectLiteralProperty;
1107 typedef PreParserExpression Literal; 1136 typedef PreParserExpression Literal;
1108 typedef PreParserExpressionList ExpressionList; 1137 typedef PreParserExpressionList ExpressionList;
1109 typedef PreParserExpressionList PropertyList; 1138 typedef PreParserExpressionList PropertyList;
1110 typedef PreParserStatementList StatementList; 1139 typedef PreParserStatementList StatementList;
1111 1140
1112 // For constructing objects returned by the traversing functions. 1141 // For constructing objects returned by the traversing functions.
1113 typedef PreParserFactory Factory; 1142 typedef PreParserFactory Factory;
1114 }; 1143 };
1115 1144
1116 class Checkpoint; 1145 class Checkpoint;
1117 1146
1118 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} 1147 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {}
1119 1148
1120 // Custom operations executed when FunctionStates are created and 1149 // Custom operations executed when FunctionStates are created and
1121 // destructed. (The PreParser doesn't need to do anything.) 1150 // destructed. (The PreParser doesn't need to do anything.)
1122 template <typename FunctionState> 1151 template <typename FunctionState>
1123 static void SetUpFunctionState(FunctionState* function_state) {} 1152 static void SetUpFunctionState(FunctionState* function_state) {}
1124 template <typename FunctionState> 1153 template <typename FunctionState>
1125 static void TearDownFunctionState(FunctionState* function_state) {} 1154 static void TearDownFunctionState(FunctionState* function_state) {}
1126 1155
1127 // Helper functions for recursive descent. 1156 // Helper functions for recursive descent.
1128 static bool IsEvalOrArguments(PreParserIdentifier identifier) { 1157 static bool IsEvalOrArguments(PreParserIdentifier identifier) {
1129 return identifier.IsEvalOrArguments(); 1158 return identifier.IsEvalOrArguments();
1130 } 1159 }
1131 1160
1161 static bool IsPrototype(PreParserIdentifier identifier) {
1162 return identifier.IsPrototype();
1163 }
1164
1165 static bool IsConstructor(PreParserIdentifier identifier) {
1166 return identifier.IsConstructor();
1167 }
1168
1132 // Returns true if the expression is of type "this.foo". 1169 // Returns true if the expression is of type "this.foo".
1133 static bool IsThisProperty(PreParserExpression expression) { 1170 static bool IsThisProperty(PreParserExpression expression) {
1134 return expression.IsThisProperty(); 1171 return expression.IsThisProperty();
1135 } 1172 }
1136 1173
1137 static bool IsIdentifier(PreParserExpression expression) { 1174 static bool IsIdentifier(PreParserExpression expression) {
1138 return expression.IsIdentifier(); 1175 return expression.IsIdentifier();
1139 } 1176 }
1140 1177
1141 static PreParserIdentifier AsIdentifier(PreParserExpression expression) { 1178 static PreParserIdentifier AsIdentifier(PreParserExpression expression) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1279 }
1243 static PreParserExpression EmptyArrowParamList() { 1280 static PreParserExpression EmptyArrowParamList() {
1244 return PreParserExpression::EmptyArrowParamList(); 1281 return PreParserExpression::EmptyArrowParamList();
1245 } 1282 }
1246 static PreParserExpression EmptyLiteral() { 1283 static PreParserExpression EmptyLiteral() {
1247 return PreParserExpression::Default(); 1284 return PreParserExpression::Default();
1248 } 1285 }
1249 static PreParserExpression EmptyObjectLiteralProperty() { 1286 static PreParserExpression EmptyObjectLiteralProperty() {
1250 return PreParserExpression::Default(); 1287 return PreParserExpression::Default();
1251 } 1288 }
1289 static PreParserExpression EmptyFunctionLiteral() {
1290 return PreParserExpression::Default();
1291 }
1292 static PreParserExpression EmptyClassLiteral() {
1293 return PreParserExpression::Default();
1294 }
1252 static PreParserExpressionList NullExpressionList() { 1295 static PreParserExpressionList NullExpressionList() {
1253 return PreParserExpressionList(); 1296 return PreParserExpressionList();
1254 } 1297 }
1255 1298
1256 // Odd-ball literal creators. 1299 // Odd-ball literal creators.
1257 static PreParserExpression GetLiteralTheHole(int position, 1300 static PreParserExpression GetLiteralTheHole(int position,
1258 PreParserFactory* factory) { 1301 PreParserFactory* factory) {
1259 return PreParserExpression::Default(); 1302 return PreParserExpression::Default();
1260 } 1303 }
1261 1304
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 }; 1475 };
1433 1476
1434 // All ParseXXX functions take as the last argument an *ok parameter 1477 // All ParseXXX functions take as the last argument an *ok parameter
1435 // which is set to false if parsing failed; it is unchanged otherwise. 1478 // which is set to false if parsing failed; it is unchanged otherwise.
1436 // By making the 'exception handling' explicit, we are forced to check 1479 // By making the 'exception handling' explicit, we are forced to check
1437 // for failure at the call sites. 1480 // for failure at the call sites.
1438 Statement ParseSourceElement(bool* ok); 1481 Statement ParseSourceElement(bool* ok);
1439 SourceElements ParseSourceElements(int end_token, bool* ok); 1482 SourceElements ParseSourceElements(int end_token, bool* ok);
1440 Statement ParseStatement(bool* ok); 1483 Statement ParseStatement(bool* ok);
1441 Statement ParseFunctionDeclaration(bool* ok); 1484 Statement ParseFunctionDeclaration(bool* ok);
1485 Statement ParseClassDeclaration(bool* ok);
1442 Statement ParseBlock(bool* ok); 1486 Statement ParseBlock(bool* ok);
1443 Statement ParseVariableStatement(VariableDeclarationContext var_context, 1487 Statement ParseVariableStatement(VariableDeclarationContext var_context,
1444 bool* ok); 1488 bool* ok);
1445 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, 1489 Statement ParseVariableDeclarations(VariableDeclarationContext var_context,
1446 VariableDeclarationProperties* decl_props, 1490 VariableDeclarationProperties* decl_props,
1447 int* num_decl, 1491 int* num_decl,
1448 bool* ok); 1492 bool* ok);
1449 Statement ParseExpressionOrLabelledStatement(bool* ok); 1493 Statement ParseExpressionOrLabelledStatement(bool* ok);
1450 Statement ParseIfStatement(bool* ok); 1494 Statement ParseIfStatement(bool* ok);
1451 Statement ParseContinueStatement(bool* ok); 1495 Statement ParseContinueStatement(bool* ok);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 // 'this' 1749 // 'this'
1706 // 'null' 1750 // 'null'
1707 // 'true' 1751 // 'true'
1708 // 'false' 1752 // 'false'
1709 // Identifier 1753 // Identifier
1710 // Number 1754 // Number
1711 // String 1755 // String
1712 // ArrayLiteral 1756 // ArrayLiteral
1713 // ObjectLiteral 1757 // ObjectLiteral
1714 // RegExpLiteral 1758 // RegExpLiteral
1759 // ClassLiteral
1715 // '(' Expression ')' 1760 // '(' Expression ')'
1716 1761
1717 int pos = peek_position(); 1762 int pos = peek_position();
1718 ExpressionT result = this->EmptyExpression(); 1763 ExpressionT result = this->EmptyExpression();
1719 Token::Value token = peek(); 1764 Token::Value token = peek();
1720 switch (token) { 1765 switch (token) {
1721 case Token::THIS: { 1766 case Token::THIS: {
1722 Consume(Token::THIS); 1767 Consume(Token::THIS);
1723 result = this->ThisExpression(scope_, factory()); 1768 result = this->ThisExpression(scope_, factory());
1724 break; 1769 break;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 } else { 1820 } else {
1776 // Heuristically try to detect immediately called functions before 1821 // Heuristically try to detect immediately called functions before
1777 // seeing the call parentheses. 1822 // seeing the call parentheses.
1778 parenthesized_function_ = (peek() == Token::FUNCTION); 1823 parenthesized_function_ = (peek() == Token::FUNCTION);
1779 result = this->ParseExpression(true, CHECK_OK); 1824 result = this->ParseExpression(true, CHECK_OK);
1780 result->increase_parenthesization_level(); 1825 result->increase_parenthesization_level();
1781 Expect(Token::RPAREN, CHECK_OK); 1826 Expect(Token::RPAREN, CHECK_OK);
1782 } 1827 }
1783 break; 1828 break;
1784 1829
1830 case Token::CLASS: {
1831 Consume(Token::CLASS);
1832 int class_token_position = position();
1833 IdentifierT name = this->EmptyIdentifier();
1834 bool is_strict_reserved_name = false;
1835 Scanner::Location class_name_location = Scanner::Location::invalid();
1836 if (peek_any_identifier()) {
1837 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
1838 CHECK_OK);
1839 class_name_location = scanner()->location();
1840 }
1841 result = this->ParseClassLiteral(name, class_name_location,
1842 is_strict_reserved_name,
1843 class_token_position, CHECK_OK);
1844 break;
1845 }
1846
1785 case Token::MOD: 1847 case Token::MOD:
1786 if (allow_natives_syntax() || extension_ != NULL) { 1848 if (allow_natives_syntax() || extension_ != NULL) {
1787 result = this->ParseV8Intrinsic(CHECK_OK); 1849 result = this->ParseV8Intrinsic(CHECK_OK);
1788 break; 1850 break;
1789 } 1851 }
1790 // If we're not allowing special syntax we fall-through to the 1852 // If we're not allowing special syntax we fall-through to the
1791 // default case. 1853 // default case.
1792 1854
1793 default: { 1855 default: {
1794 Next(); 1856 Next();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 1907
1846 // Update the scope information before the pre-parsing bailout. 1908 // Update the scope information before the pre-parsing bailout.
1847 int literal_index = function_state_->NextMaterializedLiteralIndex(); 1909 int literal_index = function_state_->NextMaterializedLiteralIndex();
1848 1910
1849 return factory()->NewArrayLiteral(values, literal_index, pos); 1911 return factory()->NewArrayLiteral(values, literal_index, pos);
1850 } 1912 }
1851 1913
1852 1914
1853 template <class Traits> 1915 template <class Traits>
1854 typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParsePropertyName( 1916 typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParsePropertyName(
1855 bool* is_getter, bool* is_setter, bool* ok) { 1917 bool* is_get, bool* is_set, bool* is_static, bool* ok) {
1856 Token::Value next = peek(); 1918 Token::Value next = peek();
1857 switch (next) { 1919 switch (next) {
1858 case Token::STRING: 1920 case Token::STRING:
1859 Consume(Token::STRING); 1921 Consume(Token::STRING);
1860 return this->GetSymbol(scanner_); 1922 return this->GetSymbol(scanner_);
1861 case Token::NUMBER: 1923 case Token::NUMBER:
1862 Consume(Token::NUMBER); 1924 Consume(Token::NUMBER);
1863 return this->GetNumberAsSymbol(scanner_); 1925 return this->GetNumberAsSymbol(scanner_);
1926 case Token::STATIC:
1927 *is_static = true;
1928 // Fall through.
1864 default: 1929 default:
1865 return ParseIdentifierNameOrGetOrSet(is_getter, is_setter, 1930 return ParseIdentifierNameOrGetOrSet(is_get, is_set, ok);
1866 CHECK_OK_CUSTOM(EmptyIdentifier));
1867 } 1931 }
1932 UNREACHABLE();
1933 return this->EmptyIdentifier();
1868 } 1934 }
1869 1935
1870 1936
1871 template <class Traits> 1937 template <class Traits>
1872 typename ParserBase<Traits>::ObjectLiteralPropertyT ParserBase< 1938 typename ParserBase<Traits>::ObjectLiteralPropertyT ParserBase<
1873 Traits>::ParsePropertyDefinition(ObjectLiteralChecker* checker, bool* ok) { 1939 Traits>::ParsePropertyDefinition(ObjectLiteralChecker* checker,
1940 bool in_class, bool is_static, bool* ok) {
1874 // TODO(arv): Add support for concise generator methods. 1941 // TODO(arv): Add support for concise generator methods.
1875 ExpressionT value = this->EmptyExpression(); 1942 ExpressionT value = this->EmptyExpression();
1876 bool is_getter = false; 1943 bool is_get = false;
1877 bool is_setter = false; 1944 bool is_set = false;
1945 bool name_is_static = false;
1878 Token::Value name_token = peek(); 1946 Token::Value name_token = peek();
1879 int next_pos = peek_position(); 1947 int next_pos = peek_position();
1880 IdentifierT name = ParsePropertyName( 1948 IdentifierT name =
1881 &is_getter, &is_setter, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1949 ParsePropertyName(&is_get, &is_set, &name_is_static,
1950 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1951
1882 if (fni_ != NULL) this->PushLiteralName(fni_, name); 1952 if (fni_ != NULL) this->PushLiteralName(fni_, name);
1883 1953
1884 if (peek() == Token::COLON) { 1954 if (!in_class && peek() == Token::COLON) {
1885 // PropertyDefinition : PropertyName ':' AssignmentExpression 1955 // PropertyDefinition : PropertyName ':' AssignmentExpression
1886 checker->CheckProperty(name_token, kValueProperty, 1956 checker->CheckProperty(name_token, kValueProperty,
1887 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1957 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1888 Consume(Token::COLON); 1958 Consume(Token::COLON);
1889 value = this->ParseAssignmentExpression( 1959 value = this->ParseAssignmentExpression(
1890 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1960 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1891 1961
1892 } else if (allow_harmony_object_literals_ && peek() == Token::LPAREN) { 1962 } else if (allow_harmony_object_literals_ && peek() == Token::LPAREN) {
1893 // Concise Method 1963 // Concise Method
1964
1965 if (is_static && this->IsPrototype(name)) {
1966 ReportMessageAt(scanner()->location(), "static_prototype");
1967 *ok = false;
1968 return this->EmptyObjectLiteralProperty();
1969 }
1970
1894 checker->CheckProperty(name_token, kValueProperty, 1971 checker->CheckProperty(name_token, kValueProperty,
1895 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1972 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1896 value = this->ParseFunctionLiteral( 1973 value = this->ParseFunctionLiteral(
1897 name, scanner()->location(), 1974 name, scanner()->location(),
1898 false, // reserved words are allowed here 1975 false, // reserved words are allowed here
1899 FunctionKind::kConciseMethod, RelocInfo::kNoPosition, 1976 FunctionKind::kConciseMethod, RelocInfo::kNoPosition,
1900 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::NORMAL_ARITY, 1977 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::NORMAL_ARITY,
1901 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1978 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1902 1979
1903 } else if (is_getter || is_setter) { 1980 } else if (in_class && name_is_static && !is_static) {
rossberg 2014/09/15 12:32:48 Hm, I'd prefer pulling recognising 'static' out of
arv (Not doing code reviews) 2014/09/15 15:12:32 That gets a lot more complicated. The problem is t
1981 // static MethodDefinition
1982 return ParsePropertyDefinition(checker, true, true, ok);
1983
1984 } else if (is_get || is_set) {
1904 // Accessor 1985 // Accessor
1905 bool dont_care = false; 1986 bool dont_care = false;
1906 name_token = peek(); 1987 name_token = peek();
1907 name = ParsePropertyName(&dont_care, &dont_care, 1988 name = ParsePropertyName(&dont_care, &dont_care, &dont_care,
1908 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1989 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1990
1909 // Validate the property. 1991 // Validate the property.
1992 if (is_static && this->IsPrototype(name)) {
1993 ReportMessageAt(scanner()->location(), "static_prototype");
1994 *ok = false;
1995 return this->EmptyObjectLiteralProperty();
1996 } else if (in_class && this->IsConstructor(name)) {
1997 ReportMessageAt(scanner()->location(), "constructor_special_method");
1998 *ok = false;
1999 return this->EmptyObjectLiteralProperty();
2000 }
1910 checker->CheckProperty(name_token, 2001 checker->CheckProperty(name_token,
1911 is_getter ? kGetterProperty : kSetterProperty, 2002 is_get ? kGetterProperty : kSetterProperty,
1912 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2003 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2004
1913 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( 2005 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
1914 name, scanner()->location(), 2006 name, scanner()->location(),
1915 false, // reserved words are allowed here 2007 false, // reserved words are allowed here
1916 FunctionKind::kNormalFunction, RelocInfo::kNoPosition, 2008 FunctionKind::kNormalFunction, RelocInfo::kNoPosition,
1917 FunctionLiteral::ANONYMOUS_EXPRESSION, 2009 FunctionLiteral::ANONYMOUS_EXPRESSION,
1918 is_getter ? FunctionLiteral::GETTER_ARITY 2010 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY,
1919 : FunctionLiteral::SETTER_ARITY,
1920 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2011 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1921 return factory()->NewObjectLiteralProperty(is_getter, value, next_pos); 2012 return factory()->NewObjectLiteralProperty(is_get, value, next_pos,
2013 is_static);
1922 } else { 2014 } else {
1923 Token::Value next = Next(); 2015 Token::Value next = Next();
1924 ReportUnexpectedToken(next); 2016 ReportUnexpectedToken(next);
1925 *ok = false; 2017 *ok = false;
1926 return this->EmptyObjectLiteralProperty(); 2018 return this->EmptyObjectLiteralProperty();
1927 } 2019 }
1928 2020
1929 uint32_t index; 2021 uint32_t index;
1930 LiteralT key = this->IsArrayIndex(name, &index) 2022 LiteralT key = this->IsArrayIndex(name, &index)
1931 ? factory()->NewNumberLiteral(index, next_pos) 2023 ? factory()->NewNumberLiteral(index, next_pos)
1932 : factory()->NewStringLiteral(name, next_pos); 2024 : factory()->NewStringLiteral(name, next_pos);
1933 2025
1934 return factory()->NewObjectLiteralProperty(key, value); 2026 return factory()->NewObjectLiteralProperty(key, value, is_static);
1935 } 2027 }
1936 2028
1937 2029
1938 template <class Traits> 2030 template <class Traits>
1939 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( 2031 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral(
1940 bool* ok) { 2032 bool* ok) {
1941 // ObjectLiteral :: 2033 // ObjectLiteral ::
1942 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' 2034 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
1943 2035
1944 int pos = peek_position(); 2036 int pos = peek_position();
1945 typename Traits::Type::PropertyList properties = 2037 typename Traits::Type::PropertyList properties =
1946 this->NewPropertyList(4, zone_); 2038 this->NewPropertyList(4, zone_);
1947 int number_of_boilerplate_properties = 0; 2039 int number_of_boilerplate_properties = 0;
1948 bool has_function = false; 2040 bool has_function = false;
1949 2041
1950 ObjectLiteralChecker checker(this, strict_mode()); 2042 ObjectLiteralChecker checker(this, strict_mode());
1951 2043
1952 Expect(Token::LBRACE, CHECK_OK); 2044 Expect(Token::LBRACE, CHECK_OK);
1953 2045
2046 const bool in_class = false;
2047 const bool is_static = false;
1954 while (peek() != Token::RBRACE) { 2048 while (peek() != Token::RBRACE) {
1955 if (fni_ != NULL) fni_->Enter(); 2049 if (fni_ != NULL) fni_->Enter();
1956 2050
1957 ObjectLiteralPropertyT property = 2051 ObjectLiteralPropertyT property =
1958 this->ParsePropertyDefinition(&checker, CHECK_OK); 2052 this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK);
1959 2053
1960 // Mark top-level object literals that contain function literals and 2054 // Mark top-level object literals that contain function literals and
1961 // pretenure the literal so it can be added as a constant function 2055 // pretenure the literal so it can be added as a constant function
1962 // property. (Parser only.) 2056 // property. (Parser only.)
1963 this->CheckFunctionLiteralInsideTopLevelObjectLiteral(scope_, property, 2057 this->CheckFunctionLiteralInsideTopLevelObjectLiteral(scope_, property,
1964 &has_function); 2058 &has_function);
1965 2059
1966 // Count CONSTANT or COMPUTED properties to maintain the enumeration order. 2060 // Count CONSTANT or COMPUTED properties to maintain the enumeration order.
1967 if (this->IsBoilerplateProperty(property)) { 2061 if (this->IsBoilerplateProperty(property)) {
1968 number_of_boilerplate_properties++; 2062 number_of_boilerplate_properties++;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 } 2491 }
2398 // No 'new' or 'super' keyword. 2492 // No 'new' or 'super' keyword.
2399 return this->ParseMemberExpression(ok); 2493 return this->ParseMemberExpression(ok);
2400 } 2494 }
2401 2495
2402 2496
2403 template <class Traits> 2497 template <class Traits>
2404 typename ParserBase<Traits>::ExpressionT 2498 typename ParserBase<Traits>::ExpressionT
2405 ParserBase<Traits>::ParseMemberExpression(bool* ok) { 2499 ParserBase<Traits>::ParseMemberExpression(bool* ok) {
2406 // MemberExpression :: 2500 // MemberExpression ::
2407 // (PrimaryExpression | FunctionLiteral) 2501 // (PrimaryExpression | FunctionLiteral | ClassLiteral)
2408 // ('[' Expression ']' | '.' Identifier | Arguments)* 2502 // ('[' Expression ']' | '.' Identifier | Arguments)*
2409 2503
2410 // The '[' Expression ']' and '.' Identifier parts are parsed by 2504 // The '[' Expression ']' and '.' Identifier parts are parsed by
2411 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the 2505 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the
2412 // caller. 2506 // caller.
2413 2507
2414 // Parse the initial primary or function expression. 2508 // Parse the initial primary or function expression.
2415 ExpressionT result = this->EmptyExpression(); 2509 ExpressionT result = this->EmptyExpression();
2416 if (peek() == Token::FUNCTION) { 2510 if (peek() == Token::FUNCTION) {
2417 Consume(Token::FUNCTION); 2511 Consume(Token::FUNCTION);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 function_literal->set_function_token_position(start_pos); 2694 function_literal->set_function_token_position(start_pos);
2601 function_literal->set_ast_properties(&ast_properties); 2695 function_literal->set_ast_properties(&ast_properties);
2602 function_literal->set_dont_optimize_reason(dont_optimize_reason); 2696 function_literal->set_dont_optimize_reason(dont_optimize_reason);
2603 2697
2604 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); 2698 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
2605 2699
2606 return function_literal; 2700 return function_literal;
2607 } 2701 }
2608 2702
2609 2703
2704 template <class Traits>
2705 typename ParserBase<Traits>::ClassLiteralT
2706 ParserBase<Traits>::ParseClassLiteral(IdentifierT name,
2707 Scanner::Location class_name_location,
2708 bool name_is_strict_reserved, int pos,
2709 bool* ok) {
2710 // All parts of a ClassDeclaration or a ClassExpression are strict code.
2711 if (name_is_strict_reserved) {
2712 ReportMessageAt(class_name_location, "unexpected_strict_reserved");
2713 *ok = false;
2714 return this->EmptyClassLiteral();
2715 }
2716 if (this->IsEvalOrArguments(name)) {
2717 ReportMessageAt(class_name_location, "strict_eval_arguments");
2718 *ok = false;
2719 return this->EmptyClassLiteral();
2720 }
2721
2722 typename Traits::Type::ScopePtr extends_scope =
2723 this->NewScope(scope_, BLOCK_SCOPE);
rossberg 2014/09/15 12:32:48 Why does the extends clause need its own scope?
arv (Not doing code reviews) 2014/09/15 15:12:32 This is premature. My thinking was this. 1. The e
rossberg 2014/09/16 15:25:40 I see, oh dear. Having a strict pseudo scope for t
2724 FunctionState extends_function_state(
2725 &function_state_, &scope_, &extends_scope, zone(),
2726 this->ast_value_factory(), ast_node_id_gen_);
2727 scope_->SetStrictMode(STRICT);
2728 scope_->SetScopeName(name);
2729
2730 ExpressionT extends = this->EmptyExpression();
2731 if (Check(Token::EXTENDS)) {
2732 extends =
2733 this->ParseLeftHandSideExpression(CHECK_OK_CUSTOM(EmptyClassLiteral));
2734 }
2735
2736 // The name binding is only visible inside the class body (not the extends
2737 // expression).
2738 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE);
rossberg 2014/09/15 12:32:48 I'm not sure it will work out to reuse BLOCK_SCOPE
arv (Not doing code reviews) 2014/09/15 15:12:32 I agree that this is not obvious at this point. I'
2739 FunctionState function_state(&function_state_, &scope_, &scope, zone(),
2740 this->ast_value_factory(), ast_node_id_gen_);
2741 // TODO(arv): Add binding if the class literal has a name.
2742
2743 ObjectLiteralChecker checker(this, STRICT);
2744 const bool in_class = true;
2745 const bool is_static = false;
rossberg 2014/09/15 12:32:48 Nit: If you find it worth naming these constants,
arv (Not doing code reviews) 2014/09/15 15:12:32 Done.
2746 typename Traits::Type::PropertyList properties =
2747 this->NewPropertyList(4, zone_);
2748 FunctionLiteralT constructor = this->EmptyFunctionLiteral();
2749
2750 Expect(Token::LBRACE, CHECK_OK_CUSTOM(EmptyClassLiteral));
2751 while (peek() != Token::RBRACE) {
2752 if (Check(Token::SEMICOLON)) continue;
2753 if (fni_ != NULL) fni_->Enter();
2754
2755 ObjectLiteralPropertyT property = this->ParsePropertyDefinition(
rossberg 2014/09/15 12:32:48 I'd prefer to check for 'static' here. That would
arv (Not doing code reviews) 2014/09/15 15:12:32 Storing two separate list is not going to work bec
rossberg 2014/09/16 15:25:40 Oh hell. Make sure to add the above as a test case
2756 &checker, in_class, is_static, CHECK_OK_CUSTOM(EmptyClassLiteral));
2757
2758 properties->Add(property, zone());
2759
2760 if (fni_ != NULL) {
2761 fni_->Infer();
2762 fni_->Leave();
2763 }
2764 }
2765 Expect(Token::RBRACE, CHECK_OK_CUSTOM(EmptyClassLiteral));
2766
2767 return factory()->NewClassLiteral(name, extends, constructor, properties,
2768 this->ast_value_factory(), pos);
2769 }
2770
2771
2610 template <typename Traits> 2772 template <typename Traits>
2611 typename ParserBase<Traits>::ExpressionT 2773 typename ParserBase<Traits>::ExpressionT
2612 ParserBase<Traits>::CheckAndRewriteReferenceExpression( 2774 ParserBase<Traits>::CheckAndRewriteReferenceExpression(
2613 ExpressionT expression, 2775 ExpressionT expression,
2614 Scanner::Location location, const char* message, bool* ok) { 2776 Scanner::Location location, const char* message, bool* ok) {
2615 if (strict_mode() == STRICT && this->IsIdentifier(expression) && 2777 if (strict_mode() == STRICT && this->IsIdentifier(expression) &&
2616 this->IsEvalOrArguments(this->AsIdentifier(expression))) { 2778 this->IsEvalOrArguments(this->AsIdentifier(expression))) {
2617 this->ReportMessageAt(location, "strict_eval_arguments", false); 2779 this->ReportMessageAt(location, "strict_eval_arguments", false);
2618 *ok = false; 2780 *ok = false;
2619 return this->EmptyExpression(); 2781 return this->EmptyExpression();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 DCHECK(IsAccessorAccessorConflict(old_type, type)); 2821 DCHECK(IsAccessorAccessorConflict(old_type, type));
2660 // Both accessors of the same type. 2822 // Both accessors of the same type.
2661 parser()->ReportMessage("accessor_get_set"); 2823 parser()->ReportMessage("accessor_get_set");
2662 } 2824 }
2663 *ok = false; 2825 *ok = false;
2664 } 2826 }
2665 } 2827 }
2666 } } // v8::internal 2828 } } // v8::internal
2667 2829
2668 #endif // V8_PREPARSER_H 2830 #endif // V8_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698