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 class Universe { | 5 class Universe { |
| 6 Map<Element, CodeBuffer> generatedCode; | 6 Map<Element, CodeBuffer> generatedCode; |
| 7 Map<Element, CodeBuffer> generatedBailoutCode; | 7 Map<Element, CodeBuffer> generatedBailoutCode; |
| 8 final Set<ClassElement> instantiatedClasses; | 8 final Set<ClassElement> instantiatedClasses; |
| 9 final Set<SourceString> instantiatedClassInstanceFields; | 9 final Set<SourceString> instantiatedClassInstanceFields; |
| 10 final Set<FunctionElement> staticFunctionsNeedingGetter; | 10 final Set<FunctionElement> staticFunctionsNeedingGetter; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 if (namedArguments.isEmpty()) return namedArguments; | 315 if (namedArguments.isEmpty()) return namedArguments; |
| 316 if (!orderedNamedArguments.isEmpty()) return orderedNamedArguments; | 316 if (!orderedNamedArguments.isEmpty()) return orderedNamedArguments; |
| 317 | 317 |
| 318 orderedNamedArguments.addAll(namedArguments); | 318 orderedNamedArguments.addAll(namedArguments); |
| 319 orderedNamedArguments.sort((SourceString first, SourceString second) { | 319 orderedNamedArguments.sort((SourceString first, SourceString second) { |
| 320 return first.slowToString().compareTo(second.slowToString()); | 320 return first.slowToString().compareTo(second.slowToString()); |
| 321 }); | 321 }); |
| 322 return orderedNamedArguments; | 322 return orderedNamedArguments; |
| 323 } | 323 } |
| 324 | 324 |
| 325 toString() => 'Selector($kind, $name, $argumentCount)'; | 325 String namedArgumentsToString() { |
| 326 StringBuffer result = new StringBuffer(); | |
|
kasperl
2012/09/05 07:06:29
Don't do the allocation of this if namedArgumentCo
Søren Gjesse
2012/09/05 08:02:59
Done.
| |
| 327 if (namedArgumentCount > 0) { | |
| 328 result.add('['); | |
|
kasperl
2012/09/05 07:06:29
How about not adding [ and ] and just returning "[
Søren Gjesse
2012/09/05 08:02:59
Done.
| |
| 329 for (int i = 0; i < namedArgumentCount; i++) { | |
| 330 if (i != 0) result.add(', '); | |
| 331 result.add(namedArguments[i].slowToString()); | |
| 332 } | |
| 333 result.add(']'); | |
| 334 return result.toString(); | |
| 335 } | |
| 336 return ''; | |
| 337 } | |
| 338 | |
| 339 String toString() { | |
| 340 String named = ''; | |
| 341 if (namedArgumentCount > 0) named = ', named=${namedArgumentsToString()}'; | |
| 342 return 'Selector($kind, ${name.slowToString()}, ' | |
| 343 'arity=$argumentCount$named)'; | |
| 344 } | |
| 326 } | 345 } |
| 327 | 346 |
| 328 class TypedSelector extends Selector { | 347 class TypedSelector extends Selector { |
| 329 /** | 348 /** |
| 330 * The type of the receiver. Any subtype of that type can be the | 349 * The type of the receiver. Any subtype of that type can be the |
| 331 * target of the invocation. | 350 * target of the invocation. |
| 332 */ | 351 */ |
| 333 final DartType receiverType; | 352 final DartType receiverType; |
| 334 | 353 |
| 335 TypedSelector(this.receiverType, Selector selector) | 354 TypedSelector(this.receiverType, Selector selector) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 | 400 |
| 382 if (!self.isInterface() && self.isSubclassOf(other)) { | 401 if (!self.isInterface() && self.isSubclassOf(other)) { |
| 383 // Resolve an invocation of [element.name] on [self]. If it | 402 // Resolve an invocation of [element.name] on [self]. If it |
| 384 // is found, this selector is a candidate. | 403 // is found, this selector is a candidate. |
| 385 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 404 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 386 } | 405 } |
| 387 | 406 |
| 388 return false; | 407 return false; |
| 389 } | 408 } |
| 390 | 409 |
| 391 toString() { | 410 String toString() { |
|
kasperl
2012/09/05 07:06:29
How about getting rid of this and just use the one
Søren Gjesse
2012/09/05 08:02:59
Good point, done.
| |
| 392 return 'Selector($kind, "${name.slowToString()}", ' | 411 String named = ''; |
| 393 '$argumentCount, type=$receiverType)'; | 412 if (namedArgumentCount > 0) named = ', named=${namedArgumentsToString()}'; |
| 413 return 'Selector($kind, ${name.slowToString()}, ' | |
| 414 'arity=$argumentCount$named, type=$receiverType)'; | |
| 394 } | 415 } |
| 395 } | 416 } |
| OLD | NEW |