Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: lib/compiler/compiler.dart

Issue 10579019: First shot at source maps generation in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #import('implementation/source_file.dart');
10 #import('implementation/util/source_map_builder.dart');
9 11
10 // Unless explicitly allowed, passing null for any argument to the 12 // Unless explicitly allowed, passing null for any argument to the
11 // methods of library will result in a NullPointerException being 13 // methods of library will result in a NullPointerException being
12 // thrown. 14 // thrown.
13 15
14 /** 16 /**
15 * Returns the source corresponding to [uri]. If no such source exists 17 * Returns the source corresponding to [uri]. If no such source exists
16 * or if an error occur while fetching it, this method must throw an 18 * or if an error occur while fetching it, this method must throw an
17 * exception. 19 * exception.
18 */ 20 */
19 typedef Future<String> ReadUriFromString(Uri uri); 21 typedef Future<String> ReadUriFromString(Uri uri);
20 22
21 /** 23 /**
22 * Invoked by the compiler to report diagnostics. If [uri] is null, so 24 * Invoked by the compiler to report diagnostics. If [uri] is null, so
23 * is [begin] and [end]. No other arguments may be null. If [uri] is 25 * is [begin] and [end]. No other arguments may be null. If [uri] is
24 * not null, neither are [begin] and [end]. [uri] indicates the 26 * not null, neither are [begin] and [end]. [uri] indicates the
25 * compilation unit from where the diagnostic originates. [begin] and 27 * compilation unit from where the diagnostic originates. [begin] and
26 * [end] are zero-based character offsets from the beginning of the 28 * [end] are zero-based character offsets from the beginning of the
27 * compilaton unit. [message] is the diagnostic message, and [fatal] 29 * compilaton unit. [message] is the diagnostic message, and [fatal]
28 * indicates whether or not this diagnostic will prevent the compiler 30 * indicates whether or not this diagnostic will prevent the compiler
29 * from returning null. 31 * from returning null.
30 */ 32 */
31 typedef void DiagnosticHandler(Uri uri, int begin, int end, 33 typedef void DiagnosticHandler(Uri uri, int begin, int end,
32 String message, bool fatal); 34 String message, bool fatal);
33 35
36 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.
37 String code;
38 String sourceMap;
39 CompiledScript(this.code, this.sourceMap);
40 }
41
34 /** 42 /**
35 * Returns [script] compiled to JavaScript. If the compilation fails, 43 * Returns [script] compiled to JavaScript. If the compilation fails,
36 * null is returned and [handler] will have been invoked at least once 44 * null is returned and [handler] will have been invoked at least once
37 * with [:fatal == true:]. 45 * with [:fatal == true:].
38 */ 46 */
39 Future<String> compile(Uri script, 47 Future<CompiledScript> compile(Uri script,
40 Uri libraryRoot, 48 Uri libraryRoot,
41 Uri packageRoot, 49 Uri packageRoot,
42 ReadUriFromString provider, 50 ReadUriFromString provider,
43 DiagnosticHandler handler, 51 DiagnosticHandler handler,
44 [List<String> options = const []]) { 52 [List<String> options = const []]) {
45 Compiler compiler = new Compiler(provider, handler, libraryRoot, packageRoot, 53 Compiler compiler = new Compiler(provider, handler, libraryRoot, packageRoot,
46 options); 54 options);
47 compiler.run(script); 55 compiler.run(script);
48 String code = compiler.assembledCode; 56 String code = compiler.assembledCode;
49 return new Future.immediate(code); 57 SourceFile compiledFile = new SourceFile(null, code);
podivilov 2012/06/19 16:37:54 We could pass SourceMapListener interface/handler
58 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.
59 compiler.backend.emitter.sourceMappings, compiledFile);
60 return new Future.immediate(new CompiledScript(code, sourceMap));
50 } 61 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/dart2js.dart » ('j') | lib/compiler/implementation/dart2js.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698