| OLD | NEW | 
|---|
| 1 // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.js_emitter.startup_emitter.model_emitter; | 5 library dart2js.js_emitter.startup_emitter.model_emitter; | 
| 6 | 6 | 
| 7 import 'dart:convert' show JsonEncoder; | 7 import 'dart:convert' show JsonEncoder; | 
| 8 | 8 | 
| 9 import '../../common.dart'; | 9 import '../../common.dart'; | 
| 10 | 10 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 24 | 24 | 
| 25 import '../../io/source_map_builder.dart' show | 25 import '../../io/source_map_builder.dart' show | 
| 26     SourceMapBuilder; | 26     SourceMapBuilder; | 
| 27 | 27 | 
| 28 import '../../js/js.dart' as js; | 28 import '../../js/js.dart' as js; | 
| 29 import '../../js_backend/js_backend.dart' show | 29 import '../../js_backend/js_backend.dart' show | 
| 30     JavaScriptBackend, | 30     JavaScriptBackend, | 
| 31     Namer, | 31     Namer, | 
| 32     ConstantEmitter; | 32     ConstantEmitter; | 
| 33 | 33 | 
|  | 34 import '../../diagnostics/diagnostic_listener.dart' show | 
|  | 35     DiagnosticReporter; | 
|  | 36 | 
| 34 import '../../diagnostics/spannable.dart' show | 37 import '../../diagnostics/spannable.dart' show | 
| 35     NO_LOCATION_SPANNABLE; | 38     NO_LOCATION_SPANNABLE; | 
| 36 | 39 | 
| 37 import '../../util/uri_extras.dart' show | 40 import '../../util/uri_extras.dart' show | 
| 38     relativize; | 41     relativize; | 
| 39 | 42 | 
| 40 import '../headers.dart'; | 43 import '../headers.dart'; | 
| 41 import '../js_emitter.dart' show NativeEmitter; | 44 import '../js_emitter.dart' show NativeEmitter; | 
| 42 | 45 | 
| 43 import 'package:js_runtime/shared/embedded_names.dart' show | 46 import 'package:js_runtime/shared/embedded_names.dart' show | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93 | 96 | 
| 94   ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter, | 97   ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter, | 
| 95                this.shouldGenerateSourceMap) | 98                this.shouldGenerateSourceMap) | 
| 96       : this.compiler = compiler, | 99       : this.compiler = compiler, | 
| 97         this.namer = namer { | 100         this.namer = namer { | 
| 98     this.constantEmitter = new ConstantEmitter( | 101     this.constantEmitter = new ConstantEmitter( | 
| 99         compiler, namer, this.generateConstantReference, | 102         compiler, namer, this.generateConstantReference, | 
| 100         constantListGenerator); | 103         constantListGenerator); | 
| 101   } | 104   } | 
| 102 | 105 | 
|  | 106   DiagnosticReporter get reporter => compiler.reporter; | 
|  | 107 | 
| 103   js.Expression constantListGenerator(js.Expression array) { | 108   js.Expression constantListGenerator(js.Expression array) { | 
| 104     // TODO(floitsch): remove hard-coded name. | 109     // TODO(floitsch): remove hard-coded name. | 
| 105     return js.js('makeConstList(#)', [array]); | 110     return js.js('makeConstList(#)', [array]); | 
| 106   } | 111   } | 
| 107 | 112 | 
| 108   js.Expression generateEmbeddedGlobalAccess(String global) { | 113   js.Expression generateEmbeddedGlobalAccess(String global) { | 
| 109     return js.js(generateEmbeddedGlobalAccessString(global)); | 114     return js.js(generateEmbeddedGlobalAccessString(global)); | 
| 110   } | 115   } | 
| 111 | 116 | 
| 112   String generateEmbeddedGlobalAccessString(String global) { | 117   String generateEmbeddedGlobalAccessString(String global) { | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 204     // tokens in the main-fragment. | 209     // tokens in the main-fragment. | 
| 205     deferredHashTokens.forEach((DeferredFragment key, | 210     deferredHashTokens.forEach((DeferredFragment key, | 
| 206                                 _DeferredFragmentHash token) { | 211                                 _DeferredFragmentHash token) { | 
| 207       token.setHash(hunkHashes[key]); | 212       token.setHash(hunkHashes[key]); | 
| 208     }); | 213     }); | 
| 209 | 214 | 
| 210     writeMainFragment(mainFragment, mainCode); | 215     writeMainFragment(mainFragment, mainCode); | 
| 211 | 216 | 
| 212     if (backend.requiresPreamble && | 217     if (backend.requiresPreamble && | 
| 213         !backend.htmlLibraryIsLoaded) { | 218         !backend.htmlLibraryIsLoaded) { | 
| 214       compiler.reportHintMessage( | 219       reporter.reportHintMessage( | 
| 215           NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); | 220           NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); | 
| 216     } | 221     } | 
| 217 | 222 | 
| 218     if (compiler.deferredMapUri != null) { | 223     if (compiler.deferredMapUri != null) { | 
| 219       writeDeferredMap(); | 224       writeDeferredMap(); | 
| 220     } | 225     } | 
| 221 | 226 | 
| 222     // Return the total program size. | 227     // Return the total program size. | 
| 223     return outputBuffers.values.fold(0, (a, b) => a + b.length); | 228     return outputBuffers.values.fold(0, (a, b) => a + b.length); | 
| 224   } | 229   } | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 402     // Json does not support comments, so we embed the explanation in the | 407     // Json does not support comments, so we embed the explanation in the | 
| 403     // data. | 408     // data. | 
| 404     mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 409     mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 
| 405         "needed for a given deferred library import."; | 410         "needed for a given deferred library import."; | 
| 406     mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 411     mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 
| 407     compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map') | 412     compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map') | 
| 408       ..add(const JsonEncoder.withIndent("  ").convert(mapping)) | 413       ..add(const JsonEncoder.withIndent("  ").convert(mapping)) | 
| 409       ..close(); | 414       ..close(); | 
| 410   } | 415   } | 
| 411 } | 416 } | 
| OLD | NEW | 
|---|