public static IdentType CreateVariable(String type) { IdentType it = new IdentType(Class.Variable); it.type = type; return(it); }
public static bool Equals(IdentType a, IdentType b) { if (a.typeClass != b.typeClass) { return(false); } // Might want to change how we check equality. I'll see later. if (a.typeClass == Class.Variable) { return(a.type == b.type); } else if (a.typeClass == Class.Function) { if (a.returnType != b.returnType) { return(false); } if (a.paramTypes.Length != b.paramTypes.Length) { return(false); } for (int i = 0; i < a.paramTypes.Length; i++) { if (a.paramTypes[i] != b.paramTypes[i]) { return(false); } } return(true); } return(false); }
public static IdentType CreateFunction(String returnType, String[] paramTypes) { IdentType it = new IdentType(Class.Function); it.returnType = returnType; it.paramTypes = paramTypes; return(it); }
public void addSymbol(String name, IdentType type) { if (!symbols.ContainsKey(name)) { symbols[name] = new List <IdentType>(); symbols[name].Add(type); } else { if (symbols[name][0].typeClass != IdentType.Class.Function || type.typeClass != IdentType.Class.Function) // Only allow function overloading { throw new Exception("Trying to overload name " + name + ". Only function types may be overloaded."); } else { symbols[name].Add(type); } } }
public static IdentType CreateDatatype() { IdentType it = new IdentType(Class.Datatype); return(it); }