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/parser.h" | 6 #include "src/parser.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 | 9 |
10 namespace internal { | 10 namespace internal { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 Assignment* assignment = factory()->NewAssignment( | 201 Assignment* assignment = factory()->NewAssignment( |
202 descriptor_->init_op, proxy, value, descriptor_->pos); | 202 descriptor_->init_op, proxy, value, descriptor_->pos); |
203 block_->AddStatement( | 203 block_->AddStatement( |
204 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 204 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), |
205 zone()); | 205 zone()); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 | 209 |
210 void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern) { | 210 void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern) { |
211 auto temp = descriptor_->declaration_scope->NewTemporary( | 211 auto temp = TemporaryDeclarationScope()->NewTemporary( |
212 ast_value_factory()->empty_string()); | 212 ast_value_factory()->empty_string()); |
213 auto assignment = | 213 auto assignment = |
214 factory()->NewAssignment(Token::ASSIGN, factory()->NewVariableProxy(temp), | 214 factory()->NewAssignment(Token::ASSIGN, factory()->NewVariableProxy(temp), |
215 current_value_, RelocInfo::kNoPosition); | 215 current_value_, RelocInfo::kNoPosition); |
216 | |
216 block_->AddStatement( | 217 block_->AddStatement( |
217 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 218 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), |
218 zone()); | 219 zone()); |
220 block_->AddStatement(descriptor_->parser->BuildAssertIsCoercible(temp), | |
arv (Not doing code reviews)
2015/05/18 13:12:53
In theory this is only need when we have an empty
Dmitry Lomov (no reviews)
2015/05/18 13:41:46
Done.
| |
221 zone()); | |
222 | |
219 for (ObjectLiteralProperty* property : *pattern->properties()) { | 223 for (ObjectLiteralProperty* property : *pattern->properties()) { |
220 // TODO(dslomov): computed property names. | 224 // TODO(dslomov): computed property names. |
221 RecurseIntoSubpattern( | 225 RecurseIntoSubpattern( |
222 property->value(), | 226 property->value(), |
223 factory()->NewProperty(factory()->NewVariableProxy(temp), | 227 factory()->NewProperty(factory()->NewVariableProxy(temp), |
224 property->key(), RelocInfo::kNoPosition)); | 228 property->key(), RelocInfo::kNoPosition)); |
225 } | 229 } |
226 } | 230 } |
227 | 231 |
228 | 232 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 NOT_A_PATTERN(TryFinallyStatement) | 291 NOT_A_PATTERN(TryFinallyStatement) |
288 NOT_A_PATTERN(UnaryOperation) | 292 NOT_A_PATTERN(UnaryOperation) |
289 NOT_A_PATTERN(VariableDeclaration) | 293 NOT_A_PATTERN(VariableDeclaration) |
290 NOT_A_PATTERN(WhileStatement) | 294 NOT_A_PATTERN(WhileStatement) |
291 NOT_A_PATTERN(WithStatement) | 295 NOT_A_PATTERN(WithStatement) |
292 NOT_A_PATTERN(Yield) | 296 NOT_A_PATTERN(Yield) |
293 | 297 |
294 #undef NOT_A_PATTERN | 298 #undef NOT_A_PATTERN |
295 } | 299 } |
296 } // namespace v8::internal | 300 } // namespace v8::internal |
OLD | NEW |