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