| 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 <memory> | 7 #include <memory> | 
| 8 | 8 | 
| 9 #include "src/api.h" | 9 #include "src/api.h" | 
| 10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" | 
| (...skipping 5036 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5047   do_block->statements()->Add( | 5047   do_block->statements()->Add( | 
| 5048       factory()->NewExpressionStatement(init_result, kNoSourcePosition), | 5048       factory()->NewExpressionStatement(init_result, kNoSourcePosition), | 
| 5049       zone()); | 5049       zone()); | 
| 5050   // Traverse the array literal starting from the first spread. | 5050   // Traverse the array literal starting from the first spread. | 
| 5051   while (s != lit->EndValue()) { | 5051   while (s != lit->EndValue()) { | 
| 5052     Expression* value = *s++; | 5052     Expression* value = *s++; | 
| 5053     Spread* spread = value->AsSpread(); | 5053     Spread* spread = value->AsSpread(); | 
| 5054     if (spread == nullptr) { | 5054     if (spread == nullptr) { | 
| 5055       // If the element is not a spread, we're adding a single: | 5055       // If the element is not a spread, we're adding a single: | 
| 5056       // %AppendElement($R, value) | 5056       // %AppendElement($R, value) | 
| 5057       ZoneList<Expression*>* append_element_args = NewExpressionList(2); | 5057       // or, in case of a hole, | 
| 5058       append_element_args->Add(factory()->NewVariableProxy(result), zone()); | 5058       // ++($R.length) | 
| 5059       append_element_args->Add(value, zone()); | 5059       if (!value->IsLiteral() || | 
| 5060       do_block->statements()->Add( | 5060           !value->AsLiteral()->raw_value()->IsTheHole()) { | 
| 5061           factory()->NewExpressionStatement( | 5061         ZoneList<Expression*>* append_element_args = NewExpressionList(2); | 
| 5062               factory()->NewCallRuntime(Runtime::kAppendElement, | 5062         append_element_args->Add(factory()->NewVariableProxy(result), zone()); | 
| 5063                                         append_element_args, kNoSourcePosition), | 5063         append_element_args->Add(value, zone()); | 
| 5064               kNoSourcePosition), | 5064         do_block->statements()->Add( | 
| 5065           zone()); | 5065             factory()->NewExpressionStatement( | 
|  | 5066                 factory()->NewCallRuntime(Runtime::kAppendElement, | 
|  | 5067                                           append_element_args, | 
|  | 5068                                           kNoSourcePosition), | 
|  | 5069                 kNoSourcePosition), | 
|  | 5070             zone()); | 
|  | 5071       } else { | 
|  | 5072         Property* length_property = factory()->NewProperty( | 
|  | 5073             factory()->NewVariableProxy(result), | 
|  | 5074             factory()->NewStringLiteral(ast_value_factory()->length_string(), | 
|  | 5075                                         kNoSourcePosition), | 
|  | 5076             kNoSourcePosition); | 
|  | 5077         CountOperation* count_op = factory()->NewCountOperation( | 
|  | 5078             Token::INC, true /* prefix */, length_property, kNoSourcePosition); | 
|  | 5079         do_block->statements()->Add( | 
|  | 5080             factory()->NewExpressionStatement(count_op, kNoSourcePosition), | 
|  | 5081             zone()); | 
|  | 5082       } | 
| 5066     } else { | 5083     } else { | 
| 5067       // If it's a spread, we're adding a for/of loop iterating through it. | 5084       // If it's a spread, we're adding a for/of loop iterating through it. | 
| 5068       Variable* each = NewTemporary(ast_value_factory()->dot_for_string()); | 5085       Variable* each = NewTemporary(ast_value_factory()->dot_for_string()); | 
| 5069       Expression* subject = spread->expression(); | 5086       Expression* subject = spread->expression(); | 
| 5070       // %AppendElement($R, each) | 5087       // %AppendElement($R, each) | 
| 5071       Statement* append_body; | 5088       Statement* append_body; | 
| 5072       { | 5089       { | 
| 5073         ZoneList<Expression*>* append_element_args = NewExpressionList(2); | 5090         ZoneList<Expression*>* append_element_args = NewExpressionList(2); | 
| 5074         append_element_args->Add(factory()->NewVariableProxy(result), zone()); | 5091         append_element_args->Add(factory()->NewVariableProxy(result), zone()); | 
| 5075         append_element_args->Add(factory()->NewVariableProxy(each), zone()); | 5092         append_element_args->Add(factory()->NewVariableProxy(each), zone()); | 
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6082   node->Print(Isolate::Current()); | 6099   node->Print(Isolate::Current()); | 
| 6083 } | 6100 } | 
| 6084 #endif  // DEBUG | 6101 #endif  // DEBUG | 
| 6085 | 6102 | 
| 6086 #undef CHECK_OK | 6103 #undef CHECK_OK | 
| 6087 #undef CHECK_OK_VOID | 6104 #undef CHECK_OK_VOID | 
| 6088 #undef CHECK_FAILED | 6105 #undef CHECK_FAILED | 
| 6089 | 6106 | 
| 6090 }  // namespace internal | 6107 }  // namespace internal | 
| 6091 }  // namespace v8 | 6108 }  // namespace v8 | 
| OLD | NEW | 
|---|