Search in sources :

Example 1 with CDeclProperty

use of mb.nabl2.constraints.nameresolution.CDeclProperty in project nabl by metaborg.

the class NameResolutionComponent method solve.

private Optional<SolveResult> solve(CDeclProperty c) {
    final ITerm declTerm = unifier().findRecursive(c.getDeclaration());
    if (!declTerm.isGround()) {
        return Optional.empty();
    }
    final Occurrence decl = Occurrence.matcher().match(declTerm, unifier()).orElseThrow(() -> new TypeException("Expected an occurrence as first argument to " + c));
    final SolveResult result = putProperty(decl, c.getKey(), c.getValue(), c.getMessageInfo()).map(cc -> SolveResult.constraints(cc)).orElseGet(() -> SolveResult.empty());
    return Optional.of(result);
}
Also used : INameResolutionConstraint(mb.nabl2.constraints.nameresolution.INameResolutionConstraint) CDeclProperty(mb.nabl2.constraints.nameresolution.CDeclProperty) TypeException(mb.nabl2.solver.TypeException) ITerm(mb.nabl2.terms.ITerm) ImmutableCEqual(mb.nabl2.constraints.equality.ImmutableCEqual) IConstraint(mb.nabl2.constraints.IConstraint) Multimap(com.google.common.collect.Multimap) Occurrence(mb.nabl2.scopegraph.terms.Occurrence) IProperties(mb.nabl2.util.collections.IProperties) IEsopNameResolution(mb.nabl2.scopegraph.esop.IEsopNameResolution) SolveResult(mb.nabl2.solver.ISolver.SolveResult) SolverCore(mb.nabl2.solver.SolverCore) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) VarMultimap(mb.nabl2.terms.collection.VarMultimap) Value(org.immutables.value.Value) Label(mb.nabl2.scopegraph.terms.Label) ASolver(mb.nabl2.solver.ASolver) IEsopScopeGraph(mb.nabl2.scopegraph.esop.IEsopScopeGraph) CResolve(mb.nabl2.constraints.nameresolution.CResolve) Scope(mb.nabl2.scopegraph.terms.Scope) IResolutionPath(mb.nabl2.scopegraph.path.IResolutionPath) Collectors(java.util.stream.Collectors) IMessageInfo(mb.nabl2.constraints.messages.IMessageInfo) Sets(com.google.common.collect.Sets) MessageContent(mb.nabl2.constraints.messages.MessageContent) ImmutableSolveResult(mb.nabl2.solver.ImmutableSolveResult) List(java.util.List) Paths(mb.nabl2.scopegraph.terms.path.Paths) Serial(org.immutables.serial.Serial) SeedResult(mb.nabl2.solver.ISolver.SeedResult) Optional(java.util.Optional) CAssoc(mb.nabl2.constraints.nameresolution.CAssoc) SolveResult(mb.nabl2.solver.ISolver.SolveResult) ImmutableSolveResult(mb.nabl2.solver.ImmutableSolveResult) ITerm(mb.nabl2.terms.ITerm) TypeException(mb.nabl2.solver.TypeException) Occurrence(mb.nabl2.scopegraph.terms.Occurrence)

Aggregations

HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1 Multimap (com.google.common.collect.Multimap)1 Sets (com.google.common.collect.Sets)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 IConstraint (mb.nabl2.constraints.IConstraint)1 ImmutableCEqual (mb.nabl2.constraints.equality.ImmutableCEqual)1 IMessageInfo (mb.nabl2.constraints.messages.IMessageInfo)1 MessageContent (mb.nabl2.constraints.messages.MessageContent)1 CAssoc (mb.nabl2.constraints.nameresolution.CAssoc)1 CDeclProperty (mb.nabl2.constraints.nameresolution.CDeclProperty)1 CResolve (mb.nabl2.constraints.nameresolution.CResolve)1 INameResolutionConstraint (mb.nabl2.constraints.nameresolution.INameResolutionConstraint)1 IEsopNameResolution (mb.nabl2.scopegraph.esop.IEsopNameResolution)1 IEsopScopeGraph (mb.nabl2.scopegraph.esop.IEsopScopeGraph)1 IResolutionPath (mb.nabl2.scopegraph.path.IResolutionPath)1 Label (mb.nabl2.scopegraph.terms.Label)1 Occurrence (mb.nabl2.scopegraph.terms.Occurrence)1