List<AJCTree> prospectiveRootNodes = List.nil();
HashMap<AJCTree, Env<AttrContext>> environMap = new HashMap<AJCTree, Env<AttrContext>>();
// Since it's stateless...
final TreePreparationTranslator sanity = new TreePreparationTranslator();
final TreeNormalisingTranslator normaliser = new TreeNormalisingTranslator();
HashMap<MethodSymbol, AJCMethodDecl> prospectiveMethodTable = new HashMap<MethodSymbol, AJCMethodDecl>();
InitialASTConverter.init();
for (Pair<Env<AttrContext>, JCClassDecl> env : rootElements) {
currentEnvironment = env.fst;
JCClassDecl classTree = env.snd;
log.trace("Input tree: {}", classTree);
// Perform the sanity translations on the tree that are more convenient to do before the translation step...
classTree.accept(sanity);
log.trace("Prepared tree: {}", classTree);
// Translate the tree to our tree representation...
InitialASTConverter converter = new InitialASTConverter();
classTree.accept(converter);
AJCClassDecl translatedTree = (AJCClassDecl) converter.getResult();
log.debug("Translated tree: {}", translatedTree);
// Populate method and varsym tables.
for (AJCMethodDecl defN : translatedTree.methods) {
prospectiveMethodTable.put(defN.getTargetSymbol(), defN);
log.debug("Method: {}", defN.getTargetSymbol());
}
// Normalise the tree.
normaliser.visitTree(translatedTree);
prospectiveRootNodes = prospectiveRootNodes.prepend(translatedTree);
environMap.put(translatedTree, env.fst);
}