OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_COMPILER_CONTROL_BUILDERS_H_ | 5 #ifndef V8_COMPILER_CONTROL_BUILDERS_H_ |
6 #define V8_COMPILER_CONTROL_BUILDERS_H_ | 6 #define V8_COMPILER_CONTROL_BUILDERS_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler/graph-builder.h" | 10 #include "src/compiler/graph-builder.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void EndLabel(); | 103 void EndLabel(); |
104 void DefaultAt(int index); | 104 void DefaultAt(int index); |
105 void BeginCase(int index); | 105 void BeginCase(int index); |
106 void EndCase(); | 106 void EndCase(); |
107 void EndSwitch(); | 107 void EndSwitch(); |
108 | 108 |
109 // Primitive support for break. | 109 // Primitive support for break. |
110 virtual void Break(); | 110 virtual void Break(); |
111 | 111 |
112 // The number of cases within a switch is statically known. | 112 // The number of cases within a switch is statically known. |
113 int case_count() const { return body_environments_.capacity(); } | 113 size_t case_count() const { return body_environments_.size(); } |
114 | 114 |
115 private: | 115 private: |
116 Environment* body_environment_; // Environment after last case body. | 116 Environment* body_environment_; // Environment after last case body. |
117 Environment* label_environment_; // Environment for next label condition. | 117 Environment* label_environment_; // Environment for next label condition. |
118 Environment* break_environment_; // Environment after the switch exits. | 118 Environment* break_environment_; // Environment after the switch exits. |
119 ZoneList<Environment*> body_environments_; | 119 ZoneVector<Environment*> body_environments_; |
120 }; | 120 }; |
121 | 121 |
122 | 122 |
123 // Tracks control flow for a block statement. | 123 // Tracks control flow for a block statement. |
124 class BlockBuilder : public ControlBuilder { | 124 class BlockBuilder : public ControlBuilder { |
125 public: | 125 public: |
126 explicit BlockBuilder(StructuredGraphBuilder* builder) | 126 explicit BlockBuilder(StructuredGraphBuilder* builder) |
127 : ControlBuilder(builder), break_environment_(NULL) {} | 127 : ControlBuilder(builder), break_environment_(NULL) {} |
128 | 128 |
129 // Primitive control commands. | 129 // Primitive control commands. |
130 void BeginBlock(); | 130 void BeginBlock(); |
131 void EndBlock(); | 131 void EndBlock(); |
132 | 132 |
133 // Primitive support for break. | 133 // Primitive support for break. |
134 virtual void Break(); | 134 virtual void Break(); |
135 | 135 |
136 private: | 136 private: |
137 Environment* break_environment_; // Environment after the block exits. | 137 Environment* break_environment_; // Environment after the block exits. |
138 }; | 138 }; |
139 } | 139 } |
140 } | 140 } |
141 } // namespace v8::internal::compiler | 141 } // namespace v8::internal::compiler |
142 | 142 |
143 #endif // V8_COMPILER_CONTROL_BUILDERS_H_ | 143 #endif // V8_COMPILER_CONTROL_BUILDERS_H_ |
OLD | NEW |