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 elements; | 5 library elements; |
| 6 | 6 |
| 7 | 7 |
| 8 import 'modelx.dart'; | 8 import 'modelx.dart'; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 Node selector = send.selector; | 346 Node selector = send.selector; |
| 347 // this(). | 347 // this(). |
| 348 if (selector.isThis()) return true; | 348 if (selector.isThis()) return true; |
| 349 // (o)() or foo()(). | 349 // (o)() or foo()(). |
| 350 if (element == null && selector.asIdentifier() == null) return true; | 350 if (element == null && selector.asIdentifier() == null) return true; |
| 351 if (element == null) return false; | 351 if (element == null) return false; |
| 352 // foo() with foo a local or a parameter. | 352 // foo() with foo a local or a parameter. |
| 353 return isLocal(element); | 353 return isLocal(element); |
| 354 } | 354 } |
| 355 | 355 |
| 356 static SourceString constructConstructorName(SourceString receiver, | 356 static SourceString reconstructConstructorNameSourceString(Element element) { |
|
ahe
2013/07/11 10:09:42
Can we get rid of these methods?
Johnni Winther
2013/07/11 13:09:19
That requires changes to reflection. Added a TODO.
| |
| 357 SourceString selector) { | 357 if (element.name == const SourceString('')) { |
| 358 String r = receiver.slowToString(); | 358 return element.getEnclosingClass().name; |
| 359 String s = selector.slowToString(); | 359 } else { |
| 360 return new SourceString('$r\$$s'); | 360 return new SourceString(reconstructConstructorName(element)); |
| 361 } | |
| 361 } | 362 } |
| 362 | 363 |
| 363 static SourceString deconstructConstructorName(SourceString name, | 364 static String reconstructConstructorName(Element element) { |
| 364 ClassElement holder) { | 365 String className = element.getEnclosingClass().name.slowToString(); |
| 365 String r = '${holder.name.slowToString()}\$'; | 366 if (element.name == const SourceString('')) { |
| 366 String s = name.slowToString(); | 367 return className; |
| 367 if (s.startsWith(r)) { | 368 } else { |
| 368 return new SourceString(s.substring(r.length)); | 369 return '$className\$${element.name.slowToString()}'; |
| 369 } | 370 } |
| 370 return null; | |
| 371 } | 371 } |
| 372 | 372 |
| 373 /** | 373 /** |
| 374 * Map an operator-name to a valid Dart identifier. | 374 * Map an operator-name to a valid Dart identifier. |
| 375 * | 375 * |
| 376 * For non-operator names, this metod just returns its input. | 376 * For non-operator names, this metod just returns its input. |
| 377 * | 377 * |
| 378 * The results returned from this method are guaranteed to be valid | 378 * The results returned from this method are guaranteed to be valid |
| 379 * JavaScript identifers, except it may include reserved words for | 379 * JavaScript identifers, except it may include reserved words for |
| 380 * non-operator names. | 380 * non-operator names. |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 int get resolutionState; | 934 int get resolutionState; |
| 935 Token get beginToken; | 935 Token get beginToken; |
| 936 Token get endToken; | 936 Token get endToken; |
| 937 | 937 |
| 938 // TODO(kasperl): Try to get rid of these. | 938 // TODO(kasperl): Try to get rid of these. |
| 939 void set annotatedElement(Element value); | 939 void set annotatedElement(Element value); |
| 940 void set resolutionState(int value); | 940 void set resolutionState(int value); |
| 941 | 941 |
| 942 MetadataAnnotation ensureResolved(Compiler compiler); | 942 MetadataAnnotation ensureResolved(Compiler compiler); |
| 943 } | 943 } |
| OLD | NEW |