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' | 7 import 'dart:convert' |
8 show ChunkedConversionSink, JsonEncoder, StringConversionSink; | 8 show ChunkedConversionSink, JsonEncoder, StringConversionSink; |
9 | 9 |
10 import 'package:dart2js_info/info.dart'; | 10 import 'package:dart2js_info/info.dart'; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 result.typedefs.add(info); | 118 result.typedefs.add(info); |
119 return info; | 119 return info; |
120 } | 120 } |
121 | 121 |
122 _resultOfMember(MemberElement e) => | 122 _resultOfMember(MemberElement e) => |
123 compiler.globalInference.results.resultOfMember(e); | 123 compiler.globalInference.results.resultOfMember(e); |
124 | 124 |
125 _resultOfParameter(ParameterElement e) => | 125 _resultOfParameter(ParameterElement e) => |
126 compiler.globalInference.results.resultOfParameter(e); | 126 compiler.globalInference.results.resultOfParameter(e); |
127 | 127 |
128 @deprecated | |
129 _resultOfElement(AstElement e) => | |
130 compiler.globalInference.results.resultOfElement(e); | |
131 | |
132 FieldInfo visitFieldElement(FieldElement element, _) { | 128 FieldInfo visitFieldElement(FieldElement element, _) { |
133 TypeMask inferredType = _resultOfMember(element).type; | 129 TypeMask inferredType = _resultOfMember(element).type; |
134 // If a field has an empty inferred type it is never used. | 130 // If a field has an empty inferred type it is never used. |
135 if (inferredType == null || inferredType.isEmpty) return null; | 131 if (inferredType == null || inferredType.isEmpty) return null; |
136 | 132 |
137 int size = compiler.dumpInfoTask.sizeOf(element); | 133 int size = compiler.dumpInfoTask.sizeOf(element); |
138 String code = compiler.dumpInfoTask.codeOf(element); | 134 String code = compiler.dumpInfoTask.codeOf(element); |
139 if (code != null) size += code.length; | 135 if (code != null) size += code.length; |
140 | 136 |
141 FieldInfo info = new FieldInfo( | 137 FieldInfo info = new FieldInfo( |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 List<ParameterInfo> parameters = <ParameterInfo>[]; | 263 List<ParameterInfo> parameters = <ParameterInfo>[]; |
268 if (element.hasFunctionSignature) { | 264 if (element.hasFunctionSignature) { |
269 FunctionSignature signature = element.functionSignature; | 265 FunctionSignature signature = element.functionSignature; |
270 signature.forEachParameter((parameter) { | 266 signature.forEachParameter((parameter) { |
271 parameters.add(new ParameterInfo(parameter.name, | 267 parameters.add(new ParameterInfo(parameter.name, |
272 '${_resultOfParameter(parameter).type}', '${parameter.node.type}')); | 268 '${_resultOfParameter(parameter).type}', '${parameter.node.type}')); |
273 }); | 269 }); |
274 returnType = '${element.type.returnType}'; | 270 returnType = '${element.type.returnType}'; |
275 } | 271 } |
276 | 272 |
277 String inferredReturnType = '${_resultOfElement(element).returnType}'; | 273 MethodElement method; |
| 274 if (element is LocalFunctionElement) { |
| 275 method = element.callMethod; |
| 276 } else { |
| 277 method = element; |
| 278 } |
| 279 |
| 280 String inferredReturnType = '${_resultOfMember(method).returnType}'; |
278 String sideEffects = '${closedWorld.getSideEffectsOfElement(element)}'; | 281 String sideEffects = '${closedWorld.getSideEffectsOfElement(element)}'; |
279 | 282 |
280 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; | 283 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; |
281 if (inlinedCount == null) inlinedCount = 0; | 284 if (inlinedCount == null) inlinedCount = 0; |
282 | 285 |
283 FunctionInfo info = new FunctionInfo( | 286 FunctionInfo info = new FunctionInfo( |
284 name: name, | 287 name: name, |
285 functionKind: kind, | 288 functionKind: kind, |
286 modifiers: modifiers, | 289 modifiers: modifiers, |
287 returnType: returnType, | 290 returnType: returnType, |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 617 |
615 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 618 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
616 new StringConversionSink.fromStringSink(buffer)); | 619 new StringConversionSink.fromStringSink(buffer)); |
617 sink.add(new AllInfoJsonCodec().encode(result)); | 620 sink.add(new AllInfoJsonCodec().encode(result)); |
618 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 621 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
619 'text': "View the dumped .info.json file at " | 622 'text': "View the dumped .info.json file at " |
620 "https://dart-lang.github.io/dump-info-visualizer" | 623 "https://dart-lang.github.io/dump-info-visualizer" |
621 }); | 624 }); |
622 } | 625 } |
623 } | 626 } |
OLD | NEW |