CompilerContext context = new CompilerContext();
// 1. parse/analyze MXML, or retrieve preparsed DOM
// 2. add MXML syntax tree to a new CompilationUnit
DocumentNode app;
CompilationUnit unit;
Object preparsedSyntaxTree = source.getSourceFragment(AttrInlineComponentSyntaxTree);
if (preparsedSyntaxTree == null)
{
app = parseMXML(source);
if (app == null)
{
return null;
}
unit = source.newCompilationUnit(app, context);
// do more syntax checking, chase includes, etc.
app.analyze(new SyntaxAnalyzer(unit, mxmlConfiguration));
if (ThreadLocalToolkit.errorCount() > 0)
{
return null;
}
}
else
{
assert preparsedSyntaxTree instanceof DocumentNode : "bogus preparsed root node passed to InterfaceCompiler";
app = (DocumentNode) preparsedSyntaxTree;
unit = source.newCompilationUnit(app, context);
}
unit.getContext().setAttribute(DOCUMENT_NODE, app);
// start a new DocumentInfo. this will accumulate document state as compilation proceeds
DocumentInfo docInfo = createDocumentInfo(unit, app, source);
if (ThreadLocalToolkit.errorCount() > 0)
{
return null;
}
unit.getContext().setAttribute(MxmlCompiler.DOCUMENT_INFO, docInfo);
unit.topLevelDefinitions.add(new QName(docInfo.getPackageName(), docInfo.getClassName()));
transferDependencies(docInfo, unit.inheritance, unit.inheritanceHistory);
return unit;
}