Search in sources :

Example 1 with FullSigma

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

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, FullSigma e) {
    if (seen.contains(e.h)) {
        throw new RuntimeException("Circular transform " + e);
    }
    seen.add(e.h);
    if (env.transforms.get(e.h) == null) {
        throw new RuntimeException("Transform not found " + e);
    }
    Pair<String, String> ht = env.transforms.get(e.h).type(env);
    InstExp i1 = env.insts.get(e.src);
    if (!(i1 instanceof InstExp.FullSigma)) {
        throw new RuntimeException(i1 + " is not a full sigma in " + e);
    }
    String i1x = ((InstExp.FullSigma) i1).I;
    if (!i1x.equals(ht.first)) {
        throw new RuntimeException("Source mismatch on " + e + ": " + i1x + " and " + ht.first);
    }
    InstExp i2 = env.insts.get(e.dst);
    if (!(i2 instanceof InstExp.FullSigma)) {
        throw new RuntimeException(i2 + " is not a fullsigma in " + e);
    }
    String i2x = ((InstExp.FullSigma) i2).I;
    if (!i2x.equals(ht.second)) {
        throw new RuntimeException("Target mismatch on " + e + ": " + i2x + " and " + ht.second);
    }
    return new Pair<>(e.src, e.dst);
}
Also used : InstExp(catdata.fql.decl.InstExp) FullSigma(catdata.fql.decl.TransExp.FullSigma) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)1 InstExp (catdata.fql.decl.InstExp)1 FullSigma (catdata.fql.decl.TransExp.FullSigma)1