OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/parsing/parameter-initializer-rewriter.h" | 5 #include "src/parsing/parameter-initializer-rewriter.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-traversal-visitor.h" | 8 #include "src/ast/ast-traversal-visitor.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 Scope* param_scope_; | 36 Scope* param_scope_; |
37 }; | 37 }; |
38 | 38 |
39 void Rewriter::VisitFunctionLiteral(FunctionLiteral* function_literal) { | 39 void Rewriter::VisitFunctionLiteral(FunctionLiteral* function_literal) { |
40 function_literal->scope()->ReplaceOuterScope(param_scope_); | 40 function_literal->scope()->ReplaceOuterScope(param_scope_); |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 void Rewriter::VisitClassLiteral(ClassLiteral* class_literal) { | 44 void Rewriter::VisitClassLiteral(ClassLiteral* class_literal) { |
45 class_literal->scope()->ReplaceOuterScope(param_scope_); | |
46 if (class_literal->extends() != nullptr) { | 45 if (class_literal->extends() != nullptr) { |
47 Visit(class_literal->extends()); | 46 Visit(class_literal->extends()); |
48 } | 47 } |
49 // No need to visit the constructor since it will have the class | 48 // No need to visit the constructor since it will have the class |
50 // scope on its scope chain. | 49 // scope on its scope chain. |
51 ZoneList<ObjectLiteralProperty*>* props = class_literal->properties(); | 50 ZoneList<ObjectLiteralProperty*>* props = class_literal->properties(); |
52 for (int i = 0; i < props->length(); ++i) { | 51 for (int i = 0; i < props->length(); ++i) { |
53 ObjectLiteralProperty* prop = props->at(i); | 52 ObjectLiteralProperty* prop = props->at(i); |
54 if (!prop->key()->IsLiteral()) { | 53 if (!prop->key()->IsLiteral()) { |
55 Visit(prop->key()); | 54 Visit(prop->key()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DCHECK(param_scope->calls_sloppy_eval()); | 104 DCHECK(param_scope->calls_sloppy_eval()); |
106 DCHECK(param_scope->outer_scope()->is_function_scope()); | 105 DCHECK(param_scope->outer_scope()->is_function_scope()); |
107 | 106 |
108 Rewriter rewriter(stack_limit, expr, param_scope); | 107 Rewriter rewriter(stack_limit, expr, param_scope); |
109 rewriter.Run(); | 108 rewriter.Run(); |
110 } | 109 } |
111 | 110 |
112 | 111 |
113 } // namespace internal | 112 } // namespace internal |
114 } // namespace v8 | 113 } // namespace v8 |
OLD | NEW |