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

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

Issue 944423002: Revert "Use an enum in embedded_names as input to JS_GET_NAME." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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,
9 ALL_CLASSES, 8 ALL_CLASSES,
10 LAZIES, 9 LAZIES,
11 LIBRARIES, 10 LIBRARIES,
12 STATICS, 11 STATICS,
13 TYPE_INFORMATION, 12 TYPE_INFORMATION,
14 TYPEDEF_PREDICATE_PROPERTY_NAME, 13 TYPEDEF_PREDICATE_PROPERTY_NAME,
15 TYPEDEF_TYPE_PROPERTY_NAME; 14 TYPEDEF_TYPE_PROPERTY_NAME;
16 15
17 import 'dart:collection' show 16 import 'dart:collection' show
18 UnmodifiableListView, 17 UnmodifiableListView,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Interceptor, 64 Interceptor,
66 JSArray, 65 JSArray,
67 JSExtendableArray, 66 JSExtendableArray,
68 getInterceptor; 67 getInterceptor;
69 68
70 import 'dart:_js_names'; 69 import 'dart:_js_names';
71 70
72 const String METHODS_WITH_OPTIONAL_ARGUMENTS = r'$methodsWithOptionalArguments'; 71 const String METHODS_WITH_OPTIONAL_ARGUMENTS = r'$methodsWithOptionalArguments';
73 72
74 bool hasReflectableProperty(var jsFunction) { 73 bool hasReflectableProperty(var jsFunction) {
75 return JS('bool', '# in #', JS_GET_NAME(JsGetName.REFLECTABLE), jsFunction); 74 return JS('bool', '# in #', JS_GET_NAME("REFLECTABLE"), jsFunction);
76 } 75 }
77 76
78 /// No-op method that is called to inform the compiler that tree-shaking needs 77 /// No-op method that is called to inform the compiler that tree-shaking needs
79 /// to be disabled. 78 /// to be disabled.
80 disableTreeShaking() => preserveNames(); 79 disableTreeShaking() => preserveNames();
81 80
82 /// No-op method that is called to inform the compiler that metadata must be 81 /// No-op method that is called to inform the compiler that metadata must be
83 /// preserved at runtime. 82 /// preserved at runtime.
84 preserveMetadata() {} 83 preserveMetadata() {}
85 84
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // MyTypedef: { 643 // MyTypedef: {
645 // "^": "Object;", 644 // "^": "Object;",
646 // $typedefType: 58, 645 // $typedefType: 58,
647 // $$isTypedef: true 646 // $$isTypedef: true
648 // } 647 // }
649 // The typedefType is the index into the metadata table. 648 // The typedefType is the index into the metadata table.
650 int index = JS('int', '#[#]', descriptor, TYPEDEF_TYPE_PROPERTY_NAME); 649 int index = JS('int', '#[#]', descriptor, TYPEDEF_TYPE_PROPERTY_NAME);
651 mirror = new JsTypedefMirror(symbol, mangledName, getMetadata(index)); 650 mirror = new JsTypedefMirror(symbol, mangledName, getMetadata(index));
652 } else { 651 } else {
653 fields = JS('', '#[#]', descriptor, 652 fields = JS('', '#[#]', descriptor,
654 JS_GET_NAME(JsGetName.CLASS_DESCRIPTOR_PROPERTY)); 653 JS_GET_NAME('CLASS_DESCRIPTOR_PROPERTY'));
655 if (fields is List) { 654 if (fields is List) {
656 fieldsMetadata = fields.getRange(1, fields.length).toList(); 655 fieldsMetadata = fields.getRange(1, fields.length).toList();
657 fields = fields[0]; 656 fields = fields[0];
658 } 657 }
659 if (fields is! String) { 658 if (fields is! String) {
660 // TODO(ahe): This is CSP mode. Find a way to determine the 659 // TODO(ahe): This is CSP mode. Find a way to determine the
661 // fields of this class. 660 // fields of this class.
662 fields = ''; 661 fields = '';
663 } 662 }
664 } 663 }
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 } 1739 }
1741 parseCompactFieldSpecification( 1740 parseCompactFieldSpecification(
1742 fieldOwner, instanceFieldSpecfication, false, result); 1741 fieldOwner, instanceFieldSpecfication, false, result);
1743 1742
1744 var statics = JS_EMBEDDED_GLOBAL('', STATICS); 1743 var statics = JS_EMBEDDED_GLOBAL('', STATICS);
1745 var staticDescriptor = JS('', '#[#]', statics, _mangledName); 1744 var staticDescriptor = JS('', '#[#]', statics, _mangledName);
1746 if (staticDescriptor != null) { 1745 if (staticDescriptor != null) {
1747 parseCompactFieldSpecification( 1746 parseCompactFieldSpecification(
1748 fieldOwner, 1747 fieldOwner,
1749 JS('', '#[#]', 1748 JS('', '#[#]',
1750 staticDescriptor, 1749 staticDescriptor, JS_GET_NAME('CLASS_DESCRIPTOR_PROPERTY')),
1751 JS_GET_NAME(JsGetName.CLASS_DESCRIPTOR_PROPERTY)),
1752 true, result); 1750 true, result);
1753 } 1751 }
1754 return result; 1752 return result;
1755 } 1753 }
1756 1754
1757 List<VariableMirror> get _fields { 1755 List<VariableMirror> get _fields {
1758 if (_cachedFields != null) return _cachedFields; 1756 if (_cachedFields != null) return _cachedFields;
1759 return _cachedFields = _getFieldsWithOwner(this); 1757 return _cachedFields = _getFieldsWithOwner(this);
1760 } 1758 }
1761 1759
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 String accessorName = jsName = field.substring(0, length); 2145 String accessorName = jsName = field.substring(0, length);
2148 int divider = field.indexOf(':'); 2146 int divider = field.indexOf(':');
2149 if (divider > 0) { 2147 if (divider > 0) {
2150 accessorName = accessorName.substring(0, divider); 2148 accessorName = accessorName.substring(0, divider);
2151 jsName = field.substring(divider + 1); 2149 jsName = field.substring(divider + 1);
2152 } 2150 }
2153 var unmangledName; 2151 var unmangledName;
2154 if (isStatic) { 2152 if (isStatic) {
2155 unmangledName = mangledGlobalNames[accessorName]; 2153 unmangledName = mangledGlobalNames[accessorName];
2156 } else { 2154 } else {
2157 String getterPrefix = JS_GET_NAME(JsGetName.GETTER_PREFIX); 2155 String getterPrefix = JS_GET_NAME('GETTER_PREFIX');
2158 unmangledName = mangledNames['$getterPrefix$accessorName']; 2156 unmangledName = mangledNames['$getterPrefix$accessorName'];
2159 } 2157 }
2160 if (unmangledName == null) unmangledName = accessorName; 2158 if (unmangledName == null) unmangledName = accessorName;
2161 if (!hasSetter) { 2159 if (!hasSetter) {
2162 // TODO(ahe): This is a hack to handle checked setters in checked mode. 2160 // TODO(ahe): This is a hack to handle checked setters in checked mode.
2163 var setterName = s('$unmangledName='); 2161 var setterName = s('$unmangledName=');
2164 for (JsMethodMirror method in owner._methods) { 2162 for (JsMethodMirror method in owner._methods) {
2165 if (method.simpleName == setterName) { 2163 if (method.simpleName == setterName) {
2166 isFinal = false; 2164 isFinal = false;
2167 break; 2165 break;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 : super(reflectee); 2224 : super(reflectee);
2227 2225
2228 MethodMirror get function { 2226 MethodMirror get function {
2229 String cacheName = Primitives.mirrorFunctionCacheName; 2227 String cacheName = Primitives.mirrorFunctionCacheName;
2230 JsMethodMirror cachedFunction; 2228 JsMethodMirror cachedFunction;
2231 // TODO(ahe): Restore caching. 2229 // TODO(ahe): Restore caching.
2232 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName); 2230 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName);
2233 if (cachedFunction != null) return cachedFunction; 2231 if (cachedFunction != null) return cachedFunction;
2234 disableTreeShaking(); 2232 disableTreeShaking();
2235 // TODO(ahe): What about optional parameters (named or not). 2233 // TODO(ahe): What about optional parameters (named or not).
2236 String callPrefix = "${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$"; 2234 String callPrefix = "${JS_GET_NAME("CALL_PREFIX")}\$";
2237 var extractCallName = JS('', r''' 2235 var extractCallName = JS('', r'''
2238 function(reflectee) { 2236 function(reflectee) {
2239 for (var property in reflectee) { 2237 for (var property in reflectee) {
2240 if (# == property.substring(0, #) && 2238 if (# == property.substring(0, #) &&
2241 property[#] >= '0' && 2239 property[#] >= '0' &&
2242 property[#] <= '9') return property; 2240 property[#] <= '9') return property;
2243 } 2241 }
2244 return null; 2242 return null;
2245 } 2243 }
2246 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length); 2244 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length);
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 case '~': 2936 case '~':
2939 return true; 2937 return true;
2940 default: 2938 default:
2941 return false; 2939 return false;
2942 } 2940 }
2943 } 2941 }
2944 2942
2945 /// Returns true if the key represent ancillary reflection data, that is, not a 2943 /// Returns true if the key represent ancillary reflection data, that is, not a
2946 /// method. 2944 /// method.
2947 bool isReflectiveDataInPrototype(String key) { 2945 bool isReflectiveDataInPrototype(String key) {
2948 if (key == JS_GET_NAME(JsGetName.CLASS_DESCRIPTOR_PROPERTY) || 2946 if (key == JS_GET_NAME('CLASS_DESCRIPTOR_PROPERTY') ||
2949 key == METHODS_WITH_OPTIONAL_ARGUMENTS) { 2947 key == METHODS_WITH_OPTIONAL_ARGUMENTS) {
2950 return true; 2948 return true;
2951 } 2949 }
2952 String firstChar = key[0]; 2950 String firstChar = key[0];
2953 return firstChar == '*' || firstChar == '+'; 2951 return firstChar == '*' || firstChar == '+';
2954 } 2952 }
2955 2953
2956 bool isNoSuchMethodStub(var jsFunction) { 2954 bool isNoSuchMethodStub(var jsFunction) {
2957 return JS('bool', r'#.$reflectable == 2', jsFunction); 2955 return JS('bool', r'#.$reflectable == 2', jsFunction);
2958 } 2956 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 // have a part (following a '.') that starts with '_'. 3025 // have a part (following a '.') that starts with '_'.
3028 const int UNDERSCORE = 0x5f; 3026 const int UNDERSCORE = 0x5f;
3029 if (name.isEmpty) return true; 3027 if (name.isEmpty) return true;
3030 int index = -1; 3028 int index = -1;
3031 do { 3029 do {
3032 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; 3030 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false;
3033 index = name.indexOf('.', index + 1); 3031 index = name.indexOf('.', index + 1);
3034 } while (index >= 0 && index + 1 < name.length); 3032 } while (index >= 0 && index + 1 < name.length);
3035 return true; 3033 return true;
3036 } 3034 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_helper.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_names.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698