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

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: some nits 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
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, is_rest, &is_duplicate, pos);
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 // Initialize the components of a for-in / for-of statement. 973 // Initialize the components of a for-in / for-of statement.
973 void InitializeForEachStatement(ForEachStatement* stmt, 974 void InitializeForEachStatement(ForEachStatement* stmt,
974 Expression* each, 975 Expression* each,
975 Expression* subject, 976 Expression* subject,
976 Statement* body); 977 Statement* body);
977 Statement* DesugarLexicalBindingsInForStatement( 978 Statement* DesugarLexicalBindingsInForStatement(
978 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names, 979 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names,
979 ForStatement* loop, Statement* init, Expression* cond, Statement* next, 980 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
980 Statement* body, bool* ok); 981 Statement* body, bool* ok);
981 982
983 ZoneList<Statement*>* DesugarInitializeParameters(
984 Scope* scope, bool has_initializers, ZoneList<Expression*>* initializers);
985
982 FunctionLiteral* ParseFunctionLiteral( 986 FunctionLiteral* ParseFunctionLiteral(
983 const AstRawString* name, Scanner::Location function_name_location, 987 const AstRawString* name, Scanner::Location function_name_location,
984 bool name_is_strict_reserved, FunctionKind kind, 988 bool name_is_strict_reserved, FunctionKind kind,
985 int function_token_position, FunctionLiteral::FunctionType type, 989 int function_token_position, FunctionLiteral::FunctionType type,
986 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); 990 FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
987 991
988 992
989 ClassLiteral* ParseClassLiteral(const AstRawString* name, 993 ClassLiteral* ParseClassLiteral(const AstRawString* name,
990 Scanner::Location class_name_location, 994 Scanner::Location class_name_location,
991 bool name_is_strict_reserved, int pos, 995 bool name_is_strict_reserved, int pos,
(...skipping 13 matching lines...) Expand all
1005 // 1009 //
1006 // The var declarations are hoisted to the function scope, but originate from 1010 // The var declarations are hoisted to the function scope, but originate from
1007 // a scope where the name has also been let bound or the var declaration is 1011 // a scope where the name has also been let bound or the var declaration is
1008 // hoisted over such a scope. 1012 // hoisted over such a scope.
1009 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); 1013 void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
1010 1014
1011 // Parser support 1015 // Parser support
1012 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); 1016 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode);
1013 Variable* Declare(Declaration* declaration, bool resolve, bool* ok); 1017 Variable* Declare(Declaration* declaration, bool resolve, bool* ok);
1014 1018
1019 // Parameters have expressions --- ensure that the declared parameters can
1020 // never be resolved
1021 void ShadowParametersForExpressions(Scope* scope);
1022
1015 bool TargetStackContainsLabel(const AstRawString* label); 1023 bool TargetStackContainsLabel(const AstRawString* label);
1016 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); 1024 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok);
1017 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); 1025 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok);
1018 1026
1019 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); 1027 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos);
1020 1028
1021 // Factory methods. 1029 // Factory methods.
1022 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, 1030 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos,
1023 int end_pos); 1031 int end_pos);
1024 1032
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 } 1186 }
1179 1187
1180 1188
1181 Expression* ParserTraits::SpreadCallNew( 1189 Expression* ParserTraits::SpreadCallNew(
1182 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1190 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1183 return parser_->SpreadCallNew(function, args, pos); 1191 return parser_->SpreadCallNew(function, args, pos);
1184 } 1192 }
1185 } } // namespace v8::internal 1193 } } // namespace v8::internal
1186 1194
1187 #endif // V8_PARSER_H_ 1195 #endif // V8_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698