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

Unified Diff: lib/compiler/implementation/universe/universe.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/universe/universe.dart
diff --git a/lib/compiler/implementation/universe/universe.dart b/lib/compiler/implementation/universe/universe.dart
index 645d71b77b5173cfe4910803a83634a1f1891eda..296b9ec46bcac0167d71f638e6ec2103418dcbe2 100644
--- a/lib/compiler/implementation/universe/universe.dart
+++ b/lib/compiler/implementation/universe/universe.dart
@@ -129,20 +129,26 @@ class Selector implements Hashable {
final List<SourceString> namedArguments;
final List<SourceString> orderedNamedArguments;
- Selector(
+ Selector._noLibraryCheck(
ahe 2012/09/24 06:43:31 This is getting really confusing now. First, I'd l
aam-me 2012/09/24 13:08:20 This implementation doesn't rely on name prefixed
aam-me 2012/09/25 04:15:18 I reverted this in most recent implementation.
this.kind,
- SourceString name,
- LibraryElement library,
+ this.name,
+ this.library,
this.argumentCount,
- [List<SourceString> namedArguments = const <SourceString>[]])
- : this.name = name,
- this.library = name.isPrivate() ? library : null,
- this.namedArguments = namedArguments,
- this.orderedNamedArguments = namedArguments.isEmpty()
- ? namedArguments
- : <SourceString>[] {
- assert(!name.isPrivate() || library != null);
- }
+ namedArguments)
+ : this.namedArguments = namedArguments,
+ this.orderedNamedArguments = namedArguments.isEmpty() ? namedArguments
+ : <SourceString>[];
kasperl 2012/09/24 05:52:38 Somewhere you lost the assert(!name.isPrivate
+
+ Selector(kind,
+ name,
+ LibraryElement library,
+ argumentCount,
+ [List<SourceString> namedArguments = const <SourceString>[]])
+ : this._noLibraryCheck(kind,
+ name,
+ name.isPrivate() ? library : null,
+ argumentCount,
+ namedArguments);
Selector.getter(SourceString name, LibraryElement library)
: this(SelectorKind.GETTER, name, library, 0);
@@ -179,6 +185,26 @@ class Selector implements Hashable {
[List<SourceString> named = const []])
: this(SelectorKind.CALL, name, library, arity, named);
+ // Ignore arity and named parameters when creating constructor selector
+ // since constructors are uniquely identifed by name only, can't be
+ // overriden.
+ Selector.callConstructor(SourceString className,
kasperl 2012/09/24 05:52:38 I know I sort of led you to a design where the sel
aam-me 2012/09/24 13:08:20 Let me give it a try!
aam-me 2012/09/25 04:15:18 Okay, so name is just a constructor name, but now
+ SourceString constructorName,
+ LibraryElement library)
+ : this._noLibraryCheck(SelectorKind.CALL,
+ (constructorName === const SourceString(''))
kasperl 2012/09/24 05:52:38 Can't you make it so this will never be called wit
aam-me 2012/09/25 04:15:18 I'm not certain on how to ensure that callConstruc
+ ? className
+ : new SourceString(
+ "${className.slowToString()}."
+ "${constructorName.slowToString()}"),
ahe 2012/09/24 06:43:31 I think this is problematic. The constructor name
aam-me 2012/09/25 04:15:18 All this is gone now.
+ constructorName.isPrivate()? library: null,
kasperl 2012/09/24 05:52:38 Space before ? and before :.
+ 0,
+ const []);
+
+ Selector.callDefaultConstructor(SourceString name,
+ LibraryElement library)
+ : this(SelectorKind.CALL, name, library, 0, const []);
+
Selector.callClosure(int arity, [List<SourceString> named = const []])
: this(SelectorKind.CALL, Compiler.CALL_OPERATOR_NAME, null,
arity, named);
@@ -202,6 +228,8 @@ class Selector implements Hashable {
bool isUnaryOperator() => isOperator() && argumentCount == 0;
bool isBinaryOperator() => isOperator() && argumentCount == 1;
+ bool isPrivate() => library != null;
+
/** Check whether this is a call to 'assert' with one positional parameter. */
bool isAssertSyntax() {
return (isCall() &&

Powered by Google App Engine
This is Rietveld 408576698