Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: src/ast.h

Issue 795573005: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/ast.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 class ObjectLiteralProperty FINAL : public ZoneObject { 1476 class ObjectLiteralProperty FINAL : public ZoneObject {
1477 public: 1477 public:
1478 enum Kind { 1478 enum Kind {
1479 CONSTANT, // Property with constant value (compile time). 1479 CONSTANT, // Property with constant value (compile time).
1480 COMPUTED, // Property with computed value (execution time). 1480 COMPUTED, // Property with computed value (execution time).
1481 MATERIALIZED_LITERAL, // Property value is a materialized literal. 1481 MATERIALIZED_LITERAL, // Property value is a materialized literal.
1482 GETTER, SETTER, // Property is an accessor function. 1482 GETTER, SETTER, // Property is an accessor function.
1483 PROTOTYPE // Property is __proto__. 1483 PROTOTYPE // Property is __proto__.
1484 }; 1484 };
1485 1485
1486 ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory, 1486 Expression* key() { return key_; }
1487 Literal* key, Expression* value, bool is_static);
1488
1489 Literal* key() { return key_; }
1490 Expression* value() { return value_; } 1487 Expression* value() { return value_; }
1491 Kind kind() { return kind_; } 1488 Kind kind() { return kind_; }
1492 1489
1493 // Type feedback information. 1490 // Type feedback information.
1494 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1491 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1495 bool IsMonomorphic() { return !receiver_type_.is_null(); } 1492 bool IsMonomorphic() { return !receiver_type_.is_null(); }
1496 Handle<Map> GetReceiverType() { return receiver_type_; } 1493 Handle<Map> GetReceiverType() { return receiver_type_; }
1497 1494
1498 bool IsCompileTimeValue(); 1495 bool IsCompileTimeValue();
1499 1496
1500 void set_emit_store(bool emit_store); 1497 void set_emit_store(bool emit_store);
1501 bool emit_store(); 1498 bool emit_store();
1502 1499
1503 bool is_static() const { return is_static_; } 1500 bool is_static() const { return is_static_; }
1501 bool is_computed_name() const { return is_computed_name_; }
1504 1502
1505 protected: 1503 protected:
1506 friend class AstNodeFactory; 1504 friend class AstNodeFactory;
1507 1505
1508 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value, 1506 ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory,
1509 bool is_static); 1507 Expression* key, Expression* value, bool is_static,
1510 void set_key(Literal* key) { key_ = key; } 1508 bool is_computed_name);
1509
1510 ObjectLiteralProperty(Zone* zone, bool is_getter, Expression* key,
1511 FunctionLiteral* value, bool is_static,
1512 bool is_computed_name);
1511 1513
1512 private: 1514 private:
1513 Literal* key_; 1515 Expression* key_;
1514 Expression* value_; 1516 Expression* value_;
1515 Kind kind_; 1517 Kind kind_;
1516 bool emit_store_; 1518 bool emit_store_;
1517 bool is_static_; 1519 bool is_static_;
1520 bool is_computed_name_;
arv (Not doing code reviews) 2014/12/10 23:38:13 Another Kind would not work since computed can be
1518 Handle<Map> receiver_type_; 1521 Handle<Map> receiver_type_;
1519 }; 1522 };
1520 1523
1521 1524
1522 // An object literal has a boilerplate object that is used 1525 // An object literal has a boilerplate object that is used
1523 // for minimizing the work when constructing it at runtime. 1526 // for minimizing the work when constructing it at runtime.
1524 class ObjectLiteral FINAL : public MaterializedLiteral { 1527 class ObjectLiteral FINAL : public MaterializedLiteral {
1525 public: 1528 public:
1526 typedef ObjectLiteralProperty Property; 1529 typedef ObjectLiteralProperty Property;
1527 1530
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 ObjectLiteral* NewObjectLiteral( 3408 ObjectLiteral* NewObjectLiteral(
3406 ZoneList<ObjectLiteral::Property*>* properties, 3409 ZoneList<ObjectLiteral::Property*>* properties,
3407 int literal_index, 3410 int literal_index,
3408 int boilerplate_properties, 3411 int boilerplate_properties,
3409 bool has_function, 3412 bool has_function,
3410 int pos) { 3413 int pos) {
3411 return new (zone_) ObjectLiteral(zone_, properties, literal_index, 3414 return new (zone_) ObjectLiteral(zone_, properties, literal_index,
3412 boilerplate_properties, has_function, pos); 3415 boilerplate_properties, has_function, pos);
3413 } 3416 }
3414 3417
3415 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, 3418 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
3416 Expression* value, 3419 Expression* value,
3417 bool is_static) { 3420 bool is_static,
3421 bool is_computed_name) {
3418 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, 3422 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key,
3419 value, is_static); 3423 value, is_static,
3424 is_computed_name);
3420 } 3425 }
3421 3426
3422 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, 3427 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3428 Expression* key,
3423 FunctionLiteral* value, 3429 FunctionLiteral* value,
3424 int pos, bool is_static) { 3430 int pos, bool is_static,
3425 ObjectLiteral::Property* prop = 3431 bool is_computed_name) {
3426 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); 3432 return new (zone_) ObjectLiteral::Property(zone_, is_getter, key, value,
3427 prop->set_key(NewStringLiteral(value->raw_name(), pos)); 3433 is_static, is_computed_name);
3428 return prop;
3429 } 3434 }
3430 3435
3431 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, 3436 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern,
3432 const AstRawString* flags, 3437 const AstRawString* flags,
3433 int literal_index, 3438 int literal_index,
3434 int pos) { 3439 int pos) {
3435 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); 3440 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
3436 } 3441 }
3437 3442
3438 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3443 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 3585
3581 private: 3586 private:
3582 Zone* zone_; 3587 Zone* zone_;
3583 AstValueFactory* ast_value_factory_; 3588 AstValueFactory* ast_value_factory_;
3584 }; 3589 };
3585 3590
3586 3591
3587 } } // namespace v8::internal 3592 } } // namespace v8::internal
3588 3593
3589 #endif // V8_AST_H_ 3594 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698