| OLD | NEW |
| 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library fletchc.fletch_system_builder; | 5 library fletchc.fletch_system_builder; |
| 6 | 6 |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:compiler/src/constants/values.dart' show | 9 import 'package:compiler/src/constants/values.dart' show |
| 10 ConstantValue, | 10 ConstantValue, |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 FletchFunctionBase tearoff = lookupFunction(tearoffId); | 481 FletchFunctionBase tearoff = lookupFunction(tearoffId); |
| 482 commands | 482 commands |
| 483 ..add(new PushFromMap(MapId.classes, tearoff.memberOf)) | 483 ..add(new PushFromMap(MapId.classes, tearoff.memberOf)) |
| 484 ..add(const PushNewInstance()); | 484 ..add(const PushNewInstance()); |
| 485 } else if (constant.isConstructedObject) { | 485 } else if (constant.isConstructedObject) { |
| 486 ConstructedConstantValue value = constant; | 486 ConstructedConstantValue value = constant; |
| 487 ClassElement classElement = value.type.element; | 487 ClassElement classElement = value.type.element; |
| 488 // TODO(ajohnsen): Avoid usage of builders (should be FletchClass). | 488 // TODO(ajohnsen): Avoid usage of builders (should be FletchClass). |
| 489 FletchClassBuilder classBuilder = _classBuildersByElement[classElement]; | 489 FletchClassBuilder classBuilder = _classBuildersByElement[classElement]; |
| 490 | 490 |
| 491 void addIfField(MemberElement member) { | 491 void addIfInstanceField(MemberElement member) { |
| 492 if (!member.isField || member.isStatic || member.isPatch) return; | 492 if (!member.isField || member.isStatic || member.isPatch) return; |
| 493 FieldElement fieldElement = member; | 493 FieldElement fieldElement = member; |
| 494 ConstantValue fieldValue = value.fields[fieldElement]; | 494 ConstantValue fieldValue = value.fields[fieldElement]; |
| 495 int fieldId = context.compiledConstants[fieldValue]; | 495 int fieldId = context.compiledConstants[fieldValue]; |
| 496 commands.add(new PushFromMap(MapId.constants, fieldId)); | 496 commands.add(new PushFromMap(MapId.constants, fieldId)); |
| 497 } | 497 } |
| 498 | 498 |
| 499 // Adds all the fields of [currentClass] in order starting from the top | 499 // Adds all the fields of [currentClass] in order starting from the top |
| 500 // of the inheritance chain, and for each class adds non-patch fields | 500 // of the inheritance chain, and for each class adds non-patch fields |
| 501 // before patch fields. | 501 // before patch fields. |
| 502 void addFields(ClassElement currentClass) { | 502 void addFields(ClassElement currentClass) { |
| 503 if (currentClass.superclass != null) { | 503 if (currentClass.superclass != null) { |
| 504 addFields(currentClass.superclass); | 504 addFields(currentClass.superclass); |
| 505 } | 505 } |
| 506 currentClass.forEachLocalMember(addIfField); | 506 currentClass.forEachLocalMember(addIfInstanceField); |
| 507 if (currentClass.isPatched) { | 507 if (currentClass.isPatched) { |
| 508 currentClass.patch.forEachLocalMember(addIfField); | 508 currentClass.patch.forEachLocalMember(addIfInstanceField); |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 addFields(classElement); | 512 addFields(classElement); |
| 513 | 513 |
| 514 commands | 514 commands |
| 515 ..add(new PushFromMap(MapId.classes, classBuilder.classId)) | 515 ..add(new PushFromMap(MapId.classes, classBuilder.classId)) |
| 516 ..add(const PushNewInstance()); | 516 ..add(const PushNewInstance()); |
| 517 } else if (constant is FletchClassInstanceConstant) { | 517 } else if (constant is FletchClassInstanceConstant) { |
| 518 commands | 518 commands |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 constructorInitializersByElement, | 690 constructorInitializersByElement, |
| 691 tearoffsById, | 691 tearoffsById, |
| 692 classesById, | 692 classesById, |
| 693 classesByElement, | 693 classesByElement, |
| 694 constants, | 694 constants, |
| 695 symbolByFletchSelectorId, | 695 symbolByFletchSelectorId, |
| 696 gettersByFieldIndex, | 696 gettersByFieldIndex, |
| 697 settersByFieldIndex); | 697 settersByFieldIndex); |
| 698 } | 698 } |
| 699 } | 699 } |
| OLD | NEW |