use of org.checkerframework.dataflow.cfg.builder.PhaseOneResult in project checker-framework by typetools.
the class CFCFGBuilder method build.
/**
* Build the control flow graph of some code.
*/
public static ControlFlowGraph build(CompilationUnitTree root, UnderlyingAST underlyingAST, BaseTypeChecker checker, AnnotatedTypeFactory factory, ProcessingEnvironment env) {
boolean assumeAssertionsEnabled = checker.hasOption("assumeAssertionsAreEnabled");
boolean assumeAssertionsDisabled = checker.hasOption("assumeAssertionsAreDisabled");
if (assumeAssertionsEnabled && assumeAssertionsDisabled) {
throw new UserError("Assertions cannot be assumed to be enabled and disabled at the same time.");
}
// allow a super-checker to query the stores of a subchecker.
if (factory instanceof GenericAnnotatedTypeFactory) {
GenericAnnotatedTypeFactory<?, ?, ?, ?> asGATF = (GenericAnnotatedTypeFactory<?, ?, ?, ?>) factory;
if (asGATF.hasOrIsSubchecker) {
ControlFlowGraph sharedCFG = asGATF.getSharedCFGForTree(underlyingAST.getCode());
if (sharedCFG != null) {
return sharedCFG;
}
}
}
CFTreeBuilder builder = new CFTreeBuilder(env);
PhaseOneResult phase1result = new CFCFGTranslationPhaseOne(builder, checker, factory, assumeAssertionsEnabled, assumeAssertionsDisabled, env).process(root, underlyingAST);
ControlFlowGraph phase2result = CFGTranslationPhaseTwo.process(phase1result);
ControlFlowGraph phase3result = CFGTranslationPhaseThree.process(phase2result);
if (factory instanceof GenericAnnotatedTypeFactory) {
GenericAnnotatedTypeFactory<?, ?, ?, ?> asGATF = (GenericAnnotatedTypeFactory<?, ?, ?, ?>) factory;
if (asGATF.hasOrIsSubchecker) {
asGATF.addSharedCFGForTree(underlyingAST.getCode(), phase3result);
}
}
return phase3result;
}
Aggregations