OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 } | 1378 } |
1379 virtual bool ToBooleanIsFalse() const OVERRIDE { | 1379 virtual bool ToBooleanIsFalse() const OVERRIDE { |
1380 return !value()->BooleanValue(); | 1380 return !value()->BooleanValue(); |
1381 } | 1381 } |
1382 | 1382 |
1383 Handle<Object> value() const { return value_->value(); } | 1383 Handle<Object> value() const { return value_->value(); } |
1384 const AstValue* raw_value() const { return value_; } | 1384 const AstValue* raw_value() const { return value_; } |
1385 | 1385 |
1386 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1386 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
1387 // only for string and number literals! | 1387 // only for string and number literals! |
1388 uint32_t Hash() { return ToString()->Hash(); } | 1388 uint32_t Hash(); |
1389 | 1389 static bool Match(void* literal1, void* literal2); |
1390 static bool Match(void* literal1, void* literal2) { | |
1391 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); | |
1392 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); | |
1393 return String::Equals(s1, s2); | |
1394 } | |
1395 | 1390 |
1396 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } | 1391 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } |
1397 | 1392 |
1398 protected: | 1393 protected: |
1399 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) | 1394 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) |
1400 : Expression(zone, position, id_gen), | 1395 : Expression(zone, position, id_gen), value_(value) {} |
1401 value_(value), | |
1402 isolate_(zone->isolate()) {} | |
1403 | 1396 |
1404 private: | 1397 private: |
1405 Handle<String> ToString(); | |
1406 | |
1407 const AstValue* value_; | 1398 const AstValue* value_; |
1408 // TODO(dcarney): remove. this is only needed for Match and Hash. | |
1409 Isolate* isolate_; | |
1410 }; | 1399 }; |
1411 | 1400 |
1412 | 1401 |
1413 // Base class for literals that needs space in the corresponding JSFunction. | 1402 // Base class for literals that needs space in the corresponding JSFunction. |
1414 class MaterializedLiteral : public Expression { | 1403 class MaterializedLiteral : public Expression { |
1415 public: | 1404 public: |
1416 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1405 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
1417 | 1406 |
1418 int literal_index() { return literal_index_; } | 1407 int literal_index() { return literal_index_; } |
1419 | 1408 |
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3558 Zone* zone_; | 3547 Zone* zone_; |
3559 Visitor visitor_; | 3548 Visitor visitor_; |
3560 AstValueFactory* ast_value_factory_; | 3549 AstValueFactory* ast_value_factory_; |
3561 AstNode::IdGen* id_gen_; | 3550 AstNode::IdGen* id_gen_; |
3562 }; | 3551 }; |
3563 | 3552 |
3564 | 3553 |
3565 } } // namespace v8::internal | 3554 } } // namespace v8::internal |
3566 | 3555 |
3567 #endif // V8_AST_H_ | 3556 #endif // V8_AST_H_ |
OLD | NEW |