OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 Expression() | 198 Expression() |
199 : bitfields_(0), | 199 : bitfields_(0), |
200 def_(NULL), | 200 def_(NULL), |
201 defined_vars_(NULL) {} | 201 defined_vars_(NULL) {} |
202 | 202 |
203 virtual Expression* AsExpression() { return this; } | 203 virtual Expression* AsExpression() { return this; } |
204 | 204 |
205 virtual bool IsValidLeftHandSide() { return false; } | 205 virtual bool IsValidLeftHandSide() { return false; } |
206 | 206 |
| 207 virtual Variable* AssignedVar() { return NULL; } |
| 208 |
207 // Symbols that cannot be parsed as array indices are considered property | 209 // Symbols that cannot be parsed as array indices are considered property |
208 // names. We do not treat symbols that can be array indexes as property | 210 // names. We do not treat symbols that can be array indexes as property |
209 // names because [] for string objects is handled only by keyed ICs. | 211 // names because [] for string objects is handled only by keyed ICs. |
210 virtual bool IsPropertyName() { return false; } | 212 virtual bool IsPropertyName() { return false; } |
211 | 213 |
212 // True if the expression does not have (evaluated) subexpressions. | 214 // True if the expression does not have (evaluated) subexpressions. |
213 // Function literals are leaves because their subexpressions are not | 215 // Function literals are leaves because their subexpressions are not |
214 // evaluated. | 216 // evaluated. |
215 virtual bool IsLeaf() { return false; } | 217 virtual bool IsLeaf() { return false; } |
216 | 218 |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 public: | 1273 public: |
1272 CountOperation(bool is_prefix, Token::Value op, Expression* expression) | 1274 CountOperation(bool is_prefix, Token::Value op, Expression* expression) |
1273 : is_prefix_(is_prefix), op_(op), expression_(expression) { | 1275 : is_prefix_(is_prefix), op_(op), expression_(expression) { |
1274 ASSERT(Token::IsCountOp(op)); | 1276 ASSERT(Token::IsCountOp(op)); |
1275 } | 1277 } |
1276 | 1278 |
1277 virtual void Accept(AstVisitor* v); | 1279 virtual void Accept(AstVisitor* v); |
1278 | 1280 |
1279 virtual CountOperation* AsCountOperation() { return this; } | 1281 virtual CountOperation* AsCountOperation() { return this; } |
1280 | 1282 |
| 1283 virtual Variable* AssignedVar() { |
| 1284 return expression()->AsVariableProxy()->AsVariable(); |
| 1285 } |
| 1286 |
1281 bool is_prefix() const { return is_prefix_; } | 1287 bool is_prefix() const { return is_prefix_; } |
1282 bool is_postfix() const { return !is_prefix_; } | 1288 bool is_postfix() const { return !is_prefix_; } |
1283 Token::Value op() const { return op_; } | 1289 Token::Value op() const { return op_; } |
1284 Token::Value binary_op() { | 1290 Token::Value binary_op() { |
1285 return op_ == Token::INC ? Token::ADD : Token::SUB; | 1291 return op_ == Token::INC ? Token::ADD : Token::SUB; |
1286 } | 1292 } |
1287 Expression* expression() const { return expression_; } | 1293 Expression* expression() const { return expression_; } |
1288 | 1294 |
1289 virtual void MarkAsStatement() { is_prefix_ = true; } | 1295 virtual void MarkAsStatement() { is_prefix_ = true; } |
1290 | 1296 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 : op_(op), target_(target), value_(value), pos_(pos), | 1357 : op_(op), target_(target), value_(value), pos_(pos), |
1352 block_start_(false), block_end_(false) { | 1358 block_start_(false), block_end_(false) { |
1353 ASSERT(Token::IsAssignmentOp(op)); | 1359 ASSERT(Token::IsAssignmentOp(op)); |
1354 } | 1360 } |
1355 | 1361 |
1356 virtual void Accept(AstVisitor* v); | 1362 virtual void Accept(AstVisitor* v); |
1357 virtual Assignment* AsAssignment() { return this; } | 1363 virtual Assignment* AsAssignment() { return this; } |
1358 | 1364 |
1359 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 1365 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
1360 | 1366 |
| 1367 virtual Variable* AssignedVar() { |
| 1368 return target()->AsVariableProxy()->AsVariable(); |
| 1369 } |
| 1370 |
1361 Token::Value binary_op() const; | 1371 Token::Value binary_op() const; |
1362 | 1372 |
1363 Token::Value op() const { return op_; } | 1373 Token::Value op() const { return op_; } |
1364 Expression* target() const { return target_; } | 1374 Expression* target() const { return target_; } |
1365 Expression* value() const { return value_; } | 1375 Expression* value() const { return value_; } |
1366 int position() { return pos_; } | 1376 int position() { return pos_; } |
1367 // This check relies on the definition order of token in token.h. | 1377 // This check relies on the definition order of token in token.h. |
1368 bool is_compound() const { return op() > Token::ASSIGN; } | 1378 bool is_compound() const { return op() > Token::ASSIGN; } |
1369 | 1379 |
1370 // An initialization block is a series of statments of the form | 1380 // An initialization block is a series of statments of the form |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 #undef DEF_VISIT | 1920 #undef DEF_VISIT |
1911 | 1921 |
1912 private: | 1922 private: |
1913 bool stack_overflow_; | 1923 bool stack_overflow_; |
1914 }; | 1924 }; |
1915 | 1925 |
1916 | 1926 |
1917 } } // namespace v8::internal | 1927 } } // namespace v8::internal |
1918 | 1928 |
1919 #endif // V8_AST_H_ | 1929 #endif // V8_AST_H_ |
OLD | NEW |