OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_AST_H_ | 28 #ifndef V8_AST_H_ |
29 #define V8_AST_H_ | 29 #define V8_AST_H_ |
30 | 30 |
31 #include "location.h" | |
32 #include "execution.h" | 31 #include "execution.h" |
33 #include "factory.h" | 32 #include "factory.h" |
34 #include "jsregexp.h" | 33 #include "jsregexp.h" |
35 #include "jump-target.h" | 34 #include "jump-target.h" |
36 #include "runtime.h" | 35 #include "runtime.h" |
37 #include "token.h" | 36 #include "token.h" |
38 #include "variables.h" | 37 #include "variables.h" |
39 | 38 |
40 namespace v8 { | 39 namespace v8 { |
41 namespace internal { | 40 namespace internal { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 154 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
156 int statement_pos() const { return statement_pos_; } | 155 int statement_pos() const { return statement_pos_; } |
157 | 156 |
158 private: | 157 private: |
159 int statement_pos_; | 158 int statement_pos_; |
160 }; | 159 }; |
161 | 160 |
162 | 161 |
163 class Expression: public AstNode { | 162 class Expression: public AstNode { |
164 public: | 163 public: |
165 Expression() : location_(Location::Uninitialized()) {} | 164 enum Context { |
| 165 kUninitialized, |
| 166 kEffect, |
| 167 kValue |
| 168 }; |
| 169 |
| 170 Expression() : context_(kUninitialized) {} |
166 | 171 |
167 virtual Expression* AsExpression() { return this; } | 172 virtual Expression* AsExpression() { return this; } |
168 | 173 |
169 virtual bool IsValidJSON() { return false; } | 174 virtual bool IsValidJSON() { return false; } |
170 virtual bool IsValidLeftHandSide() { return false; } | 175 virtual bool IsValidLeftHandSide() { return false; } |
171 | 176 |
172 // Mark the expression as being compiled as an expression | 177 // Mark the expression as being compiled as an expression |
173 // statement. This is used to transform postfix increments to | 178 // statement. This is used to transform postfix increments to |
174 // (faster) prefix increments. | 179 // (faster) prefix increments. |
175 virtual void MarkAsStatement() { /* do nothing */ } | 180 virtual void MarkAsStatement() { /* do nothing */ } |
176 | 181 |
177 // Static type information for this expression. | 182 // Static type information for this expression. |
178 SmiAnalysis* type() { return &type_; } | 183 SmiAnalysis* type() { return &type_; } |
179 | 184 |
180 Location location() { return location_; } | 185 Context context() { return context_; } |
181 void set_location(Location loc) { location_ = loc; } | 186 void set_context(Context context) { context_ = context; } |
182 | 187 |
183 private: | 188 private: |
184 SmiAnalysis type_; | 189 SmiAnalysis type_; |
185 Location location_; | 190 Context context_; |
186 }; | 191 }; |
187 | 192 |
188 | 193 |
189 /** | 194 /** |
190 * A sentinel used during pre parsing that represents some expression | 195 * A sentinel used during pre parsing that represents some expression |
191 * that is a valid left hand side without having to actually build | 196 * that is a valid left hand side without having to actually build |
192 * the expression. | 197 * the expression. |
193 */ | 198 */ |
194 class ValidLeftHandSideSentinel: public Expression { | 199 class ValidLeftHandSideSentinel: public Expression { |
195 public: | 200 public: |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 #undef DEF_VISIT | 1767 #undef DEF_VISIT |
1763 | 1768 |
1764 private: | 1769 private: |
1765 bool stack_overflow_; | 1770 bool stack_overflow_; |
1766 }; | 1771 }; |
1767 | 1772 |
1768 | 1773 |
1769 } } // namespace v8::internal | 1774 } } // namespace v8::internal |
1770 | 1775 |
1771 #endif // V8_AST_H_ | 1776 #endif // V8_AST_H_ |
OLD | NEW |