Example #1
0
 XmlNode FindMatch(XmlNodeList nodes, NCC.IMethod methodBase)
 {
     Nemerle.Core.list <Fun_parm> p = methodBase.GetParameters();
     foreach (XmlNode node in nodes)
     {
         XmlNodeList paramList = node.SelectNodes("Parameters/*");
         if (p.Length == 0 && paramList.Count == 0)
         {
             return(node);
         }
         if (p.Length != paramList.Count)
         {
             continue;
         }
         try
         {
             bool matched = true;
             for (int i = 0; i < paramList.Count; i++)
             {
                 Fun_parm k = p.Nth(i);
                 if (k.ty is NCC.MType.Class)
                 {
                     string pname = ((NCC.MType.Class)k.ty).tycon.FrameworkTypeName;
                     if (pname != paramList[i].Attributes["Type"].Value)
                     {
                         matched = false;
                         break;
                     }
                 }
                 else if (k.ty is NCC.MType.Array)
                 {
                     NCC.MType.Array zas = (NCC.MType.Array)k.ty;
                     if (zas.t is NCC.MType.Class)
                     {
                         string pname = ((NCC.MType.Class)zas.t).tycon.FrameworkTypeName + "[]";
                         if (pname != paramList[i].Attributes["Type"].Value)
                         {
                             matched = false;
                             break;
                         }
                     }
                 }
                 else if (k.ty is NCC.MType.Ref)
                 {
                     NCC.MType.Ref zas = (NCC.MType.Ref)k.ty;
                     if (zas.t is NCC.MType.Class)
                     {
                         string pname = ((NCC.MType.Class)zas.t).tycon.FrameworkTypeName + "&";
                         if (pname != paramList[i].Attributes["Type"].Value)
                         {
                             matched = false;
                             break;
                         }
                     }
                 }
                 else
                 {
                     matched = false;
                     break;
                 }
             }
             if (matched)
             {
                 return(node);
             }
         }
         catch { }
     }
     return(null);
 }
Example #2
0
        public ReturnType(NCC.MType type)
        {
            base.arrayDimensions     = new int[0];
            base.pointerNestingLevel = 0;

            if (type is NCC.MType.Class)
            {
                NCC.MType.Class t = (NCC.MType.Class)type;
                base.FullyQualifiedName = t.tycon.FrameworkTypeName
                                          .Replace("`1", "")
                                          .Replace("`2", "")
                                          .Replace("`3", "")
                                          .Replace("`4", "");

                if (t.args.Length > 0)
                {
                    base.genericArguments = new ReturnTypeList();
                    foreach (NCC.TyVar tyvar in t.args)
                    {
                        base.genericArguments.Add(new ReturnType(tyvar.Fix()));
                    }
                }
            }
            else if (type is NCC.MType.TyVarRef)
            {
                base.FullyQualifiedName = ((NCC.MType.TyVarRef)type).tyvar.Name;
            }
            else if (type is NCC.MType.Fun)
            {
                // Use the plain type until Ambience works correctly
                base.FullyQualifiedName = Engine.GetNameFromType(type);
            }
            else if (type is NCC.MType.Tuple)
            {
                // Use the plain type until Ambience works correctly
                base.FullyQualifiedName = Engine.GetNameFromType(type);
            }
            else if (type is NCC.MType.Array)
            {
                NCC.MType.Array a   = (NCC.MType.Array)type;
                ReturnType      rtx = new ReturnType(a.t.Fix());
                this.FullyQualifiedName = rtx.FullyQualifiedName;
                this.arrayDimensions    = new int[rtx.ArrayDimensions.Length + 1];
                this.arrayDimensions[0] = a.rank;
                for (int i = 0; i < rtx.ArrayDimensions.Length; i++)
                {
                    this.arrayDimensions[i + 1] = rtx.ArrayDimensions[i];
                }
            }
            else if (type is NCC.MType.Void)
            {
                base.FullyQualifiedName = "System.Void";
            }
            else if (type is NCC.MType.Ref)
            {
                ReturnType rtx = new ReturnType(((NCC.MType.Ref)type).t.Fix());
                this.FullyQualifiedName = rtx.FullyQualifiedName;
                this.arrayDimensions    = rtx.ArrayDimensions;
            }
            else if (type is NCC.MType.Out)
            {
                ReturnType rtx = new ReturnType(((NCC.MType.Out)type).t.Fix());
                this.FullyQualifiedName = rtx.FullyQualifiedName;
                this.arrayDimensions    = rtx.ArrayDimensions;
            }
        }