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

Unified Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10698154: Fix getters/setters unparsing, they appeared as ordinary methods without get/set keywords. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/backend.dart
diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
index 0ab44e249c854791b011097bc5683bc6d635975e..994eeb73faa6ad9f6110faa7a199842f516aa7ad 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -57,13 +57,43 @@ class DartBackend extends Backend {
sb.add(classElement.name.slowToString());
sb.add('{');
innerElements.forEach((element) {
- if (element is SynthesizedConstructorElement) return;
// TODO(smok): Filter out default constructors here.
- sb.add(element.parseNode(compiler).unparse());
+ outputElement(element, sb);
});
sb.add('}');
}
+ void outputElement(Element element, StringBuffer sb) {
Anton Muhin 2012/07/11 15:40:28 maybe it's time to introduce emitter class instead
+ // TODO(smok): Figure out why AbstractFieldElement appears here,
+ // we have used getters/setters resolved instead of it.
+ if (element is SynthesizedConstructorElement
+ || element is AbstractFieldElement) return;
+ if (element.isField()) {
+ // Add modifiers first.
+ sb.add(element.modifiers.toString());
+ sb.add(' ');
+ // Figure out type.
+ if (element is VariableElement) {
+ VariableListElement variables = element.variables;
+ if (variables.type !== null) {
+ sb.add(variables.type);
+ sb.add(' ');
+ }
+ }
+ // TODO(smok): Maybe not rely on node unparsing,
+ // but unparse initializer manually.
+ sb.add(element.parseNode(compiler).unparse());
+ sb.add(';');
+ } else {
+ if (element.isSetter()) {
+ sb.add('set ');
+ } else if (element.isGetter()) {
+ sb.add('get ');
+ }
+ sb.add(element.parseNode(compiler).unparse());
+ }
+ }
+
void assembleProgram() {
resolvedElements.forEach((element, treeElements) {
unparseValidator.check(element);
@@ -98,25 +128,7 @@ class DartBackend extends Backend {
bailout('Cannot process non top-level $element');
}
- if (element.isField()) {
- // Add modifiers first.
- sb.add(element.modifiers.toString());
- sb.add(' ');
- // Figure out type.
- if (element is VariableElement) {
- VariableListElement variables = element.variables;
- if (variables.type !== null) {
- sb.add(variables.type);
- sb.add(' ');
- }
- }
- // TODO(smok): Maybe not rely on node unparsing,
- // but unparse initializer manually.
- sb.add(element.parseNode(compiler).unparse());
- sb.add(';');
- } else {
- sb.add(element.parseNode(compiler).unparse());
- }
+ outputElement(element, sb);
});
// Now output resolved classes with inner elements we met before.
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698