use of catdata.fql.decl.InstExp.Exp in project fql by CategoricalData.
the class InstOps method visit.
@Override
public List<PSM> visit(String env, TransEval e) {
List<PSM> ret = new LinkedList<>();
InstExp k = prog.insts.get(e.inst);
Times t = (Times) k;
InstExp v = prog.insts.get(t.a);
Exp i = (Exp) v;
ret.add(new PSMEval(env, i.a, i.b, t.a, e.inst, t.type(prog).toSig(prog)));
return ret;
}
use of catdata.fql.decl.InstExp.Exp in project fql by CategoricalData.
the class FQLProgram method build.
private Graph<String, Object> build() {
// Graph<V, E> where V is the type of the vertices
Graph<String, Object> g2 = new DirectedSparseMultigraph<>();
Ref<Integer> guid = new Ref<>(0);
for (String k : insts.keySet()) {
InstExp i = insts.get(k);
i.type(this).toConst(this);
g2.addVertex(k);
i.accept(new Unit(), new InstExpVisitor<Unit, Unit>() {
@Override
public Unit visit(Unit env, Zero e) {
return null;
}
@Override
public Unit visit(Unit env, One e) {
return null;
}
@Override
public Unit visit(Unit env, Two e) {
return null;
}
@Override
public Unit visit(Unit env, Plus e) {
g2.addEdge(new Pair<>(pp(guid), e), e.a, k);
g2.addEdge(new Pair<>(pp(guid), e), e.b, k);
return null;
}
@Override
public Unit visit(Unit env, Times e) {
g2.addEdge(new Pair<>(pp(guid), e), e.a, k);
g2.addEdge(new Pair<>(pp(guid), e), e.b, k);
return null;
}
@Override
public Unit visit(Unit env, Exp e) {
g2.addEdge(new Pair<>(pp(guid), e), e.a, k);
g2.addEdge(new Pair<>(pp(guid), e), e.b, k);
return null;
}
@Override
public Unit visit(Unit env, Const e) {
return null;
}
@Override
public Unit visit(Unit env, Delta e) {
g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
return null;
}
@Override
public Unit visit(Unit env, Sigma e) {
g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
return null;
}
@Override
public Unit visit(Unit env, Pi e) {
g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
return null;
}
@Override
public Unit visit(Unit env, FullSigma e) {
g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
return null;
}
@Override
public Unit visit(Unit env, Relationalize e) {
g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
return null;
}
@Override
public Unit visit(Unit env, External e) {
return null;
}
@Override
public Unit visit(Unit env, Eval e) {
g2.addEdge(new Pair<>(pp(guid), e), e.e, k);
return null;
}
@Override
public Unit visit(Unit env, FullEval e) {
g2.addEdge(new Pair<>(pp(guid), e), e.e, k);
return null;
}
@Override
public Unit visit(Unit env, Kernel e) {
TransExp t = transforms.get(e.trans);
Pair<String, String> p = t.type(FQLProgram.this);
g2.addEdge(new Pair<>(pp(guid), e), p.first, k);
g2.addEdge(new Pair<>(pp(guid), e), p.second, k);
return null;
}
private Integer pp(Ref<Integer> ref) {
int ret = ref.x;
ref.x = ret + 1;
return ref.x;
}
@Override
public Unit visit(Unit env, Step e) {
// (Step) this should add an edge
return null;
}
});
}
return g2;
}
Aggregations