| 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 // Test constant folding. | 4 // Test constant folding. |
| 5 | 5 |
| 6 library compiler_helper; | 6 library compiler_helper; |
| 7 | 7 |
| 8 import "dart:uri"; | 8 import "dart:uri"; |
| 9 | 9 |
| 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t" | 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t" |
| 11 as lego; | 11 as lego; |
| 12 import "../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend
.dart" | 12 import "../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend
.dart" |
| 13 as js; | 13 as js; |
| 14 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart" | 14 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart" |
| 15 as leg; | 15 as leg; |
| 16 import "../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart" as ssa; | 16 import "../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart" as ssa; |
| 17 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart"; | 17 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart"; |
| 18 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; | 18 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; |
| 19 | 19 |
| 20 import "mock_compiler.dart"; | 20 import "mock_compiler.dart"; |
| 21 import "parser_helper.dart"; | 21 import "parser_helper.dart"; |
| 22 | 22 |
| 23 String compile(String code, {String entry: 'main', | 23 String compile(String code, {String entry: 'main', |
| 24 String coreSource: DEFAULT_CORELIB, | 24 String coreSource: DEFAULT_CORELIB, |
| 25 String interceptorsSource: DEFAULT_INTERCEPTORSLIB, |
| 25 bool enableTypeAssertions: false, | 26 bool enableTypeAssertions: false, |
| 26 bool minify: false, | 27 bool minify: false, |
| 27 bool analyzeAll: false}) { | 28 bool analyzeAll: false}) { |
| 28 MockCompiler compiler = | 29 MockCompiler compiler = |
| 29 new MockCompiler(enableTypeAssertions: enableTypeAssertions, | 30 new MockCompiler(enableTypeAssertions: enableTypeAssertions, |
| 30 coreSource: coreSource, | 31 coreSource: coreSource, |
| 32 interceptorsSource: interceptorsSource, |
| 31 enableMinification: minify); | 33 enableMinification: minify); |
| 32 compiler.parseScript(code); | 34 compiler.parseScript(code); |
| 33 lego.Element element = compiler.mainApp.find(buildSourceString(entry)); | 35 lego.Element element = compiler.mainApp.find(buildSourceString(entry)); |
| 34 if (element == null) return null; | 36 if (element == null) return null; |
| 35 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution); | 37 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution); |
| 36 compiler.processQueue(compiler.enqueuer.resolution, element); | 38 compiler.processQueue(compiler.enqueuer.resolution, element); |
| 37 var context = new js.JavaScriptItemCompilationContext(); | 39 var context = new js.JavaScriptItemCompilationContext(); |
| 38 leg.WorkItem work = new leg.WorkItem(element, null, context); | 40 leg.WorkItem work = new leg.WorkItem(element, null, context); |
| 39 work.run(compiler, compiler.enqueuer.codegen); | 41 work.run(compiler, compiler.enqueuer.codegen); |
| 40 return compiler.enqueuer.codegen.lookupCode(element); | 42 return compiler.enqueuer.codegen.lookupCode(element); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 final xRe = new RegExp('\\bx\\b'); | 122 final xRe = new RegExp('\\bx\\b'); |
| 121 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 123 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 122 final spaceRe = new RegExp('\\s+'); | 124 final spaceRe = new RegExp('\\s+'); |
| 123 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 125 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 124 if (shouldMatch) { | 126 if (shouldMatch) { |
| 125 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 127 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 126 } else { | 128 } else { |
| 127 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 129 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 128 } | 130 } |
| 129 } | 131 } |
| OLD | NEW |