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

Unified Diff: src/ast.h

Issue 663683006: Implement ES6 Template Literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implement tagged template literals Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index ae7ec1a659bf7bb70ae4faeeadc6763c8bef88a0..7f9b4f5d53da5f883d183181da2bb3a04f937098 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -96,7 +96,8 @@ namespace internal {
V(CompareOperation) \
V(ThisFunction) \
V(SuperReference) \
- V(CaseClause)
+ V(CaseClause) \
+ V(TemplateLiteral)
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
@@ -1432,6 +1433,46 @@ class Literal FINAL : public Expression {
};
+class TemplateLiteral FINAL : public Expression {
+ public:
+ DECLARE_NODE_TYPE(TemplateLiteral)
+
+ const ZoneList<Expression*>* cooked() const { return &cooked_; }
+ const ZoneList<Expression*>* raw() const { return &raw_; }
+ const ZoneList<Expression*>* expressions() const { return &expressions_; }
+
+ void AddTemplateSpan(Literal* cooked, Literal* raw, Zone* zone) {
+ DCHECK(cooked != NULL);
+ DCHECK(raw != NULL);
+ cooked_.Add(cooked, zone);
+ raw_.Add(raw, zone);
+ }
+
+ void AddExpression(Expression* expression, Zone* zone) {
+ DCHECK(expression != NULL);
+ expressions_.Add(expression, zone);
+ }
+
+ static int num_ids() { return parent_num_ids() + 1; }
+
+ private:
+ TemplateLiteral(Zone* zone, int pos)
+ : Expression(zone, pos),
+ cooked_(8, zone),
+ raw_(8, zone),
+ expressions_(8, zone) {
+ }
+
+ static int parent_num_ids() { return Expression::num_ids(); }
+
+ int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+
+ ZoneList<Expression*> cooked_;
+ ZoneList<Expression*> raw_;
+ ZoneList<Expression*> expressions_;
+};
+
+
// Base class for literals that needs space in the corresponding JSFunction.
class MaterializedLiteral : public Expression {
public:
@@ -3389,6 +3430,12 @@ class AstNodeFactory FINAL BASE_EMBEDDED {
VISIT_AND_RETURN(Literal, lit)
}
+ TemplateLiteral* NewTemplateLiteral(int pos) {
+ TemplateLiteral* lit =
+ new (zone_) TemplateLiteral(zone_, pos);
+ VISIT_AND_RETURN(TemplateLiteral, lit);
+ }
+
// A JavaScript symbol (ECMA-262 edition 6).
Literal* NewSymbolLiteral(const char* name, int pos) {
Literal* lit =
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698