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

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

Issue 2685683002: [async-await] (simpler) fix for Return in try/finally in async functions (Closed)
Patch Set: add some comments + cleanup using BuildHardReturn 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 | « no previous file | src/ast/scopes.h » ('j') | src/ast/scopes.h » ('J')
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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 889
890 BreakStatement(BreakableStatement* target, int pos) 890 BreakStatement(BreakableStatement* target, int pos)
891 : JumpStatement(pos, kBreakStatement), target_(target) {} 891 : JumpStatement(pos, kBreakStatement), target_(target) {}
892 892
893 BreakableStatement* target_; 893 BreakableStatement* target_;
894 }; 894 };
895 895
896 896
897 class ReturnStatement final : public JumpStatement { 897 class ReturnStatement final : public JumpStatement {
898 public: 898 public:
899 enum Type { kNormal, kHardReturn };
Dan Ehrenberg 2017/02/08 21:12:56 Bikeshedding suggestion: Instead, have normal retu
caitp 2017/02/08 23:22:15 As explained on IRC: The key fix for the try/fina
Dan Ehrenberg 2017/02/09 06:46:58 I see how you need to differentiate between return
899 Expression* expression() const { return expression_; } 900 Expression* expression() const { return expression_; }
900 901
901 void set_expression(Expression* e) { expression_ = e; } 902 void set_expression(Expression* e) { expression_ = e; }
903 bool is_hard_return() const { return type_ == kHardReturn; }
902 904
903 private: 905 private:
904 friend class AstNodeFactory; 906 friend class AstNodeFactory;
905 907
906 ReturnStatement(Expression* expression, int pos) 908 ReturnStatement(Expression* expression, Type type, int pos)
907 : JumpStatement(pos, kReturnStatement), expression_(expression) {} 909 : JumpStatement(pos, kReturnStatement),
910 expression_(expression),
911 type_(type) {}
908 912
909 Expression* expression_; 913 Expression* expression_;
914 Type type_ = kNormal;
910 }; 915 };
911 916
912 917
913 class WithStatement final : public Statement { 918 class WithStatement final : public Statement {
914 public: 919 public:
915 Scope* scope() { return scope_; } 920 Scope* scope() { return scope_; }
916 Expression* expression() const { return expression_; } 921 Expression* expression() const { return expression_; }
917 void set_expression(Expression* e) { expression_ = e; } 922 void set_expression(Expression* e) { expression_ = e; }
918 Statement* statement() const { return statement_; } 923 Statement* statement() const { return statement_; }
919 void set_statement(Statement* s) { statement_ = s; } 924 void set_statement(Statement* s) { statement_ = s; }
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 3207
3203 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { 3208 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
3204 return new (zone_) ContinueStatement(target, pos); 3209 return new (zone_) ContinueStatement(target, pos);
3205 } 3210 }
3206 3211
3207 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { 3212 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
3208 return new (zone_) BreakStatement(target, pos); 3213 return new (zone_) BreakStatement(target, pos);
3209 } 3214 }
3210 3215
3211 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { 3216 ReturnStatement* NewReturnStatement(Expression* expression, int pos) {
3212 return new (zone_) ReturnStatement(expression, pos); 3217 return new (zone_)
3218 ReturnStatement(expression, ReturnStatement::kNormal, pos);
3219 }
3220
3221 ReturnStatement* NewHardReturnStatement(Expression* expression, int pos) {
3222 return new (zone_)
3223 ReturnStatement(expression, ReturnStatement::kHardReturn, pos);
3213 } 3224 }
3214 3225
3215 WithStatement* NewWithStatement(Scope* scope, 3226 WithStatement* NewWithStatement(Scope* scope,
3216 Expression* expression, 3227 Expression* expression,
3217 Statement* statement, 3228 Statement* statement,
3218 int pos) { 3229 int pos) {
3219 return new (zone_) WithStatement(scope, expression, statement, pos); 3230 return new (zone_) WithStatement(scope, expression, statement, pos);
3220 } 3231 }
3221 3232
3222 IfStatement* NewIfStatement(Expression* condition, 3233 IfStatement* NewIfStatement(Expression* condition,
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 : NULL; \ 3639 : NULL; \
3629 } 3640 }
3630 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3641 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3631 #undef DECLARE_NODE_FUNCTIONS 3642 #undef DECLARE_NODE_FUNCTIONS
3632 3643
3633 3644
3634 } // namespace internal 3645 } // namespace internal
3635 } // namespace v8 3646 } // namespace v8
3636 3647
3637 #endif // V8_AST_AST_H_ 3648 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.h » ('j') | src/ast/scopes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698