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 library dump_info; | 5 library dump_info; |
| 6 | 6 |
| 7 import 'dart:convert' show | 7 import 'dart:convert' show |
| 8 HtmlEscape, | 8 HtmlEscape, |
| 9 JsonEncoder, | 9 JsonEncoder, |
| 10 StringConversionSink, | 10 StringConversionSink, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 | 232 |
| 233 // Omit element if it is not needed. | 233 // Omit element if it is not needed. |
| 234 JavaScriptBackend backend = compiler.backend; | 234 JavaScriptBackend backend = compiler.backend; |
| 235 if (!backend.emitter.neededClasses.contains(element)) return null; | 235 if (!backend.emitter.neededClasses.contains(element)) return null; |
| 236 Map<String, dynamic> modifiers = { 'abstract': element.isAbstract }; | 236 Map<String, dynamic> modifiers = { 'abstract': element.isAbstract }; |
| 237 | 237 |
| 238 element.forEachLocalMember((Element member) { | 238 element.forEachLocalMember((Element member) { |
| 239 Map<String, dynamic> childJson = this.process(member); | 239 Map<String, dynamic> childJson = this.process(member); |
| 240 if (childJson != null) { | 240 if (childJson != null) { |
| 241 children.add(childJson['id']); | 241 children.add(childJson['id']); |
| 242 | |
| 243 // Closures are placed in the library namespace, but | |
| 244 // we want to attribute them to a function, and by | |
| 245 // extension, this class. Process and add the sizes | |
| 246 // here. | |
| 247 if (member is MemberElement) { | |
| 248 for (Element closure in member.nestedClosures) { | |
| 249 Map<String, dynamic> child = this.process(closure); | |
| 250 if (child != null) { | |
| 251 size += child['size']; | |
| 252 } | |
| 253 } | |
| 254 } | |
| 242 } | 255 } |
| 243 }); | 256 }); |
| 244 | 257 |
| 245 return { | 258 return { |
| 246 'name': element.name, | 259 'name': element.name, |
| 247 'size': size, | 260 'size': size, |
| 248 'kind': 'class', | 261 'kind': 'class', |
| 249 'modifiers': modifiers, | 262 'modifiers': modifiers, |
| 250 'children': children, | 263 'children': children, |
| 251 'id': id | 264 'id': id |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 'name': parameter.name, | 312 'name': parameter.name, |
| 300 'type': compiler.typesTask | 313 'type': compiler.typesTask |
| 301 .getGuaranteedTypeOfElement(parameter).toString() | 314 .getGuaranteedTypeOfElement(parameter).toString() |
| 302 }); | 315 }); |
| 303 }); | 316 }); |
| 304 inferredReturnType = compiler.typesTask | 317 inferredReturnType = compiler.typesTask |
| 305 .getGuaranteedReturnTypeOfElement(element).toString(); | 318 .getGuaranteedReturnTypeOfElement(element).toString(); |
| 306 sideEffects = compiler.world.getSideEffectsOfElement(element).toString(); | 319 sideEffects = compiler.world.getSideEffectsOfElement(element).toString(); |
| 307 code = emittedCode.toString(); | 320 code = emittedCode.toString(); |
| 308 } | 321 } |
| 309 if (element is MethodElement) { | 322 |
| 310 for (Element closure in element.nestedClosures) { | 323 if (element is MemberElement) { |
| 324 MemberElement member = element as MemberElement; | |
|
floitsch
2014/08/11 16:03:17
no need to write "as ...".
| |
| 325 for (Element closure in member.nestedClosures) { | |
| 311 Map<String, dynamic> child = this.process(closure); | 326 Map<String, dynamic> child = this.process(closure); |
| 312 if (child != null) { | 327 if (child != null) { |
| 313 children.add(child['id']); | 328 children.add(child['id']); |
| 314 size += child['size']; | 329 size += child['size']; |
| 315 } | 330 } |
| 316 } | 331 } |
| 317 } | 332 } |
| 318 | 333 |
| 319 if (size == 0 && !shouldKeep(element)) { | 334 if (size == 0 && !shouldKeep(element)) { |
| 320 return null; | 335 return null; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 }; | 555 }; |
| 541 | 556 |
| 542 outJson['program'] = generalProgramInfo; | 557 outJson['program'] = generalProgramInfo; |
| 543 | 558 |
| 544 ChunkedConversionSink<Object> sink = | 559 ChunkedConversionSink<Object> sink = |
| 545 encoder.startChunkedConversion( | 560 encoder.startChunkedConversion( |
| 546 new StringConversionSink.fromStringSink(buffer)); | 561 new StringConversionSink.fromStringSink(buffer)); |
| 547 sink.add(outJson); | 562 sink.add(outJson); |
| 548 } | 563 } |
| 549 } | 564 } |
| OLD | NEW |