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

Unified Diff: src/ast.h

Issue 1399893002: [es7] implement |do| expressions proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Less code duplication in Rewriter Created 5 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-expression-visitor.cc » ('j') | src/ast-literal-reindexer.cc » ('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 906862d56d296f217e133527507e7c3102bafc1d..2cb63bfd28f87369ad13ba99f2da120e6e249f08 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -90,7 +90,8 @@ namespace internal {
V(SuperPropertyReference) \
V(SuperCallReference) \
V(CaseClause) \
- V(EmptyParentheses)
+ V(EmptyParentheses) \
+ V(DoExpression)
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
@@ -490,6 +491,29 @@ class Block final : public BreakableStatement {
};
+class DoExpression final : public Expression {
+ public:
+ DECLARE_NODE_TYPE(DoExpression)
+
+ Block* block() { return block_; }
+ VariableProxy* result() { return result_; }
+
+ protected:
+ DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos)
+ : Expression(zone, pos), block_(block), result_(result) {
+ DCHECK_NOT_NULL(block_);
+ DCHECK_NOT_NULL(result_);
+ }
+ static int parent_num_ids() { return Expression::num_ids(); }
+
+ private:
+ int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+
+ Block* block_;
+ VariableProxy* result_;
+};
+
+
class Declaration : public AstNode {
public:
VariableProxy* proxy() const { return proxy_; }
@@ -3170,35 +3194,40 @@ class AstVisitor BASE_EMBEDDED {
};
-#define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
- public: \
- void Visit(AstNode* node) final { \
- if (!CheckStackOverflow()) node->Accept(this); \
- } \
- \
- void SetStackOverflow() { stack_overflow_ = true; } \
- void ClearStackOverflow() { stack_overflow_ = false; } \
- bool HasStackOverflow() const { return stack_overflow_; } \
- \
- bool CheckStackOverflow() { \
- if (stack_overflow_) return true; \
- if (GetCurrentStackPosition() < stack_limit_) { \
- stack_overflow_ = true; \
- return true; \
- } \
- return false; \
- } \
- \
- private: \
- void InitializeAstVisitor(Isolate* isolate, Zone* zone) { \
- zone_ = zone; \
- stack_limit_ = isolate->stack_guard()->real_climit(); \
- stack_overflow_ = false; \
- } \
- Zone* zone() { return zone_; } \
- \
- Zone* zone_; \
- uintptr_t stack_limit_; \
+#define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
+ public: \
+ void Visit(AstNode* node) final { \
+ if (!CheckStackOverflow()) node->Accept(this); \
+ } \
+ \
+ void SetStackOverflow() { stack_overflow_ = true; } \
+ void ClearStackOverflow() { stack_overflow_ = false; } \
+ bool HasStackOverflow() const { return stack_overflow_; } \
+ \
+ bool CheckStackOverflow() { \
+ if (stack_overflow_) return true; \
+ if (GetCurrentStackPosition() < stack_limit_) { \
+ stack_overflow_ = true; \
+ return true; \
+ } \
+ return false; \
+ } \
+ \
+ private: \
+ void InitializeAstVisitor(Isolate* isolate, Zone* zone) { \
+ zone_ = zone; \
+ stack_limit_ = isolate->stack_guard()->real_climit(); \
+ stack_overflow_ = false; \
+ } \
+ void InitializeAstVisitor(uintptr_t stack_limit, Zone* zone) { \
+ zone_ = zone; \
+ stack_limit_ = stack_limit; \
+ stack_overflow_ = false; \
+ } \
+ Zone* zone() { return zone_; } \
+ \
+ Zone* zone_; \
+ uintptr_t stack_limit_; \
bool stack_overflow_
@@ -3584,6 +3613,11 @@ class AstNodeFactory final BASE_EMBEDDED {
NativeFunctionLiteral(parser_zone_, name, extension, pos);
}
+ DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) {
+ VariableProxy* result = NewVariableProxy(result_var, pos);
+ return new (parser_zone_) DoExpression(parser_zone_, block, result, pos);
+ }
+
ThisFunction* NewThisFunction(int pos) {
return new (local_zone_) ThisFunction(local_zone_, pos);
}
« no previous file with comments | « no previous file | src/ast-expression-visitor.cc » ('j') | src/ast-literal-reindexer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698