Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: dart/sdk/lib/_internal/compiler/js_lib/js_mirrors.dart

Issue 938413002: Work around Safari for-in bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: More issues discovered during testing. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 String cacheName = Primitives.mirrorFunctionCacheName; 2229 String cacheName = Primitives.mirrorFunctionCacheName;
2230 JsMethodMirror cachedFunction; 2230 JsMethodMirror cachedFunction;
2231 // TODO(ahe): Restore caching. 2231 // TODO(ahe): Restore caching.
2232 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName); 2232 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName);
2233 if (cachedFunction != null) return cachedFunction; 2233 if (cachedFunction != null) return cachedFunction;
2234 disableTreeShaking(); 2234 disableTreeShaking();
2235 // TODO(ahe): What about optional parameters (named or not). 2235 // TODO(ahe): What about optional parameters (named or not).
2236 String callPrefix = "${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$"; 2236 String callPrefix = "${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$";
2237 var extractCallName = JS('', r''' 2237 var extractCallName = JS('', r'''
2238 function(reflectee) { 2238 function(reflectee) {
2239 for (var property in reflectee) { 2239 var properties = Object.keys(reflectee.constructor.prototype);
floitsch 2015/02/23 14:14:26 Are you sure this is equivalent? Does the JsClosu
ahe 2015/02/23 15:04:45 It doesn't. It only gets invoked for actual closur
2240 for (var i = 0; i < properties.length; i++) {
2241 var property = properties[i];
2240 if (# == property.substring(0, #) && 2242 if (# == property.substring(0, #) &&
2241 property[#] >= '0' && 2243 property[#] >= '0' &&
2242 property[#] <= '9') return property; 2244 property[#] <= '9') return property;
2243 } 2245 }
2244 return null; 2246 return null;
2245 } 2247 }
2246 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length); 2248 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length);
2247 String callName = JS('String|Null', '#(#)', extractCallName, reflectee); 2249 String callName = JS('String|Null', '#(#)', extractCallName, reflectee);
2248 if (callName == null) { 2250 if (callName == null) {
2249 throw new RuntimeError('Cannot find callName on "$reflectee"'); 2251 throw new RuntimeError('Cannot find callName on "$reflectee"');
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 // have a part (following a '.') that starts with '_'. 3029 // have a part (following a '.') that starts with '_'.
3028 const int UNDERSCORE = 0x5f; 3030 const int UNDERSCORE = 0x5f;
3029 if (name.isEmpty) return true; 3031 if (name.isEmpty) return true;
3030 int index = -1; 3032 int index = -1;
3031 do { 3033 do {
3032 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; 3034 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false;
3033 index = name.indexOf('.', index + 1); 3035 index = name.indexOf('.', index + 1);
3034 } while (index >= 0 && index + 1 < name.length); 3036 } while (index >= 0 && index + 1 < name.length);
3035 return true; 3037 return true;
3036 } 3038 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698