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/messages.h" |
7 #include "src/parameter-initializer-rewriter.h" | 7 #include "src/parameter-initializer-rewriter.h" |
8 #include "src/parser.h" | 8 #include "src/parser.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // is always at the function scope level. This is only relevant for | 182 // is always at the function scope level. This is only relevant for |
183 // dynamically looked-up variables and constants (the | 183 // dynamically looked-up variables and constants (the |
184 // start context for constant lookups is always the function context, | 184 // start context for constant lookups is always the function context, |
185 // while it is the top context for var declared variables). Sigh... | 185 // while it is the top context for var declared variables). Sigh... |
186 // For 'let' and 'const' declared variables in harmony mode the | 186 // For 'let' and 'const' declared variables in harmony mode the |
187 // initialization also always assigns to the declared variable. | 187 // initialization also always assigns to the declared variable. |
188 DCHECK_NOT_NULL(proxy); | 188 DCHECK_NOT_NULL(proxy); |
189 DCHECK_NOT_NULL(proxy->var()); | 189 DCHECK_NOT_NULL(proxy->var()); |
190 DCHECK_NOT_NULL(value); | 190 DCHECK_NOT_NULL(value); |
191 Assignment* assignment = factory()->NewAssignment( | 191 Assignment* assignment = factory()->NewAssignment( |
192 descriptor_->init_op, proxy, value, descriptor_->initialization_pos); | 192 Token::INIT, proxy, value, descriptor_->initialization_pos); |
193 block_->statements()->Add( | 193 block_->statements()->Add( |
194 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 194 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), |
195 zone()); | 195 zone()); |
196 value = NULL; | 196 value = NULL; |
197 } | 197 } |
198 | 198 |
199 // Add an assignment node to the initialization statement block if we still | 199 // Add an assignment node to the initialization statement block if we still |
200 // have a pending initialization value. | 200 // have a pending initialization value. |
201 if (value != NULL) { | 201 if (value != NULL) { |
202 DCHECK(descriptor_->mode == VAR); | 202 DCHECK(descriptor_->mode == VAR); |
203 // 'var' initializations are simply assignments (with all the consequences | 203 // 'var' initializations are simply assignments (with all the consequences |
204 // if they are inside a 'with' statement - they may change a 'with' object | 204 // if they are inside a 'with' statement - they may change a 'with' object |
205 // property). | 205 // property). |
206 VariableProxy* proxy = initialization_scope->NewUnresolved(factory(), name); | 206 VariableProxy* proxy = initialization_scope->NewUnresolved(factory(), name); |
207 Assignment* assignment = factory()->NewAssignment( | 207 Assignment* assignment = factory()->NewAssignment( |
208 descriptor_->init_op, proxy, value, descriptor_->initialization_pos); | 208 Token::INIT, proxy, value, descriptor_->initialization_pos); |
209 block_->statements()->Add( | 209 block_->statements()->Add( |
210 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 210 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), |
211 zone()); | 211 zone()); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 Variable* Parser::PatternRewriter::CreateTempVar(Expression* value) { | 216 Variable* Parser::PatternRewriter::CreateTempVar(Expression* value) { |
217 auto temp = descriptor_->parser->scope_->NewTemporary( | 217 auto temp = descriptor_->parser->scope_->NewTemporary( |
218 ast_value_factory()->empty_string()); | 218 ast_value_factory()->empty_string()); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 NOT_A_PATTERN(TryFinallyStatement) | 426 NOT_A_PATTERN(TryFinallyStatement) |
427 NOT_A_PATTERN(UnaryOperation) | 427 NOT_A_PATTERN(UnaryOperation) |
428 NOT_A_PATTERN(VariableDeclaration) | 428 NOT_A_PATTERN(VariableDeclaration) |
429 NOT_A_PATTERN(WhileStatement) | 429 NOT_A_PATTERN(WhileStatement) |
430 NOT_A_PATTERN(WithStatement) | 430 NOT_A_PATTERN(WithStatement) |
431 NOT_A_PATTERN(Yield) | 431 NOT_A_PATTERN(Yield) |
432 | 432 |
433 #undef NOT_A_PATTERN | 433 #undef NOT_A_PATTERN |
434 } // namespace internal | 434 } // namespace internal |
435 } // namespace v8 | 435 } // namespace v8 |
OLD | NEW |