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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart

Issue 1653453002: Don't use "var" to introduce the deferred_initializer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add test. Created 4 years, 10 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/native/native.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'package:js_runtime/shared/embedded_names.dart' show 9 import 'package:js_runtime/shared/embedded_names.dart' show
10 CLASS_FIELDS_EXTRACTOR, 10 CLASS_FIELDS_EXTRACTOR,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 Map<DeferredFragment, String> hunkHashes = <DeferredFragment, String>{}; 245 Map<DeferredFragment, String> hunkHashes = <DeferredFragment, String>{};
246 246
247 fragmentsCode.forEach((DeferredFragment fragment, js.Expression code) { 247 fragmentsCode.forEach((DeferredFragment fragment, js.Expression code) {
248 hunkHashes[fragment] = writeDeferredFragment(fragment, code); 248 hunkHashes[fragment] = writeDeferredFragment(fragment, code);
249 }); 249 });
250 250
251 return hunkHashes; 251 return hunkHashes;
252 } 252 }
253 253
254 js.Statement buildDeferredInitializerGlobal() { 254 js.Statement buildDeferredInitializerGlobal() {
255 String global = deferredInitializersGlobal; 255 return js.js.statement('self.#deferredInitializers = '
256 return js.js.statement( 256 'self.#deferredInitializers || Object.create(null);',
257 "if (typeof($global) === 'undefined') var # = Object.create(null);", 257 {'deferredInitializers': deferredInitializersGlobal});
258 new js.VariableDeclaration(global, allowRename: false));
259 } 258 }
260 259
261 // Writes the given [fragment]'s [code] into a file. 260 // Writes the given [fragment]'s [code] into a file.
262 // 261 //
263 // Updates the shared [outputBuffers] field with the output. 262 // Updates the shared [outputBuffers] field with the output.
264 void writeMainFragment(MainFragment fragment, js.Statement code, 263 void writeMainFragment(MainFragment fragment, js.Statement code,
265 {bool isSplit}) { 264 {bool isSplit}) {
266 LineColumnCollector lineColumnCollector; 265 LineColumnCollector lineColumnCollector;
267 List<CodeOutputListener> codeOutputListeners; 266 List<CodeOutputListener> codeOutputListeners;
268 if (shouldGenerateSourceMap) { 267 if (shouldGenerateSourceMap) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Json does not support comments, so we embed the explanation in the 414 // Json does not support comments, so we embed the explanation in the
416 // data. 415 // data.
417 mapping["_comment"] = "This mapping shows which compiled `.js` files are " 416 mapping["_comment"] = "This mapping shows which compiled `.js` files are "
418 "needed for a given deferred library import."; 417 "needed for a given deferred library import.";
419 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); 418 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap());
420 compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map') 419 compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map')
421 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) 420 ..add(const JsonEncoder.withIndent(" ").convert(mapping))
422 ..close(); 421 ..close();
423 } 422 }
424 } 423 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/native/native.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698