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

Side by Side Diff: src/ast.h

Issue 663683006: Implement ES6 Template Literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/bailout-reason.h » ('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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 V(Property) \ 89 V(Property) \
90 V(Call) \ 90 V(Call) \
91 V(CallNew) \ 91 V(CallNew) \
92 V(CallRuntime) \ 92 V(CallRuntime) \
93 V(UnaryOperation) \ 93 V(UnaryOperation) \
94 V(CountOperation) \ 94 V(CountOperation) \
95 V(BinaryOperation) \ 95 V(BinaryOperation) \
96 V(CompareOperation) \ 96 V(CompareOperation) \
97 V(ThisFunction) \ 97 V(ThisFunction) \
98 V(SuperReference) \ 98 V(SuperReference) \
99 V(CaseClause) 99 V(CaseClause) \
100 V(TemplateLiteral)
100 101
101 #define AST_NODE_LIST(V) \ 102 #define AST_NODE_LIST(V) \
102 DECLARATION_NODE_LIST(V) \ 103 DECLARATION_NODE_LIST(V) \
103 MODULE_NODE_LIST(V) \ 104 MODULE_NODE_LIST(V) \
104 STATEMENT_NODE_LIST(V) \ 105 STATEMENT_NODE_LIST(V) \
105 EXPRESSION_NODE_LIST(V) 106 EXPRESSION_NODE_LIST(V)
106 107
107 // Forward declarations 108 // Forward declarations
108 class AstConstructionVisitor; 109 class AstConstructionVisitor;
109 template<class> class AstNodeFactory; 110 template<class> class AstNodeFactory;
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 : Expression(zone, position), value_(value) {} 1426 : Expression(zone, position), value_(value) {}
1426 static int parent_num_ids() { return Expression::num_ids(); } 1427 static int parent_num_ids() { return Expression::num_ids(); }
1427 1428
1428 private: 1429 private:
1429 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1430 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1430 1431
1431 const AstValue* value_; 1432 const AstValue* value_;
1432 }; 1433 };
1433 1434
1434 1435
1436 class TemplateLiteral FINAL : public Expression {
1437 public:
1438 DECLARE_NODE_TYPE(TemplateLiteral)
1439
1440 ZoneList<const AstTemplateSpan*>* spans() const { return spans_; }
1441 ZoneList<Expression*>* expressions() const { return expressions_; }
1442
1443 static int num_ids() { return parent_num_ids() + 1; }
1444
1445 private:
1446 TemplateLiteral(Zone* zone, ZoneList<const AstTemplateSpan*>* spans,
1447 ZoneList<Expression*>* expressions, int pos)
1448 : Expression(zone, pos), spans_(spans), expressions_(expressions) {}
1449
1450 static int parent_num_ids() { return Expression::num_ids(); }
1451
1452 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1453
1454 ZoneList<const AstTemplateSpan*>* spans_;
1455 ZoneList<Expression*>* expressions_;
1456 };
1457
1458
1435 // Base class for literals that needs space in the corresponding JSFunction. 1459 // Base class for literals that needs space in the corresponding JSFunction.
1436 class MaterializedLiteral : public Expression { 1460 class MaterializedLiteral : public Expression {
1437 public: 1461 public:
1438 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1462 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1439 1463
1440 int literal_index() { return literal_index_; } 1464 int literal_index() { return literal_index_; }
1441 1465
1442 int depth() const { 1466 int depth() const {
1443 // only callable after initialization. 1467 // only callable after initialization.
1444 DCHECK(depth_ >= 1); 1468 DCHECK(depth_ >= 1);
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
3382 CaseClause* clause = new (zone_) CaseClause(zone_, label, statements, pos); 3406 CaseClause* clause = new (zone_) CaseClause(zone_, label, statements, pos);
3383 VISIT_AND_RETURN(CaseClause, clause) 3407 VISIT_AND_RETURN(CaseClause, clause)
3384 } 3408 }
3385 3409
3386 Literal* NewStringLiteral(const AstRawString* string, int pos) { 3410 Literal* NewStringLiteral(const AstRawString* string, int pos) {
3387 Literal* lit = 3411 Literal* lit =
3388 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos); 3412 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos);
3389 VISIT_AND_RETURN(Literal, lit) 3413 VISIT_AND_RETURN(Literal, lit)
3390 } 3414 }
3391 3415
3416 TemplateLiteral* NewTemplateLiteral(ZoneList<const AstTemplateSpan*>* spans,
3417 ZoneList<Expression*>* exprs, int pos) {
3418 TemplateLiteral* lit =
3419 new (zone_) TemplateLiteral(zone_, spans, exprs, pos);
3420 VISIT_AND_RETURN(TemplateLiteral, lit);
3421 }
3422
3392 // A JavaScript symbol (ECMA-262 edition 6). 3423 // A JavaScript symbol (ECMA-262 edition 6).
3393 Literal* NewSymbolLiteral(const char* name, int pos) { 3424 Literal* NewSymbolLiteral(const char* name, int pos) {
3394 Literal* lit = 3425 Literal* lit =
3395 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); 3426 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos);
3396 VISIT_AND_RETURN(Literal, lit) 3427 VISIT_AND_RETURN(Literal, lit)
3397 } 3428 }
3398 3429
3399 Literal* NewNumberLiteral(double number, int pos) { 3430 Literal* NewNumberLiteral(double number, int pos) {
3400 Literal* lit = 3431 Literal* lit =
3401 new (zone_) Literal(zone_, ast_value_factory_->NewNumber(number), pos); 3432 new (zone_) Literal(zone_, ast_value_factory_->NewNumber(number), pos);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3649 private: 3680 private:
3650 Zone* zone_; 3681 Zone* zone_;
3651 Visitor visitor_; 3682 Visitor visitor_;
3652 AstValueFactory* ast_value_factory_; 3683 AstValueFactory* ast_value_factory_;
3653 }; 3684 };
3654 3685
3655 3686
3656 } } // namespace v8::internal 3687 } } // namespace v8::internal
3657 3688
3658 #endif // V8_AST_H_ 3689 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/bailout-reason.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698