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

Side by Side Diff: src/parser.h

Issue 1127063003: [es6] implement default parameters via desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | src/parser.cc » ('j') | src/parser.cc » ('J')
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 #ifndef V8_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 739 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
740 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 740 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
741 } 741 }
742 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 742 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
743 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 743 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
744 } 744 }
745 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 745 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
746 FunctionKind kind = kNormalFunction); 746 FunctionKind kind = kNormalFunction);
747 747
748 bool DeclareFormalParameter(Scope* scope, const AstRawString* name, 748 bool DeclareFormalParameter(Scope* scope, const AstRawString* name,
749 bool is_rest) { 749 bool is_rest, int pos) {
750 bool is_duplicate = false; 750 bool is_duplicate = false;
751 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); 751 Variable* var =
752 scope->DeclareParameter(name, VAR, pos, is_rest, &is_duplicate);
arv (Not doing code reviews) 2015/05/06 20:32:38 keep pos at end?
752 if (is_sloppy(scope->language_mode())) { 753 if (is_sloppy(scope->language_mode())) {
753 // TODO(sigurds) Mark every parameter as maybe assigned. This is a 754 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
754 // conservative approximation necessary to account for parameters 755 // conservative approximation necessary to account for parameters
755 // that are assigned via the arguments array. 756 // that are assigned via the arguments array.
756 var->set_maybe_assigned(); 757 var->set_maybe_assigned();
757 } 758 }
758 return is_duplicate; 759 return is_duplicate;
759 } 760 }
760 761
761 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr, 762 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 // Initialize the components of a for-in / for-of statement. 972 // Initialize the components of a for-in / for-of statement.
972 void InitializeForEachStatement(ForEachStatement* stmt, 973 void InitializeForEachStatement(ForEachStatement* stmt,
973 Expression* each, 974 Expression* each,
974 Expression* subject, 975 Expression* subject,
975 Statement* body); 976 Statement* body);
976 Statement* DesugarLexicalBindingsInForStatement( 977 Statement* DesugarLexicalBindingsInForStatement(
977 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names, 978 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names,
978 ForStatement* loop, Statement* init, Expression* cond, Statement* next, 979 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
979 Statement* body, bool* ok); 980 Statement* body, bool* ok);
980 981
982 ZoneList<Statement*>* DesugarInitializeParameters(
983 Scope* scope, bool has_initializers, ZoneList<Expression*>* initializers);
984
981 FunctionLiteral* ParseFunctionLiteral( 985 FunctionLiteral* ParseFunctionLiteral(
982 const AstRawString* name, Scanner::Location function_name_location, 986 const AstRawString* name, Scanner::Location function_name_location,
983 bool name_is_strict_reserved, FunctionKind kind, 987 bool name_is_strict_reserved, FunctionKind kind,
984 int function_token_position, FunctionLiteral::FunctionType type, 988 int function_token_position, FunctionLiteral::FunctionType type,
985 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); 989 FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
986 990
987 991
988 ClassLiteral* ParseClassLiteral(const AstRawString* name, 992 ClassLiteral* ParseClassLiteral(const AstRawString* name,
989 Scanner::Location class_name_location, 993 Scanner::Location class_name_location,
990 bool name_is_strict_reserved, int pos, 994 bool name_is_strict_reserved, int pos,
(...skipping 13 matching lines...) Expand all
1004 // 1008 //
1005 // The var declarations are hoisted to the function scope, but originate from 1009 // The var declarations are hoisted to the function scope, but originate from
1006 // a scope where the name has also been let bound or the var declaration is 1010 // a scope where the name has also been let bound or the var declaration is
1007 // hoisted over such a scope. 1011 // hoisted over such a scope.
1008 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); 1012 void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
1009 1013
1010 // Parser support 1014 // Parser support
1011 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); 1015 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode);
1012 Variable* Declare(Declaration* declaration, bool resolve, bool* ok); 1016 Variable* Declare(Declaration* declaration, bool resolve, bool* ok);
1013 1017
1018 // Parameters have expressions --- ensure that the declared parameters can
1019 // never be resolved
1020 void ShadowParametersForExpressions(Scope* scope);
1021
1014 bool TargetStackContainsLabel(const AstRawString* label); 1022 bool TargetStackContainsLabel(const AstRawString* label);
1015 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); 1023 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok);
1016 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); 1024 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok);
1017 1025
1018 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); 1026 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos);
1019 1027
1020 // Factory methods. 1028 // Factory methods.
1021 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, 1029 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos,
1022 int end_pos); 1030 int end_pos);
1023 1031
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 } 1181 }
1174 1182
1175 1183
1176 Expression* ParserTraits::SpreadCallNew( 1184 Expression* ParserTraits::SpreadCallNew(
1177 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1185 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1178 return parser_->SpreadCallNew(function, args, pos); 1186 return parser_->SpreadCallNew(function, args, pos);
1179 } 1187 }
1180 } } // namespace v8::internal 1188 } } // namespace v8::internal
1181 1189
1182 #endif // V8_PARSER_H_ 1190 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698