Chromium Code Reviews| Index: lib/compiler/implementation/universe/universe.dart |
| diff --git a/lib/compiler/implementation/universe/universe.dart b/lib/compiler/implementation/universe/universe.dart |
| index 09cd1467b6697b638fb638f3f63720bea538e840..6389937f7acc03247ea9a82fe4aa5fdf23fc02ea 100644 |
| --- a/lib/compiler/implementation/universe/universe.dart |
| +++ b/lib/compiler/implementation/universe/universe.dart |
| @@ -94,9 +94,50 @@ class SelectorKind { |
| toString() => name; |
| } |
| +class SelectorName { |
|
kasperl
2012/09/21 12:12:06
I'm not quite happy with this abstraction. Why do
aam-me
2012/09/21 12:35:27
Main reason for having library in SelectorName and
|
| + final SourceString libName; |
| + final SourceString className; |
| + final SourceString name; |
| + |
| + SourceString _fullName; |
| + |
| + SelectorName(name, {libName: const SourceString('')}) |
|
kasperl
2012/09/21 12:12:06
It makes me a bit uncomfortable to have these defa
aam-me
2012/09/21 12:35:27
This libName represents names which have library n
|
| + : this.fullyNamed(libName, const SourceString(''), name); |
| + SelectorName.namedClass(className, {libName: const SourceString('')}) |
| + : this.fullyNamed(libName, className, const SourceString('')); |
| + SelectorName.namedConstructor(className, |
| + name, |
| + {libName: const SourceString('')}) |
| + : this.fullyNamed(libName, className, name); |
| + |
| + SelectorName.fullyNamed(this.libName, this.className, this.name) { |
| + String fn = name.slowToString(); |
| + String cn = className.slowToString(); |
| + if (cn.length > 0) { |
| + if (fn.length > 0) { |
| + cn = cn.concat("."); |
| + } |
| + fn = cn.concat(fn); |
| + } |
| + String ln = libName.slowToString(); |
| + if (ln.length > 0) { |
| + if (fn.length >0 ) { |
| + ln = ln.concat("."); |
| + } |
| + fn = ln.concat(fn); |
| + } |
| + this._fullName = new SourceString(fn); |
| + } |
| + |
| + toString() => _fullName.stringValue; |
| + isPrivate() => name.isPrivate(); |
| +} |
| + |
| class Selector implements Hashable { |
| final SelectorKind kind; |
| - final SourceString name; |
| + final SelectorName selectorName; |
| + SourceString get name => selectorName._fullName; |
| + |
| final LibraryElement library; // Library is null for non-private selectors. |
| // The numbers of arguments of the selector. Includes named arguments. |
| @@ -105,18 +146,30 @@ class Selector implements Hashable { |
| final List<SourceString> orderedNamedArguments; |
| Selector( |
| - this.kind, |
| + kind, |
| SourceString name, |
| LibraryElement library, |
| + argumentCount, |
| + [List<SourceString> namedArguments = const <SourceString>[]]) |
| + : this.fromSelectorName(kind, |
| + new SelectorName(name), |
| + library, |
| + argumentCount, |
| + namedArguments); |
| + |
| + Selector.fromSelectorName( |
| + this.kind, |
| + SelectorName selectorName, |
| + LibraryElement library, |
| this.argumentCount, |
| [List<SourceString> namedArguments = const <SourceString>[]]) |
| - : this.name = name, |
| - this.library = name.isPrivate() ? library : null, |
| + : this.selectorName = selectorName, |
| + this.library = selectorName.isPrivate() ? library : null, |
| this.namedArguments = namedArguments, |
| this.orderedNamedArguments = namedArguments.isEmpty() |
| ? namedArguments |
| : <SourceString>[] { |
| - assert(!name.isPrivate() || library != null); |
| + assert(!selectorName.isPrivate() || library != null); |
| } |
| Selector.getter(SourceString name, LibraryElement library) |
| @@ -154,6 +207,13 @@ 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(SelectorName name, |
|
kasperl
2012/09/21 12:12:06
This looks nice and it looks like a good place to
|
| + LibraryElement library) |
| + : this.fromSelectorName(SelectorKind.CALL, name, library, 0, const []); |
| + |
| Selector.callClosure(int arity, [List<SourceString> named = const []]) |
| : this(SelectorKind.CALL, Compiler.CALL_OPERATOR_NAME, null, |
| arity, named); |