| 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 * Documentation wanted -- johnniwinther | 9 * Documentation wanted -- johnniwinther |
| 10 * | 10 * |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 if (!statics.isEmpty) { | 330 if (!statics.isEmpty) { |
| 331 classBuilder.addProperty('static', new jsAst.ObjectInitializer(statics)); | 331 classBuilder.addProperty('static', new jsAst.ObjectInitializer(statics)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. | 334 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. |
| 335 enclosingBuilder.addProperty(className, classBuilder.toObjectInitializer()); | 335 enclosingBuilder.addProperty(className, classBuilder.toObjectInitializer()); |
| 336 | 336 |
| 337 String reflectionName = task.getReflectionName(classElement, className); | 337 String reflectionName = task.getReflectionName(classElement, className); |
| 338 if (reflectionName != null) { | 338 if (reflectionName != null) { |
| 339 reflectionName = '+$reflectionName'; |
| 340 } else if (classElement.isUnnamedMixinApplication && |
| 341 backend.isNeededForReflection(classElement)) { |
| 342 reflectionName = '-$className'; |
| 343 } |
| 344 if (reflectionName != null) { |
| 339 if (!backend.isNeededForReflection(classElement)) { | 345 if (!backend.isNeededForReflection(classElement)) { |
| 340 enclosingBuilder.addProperty("+$reflectionName", js.number(0)); | 346 enclosingBuilder.addProperty("$reflectionName", js.number(0)); |
| 341 } else { | 347 } else { |
| 342 List<int> types = new List<int>(); | 348 List<int> types = new List<int>(); |
| 343 if (classElement.supertype != null) { | 349 if (classElement.supertype != null) { |
| 344 types.add(task.metadataEmitter.reifyType(classElement.supertype)); | 350 types.add(task.metadataEmitter.reifyType(classElement.supertype)); |
| 345 } | 351 } |
| 346 for (DartType interface in classElement.interfaces) { | 352 for (DartType interface in classElement.interfaces) { |
| 347 types.add(task.metadataEmitter.reifyType(interface)); | 353 types.add(task.metadataEmitter.reifyType(interface)); |
| 348 } | 354 } |
| 349 enclosingBuilder.addProperty("+$reflectionName", | 355 enclosingBuilder.addProperty("$reflectionName", |
| 350 new jsAst.ArrayInitializer.from(types.map((typeNumber) => | 356 new jsAst.ArrayInitializer.from(types.map((typeNumber) => |
| 351 js.number(typeNumber)))); | 357 js.number(typeNumber)))); |
| 352 } | 358 } |
| 353 } | 359 } |
| 354 } | 360 } |
| 355 | 361 |
| 356 /** | 362 /** |
| 357 * Calls [addField] for each of the fields of [element]. | 363 * Calls [addField] for each of the fields of [element]. |
| 358 * | 364 * |
| 359 * [element] must be a [ClassElement] or a [LibraryElement]. | 365 * [element] must be a [ClassElement] or a [LibraryElement]. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 computeTypeVariable = | 598 computeTypeVariable = |
| 593 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); | 599 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); |
| 594 } | 600 } |
| 595 jsAst.Expression convertRtiToRuntimeType = | 601 jsAst.Expression convertRtiToRuntimeType = |
| 596 namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType')); | 602 namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType')); |
| 597 builder.addProperty( | 603 builder.addProperty( |
| 598 name, js.fun( | 604 name, js.fun( |
| 599 [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))])); | 605 [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))])); |
| 600 } | 606 } |
| 601 } | 607 } |
| OLD | NEW |