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

Unified Diff: frog/leg/compile_time_constants.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
« no previous file with comments | « no previous file | frog/leg/elements/elements.dart » ('j') | frog/leg/elements/elements.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/compile_time_constants.dart
diff --git a/frog/leg/compile_time_constants.dart b/frog/leg/compile_time_constants.dart
index 94c98c5f9b08edbfd6af8cfd32eb8b6b882bee4e..dbd9387f50563271f946acdad0160ae7cbf988cf 100644
--- a/frog/leg/compile_time_constants.dart
+++ b/frog/leg/compile_time_constants.dart
@@ -356,25 +356,22 @@ class MapConstant extends ObjectConstant {
// The arguments of the JavaScript constructor for any given Dart class
// are in the same order as the members of the class element.
int emittedArgumentCount = 0;
- for (Element element in classElement.members) {
- if (element.name == LENGTH_NAME) {
+ classElement.forEachInstanceField(
+ includeBackendMembers: true,
+ includeSuperMembers: true,
+ f: (ClassElement enclosing, Element field) {
+ if (emittedArgumentCount != 0) buffer.add(", ");
+ if (field.name == LENGTH_NAME) {
buffer.add(keys.entries.length);
- } else if (element.name == JS_OBJECT_NAME) {
+ } else if (field.name == JS_OBJECT_NAME) {
writeJsMap();
- } else if (element.name == KEYS_NAME) {
+ } else if (field.name == KEYS_NAME) {
keys.writeCanonicalizedJsCode(buffer, handler);
} else {
- // Skip methods.
- if (element.kind == ElementKind.FIELD) badFieldCountError();
- continue;
+ badFieldCountError();
}
emittedArgumentCount++;
- if (emittedArgumentCount == 3) {
- break; // All arguments have been emitted.
- } else {
- buffer.add(", ");
- }
- }
+ });
if (emittedArgumentCount != 3) badFieldCountError();
buffer.add(")");
}
@@ -1095,21 +1092,17 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
List<Constant> buildJsNewArguments(ClassElement classElement) {
List<Constant> jsNewArguments = <Constant>[];
- // TODO(floitsch): share this code with the emitter, so that we don't
- // need to care about the order of fields here.
- while (classElement != compiler.objectClass) {
- for (Element member in classElement.members) {
- if (member.isInstanceMember() && member.kind == ElementKind.FIELD) {
- Constant fieldValue = fieldValues[member];
- if (fieldValue === null) {
- // Use the default value.
- fieldValue = compiler.compileVariable(member);
- }
- jsNewArguments.add(fieldValue);
- }
+ classElement.forEachInstanceField(
+ includeBackendMembers: true,
+ includeSuperMembers: true,
+ f: (ClassElement enclosing, Element field) {
+ Constant fieldValue = fieldValues[field];
+ if (fieldValue === null) {
+ // Use the default value.
+ fieldValue = compiler.compileVariable(field);
}
- classElement = classElement.superclass;
- }
+ jsNewArguments.add(fieldValue);
+ });
return jsNewArguments;
}
}
« no previous file with comments | « no previous file | frog/leg/elements/elements.dart » ('j') | frog/leg/elements/elements.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698