| OLD | NEW |
| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class ClassEmitter extends CodeEmitterHelper { | 7 class ClassEmitter extends CodeEmitterHelper { |
| 8 | 8 |
| 9 ClassStubGenerator get _stubGenerator => | 9 ClassStubGenerator get _stubGenerator => |
| 10 new ClassStubGenerator(compiler, namer, backend); | 10 new ClassStubGenerator(compiler, namer, backend); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 emitter.needsMixinSupport = true; | 36 emitter.needsMixinSupport = true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 ClassBuilder builder = new ClassBuilder(classElement, namer); | 39 ClassBuilder builder = new ClassBuilder(classElement, namer); |
| 40 builder.superName = superName; | 40 builder.superName = superName; |
| 41 emitConstructorsForCSP(cls); | 41 emitConstructorsForCSP(cls); |
| 42 emitFields(cls, builder); | 42 emitFields(cls, builder); |
| 43 emitCheckedClassSetters(cls, builder); | 43 emitCheckedClassSetters(cls, builder); |
| 44 emitClassGettersSettersForCSP(cls, builder); | 44 emitClassGettersSettersForCSP(cls, builder); |
| 45 emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti); | 45 emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti); |
| 46 emitCallStubs(cls, builder); |
| 46 emitRuntimeTypeInformation(cls, builder); | 47 emitRuntimeTypeInformation(cls, builder); |
| 47 if (additionalProperties != null) { | 48 if (additionalProperties != null) { |
| 48 additionalProperties.forEach(builder.addProperty); | 49 additionalProperties.forEach(builder.addProperty); |
| 49 } | 50 } |
| 50 | 51 |
| 51 if (classElement == backend.closureClass) { | 52 if (classElement == backend.closureClass) { |
| 52 // We add a special getter here to allow for tearing off a closure from | 53 // We add a special getter here to allow for tearing off a closure from |
| 53 // itself. | 54 // itself. |
| 54 String name = namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME); | 55 String name = namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME); |
| 55 jsAst.Fun function = js('function() { return this; }'); | 56 jsAst.Fun function = js('function() { return this; }'); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (field.needsGetter) { | 212 if (field.needsGetter) { |
| 212 emitGetterForCSP(member, field.name, field.accessorName, builder); | 213 emitGetterForCSP(member, field.name, field.accessorName, builder); |
| 213 } | 214 } |
| 214 if (field.needsUncheckedSetter) { | 215 if (field.needsUncheckedSetter) { |
| 215 emitSetterForCSP(member, field.name, field.accessorName, builder); | 216 emitSetterForCSP(member, field.name, field.accessorName, builder); |
| 216 } | 217 } |
| 217 }); | 218 }); |
| 218 } | 219 } |
| 219 } | 220 } |
| 220 | 221 |
| 222 void emitCallStubs(Class cls, ClassBuilder builder) { |
| 223 for (Method method in cls.callStubs) { |
| 224 jsAst.Property property = builder.addProperty(method.name, method.code); |
| 225 compiler.dumpInfoTask.registerElementAst(method.element, property); |
| 226 } |
| 227 } |
| 228 |
| 221 /** | 229 /** |
| 222 * Documentation wanted -- johnniwinther | 230 * Documentation wanted -- johnniwinther |
| 223 * | 231 * |
| 224 * Invariant: [classElement] must be a declaration element. | 232 * Invariant: [classElement] must be a declaration element. |
| 225 */ | 233 */ |
| 226 void emitInstanceMembers(ClassElement classElement, | 234 void emitInstanceMembers(ClassElement classElement, |
| 227 ClassBuilder builder, | 235 ClassBuilder builder, |
| 228 {bool onlyForRti: false}) { | 236 {bool onlyForRti: false}) { |
| 229 assert(invariant(classElement, classElement.isDeclaration)); | 237 assert(invariant(classElement, classElement.isDeclaration)); |
| 230 | 238 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 js.number(index)); | 588 js.number(index)); |
| 581 } | 589 } |
| 582 jsAst.Expression convertRtiToRuntimeType = emitter | 590 jsAst.Expression convertRtiToRuntimeType = emitter |
| 583 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); | 591 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); |
| 584 compiler.dumpInfoTask.registerElementAst(element, | 592 compiler.dumpInfoTask.registerElementAst(element, |
| 585 builder.addProperty(name, | 593 builder.addProperty(name, |
| 586 js('function () { return #(#) }', | 594 js('function () { return #(#) }', |
| 587 [convertRtiToRuntimeType, computeTypeVariable]))); | 595 [convertRtiToRuntimeType, computeTypeVariable]))); |
| 588 } | 596 } |
| 589 } | 597 } |
| OLD | NEW |