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.h" | 5 #include "src/ast.h" |
| 6 #include "src/messages.h" |
6 #include "src/parser.h" | 7 #include "src/parser.h" |
7 | 8 |
8 namespace v8 { | 9 namespace v8 { |
9 | 10 |
10 namespace internal { | 11 namespace internal { |
11 | 12 |
12 | 13 |
13 void Parser::PatternRewriter::DeclareAndInitializeVariables( | 14 void Parser::PatternRewriter::DeclareAndInitializeVariables( |
14 Block* block, const DeclarationDescriptor* declaration_descriptor, | 15 Block* block, const DeclarationDescriptor* declaration_descriptor, |
15 const DeclarationParsingResult::Declaration* declaration, | 16 const DeclarationParsingResult::Declaration* declaration, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 Variable* var = parser->Declare(declaration, descriptor_->mode != VAR, ok_); | 55 Variable* var = parser->Declare(declaration, descriptor_->mode != VAR, ok_); |
55 if (!*ok_) return; | 56 if (!*ok_) return; |
56 DCHECK_NOT_NULL(var); | 57 DCHECK_NOT_NULL(var); |
57 DCHECK(!proxy->is_resolved() || proxy->var() == var); | 58 DCHECK(!proxy->is_resolved() || proxy->var() == var); |
58 var->set_initializer_position(initializer_position_); | 59 var->set_initializer_position(initializer_position_); |
59 | 60 |
60 DCHECK(initializer_position_ != RelocInfo::kNoPosition); | 61 DCHECK(initializer_position_ != RelocInfo::kNoPosition); |
61 | 62 |
62 if (descriptor_->declaration_scope->num_var_or_const() > | 63 if (descriptor_->declaration_scope->num_var_or_const() > |
63 kMaxNumFunctionLocals) { | 64 kMaxNumFunctionLocals) { |
64 parser->ReportMessage("too_many_variables"); | 65 parser->ReportMessage(MessageTemplate::kTooManyVariables); |
65 *ok_ = false; | 66 *ok_ = false; |
66 return; | 67 return; |
67 } | 68 } |
68 if (names_) { | 69 if (names_) { |
69 names_->Add(name, zone()); | 70 names_->Add(name, zone()); |
70 } | 71 } |
71 | 72 |
72 // Initialize variables if needed. A | 73 // Initialize variables if needed. A |
73 // declaration of the form: | 74 // declaration of the form: |
74 // | 75 // |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 NOT_A_PATTERN(TryFinallyStatement) | 288 NOT_A_PATTERN(TryFinallyStatement) |
288 NOT_A_PATTERN(UnaryOperation) | 289 NOT_A_PATTERN(UnaryOperation) |
289 NOT_A_PATTERN(VariableDeclaration) | 290 NOT_A_PATTERN(VariableDeclaration) |
290 NOT_A_PATTERN(WhileStatement) | 291 NOT_A_PATTERN(WhileStatement) |
291 NOT_A_PATTERN(WithStatement) | 292 NOT_A_PATTERN(WithStatement) |
292 NOT_A_PATTERN(Yield) | 293 NOT_A_PATTERN(Yield) |
293 | 294 |
294 #undef NOT_A_PATTERN | 295 #undef NOT_A_PATTERN |
295 } | 296 } |
296 } // namespace v8::internal | 297 } // namespace v8::internal |
OLD | NEW |