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

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

Issue 10836360: Process private identifier in visitIdentifier. (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 | no next file » | 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 1f697c8f190f493d071f1a5eb378e4ca304d6272..e57402178aad06c1d8ab624c0c0375d90a11e35b 100644
--- a/lib/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -16,6 +16,7 @@ class SendVisitor extends ResolvedVisitor {
SendVisitor(this.collector, TreeElements elements) : super(elements);
+ visitDynamicSend(Send node) {}
visitSuperSend(Send node) {}
visitOperatorSend(Send node) {}
visitForeignSend(Send node) {}
@@ -27,17 +28,10 @@ class SendVisitor extends ResolvedVisitor {
}
}
- visitDynamicSend(Send node) {
- tryRenamePrivateSelector(node);
- }
-
visitGetterSend(Send node) {
final element = elements[node];
// element === null means dynamic property access.
- if (element === null || element.isMember()) {
- tryRenamePrivateSelector(node);
- return;
- }
+ if (element === null) return;
// We don't want to rename non top-level element access
// unless it's a local variable.
if (element.isPrefix()) {
@@ -81,10 +75,6 @@ class SendVisitor extends ResolvedVisitor {
internalError(String reason, [Node node]) {
collector.internalError(reason, node);
}
-
- tryRenamePrivateSelector(Send node) {
- collector.tryMakePrivateIdentifier(node.selector.asIdentifier());
- }
}
class PlaceholderCollector extends AbstractVisitor {
@@ -152,64 +142,18 @@ class PlaceholderCollector extends AbstractVisitor {
tryMakeConstructorNamePlaceholder(implementingFactory.cachedNode,
element.getEnclosingClass());
}
-
- // Process Ctor(this._field) correctly.
- for (Node parameter in node.parameters) {
- VariableDefinitions definitions = parameter.asVariableDefinitions();
- if (definitions !== null) {
- for (Node definition in definitions.definitions) {
- Send send = definition.asSend();
- if (send !== null) {
- assert(send.receiver is Identifier);
- assert(send.receiver.asIdentifier().isThis());
- if (send.selector is Identifier) {
- tryMakePrivateIdentifier(send.selector.asIdentifier());
- } else if (send.selector is FunctionExpression) {
- // C(int this.f()) case where f is field of function type.
- tryMakePrivateIdentifier(
- send.selector.asFunctionExpression().name.asIdentifier());
- } else {
- unreachable();
- }
- } else {
- assert(definition is Identifier
- || definition is FunctionExpression);
- }
- }
- } else {
- assert(parameter is NodeList);
- // We don't have to rename privates in optionals.
- }
- }
} else if (element.isTopLevel()) {
// 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
// be able to resolve private identifiers for other libraries.
makeElementPlaceholder(node.name, element);
- } else {
- if (node.name !== null) {
- Identifier identifier = node.name.asIdentifier();
- // operator <blah> names shouldn't be renamed.
- if (identifier !== null) tryMakePrivateIdentifier(identifier);
- }
}
}
void collectFieldDeclarationPlaceholders(
Element element, VariableDefinitions node) {
- if (element.isInstanceMember()) {
- for (Node definition in node.definitions) {
- if (definition is Identifier) {
- tryMakePrivateIdentifier(definition.asIdentifier());
- } else if (definition is SendSet) {
- tryMakePrivateIdentifier(
- definition.asSendSet().selector.asIdentifier());
- } else {
- unreachable();
- }
- }
- } else if (element.isTopLevel()) {
+ if (element.isTopLevel()) {
Node fieldNode = element.parseNode(compiler);
if (fieldNode is Identifier) {
makeElementPlaceholder(fieldNode, element);
@@ -248,10 +192,6 @@ class PlaceholderCollector extends AbstractVisitor {
});
}
- void tryMakePrivateIdentifier(Identifier identifier) {
- if (identifier.source.isPrivate()) makePrivateIdentifier(identifier);
- }
-
void tryMakeLocalPlaceholder(Element element, Identifier node) {
// TODO(smok): Maybe we should rename privates as well, their privacy
// should not matter if they are local vars.
@@ -314,21 +254,11 @@ class PlaceholderCollector extends AbstractVisitor {
visitNode(Node node) { node.visitChildren(this); } // We must go deeper.
visitSend(Send send) {
- Element element = treeElements[send];
- if (element !== null && element.isErroneous()) {
- // TODO(antonm): this is an unresolved constructor, not a dynamic send.
- ErroneousElement erroneousElement = element;
- compiler.cancel(reason: erroneousElement.errorMessage.toString(),
- node: send);
- }
new SendVisitor(this, treeElements).visitSend(send);
send.visitChildren(this);
}
visitSendSet(SendSet send) {
- if (send.selector is Identifier) {
- tryMakePrivateIdentifier(send.selector.asIdentifier());
- }
final element = treeElements[send];
if (element !== null) {
if (element.isTopLevel()) {
@@ -342,6 +272,10 @@ class PlaceholderCollector extends AbstractVisitor {
send.visitChildren(this);
}
+ visitIdentifier(Identifier identifier) {
+ if (identifier.source.isPrivate()) makePrivateIdentifier(identifier);
+ }
+
static bool isPlainTypeName(TypeAnnotation typeAnnotation) {
if (typeAnnotation.typeName is !Identifier) return false;
if (typeAnnotation.typeArguments === null) return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698