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

Side by Side Diff: src/ast.h

Issue 332443002: Add support for computed property names in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added tests Created 6 years, 6 months 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 | Annotate | Revision Log
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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 // Property is used for passing information 1440 // Property is used for passing information
1441 // about an object literal's properties from the parser 1441 // about an object literal's properties from the parser
1442 // to the code generator. 1442 // to the code generator.
1443 class ObjectLiteralProperty V8_FINAL : public ZoneObject { 1443 class ObjectLiteralProperty V8_FINAL : public ZoneObject {
1444 public: 1444 public:
1445 enum Kind { 1445 enum Kind {
1446 CONSTANT, // Property with constant value (compile time). 1446 CONSTANT, // Property with constant value (compile time).
1447 COMPUTED, // Property with computed value (execution time). 1447 COMPUTED, // Property with computed value (execution time).
1448 MATERIALIZED_LITERAL, // Property value is a materialized literal. 1448 MATERIALIZED_LITERAL, // Property value is a materialized literal.
1449 GETTER, SETTER, // Property is an accessor function. 1449 GETTER, SETTER, // Property is an accessor function.
1450 PROTOTYPE // Property is __proto__. 1450 PROTOTYPE, // Property is __proto__.
1451 COMPUTED_NAME // Property with computed name.
1451 }; 1452 };
1452 1453
1453 ObjectLiteralProperty(Zone* zone, Literal* key, Expression* value); 1454 ObjectLiteralProperty(Zone* zone, Expression* key, Expression* value,
1455 bool is_computed_name);
1454 1456
1455 Literal* key() { return key_; } 1457 Expression* key() { return key_; }
1456 Expression* value() { return value_; } 1458 Expression* value() { return value_; }
1457 Kind kind() { return kind_; } 1459 Kind kind() { return kind_; }
1458 1460
1459 // Type feedback information. 1461 // Type feedback information.
1460 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1462 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1461 bool IsMonomorphic() { return !receiver_type_.is_null(); } 1463 bool IsMonomorphic() { return !receiver_type_.is_null(); }
1462 Handle<Map> GetReceiverType() { return receiver_type_; } 1464 Handle<Map> GetReceiverType() { return receiver_type_; }
1463 1465
1464 bool IsCompileTimeValue(); 1466 bool IsCompileTimeValue();
1465 1467
1466 void set_emit_store(bool emit_store); 1468 void set_emit_store(bool emit_store);
1467 bool emit_store(); 1469 bool emit_store();
1468 1470
1469 protected: 1471 protected:
1470 template<class> friend class AstNodeFactory; 1472 template<class> friend class AstNodeFactory;
1471 1473
1472 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value); 1474 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value);
1473 void set_key(Literal* key) { key_ = key; } 1475 void set_key(Expression* key) { key_ = key; }
1474 1476
1475 private: 1477 private:
1476 Literal* key_; 1478 Expression* key_;
1477 Expression* value_; 1479 Expression* value_;
1478 Kind kind_; 1480 Kind kind_;
1479 bool emit_store_; 1481 bool emit_store_;
1480 Handle<Map> receiver_type_; 1482 Handle<Map> receiver_type_;
1481 }; 1483 };
1482 1484
1483 1485
1484 // An object literal has a boilerplate object that is used 1486 // An object literal has a boilerplate object that is used
1485 // for minimizing the work when constructing it at runtime. 1487 // for minimizing the work when constructing it at runtime.
1486 class ObjectLiteral V8_FINAL : public MaterializedLiteral { 1488 class ObjectLiteral V8_FINAL : public MaterializedLiteral {
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 int literal_index, 3149 int literal_index,
3148 int boilerplate_properties, 3150 int boilerplate_properties,
3149 bool has_function, 3151 bool has_function,
3150 int pos) { 3152 int pos) {
3151 ObjectLiteral* lit = new(zone_) ObjectLiteral( 3153 ObjectLiteral* lit = new(zone_) ObjectLiteral(
3152 zone_, properties, literal_index, boilerplate_properties, 3154 zone_, properties, literal_index, boilerplate_properties,
3153 has_function, pos); 3155 has_function, pos);
3154 VISIT_AND_RETURN(ObjectLiteral, lit) 3156 VISIT_AND_RETURN(ObjectLiteral, lit)
3155 } 3157 }
3156 3158
3157 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, 3159 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
3158 Expression* value) { 3160 Expression* value,
3159 return new(zone_) ObjectLiteral::Property(zone_, key, value); 3161 bool is_computed_name) {
3162 return new(zone_) ObjectLiteral::Property(zone_, key, value,
3163 is_computed_name);
3160 } 3164 }
3161 3165
3162 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, 3166 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3163 FunctionLiteral* value, 3167 FunctionLiteral* value,
3164 int pos) { 3168 int pos) {
3165 ObjectLiteral::Property* prop = 3169 ObjectLiteral::Property* prop =
3166 new(zone_) ObjectLiteral::Property(zone_, is_getter, value); 3170 new(zone_) ObjectLiteral::Property(zone_, is_getter, value);
3167 prop->set_key(NewLiteral(value->name(), pos)); 3171 prop->set_key(NewLiteral(value->name(), pos));
3168 return prop; // Not an AST node, will not be visited. 3172 return prop; // Not an AST node, will not be visited.
3169 } 3173 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 3342
3339 private: 3343 private:
3340 Zone* zone_; 3344 Zone* zone_;
3341 Visitor visitor_; 3345 Visitor visitor_;
3342 }; 3346 };
3343 3347
3344 3348
3345 } } // namespace v8::internal 3349 } } // namespace v8::internal
3346 3350
3347 #endif // V8_AST_H_ 3351 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/ast.cc » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698