GdlTerm arg = template.get(i);
if(arg instanceof GdlConstant)
{
List<GdlTerm> domBody = new ArrayList<GdlTerm>();
domBody.add(arg);
GdlFunction dom = GdlPool.getFunction(GdlPool.getConstant("val"), domBody);
body.add(dom);
}
else if(arg instanceof GdlVariable)
{
List<GdlTerm> domBody = new ArrayList<GdlTerm>();
Location loc = new Location();
loc.idx = i;
loc.name = template.getName();
Domain varDom = domains.get(loc);
if(varDom == null)
throw new RuntimeException("Unexpected domain: "+loc+" encountered.");
domBody.addAll(varDom.values);
GdlFunction dom = GdlPool.getFunction(GdlPool.getConstant("val"), domBody);
body.add(dom);
}
else if(arg instanceof GdlFunction)
{
throw new RuntimeException("Don't know how to deal with functions within next/init.");