Esempio n. 1
0
        public static IdentType CreateVariable(String type)
        {
            IdentType it = new IdentType(Class.Variable);

            it.type = type;
            return(it);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public static IdentType CreateFunction(String returnType, String[] paramTypes)
        {
            IdentType it = new IdentType(Class.Function);

            it.returnType = returnType;
            it.paramTypes = paramTypes;
            return(it);
        }
Esempio n. 4
0
 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);
         }
     }
 }
Esempio n. 5
0
        public static IdentType CreateDatatype()
        {
            IdentType it = new IdentType(Class.Datatype);

            return(it);
        }