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 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 Expression* expression() const { return expression_; } | 1195 Expression* expression() const { return expression_; } |
1196 | 1196 |
1197 private: | 1197 private: |
1198 Token::Value op_; | 1198 Token::Value op_; |
1199 Expression* expression_; | 1199 Expression* expression_; |
1200 }; | 1200 }; |
1201 | 1201 |
1202 | 1202 |
1203 class BinaryOperation: public Expression { | 1203 class BinaryOperation: public Expression { |
1204 public: | 1204 public: |
1205 BinaryOperation(Token::Value op, Expression* left, Expression* right) | 1205 BinaryOperation(Token::Value op, |
1206 : op_(op), left_(left), right_(right) { | 1206 Expression* left, |
| 1207 Expression* right, |
| 1208 int pos) |
| 1209 : op_(op), left_(left), right_(right), pos_(pos) { |
1207 ASSERT(Token::IsBinaryOp(op)); | 1210 ASSERT(Token::IsBinaryOp(op)); |
1208 } | 1211 } |
1209 | 1212 |
| 1213 // Create the binary operation corresponding to a compound assignment. |
| 1214 explicit BinaryOperation(Assignment* assignment); |
| 1215 |
1210 virtual void Accept(AstVisitor* v); | 1216 virtual void Accept(AstVisitor* v); |
1211 | 1217 |
1212 // Type testing & conversion | 1218 // Type testing & conversion |
1213 virtual BinaryOperation* AsBinaryOperation() { return this; } | 1219 virtual BinaryOperation* AsBinaryOperation() { return this; } |
1214 | 1220 |
1215 // True iff the result can be safely overwritten (to avoid allocation). | 1221 // True iff the result can be safely overwritten (to avoid allocation). |
1216 // False for operations that can return one of their operands. | 1222 // False for operations that can return one of their operands. |
1217 bool ResultOverwriteAllowed() { | 1223 bool ResultOverwriteAllowed() { |
1218 switch (op_) { | 1224 switch (op_) { |
1219 case Token::COMMA: | 1225 case Token::COMMA: |
(...skipping 14 matching lines...) Expand all Loading... |
1234 return true; | 1240 return true; |
1235 default: | 1241 default: |
1236 UNREACHABLE(); | 1242 UNREACHABLE(); |
1237 } | 1243 } |
1238 return false; | 1244 return false; |
1239 } | 1245 } |
1240 | 1246 |
1241 Token::Value op() const { return op_; } | 1247 Token::Value op() const { return op_; } |
1242 Expression* left() const { return left_; } | 1248 Expression* left() const { return left_; } |
1243 Expression* right() const { return right_; } | 1249 Expression* right() const { return right_; } |
| 1250 int position() const { return pos_; } |
1244 | 1251 |
1245 private: | 1252 private: |
1246 Token::Value op_; | 1253 Token::Value op_; |
1247 Expression* left_; | 1254 Expression* left_; |
1248 Expression* right_; | 1255 Expression* right_; |
| 1256 int pos_; |
1249 }; | 1257 }; |
1250 | 1258 |
1251 | 1259 |
1252 class IncrementOperation: public Expression { | 1260 class IncrementOperation: public Expression { |
1253 public: | 1261 public: |
1254 IncrementOperation(Token::Value op, Expression* expr) | 1262 IncrementOperation(Token::Value op, Expression* expr) |
1255 : op_(op), expression_(expr) { | 1263 : op_(op), expression_(expr) { |
1256 ASSERT(Token::IsCountOp(op)); | 1264 ASSERT(Token::IsCountOp(op)); |
1257 } | 1265 } |
1258 | 1266 |
1259 Token::Value op() const { return op_; } | 1267 Token::Value op() const { return op_; } |
1260 bool is_increment() { return op_ == Token::INC; } | 1268 bool is_increment() { return op_ == Token::INC; } |
1261 Expression* expression() const { return expression_; } | 1269 Expression* expression() const { return expression_; } |
1262 | 1270 |
1263 virtual void Accept(AstVisitor* v); | 1271 virtual void Accept(AstVisitor* v); |
1264 | 1272 |
1265 private: | 1273 private: |
1266 Token::Value op_; | 1274 Token::Value op_; |
1267 Expression* expression_; | 1275 Expression* expression_; |
| 1276 int pos_; |
1268 }; | 1277 }; |
1269 | 1278 |
1270 | 1279 |
1271 class CountOperation: public Expression { | 1280 class CountOperation: public Expression { |
1272 public: | 1281 public: |
1273 CountOperation(bool is_prefix, IncrementOperation* increment) | 1282 CountOperation(bool is_prefix, IncrementOperation* increment, int pos) |
1274 : is_prefix_(is_prefix), increment_(increment) { } | 1283 : is_prefix_(is_prefix), increment_(increment), pos_(pos) { } |
1275 | 1284 |
1276 virtual void Accept(AstVisitor* v); | 1285 virtual void Accept(AstVisitor* v); |
1277 | 1286 |
1278 virtual CountOperation* AsCountOperation() { return this; } | 1287 virtual CountOperation* AsCountOperation() { return this; } |
1279 | 1288 |
1280 bool is_prefix() const { return is_prefix_; } | 1289 bool is_prefix() const { return is_prefix_; } |
1281 bool is_postfix() const { return !is_prefix_; } | 1290 bool is_postfix() const { return !is_prefix_; } |
1282 | 1291 |
1283 Token::Value op() const { return increment_->op(); } | 1292 Token::Value op() const { return increment_->op(); } |
1284 Token::Value binary_op() { | 1293 Token::Value binary_op() { |
1285 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 1294 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
1286 } | 1295 } |
1287 | 1296 |
1288 Expression* expression() const { return increment_->expression(); } | 1297 Expression* expression() const { return increment_->expression(); } |
1289 IncrementOperation* increment() const { return increment_; } | 1298 IncrementOperation* increment() const { return increment_; } |
| 1299 int position() const { return pos_; } |
1290 | 1300 |
1291 virtual void MarkAsStatement() { is_prefix_ = true; } | 1301 virtual void MarkAsStatement() { is_prefix_ = true; } |
1292 | 1302 |
1293 private: | 1303 private: |
1294 bool is_prefix_; | 1304 bool is_prefix_; |
1295 IncrementOperation* increment_; | 1305 IncrementOperation* increment_; |
| 1306 int pos_; |
1296 }; | 1307 }; |
1297 | 1308 |
1298 | 1309 |
1299 class CompareOperation: public Expression { | 1310 class CompareOperation: public Expression { |
1300 public: | 1311 public: |
1301 CompareOperation(Token::Value op, Expression* left, Expression* right) | 1312 CompareOperation(Token::Value op, |
1302 : op_(op), left_(left), right_(right) { | 1313 Expression* left, |
| 1314 Expression* right, |
| 1315 int pos) |
| 1316 : op_(op), left_(left), right_(right), pos_(pos) { |
1303 ASSERT(Token::IsCompareOp(op)); | 1317 ASSERT(Token::IsCompareOp(op)); |
1304 } | 1318 } |
1305 | 1319 |
1306 virtual void Accept(AstVisitor* v); | 1320 virtual void Accept(AstVisitor* v); |
1307 | 1321 |
1308 Token::Value op() const { return op_; } | 1322 Token::Value op() const { return op_; } |
1309 Expression* left() const { return left_; } | 1323 Expression* left() const { return left_; } |
1310 Expression* right() const { return right_; } | 1324 Expression* right() const { return right_; } |
| 1325 int position() const { return pos_; } |
1311 | 1326 |
1312 // Type testing & conversion | 1327 // Type testing & conversion |
1313 virtual CompareOperation* AsCompareOperation() { return this; } | 1328 virtual CompareOperation* AsCompareOperation() { return this; } |
1314 | 1329 |
1315 private: | 1330 private: |
1316 Token::Value op_; | 1331 Token::Value op_; |
1317 Expression* left_; | 1332 Expression* left_; |
1318 Expression* right_; | 1333 Expression* right_; |
| 1334 int pos_; |
1319 }; | 1335 }; |
1320 | 1336 |
1321 | 1337 |
1322 class CompareToNull: public Expression { | 1338 class CompareToNull: public Expression { |
1323 public: | 1339 public: |
1324 CompareToNull(bool is_strict, Expression* expression) | 1340 CompareToNull(bool is_strict, Expression* expression) |
1325 : is_strict_(is_strict), expression_(expression) { } | 1341 : is_strict_(is_strict), expression_(expression) { } |
1326 | 1342 |
1327 virtual void Accept(AstVisitor* v); | 1343 virtual void Accept(AstVisitor* v); |
1328 | 1344 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 AST_NODE_LIST(DEF_VISIT) | 1942 AST_NODE_LIST(DEF_VISIT) |
1927 #undef DEF_VISIT | 1943 #undef DEF_VISIT |
1928 | 1944 |
1929 private: | 1945 private: |
1930 bool stack_overflow_; | 1946 bool stack_overflow_; |
1931 }; | 1947 }; |
1932 | 1948 |
1933 } } // namespace v8::internal | 1949 } } // namespace v8::internal |
1934 | 1950 |
1935 #endif // V8_AST_H_ | 1951 #endif // V8_AST_H_ |
OLD | NEW |