Chromium Code Reviews| Index: src/ast.h |
| diff --git a/src/ast.h b/src/ast.h |
| index af6ecb8d10647d27faf9d01f5dc37928b30b77aa..fd7ca9ece823adb39a08bd538593c4f2fd8bdd89 100644 |
| --- a/src/ast.h |
| +++ b/src/ast.h |
| @@ -90,7 +90,8 @@ namespace internal { |
| V(SuperPropertyReference) \ |
| V(SuperCallReference) \ |
| V(CaseClause) \ |
| - V(EmptyParentheses) |
| + V(EmptyParentheses) \ |
| + V(DoExpression) |
| #define AST_NODE_LIST(V) \ |
| DECLARATION_NODE_LIST(V) \ |
| @@ -2690,6 +2691,42 @@ class NativeFunctionLiteral final : public Expression { |
| }; |
| +class DoExpression final : public Expression { |
| + public: |
| + DECLARE_NODE_TYPE(DoExpression) |
| + |
| + Scope* scope() { return scope_; } |
|
rossberg
2015/10/12 13:52:39
Why not just have a DoExpression carry a Block, in
caitp (gmail)
2015/10/12 18:22:59
Done
|
| + ZoneList<Statement*>* statements() { return statements_; } |
| + |
| + static int num_ids() { return parent_num_ids() + 1; } |
| + BailoutId EntryId() const { return BailoutId(local_id(0)); } |
| + BailoutId ExitId() const { return BailoutId(local_id(1)); } |
| + BailoutId DeclsId() const { return BailoutId(local_id(2)); } |
| + |
| + VariableProxy* result() { return result_; } |
| + |
| + protected: |
| + DoExpression(Zone* zone, Scope* scope, ZoneList<Statement*>* statements, |
| + VariableProxy* result, int pos) |
| + : Expression(zone, pos), |
| + scope_(scope), |
| + statements_(statements), |
| + result_(result) { |
| + DCHECK_NOT_NULL(scope_); |
| + DCHECK_NOT_NULL(statements_); |
| + DCHECK_NOT_NULL(result_); |
| + } |
| + static int parent_num_ids() { return Expression::num_ids(); } |
| + |
| + private: |
| + int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| + |
| + Scope* scope_; |
| + ZoneList<Statement*>* statements_; |
| + VariableProxy* result_; |
| +}; |
| + |
| + |
| class ThisFunction final : public Expression { |
| public: |
| DECLARE_NODE_TYPE(ThisFunction) |
| @@ -3558,6 +3595,15 @@ class AstNodeFactory final BASE_EMBEDDED { |
| NativeFunctionLiteral(parser_zone_, name, extension, pos); |
| } |
| + DoExpression* NewDoExpression(Scope* scope, ZoneList<Statement*>* statements, |
| + int pos, int end_pos) { |
| + Variable* result_var = |
| + NewTemporaryVar(scope, ast_value_factory()->dot_result_string()); |
| + VariableProxy* result = NewVariableProxy(result_var, end_pos, end_pos); |
| + return new (parser_zone_) |
| + DoExpression(parser_zone_, scope, statements, result, pos); |
| + } |
| + |
| ThisFunction* NewThisFunction(int pos) { |
| return new (local_zone_) ThisFunction(local_zone_, pos); |
| } |
| @@ -3610,6 +3656,8 @@ class AstNodeFactory final BASE_EMBEDDED { |
| // the parser-level zone. |
| Zone* parser_zone_; |
| AstValueFactory* ast_value_factory_; |
| + |
| + Variable* NewTemporaryVar(Scope* scope, const AstRawString* name); |
| }; |