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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/ast-expression-visitor.cc » ('j') | no next file with comments »
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/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 26 matching lines...) Expand all
37 // ---------------------------------------------------------------------------- 37 // ----------------------------------------------------------------------------
38 // Nodes of the abstract syntax tree. Only concrete classes are 38 // Nodes of the abstract syntax tree. Only concrete classes are
39 // enumerated here. 39 // enumerated here.
40 40
41 #define DECLARATION_NODE_LIST(V) \ 41 #define DECLARATION_NODE_LIST(V) \
42 V(VariableDeclaration) \ 42 V(VariableDeclaration) \
43 V(FunctionDeclaration) \ 43 V(FunctionDeclaration) \
44 V(ImportDeclaration) \ 44 V(ImportDeclaration) \
45 V(ExportDeclaration) 45 V(ExportDeclaration)
46 46
47 #define STATEMENT_NODE_LIST(V) \ 47 #define STATEMENT_NODE_LIST(V) \
48 V(Block) \ 48 V(Block) \
49 V(ExpressionStatement) \ 49 V(ExpressionStatement) \
50 V(EmptyStatement) \ 50 V(EmptyStatement) \
51 V(IfStatement) \ 51 V(SloppyBlockFunctionStatement) \
52 V(ContinueStatement) \ 52 V(IfStatement) \
53 V(BreakStatement) \ 53 V(ContinueStatement) \
54 V(ReturnStatement) \ 54 V(BreakStatement) \
55 V(WithStatement) \ 55 V(ReturnStatement) \
56 V(SwitchStatement) \ 56 V(WithStatement) \
57 V(DoWhileStatement) \ 57 V(SwitchStatement) \
58 V(WhileStatement) \ 58 V(DoWhileStatement) \
59 V(ForStatement) \ 59 V(WhileStatement) \
60 V(ForInStatement) \ 60 V(ForStatement) \
61 V(ForOfStatement) \ 61 V(ForInStatement) \
62 V(TryCatchStatement) \ 62 V(ForOfStatement) \
63 V(TryFinallyStatement) \ 63 V(TryCatchStatement) \
64 V(TryFinallyStatement) \
64 V(DebuggerStatement) 65 V(DebuggerStatement)
65 66
66 #define EXPRESSION_NODE_LIST(V) \ 67 #define EXPRESSION_NODE_LIST(V) \
67 V(FunctionLiteral) \ 68 V(FunctionLiteral) \
68 V(ClassLiteral) \ 69 V(ClassLiteral) \
69 V(NativeFunctionLiteral) \ 70 V(NativeFunctionLiteral) \
70 V(Conditional) \ 71 V(Conditional) \
71 V(VariableProxy) \ 72 V(VariableProxy) \
72 V(Literal) \ 73 V(Literal) \
73 V(RegExpLiteral) \ 74 V(RegExpLiteral) \
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 1262
1262 class EmptyStatement final : public Statement { 1263 class EmptyStatement final : public Statement {
1263 public: 1264 public:
1264 DECLARE_NODE_TYPE(EmptyStatement) 1265 DECLARE_NODE_TYPE(EmptyStatement)
1265 1266
1266 protected: 1267 protected:
1267 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} 1268 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {}
1268 }; 1269 };
1269 1270
1270 1271
1272 // Delegates to another statement, which may be overwritten.
1273 // This was introduced to implement ES2015 Annex B3.3 for conditionally making
1274 // sloppy-mode block-scoped functions have a var binding, which is changed
1275 // from one statement to another during parsing.
1276 class SloppyBlockFunctionStatement final : public Statement {
1277 public:
1278 DECLARE_NODE_TYPE(SloppyBlockFunctionStatement)
1279
1280 Statement* statement() const { return statement_; }
1281 void set_statement(Statement* statement) { statement_ = statement; }
1282 Scope* scope() const { return scope_; }
1283
1284 private:
1285 SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope)
1286 : Statement(zone, RelocInfo::kNoPosition),
1287 statement_(statement),
1288 scope_(scope) {}
1289
1290 Statement* statement_;
1291 Scope* const scope_;
1292 };
1293
1294
1271 class Literal final : public Expression { 1295 class Literal final : public Expression {
1272 public: 1296 public:
1273 DECLARE_NODE_TYPE(Literal) 1297 DECLARE_NODE_TYPE(Literal)
1274 1298
1275 bool IsPropertyName() const override { return value_->IsPropertyName(); } 1299 bool IsPropertyName() const override { return value_->IsPropertyName(); }
1276 1300
1277 Handle<String> AsPropertyName() { 1301 Handle<String> AsPropertyName() {
1278 DCHECK(IsPropertyName()); 1302 DCHECK(IsPropertyName());
1279 return Handle<String>::cast(value()); 1303 return Handle<String>::cast(value());
1280 } 1304 }
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3397 } 3421 }
3398 3422
3399 DebuggerStatement* NewDebuggerStatement(int pos) { 3423 DebuggerStatement* NewDebuggerStatement(int pos) {
3400 return new (local_zone_) DebuggerStatement(local_zone_, pos); 3424 return new (local_zone_) DebuggerStatement(local_zone_, pos);
3401 } 3425 }
3402 3426
3403 EmptyStatement* NewEmptyStatement(int pos) { 3427 EmptyStatement* NewEmptyStatement(int pos) {
3404 return new (local_zone_) EmptyStatement(local_zone_, pos); 3428 return new (local_zone_) EmptyStatement(local_zone_, pos);
3405 } 3429 }
3406 3430
3431 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(
3432 Statement* statement, Scope* scope) {
3433 return new (local_zone_)
3434 SloppyBlockFunctionStatement(local_zone_, statement, scope);
3435 }
3436
3407 CaseClause* NewCaseClause( 3437 CaseClause* NewCaseClause(
3408 Expression* label, ZoneList<Statement*>* statements, int pos) { 3438 Expression* label, ZoneList<Statement*>* statements, int pos) {
3409 return new (local_zone_) CaseClause(local_zone_, label, statements, pos); 3439 return new (local_zone_) CaseClause(local_zone_, label, statements, pos);
3410 } 3440 }
3411 3441
3412 Literal* NewStringLiteral(const AstRawString* string, int pos) { 3442 Literal* NewStringLiteral(const AstRawString* string, int pos) {
3413 return new (local_zone_) 3443 return new (local_zone_)
3414 Literal(local_zone_, ast_value_factory_->NewString(string), pos); 3444 Literal(local_zone_, ast_value_factory_->NewString(string), pos);
3415 } 3445 }
3416 3446
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
3703 // ZoneObjects which need to persist until scope analysis must be allocated in 3733 // ZoneObjects which need to persist until scope analysis must be allocated in
3704 // the parser-level zone. 3734 // the parser-level zone.
3705 Zone* parser_zone_; 3735 Zone* parser_zone_;
3706 AstValueFactory* ast_value_factory_; 3736 AstValueFactory* ast_value_factory_;
3707 }; 3737 };
3708 3738
3709 3739
3710 } } // namespace v8::internal 3740 } } // namespace v8::internal
3711 3741
3712 #endif // V8_AST_H_ 3742 #endif // V8_AST_H_
OLDNEW
« 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