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

Unified Diff: dart/frog/leg/emitter.dart

Issue 9813012: Add "mock" compilation feature to dart2js and use it to improve test coverage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 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 side-by-side diff with in-line comments
Download patch
Index: dart/frog/leg/emitter.dart
diff --git a/dart/frog/leg/emitter.dart b/dart/frog/leg/emitter.dart
index 0a057355f354104fdb30d5954b8b02904817f3b3..d5cd08e598591232f6374dd77ff3aee5eec28b41 100644
--- a/dart/frog/leg/emitter.dart
+++ b/dart/frog/leg/emitter.dart
@@ -653,9 +653,9 @@ function(child, parent) {
mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess";
}
- // TODO(ngeoffray): These globals are currently required by the isolate
- // library, but since leg already generates code on an Isolate object, they
- // are not really needed. We should remove them once Leg replaces Frog.
+ // TODO(ngeoffray): These globals are currently required by the isolate
+ // library, but since leg already generates code on an Isolate object, they
+ // are not really needed. We should remove them once Leg replaces Frog.
return """
var \$globalThis = $currentIsolate;
var \$globalState;
@@ -673,6 +673,18 @@ $mainEnsureGetter
${namer.isolateAccess(isolateMain)}($mainAccess);""";
}
+ emitMain(StringBuffer buffer) {
+ if (compiler.isMockCompilation) return;
+ Element main = compiler.mainApp.find(Compiler.MAIN);
+ if (compiler.isolateLibrary != null) {
+ Element isolateMain =
+ compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE);
+ buffer.add(buildIsolateSetup(main, isolateMain));
+ } else {
+ buffer.add('${namer.isolateAccess(main)}();\n');
+ }
+ }
+
String assembleProgram() {
measure(() {
StringBuffer buffer = new StringBuffer();
@@ -686,14 +698,7 @@ ${namer.isolateAccess(isolateMain)}($mainAccess);""";
emitStaticFinalFieldInitializations(buffer);
nativeEmitter.emitDynamicDispatchMetadata(buffer);
buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n');
- Element main = compiler.mainApp.find(Compiler.MAIN);
- if (compiler.isolateLibrary != null) {
- Element isolateMain =
- compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE);
- buffer.add(buildIsolateSetup(main, isolateMain));
- } else {
- buffer.add('${namer.isolateAccess(main)}();\n');
- }
+ emitMain(buffer);
compiler.assembledCode = buffer.toString();
});
return compiler.assembledCode;

Powered by Google App Engine
This is Rietveld 408576698