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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 enum AllowEvalOrArgumentsAsIdentifier { | 165 enum AllowEvalOrArgumentsAsIdentifier { |
166 kAllowEvalOrArguments, | 166 kAllowEvalOrArguments, |
167 kDontAllowEvalOrArguments | 167 kDontAllowEvalOrArguments |
168 }; | 168 }; |
169 | 169 |
170 enum Mode { | 170 enum Mode { |
171 PARSE_LAZILY, | 171 PARSE_LAZILY, |
172 PARSE_EAGERLY | 172 PARSE_EAGERLY |
173 }; | 173 }; |
174 | 174 |
| 175 enum VariableDeclarationContext { |
| 176 kStatementListItem, |
| 177 kStatement, |
| 178 kForStatement |
| 179 }; |
| 180 |
| 181 // If a list of variable declarations includes any initializers. |
| 182 enum VariableDeclarationProperties { kHasInitializers, kHasNoInitializers }; |
| 183 |
175 class Checkpoint; | 184 class Checkpoint; |
176 class ObjectLiteralCheckerBase; | 185 class ObjectLiteralCheckerBase; |
177 | 186 |
178 // --------------------------------------------------------------------------- | 187 // --------------------------------------------------------------------------- |
179 // FunctionState and BlockState together implement the parser's scope stack. | 188 // FunctionState and BlockState together implement the parser's scope stack. |
180 // The parser's current scope is in scope_. BlockState and FunctionState | 189 // The parser's current scope is in scope_. BlockState and FunctionState |
181 // constructors push on the scope stack and the destructors pop. They are also | 190 // constructors push on the scope stack and the destructors pop. They are also |
182 // used to hold the parser's per-function and per-block state. | 191 // used to hold the parser's per-function and per-block state. |
183 class BlockState BASE_EMBEDDED { | 192 class BlockState BASE_EMBEDDED { |
184 public: | 193 public: |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 public: | 1197 public: |
1189 struct Type { | 1198 struct Type { |
1190 // TODO(marja): To be removed. The Traits object should contain all the data | 1199 // TODO(marja): To be removed. The Traits object should contain all the data |
1191 // it needs. | 1200 // it needs. |
1192 typedef PreParser* Parser; | 1201 typedef PreParser* Parser; |
1193 | 1202 |
1194 // PreParser doesn't need to store generator variables. | 1203 // PreParser doesn't need to store generator variables. |
1195 typedef void GeneratorVariable; | 1204 typedef void GeneratorVariable; |
1196 | 1205 |
1197 typedef int AstProperties; | 1206 typedef int AstProperties; |
1198 typedef Vector<PreParserIdentifier> ParameterIdentifierVector; | |
1199 | 1207 |
1200 // Return types for traversing functions. | 1208 // Return types for traversing functions. |
1201 typedef PreParserIdentifier Identifier; | 1209 typedef PreParserIdentifier Identifier; |
1202 typedef PreParserExpression Expression; | 1210 typedef PreParserExpression Expression; |
1203 typedef PreParserExpression YieldExpression; | 1211 typedef PreParserExpression YieldExpression; |
1204 typedef PreParserExpression FunctionLiteral; | 1212 typedef PreParserExpression FunctionLiteral; |
1205 typedef PreParserExpression ClassLiteral; | 1213 typedef PreParserExpression ClassLiteral; |
1206 typedef PreParserExpression ObjectLiteralProperty; | 1214 typedef PreParserExpression ObjectLiteralProperty; |
1207 typedef PreParserExpression Literal; | 1215 typedef PreParserExpression Literal; |
1208 typedef PreParserExpressionList ExpressionList; | 1216 typedef PreParserExpressionList ExpressionList; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 FunctionKind kind, ParserRecorder* log); | 1558 FunctionKind kind, ParserRecorder* log); |
1551 | 1559 |
1552 private: | 1560 private: |
1553 friend class PreParserTraits; | 1561 friend class PreParserTraits; |
1554 | 1562 |
1555 // These types form an algebra over syntactic categories that is just | 1563 // These types form an algebra over syntactic categories that is just |
1556 // rich enough to let us recognize and propagate the constructs that | 1564 // rich enough to let us recognize and propagate the constructs that |
1557 // are either being counted in the preparser data, or is important | 1565 // are either being counted in the preparser data, or is important |
1558 // to throw the correct syntax error exceptions. | 1566 // to throw the correct syntax error exceptions. |
1559 | 1567 |
1560 enum VariableDeclarationContext { | |
1561 kSourceElement, | |
1562 kStatement, | |
1563 kForStatement | |
1564 }; | |
1565 | |
1566 // If a list of variable declarations includes any initializers. | |
1567 enum VariableDeclarationProperties { | |
1568 kHasInitializers, | |
1569 kHasNoInitializers | |
1570 }; | |
1571 | |
1572 // All ParseXXX functions take as the last argument an *ok parameter | 1568 // All ParseXXX functions take as the last argument an *ok parameter |
1573 // which is set to false if parsing failed; it is unchanged otherwise. | 1569 // which is set to false if parsing failed; it is unchanged otherwise. |
1574 // By making the 'exception handling' explicit, we are forced to check | 1570 // By making the 'exception handling' explicit, we are forced to check |
1575 // for failure at the call sites. | 1571 // for failure at the call sites. |
1576 Statement ParseStatementListItem(bool* ok); | 1572 Statement ParseStatementListItem(bool* ok); |
1577 void ParseStatementList(int end_token, bool* ok); | 1573 void ParseStatementList(int end_token, bool* ok); |
1578 Statement ParseStatement(bool* ok); | 1574 Statement ParseStatement(bool* ok); |
1579 Statement ParseFunctionDeclaration(bool* ok); | 1575 Statement ParseFunctionDeclaration(bool* ok); |
1580 Statement ParseClassDeclaration(bool* ok); | 1576 Statement ParseClassDeclaration(bool* ok); |
1581 Statement ParseBlock(bool* ok); | 1577 Statement ParseBlock(bool* ok); |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3082 *ok = false; | 3078 *ok = false; |
3083 return; | 3079 return; |
3084 } | 3080 } |
3085 has_seen_constructor_ = true; | 3081 has_seen_constructor_ = true; |
3086 return; | 3082 return; |
3087 } | 3083 } |
3088 } | 3084 } |
3089 } } // v8::internal | 3085 } } // v8::internal |
3090 | 3086 |
3091 #endif // V8_PREPARSER_H | 3087 #endif // V8_PREPARSER_H |
OLD | NEW |