Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('universe'); | 5 #library('universe'); |
| 6 | 6 |
| 7 #import('../closure.dart'); | 7 #import('../closure.dart'); |
| 8 #import('../elements/elements.dart'); | 8 #import('../elements/elements.dart'); |
| 9 #import('../leg.dart'); | 9 #import('../leg.dart'); |
| 10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 static const SelectorKind OPERATOR = const SelectorKind('operator'); | 116 static const SelectorKind OPERATOR = const SelectorKind('operator'); |
| 117 static const SelectorKind INDEX = const SelectorKind('index'); | 117 static const SelectorKind INDEX = const SelectorKind('index'); |
| 118 | 118 |
| 119 toString() => name; | 119 toString() => name; |
| 120 } | 120 } |
| 121 | 121 |
| 122 class Selector { | 122 class Selector { |
| 123 final SelectorKind kind; | 123 final SelectorKind kind; |
| 124 final SourceString name; | 124 final SourceString name; |
| 125 final LibraryElement library; // Library is null for non-private selectors. | 125 final LibraryElement library; // Library is null for non-private selectors. |
| 126 final SourceString normalizedConstructorName; | |
|
kasperl
2012/10/08 08:06:41
It would indeed be great to get rid of this and us
aam-me
2012/10/09 04:08:42
Done.
| |
| 126 | 127 |
| 127 // The numbers of arguments of the selector. Includes named arguments. | 128 // The numbers of arguments of the selector. Includes named arguments. |
| 128 final int argumentCount; | 129 final int argumentCount; |
| 129 final List<SourceString> namedArguments; | 130 final List<SourceString> namedArguments; |
| 130 final List<SourceString> orderedNamedArguments; | 131 final List<SourceString> orderedNamedArguments; |
| 131 | 132 |
| 132 Selector( | 133 Selector( |
| 133 this.kind, | 134 this.kind, |
| 134 SourceString name, | 135 SourceString name, |
| 135 LibraryElement library, | 136 LibraryElement library, |
| 136 this.argumentCount, | 137 this.argumentCount, |
| 137 [List<SourceString> namedArguments = const <SourceString>[]]) | 138 [List<SourceString> namedArguments = const <SourceString>[], |
| 139 SourceString normalizedConstructorName = null]) | |
| 138 : this.name = name, | 140 : this.name = name, |
| 139 this.library = name.isPrivate() ? library : null, | 141 this.library = name.isPrivate() ? library : null, |
| 140 this.namedArguments = namedArguments, | 142 this.namedArguments = namedArguments, |
| 141 this.orderedNamedArguments = namedArguments.isEmpty() | 143 this.orderedNamedArguments = namedArguments.isEmpty() |
| 142 ? namedArguments | 144 ? namedArguments |
| 143 : <SourceString>[] { | 145 : <SourceString>[], |
| 146 this.normalizedConstructorName = normalizedConstructorName { | |
| 144 assert(!name.isPrivate() || library != null); | 147 assert(!name.isPrivate() || library != null); |
| 145 } | 148 } |
| 146 | 149 |
| 147 Selector.getter(SourceString name, LibraryElement library) | 150 Selector.getter(SourceString name, LibraryElement library) |
| 148 : this(SelectorKind.GETTER, name, library, 0); | 151 : this(SelectorKind.GETTER, name, library, 0); |
| 149 | 152 |
| 150 Selector.getterFrom(Selector selector) | 153 Selector.getterFrom(Selector selector) |
| 151 : this(SelectorKind.GETTER, selector.name, selector.library, 0); | 154 : this(SelectorKind.GETTER, selector.name, selector.library, 0); |
| 152 | 155 |
| 153 Selector.setter(SourceString name, LibraryElement library) | 156 Selector.setter(SourceString name, LibraryElement library) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 180 : this(SelectorKind.CALL, name, library, arity, named); | 183 : this(SelectorKind.CALL, name, library, arity, named); |
| 181 | 184 |
| 182 Selector.callClosure(int arity, [List<SourceString> named = const []]) | 185 Selector.callClosure(int arity, [List<SourceString> named = const []]) |
| 183 : this(SelectorKind.CALL, Compiler.CALL_OPERATOR_NAME, null, | 186 : this(SelectorKind.CALL, Compiler.CALL_OPERATOR_NAME, null, |
| 184 arity, named); | 187 arity, named); |
| 185 | 188 |
| 186 Selector.callClosureFrom(Selector selector) | 189 Selector.callClosureFrom(Selector selector) |
| 187 : this(SelectorKind.CALL, Compiler.CALL_OPERATOR_NAME, null, | 190 : this(SelectorKind.CALL, Compiler.CALL_OPERATOR_NAME, null, |
| 188 selector.argumentCount, selector.namedArguments); | 191 selector.argumentCount, selector.namedArguments); |
| 189 | 192 |
| 193 Selector.callConstructor(SourceString className, | |
| 194 SourceString constructorName, | |
| 195 LibraryElement library) | |
| 196 : this(SelectorKind.CALL, | |
| 197 constructorName, | |
| 198 library, | |
| 199 0, | |
| 200 const [], | |
| 201 Elements.constructConstructorName(className, constructorName)); | |
| 202 | |
| 203 Selector.callDefaultConstructor(SourceString name, | |
| 204 LibraryElement library) | |
| 205 : this(SelectorKind.CALL, name, library, 0, const [], name); | |
| 206 | |
| 190 // TODO(kasperl): This belongs somewhere else. | 207 // TODO(kasperl): This belongs somewhere else. |
| 191 Selector.noSuchMethod() | 208 Selector.noSuchMethod() |
| 192 : this(SelectorKind.CALL, Compiler.NO_SUCH_METHOD, null, 2); | 209 : this(SelectorKind.CALL, Compiler.NO_SUCH_METHOD, null, 2); |
| 193 | 210 |
| 194 bool isGetter() => kind === SelectorKind.GETTER; | 211 bool isGetter() => kind === SelectorKind.GETTER; |
| 195 bool isSetter() => kind === SelectorKind.SETTER; | 212 bool isSetter() => kind === SelectorKind.SETTER; |
| 196 bool isCall() => kind === SelectorKind.CALL; | 213 bool isCall() => kind === SelectorKind.CALL; |
| 197 | 214 |
| 198 bool isIndex() => kind === SelectorKind.INDEX && argumentCount == 1; | 215 bool isIndex() => kind === SelectorKind.INDEX && argumentCount == 1; |
| 199 bool isIndexSet() => kind === SelectorKind.INDEX && argumentCount == 2; | 216 bool isIndexSet() => kind === SelectorKind.INDEX && argumentCount == 2; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 | 542 |
| 526 if (!self.isInterface() && self.isSubclassOf(other)) { | 543 if (!self.isInterface() && self.isSubclassOf(other)) { |
| 527 // Resolve an invocation of [element.name] on [self]. If it | 544 // Resolve an invocation of [element.name] on [self]. If it |
| 528 // is found, this selector is a candidate. | 545 // is found, this selector is a candidate. |
| 529 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 546 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 530 } | 547 } |
| 531 | 548 |
| 532 return false; | 549 return false; |
| 533 } | 550 } |
| 534 } | 551 } |
| OLD | NEW |