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

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

Issue 12082025: Fix minified version of mixin field test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/native_field_name_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 // inheritance purposes, but we can simplify its JavaScript constructor. 878 // inheritance purposes, but we can simplify its JavaScript constructor.
879 bool isInstantiated = 879 bool isInstantiated =
880 compiler.codegenWorld.instantiatedClasses.contains(classElement); 880 compiler.codegenWorld.instantiatedClasses.contains(classElement);
881 881
882 void visitField(ClassElement enclosingClass, Element member) { 882 void visitField(ClassElement enclosingClass, Element member) {
883 assert(invariant(classElement, member.isDeclaration)); 883 assert(invariant(classElement, member.isDeclaration));
884 LibraryElement library = member.getLibrary(); 884 LibraryElement library = member.getLibrary();
885 SourceString name = member.name; 885 SourceString name = member.name;
886 bool isPrivate = name.isPrivate(); 886 bool isPrivate = name.isPrivate();
887 887
888 // If we're dealing with a native class and we've found the 888 // Keep track of whether or not we're dealing with a field mixin
889 // field in an applied mixin, we treat it as if we've found the 889 // into a native class.
890 // field in the class itself. 890 bool isMixinNativeField =
891 if (classElement.isNative() && enclosingClass.isMixinApplication) { 891 classElement.isNative() && enclosingClass.isMixinApplication;
892 enclosingClass = classElement;
893 }
894 892
895 // See if we can dynamically create getters and setters. 893 // See if we can dynamically create getters and setters.
896 // We can only generate getters and setters for [classElement] since 894 // We can only generate getters and setters for [classElement] since
897 // the fields of super classes could be overwritten with getters or 895 // the fields of super classes could be overwritten with getters or
898 // setters. 896 // setters.
899 bool needsGetter = false; 897 bool needsGetter = false;
900 bool needsSetter = false; 898 bool needsSetter = false;
901 // We need to name shadowed fields differently, so they don't clash with 899 // We need to name shadowed fields differently, so they don't clash with
902 // the non-shadowed field. 900 // the non-shadowed field.
903 bool isShadowed = false; 901 bool isShadowed = false;
904 if (identical(enclosingClass, classElement)) { 902 if (isMixinNativeField || identical(enclosingClass, classElement)) {
905 needsGetter = instanceFieldNeedsGetter(member); 903 needsGetter = instanceFieldNeedsGetter(member);
906 needsSetter = instanceFieldNeedsSetter(member); 904 needsSetter = instanceFieldNeedsSetter(member);
907 } else { 905 } else {
908 isShadowed = classElement.isShadowedByField(member); 906 isShadowed = classElement.isShadowedByField(member);
909 } 907 }
910 908
911 if ((isInstantiated && !enclosingClass.isNative()) 909 if ((isInstantiated && !enclosingClass.isNative())
912 || needsGetter 910 || needsGetter
913 || needsSetter) { 911 || needsSetter) {
914 String accessorName = isShadowed 912 String accessorName = isShadowed
915 ? namer.shadowedFieldName(member) 913 ? namer.shadowedFieldName(member)
916 : namer.getName(member); 914 : namer.getName(member);
917 String fieldName = member.hasFixedBackendName() 915 String fieldName = member.hasFixedBackendName()
918 ? member.fixedBackendName() 916 ? member.fixedBackendName()
919 : accessorName; 917 : (isMixinNativeField ? member.name.slowToString() : accessorName);
920 bool needsCheckedSetter = false; 918 bool needsCheckedSetter = false;
921 if (needsSetter && compiler.enableTypeAssertions 919 if (needsSetter && compiler.enableTypeAssertions
922 && canGenerateCheckedSetter(member)) { 920 && canGenerateCheckedSetter(member)) {
923 needsCheckedSetter = true; 921 needsCheckedSetter = true;
924 needsSetter = false; 922 needsSetter = false;
925 } 923 }
926 // Getters and setters with suffixes will be generated dynamically. 924 // Getters and setters with suffixes will be generated dynamically.
927 addField(member, 925 addField(member,
928 fieldName, 926 fieldName,
929 accessorName, 927 accessorName,
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 """; 2293 """;
2296 const String HOOKS_API_USAGE = """ 2294 const String HOOKS_API_USAGE = """
2297 // The code supports the following hooks: 2295 // The code supports the following hooks:
2298 // dartPrint(message) - if this function is defined it is called 2296 // dartPrint(message) - if this function is defined it is called
2299 // instead of the Dart [print] method. 2297 // instead of the Dart [print] method.
2300 // dartMainRunner(main) - if this function is defined, the Dart [main] 2298 // dartMainRunner(main) - if this function is defined, the Dart [main]
2301 // method will not be invoked directly. 2299 // method will not be invoked directly.
2302 // Instead, a closure that will invoke [main] is 2300 // Instead, a closure that will invoke [main] is
2303 // passed to [dartMainRunner]. 2301 // passed to [dartMainRunner].
2304 """; 2302 """;
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/native_field_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698