Chromium Code Reviews| 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 void DeclareAndInitializeVariables( | 280 void DeclareAndInitializeVariables( |
| 281 Block* block, const DeclarationDescriptor* declaration_descriptor, | 281 Block* block, const DeclarationDescriptor* declaration_descriptor, |
| 282 const DeclarationParsingResult::Declaration* declaration, | 282 const DeclarationParsingResult::Declaration* declaration, |
| 283 ZoneList<const AstRawString*>* names, bool* ok); | 283 ZoneList<const AstRawString*>* names, bool* ok); |
| 284 ZoneList<const AstRawString*>* DeclareLabel( | 284 ZoneList<const AstRawString*>* DeclareLabel( |
| 285 ZoneList<const AstRawString*>* labels, Expression* expr, bool* ok); | 285 ZoneList<const AstRawString*>* labels, Expression* expr, bool* ok); |
| 286 bool ContainsLabel(ZoneList<const AstRawString*>* labels, | 286 bool ContainsLabel(ZoneList<const AstRawString*>* labels, |
| 287 const AstRawString* label); | 287 const AstRawString* label); |
| 288 Expression* RewriteReturn(Expression* return_value, int pos); | 288 Expression* RewriteReturn(Expression* return_value, int pos); |
| 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); |
| 405 | |
| 406 template <typename Loop> | |
| 407 V8_INLINE Loop* InitializeLoop(Loop* loop, Expression* cond, | |
| 408 Statement* body) { | |
| 409 if (loop != nullptr) loop->Initialize(cond, body); | |
|
adamk
2016/09/08 18:44:47
I don't understand, when can loop be null?
nickie
2016/09/09 09:43:37
I don't know either, but it was in all call sites
adamk
2016/09/09 17:21:06
Those if statements go back to 2009, and my readin
nickie
2016/09/10 17:41:04
Done. I removed InitializeLoop and added a dummy
| |
| 410 return loop; | |
| 411 } | |
| 411 | 412 |
| 412 FunctionLiteral* ParseFunctionLiteral( | 413 FunctionLiteral* ParseFunctionLiteral( |
| 413 const AstRawString* name, Scanner::Location function_name_location, | 414 const AstRawString* name, Scanner::Location function_name_location, |
| 414 FunctionNameValidity function_name_validity, FunctionKind kind, | 415 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 415 int function_token_position, FunctionLiteral::FunctionType type, | 416 int function_token_position, FunctionLiteral::FunctionType type, |
| 416 LanguageMode language_mode, bool* ok); | 417 LanguageMode language_mode, bool* ok); |
| 417 | 418 |
| 418 Expression* ParseClassLiteral(const AstRawString* name, | 419 Expression* ParseClassLiteral(const AstRawString* name, |
| 419 Scanner::Location class_name_location, | 420 Scanner::Location class_name_location, |
| 420 bool name_is_strict_reserved, int pos, | 421 bool name_is_strict_reserved, int pos, |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 | 932 |
| 932 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, | 933 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, |
| 933 bool ignore_completion_value, int pos) { | 934 bool ignore_completion_value, int pos) { |
| 934 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos); | 935 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos); |
| 935 } | 936 } |
| 936 | 937 |
| 937 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, | 938 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, |
| 938 ZoneList<Expression*>* args, int pos, | 939 ZoneList<Expression*>* args, int pos, |
| 939 bool* ok); | 940 bool* ok); |
| 940 | 941 |
| 942 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) { | |
| 943 return factory()->NewExpressionStatement( | |
| 944 factory()->NewThrow(exception, pos), pos); | |
| 945 } | |
| 946 | |
| 941 V8_INLINE void AddParameterInitializationBlock( | 947 V8_INLINE void AddParameterInitializationBlock( |
| 942 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, | 948 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, |
| 943 bool is_async, bool* ok) { | 949 bool is_async, bool* ok) { |
| 944 if (parameters.is_simple) return; | 950 if (parameters.is_simple) return; |
| 945 auto* init_block = BuildParameterInitializationBlock(parameters, ok); | 951 auto* init_block = BuildParameterInitializationBlock(parameters, ok); |
| 946 if (!*ok) return; | 952 if (!*ok) return; |
| 947 if (is_async) { | 953 if (is_async) { |
| 948 init_block = BuildRejectPromiseOnException(init_block, ok); | 954 init_block = BuildRejectPromiseOnException(init_block, ok); |
| 949 if (!*ok) return; | 955 if (!*ok) return; |
| 950 } | 956 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1054 | 1060 |
| 1055 #ifdef DEBUG | 1061 #ifdef DEBUG |
| 1056 void Print(AstNode* node); | 1062 void Print(AstNode* node); |
| 1057 #endif // DEBUG | 1063 #endif // DEBUG |
| 1058 }; | 1064 }; |
| 1059 | 1065 |
| 1060 } // namespace internal | 1066 } // namespace internal |
| 1061 } // namespace v8 | 1067 } // namespace v8 |
| 1062 | 1068 |
| 1063 #endif // V8_PARSING_PARSER_H_ | 1069 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |