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

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

Issue 1803303002: Move all flags to CompilerOptions (first step to stop passing the compiler to (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 writeMainFragment(mainFragment, mainCode, 212 writeMainFragment(mainFragment, mainCode,
213 isSplit: program.deferredFragments.isNotEmpty); 213 isSplit: program.deferredFragments.isNotEmpty);
214 214
215 if (backend.requiresPreamble && 215 if (backend.requiresPreamble &&
216 !backend.htmlLibraryIsLoaded) { 216 !backend.htmlLibraryIsLoaded) {
217 reporter.reportHintMessage( 217 reporter.reportHintMessage(
218 NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); 218 NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE);
219 } 219 }
220 220
221 if (compiler.deferredMapUri != null) { 221 if (compiler.options.deferredMapUri != null) {
222 writeDeferredMap(); 222 writeDeferredMap();
223 } 223 }
224 224
225 // Return the total program size. 225 // Return the total program size.
226 return outputBuffers.values.fold(0, (a, b) => a + b.length); 226 return outputBuffers.values.fold(0, (a, b) => a + b.length);
227 } 227 }
228 228
229 /// Generates a simple header that provides the compiler's build id. 229 /// Generates a simple header that provides the compiler's build id.
230 js.Comment buildGeneratedBy() { 230 js.Comment buildGeneratedBy() {
231 String flavor = compiler.useContentSecurityPolicy 231 String flavor = compiler.options.useContentSecurityPolicy
232 ? 'fast startup, CSP' 232 ? 'fast startup, CSP'
233 : 'fast startup'; 233 : 'fast startup';
234 return new js.Comment(generatedBy(compiler, flavor: flavor)); 234 return new js.Comment(generatedBy(compiler, flavor: flavor));
235 } 235 }
236 236
237 /// Writes all deferred fragment's code into files. 237 /// Writes all deferred fragment's code into files.
238 /// 238 ///
239 /// Returns a map from fragment to its hashcode (as used for the deferred 239 /// Returns a map from fragment to its hashcode (as used for the deferred
240 /// library code). 240 /// library code).
241 /// 241 ///
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 js.Program program = new js.Program([ 277 js.Program program = new js.Program([
278 buildGeneratedBy(), 278 buildGeneratedBy(),
279 new js.Comment(HOOKS_API_USAGE), 279 new js.Comment(HOOKS_API_USAGE),
280 isSplit ? buildDeferredInitializerGlobal() : new js.Block.empty(), 280 isSplit ? buildDeferredInitializerGlobal() : new js.Block.empty(),
281 code]); 281 code]);
282 282
283 mainOutput.addBuffer(js.createCodeBuffer(program, compiler, 283 mainOutput.addBuffer(js.createCodeBuffer(program, compiler,
284 monitor: compiler.dumpInfoTask)); 284 monitor: compiler.dumpInfoTask));
285 285
286 if (shouldGenerateSourceMap) { 286 if (shouldGenerateSourceMap) {
287 mainOutput.add( 287 mainOutput.add(generateSourceMapTag(
288 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); 288 compiler.options.sourceMapUri, compiler.options.outputUri));
289 } 289 }
290 290
291 mainOutput.close(); 291 mainOutput.close();
292 292
293 if (shouldGenerateSourceMap) { 293 if (shouldGenerateSourceMap) {
294 outputSourceMap(mainOutput, lineColumnCollector, '', 294 outputSourceMap(mainOutput, lineColumnCollector, '',
295 compiler.sourceMapUri, compiler.outputUri); 295 compiler.options.sourceMapUri, compiler.options.outputUri);
296 } 296 }
297 } 297 }
298 298
299 // Writes the given [fragment]'s [code] into a file. 299 // Writes the given [fragment]'s [code] into a file.
300 // 300 //
301 // Returns the deferred fragment's hash. 301 // Returns the deferred fragment's hash.
302 // 302 //
303 // Updates the shared [outputBuffers] field with the output. 303 // Updates the shared [outputBuffers] field with the output.
304 String writeDeferredFragment(DeferredFragment fragment, js.Expression code) { 304 String writeDeferredFragment(DeferredFragment fragment, js.Expression code) {
305 List<CodeOutputListener> outputListeners = <CodeOutputListener>[]; 305 List<CodeOutputListener> outputListeners = <CodeOutputListener>[];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // This will be used to retrieve the initializing function from the global 341 // This will be used to retrieve the initializing function from the global
342 // variable. 342 // variable.
343 String hash = hasher.getHash(); 343 String hash = hasher.getHash();
344 344
345 // Now we copy the deferredInitializer.current into its correct hash. 345 // Now we copy the deferredInitializer.current into its correct hash.
346 output.add('\n${deferredInitializersGlobal}["$hash"] = ' 346 output.add('\n${deferredInitializersGlobal}["$hash"] = '
347 '${deferredInitializersGlobal}.current'); 347 '${deferredInitializersGlobal}.current');
348 348
349 if (shouldGenerateSourceMap) { 349 if (shouldGenerateSourceMap) {
350 Uri mapUri, partUri; 350 Uri mapUri, partUri;
351 Uri sourceMapUri = compiler.sourceMapUri; 351 Uri sourceMapUri = compiler.options.sourceMapUri;
352 Uri outputUri = compiler.outputUri; 352 Uri outputUri = compiler.options.outputUri;
353 String partName = "$hunkPrefix.$partExtension"; 353 String partName = "$hunkPrefix.$partExtension";
354 String hunkFileName = "$hunkPrefix.$deferredExtension"; 354 String hunkFileName = "$hunkPrefix.$deferredExtension";
355 355
356 if (sourceMapUri != null) { 356 if (sourceMapUri != null) {
357 String mapFileName = hunkFileName + ".map"; 357 String mapFileName = hunkFileName + ".map";
358 List<String> mapSegments = sourceMapUri.pathSegments.toList(); 358 List<String> mapSegments = sourceMapUri.pathSegments.toList();
359 mapSegments[mapSegments.length - 1] = mapFileName; 359 mapSegments[mapSegments.length - 1] = mapFileName;
360 mapUri = compiler.sourceMapUri.replace(pathSegments: mapSegments); 360 mapUri = compiler.options.sourceMapUri
361 .replace(pathSegments: mapSegments);
361 } 362 }
362 363
363 if (outputUri != null) { 364 if (outputUri != null) {
364 List<String> partSegments = outputUri.pathSegments.toList(); 365 List<String> partSegments = outputUri.pathSegments.toList();
365 partSegments[partSegments.length - 1] = hunkFileName; 366 partSegments[partSegments.length - 1] = hunkFileName;
366 partUri = compiler.outputUri.replace(pathSegments: partSegments); 367 partUri = compiler.options.outputUri
368 .replace(pathSegments: partSegments);
367 } 369 }
368 370
369 output.add(generateSourceMapTag(mapUri, partUri)); 371 output.add(generateSourceMapTag(mapUri, partUri));
370 output.close(); 372 output.close();
371 outputSourceMap(output, lineColumnCollector, partName, mapUri, partUri); 373 outputSourceMap(output, lineColumnCollector, partName, mapUri, partUri);
372 } else { 374 } else {
373 output.close(); 375 output.close();
374 } 376 }
375 377
376 return hash; 378 return hash;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 /// 411 ///
410 /// The output is written into a separate file that can be used by outside 412 /// The output is written into a separate file that can be used by outside
411 /// tools. 413 /// tools.
412 void writeDeferredMap() { 414 void writeDeferredMap() {
413 Map<String, dynamic> mapping = new Map<String, dynamic>(); 415 Map<String, dynamic> mapping = new Map<String, dynamic>();
414 // Json does not support comments, so we embed the explanation in the 416 // Json does not support comments, so we embed the explanation in the
415 // data. 417 // data.
416 mapping["_comment"] = "This mapping shows which compiled `.js` files are " 418 mapping["_comment"] = "This mapping shows which compiled `.js` files are "
417 "needed for a given deferred library import."; 419 "needed for a given deferred library import.";
418 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); 420 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap());
419 compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map') 421 compiler.outputProvider(
422 compiler.options.deferredMapUri.path, 'deferred_map')
420 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) 423 ..add(const JsonEncoder.withIndent(" ").convert(mapping))
421 ..close(); 424 ..close();
422 } 425 }
423 } 426 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart ('k') | pkg/compiler/lib/src/native/behavior.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698