Search in sources :

Example 1 with IScopeGraph

use of mb.nabl2.scopegraph.IScopeGraph in project nabl by metaborg.

the class InterpreterTerms method scopeEntries.

private static ITerm scopeEntries(IScopeGraph<Scope, Label, Occurrence> scopeGraph) {
    Map<ITerm, ITerm> entries = Maps.newHashMap();
    for (Scope scope : scopeGraph.getAllScopes()) {
        IListTerm decls = B.newList(scopeGraph.getDecls().inverse().get(scope));
        IListTerm refs = B.newList(scopeGraph.getRefs().inverse().get(scope));
        IListTerm edges = multimap(scopeGraph.getDirectEdges().get(scope));
        IListTerm imports = multimap(scopeGraph.getImportEdges().get(scope));
        ITerm entry = B.newAppl("SE", decls, refs, edges, imports);
        entries.put(scope, entry);
    }
    return map(entries.entrySet());
}
Also used : IListTerm(mb.nabl2.terms.IListTerm) Scope(mb.nabl2.scopegraph.terms.Scope) ITerm(mb.nabl2.terms.ITerm)

Example 2 with IScopeGraph

use of mb.nabl2.scopegraph.IScopeGraph in project nabl by metaborg.

the class InterpreterTerms method refEntries.

private static ITerm refEntries(IScopeGraph<Scope, Label, Occurrence> scopeGraph) {
    Map<ITerm, ITerm> entries = Maps.newHashMap();
    for (Occurrence ref : scopeGraph.getAllRefs()) {
        ITerm scope = scopeGraph.getRefs().get(ref).map(s -> B.newList(s)).orElse(B.newNil());
        ITerm entry = B.newAppl("RE", scope);
        entries.put(ref, entry);
    }
    return map(entries.entrySet());
}
Also used : B(mb.nabl2.terms.build.TermBuild.B) Iterables(com.google.common.collect.Iterables) IUnifier(mb.nabl2.terms.unification.IUnifier) DeclProperties(mb.nabl2.constraints.namebinding.DeclProperties) ITerm(mb.nabl2.terms.ITerm) Set(java.util.Set) Scope(mb.nabl2.scopegraph.terms.Scope) IResolutionPath(mb.nabl2.scopegraph.path.IResolutionPath) Multimap(com.google.common.collect.Multimap) Occurrence(mb.nabl2.scopegraph.terms.Occurrence) IProperties(mb.nabl2.util.collections.IProperties) Maps(com.google.common.collect.Maps) IEsopNameResolution(mb.nabl2.scopegraph.esop.IEsopNameResolution) List(java.util.List) IScopeGraph(mb.nabl2.scopegraph.IScopeGraph) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Paths(mb.nabl2.scopegraph.terms.path.Paths) Label(mb.nabl2.scopegraph.terms.Label) IListTerm(mb.nabl2.terms.IListTerm) Map(java.util.Map) LoggerUtils(org.metaborg.util.log.LoggerUtils) ISolution(mb.nabl2.solver.ISolution) ILogger(org.metaborg.util.log.ILogger) ITerm(mb.nabl2.terms.ITerm) Occurrence(mb.nabl2.scopegraph.terms.Occurrence)

Example 3 with IScopeGraph

use of mb.nabl2.scopegraph.IScopeGraph in project nabl by metaborg.

the class InterpreterTerms method declEntries.

private static ITerm declEntries(IScopeGraph<Scope, Label, Occurrence> scopeGraph) {
    Map<ITerm, ITerm> entries = Maps.newHashMap();
    for (Occurrence decl : scopeGraph.getAllDecls()) {
        ITerm scope = scopeGraph.getDecls().get(decl).map(s -> B.newList(s)).orElse(B.newNil());
        ITerm assocs = multimap(scopeGraph.getExportEdges().get(decl));
        ITerm entry = B.newAppl("DE", scope, assocs);
        entries.put(decl, entry);
    }
    return map(entries.entrySet());
}
Also used : B(mb.nabl2.terms.build.TermBuild.B) Iterables(com.google.common.collect.Iterables) IUnifier(mb.nabl2.terms.unification.IUnifier) DeclProperties(mb.nabl2.constraints.namebinding.DeclProperties) ITerm(mb.nabl2.terms.ITerm) Set(java.util.Set) Scope(mb.nabl2.scopegraph.terms.Scope) IResolutionPath(mb.nabl2.scopegraph.path.IResolutionPath) Multimap(com.google.common.collect.Multimap) Occurrence(mb.nabl2.scopegraph.terms.Occurrence) IProperties(mb.nabl2.util.collections.IProperties) Maps(com.google.common.collect.Maps) IEsopNameResolution(mb.nabl2.scopegraph.esop.IEsopNameResolution) List(java.util.List) IScopeGraph(mb.nabl2.scopegraph.IScopeGraph) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Paths(mb.nabl2.scopegraph.terms.path.Paths) Label(mb.nabl2.scopegraph.terms.Label) IListTerm(mb.nabl2.terms.IListTerm) Map(java.util.Map) LoggerUtils(org.metaborg.util.log.LoggerUtils) ISolution(mb.nabl2.solver.ISolution) ILogger(org.metaborg.util.log.ILogger) ITerm(mb.nabl2.terms.ITerm) Occurrence(mb.nabl2.scopegraph.terms.Occurrence)

Aggregations

Scope (mb.nabl2.scopegraph.terms.Scope)3 IListTerm (mb.nabl2.terms.IListTerm)3 ITerm (mb.nabl2.terms.ITerm)3 HashMultimap (com.google.common.collect.HashMultimap)2 Iterables (com.google.common.collect.Iterables)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Multimap (com.google.common.collect.Multimap)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 DeclProperties (mb.nabl2.constraints.namebinding.DeclProperties)2 IScopeGraph (mb.nabl2.scopegraph.IScopeGraph)2 IEsopNameResolution (mb.nabl2.scopegraph.esop.IEsopNameResolution)2 IResolutionPath (mb.nabl2.scopegraph.path.IResolutionPath)2 Label (mb.nabl2.scopegraph.terms.Label)2 Occurrence (mb.nabl2.scopegraph.terms.Occurrence)2 Paths (mb.nabl2.scopegraph.terms.path.Paths)2 ISolution (mb.nabl2.solver.ISolution)2 B (mb.nabl2.terms.build.TermBuild.B)2