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

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

Issue 10870008: dart2dart Rename statics as globals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/placeholder_collector.dart
diff --git a/lib/compiler/implementation/dart_backend/placeholder_collector.dart b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
index 98754ead045d6a311d22867759b75f5148bf5bc7..96644618eaa455dbfbe647a3bca429248965e739 100644
--- a/lib/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -32,12 +32,12 @@ class SendVisitor extends ResolvedVisitor {
final element = elements[node];
// element === null means dynamic property access.
if (element === null) return;
- // We don't want to rename non top-level element access
- // unless it's a local variable.
if (element.isPrefix()) {
// Node is prefix part in case of source 'lib.somesetter = 5;'
collector.makeNullPlaceholder(node);
- return;
+ } else if (Elements.isStaticOrTopLevel(element)) {
+ // Unqualified or prefixed top level or static.
+ collector.makeElementPlaceholder(node.selector, element);
} else if (!element.isTopLevel()) {
// May get FunctionExpression here in selector
// in case of A(int this.f());
@@ -46,27 +46,16 @@ class SendVisitor extends ResolvedVisitor {
} else {
assert(node.selector is FunctionExpression);
}
- return;
- }
- // Unqualified <class> in static invocation, why it's not a type annotation?
- // Another option would be to process in visitStaticSend, NB:
- // those elements are not top-level.
- // OR: unqualified top level.
- collector.makeElementPlaceholder(node.selector, element);
- if (node.receiver !== null) {
Roman 2012/08/22 14:45:30 This thing is actually handled with 'if(element.is
Anton Muhin 2012/08/22 14:58:47 Nice!
- // <lib prefix>.<top level>.
- collector.makeNullPlaceholder(node.receiver); // Cut library prefix.
}
}
visitStaticSend(Send node) {
final element = elements[node];
- if (!element.isTopLevel()) return;
+ if (element.isConstructor() || element.isFactoryConstructor()) return;
+ collector.makeElementPlaceholder(node.selector, element);
// Another ugly case: <lib prefix>.<top level> is represented as
// receiver: lib prefix, selector: top level.
- collector.makeElementPlaceholder(node.selector, element);
- if (node.receiver !== null) {
- assert(elements[node.receiver].isPrefix());
Anton Muhin 2012/08/22 14:58:47 why drop assert?
Roman 2012/08/22 15:09:03 Done.
+ if (element.isTopLevel() && node.receiver !== null) {
// Hack: putting null into map overrides receiver of original node.
collector.makeNullPlaceholder(node.receiver);
}
@@ -142,7 +131,7 @@ class PlaceholderCollector extends AbstractVisitor {
tryMakeConstructorNamePlaceholder(implementingFactory.cachedNode,
element.getEnclosingClass());
}
- } else if (element.isTopLevel()) {
+ } else if (Elements.isStaticOrTopLevel(element)) {
// Note: this code should only rename private identifiers for class'
// fields/getters/setters/methods. Top-level identifiers are renamed
// just to escape conflicts and that should be enough as we shouldn't
@@ -153,7 +142,7 @@ class PlaceholderCollector extends AbstractVisitor {
void collectFieldDeclarationPlaceholders(
Element element, VariableDefinitions node) {
- if (element.isTopLevel()) {
+ if (Elements.isStaticOrTopLevel(element)) {
Node fieldNode = element.parseNode(compiler);
if (fieldNode is Identifier) {
makeElementPlaceholder(fieldNode, element);
@@ -266,7 +255,7 @@ class PlaceholderCollector extends AbstractVisitor {
visitSendSet(SendSet send) {
final element = treeElements[send];
if (element !== null) {
- if (element.isTopLevel()) {
+ if (Elements.isStaticOrTopLevel(element)) {
assert(element is VariableElement || element.isSetter());
makeElementPlaceholder(send.selector, element);
} else {
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698