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

Unified Diff: frog/leg/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: 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
« frog/leg/elements/elements.dart ('K') | « frog/leg/emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/ssa/builder.dart
diff --git a/frog/leg/ssa/builder.dart b/frog/leg/ssa/builder.dart
index 92ba9bc873fc4e6294b25808f9f5eb1a28ae10e9..9cac597544e9244c5125bb6ef5d5cfe9ffe31b59 100644
--- a/frog/leg/ssa/builder.dart
+++ b/frog/leg/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.
« frog/leg/elements/elements.dart ('K') | « frog/leg/emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698