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_); |
45 if (class_literal->extends() != nullptr) { | 46 if (class_literal->extends() != nullptr) { |
46 Visit(class_literal->extends()); | 47 Visit(class_literal->extends()); |
47 } | 48 } |
48 // No need to visit the constructor since it will have the class | 49 // No need to visit the constructor since it will have the class |
49 // scope on its scope chain. | 50 // scope on its scope chain. |
50 ZoneList<ObjectLiteralProperty*>* props = class_literal->properties(); | 51 ZoneList<ObjectLiteralProperty*>* props = class_literal->properties(); |
51 for (int i = 0; i < props->length(); ++i) { | 52 for (int i = 0; i < props->length(); ++i) { |
52 ObjectLiteralProperty* prop = props->at(i); | 53 ObjectLiteralProperty* prop = props->at(i); |
53 if (!prop->key()->IsLiteral()) { | 54 if (!prop->key()->IsLiteral()) { |
54 Visit(prop->key()); | 55 Visit(prop->key()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 DCHECK(param_scope->calls_sloppy_eval()); | 105 DCHECK(param_scope->calls_sloppy_eval()); |
105 DCHECK(param_scope->outer_scope()->is_function_scope()); | 106 DCHECK(param_scope->outer_scope()->is_function_scope()); |
106 | 107 |
107 Rewriter rewriter(stack_limit, expr, param_scope); | 108 Rewriter rewriter(stack_limit, expr, param_scope); |
108 rewriter.Run(); | 109 rewriter.Run(); |
109 } | 110 } |
110 | 111 |
111 | 112 |
112 } // namespace internal | 113 } // namespace internal |
113 } // namespace v8 | 114 } // namespace v8 |
OLD | NEW |