| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 ir.FunctionDefinition irNodeForMain; | 71 ir.FunctionDefinition irNodeForMain; |
| 72 | 72 |
| 73 void cacheIrNodeForMain(Element function, ir.FunctionDefinition irNode) { | 73 void cacheIrNodeForMain(Element function, ir.FunctionDefinition irNode) { |
| 74 if (function == compiler.mainFunction) { | 74 if (function == compiler.mainFunction) { |
| 75 assert(irNodeForMain == null); | 75 assert(irNodeForMain == null); |
| 76 irNodeForMain = irNode; | 76 irNodeForMain = irNode; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); | 80 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); |
| 81 compiler.irBuilder.builderCallback = cacheIrNodeForMain; | 81 compiler.backend.functionCompiler.cpsBuilderTask.builderCallback = |
| 82 cacheIrNodeForMain; |
| 82 | 83 |
| 83 return compiler.run(uri).then((bool success) { | 84 return compiler.run(uri).then((bool success) { |
| 84 Expect.isTrue(success); | 85 Expect.isTrue(success); |
| 85 | 86 |
| 86 IrSourceInformationVisitor irVisitor = new IrSourceInformationVisitor(); | 87 IrSourceInformationVisitor irVisitor = new IrSourceInformationVisitor(); |
| 87 irNodeForMain.accept(irVisitor); | 88 irNodeForMain.accept(irVisitor); |
| 88 | 89 |
| 89 js.Node jsNode = getJsNodeForElement(compiler, compiler.mainFunction); | 90 js.Node jsNode = getJsNodeForElement(compiler, compiler.mainFunction); |
| 90 JsSourceInformationVisitor jsVisitor = new JsSourceInformationVisitor(); | 91 JsSourceInformationVisitor jsVisitor = new JsSourceInformationVisitor(); |
| 91 jsNode.accept(jsVisitor); | 92 jsNode.accept(jsVisitor); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 print('Hello'); | 141 print('Hello'); |
| 141 print('World'); | 142 print('World'); |
| 142 } | 143 } |
| 143 """, const ['memory:test.dart:[2,3]', | 144 """, const ['memory:test.dart:[2,3]', |
| 144 'memory:test.dart:[3,3]']), | 145 'memory:test.dart:[3,3]']), |
| 145 ]; | 146 ]; |
| 146 | 147 |
| 147 void main() { | 148 void main() { |
| 148 runTests(tests); | 149 runTests(tests); |
| 149 } | 150 } |
| OLD | NEW |