package edu.neu.ccs.demeterf.demfgen.dgp;

import edu.neu.ccs.demeterf.demfgen.Diff;
import edu.neu.ccs.demeterf.demfgen.ClassGen;
import edu.neu.ccs.demeterf.demfgen.classes.*;
import edu.neu.ccs.demeterf.lib.*;

/**  */
public abstract class Concrete extends TravGeneric{
    public Concrete(String beh){ super(beh); }
    
    public abstract Concrete functionObj(String beh);
    
    public String combine(ClassDef td){ return (td.typeParams().isEmpty())?recur(td):""; }
    
    // These are to collect uses from SumTypes
    public SumToken combine(SumToken s){ return s; }

    public List<String> combine(SubtypeList e){ return List.create(); }
    public List<String> combine(SubtypeList s, TypeUse f, List<String> r){ return r.push(""+f); }
    public List<String> combine(NESubtypeList s, TypeUse f, List<String> r){ return r.push(""+f); }
    public String combine(Bound b){ return ""; }
    
    List<String> chars = List.create("char","Char","Character"),
                 strs = List.create("string","String");
    public String wrapStr(String p, String arg){
        boolean esc = (chars.contains(p) || strs.contains(p));
        String wrap = (strs.contains(p)?"\\\"":chars.contains(p)?"\\\'":"");
        return ((esc?"\""+wrap+"\"+":"")+
                (esc?"escape(":"")+"\"\"+"+arg+
                (esc?")+\""+wrap+"\"":""));
    }
    
    public List<?> combine(FieldEmpty e){ return List.create(); }
    public List<?> combine(FieldCons l, Object f, List r){ return r.push(f); }
    
    public String combine(Cons<TypeDef> l, String f, String r){ return f+r; }
    public String combine(Empty<TypeDef> l){ return ""; }
    
    public String combine(IntfcDef id){ return ""; }
    
    public static String argType(ident name, TypeDefParams dp){ return argType(""+name,dp); }
    public static String argType(String name, TypeDefParams dp){
        return name+(!dp.isEmpty() && Diff.d.isCS()?ClassGen.unlocal(dp):"");
    }
}