Revert "Allow to intercept arguments to main with dartMainRunner."

This reverts commit 32720.

R=floitsch@google.com

Review URL: https://codereview.chromium.org//169283007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32721 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
karlklose@google.com 2014-02-17 12:59:52 +00:00
parent 9145ea400c
commit 38e5d47786
3 changed files with 18 additions and 23 deletions

View file

@ -963,15 +963,13 @@ class CodeEmitterTask extends CompilerTask {
''');
}
/// Returns the code equivalent to:
/// `function(args) { $.startRootIsolate(X.main$closure(), args); }`
String buildIsolateSetupClosure(CodeBuffer buffer,
Element appMain,
Element isolateMain) {
String buildIsolateSetup(CodeBuffer buffer,
Element appMain,
Element isolateMain) {
String mainAccess = "${namer.isolateStaticClosureAccess(appMain)}";
// Since we pass the closurized version of the main method to
// the isolate method, we must make sure that it exists.
return "(function(a){${namer.isolateAccess(isolateMain)}($mainAccess,a)})";
return "${namer.isolateAccess(isolateMain)}($mainAccess)";
}
/**
@ -1024,13 +1022,13 @@ class CodeEmitterTask extends CompilerTask {
emitMain(CodeBuffer buffer) {
if (compiler.isMockCompilation) return;
Element main = compiler.mainFunction;
String mainCallClosure = null;
String mainCall = null;
if (compiler.hasIsolateSupport()) {
Element isolateMain =
compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE);
mainCallClosure = buildIsolateSetupClosure(buffer, main, isolateMain);
mainCall = buildIsolateSetup(buffer, main, isolateMain);
} else {
mainCallClosure = '${namer.isolateAccess(main)}';
mainCall = '${namer.isolateAccess(main)}()';
}
if (backend.needToInitializeIsolateAffinityTag) {
@ -1077,9 +1075,9 @@ class CodeEmitterTask extends CompilerTask {
init.currentScript = currentScript;
if (typeof dartMainRunner === "function") {
dartMainRunner(${mainCallClosure}, []);
dartMainRunner(function() { ${mainCall}; });
} else {
${mainCallClosure}([]);
${mainCall};
}
})$N''');
addComment('END invoke [main].', buffer);

View file

@ -57,14 +57,12 @@ const String GENERATED_BY = """
const String HOOKS_API_USAGE = """
// The code supports the following hooks:
// dartPrint(message):
// if this function is defined it is called instead of the Dart [print]
// method.
//
// dartMainRunner(main, args):
// if this function is defined, the Dart [main] method will not be invoked
// directly. Instead, a closure that will invoke [main], and its arguments
// [args] is passed to [dartMainRunner].
// dartPrint(message) - if this function is defined it is called
// instead of the Dart [print] method.
// dartMainRunner(main) - if this function is defined, the Dart [main]
// method will not be invoked directly.
// Instead, a closure that will invoke [main] is
// passed to [dartMainRunner].
""";
// Compact field specifications. The format of the field specification is

View file

@ -70,8 +70,7 @@ _IsolateContext _currentIsolate() => _globalState.currentContext;
* is needed. For single-isolate applications (e.g. hello world), this
* call is not emitted.
*/
void startRootIsolate(entry, args) {
if (args == null) args = [];
void startRootIsolate(entry) {
_globalState = new _Manager(entry);
// Don't start the main loop again, if we are in a worker.
@ -86,9 +85,9 @@ void startRootIsolate(entry, args) {
_globalState.currentContext = rootContext;
if (entry is _MainFunctionArgs) {
rootContext.eval(() { entry(args); });
rootContext.eval(() { entry([]); });
} else if (entry is _MainFunctionArgsMessage) {
rootContext.eval(() { entry(args, null); });
rootContext.eval(() { entry([], null); });
} else {
rootContext.eval(entry);
}