| OLD | NEW |
| 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 Loading... |
| 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); |
| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 | 971 |
| 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 ZoneList<Statement*>* DesugarInitializeParameters( |
| 982 Scope* scope, bool has_initializers, ZoneList<Expression*>* initializers); |
| 981 FunctionLiteral* ParseFunctionLiteral( | 983 FunctionLiteral* ParseFunctionLiteral( |
| 982 const AstRawString* name, Scanner::Location function_name_location, | 984 const AstRawString* name, Scanner::Location function_name_location, |
| 983 bool name_is_strict_reserved, FunctionKind kind, | 985 bool name_is_strict_reserved, FunctionKind kind, |
| 984 int function_token_position, FunctionLiteral::FunctionType type, | 986 int function_token_position, FunctionLiteral::FunctionType type, |
| 985 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 987 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 986 | 988 |
| 987 | 989 |
| 988 ClassLiteral* ParseClassLiteral(const AstRawString* name, | 990 ClassLiteral* ParseClassLiteral(const AstRawString* name, |
| 989 Scanner::Location class_name_location, | 991 Scanner::Location class_name_location, |
| 990 bool name_is_strict_reserved, int pos, | 992 bool name_is_strict_reserved, int pos, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1002 // function f() { { { var x; } let x; } } | 1004 // function f() { { { var x; } let x; } } |
| 1003 // function g() { { var x; let x; } } | 1005 // function g() { { var x; let x; } } |
| 1004 // | 1006 // |
| 1005 // The var declarations are hoisted to the function scope, but originate from | 1007 // 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 | 1008 // a scope where the name has also been let bound or the var declaration is |
| 1007 // hoisted over such a scope. | 1009 // hoisted over such a scope. |
| 1008 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 1010 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
| 1009 | 1011 |
| 1010 // Parser support | 1012 // Parser support |
| 1011 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); | 1013 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); |
| 1012 Variable* Declare(Declaration* declaration, bool resolve, bool* ok); | 1014 Variable* Declare(Declaration* declaration, bool resolve, |
| 1015 bool allow_redeclaration, bool* ok); |
| 1016 Variable* Declare(Declaration* declaration, bool resolve, |
| 1017 bool allow_redeclaration) { |
| 1018 bool ok = true; |
| 1019 Variable* var = Declare(declaration, resolve, allow_redeclaration, &ok); |
| 1020 DCHECK(ok); |
| 1021 return var; |
| 1022 } |
| 1023 Variable* Declare(Declaration* declaration, bool resolve, bool* ok) { |
| 1024 return Declare(declaration, resolve, false, ok); |
| 1025 } |
| 1013 | 1026 |
| 1014 bool TargetStackContainsLabel(const AstRawString* label); | 1027 bool TargetStackContainsLabel(const AstRawString* label); |
| 1015 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); | 1028 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); |
| 1016 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); | 1029 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
| 1017 | 1030 |
| 1018 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); | 1031 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); |
| 1019 | 1032 |
| 1020 // Factory methods. | 1033 // Factory methods. |
| 1021 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, | 1034 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, |
| 1022 int end_pos); | 1035 int end_pos); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 } | 1186 } |
| 1174 | 1187 |
| 1175 | 1188 |
| 1176 Expression* ParserTraits::SpreadCallNew( | 1189 Expression* ParserTraits::SpreadCallNew( |
| 1177 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1190 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
| 1178 return parser_->SpreadCallNew(function, args, pos); | 1191 return parser_->SpreadCallNew(function, args, pos); |
| 1179 } | 1192 } |
| 1180 } } // namespace v8::internal | 1193 } } // namespace v8::internal |
| 1181 | 1194 |
| 1182 #endif // V8_PARSER_H_ | 1195 #endif // V8_PARSER_H_ |
| OLD | NEW |