Exemplo n.º 1
0
        private void LoadSavedMethods(IMetadataHost host, string methodsFN,
                                      IDictionary <string, ITypeDefinition> classNameToTypeMap,
                                      IDictionary <string, IMethodDefinition> methodNameToMethodMap)
        {
            using (StreamReader sr = new StreamReader(methodsFN))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    line = line.Trim();
                    int    ndxOfClass  = line.IndexOf(" CLASS:");
                    string className   = line.Substring(ndxOfClass).Split(':')[1];
                    string methAndArgs = line.Substring(0, ndxOfClass);
                    int    ndxOfArgs   = methAndArgs.IndexOf(" ARGS:");
                    string methName    = methAndArgs.Substring(0, ndxOfArgs).Split(':')[1];
                    string args        = methAndArgs.Substring(ndxOfArgs + 6);

                    if (!classNameToTypeMap.ContainsKey(className))
                    {
                        System.Console.WriteLine("WARNING: LoadSavedMethods: Skipping method {0}", methName);
                        continue;
                    }
                    ITypeDefinition   cl       = classNameToTypeMap[className];
                    IMethodDefinition methDefn = Utils.GetMethodByFullName(cl, methName);
                    if (methDefn == null)
                    {
                        System.Console.WriteLine("WARNING: LoadSavedMethods: Skipping method {0}", methName);
                        continue;
                    }
                    if (methDefn.IsGeneric && args.Length > 0)
                    {
                        IList <ITypeReference> genArgs = getArgsList(args, classNameToTypeMap);
                        if (genArgs != null)
                        {
                            GenericMethodInstance newInstMeth = new GenericMethodInstance(methDefn, genArgs, host.InternFactory);
                            methDefn = newInstMeth;
                        }
                        else
                        {
                            methDefn = null;
                        }
                    }
                    if (methDefn != null)
                    {
                        methodNameToMethodMap[methDefn.FullName()] = methDefn;
                        methods.Add(methDefn);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public virtual GenericMethodInstance VisitGenericMethodInstance(GenericMethodInstance node)
 {
     return node;
 }