| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 compiler_helper; | 5 library compiler_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 import 'package:compiler/src/elements/elements.dart' | 10 import 'package:compiler/src/elements/elements.dart' |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (minify) { | 105 if (minify) { |
| 106 options.add(Flags.minify); | 106 options.add(Flags.minify); |
| 107 } | 107 } |
| 108 if (analyzeAll) { | 108 if (analyzeAll) { |
| 109 options.add(Flags.analyzeAll); | 109 options.add(Flags.analyzeAll); |
| 110 } | 110 } |
| 111 if (trustJSInteropTypeAnnotations) { | 111 if (trustJSInteropTypeAnnotations) { |
| 112 options.add(Flags.trustJSInteropTypeAnnotations); | 112 options.add(Flags.trustJSInteropTypeAnnotations); |
| 113 } | 113 } |
| 114 | 114 |
| 115 if (disableInlining) { |
| 116 options.add(Flags.disableInlining); |
| 117 } |
| 118 |
| 115 Map<String, String> source; | 119 Map<String, String> source; |
| 116 if (entry != 'main') { | 120 if (entry != 'main') { |
| 117 source = {'main.dart': "$code\n\nmain() => $entry;" }; | 121 source = {'main.dart': "$code\n\nmain() => $entry;" }; |
| 118 } else { | 122 } else { |
| 119 source = {'main.dart': code}; | 123 source = {'main.dart': code}; |
| 120 } | 124 } |
| 121 | 125 |
| 122 CompilationResult result = await runCompiler( | 126 CompilationResult result = await runCompiler( |
| 123 memorySourceFiles: source, | 127 memorySourceFiles: source, |
| 124 options: options, | 128 options: options, |
| 125 outputProvider: outputCollector, | 129 outputProvider: outputCollector); |
| 126 beforeRun: (compiler) { | |
| 127 if (disableInlining) { | |
| 128 compiler.disableInlining = true; | |
| 129 } | |
| 130 }); | |
| 131 Expect.isTrue(result.isSuccess); | 130 Expect.isTrue(result.isSuccess); |
| 132 Compiler compiler = result.compiler; | 131 Compiler compiler = result.compiler; |
| 133 lego.Element element = compiler.mainApp.find(entry); | 132 lego.Element element = compiler.mainApp.find(entry); |
| 134 js.JavaScriptBackend backend = compiler.backend; | 133 js.JavaScriptBackend backend = compiler.backend; |
| 135 String generated = backend.getGeneratedCode(element); | 134 String generated = backend.getGeneratedCode(element); |
| 136 if (check != null) { | 135 if (check != null) { |
| 137 check(generated); | 136 check(generated); |
| 138 } | 137 } |
| 139 return returnAll ? outputCollector.getOutput('', 'js') : generated; | 138 return returnAll ? outputCollector.getOutput('', 'js') : generated; |
| 140 } | 139 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 290 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 292 final spaceRe = new RegExp('\\s+'); | 291 final spaceRe = new RegExp('\\s+'); |
| 293 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 292 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 294 if (shouldMatch) { | 293 if (shouldMatch) { |
| 295 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 294 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 296 } else { | 295 } else { |
| 297 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 296 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 298 } | 297 } |
| 299 }); | 298 }); |
| 300 } | 299 } |
| OLD | NEW |