| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 jsAst.Fun function = js('function() { return this; }'); | 56 jsAst.Fun function = js('function() { return this; }'); |
| 57 builder.addProperty(namer.getterNameFromAccessorName(name), function); | 57 builder.addProperty(namer.getterNameFromAccessorName(name), function); |
| 58 } | 58 } |
| 59 | 59 |
| 60 emitTypeVariableReaders(classElement, builder); | 60 emitTypeVariableReaders(classElement, builder); |
| 61 | 61 |
| 62 emitClassBuilderWithReflectionData( | 62 emitClassBuilderWithReflectionData( |
| 63 className, classElement, builder, properties); | 63 className, classElement, builder, properties); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | |
| 67 * [emitClassConstructor] affects the generation of constructors in CSP mode. | |
| 68 */ | |
| 69 void emitClassConstructor(ClassElement classElement, | 66 void emitClassConstructor(ClassElement classElement, |
| 70 ClassBuilder builder, | 67 ClassBuilder builder, |
| 71 {bool onlyForRti: false}) { | 68 {bool onlyForRti: false}) { |
| 72 List<String> fields = <String>[]; | 69 List<String> fields = <String>[]; |
| 73 if (!onlyForRti && !classElement.isNative) { | 70 if (!onlyForRti && !classElement.isNative) { |
| 74 visitFields(classElement, false, | 71 visitFields(classElement, false, |
| 75 (Element member, | 72 (Element member, |
| 76 String name, | 73 String name, |
| 77 String accessorName, | 74 String accessorName, |
| 78 bool needsGetter, | 75 bool needsGetter, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 211 } |
| 215 }); | 212 }); |
| 216 } | 213 } |
| 217 | 214 |
| 218 if (hasMetadata) { | 215 if (hasMetadata) { |
| 219 builder.fieldMetadata = fieldMetadata; | 216 builder.fieldMetadata = fieldMetadata; |
| 220 } | 217 } |
| 221 return fieldsAdded; | 218 return fieldsAdded; |
| 222 } | 219 } |
| 223 | 220 |
| 224 /** | |
| 225 * Emits getters/setters for fields if necessary. | |
| 226 * | |
| 227 * They can be needed in CSP mode, or in checked mode, when types need to be | |
| 228 * verified. | |
| 229 */ | |
| 230 void emitClassGettersSetters(ClassElement classElement, | 221 void emitClassGettersSetters(ClassElement classElement, |
| 231 ClassBuilder builder, | 222 ClassBuilder builder, |
| 232 {bool onlyForRti: false}) { | 223 {bool onlyForRti: false}) { |
| 233 if (onlyForRti) return; | 224 if (onlyForRti) return; |
| 234 | 225 |
| 235 visitFields(classElement, false, | 226 visitFields(classElement, false, |
| 236 (VariableElement member, | 227 (VariableElement member, |
| 237 String name, | 228 String name, |
| 238 String accessorName, | 229 String accessorName, |
| 239 bool needsGetter, | 230 bool needsGetter, |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); | 594 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); |
| 604 } | 595 } |
| 605 jsAst.Expression convertRtiToRuntimeType = emitter | 596 jsAst.Expression convertRtiToRuntimeType = emitter |
| 606 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); | 597 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); |
| 607 compiler.dumpInfoTask.registerElementAst(element, | 598 compiler.dumpInfoTask.registerElementAst(element, |
| 608 builder.addProperty(name, | 599 builder.addProperty(name, |
| 609 js('function () { return #(#) }', | 600 js('function () { return #(#) }', |
| 610 [convertRtiToRuntimeType, computeTypeVariable]))); | 601 [convertRtiToRuntimeType, computeTypeVariable]))); |
| 611 } | 602 } |
| 612 } | 603 } |
| OLD | NEW |