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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 TypedefInfo visitTypedefElement(TypedefElement element, _) { | 108 TypedefInfo visitTypedefElement(TypedefElement element, _) { |
109 if (!element.isResolved) return null; | 109 if (!element.isResolved) return null; |
110 TypedefInfo info = new TypedefInfo( | 110 TypedefInfo info = new TypedefInfo( |
111 element.name, '${element.alias}', _unitInfoForElement(element)); | 111 element.name, '${element.alias}', _unitInfoForElement(element)); |
112 _elementToInfo[element] = info; | 112 _elementToInfo[element] = info; |
113 result.typedefs.add(info); | 113 result.typedefs.add(info); |
114 return info; | 114 return info; |
115 } | 115 } |
116 | 116 |
117 FieldInfo visitFieldElement(FieldElement element, _) { | 117 FieldInfo visitFieldElement(FieldElement element, _) { |
118 TypeMask inferredType = | 118 TypeMask inferredType = compiler.globalInference.results.typeOf(element); |
119 compiler.globalInference.getGuaranteedTypeOfElement(element); | |
120 // If a field has an empty inferred type it is never used. | 119 // If a field has an empty inferred type it is never used. |
121 if (inferredType == null || inferredType.isEmpty) return null; | 120 if (inferredType == null || inferredType.isEmpty) return null; |
122 | 121 |
123 int size = compiler.dumpInfoTask.sizeOf(element); | 122 int size = compiler.dumpInfoTask.sizeOf(element); |
124 String code = compiler.dumpInfoTask.codeOf(element); | 123 String code = compiler.dumpInfoTask.codeOf(element); |
125 if (code != null) size += code.length; | 124 if (code != null) size += code.length; |
126 | 125 |
127 FieldInfo info = new FieldInfo( | 126 FieldInfo info = new FieldInfo( |
128 name: element.name, | 127 name: element.name, |
129 // We use element.hashCode because it is globally unique and it is | 128 // We use element.hashCode because it is globally unique and it is |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 isFactory: element.isFactoryConstructor, | 249 isFactory: element.isFactoryConstructor, |
251 isExternal: element.isPatched); | 250 isExternal: element.isPatched); |
252 String code = compiler.dumpInfoTask.codeOf(element); | 251 String code = compiler.dumpInfoTask.codeOf(element); |
253 | 252 |
254 List<ParameterInfo> parameters = <ParameterInfo>[]; | 253 List<ParameterInfo> parameters = <ParameterInfo>[]; |
255 if (element.hasFunctionSignature) { | 254 if (element.hasFunctionSignature) { |
256 FunctionSignature signature = element.functionSignature; | 255 FunctionSignature signature = element.functionSignature; |
257 signature.forEachParameter((parameter) { | 256 signature.forEachParameter((parameter) { |
258 parameters.add(new ParameterInfo( | 257 parameters.add(new ParameterInfo( |
259 parameter.name, | 258 parameter.name, |
260 '${compiler.globalInference.getGuaranteedTypeOfElement(parameter)}', | 259 '${compiler.globalInference.results.typeOf(parameter)}', |
261 '${parameter.node.type}')); | 260 '${parameter.node.type}')); |
262 }); | 261 }); |
263 } | 262 } |
264 | 263 |
265 String returnType = null; | 264 String returnType = null; |
266 // TODO(sigmund): why all these checks? | 265 // TODO(sigmund): why all these checks? |
267 if (element.isInstanceMember && | 266 if (element.isInstanceMember && |
268 !element.isAbstract && | 267 !element.isAbstract && |
269 compiler.world.allFunctions.contains(element)) { | 268 compiler.world.allFunctions.contains(element)) { |
270 returnType = '${element.type.returnType}'; | 269 returnType = '${element.type.returnType}'; |
271 } | 270 } |
272 String inferredReturnType = | 271 String inferredReturnType = |
273 '${compiler.globalInference.getGuaranteedReturnTypeOfElement(element)}'; | 272 '${compiler.globalInference.results.returnTypeOf(element)}'; |
274 String sideEffects = '${compiler.world.getSideEffectsOfElement(element)}'; | 273 String sideEffects = '${compiler.world.getSideEffectsOfElement(element)}'; |
275 | 274 |
276 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; | 275 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; |
277 if (inlinedCount == null) inlinedCount = 0; | 276 if (inlinedCount == null) inlinedCount = 0; |
278 | 277 |
279 FunctionInfo info = new FunctionInfo( | 278 FunctionInfo info = new FunctionInfo( |
280 name: name, | 279 name: name, |
281 functionKind: kind, | 280 functionKind: kind, |
282 // We use element.hashCode because it is globally unique and it is | 281 // We use element.hashCode because it is globally unique and it is |
283 // available while we are doing codegen. | 282 // available while we are doing codegen. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 585 |
587 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 586 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
588 new StringConversionSink.fromStringSink(buffer)); | 587 new StringConversionSink.fromStringSink(buffer)); |
589 sink.add(new AllInfoJsonCodec().encode(result)); | 588 sink.add(new AllInfoJsonCodec().encode(result)); |
590 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 589 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
591 'text': "View the dumped .info.json file at " | 590 'text': "View the dumped .info.json file at " |
592 "https://dart-lang.github.io/dump-info-visualizer" | 591 "https://dart-lang.github.io/dump-info-visualizer" |
593 }); | 592 }); |
594 } | 593 } |
595 } | 594 } |
OLD | NEW |