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

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

Issue 10752002: support unparsing of "new Object()": (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') | tests/compiler/dart2js/unparser_test.dart » ('J')
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 b03c108c4204ee3cf76c583321093b9c8c1ec910..86cc25a536f3e799900eef27c929b363752d6220 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -42,9 +42,28 @@ class DartBackend extends Backend {
throw new BailoutException(reason);
}
+ /**
+ * Tells whether we should output given element. Corelib classes like
+ * Object should not be in the resulting code.
+ */
+ bool shouldOutput(Element element) {
+ var compilationUnitUri = element.getCompilationUnit().script.uri;
+ if (compilationUnitUri !== null && compilationUnitUri.path !== null &&
Anton Muhin 2012/07/09 18:31:26 I believe (but not 100% sure) that we have a refer
Roman 2012/07/10 03:20:29 Done. Thanks! Indeed we have reference in compiler
+ // TODO(smok): URI hacks, should we have a special 'core' flag for
+ // elements from corelib?
+ (compilationUnitUri.path.endsWith('/core.dart')
+ || compilationUnitUri.path.contains('/corelib/src/'))) {
+ return false;
+ }
+ return element.kind !== ElementKind.VOID;
+ }
+
try {
StringBuffer sb = new StringBuffer();
resolvedElements.forEach((element, treeElements) {
+ if (!shouldOutput(element)) {
Anton Muhin 2012/07/09 18:31:26 nit: single line.
Roman 2012/07/10 03:20:29 Done.
+ return;
+ }
if (!element.isTopLevel()) {
bailout('Cannot process non top-level $element');
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | tests/compiler/dart2js/unparser_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698