| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 sourcemap.js_tracer; | 5 library sourcemap.js_tracer; |
| 6 | 6 |
| 7 import 'package:compiler/src/io/source_information.dart'; | 7 import 'package:compiler/src/io/source_information.dart'; |
| 8 import 'package:compiler/src/io/position_information.dart'; | 8 import 'package:compiler/src/io/position_information.dart'; |
| 9 import 'package:compiler/src/js/js.dart' as js; | 9 import 'package:compiler/src/js/js.dart' as js; |
| 10 import 'package:compiler/src/js/js_source_mapping.dart'; |
| 10 import 'sourcemap_helper.dart'; | 11 import 'sourcemap_helper.dart'; |
| 11 import 'trace_graph.dart'; | 12 import 'trace_graph.dart'; |
| 12 | 13 |
| 13 /// Create a [TraceGraph] for [info] registering usage in [coverage]. | 14 /// Create a [TraceGraph] for [info] registering usage in [coverage]. |
| 14 TraceGraph createTraceGraph(SourceMapInfo info, Coverage coverage) { | 15 TraceGraph createTraceGraph(SourceMapInfo info, Coverage coverage) { |
| 15 TraceGraph graph = new TraceGraph(); | 16 TraceGraph graph = new TraceGraph(); |
| 16 TraceListener listener = new StepTraceListener(graph); | 17 TraceListener listener = new StepTraceListener(graph); |
| 17 CodePositionMap codePositions = | 18 CodePositionMap codePositions = |
| 18 new CodePositionCoverage(info.jsCodePositions, coverage); | 19 new CodePositionCoverage(info.jsCodePositions, coverage); |
| 19 JavaScriptTracer tracer = new JavaScriptTracer( | 20 JavaScriptTracer tracer = new JavaScriptTracer( |
| 20 codePositions, [new CoverageListener(coverage), listener]); | 21 codePositions, const SourceInformationReader(), [ |
| 22 new CoverageListener(coverage, const SourceInformationReader()), |
| 23 listener |
| 24 ]); |
| 21 info.node.accept(tracer); | 25 info.node.accept(tracer); |
| 22 return graph; | 26 return graph; |
| 23 } | 27 } |
| 24 | 28 |
| 25 class StepTraceListener extends TraceListener | 29 class StepTraceListener extends TraceListener |
| 26 with NodeToSourceInformationMixin { | 30 with NodeToSourceInformationMixin { |
| 27 Map<js.Node, TraceStep> steppableMap = <js.Node, TraceStep>{}; | 31 Map<js.Node, TraceStep> steppableMap = <js.Node, TraceStep>{}; |
| 28 final TraceGraph graph; | 32 final TraceGraph graph; |
| 29 | 33 |
| 30 StepTraceListener(this.graph); | 34 StepTraceListener(this.graph); |
| 31 | 35 |
| 36 SourceInformationReader get reader => const SourceInformationReader(); |
| 37 |
| 32 @override | 38 @override |
| 33 void onStep(js.Node node, Offset offset, StepKind kind) { | 39 void onStep(js.Node node, Offset offset, StepKind kind) { |
| 34 SourceInformation sourceInformation = computeSourceInformation(node); | 40 SourceInformation sourceInformation = computeSourceInformation(node); |
| 35 SourcePositionKind sourcePositionKind = SourcePositionKind.START; | 41 SourcePositionKind sourcePositionKind = SourcePositionKind.START; |
| 36 List text = [node]; | 42 List text = [node]; |
| 37 switch (kind) { | 43 switch (kind) { |
| 38 case StepKind.FUN_ENTRY: | 44 case StepKind.FUN_ENTRY: |
| 39 text = ['<entry>']; | 45 text = ['<entry>']; |
| 40 break; | 46 break; |
| 41 case StepKind.FUN_EXIT: | 47 case StepKind.FUN_EXIT: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 branch = '$value'; | 132 branch = '$value'; |
| 127 break; | 133 break; |
| 128 } | 134 } |
| 129 graph.pushBranch(branch); | 135 graph.pushBranch(branch); |
| 130 } | 136 } |
| 131 | 137 |
| 132 void popBranch() { | 138 void popBranch() { |
| 133 graph.popBranch(); | 139 graph.popBranch(); |
| 134 } | 140 } |
| 135 } | 141 } |
| OLD | NEW |