analyzeCompilation method
HTModuleAnalysisResult
analyzeCompilation(
- ASTCompilation compilation, {
- String? moduleName,
- bool globallyImport = false,
- bool debugPerformance = false,
Implementation
HTModuleAnalysisResult analyzeCompilation(
ASTCompilation compilation, {
String? moduleName,
bool globallyImport = false,
bool debugPerformance = false,
}) {
final tik = DateTime.now().millisecondsSinceEpoch;
// _currentCompilation = compilation;
_currentErrors = [];
_currentAnalysisResults = {};
// Resolve namespaces
for (final source in compilation.sources.values) {
// the first scan, create namespaces & declarations.
resolve(source);
}
for (final source in compilation.sources.values) {
// the second scan, handle import.
handleImport(source);
}
for (final source in compilation.sources.values) {
// the third & forth scan.
_analyze(source);
}
if (globallyImport) {
globalNamespace.import(_currentAnalysisResults.values.last.namespace);
}
// walk through ast again to resolve each symbol's declaration referrence.
// final visitor = _OccurrencesVisitor();
// for (final node in result.parseResult.nodes) {
// node.accept(visitor);
// }
final result = HTModuleAnalysisResult(
sourceAnalysisResults: _currentAnalysisResults,
errors: _currentErrors,
compilation: compilation,
);
final tok = DateTime.now().millisecondsSinceEpoch;
if (debugPerformance) {
print('analyzed [${compilation.entryFullname}]\t${tok - tik}ms');
}
return result;
}