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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 967 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
968 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 968 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
969 ZoneList<const AstRawString*>* names, | 969 ZoneList<const AstRawString*>* names, |
970 bool* ok); | 970 bool* ok); |
971 | 971 |
972 struct DeclarationDescriptor { | 972 struct DeclarationDescriptor { |
973 enum Kind { NORMAL, PARAMETER }; | 973 enum Kind { NORMAL, PARAMETER }; |
974 Parser* parser; | 974 Parser* parser; |
975 Scope* declaration_scope; | 975 Scope* declaration_scope; |
976 Scope* scope; | 976 Scope* scope; |
| 977 Scope* hoist_scope; |
977 VariableMode mode; | 978 VariableMode mode; |
978 bool is_const; | 979 bool is_const; |
979 bool needs_init; | 980 bool needs_init; |
980 int declaration_pos; | 981 int declaration_pos; |
981 int initialization_pos; | 982 int initialization_pos; |
982 Token::Value init_op; | 983 Token::Value init_op; |
983 Kind declaration_kind; | 984 Kind declaration_kind; |
984 }; | 985 }; |
985 | 986 |
986 struct DeclarationParsingResult { | 987 struct DeclarationParsingResult { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 // | 1128 // |
1128 // The var declarations are hoisted to the function scope, but originate from | 1129 // The var declarations are hoisted to the function scope, but originate from |
1129 // a scope where the name has also been let bound or the var declaration is | 1130 // a scope where the name has also been let bound or the var declaration is |
1130 // hoisted over such a scope. | 1131 // hoisted over such a scope. |
1131 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 1132 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
1132 | 1133 |
1133 // Parser support | 1134 // Parser support |
1134 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); | 1135 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); |
1135 Variable* Declare(Declaration* declaration, | 1136 Variable* Declare(Declaration* declaration, |
1136 DeclarationDescriptor::Kind declaration_kind, bool resolve, | 1137 DeclarationDescriptor::Kind declaration_kind, bool resolve, |
1137 bool* ok); | 1138 bool* ok, Scope* declaration_scope = nullptr); |
1138 | 1139 |
1139 bool TargetStackContainsLabel(const AstRawString* label); | 1140 bool TargetStackContainsLabel(const AstRawString* label); |
1140 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); | 1141 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); |
1141 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); | 1142 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
1142 | 1143 |
1143 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); | 1144 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); |
1144 Statement* BuildAssertIsCoercible(Variable* var); | 1145 Statement* BuildAssertIsCoercible(Variable* var); |
1145 | 1146 |
1146 // Factory methods. | 1147 // Factory methods. |
1147 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, | 1148 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 parser_->BuildParameterInitializationBlock(parameters, ok); | 1361 parser_->BuildParameterInitializationBlock(parameters, ok); |
1361 if (!*ok) return; | 1362 if (!*ok) return; |
1362 if (init_block != nullptr) { | 1363 if (init_block != nullptr) { |
1363 body->Add(init_block, parser_->zone()); | 1364 body->Add(init_block, parser_->zone()); |
1364 } | 1365 } |
1365 } | 1366 } |
1366 } | 1367 } |
1367 } } // namespace v8::internal | 1368 } } // namespace v8::internal |
1368 | 1369 |
1369 #endif // V8_PARSER_H_ | 1370 #endif // V8_PARSER_H_ |
OLD | NEW |