| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index b5f9c1bbbe5c9ebca94d01d8ea90586e7f63a80e..9a088bc646ce7611f9908d0792d33d60f1901037 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -366,6 +366,16 @@ bool ParserTraits::IsEvalOrArguments(const AstRawString* identifier) const {
|
| }
|
|
|
|
|
| +bool ParserTraits::IsPrototype(const AstRawString* identifier) const {
|
| + return identifier == parser_->ast_value_factory_->prototype_string();
|
| +}
|
| +
|
| +
|
| +bool ParserTraits::IsConstructor(const AstRawString* identifier) const {
|
| + return identifier == parser_->ast_value_factory_->constructor_string();
|
| +}
|
| +
|
| +
|
| bool ParserTraits::IsThisProperty(Expression* expression) {
|
| DCHECK(expression != NULL);
|
| Property* property = expression->AsProperty();
|
| @@ -1123,10 +1133,13 @@ Statement* Parser::ParseModuleElement(ZoneList<const AstRawString*>* labels,
|
| // ImportDeclaration
|
| // ExportDeclaration
|
| // GeneratorDeclaration
|
| + // ClassDeclaration
|
|
|
| switch (peek()) {
|
| case Token::FUNCTION:
|
| return ParseFunctionDeclaration(NULL, ok);
|
| + case Token::CLASS:
|
| + return ParseClassDeclaration(NULL, ok);
|
| case Token::IMPORT:
|
| return ParseImportDeclaration(ok);
|
| case Token::EXPORT:
|
| @@ -1466,6 +1479,10 @@ Statement* Parser::ParseExportDeclaration(bool* ok) {
|
| result = ParseFunctionDeclaration(&names, CHECK_OK);
|
| break;
|
|
|
| + case Token::CLASS:
|
| + result = ParseClassDeclaration(&names, CHECK_OK);
|
| + break;
|
| +
|
| case Token::VAR:
|
| case Token::LET:
|
| case Token::CONST:
|
| @@ -1528,10 +1545,13 @@ Statement* Parser::ParseBlockElement(ZoneList<const AstRawString*>* labels,
|
| // LetDeclaration
|
| // ConstDeclaration
|
| // GeneratorDeclaration
|
| + // ClassDeclaration
|
|
|
| switch (peek()) {
|
| case Token::FUNCTION:
|
| return ParseFunctionDeclaration(NULL, ok);
|
| + case Token::CLASS:
|
| + return ParseClassDeclaration(NULL, ok);
|
| case Token::CONST:
|
| return ParseVariableStatement(kModuleElement, NULL, ok);
|
| case Token::LET:
|
| @@ -1643,6 +1663,9 @@ Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels,
|
| return ParseFunctionDeclaration(NULL, ok);
|
| }
|
|
|
| + case Token::CLASS:
|
| + return ParseClassDeclaration(NULL, ok);
|
| +
|
| case Token::DEBUGGER:
|
| return ParseDebuggerStatement(ok);
|
|
|
| @@ -1911,6 +1934,27 @@ Statement* Parser::ParseFunctionDeclaration(
|
| }
|
|
|
|
|
| +Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names,
|
| + bool* ok) {
|
| + // ClassDeclaration ::
|
| + // 'class' Identifier ('extends' LeftHandExpression)? '{' ClassBody '}'
|
| + Expect(Token::CLASS, CHECK_OK);
|
| + int pos = position();
|
| + bool is_strict_reserved = false;
|
| + const AstRawString* name =
|
| + ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
|
| + ClassLiteral* lit = ParseClassLiteral(name, scanner()->location(),
|
| + is_strict_reserved, pos, CHECK_OK);
|
| + VariableMode mode = LET;
|
| + VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue());
|
| + Declaration* declaration =
|
| + factory()->NewClassDeclaration(proxy, lit, scope_, pos);
|
| + Declare(declaration, true, CHECK_OK);
|
| + if (names) names->Add(name, zone());
|
| + return factory()->NewEmptyStatement(RelocInfo::kNoPosition);
|
| +}
|
| +
|
| +
|
| Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
|
| if (allow_harmony_scoping() && strict_mode() == STRICT) {
|
| return ParseScopedBlock(labels, ok);
|
|
|