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

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: 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
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..4c423709a0dfb104b0727455c1d2a345803ebf03 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,8 @@ 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';
+ String buildGeneratedBy() {
+ return new jsAst.Comment(generatedBy(compiler));
Siggi Cherem (dart-lang) 2015/08/04 16:42:48 should we add an argument to generatedBy so we can
floitsch 2015/08/05 11:46:50 I added a 'flavor' argument to 'generatedBy'. That
Siggi Cherem (dart-lang) 2015/08/05 15:53:36 I have a feeling that all flags might be too noisy
}
/// Writes all deferred fragment's code into files.
@@ -258,7 +256,12 @@ class ModelEmitter {
codeOutputListeners);
outputBuffers[fragment] = mainOutput;
- mainOutput.addBuffer(js.prettyPrint(code, compiler,
+ js.Program program = new js.Program([
+ new js.Comment(generatedBy(compiler)),
+ new js.Comment(HOOKS_API_USAGE),
+ code]);
+
+ mainOutput.addBuffer(js.prettyPrint(program, compiler,
monitor: compiler.dumpInfoTask));
if (shouldGenerateSourceMap) {
@@ -307,9 +310,11 @@ class ModelEmitter {
// deferredInitializer.current = <pretty-printed code>;
// deferredInitializer[<hash>] = deferredInitializer.current;
- output.add('\n${deferredInitializersGlobal}.current = ');
+ js.Program program = new js.Program([
+ new js.Comment(generatedBy(compiler)),
+ 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)

Powered by Google App Engine
This is Rietveld 408576698