| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. | 349 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. |
| 350 if (!buffer.isEmpty) { | 350 if (!buffer.isEmpty) { |
| 351 buffer.write(',$n$n'); | 351 buffer.write(',$n$n'); |
| 352 } | 352 } |
| 353 buffer.write('$className:$_'); | 353 buffer.write('$className:$_'); |
| 354 buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler)); | 354 buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler)); |
| 355 String reflectionName = task.getReflectionName(classElement, className); | 355 String reflectionName = task.getReflectionName(classElement, className); |
| 356 if (reflectionName != null) { | 356 if (reflectionName != null) { |
| 357 reflectionName = '+$reflectionName'; |
| 358 } else if (classElement.isUnnamedMixinApplication && |
| 359 backend.isNeededForReflection(classElement)) { |
| 360 reflectionName = '-$className'; |
| 361 } |
| 362 if (reflectionName != null) { |
| 357 if (!backend.isNeededForReflection(classElement)) { | 363 if (!backend.isNeededForReflection(classElement)) { |
| 358 buffer.write(',$n$n"+$reflectionName": 0'); | 364 buffer.write(',$n$n"$reflectionName": 0'); |
| 359 } else { | 365 } else { |
| 360 List<int> types = <int>[]; | 366 List<int> types = <int>[]; |
| 361 if (classElement.supertype != null) { | 367 if (classElement.supertype != null) { |
| 362 types.add( | 368 types.add( |
| 363 task.metadataEmitter.reifyType(classElement.supertype)); | 369 task.metadataEmitter.reifyType(classElement.supertype)); |
| 364 } | 370 } |
| 365 for (DartType interface in classElement.interfaces) { | 371 for (DartType interface in classElement.interfaces) { |
| 366 types.add(task.metadataEmitter.reifyType(interface)); | 372 types.add(task.metadataEmitter.reifyType(interface)); |
| 367 } | 373 } |
| 368 buffer.write(',$n$n"+$reflectionName": $types'); | 374 buffer.write(',$n$n"$reflectionName": $types'); |
| 369 } | 375 } |
| 370 } | 376 } |
| 371 } | 377 } |
| 372 | 378 |
| 373 /** | 379 /** |
| 374 * Calls [addField] for each of the fields of [element]. | 380 * Calls [addField] for each of the fields of [element]. |
| 375 * | 381 * |
| 376 * [element] must be a [ClassElement] or a [LibraryElement]. | 382 * [element] must be a [ClassElement] or a [LibraryElement]. |
| 377 * | 383 * |
| 378 * If [element] is a [ClassElement], the static fields of the class are | 384 * If [element] is a [ClassElement], the static fields of the class are |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 ? new Selector.getter(member.name, member.getLibrary()) | 574 ? new Selector.getter(member.name, member.getLibrary()) |
| 569 : new Selector.setter(member.name, member.getLibrary()); | 575 : new Selector.setter(member.name, member.getLibrary()); |
| 570 String reflectionName = task.getReflectionName(selector, name); | 576 String reflectionName = task.getReflectionName(selector, name); |
| 571 if (reflectionName != null) { | 577 if (reflectionName != null) { |
| 572 var reflectable = | 578 var reflectable = |
| 573 js(backend.isAccessibleByReflection(member) ? '1' : '0'); | 579 js(backend.isAccessibleByReflection(member) ? '1' : '0'); |
| 574 builder.addProperty('+$reflectionName', reflectable); | 580 builder.addProperty('+$reflectionName', reflectable); |
| 575 } | 581 } |
| 576 } | 582 } |
| 577 } | 583 } |
| OLD | NEW |