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

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

Issue 1271953003: dart2js: Add a header to the output of the startup emitter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add flavor section to generatedBy comment. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
index e30c58b0623fbef2a47fc59f03f837e8ad49100b..ed243002f0ceee9bc149e56912bc8a6dd1f69b53 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
@@ -34,6 +34,7 @@ import '../../util/util.dart' show
import '../../util/uri_extras.dart' show
relativize;
+import '../headers.dart';
import '../js_emitter.dart' show AstContainer, NativeEmitter;
import 'package:js_runtime/shared/embedded_names.dart' show
@@ -218,11 +219,11 @@ class ModelEmitter {
}
/// Generates a simple header that provides the compiler's build id.
- String buildGeneratedBy(compiler) {
- var suffix = '';
- if (compiler.hasBuildId) suffix = ' version: ${compiler.buildId}';
- return '// Generated by dart2js (fast startup), '
- 'the Dart to JavaScript compiler$suffix.\n';
+ js.Comment buildGeneratedBy() {
+ String flavor = compiler.useContentSecurityPolicy
+ ? 'fast startup, CSP'
+ : 'fast startup';
+ return new js.Comment(generatedBy(compiler, flavor: flavor));
}
/// Writes all deferred fragment's code into files.
@@ -258,7 +259,12 @@ class ModelEmitter {
codeOutputListeners);
outputBuffers[fragment] = mainOutput;
- mainOutput.addBuffer(js.prettyPrint(code, compiler,
+ js.Program program = new js.Program([
+ buildGeneratedBy(),
+ new js.Comment(HOOKS_API_USAGE),
+ code]);
+
+ mainOutput.addBuffer(js.prettyPrint(program, compiler,
monitor: compiler.dumpInfoTask));
if (shouldGenerateSourceMap) {
@@ -307,9 +313,11 @@ class ModelEmitter {
// deferredInitializer.current = <pretty-printed code>;
// deferredInitializer[<hash>] = deferredInitializer.current;
- output.add('\n${deferredInitializersGlobal}.current = ');
+ js.Program program = new js.Program([
+ buildGeneratedBy(),
+ js.js.statement('$deferredInitializersGlobal.current = #', code)]);
- output.addBuffer(js.prettyPrint(code, compiler,
+ output.addBuffer(js.prettyPrint(program, compiler,
monitor: compiler.dumpInfoTask));
// Make a unique hash of the code (before the sourcemaps are added)
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698