| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 OpenFunctionBlock(func); | 1466 OpenFunctionBlock(func); |
| 1467 AddFormalParamsToScope(¶ms, current_block_->scope); | 1467 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 1468 | 1468 |
| 1469 LoadLocalNode* receiver = | 1469 LoadLocalNode* receiver = |
| 1470 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(0)); | 1470 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(0)); |
| 1471 LoadLocalNode* value = | 1471 LoadLocalNode* value = |
| 1472 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(1)); | 1472 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(1)); |
| 1473 | 1473 |
| 1474 EnsureExpressionTemp(); | 1474 EnsureExpressionTemp(); |
| 1475 StoreInstanceFieldNode* store_field = | 1475 StoreInstanceFieldNode* store_field = |
| 1476 new StoreInstanceFieldNode(ident_pos, receiver, field, value); | 1476 new StoreInstanceFieldNode(ident_pos, receiver, field, value, |
| 1477 /* is_initializer = */ false); |
| 1477 current_block_->statements->Add(store_field); | 1478 current_block_->statements->Add(store_field); |
| 1478 current_block_->statements->Add(new ReturnNode(ST(ident_pos))); | 1479 current_block_->statements->Add(new ReturnNode(ST(ident_pos))); |
| 1479 return CloseBlock(); | 1480 return CloseBlock(); |
| 1480 } | 1481 } |
| 1481 | 1482 |
| 1482 | 1483 |
| 1483 SequenceNode* Parser::ParseConstructorClosure(const Function& func) { | 1484 SequenceNode* Parser::ParseConstructorClosure(const Function& func) { |
| 1484 TRACE_PARSER("ParseConstructorClosure"); | 1485 TRACE_PARSER("ParseConstructorClosure"); |
| 1485 const TokenPosition token_pos = func.token_pos(); | 1486 const TokenPosition token_pos = func.token_pos(); |
| 1486 | 1487 |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2602 if (field.IsNull()) { | 2603 if (field.IsNull()) { |
| 2603 ReportError(field_pos, "unresolved reference to instance field '%s'", | 2604 ReportError(field_pos, "unresolved reference to instance field '%s'", |
| 2604 field_name.ToCString()); | 2605 field_name.ToCString()); |
| 2605 } | 2606 } |
| 2606 EnsureExpressionTemp(); | 2607 EnsureExpressionTemp(); |
| 2607 AstNode* instance = new(Z) LoadLocalNode(field_pos, receiver); | 2608 AstNode* instance = new(Z) LoadLocalNode(field_pos, receiver); |
| 2608 AstNode* initializer = CheckDuplicateFieldInit(field_pos, | 2609 AstNode* initializer = CheckDuplicateFieldInit(field_pos, |
| 2609 initialized_fields, instance, &field, init_expr); | 2610 initialized_fields, instance, &field, init_expr); |
| 2610 if (initializer == NULL) { | 2611 if (initializer == NULL) { |
| 2611 initializer = | 2612 initializer = |
| 2612 new(Z) StoreInstanceFieldNode(field_pos, instance, field, init_expr); | 2613 new(Z) StoreInstanceFieldNode(field_pos, instance, field, init_expr, |
| 2614 /* is_initializer = */ true); |
| 2613 } | 2615 } |
| 2614 return initializer; | 2616 return initializer; |
| 2615 } | 2617 } |
| 2616 | 2618 |
| 2617 | 2619 |
| 2618 void Parser::CheckFieldsInitialized(const Class& cls) { | 2620 void Parser::CheckFieldsInitialized(const Class& cls) { |
| 2619 const Array& fields = Array::Handle(Z, cls.fields()); | 2621 const Array& fields = Array::Handle(Z, cls.fields()); |
| 2620 Field& field = Field::Handle(Z); | 2622 Field& field = Field::Handle(Z); |
| 2621 SequenceNode* initializers = current_block_->statements; | 2623 SequenceNode* initializers = current_block_->statements; |
| 2622 for (int field_num = 0; field_num < fields.Length(); field_num++) { | 2624 for (int field_num = 0; field_num < fields.Length(); field_num++) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 } | 2730 } |
| 2729 } | 2731 } |
| 2730 } | 2732 } |
| 2731 ASSERT(init_expr != NULL); | 2733 ASSERT(init_expr != NULL); |
| 2732 AstNode* instance = new LoadLocalNode(field.token_pos(), receiver); | 2734 AstNode* instance = new LoadLocalNode(field.token_pos(), receiver); |
| 2733 EnsureExpressionTemp(); | 2735 EnsureExpressionTemp(); |
| 2734 AstNode* field_init = | 2736 AstNode* field_init = |
| 2735 new StoreInstanceFieldNode(field.token_pos(), | 2737 new StoreInstanceFieldNode(field.token_pos(), |
| 2736 instance, | 2738 instance, |
| 2737 field, | 2739 field, |
| 2738 init_expr); | 2740 init_expr, |
| 2741 /* is_initializer = */ true); |
| 2739 current_block_->statements->Add(field_init); | 2742 current_block_->statements->Add(field_init); |
| 2740 } | 2743 } |
| 2741 } | 2744 } |
| 2742 initialized_fields->Add(NULL); // End of inline initializers. | 2745 initialized_fields->Add(NULL); // End of inline initializers. |
| 2743 SetPosition(saved_pos); | 2746 SetPosition(saved_pos); |
| 2744 } | 2747 } |
| 2745 | 2748 |
| 2746 | 2749 |
| 2747 AstNode* Parser::CheckDuplicateFieldInit( | 2750 AstNode* Parser::CheckDuplicateFieldInit( |
| 2748 TokenPosition init_pos, | 2751 TokenPosition init_pos, |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3191 AstNode* value = new LoadLocalNode(param.name_pos, p); | 3194 AstNode* value = new LoadLocalNode(param.name_pos, p); |
| 3192 EnsureExpressionTemp(); | 3195 EnsureExpressionTemp(); |
| 3193 AstNode* initializer = | 3196 AstNode* initializer = |
| 3194 CheckDuplicateFieldInit(param.name_pos, | 3197 CheckDuplicateFieldInit(param.name_pos, |
| 3195 &initialized_fields, | 3198 &initialized_fields, |
| 3196 instance, | 3199 instance, |
| 3197 &field, | 3200 &field, |
| 3198 value); | 3201 value); |
| 3199 if (initializer == NULL) { | 3202 if (initializer == NULL) { |
| 3200 initializer = new(Z) StoreInstanceFieldNode( | 3203 initializer = new(Z) StoreInstanceFieldNode( |
| 3201 param.name_pos, instance, field, value); | 3204 param.name_pos, instance, field, value, |
| 3205 /* is_initializer = */ true); |
| 3202 } | 3206 } |
| 3203 current_block_->statements->Add(initializer); | 3207 current_block_->statements->Add(initializer); |
| 3204 } | 3208 } |
| 3205 } | 3209 } |
| 3206 } | 3210 } |
| 3207 | 3211 |
| 3208 if (is_redirecting_constructor) { | 3212 if (is_redirecting_constructor) { |
| 3209 ParseConstructorRedirection(cls, receiver); | 3213 ParseConstructorRedirection(cls, receiver); |
| 3210 } else { | 3214 } else { |
| 3211 ParseInitializers(cls, receiver, &initialized_fields); | 3215 ParseInitializers(cls, receiver, &initialized_fields); |
| (...skipping 11404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14616 const ArgumentListNode& function_args, | 14620 const ArgumentListNode& function_args, |
| 14617 const LocalVariable* temp_for_last_arg, | 14621 const LocalVariable* temp_for_last_arg, |
| 14618 bool is_super_invocation) { | 14622 bool is_super_invocation) { |
| 14619 UNREACHABLE(); | 14623 UNREACHABLE(); |
| 14620 return NULL; | 14624 return NULL; |
| 14621 } | 14625 } |
| 14622 | 14626 |
| 14623 } // namespace dart | 14627 } // namespace dart |
| 14624 | 14628 |
| 14625 #endif // DART_PRECOMPILED_RUNTIME | 14629 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |