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 for (Element closure in member.nestedClosures) { | |
| 248 Map<String, dynamic> child = this.process(closure); | |
|
sra1
2014/08/04 23:25:59
Does this cause the closure to be processed twice?
Ty Overby (Google)
2014/08/04 23:32:01
The `process` function is memoized. It actually e
| |
| 249 if (child != null) { | |
| 250 size += child['size']; | |
| 251 } | |
| 252 } | |
| 242 } | 253 } |
| 243 }); | 254 }); |
| 244 | 255 |
| 245 return { | 256 return { |
| 246 'name': element.name, | 257 'name': element.name, |
| 247 'size': size, | 258 'size': size, |
| 248 'kind': 'class', | 259 'kind': 'class', |
| 249 'modifiers': modifiers, | 260 'modifiers': modifiers, |
| 250 'children': children, | 261 'children': children, |
| 251 'id': id | 262 'id': id |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 'name': parameter.name, | 310 'name': parameter.name, |
| 300 'type': compiler.typesTask | 311 'type': compiler.typesTask |
| 301 .getGuaranteedTypeOfElement(parameter).toString() | 312 .getGuaranteedTypeOfElement(parameter).toString() |
| 302 }); | 313 }); |
| 303 }); | 314 }); |
| 304 inferredReturnType = compiler.typesTask | 315 inferredReturnType = compiler.typesTask |
| 305 .getGuaranteedReturnTypeOfElement(element).toString(); | 316 .getGuaranteedReturnTypeOfElement(element).toString(); |
| 306 sideEffects = compiler.world.getSideEffectsOfElement(element).toString(); | 317 sideEffects = compiler.world.getSideEffectsOfElement(element).toString(); |
| 307 code = emittedCode.toString(); | 318 code = emittedCode.toString(); |
| 308 } | 319 } |
| 309 if (element is MethodElement) { | 320 |
| 310 for (Element closure in element.nestedClosures) { | 321 for (Element closure in element.nestedClosures) { |
| 311 Map<String, dynamic> child = this.process(closure); | 322 Map<String, dynamic> child = this.process(closure); |
| 312 if (child != null) { | 323 if (child != null) { |
| 313 children.add(child['id']); | 324 children.add(child['id']); |
| 314 size += child['size']; | 325 size += child['size']; |
| 315 } | |
| 316 } | 326 } |
| 317 } | 327 } |
| 318 | 328 |
| 319 if (size == 0 && !shouldKeep(element)) { | 329 if (size == 0 && !shouldKeep(element)) { |
| 320 return null; | 330 return null; |
| 321 } | 331 } |
| 322 | 332 |
| 323 return { | 333 return { |
| 324 'kind': kind, | 334 'kind': kind, |
| 325 'name': name, | 335 'name': name, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 }; | 550 }; |
| 541 | 551 |
| 542 outJson['program'] = generalProgramInfo; | 552 outJson['program'] = generalProgramInfo; |
| 543 | 553 |
| 544 ChunkedConversionSink<Object> sink = | 554 ChunkedConversionSink<Object> sink = |
| 545 encoder.startChunkedConversion( | 555 encoder.startChunkedConversion( |
| 546 new StringConversionSink.fromStringSink(buffer)); | 556 new StringConversionSink.fromStringSink(buffer)); |
| 547 sink.add(outJson); | 557 sink.add(outJson); |
| 548 } | 558 } |
| 549 } | 559 } |
| OLD | NEW |