StatementRanges statementRanges = v.getStatementRanges();
String code = out.toString();
JsSourceMap infoMap = (sourceInfoMaps != null) ? v.getSourceInfoMap() : null;
JsAbstractTextTransformer transformer =
new JsNoopTransformer(code, statementRanges, infoMap);
/**
* Cut generated JS up on class boundaries and re-link the source (possibly making use of
* source from previous compiles, thus making it possible to perform partial recompiles).
*/
if (options.isIncrementalCompileEnabled()) {
transformer = new JsTypeLinker(logger, transformer, v.getClassRanges(),
v.getProgramClassRange(), getMinimalRebuildCache(), jprogram.typeOracle);
transformer.exec();
}
/**
* Reorder function decls to improve compression ratios. Also restructures the top level
* blocks into sub-blocks if they exceed 32767 statements.
*/
Event functionClusterEvent = SpeedTracerLogger.start(CompilerEventType.FUNCTION_CLUSTER);
// TODO(cromwellian) move to the Js AST optimization, re-enable sourcemaps + clustering
if (!sourceMapsEnabled && options.shouldClusterSimilarFunctions()
&& options.getNamespace() == JsNamespaceOption.NONE
&& options.getOutput() == JsOutputOption.OBFUSCATED) {
transformer = new JsFunctionClusterer(transformer);
transformer.exec();
}
functionClusterEvent.end();
jsFragments[i] = transformer.getJs();
ranges[i] = transformer.getStatementRanges();
if (sizeBreakdowns != null) {
sizeBreakdowns[i] = v.getSizeBreakdown();
}
if (sourceInfoMaps != null) {
sourceInfoMaps.add(transformer.getSourceInfoMap());
}
}
generateJavascriptEvent.end();
}