Chromium Code Reviews| Index: src/ast/ast.h |
| diff --git a/src/ast/ast.h b/src/ast/ast.h |
| index 796037d7da451decdfe29efea954c3eb1ef85d69..e7e919367be3942105fc3d2a9a04b237f16c660f 100644 |
| --- a/src/ast/ast.h |
| +++ b/src/ast/ast.h |
| @@ -102,6 +102,7 @@ namespace internal { |
| V(SuperCallReference) \ |
| V(CaseClause) \ |
| V(EmptyParentheses) \ |
| + V(InternalVariable) \ |
| V(GetIterator) \ |
| V(DoExpression) \ |
| V(RewritableExpression) |
| @@ -2516,7 +2517,8 @@ class Yield final : public Expression { |
| public: |
| enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; |
| - Expression* generator_object() const { return generator_object_; } |
| + enum YieldType { kNormal, kAwait }; |
| + |
| Expression* expression() const { return expression_; } |
| OnException on_exception() const { |
| return OnExceptionField::decode(bit_field_); |
| @@ -2525,29 +2527,28 @@ class Yield final : public Expression { |
| return on_exception() == kOnExceptionRethrow; |
| } |
| int yield_id() const { return yield_id_; } |
| + YieldType yield_type() const { return YieldTypeField::decode(bit_field_); } |
|
caitp
2017/01/30 04:20:29
Await gets desugared in the bytecode generator now
|
| - void set_generator_object(Expression* e) { generator_object_ = e; } |
| void set_expression(Expression* e) { expression_ = e; } |
| void set_yield_id(int yield_id) { yield_id_ = yield_id; } |
| private: |
| friend class AstNodeFactory; |
| - Yield(Expression* generator_object, Expression* expression, int pos, |
| - OnException on_exception) |
| - : Expression(pos, kYield), |
| - yield_id_(-1), |
| - generator_object_(generator_object), |
| - expression_(expression) { |
| - bit_field_ |= OnExceptionField::encode(on_exception); |
| + Yield(Expression* expression, int pos, OnException on_exception, |
| + YieldType yield_type) |
| + : Expression(pos, kYield), yield_id_(-1), expression_(expression) { |
| + bit_field_ |= OnExceptionField::encode(on_exception) | |
| + YieldTypeField::encode(yield_type); |
| } |
| int yield_id_; |
| - Expression* generator_object_; |
| Expression* expression_; |
| class OnExceptionField |
| : public BitField<OnException, Expression::kNextBitFieldIndex, 1> {}; |
| + class YieldTypeField |
| + : public BitField<YieldType, OnExceptionField::kNext, 1> {}; |
| }; |
| @@ -2585,6 +2586,12 @@ class FunctionLiteral final : public Expression { |
| const AstString* raw_name() const { return raw_name_; } |
| void set_raw_name(const AstString* name) { raw_name_ = name; } |
| DeclarationScope* scope() const { return scope_; } |
| + |
| + // AST desugaring of initialization of non-simple parameters. If non-null, |
| + // forces Ignition/TF pipeline. |
| + Block* parameter_init_block() const { return parameter_init_block_; } |
| + 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
|
| + |
| ZoneList<Statement*>* body() const { return body_; } |
| void set_function_token_position(int pos) { function_token_position_ = pos; } |
| int function_token_position() const { return function_token_position_; } |
| @@ -2734,6 +2741,7 @@ class FunctionLiteral final : public Expression { |
| has_braces_(has_braces), |
| raw_name_(name), |
| scope_(scope), |
| + parameter_init_block_(nullptr), |
| body_(body), |
| raw_inferred_name_(ast_value_factory->empty_string()), |
| ast_properties_(zone), |
| @@ -2767,6 +2775,7 @@ class FunctionLiteral final : public Expression { |
| const AstString* raw_name_; |
| DeclarationScope* scope_; |
| + Block* parameter_init_block_; |
| ZoneList<Statement*>* body_; |
| const AstString* raw_inferred_name_; |
| Handle<String> inferred_name_; |
| @@ -2958,6 +2967,23 @@ class EmptyParentheses final : public Expression { |
| explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} |
| }; |
| +class InternalVariable final : public Expression { |
|
caitp
2017/01/30 04:20:29
Originally this was used for a lot of different th
|
| + public: |
| + enum Type { kGeneratorObject }; |
| + |
| + Type type() const { return type_; } |
| + |
| + const char* name() const; |
| + |
| + private: |
| + friend class AstNodeFactory; |
| + |
| + explicit InternalVariable(Type type) |
| + : Expression(kNoSourcePosition, kInternalVariable), type_(type) {} |
| + |
| + Type type_; |
| +}; |
| + |
| // Represents the spec operation `GetIterator()` |
| // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition |
| // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to |
| @@ -3481,10 +3507,10 @@ class AstNodeFactory final BASE_EMBEDDED { |
| return assign; |
| } |
| - Yield* NewYield(Expression* generator_object, Expression* expression, int pos, |
| - Yield::OnException on_exception) { |
| + Yield* NewYield(Expression* expression, int pos, |
|
caitp
2017/01/30 04:20:29
Yield no longer takes a generator object as a para
|
| + Yield::OnException on_exception, Yield::YieldType type) { |
| if (!expression) expression = NewUndefinedLiteral(pos); |
| - return new (zone_) Yield(generator_object, expression, pos, on_exception); |
| + return new (zone_) Yield(expression, pos, on_exception, type); |
| } |
| Throw* NewThrow(Expression* exception, int pos) { |
| @@ -3573,6 +3599,10 @@ class AstNodeFactory final BASE_EMBEDDED { |
| return new (zone_) EmptyParentheses(pos); |
| } |
| + InternalVariable* NewInternalVariable(InternalVariable::Type type) { |
| + return new (zone_) InternalVariable(type); |
| + } |
| + |
| GetIterator* NewGetIterator(Expression* iterable, int pos) { |
| return new (zone_) GetIterator(iterable, pos); |
| } |