Exemplo n.º 1
0
 public void AddFunction(FunctionInfo fi)
 {
     Functions.Add(fi);
 }
Exemplo n.º 2
0
        public override BaseTypeInfo ResolvePropertyPath(Globals globals, params string[] path)
        {
            string str = path[0];

            if (str.Contains('('))
            {
                string       content = str.Substring(0, str.IndexOf('('));
                FunctionInfo fi      = Functions.FirstOrDefault(f => f.Name.Equals(content));
                if (fi != null)
                {
                    if (str.Contains('[') && fi.ReturnType is TemplateInst)
                    {
                        return(((TemplateInst)fi.ReturnType).WrappedType);
                    }
                    else if (fi.ReturnType is TemplateInst)
                    {
                        return(globals.GetTypeInfo(fi.ReturnType.Name.Substring(0, fi.ReturnType.Name.IndexOf('<'))));
                    }
                    return(fi.ReturnType);
                }
            }
            else if (str.Contains('['))
            {
                string content = str.Extract('[', ']');
                str = str.Replace(string.Format("[{0}]", content), "");
                if (!Properties.ContainsKey(str))
                {
                    return(null);
                }
                TemplateInst ti = Properties[str] as TemplateInst;
                if (ti != null && path.Length > 1)
                {
                    TypeInfo t = ti.WrappedType;
                    return(t.ResolvePropertyPath(globals, path.SubArray(1, path.Length - 1)));
                }
                if (ti == null)
                {
                    return(null);
                }
                else if (ti.WrappedType == null)
                {
                    return(ti);
                }
                return(globals.GetTypeInfo(ti.WrappedType.Name));
            }
            else if (Properties.ContainsKey(path[0]))
            {
                BaseTypeInfo ti = Properties[path[0]];
                if (ti is TemplateInst)
                {
                    ti = globals.GetTypeInfo(((TemplateInst)ti).Name);
                }
                if (path.Length > 1)
                {
                    ti = ti.ResolvePropertyPath(globals, path.SubArray(1, path.Length - 1));
                }
                return(ti);
            }
            else if (BaseTypes.Count > 0) // Check our base classes
            {
                foreach (TypeInfo t in BaseTypes)
                {
                    BaseTypeInfo ti = t.ResolvePropertyPath(globals, path);
                    if (ti != null)
                    {
                        return(ti);
                    }
                }
            }
            return(null);
        }