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

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

Issue 753113002: Encode super calls via extra properties on prototypes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: sra@ comments Created 6 years 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 '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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 Map<Symbol, Mirror> result = new Map.from(variables); 726 Map<Symbol, Mirror> result = new Map.from(variables);
727 for (JsMethodMirror method in methods) { 727 for (JsMethodMirror method in methods) {
728 if (method.isSetter) { 728 if (method.isSetter) {
729 String name = n(method.simpleName); 729 String name = n(method.simpleName);
730 name = name.substring(0, name.length - 1); 730 name = name.substring(0, name.length - 1);
731 // Filter-out setters corresponding to variables. 731 // Filter-out setters corresponding to variables.
732 if (result[s(name)] is VariableMirror) continue; 732 if (result[s(name)] is VariableMirror) continue;
733 } 733 }
734 // Constructors aren't 'members'. 734 // Constructors aren't 'members'.
735 if (method.isConstructor) continue; 735 if (method.isConstructor) continue;
736 // Filter out synthetic tear-off stubs
737 if (JS('bool', r'!!#.$getterStub', method._jsFunction)) continue;
736 // Use putIfAbsent to filter-out getters corresponding to variables. 738 // Use putIfAbsent to filter-out getters corresponding to variables.
737 result.putIfAbsent(method.simpleName, () => method); 739 result.putIfAbsent(method.simpleName, () => method);
738 } 740 }
739 return result; 741 return result;
740 } 742 }
741 743
742 int counter = 0; 744 int counter = 0;
743 745
744 ClassMirror reflectMixinApplication(mixinNames, String mangledName) { 746 ClassMirror reflectMixinApplication(mixinNames, String mangledName) {
745 disableTreeShaking(); 747 disableTreeShaking();
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 for (String key in keys) { 1659 for (String key in keys) {
1658 if (isReflectiveDataInPrototype(key)) continue; 1660 if (isReflectiveDataInPrototype(key)) continue;
1659 String simpleName = mangledNames[key]; 1661 String simpleName = mangledNames[key];
1660 // [simpleName] can be null if [key] represents an implementation 1662 // [simpleName] can be null if [key] represents an implementation
1661 // detail, for example, a bailout method, or runtime type support. 1663 // detail, for example, a bailout method, or runtime type support.
1662 // It might also be null if the user has limited what is reified for 1664 // It might also be null if the user has limited what is reified for
1663 // reflection with metadata. 1665 // reflection with metadata.
1664 if (simpleName == null) continue; 1666 if (simpleName == null) continue;
1665 var function = JS('', '#[#]', prototype, key); 1667 var function = JS('', '#[#]', prototype, key);
1666 if (isNoSuchMethodStub(function)) continue; 1668 if (isNoSuchMethodStub(function)) continue;
1669 if (isAliasedSuperMethod(function, key)) continue;
1667 var mirror = 1670 var mirror =
1668 new JsMethodMirror.fromUnmangledName( 1671 new JsMethodMirror.fromUnmangledName(
1669 simpleName, function, false, false); 1672 simpleName, function, false, false);
1670 result.add(mirror); 1673 result.add(mirror);
1671 mirror._owner = methodOwner; 1674 mirror._owner = methodOwner;
1672 } 1675 }
1673 1676
1674 var statics = JS_EMBEDDED_GLOBAL('', STATICS); 1677 var statics = JS_EMBEDDED_GLOBAL('', STATICS);
1675 keys = extractKeys(JS('', '#[#]', statics, _mangledName)); 1678 keys = extractKeys(JS('', '#[#]', statics, _mangledName));
1676 for (String mangledName in keys) { 1679 for (String mangledName in keys) {
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 return true; 2901 return true;
2899 } 2902 }
2900 String firstChar = key[0]; 2903 String firstChar = key[0];
2901 return firstChar == '*' || firstChar == '+'; 2904 return firstChar == '*' || firstChar == '+';
2902 } 2905 }
2903 2906
2904 bool isNoSuchMethodStub(var jsFunction) { 2907 bool isNoSuchMethodStub(var jsFunction) {
2905 return JS('bool', r'#.$reflectable == 2', jsFunction); 2908 return JS('bool', r'#.$reflectable == 2', jsFunction);
2906 } 2909 }
2907 2910
2911 /// Returns true if [key] is only an aliased entry for [function] in the
2912 /// prototype.
2913 bool isAliasedSuperMethod(var jsFunction, String key) {
2914 var stubName = JS('String|Null', r'#.$stubName', jsFunction);
2915 return stubName != null && key != stubName;
2916 }
2917
2908 class NoSuchStaticMethodError extends Error implements NoSuchMethodError { 2918 class NoSuchStaticMethodError extends Error implements NoSuchMethodError {
2909 static const int MISSING_CONSTRUCTOR = 0; 2919 static const int MISSING_CONSTRUCTOR = 0;
2910 static const int MISSING_METHOD = 1; 2920 static const int MISSING_METHOD = 1;
2911 final ClassMirror _cls; 2921 final ClassMirror _cls;
2912 final Symbol _name; 2922 final Symbol _name;
2913 final List _positionalArguments; 2923 final List _positionalArguments;
2914 final Map<Symbol, dynamic> _namedArguments; 2924 final Map<Symbol, dynamic> _namedArguments;
2915 final int _kind; 2925 final int _kind;
2916 2926
2917 NoSuchStaticMethodError.missingConstructor( 2927 NoSuchStaticMethodError.missingConstructor(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 // have a part (following a '.') that starts with '_'. 2978 // have a part (following a '.') that starts with '_'.
2969 const int UNDERSCORE = 0x5f; 2979 const int UNDERSCORE = 0x5f;
2970 if (name.isEmpty) return true; 2980 if (name.isEmpty) return true;
2971 int index = -1; 2981 int index = -1;
2972 do { 2982 do {
2973 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; 2983 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false;
2974 index = name.indexOf('.', index + 1); 2984 index = name.indexOf('.', index + 1);
2975 } while (index >= 0 && index + 1 < name.length); 2985 } while (index >= 0 && index + 1 < name.length);
2976 return true; 2986 return true;
2977 } 2987 }
OLDNEW
« pkg/compiler/lib/src/ssa/codegen.dart ('K') | « pkg/dart2js_incremental/lib/library_updater.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698