| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 protected: | 1305 protected: |
| 1306 EmptyStatement() {} | 1306 EmptyStatement() {} |
| 1307 }; | 1307 }; |
| 1308 | 1308 |
| 1309 | 1309 |
| 1310 class Literal: public Expression { | 1310 class Literal: public Expression { |
| 1311 public: | 1311 public: |
| 1312 DECLARE_NODE_TYPE(Literal) | 1312 DECLARE_NODE_TYPE(Literal) |
| 1313 | 1313 |
| 1314 virtual bool IsPropertyName() { | 1314 virtual bool IsPropertyName() { |
| 1315 if (handle_->IsInternalizedString()) { | 1315 if (value_->IsInternalizedString()) { |
| 1316 uint32_t ignored; | 1316 uint32_t ignored; |
| 1317 return !String::cast(*handle_)->AsArrayIndex(&ignored); | 1317 return !String::cast(*value_)->AsArrayIndex(&ignored); |
| 1318 } | 1318 } |
| 1319 return false; | 1319 return false; |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 Handle<String> AsPropertyName() { | 1322 Handle<String> AsPropertyName() { |
| 1323 ASSERT(IsPropertyName()); | 1323 ASSERT(IsPropertyName()); |
| 1324 return Handle<String>::cast(handle_); | 1324 return Handle<String>::cast(value_); |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 virtual bool ToBooleanIsTrue() { return handle_->BooleanValue(); } | 1327 virtual bool ToBooleanIsTrue() { return value_->BooleanValue(); } |
| 1328 virtual bool ToBooleanIsFalse() { return !handle_->BooleanValue(); } | 1328 virtual bool ToBooleanIsFalse() { return !value_->BooleanValue(); } |
| 1329 | 1329 |
| 1330 // Identity testers. | 1330 // Identity testers. |
| 1331 bool IsNull() const { | 1331 bool IsNull() const { |
| 1332 ASSERT(!handle_.is_null()); | 1332 ASSERT(!value_.is_null()); |
| 1333 return handle_->IsNull(); | 1333 return value_->IsNull(); |
| 1334 } | 1334 } |
| 1335 bool IsTrue() const { | 1335 bool IsTrue() const { |
| 1336 ASSERT(!handle_.is_null()); | 1336 ASSERT(!value_.is_null()); |
| 1337 return handle_->IsTrue(); | 1337 return value_->IsTrue(); |
| 1338 } | 1338 } |
| 1339 bool IsFalse() const { | 1339 bool IsFalse() const { |
| 1340 ASSERT(!handle_.is_null()); | 1340 ASSERT(!value_.is_null()); |
| 1341 return handle_->IsFalse(); | 1341 return value_->IsFalse(); |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 Handle<Object> handle() const { return handle_; } | 1344 Handle<Object> value() const { return value_; } |
| 1345 | 1345 |
| 1346 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1346 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
| 1347 // only for string and number literals! | 1347 // only for string and number literals! |
| 1348 uint32_t Hash() { return ToString()->Hash(); } | 1348 uint32_t Hash() { return ToString()->Hash(); } |
| 1349 | 1349 |
| 1350 static bool Match(void* literal1, void* literal2) { | 1350 static bool Match(void* literal1, void* literal2) { |
| 1351 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); | 1351 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); |
| 1352 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); | 1352 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); |
| 1353 return s1->Equals(*s2); | 1353 return s1->Equals(*s2); |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } | 1356 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } |
| 1357 | 1357 |
| 1358 protected: | 1358 protected: |
| 1359 Literal(Isolate* isolate, Handle<Object> handle) | 1359 Literal(Isolate* isolate, Handle<Object> value) |
| 1360 : Expression(isolate), | 1360 : Expression(isolate), |
| 1361 handle_(handle) { } | 1361 value_(value) { } |
| 1362 | 1362 |
| 1363 private: | 1363 private: |
| 1364 Handle<String> ToString(); | 1364 Handle<String> ToString(); |
| 1365 | 1365 |
| 1366 Handle<Object> handle_; | 1366 Handle<Object> value_; |
| 1367 }; | 1367 }; |
| 1368 | 1368 |
| 1369 | 1369 |
| 1370 // Base class for literals that needs space in the corresponding JSFunction. | 1370 // Base class for literals that needs space in the corresponding JSFunction. |
| 1371 class MaterializedLiteral: public Expression { | 1371 class MaterializedLiteral: public Expression { |
| 1372 public: | 1372 public: |
| 1373 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1373 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1374 | 1374 |
| 1375 int literal_index() { return literal_index_; } | 1375 int literal_index() { return literal_index_; } |
| 1376 | 1376 |
| (...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 private: | 3208 private: |
| 3209 Isolate* isolate_; | 3209 Isolate* isolate_; |
| 3210 Zone* zone_; | 3210 Zone* zone_; |
| 3211 Visitor visitor_; | 3211 Visitor visitor_; |
| 3212 }; | 3212 }; |
| 3213 | 3213 |
| 3214 | 3214 |
| 3215 } } // namespace v8::internal | 3215 } } // namespace v8::internal |
| 3216 | 3216 |
| 3217 #endif // V8_AST_H_ | 3217 #endif // V8_AST_H_ |
| OLD | NEW |