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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10947024: Made dart2js constructor lookup logic "private"-aware, fixed 4740 bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Another try in implementing constructor lookup, without SelectorName this time. Created 8 years, 3 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
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index 4bed08dbcd52e3cd2dae94dc80666b8befea235a..d9f00ebba25b598571cdfeeb194e3fb37c3caa21 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -1374,21 +1374,17 @@ class ClassElement extends ScopeContainerElement
}
}
- Element lookupConstructor(SourceString className,
- [SourceString constructorName =
- const SourceString(''),
- Element noMatch(Element)]) {
+ Element lookupConstructor(Selector selector, [Element noMatch(Element)]) {
// TODO(karlklose): have a map from class names to a map of constructors
// instead of creating the name here?
- SourceString normalizedName;
- if (constructorName !== const SourceString('')) {
- normalizedName = Elements.constructConstructorName(className,
- constructorName);
- } else {
- normalizedName = className;
- }
+ SourceString normalizedName =
+ Elements.constructConstructorNameFromOneName(selector.name);
+
Element result = localLookup(normalizedName);
- if (result === null || !result.isConstructor()) {
+
+ if (result === null
+ || !result.isConstructor()
+ || (selector.isPrivate() && result.getLibrary() != selector.library)) {
result = noMatch !== null ? noMatch(result) : null;
}
return result;
@@ -1595,6 +1591,18 @@ class Elements {
return new SourceString('$r\$$s');
}
+ static SourceString constructConstructorNameFromOneName(SourceString name) {
kasperl 2012/09/24 05:52:38 Somehow it would be simpler if the name stored in
ahe 2012/09/24 06:43:31 I'm uncomfortable about adding this method. The me
aam-me 2012/09/25 04:15:18 Okay, got rid of the method and storing normalized
+ var strName = name.slowToString();
kasperl 2012/09/24 05:52:38 Try to avoid abbreviations. I'd go for dotIndex an
+ var ndxDot = strName.indexOf(".");
+ if (ndxDot >= 0) {
+ return new SourceString(
+ '${strName.substring(0, ndxDot)}\$'
+ '${strName.substring(ndxDot + 1, strName.length)}');
+ } else {
+ return name;
+ }
+ }
+
static const SourceString OPERATOR_EQUALS =
const SourceString(@'operator$eq');

Powered by Google App Engine
This is Rietveld 408576698