Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: src/ast/ast.h

Issue 2654423004: [async-functions] support await expressions in finally statements (Closed)
Patch Set: make -Wunused-variable bots happy maybe Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/asmjs/asm-wasm-builder.cc ('k') | src/ast/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-types.h" 8 #include "src/ast/ast-types.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 V(CallRuntime) \ 95 V(CallRuntime) \
96 V(UnaryOperation) \ 96 V(UnaryOperation) \
97 V(BinaryOperation) \ 97 V(BinaryOperation) \
98 V(CompareOperation) \ 98 V(CompareOperation) \
99 V(Spread) \ 99 V(Spread) \
100 V(ThisFunction) \ 100 V(ThisFunction) \
101 V(SuperPropertyReference) \ 101 V(SuperPropertyReference) \
102 V(SuperCallReference) \ 102 V(SuperCallReference) \
103 V(CaseClause) \ 103 V(CaseClause) \
104 V(EmptyParentheses) \ 104 V(EmptyParentheses) \
105 V(InternalVariable) \
105 V(GetIterator) \ 106 V(GetIterator) \
106 V(DoExpression) \ 107 V(DoExpression) \
107 V(RewritableExpression) 108 V(RewritableExpression)
108 109
109 #define AST_NODE_LIST(V) \ 110 #define AST_NODE_LIST(V) \
110 DECLARATION_NODE_LIST(V) \ 111 DECLARATION_NODE_LIST(V) \
111 STATEMENT_NODE_LIST(V) \ 112 STATEMENT_NODE_LIST(V) \
112 EXPRESSION_NODE_LIST(V) 113 EXPRESSION_NODE_LIST(V)
113 114
114 // Forward declarations 115 // Forward declarations
(...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; 2510 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
2510 }; 2511 };
2511 2512
2512 // Our Yield is different from the JS yield in that it "returns" its argument as 2513 // Our Yield is different from the JS yield in that it "returns" its argument as
2513 // is, without wrapping it in an iterator result object. Such wrapping, if 2514 // is, without wrapping it in an iterator result object. Such wrapping, if
2514 // desired, must be done beforehand (see the parser). 2515 // desired, must be done beforehand (see the parser).
2515 class Yield final : public Expression { 2516 class Yield final : public Expression {
2516 public: 2517 public:
2517 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; 2518 enum OnException { kOnExceptionThrow, kOnExceptionRethrow };
2518 2519
2519 Expression* generator_object() const { return generator_object_; } 2520 enum YieldType { kNormal, kAwait };
2521
2520 Expression* expression() const { return expression_; } 2522 Expression* expression() const { return expression_; }
2521 OnException on_exception() const { 2523 OnException on_exception() const {
2522 return OnExceptionField::decode(bit_field_); 2524 return OnExceptionField::decode(bit_field_);
2523 } 2525 }
2524 bool rethrow_on_exception() const { 2526 bool rethrow_on_exception() const {
2525 return on_exception() == kOnExceptionRethrow; 2527 return on_exception() == kOnExceptionRethrow;
2526 } 2528 }
2527 int yield_id() const { return yield_id_; } 2529 int yield_id() const { return yield_id_; }
2530 YieldType yield_type() const { return YieldTypeField::decode(bit_field_); }
caitp 2017/01/30 04:20:29 Await gets desugared in the bytecode generator now
2528 2531
2529 void set_generator_object(Expression* e) { generator_object_ = e; }
2530 void set_expression(Expression* e) { expression_ = e; } 2532 void set_expression(Expression* e) { expression_ = e; }
2531 void set_yield_id(int yield_id) { yield_id_ = yield_id; } 2533 void set_yield_id(int yield_id) { yield_id_ = yield_id; }
2532 2534
2533 private: 2535 private:
2534 friend class AstNodeFactory; 2536 friend class AstNodeFactory;
2535 2537
2536 Yield(Expression* generator_object, Expression* expression, int pos, 2538 Yield(Expression* expression, int pos, OnException on_exception,
2537 OnException on_exception) 2539 YieldType yield_type)
2538 : Expression(pos, kYield), 2540 : Expression(pos, kYield), yield_id_(-1), expression_(expression) {
2539 yield_id_(-1), 2541 bit_field_ |= OnExceptionField::encode(on_exception) |
2540 generator_object_(generator_object), 2542 YieldTypeField::encode(yield_type);
2541 expression_(expression) {
2542 bit_field_ |= OnExceptionField::encode(on_exception);
2543 } 2543 }
2544 2544
2545 int yield_id_; 2545 int yield_id_;
2546 Expression* generator_object_;
2547 Expression* expression_; 2546 Expression* expression_;
2548 2547
2549 class OnExceptionField 2548 class OnExceptionField
2550 : public BitField<OnException, Expression::kNextBitFieldIndex, 1> {}; 2549 : public BitField<OnException, Expression::kNextBitFieldIndex, 1> {};
2550 class YieldTypeField
2551 : public BitField<YieldType, OnExceptionField::kNext, 1> {};
2551 }; 2552 };
2552 2553
2553 2554
2554 class Throw final : public Expression { 2555 class Throw final : public Expression {
2555 public: 2556 public:
2556 Expression* exception() const { return exception_; } 2557 Expression* exception() const { return exception_; }
2557 void set_exception(Expression* e) { exception_ = e; } 2558 void set_exception(Expression* e) { exception_ = e; }
2558 2559
2559 private: 2560 private:
2560 friend class AstNodeFactory; 2561 friend class AstNodeFactory;
(...skipping 17 matching lines...) Expand all
2578 enum IdType { kIdTypeInvalid = -1, kIdTypeTopLevel = 0 }; 2579 enum IdType { kIdTypeInvalid = -1, kIdTypeTopLevel = 0 };
2579 2580
2580 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; 2581 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters };
2581 2582
2582 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; 2583 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile };
2583 2584
2584 Handle<String> name() const { return raw_name_->string(); } 2585 Handle<String> name() const { return raw_name_->string(); }
2585 const AstString* raw_name() const { return raw_name_; } 2586 const AstString* raw_name() const { return raw_name_; }
2586 void set_raw_name(const AstString* name) { raw_name_ = name; } 2587 void set_raw_name(const AstString* name) { raw_name_ = name; }
2587 DeclarationScope* scope() const { return scope_; } 2588 DeclarationScope* scope() const { return scope_; }
2589
2590 // AST desugaring of initialization of non-simple parameters. If non-null,
2591 // forces Ignition/TF pipeline.
2592 Block* parameter_init_block() const { return parameter_init_block_; }
2593 void set_parameter_init_block(Block* block) { parameter_init_block_ = block; }
caitp 2017/01/30 04:20:29 Separating this from the function's "body" allows
2594
2588 ZoneList<Statement*>* body() const { return body_; } 2595 ZoneList<Statement*>* body() const { return body_; }
2589 void set_function_token_position(int pos) { function_token_position_ = pos; } 2596 void set_function_token_position(int pos) { function_token_position_ = pos; }
2590 int function_token_position() const { return function_token_position_; } 2597 int function_token_position() const { return function_token_position_; }
2591 int start_position() const; 2598 int start_position() const;
2592 int end_position() const; 2599 int end_position() const;
2593 int SourceSize() const { return end_position() - start_position(); } 2600 int SourceSize() const { return end_position() - start_position(); }
2594 bool is_declaration() const { return function_type() == kDeclaration; } 2601 bool is_declaration() const { return function_type() == kDeclaration; }
2595 bool is_named_expression() const { 2602 bool is_named_expression() const {
2596 return function_type() == kNamedExpression; 2603 return function_type() == kNamedExpression;
2597 } 2604 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 : Expression(position, kFunctionLiteral), 2734 : Expression(position, kFunctionLiteral),
2728 materialized_literal_count_(materialized_literal_count), 2735 materialized_literal_count_(materialized_literal_count),
2729 expected_property_count_(expected_property_count), 2736 expected_property_count_(expected_property_count),
2730 parameter_count_(parameter_count), 2737 parameter_count_(parameter_count),
2731 function_length_(function_length), 2738 function_length_(function_length),
2732 function_token_position_(kNoSourcePosition), 2739 function_token_position_(kNoSourcePosition),
2733 yield_count_(0), 2740 yield_count_(0),
2734 has_braces_(has_braces), 2741 has_braces_(has_braces),
2735 raw_name_(name), 2742 raw_name_(name),
2736 scope_(scope), 2743 scope_(scope),
2744 parameter_init_block_(nullptr),
2737 body_(body), 2745 body_(body),
2738 raw_inferred_name_(ast_value_factory->empty_string()), 2746 raw_inferred_name_(ast_value_factory->empty_string()),
2739 ast_properties_(zone), 2747 ast_properties_(zone),
2740 function_literal_id_(function_literal_id) { 2748 function_literal_id_(function_literal_id) {
2741 bit_field_ |= FunctionTypeBits::encode(function_type) | 2749 bit_field_ |= FunctionTypeBits::encode(function_type) |
2742 Pretenure::encode(false) | 2750 Pretenure::encode(false) |
2743 HasDuplicateParameters::encode(has_duplicate_parameters == 2751 HasDuplicateParameters::encode(has_duplicate_parameters ==
2744 kHasDuplicateParameters) | 2752 kHasDuplicateParameters) |
2745 ShouldNotBeUsedOnceHintField::encode(false) | 2753 ShouldNotBeUsedOnceHintField::encode(false) |
2746 DontOptimizeReasonField::encode(kNoReason); 2754 DontOptimizeReasonField::encode(kNoReason);
(...skipping 13 matching lines...) Expand all
2760 int materialized_literal_count_; 2768 int materialized_literal_count_;
2761 int expected_property_count_; 2769 int expected_property_count_;
2762 int parameter_count_; 2770 int parameter_count_;
2763 int function_length_; 2771 int function_length_;
2764 int function_token_position_; 2772 int function_token_position_;
2765 int yield_count_; 2773 int yield_count_;
2766 bool has_braces_; 2774 bool has_braces_;
2767 2775
2768 const AstString* raw_name_; 2776 const AstString* raw_name_;
2769 DeclarationScope* scope_; 2777 DeclarationScope* scope_;
2778 Block* parameter_init_block_;
2770 ZoneList<Statement*>* body_; 2779 ZoneList<Statement*>* body_;
2771 const AstString* raw_inferred_name_; 2780 const AstString* raw_inferred_name_;
2772 Handle<String> inferred_name_; 2781 Handle<String> inferred_name_;
2773 AstProperties ast_properties_; 2782 AstProperties ast_properties_;
2774 int function_literal_id_; 2783 int function_literal_id_;
2775 FeedbackVectorSlot literal_feedback_slot_; 2784 FeedbackVectorSlot literal_feedback_slot_;
2776 }; 2785 };
2777 2786
2778 // Property is used for passing information 2787 // Property is used for passing information
2779 // about a class literal's properties from the parser to the code generator. 2788 // about a class literal's properties from the parser to the code generator.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2951 2960
2952 // This class is produced when parsing the () in arrow functions without any 2961 // This class is produced when parsing the () in arrow functions without any
2953 // arguments and is not actually a valid expression. 2962 // arguments and is not actually a valid expression.
2954 class EmptyParentheses final : public Expression { 2963 class EmptyParentheses final : public Expression {
2955 private: 2964 private:
2956 friend class AstNodeFactory; 2965 friend class AstNodeFactory;
2957 2966
2958 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} 2967 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {}
2959 }; 2968 };
2960 2969
2970 class InternalVariable final : public Expression {
caitp 2017/01/30 04:20:29 Originally this was used for a lot of different th
2971 public:
2972 enum Type { kGeneratorObject };
2973
2974 Type type() const { return type_; }
2975
2976 const char* name() const;
2977
2978 private:
2979 friend class AstNodeFactory;
2980
2981 explicit InternalVariable(Type type)
2982 : Expression(kNoSourcePosition, kInternalVariable), type_(type) {}
2983
2984 Type type_;
2985 };
2986
2961 // Represents the spec operation `GetIterator()` 2987 // Represents the spec operation `GetIterator()`
2962 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition 2988 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition
2963 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to 2989 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to
2964 // validate return value of the Symbol.iterator() call. 2990 // validate return value of the Symbol.iterator() call.
2965 class GetIterator final : public Expression { 2991 class GetIterator final : public Expression {
2966 public: 2992 public:
2967 Expression* iterable() const { return iterable_; } 2993 Expression* iterable() const { return iterable_; }
2968 void set_iterable(Expression* iterable) { iterable_ = iterable; } 2994 void set_iterable(Expression* iterable) { iterable_ = iterable; }
2969 2995
2970 static int num_ids() { return parent_num_ids(); } 2996 static int num_ids() { return parent_num_ids(); }
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 } 3500 }
3475 3501
3476 Assignment* assign = new (zone_) Assignment(op, target, value, pos); 3502 Assignment* assign = new (zone_) Assignment(op, target, value, pos);
3477 if (assign->is_compound()) { 3503 if (assign->is_compound()) {
3478 assign->binary_operation_ = 3504 assign->binary_operation_ =
3479 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); 3505 NewBinaryOperation(assign->binary_op(), target, value, pos + 1);
3480 } 3506 }
3481 return assign; 3507 return assign;
3482 } 3508 }
3483 3509
3484 Yield* NewYield(Expression* generator_object, Expression* expression, int pos, 3510 Yield* NewYield(Expression* expression, int pos,
caitp 2017/01/30 04:20:29 Yield no longer takes a generator object as a para
3485 Yield::OnException on_exception) { 3511 Yield::OnException on_exception, Yield::YieldType type) {
3486 if (!expression) expression = NewUndefinedLiteral(pos); 3512 if (!expression) expression = NewUndefinedLiteral(pos);
3487 return new (zone_) Yield(generator_object, expression, pos, on_exception); 3513 return new (zone_) Yield(expression, pos, on_exception, type);
3488 } 3514 }
3489 3515
3490 Throw* NewThrow(Expression* exception, int pos) { 3516 Throw* NewThrow(Expression* exception, int pos) {
3491 return new (zone_) Throw(exception, pos); 3517 return new (zone_) Throw(exception, pos);
3492 } 3518 }
3493 3519
3494 FunctionLiteral* NewFunctionLiteral( 3520 FunctionLiteral* NewFunctionLiteral(
3495 const AstRawString* name, DeclarationScope* scope, 3521 const AstRawString* name, DeclarationScope* scope,
3496 ZoneList<Statement*>* body, int materialized_literal_count, 3522 ZoneList<Statement*>* body, int materialized_literal_count,
3497 int expected_property_count, int parameter_count, int function_length, 3523 int expected_property_count, int parameter_count, int function_length,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 VariableProxy* this_function_var, 3592 VariableProxy* this_function_var,
3567 int pos) { 3593 int pos) {
3568 return new (zone_) 3594 return new (zone_)
3569 SuperCallReference(this_var, new_target_var, this_function_var, pos); 3595 SuperCallReference(this_var, new_target_var, this_function_var, pos);
3570 } 3596 }
3571 3597
3572 EmptyParentheses* NewEmptyParentheses(int pos) { 3598 EmptyParentheses* NewEmptyParentheses(int pos) {
3573 return new (zone_) EmptyParentheses(pos); 3599 return new (zone_) EmptyParentheses(pos);
3574 } 3600 }
3575 3601
3602 InternalVariable* NewInternalVariable(InternalVariable::Type type) {
3603 return new (zone_) InternalVariable(type);
3604 }
3605
3576 GetIterator* NewGetIterator(Expression* iterable, int pos) { 3606 GetIterator* NewGetIterator(Expression* iterable, int pos) {
3577 return new (zone_) GetIterator(iterable, pos); 3607 return new (zone_) GetIterator(iterable, pos);
3578 } 3608 }
3579 3609
3580 Zone* zone() const { return zone_; } 3610 Zone* zone() const { return zone_; }
3581 void set_zone(Zone* zone) { zone_ = zone; } 3611 void set_zone(Zone* zone) { zone_ = zone; }
3582 3612
3583 // Handles use of temporary zones when parsing inner function bodies. 3613 // Handles use of temporary zones when parsing inner function bodies.
3584 class BodyScope { 3614 class BodyScope {
3585 public: 3615 public:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3645 : NULL; \ 3675 : NULL; \
3646 } 3676 }
3647 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3677 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3648 #undef DECLARE_NODE_FUNCTIONS 3678 #undef DECLARE_NODE_FUNCTIONS
3649 3679
3650 3680
3651 } // namespace internal 3681 } // namespace internal
3652 } // namespace v8 3682 } // namespace v8
3653 3683
3654 #endif // V8_AST_AST_H_ 3684 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « src/asmjs/asm-wasm-builder.cc ('k') | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698