Index: pkg/compiler/lib/src/universe/selector.dart |
diff --git a/pkg/compiler/lib/src/universe/selector.dart b/pkg/compiler/lib/src/universe/selector.dart |
index 8bef9fac0841b3700490c639a300b349dc2579ab..a76db34ea011714ff0a0fe8be36b572f4cc07bd4 100644 |
--- a/pkg/compiler/lib/src/universe/selector.dart |
+++ b/pkg/compiler/lib/src/universe/selector.dart |
@@ -5,23 +5,20 @@ |
library dart2js.selector; |
import '../common.dart'; |
-import '../common/names.dart' show |
- Names; |
-import '../elements/elements.dart' show |
- Element, |
- Elements, |
- FunctionElement, |
- FunctionSignature, |
- Name, |
- LibraryElement, |
- PublicName; |
-import '../util/util.dart' show |
- Hashing; |
-import '../world.dart' show |
- World; |
- |
-import 'call_structure.dart' show |
- CallStructure; |
+import '../common/names.dart' show Names; |
+import '../elements/elements.dart' |
+ show |
+ Element, |
+ Elements, |
+ FunctionElement, |
+ FunctionSignature, |
+ Name, |
+ LibraryElement, |
+ PublicName; |
+import '../util/util.dart' show Hashing; |
+import '../world.dart' show World; |
+ |
+import 'call_structure.dart' show CallStructure; |
class SelectorKind { |
final String name; |
@@ -38,8 +35,13 @@ class SelectorKind { |
String toString() => name; |
- static List<SelectorKind> values = |
- const <SelectorKind>[GETTER, SETTER, CALL, OPERATOR, INDEX]; |
+ static List<SelectorKind> values = const <SelectorKind>[ |
+ GETTER, |
+ SETTER, |
+ CALL, |
+ OPERATOR, |
+ INDEX |
+ ]; |
} |
class Selector { |
@@ -58,44 +60,43 @@ class Selector { |
LibraryElement get library => memberName.library; |
- Selector.internal(this.kind, |
- this.memberName, |
- this.callStructure, |
- this.hashCode) { |
- assert(invariant(NO_LOCATION_SPANNABLE, |
+ Selector.internal( |
+ this.kind, this.memberName, this.callStructure, this.hashCode) { |
+ assert(invariant( |
+ NO_LOCATION_SPANNABLE, |
kind == SelectorKind.INDEX || |
- (memberName != Names.INDEX_NAME && |
- memberName != Names.INDEX_SET_NAME), |
+ (memberName != Names.INDEX_NAME && |
+ memberName != Names.INDEX_SET_NAME), |
message: "kind=$kind,memberName=$memberName," |
- "callStructure:$callStructure")); |
- assert(invariant(NO_LOCATION_SPANNABLE, |
+ "callStructure:$callStructure")); |
+ assert(invariant( |
+ NO_LOCATION_SPANNABLE, |
kind == SelectorKind.OPERATOR || |
- kind == SelectorKind.INDEX || |
- !Elements.isOperatorName(memberName.text) || |
- memberName.text == '??', |
+ kind == SelectorKind.INDEX || |
+ !Elements.isOperatorName(memberName.text) || |
+ memberName.text == '??', |
message: "kind=$kind,memberName=$memberName," |
- "callStructure:$callStructure")); |
- assert(invariant(NO_LOCATION_SPANNABLE, |
+ "callStructure:$callStructure")); |
+ assert(invariant( |
+ NO_LOCATION_SPANNABLE, |
kind == SelectorKind.CALL || |
- kind == SelectorKind.GETTER || |
- kind == SelectorKind.SETTER || |
- Elements.isOperatorName(memberName.text) || |
- memberName.text == '??', |
+ kind == SelectorKind.GETTER || |
+ kind == SelectorKind.SETTER || |
+ Elements.isOperatorName(memberName.text) || |
+ memberName.text == '??', |
message: "kind=$kind,memberName=$memberName," |
- "callStructure:$callStructure")); |
+ "callStructure:$callStructure")); |
} |
// TODO(johnniwinther): Extract caching. |
static Map<int, List<Selector>> canonicalizedValues = |
new Map<int, List<Selector>>(); |
- factory Selector(SelectorKind kind, |
- Name name, |
- CallStructure callStructure) { |
+ factory Selector(SelectorKind kind, Name name, CallStructure callStructure) { |
// TODO(johnniwinther): Maybe use equality instead of implicit hashing. |
int hashCode = computeHashCode(kind, name, callStructure); |
- List<Selector> list = canonicalizedValues.putIfAbsent(hashCode, |
- () => <Selector>[]); |
+ List<Selector> list = |
+ canonicalizedValues.putIfAbsent(hashCode, () => <Selector>[]); |
for (int i = 0; i < list.length; i++) { |
Selector existing = list[i]; |
if (existing.match(kind, name, callStructure)) { |
@@ -103,8 +104,8 @@ class Selector { |
return existing; |
} |
} |
- Selector result = new Selector.internal( |
- kind, name, callStructure, hashCode); |
+ Selector result = |
+ new Selector.internal(kind, name, callStructure, hashCode); |
list.add(result); |
return result; |
} |
@@ -128,9 +129,7 @@ class Selector { |
if (element.isOperator) { |
// Operators cannot have named arguments, however, that doesn't prevent |
// a user from declaring such an operator. |
- return new Selector( |
- SelectorKind.OPERATOR, |
- name, |
+ return new Selector(SelectorKind.OPERATOR, name, |
new CallStructure(arity, namedArguments)); |
} else { |
return new Selector.call( |
@@ -150,15 +149,11 @@ class Selector { |
} |
} |
- factory Selector.getter(Name name) |
- => new Selector(SelectorKind.GETTER, |
- name.getter, |
- CallStructure.NO_ARGS); |
+ factory Selector.getter(Name name) => |
+ new Selector(SelectorKind.GETTER, name.getter, CallStructure.NO_ARGS); |
- factory Selector.setter(Name name) |
- => new Selector(SelectorKind.SETTER, |
- name.setter, |
- CallStructure.ONE_ARG); |
+ factory Selector.setter(Name name) => |
+ new Selector(SelectorKind.SETTER, name.setter, CallStructure.ONE_ARG); |
factory Selector.unaryOperator(String name) => new Selector( |
SelectorKind.OPERATOR, |
@@ -170,35 +165,29 @@ class Selector { |
new PublicName(Elements.constructOperatorName(name, false)), |
CallStructure.ONE_ARG); |
- factory Selector.index() |
- => new Selector(SelectorKind.INDEX, Names.INDEX_NAME, |
- CallStructure.ONE_ARG); |
+ factory Selector.index() => |
+ new Selector(SelectorKind.INDEX, Names.INDEX_NAME, CallStructure.ONE_ARG); |
- factory Selector.indexSet() |
- => new Selector(SelectorKind.INDEX, Names.INDEX_SET_NAME, |
- CallStructure.TWO_ARGS); |
+ factory Selector.indexSet() => new Selector( |
+ SelectorKind.INDEX, Names.INDEX_SET_NAME, CallStructure.TWO_ARGS); |
- factory Selector.call(Name name, CallStructure callStructure) |
- => new Selector(SelectorKind.CALL, name, callStructure); |
+ factory Selector.call(Name name, CallStructure callStructure) => |
+ new Selector(SelectorKind.CALL, name, callStructure); |
- factory Selector.callClosure(int arity, [List<String> namedArguments]) |
- => new Selector(SelectorKind.CALL, Names.call, |
- new CallStructure(arity, namedArguments)); |
+ factory Selector.callClosure(int arity, [List<String> namedArguments]) => |
+ new Selector(SelectorKind.CALL, Names.call, |
+ new CallStructure(arity, namedArguments)); |
- factory Selector.callClosureFrom(Selector selector) |
- => new Selector(SelectorKind.CALL, Names.call, selector.callStructure); |
+ factory Selector.callClosureFrom(Selector selector) => |
+ new Selector(SelectorKind.CALL, Names.call, selector.callStructure); |
factory Selector.callConstructor(Name name, |
- [int arity = 0, |
- List<String> namedArguments]) |
- => new Selector(SelectorKind.CALL, name, |
- new CallStructure(arity, namedArguments)); |
+ [int arity = 0, List<String> namedArguments]) => |
+ new Selector( |
+ SelectorKind.CALL, name, new CallStructure(arity, namedArguments)); |
- factory Selector.callDefaultConstructor() |
- => new Selector( |
- SelectorKind.CALL, |
- const PublicName(''), |
- CallStructure.NO_ARGS); |
+ factory Selector.callDefaultConstructor() => new Selector( |
+ SelectorKind.CALL, const PublicName(''), CallStructure.NO_ARGS); |
bool get isGetter => kind == SelectorKind.GETTER; |
bool get isSetter => kind == SelectorKind.SETTER; |
@@ -214,8 +203,7 @@ class Selector { |
/** |
* The member name for invocation mirrors created from this selector. |
*/ |
- String get invocationMirrorMemberName => |
- isSetter ? '$name=' : name; |
+ String get invocationMirrorMemberName => isSetter ? '$name=' : name; |
int get invocationMirrorKind { |
const int METHOD = 0; |
@@ -271,17 +259,14 @@ class Selector { |
return appliesUnnamed(element, world); |
} |
- bool match(SelectorKind kind, |
- Name memberName, |
- CallStructure callStructure) { |
- return this.kind == kind |
- && this.memberName == memberName |
- && this.callStructure.match(callStructure); |
+ bool match(SelectorKind kind, Name memberName, CallStructure callStructure) { |
+ return this.kind == kind && |
+ this.memberName == memberName && |
+ this.callStructure.match(callStructure); |
} |
- static int computeHashCode(SelectorKind kind, |
- Name name, |
- CallStructure callStructure) { |
+ static int computeHashCode( |
+ SelectorKind kind, Name name, CallStructure callStructure) { |
// Add bits from name and kind. |
int hash = Hashing.mixHashCodeBits(name.hashCode, kind.hashCode); |
// Add bits from the call structure. |