| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution); | 40 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution); |
| 41 compiler.processQueue(compiler.enqueuer.resolution, element); | 41 compiler.processQueue(compiler.enqueuer.resolution, element); |
| 42 var context = new js.JavaScriptItemCompilationContext(); | 42 var context = new js.JavaScriptItemCompilationContext(); |
| 43 leg.ResolutionWorkItem resolutionWork = | 43 leg.ResolutionWorkItem resolutionWork = |
| 44 new leg.ResolutionWorkItem(element, context); | 44 new leg.ResolutionWorkItem(element, context); |
| 45 resolutionWork.run(compiler, compiler.enqueuer.resolution); | 45 resolutionWork.run(compiler, compiler.enqueuer.resolution); |
| 46 leg.CodegenWorkItem work = | 46 leg.CodegenWorkItem work = |
| 47 new leg.CodegenWorkItem(element, resolutionWork.resolutionTree, context); | 47 new leg.CodegenWorkItem(element, resolutionWork.resolutionTree, context); |
| 48 compiler.phase = Compiler.PHASE_COMPILING; | 48 compiler.phase = Compiler.PHASE_COMPILING; |
| 49 work.run(compiler, compiler.enqueuer.codegen); | 49 work.run(compiler, compiler.enqueuer.codegen); |
| 50 return compiler.enqueuer.codegen.assembleCode(element); | 50 js.JavaScriptBackend backend = compiler.backend; |
| 51 return backend.assembleCode(element); |
| 51 } | 52 } |
| 52 | 53 |
| 53 MockCompiler compilerFor(String code, Uri uri, | 54 MockCompiler compilerFor(String code, Uri uri, |
| 54 {bool analyzeAll: false, | 55 {bool analyzeAll: false, |
| 55 String coreSource: DEFAULT_CORELIB}) { | 56 String coreSource: DEFAULT_CORELIB}) { |
| 56 MockCompiler compiler = new MockCompiler( | 57 MockCompiler compiler = new MockCompiler( |
| 57 analyzeAll: analyzeAll, coreSource: coreSource); | 58 analyzeAll: analyzeAll, coreSource: coreSource); |
| 58 compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code); | 59 compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code); |
| 59 return compiler; | 60 return compiler; |
| 60 } | 61 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 final xRe = new RegExp('\\bx\\b'); | 134 final xRe = new RegExp('\\bx\\b'); |
| 134 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 135 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 135 final spaceRe = new RegExp('\\s+'); | 136 final spaceRe = new RegExp('\\s+'); |
| 136 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 137 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 137 if (shouldMatch) { | 138 if (shouldMatch) { |
| 138 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 139 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 139 } else { | 140 } else { |
| 140 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 141 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 141 } | 142 } |
| 142 } | 143 } |
| OLD | NEW |