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

Side by Side Diff: src/ast.h

Issue 1362363002: Enable visitor in rewriter to replace statements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 2 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/rewriter.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_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 Block* body_; 633 Block* body_;
634 }; 634 };
635 635
636 636
637 class IterationStatement : public BreakableStatement { 637 class IterationStatement : public BreakableStatement {
638 public: 638 public:
639 // Type testing & conversion. 639 // Type testing & conversion.
640 IterationStatement* AsIterationStatement() final { return this; } 640 IterationStatement* AsIterationStatement() final { return this; }
641 641
642 Statement* body() const { return body_; } 642 Statement* body() const { return body_; }
643 void set_body(Statement* s) { body_ = s; }
643 644
644 static int num_ids() { return parent_num_ids() + 1; } 645 static int num_ids() { return parent_num_ids() + 1; }
645 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } 646 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); }
646 virtual BailoutId ContinueId() const = 0; 647 virtual BailoutId ContinueId() const = 0;
647 virtual BailoutId StackCheckId() const = 0; 648 virtual BailoutId StackCheckId() const = 0;
648 649
649 // Code generation 650 // Code generation
650 Label* continue_target() { return &continue_target_; } 651 Label* continue_target() { return &continue_target_; }
651 652
652 protected: 653 protected:
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 }; 982 };
982 983
983 984
984 class WithStatement final : public Statement { 985 class WithStatement final : public Statement {
985 public: 986 public:
986 DECLARE_NODE_TYPE(WithStatement) 987 DECLARE_NODE_TYPE(WithStatement)
987 988
988 Scope* scope() { return scope_; } 989 Scope* scope() { return scope_; }
989 Expression* expression() const { return expression_; } 990 Expression* expression() const { return expression_; }
990 Statement* statement() const { return statement_; } 991 Statement* statement() const { return statement_; }
992 void set_statement(Statement* s) { statement_ = s; }
991 993
992 void set_base_id(int id) { base_id_ = id; } 994 void set_base_id(int id) { base_id_ = id; }
993 static int num_ids() { return parent_num_ids() + 1; } 995 static int num_ids() { return parent_num_ids() + 1; }
994 BailoutId EntryId() const { return BailoutId(local_id(0)); } 996 BailoutId EntryId() const { return BailoutId(local_id(0)); }
995 997
996 protected: 998 protected:
997 WithStatement(Zone* zone, Scope* scope, Expression* expression, 999 WithStatement(Zone* zone, Scope* scope, Expression* expression,
998 Statement* statement, int pos) 1000 Statement* statement, int pos)
999 : Statement(zone, pos), 1001 : Statement(zone, pos),
1000 scope_(scope), 1002 scope_(scope),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 public: 1087 public:
1086 DECLARE_NODE_TYPE(IfStatement) 1088 DECLARE_NODE_TYPE(IfStatement)
1087 1089
1088 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 1090 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
1089 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 1091 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1090 1092
1091 Expression* condition() const { return condition_; } 1093 Expression* condition() const { return condition_; }
1092 Statement* then_statement() const { return then_statement_; } 1094 Statement* then_statement() const { return then_statement_; }
1093 Statement* else_statement() const { return else_statement_; } 1095 Statement* else_statement() const { return else_statement_; }
1094 1096
1097 void set_then_statement(Statement* s) { then_statement_ = s; }
1098 void set_else_statement(Statement* s) { else_statement_ = s; }
1099
1095 bool IsJump() const override { 1100 bool IsJump() const override {
1096 return HasThenStatement() && then_statement()->IsJump() 1101 return HasThenStatement() && then_statement()->IsJump()
1097 && HasElseStatement() && else_statement()->IsJump(); 1102 && HasElseStatement() && else_statement()->IsJump();
1098 } 1103 }
1099 1104
1100 void set_base_id(int id) { base_id_ = id; } 1105 void set_base_id(int id) { base_id_ = id; }
1101 static int num_ids() { return parent_num_ids() + 3; } 1106 static int num_ids() { return parent_num_ids() + 3; }
1102 BailoutId IfId() const { return BailoutId(local_id(0)); } 1107 BailoutId IfId() const { return BailoutId(local_id(0)); }
1103 BailoutId ThenId() const { return BailoutId(local_id(1)); } 1108 BailoutId ThenId() const { return BailoutId(local_id(1)); }
1104 BailoutId ElseId() const { return BailoutId(local_id(2)); } 1109 BailoutId ElseId() const { return BailoutId(local_id(2)); }
(...skipping 19 matching lines...) Expand all
1124 Expression* condition_; 1129 Expression* condition_;
1125 Statement* then_statement_; 1130 Statement* then_statement_;
1126 Statement* else_statement_; 1131 Statement* else_statement_;
1127 int base_id_; 1132 int base_id_;
1128 }; 1133 };
1129 1134
1130 1135
1131 class TryStatement : public Statement { 1136 class TryStatement : public Statement {
1132 public: 1137 public:
1133 Block* try_block() const { return try_block_; } 1138 Block* try_block() const { return try_block_; }
1139 void set_try_block(Block* b) { try_block_ = b; }
1134 1140
1135 void set_base_id(int id) { base_id_ = id; } 1141 void set_base_id(int id) { base_id_ = id; }
1136 static int num_ids() { return parent_num_ids() + 1; } 1142 static int num_ids() { return parent_num_ids() + 1; }
1137 BailoutId HandlerId() const { return BailoutId(local_id(0)); } 1143 BailoutId HandlerId() const { return BailoutId(local_id(0)); }
1138 1144
1139 protected: 1145 protected:
1140 TryStatement(Zone* zone, Block* try_block, int pos) 1146 TryStatement(Zone* zone, Block* try_block, int pos)
1141 : Statement(zone, pos), 1147 : Statement(zone, pos),
1142 try_block_(try_block), 1148 try_block_(try_block),
1143 base_id_(BailoutId::None().ToInt()) {} 1149 base_id_(BailoutId::None().ToInt()) {}
(...skipping 12 matching lines...) Expand all
1156 }; 1162 };
1157 1163
1158 1164
1159 class TryCatchStatement final : public TryStatement { 1165 class TryCatchStatement final : public TryStatement {
1160 public: 1166 public:
1161 DECLARE_NODE_TYPE(TryCatchStatement) 1167 DECLARE_NODE_TYPE(TryCatchStatement)
1162 1168
1163 Scope* scope() { return scope_; } 1169 Scope* scope() { return scope_; }
1164 Variable* variable() { return variable_; } 1170 Variable* variable() { return variable_; }
1165 Block* catch_block() const { return catch_block_; } 1171 Block* catch_block() const { return catch_block_; }
1172 void set_catch_block(Block* b) { catch_block_ = b; }
1166 1173
1167 protected: 1174 protected:
1168 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, 1175 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope,
1169 Variable* variable, Block* catch_block, int pos) 1176 Variable* variable, Block* catch_block, int pos)
1170 : TryStatement(zone, try_block, pos), 1177 : TryStatement(zone, try_block, pos),
1171 scope_(scope), 1178 scope_(scope),
1172 variable_(variable), 1179 variable_(variable),
1173 catch_block_(catch_block) {} 1180 catch_block_(catch_block) {}
1174 1181
1175 private: 1182 private:
1176 Scope* scope_; 1183 Scope* scope_;
1177 Variable* variable_; 1184 Variable* variable_;
1178 Block* catch_block_; 1185 Block* catch_block_;
1179 }; 1186 };
1180 1187
1181 1188
1182 class TryFinallyStatement final : public TryStatement { 1189 class TryFinallyStatement final : public TryStatement {
1183 public: 1190 public:
1184 DECLARE_NODE_TYPE(TryFinallyStatement) 1191 DECLARE_NODE_TYPE(TryFinallyStatement)
1185 1192
1186 Block* finally_block() const { return finally_block_; } 1193 Block* finally_block() const { return finally_block_; }
1194 void set_finally_block(Block* b) { finally_block_ = b; }
1187 1195
1188 protected: 1196 protected:
1189 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, 1197 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block,
1190 int pos) 1198 int pos)
1191 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {} 1199 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {}
1192 1200
1193 private: 1201 private:
1194 Block* finally_block_; 1202 Block* finally_block_;
1195 }; 1203 };
1196 1204
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 // the parser-level zone. 3627 // the parser-level zone.
3620 Zone* parser_zone_; 3628 Zone* parser_zone_;
3621 AstValueFactory* ast_value_factory_; 3629 AstValueFactory* ast_value_factory_;
3622 }; 3630 };
3623 3631
3624 3632
3625 } // namespace internal 3633 } // namespace internal
3626 } // namespace v8 3634 } // namespace v8
3627 3635
3628 #endif // V8_AST_H_ 3636 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698