| 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 'sourcemap_helper.dart'; | 10 import 'sourcemap_helper.dart'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 text = ['while(', whileNode.condition, ') ...']; | 75 text = ['while(', whileNode.condition, ') ...']; |
| 76 break; | 76 break; |
| 77 case StepKind.DO_CONDITION: | 77 case StepKind.DO_CONDITION: |
| 78 js.Do doNode = node; | 78 js.Do doNode = node; |
| 79 text = ['do {... } (', doNode.condition, ')']; | 79 text = ['do {... } (', doNode.condition, ')']; |
| 80 break; | 80 break; |
| 81 case StepKind.SWITCH_EXPRESSION: | 81 case StepKind.SWITCH_EXPRESSION: |
| 82 js.Switch switchNode = node; | 82 js.Switch switchNode = node; |
| 83 text = ['switch(', switchNode.key, ') ...']; | 83 text = ['switch(', switchNode.key, ') ...']; |
| 84 break; | 84 break; |
| 85 | |
| 86 } | 85 } |
| 87 createTraceStep( | 86 createTraceStep(kind, node, |
| 88 kind, | |
| 89 node, | |
| 90 offset: offset, | 87 offset: offset, |
| 91 sourceLocation: getSourceLocation( | 88 sourceLocation: |
| 92 sourceInformation, sourcePositionKind), | 89 getSourceLocation(sourceInformation, sourcePositionKind), |
| 93 text: text); | 90 text: text); |
| 94 } | 91 } |
| 95 | 92 |
| 96 void createTraceStep( | 93 void createTraceStep(StepKind kind, js.Node node, |
| 97 StepKind kind, | 94 {Offset offset, List text, String note, SourceLocation sourceLocation}) { |
| 98 js.Node node, | |
| 99 {Offset offset, | |
| 100 List text, | |
| 101 String note, | |
| 102 SourceLocation sourceLocation}) { | |
| 103 int id = steppableMap.length; | 95 int id = steppableMap.length; |
| 104 | 96 |
| 105 if (text == null) { | 97 if (text == null) { |
| 106 text = [node]; | 98 text = [node]; |
| 107 } | 99 } |
| 108 | 100 |
| 109 TraceStep step = new TraceStep( | 101 TraceStep step = |
| 110 kind, | 102 new TraceStep(kind, id, node, offset, text, sourceLocation); |
| 111 id, | |
| 112 node, | |
| 113 offset, | |
| 114 text, | |
| 115 sourceLocation); | |
| 116 graph.addStep(step); | 103 graph.addStep(step); |
| 117 | 104 |
| 118 steppableMap[node] = step; | 105 steppableMap[node] = step; |
| 119 } | 106 } |
| 120 | 107 |
| 121 | |
| 122 void pushBranch(BranchKind kind, [value]) { | 108 void pushBranch(BranchKind kind, [value]) { |
| 123 var branch; | 109 var branch; |
| 124 switch (kind) { | 110 switch (kind) { |
| 125 case BranchKind.CONDITION: | 111 case BranchKind.CONDITION: |
| 126 branch = value ? 't' : 'f'; | 112 branch = value ? 't' : 'f'; |
| 127 break; | 113 break; |
| 128 case BranchKind.LOOP: | 114 case BranchKind.LOOP: |
| 129 branch = 'l'; | 115 branch = 'l'; |
| 130 break; | 116 break; |
| 131 case BranchKind.CATCH: | 117 case BranchKind.CATCH: |
| 132 branch = 'c'; | 118 branch = 'c'; |
| 133 break; | 119 break; |
| 134 case BranchKind.FINALLY: | 120 case BranchKind.FINALLY: |
| 135 branch = 'F'; | 121 branch = 'F'; |
| 136 break; | 122 break; |
| 137 case BranchKind.CASE: | 123 case BranchKind.CASE: |
| 138 branch = '$value'; | 124 branch = '$value'; |
| 139 break; | 125 break; |
| 140 } | 126 } |
| 141 graph.pushBranch(branch); | 127 graph.pushBranch(branch); |
| 142 } | 128 } |
| 143 | 129 |
| 144 void popBranch() { | 130 void popBranch() { |
| 145 graph.popBranch(); | 131 graph.popBranch(); |
| 146 } | 132 } |
| 147 } | 133 } |
| OLD | NEW |