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/ast/ast.h" | 5 #include "src/ast/ast.h" |
6 #include "src/messages.h" | 6 #include "src/messages.h" |
7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
8 #include "src/parsing/parameter-initializer-rewriter.h" | 8 #include "src/parsing/parameter-initializer-rewriter.h" |
9 #include "src/parsing/parser.h" | 9 #include "src/parsing/parser.h" |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 : descriptor_->scope->GetDeclarationScope()); | 164 : descriptor_->scope->GetDeclarationScope()); |
165 if (declaration_scope->num_var() > kMaxNumFunctionLocals) { | 165 if (declaration_scope->num_var() > kMaxNumFunctionLocals) { |
166 parser_->ReportMessage(MessageTemplate::kTooManyVariables); | 166 parser_->ReportMessage(MessageTemplate::kTooManyVariables); |
167 *ok_ = false; | 167 *ok_ = false; |
168 return; | 168 return; |
169 } | 169 } |
170 if (names_) { | 170 if (names_) { |
171 names_->Add(name, zone()); | 171 names_->Add(name, zone()); |
172 } | 172 } |
173 | 173 |
174 Scope* var_init_scope = descriptor_->scope; | |
175 MarkTopLevelVariableAsAssigned(var_init_scope, proxy); | |
176 | |
177 // If there's no initializer, we're done. | 174 // If there's no initializer, we're done. |
178 if (value == nullptr) return; | 175 if (value == nullptr) return; |
179 | 176 |
| 177 Scope* var_init_scope = descriptor_->scope; |
180 MarkLoopVariableAsAssigned(var_init_scope, proxy->var()); | 178 MarkLoopVariableAsAssigned(var_init_scope, proxy->var()); |
181 | 179 |
182 // A declaration of the form: | 180 // A declaration of the form: |
183 // | 181 // |
184 // var v = x; | 182 // var v = x; |
185 // | 183 // |
186 // is syntactic sugar for: | 184 // is syntactic sugar for: |
187 // | 185 // |
188 // var v; v = x; | 186 // var v; v = x; |
189 // | 187 // |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 NOT_A_PATTERN(TryFinallyStatement) | 758 NOT_A_PATTERN(TryFinallyStatement) |
761 NOT_A_PATTERN(UnaryOperation) | 759 NOT_A_PATTERN(UnaryOperation) |
762 NOT_A_PATTERN(VariableDeclaration) | 760 NOT_A_PATTERN(VariableDeclaration) |
763 NOT_A_PATTERN(WhileStatement) | 761 NOT_A_PATTERN(WhileStatement) |
764 NOT_A_PATTERN(WithStatement) | 762 NOT_A_PATTERN(WithStatement) |
765 NOT_A_PATTERN(Yield) | 763 NOT_A_PATTERN(Yield) |
766 | 764 |
767 #undef NOT_A_PATTERN | 765 #undef NOT_A_PATTERN |
768 } // namespace internal | 766 } // namespace internal |
769 } // namespace v8 | 767 } // namespace v8 |
OLD | NEW |