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

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

Issue 19097003: Support new malformed types semantics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix unittests. Created 7 years, 4 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 /** 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 void computeRequiredTypeChecks() { 215 void computeRequiredTypeChecks() {
216 assert(checkedClasses == null && checkedFunctionTypes == null); 216 assert(checkedClasses == null && checkedFunctionTypes == null);
217 217
218 backend.rti.addImplicitChecks(compiler.codegenWorld, 218 backend.rti.addImplicitChecks(compiler.codegenWorld,
219 classesUsingTypeVariableTests); 219 classesUsingTypeVariableTests);
220 220
221 checkedClasses = new Set<ClassElement>(); 221 checkedClasses = new Set<ClassElement>();
222 checkedFunctionTypes = new Set<FunctionType>(); 222 checkedFunctionTypes = new Set<FunctionType>();
223 compiler.codegenWorld.isChecks.forEach((DartType t) { 223 compiler.codegenWorld.isChecks.forEach((DartType t) {
224 if (!t.isMalformed) { 224 if (t is InterfaceType) {
225 if (t is InterfaceType) { 225 checkedClasses.add(t.element);
226 checkedClasses.add(t.element); 226 } else if (t is FunctionType) {
227 } else if (t is FunctionType) { 227 checkedFunctionTypes.add(t);
228 checkedFunctionTypes.add(t);
229 }
230 } 228 }
231 }); 229 });
232 } 230 }
233 231
234 ClassElement computeMixinClass(MixinApplicationElement mixinApplication) { 232 ClassElement computeMixinClass(MixinApplicationElement mixinApplication) {
235 ClassElement mixin = mixinApplication.mixin; 233 ClassElement mixin = mixinApplication.mixin;
236 while (mixin.isMixinApplication) { 234 while (mixin.isMixinApplication) {
237 mixinApplication = mixin; 235 mixinApplication = mixin;
238 mixin = mixinApplication.mixin; 236 mixin = mixinApplication.mixin;
239 } 237 }
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 builder.addProperty(setterName, 1640 builder.addProperty(setterName,
1643 js.fun(args, js('$receiver.$fieldName = v'))); 1641 js.fun(args, js('$receiver.$fieldName = v')));
1644 } 1642 }
1645 1643
1646 bool canGenerateCheckedSetter(VariableElement field) { 1644 bool canGenerateCheckedSetter(VariableElement field) {
1647 // We never generate accessors for top-level/static fields. 1645 // We never generate accessors for top-level/static fields.
1648 if (!field.isInstanceMember()) return false; 1646 if (!field.isInstanceMember()) return false;
1649 DartType type = field.computeType(compiler).unalias(compiler); 1647 DartType type = field.computeType(compiler).unalias(compiler);
1650 if (type.element.isTypeVariable() || 1648 if (type.element.isTypeVariable() ||
1651 (type is FunctionType && type.containsTypeVariables) || 1649 (type is FunctionType && type.containsTypeVariables) ||
1652 type.element == compiler.dynamicClass || 1650 type.treatAsDynamic ||
1653 type.element == compiler.objectClass) { 1651 type.element == compiler.objectClass) {
1654 // TODO(ngeoffray): Support type checks on type parameters. 1652 // TODO(ngeoffray): Support type checks on type parameters.
1655 return false; 1653 return false;
1656 } 1654 }
1657 return true; 1655 return true;
1658 } 1656 }
1659 1657
1660 void generateCheckedSetter(Element member, 1658 void generateCheckedSetter(Element member,
1661 String fieldName, 1659 String fieldName,
1662 String accessorName, 1660 String accessorName,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 buffer.write(name); 1785 buffer.write(name);
1788 } else { 1786 } else {
1789 // Emit (possibly renaming) field name so we can add accessors at 1787 // Emit (possibly renaming) field name so we can add accessors at
1790 // runtime. 1788 // runtime.
1791 buffer.write(accessorName); 1789 buffer.write(accessorName);
1792 if (name != accessorName) { 1790 if (name != accessorName) {
1793 buffer.write(':$name'); 1791 buffer.write(':$name');
1794 // Only the native classes can have renaming accessors. 1792 // Only the native classes can have renaming accessors.
1795 assert(classIsNative); 1793 assert(classIsNative);
1796 } 1794 }
1797 1795
1798 int getterCode = 0; 1796 int getterCode = 0;
1799 if (needsGetter) { 1797 if (needsGetter) {
1800 if (field.isInstanceMember()) { 1798 if (field.isInstanceMember()) {
1801 // 01: function() { return this.field; } 1799 // 01: function() { return this.field; }
1802 // 10: function(receiver) { return receiver.field; } 1800 // 10: function(receiver) { return receiver.field; }
1803 // 11: function(receiver) { return this.field; } 1801 // 11: function(receiver) { return this.field; }
1804 getterCode += backend.fieldHasInterceptedGetter(field) ? 2 : 0; 1802 getterCode += backend.fieldHasInterceptedGetter(field) ? 2 : 0;
1805 getterCode += backend.isInterceptorClass(element) ? 0 : 1; 1803 getterCode += backend.isInterceptorClass(element) ? 0 : 1;
1806 // TODO(sra): 'isInterceptorClass' might not be the correct test 1804 // TODO(sra): 'isInterceptorClass' might not be the correct test
1807 // for methods forced to use the interceptor convention because 1805 // for methods forced to use the interceptor convention because
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 4043
4046 const String HOOKS_API_USAGE = """ 4044 const String HOOKS_API_USAGE = """
4047 // The code supports the following hooks: 4045 // The code supports the following hooks:
4048 // dartPrint(message) - if this function is defined it is called 4046 // dartPrint(message) - if this function is defined it is called
4049 // instead of the Dart [print] method. 4047 // instead of the Dart [print] method.
4050 // dartMainRunner(main) - if this function is defined, the Dart [main] 4048 // dartMainRunner(main) - if this function is defined, the Dart [main]
4051 // method will not be invoked directly. 4049 // method will not be invoked directly.
4052 // Instead, a closure that will invoke [main] is 4050 // Instead, a closure that will invoke [main] is
4053 // passed to [dartMainRunner]. 4051 // passed to [dartMainRunner].
4054 """; 4052 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698