예제 #1
0
        public static EType TypeFromName(PTree expr)
        {
            if (!(expr is PName name))
            {
                throw new NotSupportedException($"Attempted to make type from expr {expr.ToPrettyString()}");
            }

            var ns = name.Name;

            if (ns[0] == 'f')
            {
                return(new EFloat(int.Parse(ns.Substring(1))));
            }
            if (ns == "vec")
            {
                return(EType.Vector);
            }
            return(ns[0] == 'i' ? new EInt(true, int.Parse(ns.Substring(1))) : new EInt(false, int.Parse(ns.Substring(1))));
        }