OLD | NEW |
---|---|
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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
(...skipping 5095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5106 continue; | 5106 continue; |
5107 } | 5107 } |
5108 } | 5108 } |
5109 | 5109 |
5110 bool var_created = false; | 5110 bool var_created = false; |
5111 | 5111 |
5112 // Write in assignments to var for each block-scoped function declaration | 5112 // Write in assignments to var for each block-scoped function declaration |
5113 auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value); | 5113 auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value); |
5114 for (SloppyBlockFunctionStatement* delegate : *delegates) { | 5114 for (SloppyBlockFunctionStatement* delegate : *delegates) { |
5115 // Check if there's a conflict with a lexical declaration | 5115 // Check if there's a conflict with a lexical declaration |
5116 Scope* outer_scope = scope->outer_scope(); | 5116 Scope* decl_scope = scope; |
5117 while (decl_scope->is_eval_scope()) { | |
5118 decl_scope = decl_scope->outer_scope()->DeclarationScope(); | |
Dan Ehrenberg
2016/07/01 23:55:53
It feels like this will search a little too far. D
| |
5119 } | |
5120 Scope* outer_scope = decl_scope->outer_scope(); | |
5117 Scope* query_scope = delegate->scope()->outer_scope(); | 5121 Scope* query_scope = delegate->scope()->outer_scope(); |
5118 Variable* var = nullptr; | 5122 Variable* var = nullptr; |
5119 bool should_hoist = true; | 5123 bool should_hoist = true; |
5120 | 5124 |
5121 // Note that we perform this loop for each delegate named 'name', | 5125 // Note that we perform this loop for each delegate named 'name', |
5122 // which may duplicate work if those delegates share scopes. | 5126 // which may duplicate work if those delegates share scopes. |
5123 // It is not sufficient to just do a Lookup on query_scope: for | 5127 // It is not sufficient to just do a Lookup on query_scope: for |
5124 // example, that does not prevent hoisting of the function in | 5128 // example, that does not prevent hoisting of the function in |
5125 // `{ let e; try {} catch (e) { function e(){} } }` | 5129 // `{ let e; try {} catch (e) { function e(){} } }` |
5126 do { | 5130 do { |
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6997 try_block, target); | 7001 try_block, target); |
6998 final_loop = target; | 7002 final_loop = target; |
6999 } | 7003 } |
7000 | 7004 |
7001 return final_loop; | 7005 return final_loop; |
7002 } | 7006 } |
7003 | 7007 |
7004 | 7008 |
7005 } // namespace internal | 7009 } // namespace internal |
7006 } // namespace v8 | 7010 } // namespace v8 |
OLD | NEW |