Chromium Code Reviews| 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 */ | |
| 66 void emitClassConstructor(ClassElement classElement, | 69 void emitClassConstructor(ClassElement classElement, |
| 67 ClassBuilder builder, | 70 ClassBuilder builder, |
| 68 {bool onlyForRti: false}) { | 71 {bool onlyForRti: false}) { |
| 69 List<String> fields = <String>[]; | 72 List<String> fields = <String>[]; |
| 70 if (!onlyForRti && !classElement.isNative) { | 73 if (!onlyForRti && !classElement.isNative) { |
| 71 visitFields(classElement, false, | 74 visitFields(classElement, false, |
| 72 (Element member, | 75 (Element member, |
| 73 String name, | 76 String name, |
| 74 String accessorName, | 77 String accessorName, |
| 75 bool needsGetter, | 78 bool needsGetter, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 } | 214 } |
| 212 }); | 215 }); |
| 213 } | 216 } |
| 214 | 217 |
| 215 if (hasMetadata) { | 218 if (hasMetadata) { |
| 216 builder.fieldMetadata = fieldMetadata; | 219 builder.fieldMetadata = fieldMetadata; |
| 217 } | 220 } |
| 218 return fieldsAdded; | 221 return fieldsAdded; |
| 219 } | 222 } |
| 220 | 223 |
| 224 /** | |
| 225 * [emitClassGettersSetters] does not affect whether or not a class is needed | |
|
floitsch
2015/01/15 15:14:40
That comment is out of context.
It should say som
zarah
2015/01/16 08:48:50
You are right. Comment updated.
| |
| 226 * If getters/setters are emitted, the class has fields and is therefore | |
| 227 * non-trivial. | |
| 228 */ | |
| 221 void emitClassGettersSetters(ClassElement classElement, | 229 void emitClassGettersSetters(ClassElement classElement, |
| 222 ClassBuilder builder, | 230 ClassBuilder builder, |
| 223 {bool onlyForRti: false}) { | 231 {bool onlyForRti: false}) { |
| 224 if (onlyForRti) return; | 232 if (onlyForRti) return; |
| 225 | 233 |
| 226 visitFields(classElement, false, | 234 visitFields(classElement, false, |
| 227 (VariableElement member, | 235 (VariableElement member, |
| 228 String name, | 236 String name, |
| 229 String accessorName, | 237 String accessorName, |
| 230 bool needsGetter, | 238 bool needsGetter, |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); | 602 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); |
| 595 } | 603 } |
| 596 jsAst.Expression convertRtiToRuntimeType = emitter | 604 jsAst.Expression convertRtiToRuntimeType = emitter |
| 597 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); | 605 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); |
| 598 compiler.dumpInfoTask.registerElementAst(element, | 606 compiler.dumpInfoTask.registerElementAst(element, |
| 599 builder.addProperty(name, | 607 builder.addProperty(name, |
| 600 js('function () { return #(#) }', | 608 js('function () { return #(#) }', |
| 601 [convertRtiToRuntimeType, computeTypeVariable]))); | 609 [convertRtiToRuntimeType, computeTypeVariable]))); |
| 602 } | 610 } |
| 603 } | 611 } |
| OLD | NEW |