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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 class ObjectLiteralProperty FINAL : public ZoneObject { | 1460 class ObjectLiteralProperty FINAL : public ZoneObject { |
1461 public: | 1461 public: |
1462 enum Kind { | 1462 enum Kind { |
1463 CONSTANT, // Property with constant value (compile time). | 1463 CONSTANT, // Property with constant value (compile time). |
1464 COMPUTED, // Property with computed value (execution time). | 1464 COMPUTED, // Property with computed value (execution time). |
1465 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1465 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
1466 GETTER, SETTER, // Property is an accessor function. | 1466 GETTER, SETTER, // Property is an accessor function. |
1467 PROTOTYPE // Property is __proto__. | 1467 PROTOTYPE // Property is __proto__. |
1468 }; | 1468 }; |
1469 | 1469 |
1470 Expression* key() { return key_; } | 1470 ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory, |
| 1471 Literal* key, Expression* value, bool is_static); |
| 1472 |
| 1473 Literal* key() { return key_; } |
1471 Expression* value() { return value_; } | 1474 Expression* value() { return value_; } |
1472 Kind kind() { return kind_; } | 1475 Kind kind() { return kind_; } |
1473 | 1476 |
1474 // Type feedback information. | 1477 // Type feedback information. |
1475 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1478 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1476 bool IsMonomorphic() { return !receiver_type_.is_null(); } | 1479 bool IsMonomorphic() { return !receiver_type_.is_null(); } |
1477 Handle<Map> GetReceiverType() { return receiver_type_; } | 1480 Handle<Map> GetReceiverType() { return receiver_type_; } |
1478 | 1481 |
1479 bool IsCompileTimeValue(); | 1482 bool IsCompileTimeValue(); |
1480 | 1483 |
1481 void set_emit_store(bool emit_store); | 1484 void set_emit_store(bool emit_store); |
1482 bool emit_store(); | 1485 bool emit_store(); |
1483 | 1486 |
1484 bool is_static() const { return is_static_; } | 1487 bool is_static() const { return is_static_; } |
1485 bool is_computed_name() const { return is_computed_name_; } | |
1486 | 1488 |
1487 protected: | 1489 protected: |
1488 friend class AstNodeFactory; | 1490 friend class AstNodeFactory; |
1489 | 1491 |
1490 ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory, | 1492 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value, |
1491 Expression* key, Expression* value, bool is_static, | 1493 bool is_static); |
1492 bool is_computed_name); | 1494 void set_key(Literal* key) { key_ = key; } |
1493 | |
1494 ObjectLiteralProperty(Zone* zone, bool is_getter, Expression* key, | |
1495 FunctionLiteral* value, bool is_static, | |
1496 bool is_computed_name); | |
1497 | 1495 |
1498 private: | 1496 private: |
1499 Expression* key_; | 1497 Literal* key_; |
1500 Expression* value_; | 1498 Expression* value_; |
1501 Kind kind_; | 1499 Kind kind_; |
1502 bool emit_store_; | 1500 bool emit_store_; |
1503 bool is_static_; | 1501 bool is_static_; |
1504 bool is_computed_name_; | |
1505 Handle<Map> receiver_type_; | 1502 Handle<Map> receiver_type_; |
1506 }; | 1503 }; |
1507 | 1504 |
1508 | 1505 |
1509 // An object literal has a boilerplate object that is used | 1506 // An object literal has a boilerplate object that is used |
1510 // for minimizing the work when constructing it at runtime. | 1507 // for minimizing the work when constructing it at runtime. |
1511 class ObjectLiteral FINAL : public MaterializedLiteral { | 1508 class ObjectLiteral FINAL : public MaterializedLiteral { |
1512 public: | 1509 public: |
1513 typedef ObjectLiteralProperty Property; | 1510 typedef ObjectLiteralProperty Property; |
1514 | 1511 |
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3373 ObjectLiteral* NewObjectLiteral( | 3370 ObjectLiteral* NewObjectLiteral( |
3374 ZoneList<ObjectLiteral::Property*>* properties, | 3371 ZoneList<ObjectLiteral::Property*>* properties, |
3375 int literal_index, | 3372 int literal_index, |
3376 int boilerplate_properties, | 3373 int boilerplate_properties, |
3377 bool has_function, | 3374 bool has_function, |
3378 int pos) { | 3375 int pos) { |
3379 return new (zone_) ObjectLiteral(zone_, properties, literal_index, | 3376 return new (zone_) ObjectLiteral(zone_, properties, literal_index, |
3380 boilerplate_properties, has_function, pos); | 3377 boilerplate_properties, has_function, pos); |
3381 } | 3378 } |
3382 | 3379 |
3383 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, | 3380 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, |
3384 Expression* value, | 3381 Expression* value, |
3385 bool is_static, | 3382 bool is_static) { |
3386 bool is_computed_name) { | 3383 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, |
3387 return new (zone_) ObjectLiteral::Property( | 3384 value, is_static); |
3388 zone_, ast_value_factory_, key, value, is_static, is_computed_name); | |
3389 } | 3385 } |
3390 | 3386 |
3391 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, | 3387 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, |
3392 Expression* key, | |
3393 FunctionLiteral* value, | 3388 FunctionLiteral* value, |
3394 int pos, bool is_static, | 3389 int pos, bool is_static) { |
3395 bool is_computed_name) { | 3390 ObjectLiteral::Property* prop = |
3396 return new (zone_) ObjectLiteral::Property(zone_, is_getter, key, value, | 3391 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); |
3397 is_static, is_computed_name); | 3392 prop->set_key(NewStringLiteral(value->raw_name(), pos)); |
| 3393 return prop; |
3398 } | 3394 } |
3399 | 3395 |
3400 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, | 3396 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, |
3401 const AstRawString* flags, | 3397 const AstRawString* flags, |
3402 int literal_index, | 3398 int literal_index, |
3403 int pos) { | 3399 int pos) { |
3404 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); | 3400 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); |
3405 } | 3401 } |
3406 | 3402 |
3407 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3403 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3549 | 3545 |
3550 private: | 3546 private: |
3551 Zone* zone_; | 3547 Zone* zone_; |
3552 AstValueFactory* ast_value_factory_; | 3548 AstValueFactory* ast_value_factory_; |
3553 }; | 3549 }; |
3554 | 3550 |
3555 | 3551 |
3556 } } // namespace v8::internal | 3552 } } // namespace v8::internal |
3557 | 3553 |
3558 #endif // V8_AST_H_ | 3554 #endif // V8_AST_H_ |
OLD | NEW |