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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 14049034: Revert "Revert "Fix x.runtimeType for native classes"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_backend; 5 part of js_backend;
6 6
7 typedef void Recompile(Element element); 7 typedef void Recompile(Element element);
8 8
9 class ReturnInfo { 9 class ReturnInfo {
10 HType returnType; 10 HType returnType;
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 ..add(compiler.objectClass) 952 ..add(compiler.objectClass)
953 ..add(jsInterceptorClass) 953 ..add(jsInterceptorClass)
954 ..add(jsNullClass); 954 ..add(jsNullClass);
955 955
956 validateInterceptorImplementsAllObjectMethods(jsInterceptorClass); 956 validateInterceptorImplementsAllObjectMethods(jsInterceptorClass);
957 } 957 }
958 958
959 void validateInterceptorImplementsAllObjectMethods( 959 void validateInterceptorImplementsAllObjectMethods(
960 ClassElement interceptorClass) { 960 ClassElement interceptorClass) {
961 if (interceptorClass == null) return; 961 if (interceptorClass == null) return;
962 interceptorClass.ensureResolved(compiler);
962 compiler.objectClass.forEachMember((_, Element member) { 963 compiler.objectClass.forEachMember((_, Element member) {
963 if (member.isGenerativeConstructor()) return; 964 if (member.isGenerativeConstructor()) return;
964 Element interceptorMember = interceptorClass.lookupMember(member.name); 965 Element interceptorMember = interceptorClass.lookupMember(member.name);
965 // Interceptors must override all Object methods due to calling convention 966 // Interceptors must override all Object methods due to calling convention
966 // differences. 967 // differences.
967 assert(interceptorMember.getEnclosingClass() != compiler.objectClass); 968 assert(interceptorMember.getEnclosingClass() != compiler.objectClass);
968 }); 969 });
969 } 970 }
970 971
971 void addInterceptorsForNativeClassMembers( 972 void addInterceptorsForNativeClassMembers(
972 ClassElement cls, Enqueuer enqueuer) { 973 ClassElement cls, Enqueuer enqueuer) {
973 if (enqueuer.isResolutionQueue) { 974 if (enqueuer.isResolutionQueue) {
974 cls.ensureResolved(compiler); 975 cls.ensureResolved(compiler);
975 cls.forEachMember((ClassElement classElement, Element member) { 976 cls.forEachMember((ClassElement classElement, Element member) {
976 // All methods on [Object] are shadowed by [Interceptor]. 977 // All methods on [Object] are shadowed by [Interceptor].
977 if (classElement == compiler.objectClass) return; 978 if (classElement == compiler.objectClass) return;
978 Set<Element> set = interceptedElements.putIfAbsent( 979 Set<Element> set = interceptedElements.putIfAbsent(
979 member.name, () => new Set<Element>()); 980 member.name, () => new Set<Element>());
980 set.add(member); 981 set.add(member);
982 if (classElement == jsInterceptorClass) return;
981 if (!classElement.isNative()) { 983 if (!classElement.isNative()) {
982 MixinApplicationElement mixinApplication = classElement; 984 MixinApplicationElement mixinApplication = classElement;
983 assert(member.getEnclosingClass() == mixinApplication.mixin); 985 assert(member.getEnclosingClass() == mixinApplication.mixin);
984 classesMixedIntoNativeClasses.add(mixinApplication.mixin); 986 classesMixedIntoNativeClasses.add(mixinApplication.mixin);
985 } 987 }
986 }, 988 },
987 includeSuperMembers: true); 989 includeSuperMembers: true);
988 } 990 }
989 } 991 }
990 992
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 } 1362 }
1361 1363
1362 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { 1364 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) {
1363 return new native.NativeResolutionEnqueuer(world, compiler); 1365 return new native.NativeResolutionEnqueuer(world, compiler);
1364 } 1366 }
1365 1367
1366 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { 1368 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) {
1367 return new native.NativeCodegenEnqueuer(world, compiler, emitter); 1369 return new native.NativeCodegenEnqueuer(world, compiler, emitter);
1368 } 1370 }
1369 1371
1372 ClassElement defaultSuperclass(ClassElement element) {
1373 // Native classes inherit from Interceptor.
1374 return element.isNative() ? jsInterceptorClass : compiler.objectClass;
1375 }
1376
1370 /** 1377 /**
1371 * Unit test hook that returns code of an element as a String. 1378 * Unit test hook that returns code of an element as a String.
1372 * 1379 *
1373 * Invariant: [element] must be a declaration element. 1380 * Invariant: [element] must be a declaration element.
1374 */ 1381 */
1375 String assembleCode(Element element) { 1382 String assembleCode(Element element) {
1376 assert(invariant(element, element.isDeclaration)); 1383 assert(invariant(element, element.isDeclaration));
1377 return jsAst.prettyPrint(generatedCode[element], compiler).getText(); 1384 return jsAst.prettyPrint(generatedCode[element], compiler).getText();
1378 } 1385 }
1379 1386
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 ClassElement get constListImplementation => jsArrayClass; 1786 ClassElement get constListImplementation => jsArrayClass;
1780 ClassElement get fixedListImplementation => jsFixedArrayClass; 1787 ClassElement get fixedListImplementation => jsFixedArrayClass;
1781 ClassElement get growableListImplementation => jsExtendableArrayClass; 1788 ClassElement get growableListImplementation => jsExtendableArrayClass;
1782 ClassElement get mapImplementation => mapLiteralClass; 1789 ClassElement get mapImplementation => mapLiteralClass;
1783 ClassElement get constMapImplementation => constMapLiteralClass; 1790 ClassElement get constMapImplementation => constMapLiteralClass;
1784 ClassElement get functionImplementation => jsFunctionClass; 1791 ClassElement get functionImplementation => jsFunctionClass;
1785 ClassElement get typeImplementation => typeLiteralClass; 1792 ClassElement get typeImplementation => typeLiteralClass;
1786 ClassElement get boolImplementation => jsBoolClass; 1793 ClassElement get boolImplementation => jsBoolClass;
1787 ClassElement get nullImplementation => jsNullClass; 1794 ClassElement get nullImplementation => jsNullClass;
1788 } 1795 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/core_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698