Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 9873012: Move member-iterating code into ClassElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index 7232549737f45ce91f4f2c4b49be403f815111c4..b5238ba8b03ae695b76b249e04427d9f27b85d87 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -916,26 +916,21 @@ class SsaBuilder implements Visitor {
inlineInitializers(functionElement, constructors, fieldValues);
// Call the JavaScript constructor with the fields as argument.
- // TODO(floitsch,karlklose): move this code to ClassElement and share with
- // the emitter.
List<HInstruction> constructorArguments = <HInstruction>[];
- ClassElement element = classElement;
- while (element != null) {
- for (Element member in element.members) {
- if (member.isInstanceMember() && member.kind == ElementKind.FIELD) {
- HInstruction value = fieldValues[member];
- if (value === null) {
- // The field has no value in the initializer list. Initialize it
- // with the declaration-site constant (if any).
- Constant fieldValue =
- compiler.constantHandler.compileVariable(member);
- value = graph.addConstant(fieldValue);
- }
- constructorArguments.add(value);
- }
+ classElement.forEachInstanceField(
+ includeBackendMembers: true,
+ includeSuperMembers: true,
+ f: (ClassElement enclosingClass, Element member) {
+ HInstruction value = fieldValues[member];
+ if (value === null) {
+ // The field has no value in the initializer list. Initialize it
+ // with the declaration-site constant (if any).
+ Constant fieldValue = compiler.constantHandler.compileVariable(member);
+ value = graph.addConstant(fieldValue);
}
- element = element.superclass;
- }
+ constructorArguments.add(value);
+ });
+
HForeignNew newObject = new HForeignNew(classElement, constructorArguments);
add(newObject);
// Generate calls to the constructor bodies.

Powered by Google App Engine
This is Rietveld 408576698