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

Unified 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, 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') | src/bailout-reason.h » ('J')
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..b2cc273fb8de49c49c00fc359b2baa9b010d821b 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,29 @@ class Literal FINAL : public Expression {
};
+class TemplateLiteral FINAL : public Expression {
+ public:
+ DECLARE_NODE_TYPE(TemplateLiteral)
+
+ ZoneList<const AstTemplateSpan*>* spans() const { return spans_; }
+ ZoneList<Expression*>* expressions() const { return expressions_; }
+
+ static int num_ids() { return parent_num_ids() + 1; }
+
+ private:
+ TemplateLiteral(Zone* zone, ZoneList<const AstTemplateSpan*>* spans,
+ ZoneList<Expression*>* expressions, int pos)
+ : Expression(zone, pos), spans_(spans), expressions_(expressions) {}
+
+ static int parent_num_ids() { return Expression::num_ids(); }
+
+ int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+
+ ZoneList<const AstTemplateSpan*>* spans_;
+ ZoneList<Expression*>* expressions_;
+};
+
+
// Base class for literals that needs space in the corresponding JSFunction.
class MaterializedLiteral : public Expression {
public:
@@ -3389,6 +3413,13 @@ class AstNodeFactory FINAL BASE_EMBEDDED {
VISIT_AND_RETURN(Literal, lit)
}
+ TemplateLiteral* NewTemplateLiteral(ZoneList<const AstTemplateSpan*>* spans,
+ ZoneList<Expression*>* exprs, int pos) {
+ TemplateLiteral* lit =
+ new (zone_) TemplateLiteral(zone_, spans, exprs, 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') | src/bailout-reason.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698