| 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.full_emitter; | 5 part of dart2js.js_emitter.full_emitter; |
| 6 | 6 |
| 7 class ClassEmitter extends CodeEmitterHelper { | 7 class ClassEmitter extends CodeEmitterHelper { |
| 8 ClassStubGenerator get _stubGenerator => | 8 ClassStubGenerator get _stubGenerator => |
| 9 new ClassStubGenerator(compiler, namer, backend); | 9 new ClassStubGenerator(compiler, namer, backend); |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 MixinApplication mixinApplication = cls; | 28 MixinApplication mixinApplication = cls; |
| 29 jsAst.Name mixinName = mixinApplication.mixinClass.name; | 29 jsAst.Name mixinName = mixinApplication.mixinClass.name; |
| 30 superName = new CompoundName([superName, Namer.literalPlus, mixinName]); | 30 superName = new CompoundName([superName, Namer.literalPlus, mixinName]); |
| 31 emitter.needsMixinSupport = true; | 31 emitter.needsMixinSupport = true; |
| 32 } | 32 } |
| 33 | 33 |
| 34 ClassBuilder builder = new ClassBuilder.forClass(classElement, namer); | 34 ClassBuilder builder = new ClassBuilder.forClass(classElement, namer); |
| 35 builder.superName = superName; | 35 builder.superName = superName; |
| 36 emitConstructorsForCSP(cls); | 36 emitConstructorsForCSP(cls); |
| 37 emitFields(cls, builder); | 37 emitFields(cls, builder); |
| 38 if (cls.hasRtiField) { | |
| 39 builder.addField(namer.rtiFieldName); | |
| 40 } | |
| 41 emitCheckedClassSetters(cls, builder); | 38 emitCheckedClassSetters(cls, builder); |
| 42 emitClassGettersSettersForCSP(cls, builder); | 39 emitClassGettersSettersForCSP(cls, builder); |
| 43 emitInstanceMembers(cls, builder); | 40 emitInstanceMembers(cls, builder); |
| 44 emitStubs(cls.callStubs, builder); | 41 emitStubs(cls.callStubs, builder); |
| 45 emitStubs(cls.typeVariableReaderStubs, builder); | 42 emitStubs(cls.typeVariableReaderStubs, builder); |
| 46 emitRuntimeTypeInformation(cls, builder); | 43 emitRuntimeTypeInformation(cls, builder); |
| 47 emitNativeInfo(cls, builder); | 44 emitNativeInfo(cls, builder); |
| 48 | 45 |
| 49 if (classElement == backend.helpers.closureClass) { | 46 if (classElement == backend.helpers.closureClass) { |
| 50 // We add a special getter here to allow for tearing off a closure from | 47 // We add a special getter here to allow for tearing off a closure from |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 List<jsAst.Name> fieldNames = <jsAst.Name>[]; | 62 List<jsAst.Name> fieldNames = <jsAst.Name>[]; |
| 66 | 63 |
| 67 if (!compiler.options.useContentSecurityPolicy) return; | 64 if (!compiler.options.useContentSecurityPolicy) return; |
| 68 | 65 |
| 69 if (!cls.onlyForRti && !cls.isNative) { | 66 if (!cls.onlyForRti && !cls.isNative) { |
| 70 fieldNames = cls.fields.map((Field field) => field.name).toList(); | 67 fieldNames = cls.fields.map((Field field) => field.name).toList(); |
| 71 } | 68 } |
| 72 | 69 |
| 73 ClassElement classElement = cls.element; | 70 ClassElement classElement = cls.element; |
| 74 | 71 |
| 75 jsAst.Expression constructorAst = _stubGenerator.generateClassConstructor( | 72 jsAst.Expression constructorAst = |
| 76 classElement, fieldNames, cls.hasRtiField); | 73 _stubGenerator.generateClassConstructor(classElement, fieldNames); |
| 77 | 74 |
| 78 jsAst.Name constructorName = namer.className(classElement); | 75 jsAst.Name constructorName = namer.className(classElement); |
| 79 OutputUnit outputUnit = | 76 OutputUnit outputUnit = |
| 80 compiler.deferredLoadTask.outputUnitForElement(classElement); | 77 compiler.deferredLoadTask.outputUnitForElement(classElement); |
| 81 emitter.assemblePrecompiledConstructor( | 78 emitter.assemblePrecompiledConstructor( |
| 82 outputUnit, constructorName, constructorAst, fieldNames); | 79 outputUnit, constructorName, constructorAst, fieldNames); |
| 83 } | 80 } |
| 84 | 81 |
| 85 /// Returns `true` if fields added. | 82 /// Returns `true` if fields added. |
| 86 bool emitFields(FieldContainer container, ClassBuilder builder, | 83 bool emitFields(FieldContainer container, ClassBuilder builder, |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 : new Selector.setter( | 414 : new Selector.setter( |
| 418 new Name(member.name, member.library, isSetter: true)); | 415 new Name(member.name, member.library, isSetter: true)); |
| 419 String reflectionName = emitter.getReflectionName(selector, name); | 416 String reflectionName = emitter.getReflectionName(selector, name); |
| 420 if (reflectionName != null) { | 417 if (reflectionName != null) { |
| 421 var reflectable = | 418 var reflectable = |
| 422 js(backend.isAccessibleByReflection(member) ? '1' : '0'); | 419 js(backend.isAccessibleByReflection(member) ? '1' : '0'); |
| 423 builder.addPropertyByName('+$reflectionName', reflectable); | 420 builder.addPropertyByName('+$reflectionName', reflectable); |
| 424 } | 421 } |
| 425 } | 422 } |
| 426 } | 423 } |
| OLD | NEW |