OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 }; | 1138 }; |
1139 | 1139 |
1140 | 1140 |
1141 class SwitchStatement V8_FINAL : public BreakableStatement { | 1141 class SwitchStatement V8_FINAL : public BreakableStatement { |
1142 public: | 1142 public: |
1143 DECLARE_NODE_TYPE(SwitchStatement) | 1143 DECLARE_NODE_TYPE(SwitchStatement) |
1144 | 1144 |
1145 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1145 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
1146 tag_ = tag; | 1146 tag_ = tag; |
1147 cases_ = cases; | 1147 cases_ = cases; |
1148 switch_type_ = UNKNOWN_SWITCH; | |
1149 } | 1148 } |
1150 | 1149 |
1151 Expression* tag() const { return tag_; } | 1150 Expression* tag() const { return tag_; } |
1152 ZoneList<CaseClause*>* cases() const { return cases_; } | 1151 ZoneList<CaseClause*>* cases() const { return cases_; } |
1153 | 1152 |
1154 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH, GENERIC_SWITCH }; | |
1155 SwitchType switch_type() const { return switch_type_; } | |
1156 void set_switch_type(SwitchType switch_type) { switch_type_ = switch_type; } | |
1157 | |
1158 protected: | 1153 protected: |
1159 SwitchStatement(Isolate* isolate, ZoneStringList* labels, int pos) | 1154 SwitchStatement(Isolate* isolate, ZoneStringList* labels, int pos) |
1160 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos), | 1155 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos), |
1161 tag_(NULL), | 1156 tag_(NULL), |
1162 cases_(NULL) { } | 1157 cases_(NULL) { } |
1163 | 1158 |
1164 private: | 1159 private: |
1165 Expression* tag_; | 1160 Expression* tag_; |
1166 ZoneList<CaseClause*>* cases_; | 1161 ZoneList<CaseClause*>* cases_; |
1167 SwitchType switch_type_; | |
1168 }; | 1162 }; |
1169 | 1163 |
1170 | 1164 |
1171 // If-statements always have non-null references to their then- and | 1165 // If-statements always have non-null references to their then- and |
1172 // else-parts. When parsing if-statements with no explicit else-part, | 1166 // else-parts. When parsing if-statements with no explicit else-part, |
1173 // the parser implicitly creates an empty statement. Use the | 1167 // the parser implicitly creates an empty statement. Use the |
1174 // HasThenStatement() and HasElseStatement() functions to check if a | 1168 // HasThenStatement() and HasElseStatement() functions to check if a |
1175 // given if-statement has a then- or an else-part containing code. | 1169 // given if-statement has a then- or an else-part containing code. |
1176 class IfStatement V8_FINAL : public Statement { | 1170 class IfStatement V8_FINAL : public Statement { |
1177 public: | 1171 public: |
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3298 private: | 3292 private: |
3299 Isolate* isolate_; | 3293 Isolate* isolate_; |
3300 Zone* zone_; | 3294 Zone* zone_; |
3301 Visitor visitor_; | 3295 Visitor visitor_; |
3302 }; | 3296 }; |
3303 | 3297 |
3304 | 3298 |
3305 } } // namespace v8::internal | 3299 } } // namespace v8::internal |
3306 | 3300 |
3307 #endif // V8_AST_H_ | 3301 #endif // V8_AST_H_ |
OLD | NEW |