| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_mirrors; | 5 library dart._js_mirrors; |
| 6 | 6 |
| 7 import 'shared/runtime_data.dart' as encoding; | 7 import 'shared/runtime_data.dart' as encoding; |
| 8 import 'shared/embedded_names.dart' show | 8 import 'shared/embedded_names.dart' show |
| 9 ALL_CLASSES, | 9 ALL_CLASSES, |
| 10 LAZIES, | 10 LAZIES, |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 var classMirrors; | 585 var classMirrors; |
| 586 | 586 |
| 587 TypeMirror reflectClassByName(Symbol symbol, String mangledName) { | 587 TypeMirror reflectClassByName(Symbol symbol, String mangledName) { |
| 588 if (classMirrors == null) classMirrors = JsCache.allocate(); | 588 if (classMirrors == null) classMirrors = JsCache.allocate(); |
| 589 var mirror = JsCache.fetch(classMirrors, mangledName); | 589 var mirror = JsCache.fetch(classMirrors, mangledName); |
| 590 if (mirror != null) return mirror; | 590 if (mirror != null) return mirror; |
| 591 disableTreeShaking(); | 591 disableTreeShaking(); |
| 592 int typeArgIndex = mangledName.indexOf("<"); | 592 int typeArgIndex = mangledName.indexOf("<"); |
| 593 if (typeArgIndex != -1) { | 593 if (typeArgIndex != -1) { |
| 594 mirror = new JsTypeBoundClassMirror(reflectClassByMangledName( | 594 TypeMirror originalDeclaration = |
| 595 mangledName.substring(0, typeArgIndex)).originalDeclaration, | 595 reflectClassByMangledName(mangledName.substring(0, typeArgIndex)) |
| 596 .originalDeclaration; |
| 597 if (originalDeclaration is JsTypedefMirror) { |
| 598 throw new UnimplementedError(); |
| 599 } |
| 600 mirror = new JsTypeBoundClassMirror(originalDeclaration, |
| 596 // Remove the angle brackets enclosing the type arguments. | 601 // Remove the angle brackets enclosing the type arguments. |
| 597 mangledName.substring(typeArgIndex + 1, mangledName.length - 1)); | 602 mangledName.substring(typeArgIndex + 1, mangledName.length - 1)); |
| 598 JsCache.update(classMirrors, mangledName, mirror); | 603 JsCache.update(classMirrors, mangledName, mirror); |
| 599 return mirror; | 604 return mirror; |
| 600 } | 605 } |
| 601 var allClasses = JS_EMBEDDED_GLOBAL('', ALL_CLASSES); | 606 var allClasses = JS_EMBEDDED_GLOBAL('', ALL_CLASSES); |
| 602 var constructor = JS('var', '#[#]', allClasses, mangledName); | 607 var constructor = JS('var', '#[#]', allClasses, mangledName); |
| 603 if (constructor == null) { | 608 if (constructor == null) { |
| 604 // Probably an intercepted class. | 609 // Probably an intercepted class. |
| 605 // TODO(ahe): How to handle intercepted classes? | 610 // TODO(ahe): How to handle intercepted classes? |
| (...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2953 // have a part (following a '.') that starts with '_'. | 2958 // have a part (following a '.') that starts with '_'. |
| 2954 const int UNDERSCORE = 0x5f; | 2959 const int UNDERSCORE = 0x5f; |
| 2955 if (name.isEmpty) return true; | 2960 if (name.isEmpty) return true; |
| 2956 int index = -1; | 2961 int index = -1; |
| 2957 do { | 2962 do { |
| 2958 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 2963 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
| 2959 index = name.indexOf('.', index + 1); | 2964 index = name.indexOf('.', index + 1); |
| 2960 } while (index >= 0 && index + 1 < name.length); | 2965 } while (index >= 0 && index + 1 < name.length); |
| 2961 return true; | 2966 return true; |
| 2962 } | 2967 } |
| OLD | NEW |