DocumentInfo info = (DocumentInfo)unit.getContext().removeAttribute(MxmlCompiler.DOCUMENT_INFO);
assert info != null;
// build MxmlDocument from MXML DOM
MxmlDocument document = new MxmlDocument(unit, typeTable, info, mxmlConfiguration);
DocumentBuilder builder = new DocumentBuilder(unit, typeTable, mxmlConfiguration, document);
app.analyze(builder);
if (ThreadLocalToolkit.errorCount() > 0)
{
return null;
}
Source genSource;
CompilationUnit ascUnit;
Logger original = ThreadLocalToolkit.getLogger();
if (mxmlConfiguration.getGenerateAbstractSyntaxTree())
{
Logger adapter = new AbstractSyntaxTreeLogAdapter(original);
ThreadLocalToolkit.setLogger(adapter);
genSource = generateImplementationAST(document,
symbolTable.perCompileData,
symbolTable.emitter);
// C: null out MxmlDocument after generation
document.getStylesContainer().setMxmlDocument(null);
document = null;
// C: MXML DOM no longer needed
unit.setSyntaxTree(null);
ascUnit = asc.parse1(genSource, symbolTable);
if (ThreadLocalToolkit.errorCount() > 0)
{
return null;
}
}
else
{
// generate AS3 code
VirtualFile genFile = generateImplementation(document);
// obtain the line number map...
DualModeLineNumberMap lineMap = document.getLineNumberMap();
if (genFile != null && ThreadLocalToolkit.errorCount() == 0)
{
genSource = new Source(genFile, source);
// C: I don't think this is necessary...
genSource.addFileIncludes(source);
}
else
{
return null;
}
// use MxmlLogAdapter to do filtering, e.g. -generated.as -> .mxml, as line -> mxml line, etc...
Logger adapter = new MxmlLogAdapter(original, lineMap);
ThreadLocalToolkit.setLogger(adapter);
// C: null out MxmlDocument after generation
document.getStylesContainer().setMxmlDocument(null);
document = null;
// C: MXML DOM no longer needed
unit.setSyntaxTree(null);
// 6. invoke asc