| 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, |
| 11 LIBRARIES, | 11 LIBRARIES, |
| 12 STATICS, | 12 STATICS, |
| 13 TYPE_INFORMATION, | 13 TYPE_INFORMATION, |
| 14 TYPEDEF_PREDICATE_PROPERTY_NAME, | 14 TYPEDEF_PREDICATE_PROPERTY_NAME, |
| 15 TYPEDEF_TYPE_PROPERTY_NAME; | 15 TYPEDEF_TYPE_PROPERTY_NAME; |
| 16 | 16 |
| 17 import 'dart:collection' show | 17 import 'dart:collection' show |
| 18 UnmodifiableListView, | 18 UnmodifiableListView, |
| 19 UnmodifiableMapView; | 19 UnmodifiableMapView; |
| 20 | 20 |
| 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_CURRENT_ISOLATE, | 26 JS_CURRENT_ISOLATE, |
| 26 JS_CURRENT_ISOLATE_CONTEXT, | 27 JS_CURRENT_ISOLATE_CONTEXT, |
| 27 JS_EMBEDDED_GLOBAL, | 28 JS_EMBEDDED_GLOBAL, |
| 28 JS_GET_NAME, | 29 JS_GET_NAME, |
| 29 JS_TYPEDEF_TAG, | 30 JS_TYPEDEF_TAG, |
| 30 JS_FUNCTION_TYPE_TAG, | 31 JS_FUNCTION_TYPE_TAG, |
| 31 JS_FUNCTION_TYPE_RETURN_TYPE_TAG, | 32 JS_FUNCTION_TYPE_RETURN_TYPE_TAG, |
| 32 JS_FUNCTION_TYPE_VOID_RETURN_TAG, | 33 JS_FUNCTION_TYPE_VOID_RETURN_TAG, |
| 33 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, | 34 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, |
| 34 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, | 35 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 } | 1084 } |
| 1084 | 1085 |
| 1085 // JS helpers for getField optimizations. | 1086 // JS helpers for getField optimizations. |
| 1086 static bool isUndefined(x) | 1087 static bool isUndefined(x) |
| 1087 => JS('bool', 'typeof # == "undefined"', x); | 1088 => JS('bool', 'typeof # == "undefined"', x); |
| 1088 static bool isMissingCache(x) | 1089 static bool isMissingCache(x) |
| 1089 => JS('bool', 'typeof # == "number"', x); | 1090 => JS('bool', 'typeof # == "number"', x); |
| 1090 static bool isMissingProbe(Symbol symbol) | 1091 static bool isMissingProbe(Symbol symbol) |
| 1091 => JS('bool', 'typeof #.\$p == "undefined"', symbol); | 1092 => JS('bool', 'typeof #.\$p == "undefined"', symbol); |
| 1092 static bool isEvalAllowed() | 1093 static bool isEvalAllowed() |
| 1093 => JS('bool', 'typeof dart_precompiled != "function"'); | 1094 => !JS_GET_FLAG("USE_CONTENT_SECURITY_POLICY"); |
| 1094 | 1095 |
| 1095 | 1096 |
| 1096 /// The getter cache is lazily allocated after a couple | 1097 /// The getter cache is lazily allocated after a couple |
| 1097 /// of invocations of [InstanceMirror.getField]. The delay is | 1098 /// of invocations of [InstanceMirror.getField]. The delay is |
| 1098 /// used to avoid too aggressive caching and dynamic function | 1099 /// used to avoid too aggressive caching and dynamic function |
| 1099 /// generation for rarely used mirrors. The cache is specific to | 1100 /// generation for rarely used mirrors. The cache is specific to |
| 1100 /// this [InstanceMirror] and maps reflective names to functions | 1101 /// this [InstanceMirror] and maps reflective names to functions |
| 1101 /// that will invoke the corresponding getter on the reflectee. | 1102 /// that will invoke the corresponding getter on the reflectee. |
| 1102 /// The reflectee is passed to the function as the first argument | 1103 /// The reflectee is passed to the function as the first argument |
| 1103 /// to avoid the overhead of fetching it from this mirror repeatedly. | 1104 /// to avoid the overhead of fetching it from this mirror repeatedly. |
| (...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3037 // have a part (following a '.') that starts with '_'. | 3038 // have a part (following a '.') that starts with '_'. |
| 3038 const int UNDERSCORE = 0x5f; | 3039 const int UNDERSCORE = 0x5f; |
| 3039 if (name.isEmpty) return true; | 3040 if (name.isEmpty) return true; |
| 3040 int index = -1; | 3041 int index = -1; |
| 3041 do { | 3042 do { |
| 3042 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 3043 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
| 3043 index = name.indexOf('.', index + 1); | 3044 index = name.indexOf('.', index + 1); |
| 3044 } while (index >= 0 && index + 1 < name.length); | 3045 } while (index >= 0 && index + 1 < name.length); |
| 3045 return true; | 3046 return true; |
| 3046 } | 3047 } |
| OLD | NEW |