use of catdata.opl.OplExp.OplSetTrans in project fql by CategoricalData.
the class OplOps method visit.
@Override
public OplObject visit(Program<OplExp> env, OplDelta e) {
OplObject F = ENV.get(e.F);
if (!(F instanceof OplMapping)) {
throw new RuntimeException("Not a mapping: " + e.F);
}
OplMapping F0 = (OplMapping) F;
OplObject I = ENV.get(e.I);
if (I instanceof OplSetInst) {
OplSetInst I0 = (OplSetInst) I;
return F0.delta(I0);
}
if (I instanceof OplSetTrans) {
OplSetTrans h = (OplSetTrans) I;
return F0.delta(h);
}
throw new RuntimeException("Not a model or transform: " + e.I);
}
use of catdata.opl.OplExp.OplSetTrans in project fql by CategoricalData.
the class OplParser method toTrans.
private static OplExp toTrans(Object c) {
Tuple3 t = (Tuple3) c;
if (!t.a.toString().equals("transform")) {
throw new RuntimeException();
}
Map<String, Map<String, String>> map = new HashMap<>();
Tuple3 tb = (Tuple3) t.b;
List<Tuple5> l = (List<Tuple5>) tb.b;
for (Tuple5 x : l) {
String name = (String) x.a;
List<Tuple5> y = (List<Tuple5>) x.d;
Map<String, String> m = new HashMap<>();
for (Tuple5 z : y) {
String xx = (String) z.b;
String yy = (String) z.d;
if (m.containsKey(xx)) {
throw new DoNotIgnore("Duplicate argument: " + xx);
}
m.put(xx, yy);
}
if (map.containsKey(name)) {
throw new DoNotIgnore("Duplicate sort: " + name);
}
map.put(name, m);
}
Tuple4 tc = (Tuple4) t.c;
return new OplSetTrans(map, (String) tc.b, (String) tc.d);
}
Aggregations