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