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('mock_compiler'); | 5 #library('mock_compiler'); |
6 | 6 |
7 #import("../../../../lib/uri/uri.dart"); | 7 #import("../../../../lib/uri/uri.dart"); |
8 | 8 |
9 #import("../../../../lib/compiler/implementation/elements/elements.dart"); | 9 #import("../../../../lib/compiler/implementation/elements/elements.dart"); |
10 #import("../../../../lib/compiler/implementation/io/io.dart", prefix: 'io'); | |
11 #import("../../../../lib/compiler/implementation/leg.dart"); | 10 #import("../../../../lib/compiler/implementation/leg.dart"); |
12 #import("../../../../lib/compiler/implementation/tree/tree.dart"); | 11 #import("../../../../lib/compiler/implementation/tree/tree.dart"); |
13 #import("../../../../lib/compiler/implementation/util/util.dart"); | 12 #import("../../../../lib/compiler/implementation/util/util.dart"); |
14 #import("parser_helper.dart"); | 13 #import("parser_helper.dart"); |
15 | 14 |
16 class WarningMessage { | 15 class WarningMessage { |
17 Node node; | 16 Node node; |
18 Message message; | 17 Message message; |
19 WarningMessage(this.node, this.message); | 18 WarningMessage(this.node, this.message); |
20 | 19 |
(...skipping 28 matching lines...) Expand all Loading... |
49 class MockCompiler extends Compiler { | 48 class MockCompiler extends Compiler { |
50 List<WarningMessage> warnings; | 49 List<WarningMessage> warnings; |
51 List<WarningMessage> errors; | 50 List<WarningMessage> errors; |
52 final Map<String, String> sources; | 51 final Map<String, String> sources; |
53 Node parsedTree; | 52 Node parsedTree; |
54 | 53 |
55 MockCompiler([String coreSource = DEFAULT_CORELIB, | 54 MockCompiler([String coreSource = DEFAULT_CORELIB, |
56 String helperSource = DEFAULT_HELPERLIB]) | 55 String helperSource = DEFAULT_HELPERLIB]) |
57 : warnings = [], errors = [], | 56 : warnings = [], errors = [], |
58 sources = new Map<String, String>(), | 57 sources = new Map<String, String>(), |
59 super.withCurrentDirectory(io.getCurrentDirectory()) { | 58 super() { |
60 Uri uri = new Uri(scheme: "source"); | 59 Uri uri = new Uri(scheme: "source"); |
61 var script = new Script(uri, new MockFile(coreSource)); | 60 var script = new Script(uri, new MockFile(coreSource)); |
62 coreLibrary = new LibraryElement(script); | 61 coreLibrary = new LibraryElement(script); |
63 parseScript(coreSource, coreLibrary); | 62 parseScript(coreSource, coreLibrary); |
64 script = new Script(uri, new MockFile(helperSource)); | 63 script = new Script(uri, new MockFile(helperSource)); |
65 jsHelperLibrary = new LibraryElement(script); | 64 jsHelperLibrary = new LibraryElement(script); |
66 parseScript(helperSource, jsHelperLibrary); | 65 parseScript(helperSource, jsHelperLibrary); |
67 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); | 66 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); |
68 mainApp = mockLibrary(this, ""); | 67 mainApp = mockLibrary(this, ""); |
69 initializeSpecialClasses(); | 68 initializeSpecialClasses(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 importLibrary(library, compiler.coreLibrary, compiler); | 184 importLibrary(library, compiler.coreLibrary, compiler); |
186 return library; | 185 return library; |
187 } | 186 } |
188 | 187 |
189 class StringScript extends Script { | 188 class StringScript extends Script { |
190 final String code; | 189 final String code; |
191 StringScript(this.code) : super(null, null); | 190 StringScript(this.code) : super(null, null); |
192 String get text() => code; | 191 String get text() => code; |
193 String get name() => "mock script"; | 192 String get name() => "mock script"; |
194 } | 193 } |
OLD | NEW |