| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 mainBuffer.add('$isolateProperties$_=$_{}$N'); | 2258 mainBuffer.add('$isolateProperties$_=$_{}$N'); |
| 2259 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); | 2259 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); |
| 2260 addLazyInitializerFunctionIfNecessary(mainBuffer); | 2260 addLazyInitializerFunctionIfNecessary(mainBuffer); |
| 2261 emitFinishIsolateConstructor(mainBuffer); | 2261 emitFinishIsolateConstructor(mainBuffer); |
| 2262 mainBuffer.add('}\n'); | 2262 mainBuffer.add('}\n'); |
| 2263 compiler.assembledCode = mainBuffer.getText(); | 2263 compiler.assembledCode = mainBuffer.getText(); |
| 2264 | 2264 |
| 2265 if (generateSourceMap) { | 2265 if (generateSourceMap) { |
| 2266 SourceFile compiledFile = new SourceFile(null, compiler.assembledCode); | 2266 SourceFile compiledFile = new SourceFile(null, compiler.assembledCode); |
| 2267 String sourceMap = buildSourceMap(mainBuffer, compiledFile); | 2267 String sourceMap = buildSourceMap(mainBuffer, compiledFile); |
| 2268 // TODO(podivilov): We should find a better way to return source maps to | 2268 compiler.outputProvider('', 'js.map') |
| 2269 // compiler. Using diagnostic handler for that purpose is a temporary | 2269 ..add(sourceMap) |
| 2270 // hack. | 2270 ..close(); |
| 2271 compiler.reportDiagnostic( | |
| 2272 null, sourceMap, new api.Diagnostic(-1, 'source map')); | |
| 2273 } | 2271 } |
| 2274 }); | 2272 }); |
| 2275 return compiler.assembledCode; | 2273 return compiler.assembledCode; |
| 2276 } | 2274 } |
| 2277 | 2275 |
| 2278 String buildSourceMap(CodeBuffer buffer, SourceFile compiledFile) { | 2276 String buildSourceMap(CodeBuffer buffer, SourceFile compiledFile) { |
| 2279 SourceMapBuilder sourceMapBuilder = new SourceMapBuilder(); | 2277 SourceMapBuilder sourceMapBuilder = new SourceMapBuilder(); |
| 2280 buffer.forEachSourceLocation(sourceMapBuilder.addMapping); | 2278 buffer.forEachSourceLocation(sourceMapBuilder.addMapping); |
| 2281 return sourceMapBuilder.build(compiledFile); | 2279 return sourceMapBuilder.build(compiledFile); |
| 2282 } | 2280 } |
| 2283 } | 2281 } |
| 2284 | 2282 |
| 2285 const String GENERATED_BY = """ | 2283 const String GENERATED_BY = """ |
| 2286 // Generated by dart2js, the Dart to JavaScript compiler. | 2284 // Generated by dart2js, the Dart to JavaScript compiler. |
| 2287 """; | 2285 """; |
| 2288 const String HOOKS_API_USAGE = """ | 2286 const String HOOKS_API_USAGE = """ |
| 2289 // The code supports the following hooks: | 2287 // The code supports the following hooks: |
| 2290 // dartPrint(message) - if this function is defined it is called | 2288 // dartPrint(message) - if this function is defined it is called |
| 2291 // instead of the Dart [print] method. | 2289 // instead of the Dart [print] method. |
| 2292 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2290 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2293 // method will not be invoked directly. | 2291 // method will not be invoked directly. |
| 2294 // Instead, a closure that will invoke [main] is | 2292 // Instead, a closure that will invoke [main] is |
| 2295 // passed to [dartMainRunner]. | 2293 // passed to [dartMainRunner]. |
| 2296 """; | 2294 """; |
| OLD | NEW |