| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // Symbols that cannot be parsed as array indices are considered property | 194 // Symbols that cannot be parsed as array indices are considered property |
| 195 // names. We do not treat symbols that can be array indexes as property | 195 // names. We do not treat symbols that can be array indexes as property |
| 196 // names because [] for string objects is handled only by keyed ICs. | 196 // names because [] for string objects is handled only by keyed ICs. |
| 197 virtual bool IsPropertyName() { return false; } | 197 virtual bool IsPropertyName() { return false; } |
| 198 | 198 |
| 199 // Mark the expression as being compiled as an expression | 199 // Mark the expression as being compiled as an expression |
| 200 // statement. This is used to transform postfix increments to | 200 // statement. This is used to transform postfix increments to |
| 201 // (faster) prefix increments. | 201 // (faster) prefix increments. |
| 202 virtual void MarkAsStatement() { /* do nothing */ } | 202 virtual void MarkAsStatement() { /* do nothing */ } |
| 203 | 203 |
| 204 // True iff the result can be safely overwritten (to avoid allocation). |
| 205 // False for operations that can return one of their operands. |
| 206 virtual bool ResultOverwriteAllowed() { return false; } |
| 207 |
| 204 // Static type information for this expression. | 208 // Static type information for this expression. |
| 205 StaticType* type() { return &type_; } | 209 StaticType* type() { return &type_; } |
| 206 | 210 |
| 207 // True if the expression is a loop condition. | 211 // True if the expression is a loop condition. |
| 208 bool is_loop_condition() const { | 212 bool is_loop_condition() const { |
| 209 return LoopConditionField::decode(bitfields_); | 213 return LoopConditionField::decode(bitfields_); |
| 210 } | 214 } |
| 211 void set_is_loop_condition(bool flag) { | 215 void set_is_loop_condition(bool flag) { |
| 212 bitfields_ = (bitfields_ & ~LoopConditionField::mask()) | | 216 bitfields_ = (bitfields_ & ~LoopConditionField::mask()) | |
| 213 LoopConditionField::encode(flag); | 217 LoopConditionField::encode(flag); |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 | 1184 |
| 1181 | 1185 |
| 1182 class UnaryOperation: public Expression { | 1186 class UnaryOperation: public Expression { |
| 1183 public: | 1187 public: |
| 1184 UnaryOperation(Token::Value op, Expression* expression) | 1188 UnaryOperation(Token::Value op, Expression* expression) |
| 1185 : op_(op), expression_(expression) { | 1189 : op_(op), expression_(expression) { |
| 1186 ASSERT(Token::IsUnaryOp(op)); | 1190 ASSERT(Token::IsUnaryOp(op)); |
| 1187 } | 1191 } |
| 1188 | 1192 |
| 1189 virtual void Accept(AstVisitor* v); | 1193 virtual void Accept(AstVisitor* v); |
| 1194 virtual bool ResultOverwriteAllowed(); |
| 1190 | 1195 |
| 1191 // Type testing & conversion | 1196 // Type testing & conversion |
| 1192 virtual UnaryOperation* AsUnaryOperation() { return this; } | 1197 virtual UnaryOperation* AsUnaryOperation() { return this; } |
| 1193 | 1198 |
| 1194 Token::Value op() const { return op_; } | 1199 Token::Value op() const { return op_; } |
| 1195 Expression* expression() const { return expression_; } | 1200 Expression* expression() const { return expression_; } |
| 1196 | 1201 |
| 1197 private: | 1202 private: |
| 1198 Token::Value op_; | 1203 Token::Value op_; |
| 1199 Expression* expression_; | 1204 Expression* expression_; |
| 1200 }; | 1205 }; |
| 1201 | 1206 |
| 1202 | 1207 |
| 1203 class BinaryOperation: public Expression { | 1208 class BinaryOperation: public Expression { |
| 1204 public: | 1209 public: |
| 1205 BinaryOperation(Token::Value op, | 1210 BinaryOperation(Token::Value op, |
| 1206 Expression* left, | 1211 Expression* left, |
| 1207 Expression* right, | 1212 Expression* right, |
| 1208 int pos) | 1213 int pos) |
| 1209 : op_(op), left_(left), right_(right), pos_(pos) { | 1214 : op_(op), left_(left), right_(right), pos_(pos) { |
| 1210 ASSERT(Token::IsBinaryOp(op)); | 1215 ASSERT(Token::IsBinaryOp(op)); |
| 1211 } | 1216 } |
| 1212 | 1217 |
| 1213 // Create the binary operation corresponding to a compound assignment. | 1218 // Create the binary operation corresponding to a compound assignment. |
| 1214 explicit BinaryOperation(Assignment* assignment); | 1219 explicit BinaryOperation(Assignment* assignment); |
| 1215 | 1220 |
| 1216 virtual void Accept(AstVisitor* v); | 1221 virtual void Accept(AstVisitor* v); |
| 1222 virtual bool ResultOverwriteAllowed(); |
| 1217 | 1223 |
| 1218 // Type testing & conversion | 1224 // Type testing & conversion |
| 1219 virtual BinaryOperation* AsBinaryOperation() { return this; } | 1225 virtual BinaryOperation* AsBinaryOperation() { return this; } |
| 1220 | 1226 |
| 1221 // True iff the result can be safely overwritten (to avoid allocation). | |
| 1222 // False for operations that can return one of their operands. | |
| 1223 bool ResultOverwriteAllowed() { | |
| 1224 switch (op_) { | |
| 1225 case Token::COMMA: | |
| 1226 case Token::OR: | |
| 1227 case Token::AND: | |
| 1228 return false; | |
| 1229 case Token::BIT_OR: | |
| 1230 case Token::BIT_XOR: | |
| 1231 case Token::BIT_AND: | |
| 1232 case Token::SHL: | |
| 1233 case Token::SAR: | |
| 1234 case Token::SHR: | |
| 1235 case Token::ADD: | |
| 1236 case Token::SUB: | |
| 1237 case Token::MUL: | |
| 1238 case Token::DIV: | |
| 1239 case Token::MOD: | |
| 1240 return true; | |
| 1241 default: | |
| 1242 UNREACHABLE(); | |
| 1243 } | |
| 1244 return false; | |
| 1245 } | |
| 1246 | |
| 1247 Token::Value op() const { return op_; } | 1227 Token::Value op() const { return op_; } |
| 1248 Expression* left() const { return left_; } | 1228 Expression* left() const { return left_; } |
| 1249 Expression* right() const { return right_; } | 1229 Expression* right() const { return right_; } |
| 1250 int position() const { return pos_; } | 1230 int position() const { return pos_; } |
| 1251 | 1231 |
| 1252 private: | 1232 private: |
| 1253 Token::Value op_; | 1233 Token::Value op_; |
| 1254 Expression* left_; | 1234 Expression* left_; |
| 1255 Expression* right_; | 1235 Expression* right_; |
| 1256 int pos_; | 1236 int pos_; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1942 AST_NODE_LIST(DEF_VISIT) | 1922 AST_NODE_LIST(DEF_VISIT) |
| 1943 #undef DEF_VISIT | 1923 #undef DEF_VISIT |
| 1944 | 1924 |
| 1945 private: | 1925 private: |
| 1946 bool stack_overflow_; | 1926 bool stack_overflow_; |
| 1947 }; | 1927 }; |
| 1948 | 1928 |
| 1949 } } // namespace v8::internal | 1929 } } // namespace v8::internal |
| 1950 | 1930 |
| 1951 #endif // V8_AST_H_ | 1931 #endif // V8_AST_H_ |
| OLD | NEW |