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_PARSING_PARSER_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser-base.h" | 10 #include "src/parsing/parser-base.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 ZoneList<const AstRawString*>* labels, VariableProxy* expr, bool* ok); | 280 ZoneList<const AstRawString*>* labels, VariableProxy* expr, bool* ok); |
281 bool ContainsLabel(ZoneList<const AstRawString*>* labels, | 281 bool ContainsLabel(ZoneList<const AstRawString*>* labels, |
282 const AstRawString* label); | 282 const AstRawString* label); |
283 Expression* RewriteReturn(Expression* return_value, int pos); | 283 Expression* RewriteReturn(Expression* return_value, int pos); |
284 | 284 |
285 Statement* DeclareFunction(const AstRawString* variable_name, | 285 Statement* DeclareFunction(const AstRawString* variable_name, |
286 FunctionLiteral* function, int pos, | 286 FunctionLiteral* function, int pos, |
287 bool is_generator, bool is_async, | 287 bool is_generator, bool is_async, |
288 ZoneList<const AstRawString*>* names, bool* ok); | 288 ZoneList<const AstRawString*>* names, bool* ok); |
289 | 289 |
290 DoExpression* ParseDoExpression(bool* ok); | |
291 Expression* ParseYieldStarExpression(bool* ok); | 290 Expression* ParseYieldStarExpression(bool* ok); |
292 | 291 |
293 class PatternRewriter final : public AstVisitor<PatternRewriter> { | 292 class PatternRewriter final : public AstVisitor<PatternRewriter> { |
294 public: | 293 public: |
295 static void DeclareAndInitializeVariables( | 294 static void DeclareAndInitializeVariables( |
296 Parser* parser, Block* block, | 295 Parser* parser, Block* block, |
297 const DeclarationDescriptor* declaration_descriptor, | 296 const DeclarationDescriptor* declaration_descriptor, |
298 const DeclarationParsingResult::Declaration* declaration, | 297 const DeclarationParsingResult::Declaration* declaration, |
299 ZoneList<const AstRawString*>* names, bool* ok); | 298 ZoneList<const AstRawString*>* names, bool* ok); |
300 | 299 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Expression* current_value_; | 366 Expression* current_value_; |
368 int recursion_level_; | 367 int recursion_level_; |
369 bool* ok_; | 368 bool* ok_; |
370 | 369 |
371 DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() | 370 DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() |
372 }; | 371 }; |
373 | 372 |
374 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); | 373 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); |
375 Statement* ParseSwitchStatement(ZoneList<const AstRawString*>* labels, | 374 Statement* ParseSwitchStatement(ZoneList<const AstRawString*>* labels, |
376 bool* ok); | 375 bool* ok); |
377 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, | |
378 bool* ok); | |
379 WhileStatement* ParseWhileStatement(ZoneList<const AstRawString*>* labels, | |
380 bool* ok); | |
381 Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); | 376 Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); |
382 Statement* ParseThrowStatement(bool* ok); | |
383 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); | 377 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); |
384 TryStatement* ParseTryStatement(bool* ok); | 378 TryStatement* ParseTryStatement(bool* ok); |
385 | 379 |
386 // !%_IsJSReceiver(result = iterator.next()) && | 380 // !%_IsJSReceiver(result = iterator.next()) && |
387 // %ThrowIteratorResultNotAnObject(result) | 381 // %ThrowIteratorResultNotAnObject(result) |
388 Expression* BuildIteratorNextResult(Expression* iterator, Variable* result, | 382 Expression* BuildIteratorNextResult(Expression* iterator, Variable* result, |
389 int pos); | 383 int pos); |
390 | 384 |
391 Expression* GetIterator(Expression* iterable, int pos); | 385 Expression* GetIterator(Expression* iterable, int pos); |
392 | 386 |
393 // Initialize the components of a for-in / for-of statement. | 387 // Initialize the components of a for-in / for-of statement. |
394 Statement* InitializeForEachStatement(ForEachStatement* stmt, | 388 Statement* InitializeForEachStatement(ForEachStatement* stmt, |
395 Expression* each, Expression* subject, | 389 Expression* each, Expression* subject, |
396 Statement* body, int each_keyword_pos); | 390 Statement* body, int each_keyword_pos); |
397 Statement* InitializeForOfStatement(ForOfStatement* stmt, Expression* each, | 391 Statement* InitializeForOfStatement(ForOfStatement* stmt, Expression* each, |
398 Expression* iterable, Statement* body, | 392 Expression* iterable, Statement* body, |
399 bool finalize, | 393 bool finalize, |
400 int next_result_pos = kNoSourcePosition); | 394 int next_result_pos = kNoSourcePosition); |
401 Statement* DesugarLexicalBindingsInForStatement( | 395 Statement* DesugarLexicalBindingsInForStatement( |
402 Scope* inner_scope, VariableMode mode, | 396 Scope* inner_scope, VariableMode mode, |
403 ZoneList<const AstRawString*>* names, ForStatement* loop, Statement* init, | 397 ZoneList<const AstRawString*>* names, ForStatement* loop, Statement* init, |
404 Expression* cond, Statement* next, Statement* body, bool* ok); | 398 Expression* cond, Statement* next, Statement* body, bool* ok); |
405 | 399 |
406 void DesugarAsyncFunctionBody(Scope* scope, ZoneList<Statement*>* body, | 400 void DesugarAsyncFunctionBody(Scope* scope, ZoneList<Statement*>* body, |
407 FunctionKind kind, FunctionBodyType type, | 401 FunctionKind kind, FunctionBodyType type, |
408 bool accept_IN, int pos, bool* ok); | 402 bool accept_IN, int pos, bool* ok); |
409 | 403 |
410 void RewriteDoExpression(Expression* expr, bool* ok); | 404 Expression* RewriteDoExpression(Block* body, int pos, bool* ok); |
411 | 405 |
412 FunctionLiteral* ParseFunctionLiteral( | 406 FunctionLiteral* ParseFunctionLiteral( |
413 const AstRawString* name, Scanner::Location function_name_location, | 407 const AstRawString* name, Scanner::Location function_name_location, |
414 FunctionNameValidity function_name_validity, FunctionKind kind, | 408 FunctionNameValidity function_name_validity, FunctionKind kind, |
415 int function_token_position, FunctionLiteral::FunctionType type, | 409 int function_token_position, FunctionLiteral::FunctionType type, |
416 LanguageMode language_mode, bool* ok); | 410 LanguageMode language_mode, bool* ok); |
417 | 411 |
418 Expression* ParseClassLiteral(const AstRawString* name, | 412 Expression* ParseClassLiteral(const AstRawString* name, |
419 Scanner::Location class_name_location, | 413 Scanner::Location class_name_location, |
420 bool name_is_strict_reserved, int pos, | 414 bool name_is_strict_reserved, int pos, |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 | 942 |
949 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, | 943 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, |
950 bool ignore_completion_value, int pos) { | 944 bool ignore_completion_value, int pos) { |
951 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos); | 945 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos); |
952 } | 946 } |
953 | 947 |
954 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, | 948 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, |
955 ZoneList<Expression*>* args, int pos, | 949 ZoneList<Expression*>* args, int pos, |
956 bool* ok); | 950 bool* ok); |
957 | 951 |
| 952 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) { |
| 953 return factory()->NewExpressionStatement( |
| 954 factory()->NewThrow(exception, pos), pos); |
| 955 } |
| 956 |
958 V8_INLINE void AddParameterInitializationBlock( | 957 V8_INLINE void AddParameterInitializationBlock( |
959 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, | 958 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, |
960 bool is_async, bool* ok) { | 959 bool is_async, bool* ok) { |
961 if (parameters.is_simple) return; | 960 if (parameters.is_simple) return; |
962 auto* init_block = BuildParameterInitializationBlock(parameters, ok); | 961 auto* init_block = BuildParameterInitializationBlock(parameters, ok); |
963 if (!*ok) return; | 962 if (!*ok) return; |
964 if (is_async) { | 963 if (is_async) { |
965 init_block = BuildRejectPromiseOnException(init_block, ok); | 964 init_block = BuildRejectPromiseOnException(init_block, ok); |
966 if (!*ok) return; | 965 if (!*ok) return; |
967 } | 966 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 | 1070 |
1072 #ifdef DEBUG | 1071 #ifdef DEBUG |
1073 void Print(AstNode* node); | 1072 void Print(AstNode* node); |
1074 #endif // DEBUG | 1073 #endif // DEBUG |
1075 }; | 1074 }; |
1076 | 1075 |
1077 } // namespace internal | 1076 } // namespace internal |
1078 } // namespace v8 | 1077 } // namespace v8 |
1079 | 1078 |
1080 #endif // V8_PARSING_PARSER_H_ | 1079 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |