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

Side by Side Diff: src/parser.cc

Issue 575083002: Cleanup class parsing a bit (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Git rebase 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
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 return factory->NewVariableProxy(scope->receiver(), pos); 657 return factory->NewVariableProxy(scope->receiver(), pos);
658 } 658 }
659 659
660 Expression* ParserTraits::SuperReference( 660 Expression* ParserTraits::SuperReference(
661 Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) { 661 Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) {
662 return factory->NewSuperReference( 662 return factory->NewSuperReference(
663 ThisExpression(scope, factory, pos)->AsVariableProxy(), 663 ThisExpression(scope, factory, pos)->AsVariableProxy(),
664 pos); 664 pos);
665 } 665 }
666 666
667 Expression* ParserTraits::ClassLiteral(
668 const AstRawString* name, Expression* extends, Expression* constructor,
669 ZoneList<ObjectLiteral::Property*>* properties, int pos,
670 AstNodeFactory<AstConstructionVisitor>* factory) {
671 return factory->NewClassLiteral(name, extends, constructor, properties, pos);
672 }
673
667 Literal* ParserTraits::ExpressionFromLiteral( 674 Literal* ParserTraits::ExpressionFromLiteral(
668 Token::Value token, int pos, 675 Token::Value token, int pos,
669 Scanner* scanner, 676 Scanner* scanner,
670 AstNodeFactory<AstConstructionVisitor>* factory) { 677 AstNodeFactory<AstConstructionVisitor>* factory) {
671 switch (token) { 678 switch (token) {
672 case Token::NULL_LITERAL: 679 case Token::NULL_LITERAL:
673 return factory->NewNullLiteral(pos); 680 return factory->NewNullLiteral(pos);
674 case Token::TRUE_LITERAL: 681 case Token::TRUE_LITERAL:
675 return factory->NewBooleanLiteral(true, pos); 682 return factory->NewBooleanLiteral(true, pos);
676 case Token::FALSE_LITERAL: 683 case Token::FALSE_LITERAL:
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 // 1962 //
1956 // let C = class C { ... }; 1963 // let C = class C { ... };
1957 // 1964 //
1958 // so rewrite it as such. 1965 // so rewrite it as such.
1959 1966
1960 Expect(Token::CLASS, CHECK_OK); 1967 Expect(Token::CLASS, CHECK_OK);
1961 int pos = position(); 1968 int pos = position();
1962 bool is_strict_reserved = false; 1969 bool is_strict_reserved = false;
1963 const AstRawString* name = 1970 const AstRawString* name =
1964 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); 1971 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
1965 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(), 1972 Expression* value = ParseClassLiteral(name, scanner()->location(),
1966 is_strict_reserved, pos, CHECK_OK); 1973 is_strict_reserved, pos, CHECK_OK);
1967 1974
1968 Block* block = factory()->NewBlock(NULL, 1, true, pos); 1975 Block* block = factory()->NewBlock(NULL, 1, true, pos);
1969 VariableMode mode = LET; 1976 VariableMode mode = LET;
1970 VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue()); 1977 VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue());
1971 Declaration* declaration = 1978 Declaration* declaration =
1972 factory()->NewVariableDeclaration(proxy, mode, scope_, pos); 1979 factory()->NewVariableDeclaration(proxy, mode, scope_, pos);
1973 Declare(declaration, true, CHECK_OK); 1980 Declare(declaration, true, CHECK_OK);
1974 1981
1975 Token::Value init_op = Token::INIT_LET; 1982 Token::Value init_op = Token::INIT_LET;
1976 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); 1983 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos);
(...skipping 2969 matching lines...) Expand 10 before | Expand all | Expand 10 after
4946 4953
4947 // We cannot internalize on a background thread; a foreground task will take 4954 // We cannot internalize on a background thread; a foreground task will take
4948 // care of calling Parser::Internalize just before compilation. 4955 // care of calling Parser::Internalize just before compilation.
4949 4956
4950 if (compile_options() == ScriptCompiler::kProduceParserCache) { 4957 if (compile_options() == ScriptCompiler::kProduceParserCache) {
4951 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); 4958 if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
4952 log_ = NULL; 4959 log_ = NULL;
4953 } 4960 }
4954 } 4961 }
4955 } } // namespace v8::internal 4962 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698