OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Test that the CPS IR code generator generates source information. | 5 // Test that the CPS IR code generator generates source information. |
6 | 6 |
7 library source_information_tests; | 7 library source_information_tests; |
8 | 8 |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 class JsSourceInformationVisitor extends js.BaseVisitor { | 116 class JsSourceInformationVisitor extends js.BaseVisitor { |
117 List<String> sourceInformation = <String>[]; | 117 List<String> sourceInformation = <String>[]; |
118 | 118 |
119 @override | 119 @override |
120 visitCall(js.Call node) { | 120 visitCall(js.Call node) { |
121 sourceInformation.add('${node.sourceInformation}'); | 121 sourceInformation.add('${node.sourceInformation}'); |
122 super.visitCall(node); | 122 super.visitCall(node); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 class IrSourceInformationVisitor extends ir.RecursiveVisitor { | 126 class IrSourceInformationVisitor extends ir.TrampolineRecursiveVisitor { |
127 List<String> sourceInformation = <String>[]; | 127 List<String> sourceInformation = <String>[]; |
128 | 128 |
129 @override | 129 @override |
130 processInvokeStatic(ir.InvokeStatic node) { | 130 processInvokeStatic(ir.InvokeStatic node) { |
131 sourceInformation.add('${node.sourceInformation}'); | 131 sourceInformation.add('${node.sourceInformation}'); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 const List<TestEntry> tests = const [ | 135 const List<TestEntry> tests = const [ |
136 const TestEntry(""" | 136 const TestEntry(""" |
137 main() { print('Hello World'); } | 137 main() { print('Hello World'); } |
138 """, const ['memory:test.dart:[1,10]']), | 138 """, const ['memory:test.dart:[1,10]']), |
139 const TestEntry(""" | 139 const TestEntry(""" |
140 main() { | 140 main() { |
141 print('Hello'); | 141 print('Hello'); |
142 print('World'); | 142 print('World'); |
143 } | 143 } |
144 """, const ['memory:test.dart:[2,3]', | 144 """, const ['memory:test.dart:[2,3]', |
145 'memory:test.dart:[3,3]']), | 145 'memory:test.dart:[3,3]']), |
146 ]; | 146 ]; |
147 | 147 |
148 void main() { | 148 void main() { |
149 runTests(tests); | 149 runTests(tests); |
150 } | 150 } |
OLD | NEW |