void addFunc(Pos p, Pos isPrivate, String n, Expr f, List<Decl> decls, Expr t, Expr v) throws Err {
if (decls==null) decls=new ArrayList<Decl>(); else decls=new ArrayList<Decl>(decls);
if (f!=null) decls.add(0, new Decl(null, null, null, Util.asList(ExprVar.make(f.span(), "this")), f));
for(Decl d:decls) {
if (d.isPrivate!=null) {
ExprHasName name = d.names.get(0);
throw new ErrorSyntax(d.isPrivate.merge(name.pos), "Function parameter \""+name.label+"\" is always private already.");
}
if (d.disjoint2!=null) {
ExprHasName name = d.names.get(d.names.size()-1);
throw new ErrorSyntax(d.disjoint2.merge(name.pos), "Function parameter \""+name.label+"\" cannot be bound to a 'disjoint' expression.");
}
}
status=3;
dup(p, n, false);
ExprHasName dup = Decl.findDuplicateName(decls);
if (dup!=null) throw new ErrorSyntax(dup.span(), "The parameter name \""+dup.label+"\" cannot appear more than once.");
Func ans = new Func(p, isPrivate, n, decls, t, v);
ArrayList<Func> list = funcs.get(n);
if (list==null) { list = new ArrayList<Func>(); funcs.put(n, list); }
list.add(ans);
}