*/
public String compile(TreeLogger logger, RebindOracle rebindOracle, final PropertyOracle propertyOracle ) throws UnableToCompleteException {
try {
JProgram jprogram = new JProgram(logger, rebindOracle);
JsProgram jsProgram = new JsProgram();
if (JProgram.isTracingEnabled()) {
System.out.println("------------------------------------------------------------");
System.out.println("| (new permuation) |");
System.out.println("------------------------------------------------------------");
}
{
/*
* (1) Build a flattened map of TypeDeclarations => JType. The resulting
* map contains entries for all reference types. BuildTypeMap also
* parses all JSNI.
*/
TypeMap typeMap = new TypeMap(jprogram);
TypeDeclaration[] allTypeDeclarations = BuildTypeMap.exec(typeMap,
goldenCuds, jsProgram);
// BuildTypeMap can uncover syntactic JSNI errors; report & abort
checkForErrors(logger, true);
// Compute all super type/sub type info
jprogram.typeOracle.computeBeforeAST();
// (2) Create our own Java AST from the JDT AST.
GenerateJavaAST.exec(allTypeDeclarations, typeMap, jprogram, jsProgram,
options.isEnableAssertions());
// GenerateJavaAST can uncover semantic JSNI errors; report & abort
checkForErrors(logger, true);
// Enable GC.
typeMap = null;
allTypeDeclarations = null;
}
// (3) Perform Java AST normalizations.
FixAssignmentToUnbox.exec(jprogram);
/*
* TODO: If we defer this until later, we could maybe use the results of
* the assertions to enable more optimizations.
*/
if (options.isEnableAssertions()) {
// Turn into assertion checking calls.
AssertionNormalizer.exec(jprogram);
} else {
// Remove all assert statements.
AssertionRemover.exec(jprogram);
}
// ROCKET reapply changes when upgrading
final LoggerOptimiser loggerOptimiser = this.getLoggerOptimiser(jprogram, propertyOracle, logger);
loggerOptimiser.execute();
// Resolve all rebinds through GWT.create().
ReplaceRebinds.exec(jprogram);
if (options.isValidateOnly()) {
// That's it, we're done.
return null;
}
// Also rebind all non-static entry points.
findEntryPoints(logger, rebindOracle, declEntryPoints, jprogram);
// Replace references to JSO subtypes with JSO itself.
JavaScriptObjectNormalizer.exec(jprogram);
/*
* Record the beginning of optimations; this turns on certain checks that
* guard against problematic late construction of things like class
* literals.
*/
jprogram.beginOptimizations();
// (4) Optimize the normalized Java AST
boolean didChange;
do {
// Recompute clinits each time, they can become empty.