use of mb.nabl2.solver.components.ScopeGraphComponent in project nabl by metaborg.
the class BaseSolver method solveGraph.
public GraphSolution solveGraph(BaseSolution initial, Function1<String, String> fresh, ICancel cancel, IProgress progress) throws SolverException, InterruptedException {
// shared
final Ref<IUnifier.Immutable> unifier = new Ref<>(initial.unifier());
final IEsopScopeGraph.Transient<Scope, Label, Occurrence, ITerm> scopeGraph = EsopScopeGraph.Transient.of();
// solver components
final SolverCore core = new SolverCore(initial.config(), unifier, fresh, callExternal);
final AstComponent astSolver = new AstComponent(core, Properties.Transient.of());
final BaseComponent baseSolver = new BaseComponent(core);
final EqualityComponent equalitySolver = new EqualityComponent(core, unifier);
final ScopeGraphComponent scopeGraphSolver = new ScopeGraphComponent(core, scopeGraph);
try {
ISolver component = c -> c.matchOrThrow(IConstraint.CheckedCases.<Optional<SolveResult>, InterruptedException>builder().onAst(astSolver::solve).onBase(baseSolver::solve).onEquality(equalitySolver::solve).onScopeGraph(scopeGraphSolver::solve).otherwise(cc -> Optional.empty()));
final FixedPointSolver solver = new FixedPointSolver(cancel, progress, component, Iterables2.empty());
final SolveResult solveResult = solver.solve(initial.constraints());
return ImmutableGraphSolution.of(initial.config(), astSolver.finish(), scopeGraphSolver.finish(), equalitySolver.finish(), solveResult.messages(), solveResult.constraints());
} catch (RuntimeException ex) {
throw new SolverException("Internal solver error.", ex);
}
}
Aggregations