Chromium Code Reviews| Index: lib/compiler/compiler.dart |
| diff --git a/lib/compiler/compiler.dart b/lib/compiler/compiler.dart |
| index 4038fad3606ba13f5963af77807f6fcf7c9e30ca..3eb2d359fc251f79639a7c002019415c27a2ff93 100644 |
| --- a/lib/compiler/compiler.dart |
| +++ b/lib/compiler/compiler.dart |
| @@ -6,6 +6,8 @@ |
| #import('dart:uri'); |
| #import('implementation/apiimpl.dart'); |
| +#import('implementation/source_file.dart'); |
| +#import('implementation/util/source_map_builder.dart'); |
| // Unless explicitly allowed, passing null for any argument to the |
| // methods of library will result in a NullPointerException being |
| @@ -31,20 +33,29 @@ typedef Future<String> ReadUriFromString(Uri uri); |
| typedef void DiagnosticHandler(Uri uri, int begin, int end, |
| String message, bool fatal); |
| +class CompiledScript { |
|
podivilov
2012/06/19 16:37:54
This is ugly, not sure how to return sourceMap fro
ahe
2012/06/19 17:00:41
Yes. Johnni will handle that.
In the meantime, ho
podivilov
2012/06/20 09:37:14
Done.
|
| + String code; |
| + String sourceMap; |
| + CompiledScript(this.code, this.sourceMap); |
| +} |
| + |
| /** |
| * Returns [script] compiled to JavaScript. If the compilation fails, |
| * null is returned and [handler] will have been invoked at least once |
| * with [:fatal == true:]. |
| */ |
| -Future<String> compile(Uri script, |
| - Uri libraryRoot, |
| - Uri packageRoot, |
| - ReadUriFromString provider, |
| - DiagnosticHandler handler, |
| - [List<String> options = const []]) { |
| +Future<CompiledScript> compile(Uri script, |
| + Uri libraryRoot, |
| + Uri packageRoot, |
| + ReadUriFromString provider, |
| + DiagnosticHandler handler, |
| + [List<String> options = const []]) { |
| Compiler compiler = new Compiler(provider, handler, libraryRoot, packageRoot, |
| options); |
| compiler.run(script); |
| String code = compiler.assembledCode; |
| - return new Future.immediate(code); |
| + SourceFile compiledFile = new SourceFile(null, code); |
|
podivilov
2012/06/19 16:37:54
We could pass SourceMapListener interface/handler
|
| + String sourceMap = new SourceMapBuilder().build( |
|
ahe
2012/06/19 17:00:41
This code does not belong here. I think the source
podivilov
2012/06/20 09:37:14
Done.
|
| + compiler.backend.emitter.sourceMappings, compiledFile); |
| + return new Future.immediate(new CompiledScript(code, sourceMap)); |
| } |