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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 V(ObjectLiteral) \ | 82 V(ObjectLiteral) \ |
83 V(ArrayLiteral) \ | 83 V(ArrayLiteral) \ |
84 V(CatchExtensionObject) \ | 84 V(CatchExtensionObject) \ |
85 V(Assignment) \ | 85 V(Assignment) \ |
86 V(Throw) \ | 86 V(Throw) \ |
87 V(Property) \ | 87 V(Property) \ |
88 V(Call) \ | 88 V(Call) \ |
89 V(CallNew) \ | 89 V(CallNew) \ |
90 V(CallRuntime) \ | 90 V(CallRuntime) \ |
91 V(UnaryOperation) \ | 91 V(UnaryOperation) \ |
| 92 V(IncrementOperation) \ |
92 V(CountOperation) \ | 93 V(CountOperation) \ |
93 V(BinaryOperation) \ | 94 V(BinaryOperation) \ |
94 V(CompareOperation) \ | 95 V(CompareOperation) \ |
95 V(CompareToNull) \ | 96 V(CompareToNull) \ |
96 V(ThisFunction) | 97 V(ThisFunction) |
97 | 98 |
98 #define AST_NODE_LIST(V) \ | 99 #define AST_NODE_LIST(V) \ |
99 V(Declaration) \ | 100 V(Declaration) \ |
100 STATEMENT_NODE_LIST(V) \ | 101 STATEMENT_NODE_LIST(V) \ |
101 EXPRESSION_NODE_LIST(V) | 102 EXPRESSION_NODE_LIST(V) |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 Expression* left() const { return left_; } | 1242 Expression* left() const { return left_; } |
1242 Expression* right() const { return right_; } | 1243 Expression* right() const { return right_; } |
1243 | 1244 |
1244 private: | 1245 private: |
1245 Token::Value op_; | 1246 Token::Value op_; |
1246 Expression* left_; | 1247 Expression* left_; |
1247 Expression* right_; | 1248 Expression* right_; |
1248 }; | 1249 }; |
1249 | 1250 |
1250 | 1251 |
| 1252 class IncrementOperation: public Expression { |
| 1253 public: |
| 1254 IncrementOperation(Token::Value op, Expression* expr) |
| 1255 : op_(op), expression_(expr) { |
| 1256 ASSERT(Token::IsCountOp(op)); |
| 1257 } |
| 1258 |
| 1259 Token::Value op() const { return op_; } |
| 1260 bool is_increment() { return op_ == Token::INC; } |
| 1261 Expression* expression() const { return expression_; } |
| 1262 |
| 1263 virtual void Accept(AstVisitor* v); |
| 1264 |
| 1265 private: |
| 1266 Token::Value op_; |
| 1267 Expression* expression_; |
| 1268 }; |
| 1269 |
| 1270 |
1251 class CountOperation: public Expression { | 1271 class CountOperation: public Expression { |
1252 public: | 1272 public: |
1253 CountOperation(bool is_prefix, Token::Value op, Expression* expression) | 1273 CountOperation(bool is_prefix, IncrementOperation* increment) |
1254 : is_prefix_(is_prefix), op_(op), expression_(expression) { | 1274 : is_prefix_(is_prefix), increment_(increment) { } |
1255 ASSERT(Token::IsCountOp(op)); | |
1256 } | |
1257 | 1275 |
1258 virtual void Accept(AstVisitor* v); | 1276 virtual void Accept(AstVisitor* v); |
1259 | 1277 |
1260 virtual CountOperation* AsCountOperation() { return this; } | 1278 virtual CountOperation* AsCountOperation() { return this; } |
1261 | 1279 |
1262 bool is_prefix() const { return is_prefix_; } | 1280 bool is_prefix() const { return is_prefix_; } |
1263 bool is_postfix() const { return !is_prefix_; } | 1281 bool is_postfix() const { return !is_prefix_; } |
1264 Token::Value op() const { return op_; } | 1282 |
| 1283 Token::Value op() const { return increment_->op(); } |
1265 Token::Value binary_op() { | 1284 Token::Value binary_op() { |
1266 return op_ == Token::INC ? Token::ADD : Token::SUB; | 1285 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
1267 } | 1286 } |
1268 Expression* expression() const { return expression_; } | 1287 |
| 1288 Expression* expression() const { return increment_->expression(); } |
| 1289 IncrementOperation* increment() const { return increment_; } |
1269 | 1290 |
1270 virtual void MarkAsStatement() { is_prefix_ = true; } | 1291 virtual void MarkAsStatement() { is_prefix_ = true; } |
1271 | 1292 |
1272 private: | 1293 private: |
1273 bool is_prefix_; | 1294 bool is_prefix_; |
1274 Token::Value op_; | 1295 IncrementOperation* increment_; |
1275 Expression* expression_; | |
1276 }; | 1296 }; |
1277 | 1297 |
1278 | 1298 |
1279 class CompareOperation: public Expression { | 1299 class CompareOperation: public Expression { |
1280 public: | 1300 public: |
1281 CompareOperation(Token::Value op, Expression* left, Expression* right) | 1301 CompareOperation(Token::Value op, Expression* left, Expression* right) |
1282 : op_(op), left_(left), right_(right) { | 1302 : op_(op), left_(left), right_(right) { |
1283 ASSERT(Token::IsCompareOp(op)); | 1303 ASSERT(Token::IsCompareOp(op)); |
1284 } | 1304 } |
1285 | 1305 |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 AST_NODE_LIST(DEF_VISIT) | 1926 AST_NODE_LIST(DEF_VISIT) |
1907 #undef DEF_VISIT | 1927 #undef DEF_VISIT |
1908 | 1928 |
1909 private: | 1929 private: |
1910 bool stack_overflow_; | 1930 bool stack_overflow_; |
1911 }; | 1931 }; |
1912 | 1932 |
1913 } } // namespace v8::internal | 1933 } } // namespace v8::internal |
1914 | 1934 |
1915 #endif // V8_AST_H_ | 1935 #endif // V8_AST_H_ |
OLD | NEW |