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'); | 5 #library('compiler'); |
6 | 6 |
7 #import('dart:uri'); | 7 #import('dart:uri'); |
8 #import('implementation/apiimpl.dart'); | 8 #import('implementation/apiimpl.dart'); |
9 | 9 |
10 // Unless explicitly allowed, passing [:null:] for any argument to the | 10 // Unless explicitly allowed, passing [:null:] for any argument to the |
(...skipping 25 matching lines...) Expand all Loading... |
36 * the compilation fails, the future's value will be [:null:] and | 36 * the compilation fails, the future's value will be [:null:] and |
37 * [handler] will have been invoked at least once with [:kind == | 37 * [handler] will have been invoked at least once with [:kind == |
38 * Diagnostic.ERROR:] or [:kind == Diagnostic.CRASH:]. | 38 * Diagnostic.ERROR:] or [:kind == Diagnostic.CRASH:]. |
39 */ | 39 */ |
40 Future<String> compile(Uri script, | 40 Future<String> compile(Uri script, |
41 Uri libraryRoot, | 41 Uri libraryRoot, |
42 Uri packageRoot, | 42 Uri packageRoot, |
43 ReadStringFromUri provider, | 43 ReadStringFromUri provider, |
44 DiagnosticHandler handler, | 44 DiagnosticHandler handler, |
45 [List<String> options = const []]) { | 45 [List<String> options = const []]) { |
46 if (!libraryRoot.path.endsWith("/")) { | |
47 throw new ArgumentError("libraryRoot must end with a /"); | |
48 } | |
49 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | |
50 throw new ArgumentError("packageRoot must end with a /"); | |
51 } | |
52 // TODO(ahe): Consider completing the future with an exception if | 46 // TODO(ahe): Consider completing the future with an exception if |
53 // code is null. | 47 // code is null. |
54 Compiler compiler = new Compiler(provider, handler, libraryRoot, packageRoot, | 48 Compiler compiler = new Compiler(provider, handler, libraryRoot, packageRoot, |
55 options); | 49 options); |
56 compiler.run(script); | 50 compiler.run(script); |
57 String code = compiler.assembledCode; | 51 String code = compiler.assembledCode; |
58 return new Future.immediate(code); | 52 return new Future.immediate(code); |
59 } | 53 } |
60 | 54 |
61 /** | 55 /** |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 final String name; | 112 final String name; |
119 | 113 |
120 /** | 114 /** |
121 * This constructor is not private to support user-defined | 115 * This constructor is not private to support user-defined |
122 * diagnostic kinds. | 116 * diagnostic kinds. |
123 */ | 117 */ |
124 const Diagnostic(this.ordinal, this.name); | 118 const Diagnostic(this.ordinal, this.name); |
125 | 119 |
126 String toString() => name; | 120 String toString() => name; |
127 } | 121 } |
OLD | NEW |