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

Unified Diff: src/ast.h

Issue 1332873003: Implement sloppy-mode block-defined functions (Annex B 3.3) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Improve type clarity Created 5 years, 3 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') | 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 0486c3ee3f4f19a17f021857f6f2344ce27a447c..63eb9f1fa457d6002e36d7839abe92c4b3023332 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -44,23 +44,24 @@ namespace internal {
V(ImportDeclaration) \
V(ExportDeclaration)
-#define STATEMENT_NODE_LIST(V) \
- V(Block) \
- V(ExpressionStatement) \
- V(EmptyStatement) \
- V(IfStatement) \
- V(ContinueStatement) \
- V(BreakStatement) \
- V(ReturnStatement) \
- V(WithStatement) \
- V(SwitchStatement) \
- V(DoWhileStatement) \
- V(WhileStatement) \
- V(ForStatement) \
- V(ForInStatement) \
- V(ForOfStatement) \
- V(TryCatchStatement) \
- V(TryFinallyStatement) \
+#define STATEMENT_NODE_LIST(V) \
+ V(Block) \
+ V(ExpressionStatement) \
+ V(EmptyStatement) \
+ V(SloppyBlockFunctionStatement) \
+ V(IfStatement) \
+ V(ContinueStatement) \
+ V(BreakStatement) \
+ V(ReturnStatement) \
+ V(WithStatement) \
+ V(SwitchStatement) \
+ V(DoWhileStatement) \
+ V(WhileStatement) \
+ V(ForStatement) \
+ V(ForInStatement) \
+ V(ForOfStatement) \
+ V(TryCatchStatement) \
+ V(TryFinallyStatement) \
V(DebuggerStatement)
#define EXPRESSION_NODE_LIST(V) \
@@ -1268,6 +1269,29 @@ class EmptyStatement final : public Statement {
};
+// Delegates to another statement, which may be overwritten.
+// This was introduced to implement ES2015 Annex B3.3 for conditionally making
+// sloppy-mode block-scoped functions have a var binding, which is changed
+// from one statement to another during parsing.
+class SloppyBlockFunctionStatement final : public Statement {
+ public:
+ DECLARE_NODE_TYPE(SloppyBlockFunctionStatement)
+
+ Statement* statement() const { return statement_; }
+ void set_statement(Statement* statement) { statement_ = statement; }
+ Scope* scope() const { return scope_; }
+
+ private:
+ SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope)
+ : Statement(zone, RelocInfo::kNoPosition),
+ statement_(statement),
+ scope_(scope) {}
+
+ Statement* statement_;
+ Scope* const scope_;
+};
+
+
class Literal final : public Expression {
public:
DECLARE_NODE_TYPE(Literal)
@@ -3404,6 +3428,12 @@ class AstNodeFactory final BASE_EMBEDDED {
return new (local_zone_) EmptyStatement(local_zone_, pos);
}
+ SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(
+ Statement* statement, Scope* scope) {
+ return new (local_zone_)
+ SloppyBlockFunctionStatement(local_zone_, statement, scope);
+ }
+
CaseClause* NewCaseClause(
Expression* label, ZoneList<Statement*>* statements, int pos) {
return new (local_zone_) CaseClause(local_zone_, label, statements, pos);
« no previous file with comments | « no previous file | src/ast-expression-visitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698