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

Side by Side Diff: src/parser.cc

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 #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/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 return factory->NewVariableProxy(scope->receiver(), pos); 658 return factory->NewVariableProxy(scope->receiver(), pos);
659 } 659 }
660 660
661 Expression* ParserTraits::SuperReference( 661 Expression* ParserTraits::SuperReference(
662 Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) { 662 Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) {
663 return factory->NewSuperReference( 663 return factory->NewSuperReference(
664 ThisExpression(scope, factory, pos)->AsVariableProxy(), 664 ThisExpression(scope, factory, pos)->AsVariableProxy(),
665 pos); 665 pos);
666 } 666 }
667 667
668 Expression* ParserTraits::ClassLiteral( 668 Expression* ParserTraits::ClassExpression(
669 const AstRawString* name, Expression* extends, Expression* constructor, 669 const AstRawString* name, Expression* extends, Expression* constructor,
670 ZoneList<ObjectLiteral::Property*>* properties, int pos, 670 ZoneList<ObjectLiteral::Property*>* properties, int pos,
671 AstNodeFactory<AstConstructionVisitor>* factory) { 671 AstNodeFactory<AstConstructionVisitor>* factory) {
672 return factory->NewClassLiteral(name, extends, constructor, properties, pos); 672 return factory->NewClassLiteral(name, extends, constructor, properties, pos);
673 } 673 }
674 674
675 Literal* ParserTraits::ExpressionFromLiteral( 675 Literal* ParserTraits::ExpressionFromLiteral(
676 Token::Value token, int pos, 676 Token::Value token, int pos,
677 Scanner* scanner, 677 Scanner* scanner,
678 AstNodeFactory<AstConstructionVisitor>* factory) { 678 AstNodeFactory<AstConstructionVisitor>* factory) {
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 // so rewrite it as such. 1967 // so rewrite it as such.
1968 1968
1969 Expect(Token::CLASS, CHECK_OK); 1969 Expect(Token::CLASS, CHECK_OK);
1970 int pos = position(); 1970 int pos = position();
1971 bool is_strict_reserved = false; 1971 bool is_strict_reserved = false;
1972 const AstRawString* name = 1972 const AstRawString* name =
1973 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); 1973 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
1974 Expression* value = ParseClassLiteral(name, scanner()->location(), 1974 Expression* value = ParseClassLiteral(name, scanner()->location(),
1975 is_strict_reserved, pos, CHECK_OK); 1975 is_strict_reserved, pos, CHECK_OK);
1976 1976
1977 Block* block = factory()->NewBlock(NULL, 1, true, pos); 1977 VariableProxy* proxy = NewUnresolved(name, LET, Interface::NewValue());
arv (Not doing code reviews) 2014/10/03 21:11:57 No need for this block since we only need to retur
1978 VariableMode mode = LET;
1979 VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue());
1980 Declaration* declaration = 1978 Declaration* declaration =
1981 factory()->NewVariableDeclaration(proxy, mode, scope_, pos); 1979 factory()->NewVariableDeclaration(proxy, LET, scope_, pos);
1982 Declare(declaration, true, CHECK_OK); 1980 Declare(declaration, true, CHECK_OK);
1981 proxy->var()->set_initializer_position(pos);
1983 1982
1984 Token::Value init_op = Token::INIT_LET; 1983 Token::Value init_op = Token::INIT_LET;
1985 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); 1984 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos);
1986 block->AddStatement( 1985 Statement* assignment_statement =
1987 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), 1986 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition);
1988 zone());
1989
1990 if (names) names->Add(name, zone()); 1987 if (names) names->Add(name, zone());
1991 return block; 1988 return assignment_statement;
1992 } 1989 }
1993 1990
1994 1991
1995 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { 1992 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
1996 if (allow_harmony_scoping() && strict_mode() == STRICT) { 1993 if (allow_harmony_scoping() && strict_mode() == STRICT) {
1997 return ParseScopedBlock(labels, ok); 1994 return ParseScopedBlock(labels, ok);
1998 } 1995 }
1999 1996
2000 // Block :: 1997 // Block ::
2001 // '{' Statement* '}' 1998 // '{' Statement* '}'
(...skipping 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after
4955 4952
4956 // We cannot internalize on a background thread; a foreground task will take 4953 // We cannot internalize on a background thread; a foreground task will take
4957 // care of calling Parser::Internalize just before compilation. 4954 // care of calling Parser::Internalize just before compilation.
4958 4955
4959 if (compile_options() == ScriptCompiler::kProduceParserCache) { 4956 if (compile_options() == ScriptCompiler::kProduceParserCache) {
4960 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); 4957 if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
4961 log_ = NULL; 4958 log_ = NULL;
4962 } 4959 }
4963 } 4960 }
4964 } } // namespace v8::internal 4961 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698