for (String registerFnName : registerFnList) {
globalStmts.add(constructInvocation(sourceInfo, registerFnName).makeStmt());
}
// var $entry = ModuleUtils.registerEntry();
JsStatement entryVars = constructFunctionCallStatement(
topScope.declareName("$entry"), "ModuleUtils.registerEntry");
globalStmts.add(entryVars);
// var gwtOnLoad = ModuleUtils.gwtOnLoad;
JsName gwtOnLoad = topScope.findExistingUnobfuscatableName("gwtOnLoad");
JsVar varGwtOnLoad = new JsVar(sourceInfo, gwtOnLoad);
varGwtOnLoad.setInitExpr(createAssignment(gwtOnLoad.makeRef(sourceInfo),
indexedFunctions.get("ModuleUtils.gwtOnLoad").getName().makeRef(sourceInfo)));
globalStmts.add(new JsVars(sourceInfo, varGwtOnLoad));
// ModuleUtils.addInitFunctions(init1, init2,...)
List<JsExpression> arguments = Lists.newArrayList();
for (JMethod entryPointMethod : program.getEntryMethods()) {
JsFunction entryFunction = getJsFunctionFor(entryPointMethod);
arguments.add(entryFunction.getName().makeRef(sourceInfo));
}
JsStatement createGwtOnLoadFunctionCall =
constructInvocation("ModuleUtils.addInitFunctions", arguments).makeStmt();
globalStmts.add(createGwtOnLoadFunctionCall);
}