| 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 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
| 8 JsGetName, | 8 JsGetName, |
| 9 ALL_CLASSES, | 9 ALL_CLASSES, |
| 10 LAZIES, | 10 LAZIES, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import 'dart:mirrors'; | 21 import 'dart:mirrors'; |
| 22 | 22 |
| 23 import 'dart:_foreign_helper' show | 23 import 'dart:_foreign_helper' show |
| 24 JS, | 24 JS, |
| 25 JS_GET_FLAG, | 25 JS_GET_FLAG, |
| 26 JS_CURRENT_ISOLATE, | 26 JS_CURRENT_ISOLATE, |
| 27 JS_CURRENT_ISOLATE_CONTEXT, | 27 JS_CURRENT_ISOLATE_CONTEXT, |
| 28 JS_EMBEDDED_GLOBAL, | 28 JS_EMBEDDED_GLOBAL, |
| 29 JS_GET_NAME, | 29 JS_GET_NAME, |
| 30 JS_TYPEDEF_TAG, | 30 JS_TYPEDEF_TAG, |
| 31 JS_FUNCTION_TYPE_TAG, | |
| 32 JS_FUNCTION_TYPE_RETURN_TYPE_TAG, | 31 JS_FUNCTION_TYPE_RETURN_TYPE_TAG, |
| 33 JS_FUNCTION_TYPE_VOID_RETURN_TAG, | 32 JS_FUNCTION_TYPE_VOID_RETURN_TAG, |
| 34 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, | 33 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, |
| 35 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, | 34 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, |
| 36 JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG; | 35 JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG; |
| 37 | 36 |
| 38 | 37 |
| 39 import 'dart:_internal' as _symbol_dev; | 38 import 'dart:_internal' as _symbol_dev; |
| 40 | 39 |
| 41 import 'dart:_js_helper' show | 40 import 'dart:_js_helper' show |
| 42 BoundClosure, | 41 BoundClosure, |
| 43 CachedInvocation, | 42 CachedInvocation, |
| 44 Closure, | 43 Closure, |
| 45 JSInvocationMirror, | 44 JSInvocationMirror, |
| 46 JsCache, | 45 JsCache, |
| 47 Null, | 46 Null, |
| 48 Primitives, | 47 Primitives, |
| 49 ReflectionInfo, | 48 ReflectionInfo, |
| 50 RuntimeError, | 49 RuntimeError, |
| 51 TearOffClosure, | 50 TearOffClosure, |
| 52 TypeVariable, | 51 TypeVariable, |
| 53 UnimplementedNoSuchMethodError, | 52 UnimplementedNoSuchMethodError, |
| 54 createRuntimeType, | 53 createRuntimeType, |
| 55 createUnmangledInvocationMirror, | 54 createUnmangledInvocationMirror, |
| 56 getMangledTypeName, | 55 getMangledTypeName, |
| 57 getMetadata, | 56 getMetadata, |
| 58 getType, | 57 getType, |
| 59 getRuntimeType, | 58 getRuntimeType, |
| 59 isDartFunctionType, |
| 60 runtimeTypeToString, | 60 runtimeTypeToString, |
| 61 setRuntimeTypeInfo, | 61 setRuntimeTypeInfo, |
| 62 throwInvalidReflectionError, | 62 throwInvalidReflectionError, |
| 63 TypeImpl, | 63 TypeImpl, |
| 64 deferredLoadHook; | 64 deferredLoadHook; |
| 65 | 65 |
| 66 import 'dart:_interceptors' show | 66 import 'dart:_interceptors' show |
| 67 Interceptor, | 67 Interceptor, |
| 68 JSArray, | 68 JSArray, |
| 69 JSExtendableArray, | 69 JSExtendableArray, |
| (...skipping 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 return typeArgument._mangledName; | 2848 return typeArgument._mangledName; |
| 2849 } | 2849 } |
| 2850 representation = | 2850 representation = |
| 2851 runtimeTypeToString(type, onTypeVariable: substituteTypeVariable); | 2851 runtimeTypeToString(type, onTypeVariable: substituteTypeVariable); |
| 2852 } | 2852 } |
| 2853 if (representation != null) { | 2853 if (representation != null) { |
| 2854 return reflectClassByMangledName( | 2854 return reflectClassByMangledName( |
| 2855 getMangledTypeName(createRuntimeType(representation))); | 2855 getMangledTypeName(createRuntimeType(representation))); |
| 2856 } | 2856 } |
| 2857 String typedefPropertyName = JS_TYPEDEF_TAG(); | 2857 String typedefPropertyName = JS_TYPEDEF_TAG(); |
| 2858 String functionTagPropertyName = JS_FUNCTION_TYPE_TAG(); | |
| 2859 if (type != null && JS('', '#[#]', type, typedefPropertyName) != null) { | 2858 if (type != null && JS('', '#[#]', type, typedefPropertyName) != null) { |
| 2860 return typeMirrorFromRuntimeTypeRepresentation( | 2859 return typeMirrorFromRuntimeTypeRepresentation( |
| 2861 owner, JS('', '#[#]', type, typedefPropertyName)); | 2860 owner, JS('', '#[#]', type, typedefPropertyName)); |
| 2862 } else if (type != null && | 2861 } else if (type != null && isDartFunctionType(type)) { |
| 2863 JS('', '#[#]', type, functionTagPropertyName) != null) { | |
| 2864 return new JsFunctionTypeMirror(type, owner); | 2862 return new JsFunctionTypeMirror(type, owner); |
| 2865 } | 2863 } |
| 2866 return reflectClass(Function); | 2864 return reflectClass(Function); |
| 2867 } | 2865 } |
| 2868 | 2866 |
| 2869 Symbol computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { | 2867 Symbol computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { |
| 2870 if (owner == null) return simpleName; | 2868 if (owner == null) return simpleName; |
| 2871 String ownerName = n(owner.qualifiedName); | 2869 String ownerName = n(owner.qualifiedName); |
| 2872 return s('$ownerName.${n(simpleName)}'); | 2870 return s('$ownerName.${n(simpleName)}'); |
| 2873 } | 2871 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3038 // have a part (following a '.') that starts with '_'. | 3036 // have a part (following a '.') that starts with '_'. |
| 3039 const int UNDERSCORE = 0x5f; | 3037 const int UNDERSCORE = 0x5f; |
| 3040 if (name.isEmpty) return true; | 3038 if (name.isEmpty) return true; |
| 3041 int index = -1; | 3039 int index = -1; |
| 3042 do { | 3040 do { |
| 3043 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 3041 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
| 3044 index = name.indexOf('.', index + 1); | 3042 index = name.indexOf('.', index + 1); |
| 3045 } while (index >= 0 && index + 1 < name.length); | 3043 } while (index >= 0 && index + 1 < name.length); |
| 3046 return true; | 3044 return true; |
| 3047 } | 3045 } |
| OLD | NEW |