Search in sources :

Example 1 with External

use of catdata.fql.decl.TransExp.External in project fql by CategoricalData.

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, External e) {
    InstExp src = env.insts.get(e.src);
    if (src == null) {
        throw new RuntimeException("Missing instance " + e.src);
    }
    InstExp dst = env.insts.get(e.dst);
    if (dst == null) {
        throw new RuntimeException("Missing instance " + e.src);
    }
    if (!(src instanceof InstExp.External)) {
        throw new RuntimeException(e.src + " is not external.");
    }
    if (!(dst instanceof InstExp.External)) {
        throw new RuntimeException(e.dst + " is not external.");
    }
    InstExp.External src0 = (InstExp.External) src;
    InstExp.External dst0 = (InstExp.External) dst;
    SigExp srct = src0.type(env);
    SigExp dstt = dst0.type(env);
    if (!srct.equals(dstt)) {
        throw new RuntimeException("Instances not of same type on " + e + " are " + srct + " and " + dstt);
    }
    return new Pair<>(e.src, e.dst);
}
Also used : InstExp(catdata.fql.decl.InstExp) SigExp(catdata.fql.decl.SigExp) External(catdata.fql.decl.TransExp.External) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)1 InstExp (catdata.fql.decl.InstExp)1 SigExp (catdata.fql.decl.SigExp)1 External (catdata.fql.decl.TransExp.External)1