Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: pkg/compiler/lib/src/dump_info.dart

Issue 1090243002: Fix dumpInfo: include information for methods that are not in the generated (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 Map<String, dynamic> modifiers = { 299 Map<String, dynamic> modifiers = {
300 'static': element.isStatic, 300 'static': element.isStatic,
301 'const': element.isConst, 301 'const': element.isConst,
302 'factory': element.isFactoryConstructor, 302 'factory': element.isFactoryConstructor,
303 'external': element.isPatched 303 'external': element.isPatched
304 }; 304 };
305 305
306 var enclosingElement = element.enclosingElement; 306 var enclosingElement = element.enclosingElement;
307 if (enclosingElement.isField || 307 if (enclosingElement.isField ||
308 enclosingElement.isFunction || 308 enclosingElement.isFunction ||
sra1 2015/04/17 17:35:45 fix this indentation while you are here. Tabs?
Siggi Cherem (dart-lang) 2015/04/17 17:52:20 Done.
309 element.isClosure || 309 element.isClosure ||
310 enclosingElement.isConstructor) { 310 enclosingElement.isConstructor) {
311 kind = "closure"; 311 kind = "closure";
312 name = "<unnamed>"; 312 name = "<unnamed>";
313 } else if (modifiers['static']) { 313 } else if (modifiers['static']) {
314 kind = 'function'; 314 kind = 'function';
315 } else if (enclosingElement.isClass) { 315 } else if (enclosingElement.isClass) {
316 kind = 'method'; 316 kind = 'method';
317 } 317 }
318 318
319 if (element.isConstructor) { 319 if (element.isConstructor) {
320 name == "" 320 name == ""
321 ? "${element.enclosingElement.name}" 321 ? "${element.enclosingElement.name}"
322 : "${element.enclosingElement.name}.${element.name}"; 322 : "${element.enclosingElement.name}.${element.name}";
323 kind = "constructor"; 323 kind = "constructor";
324 } 324 }
325 325
326 if (emittedCode != null) { 326 if (element.hasFunctionSignature) {
327 FunctionSignature signature = element.functionSignature; 327 FunctionSignature signature = element.functionSignature;
328 returnType = signature.type.returnType.toString();
329 signature.forEachParameter((parameter) { 328 signature.forEachParameter((parameter) {
330 parameters.add({ 329 parameters.add({
331 'name': parameter.name, 330 'name': parameter.name,
332 'type': compiler.typesTask 331 'type': '${compiler.typesTask.getGuaranteedTypeOfElement(parameter)}',
333 .getGuaranteedTypeOfElement(parameter).toString(), 332 'declaredType': '${parameter.node.type}'
334 'declaredType': parameter.node.type.toString()
335 }); 333 });
336 }); 334 });
337 inferredReturnType = compiler.typesTask
338 .getGuaranteedReturnTypeOfElement(element).toString();
339 sideEffects = compiler.world.getSideEffectsOfElement(element).toString();
340 code = emittedCode.toString();
341 } 335 }
342 336
337 if (element.isInstanceMember && !element.isAbstract &&
338 compiler.world.allFunctions.contains(element)) {
339 returnType = '${element.type.returnType}';
340 }
341 inferredReturnType =
342 '${compiler.typesTask.getGuaranteedReturnTypeOfElement(element)}';
343 sideEffects = compiler.world.getSideEffectsOfElement(element).toString();
344
343 if (element is MemberElement) { 345 if (element is MemberElement) {
344 MemberElement member = element as MemberElement; 346 MemberElement member = element as MemberElement;
345 for (Element closure in member.nestedClosures) { 347 for (Element closure in member.nestedClosures) {
346 Map<String, dynamic> child = this.process(closure); 348 Map<String, dynamic> child = this.process(closure);
347 if (child != null) { 349 if (child != null) {
348 child['kind'] = 'closure'; 350 child['kind'] = 'closure';
349 children.add(child['id']); 351 children.add(child['id']);
350 size += child['size']; 352 size += child['size'];
351 } 353 }
352 } 354 }
(...skipping 16 matching lines...) Expand all
369 'name': name, 371 'name': name,
370 'id': id, 372 'id': id,
371 'modifiers': modifiers, 373 'modifiers': modifiers,
372 'children': children, 374 'children': children,
373 'size': size, 375 'size': size,
374 'returnType': returnType, 376 'returnType': returnType,
375 'inferredReturnType': inferredReturnType, 377 'inferredReturnType': inferredReturnType,
376 'parameters': parameters, 378 'parameters': parameters,
377 'sideEffects': sideEffects, 379 'sideEffects': sideEffects,
378 'inlinedCount': inlinedCount, 380 'inlinedCount': inlinedCount,
379 'code': code, 381 'code': emittedCode == null ? null : '$emittedCode',
380 'type': element.type.toString(), 382 'type': element.type.toString(),
381 'outputUnit': mapper._outputUnit.add(outputUnit) 383 'outputUnit': mapper._outputUnit.add(outputUnit)
382 }; 384 };
383 } 385 }
384 } 386 }
385 387
386 class Selection { 388 class Selection {
387 final Element selectedElement; 389 final Element selectedElement;
388 final Selector selector; 390 final Selector selector;
389 Selection(this.selectedElement, this.selector); 391 Selection(this.selectedElement, this.selector);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 StringBuffer jsonBuffer = new StringBuffer(); 546 StringBuffer jsonBuffer = new StringBuffer();
545 dumpInfoJson(jsonBuffer); 547 dumpInfoJson(jsonBuffer);
546 compiler.outputProvider('', 'info.json') 548 compiler.outputProvider('', 'info.json')
547 ..add(jsonBuffer.toString()) 549 ..add(jsonBuffer.toString())
548 ..close(); 550 ..close();
549 }); 551 });
550 } 552 }
551 553
552 554
553 void dumpInfoJson(StringSink buffer) { 555 void dumpInfoJson(StringSink buffer) {
554 JsonEncoder encoder = const JsonEncoder(); 556 JsonEncoder encoder = const JsonEncoder.withIndent(' ');
Siggi Cherem (dart-lang) 2015/04/17 15:52:55 this is not needed, but makes the output easier to
555 DateTime startToJsonTime = new DateTime.now(); 557 DateTime startToJsonTime = new DateTime.now();
556 558
557 Map<String, List<Map<String, String>>> holding = 559 Map<String, List<Map<String, String>>> holding =
558 <String, List<Map<String, String>>>{}; 560 <String, List<Map<String, String>>>{};
559 for (Element fn in infoCollector.mapper.functions) { 561 for (Element fn in infoCollector.mapper.functions) {
560 Iterable<Selection> pulling = getRetaining(fn); 562 Iterable<Selection> pulling = getRetaining(fn);
561 // Don't bother recording an empty list of dependencies. 563 // Don't bother recording an empty list of dependencies.
562 if (pulling.length > 0) { 564 if (pulling.length > 0) {
563 String fnId = infoCollector.idOf(fn); 565 String fnId = infoCollector.idOf(fn);
564 // Some dart2js builtin functions are not 566 // Some dart2js builtin functions are not
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 ChunkedConversionSink<Object> sink = 640 ChunkedConversionSink<Object> sink =
639 encoder.startChunkedConversion( 641 encoder.startChunkedConversion(
640 new StringConversionSink.fromStringSink(buffer)); 642 new StringConversionSink.fromStringSink(buffer));
641 sink.add(outJson); 643 sink.add(outJson);
642 compiler.reportInfo(NO_LOCATION_SPANNABLE, 644 compiler.reportInfo(NO_LOCATION_SPANNABLE,
643 const MessageKind( 645 const MessageKind(
644 "View the dumped .info.json file at " 646 "View the dumped .info.json file at "
645 "https://dart-lang.github.io/dump-info-visualizer")); 647 "https://dart-lang.github.io/dump-info-visualizer"));
646 } 648 }
647 } 649 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698