Chromium Code Reviews| 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 #import("../../../lib/compiler/implementation/leg.dart", prefix: "leg"); | 9 #import("../../../lib/compiler/implementation/leg.dart", prefix: "leg"); |
| 10 #import("../../../lib/compiler/implementation/elements/elements.dart", prefix: " lego"); | 10 #import("../../../lib/compiler/implementation/elements/elements.dart", prefix: " lego"); |
| 11 #import("../../../lib/compiler/implementation/ssa/ssa.dart", prefix: "ssa"); | 11 #import("../../../lib/compiler/implementation/ssa/ssa.dart", prefix: "ssa"); |
| 12 #import("parser_helper.dart"); | 12 #import("parser_helper.dart"); |
| 13 #import("mock_compiler.dart"); | 13 #import("mock_compiler.dart"); |
| 14 | 14 |
| 15 String compile(String code, [String entry = 'main']) { | 15 String compile(String code, [String entry = 'main']) { |
| 16 MockCompiler compiler = new MockCompiler(); | 16 MockCompiler compiler = new MockCompiler(); |
| 17 compiler.parseScript(code); | 17 compiler.parseScript(code); |
| 18 lego.Element element = compiler.mainApp.find(buildSourceString(entry)); | 18 lego.Element element = compiler.mainApp.find(buildSourceString(entry)); |
| 19 if (element === null) return null; | 19 if (element === null) return null; |
| 20 String generated = new leg.WorkItem(element, null).run(compiler); | 20 leg.WorkItem work = new leg.WorkItem(element, null); |
| 21 String generated = work.run(compiler, compiler.enqueuer.codegen); | |
|
ahe
2012/05/24 07:24:48
You already reviewed the rest. The changes to this
| |
| 21 return generated; | 22 return generated; |
| 22 } | 23 } |
| 23 | 24 |
| 24 String compileAll(String code) { | 25 String compileAll(String code) { |
| 25 MockCompiler compiler = new MockCompiler(); | 26 MockCompiler compiler = new MockCompiler(); |
| 26 Uri uri = new Uri(scheme: 'source'); | 27 Uri uri = new Uri(scheme: 'source'); |
| 27 compiler.sources[uri.toString()] = code; | 28 compiler.sources[uri.toString()] = code; |
| 28 compiler.runCompiler(uri); | 29 compiler.runCompiler(uri); |
| 29 return compiler.assembledCode; | 30 return compiler.assembledCode; |
| 30 } | 31 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 51 String generated = compile(code, entry); | 52 String generated = compile(code, entry); |
| 52 Expect.isTrue(regexp.hasMatch(generated), | 53 Expect.isTrue(regexp.hasMatch(generated), |
| 53 '"$generated" does not match /$regexp/'); | 54 '"$generated" does not match /$regexp/'); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void compileAndDoNotMatch(String code, String entry, RegExp regexp) { | 57 void compileAndDoNotMatch(String code, String entry, RegExp regexp) { |
| 57 String generated = compile(code, entry); | 58 String generated = compile(code, entry); |
| 58 Expect.isFalse(regexp.hasMatch(generated), | 59 Expect.isFalse(regexp.hasMatch(generated), |
| 59 '"$generated" has a match in /$regexp/'); | 60 '"$generated" has a match in /$regexp/'); |
| 60 } | 61 } |
| OLD | NEW |