コード例 #1
0
        public FieldMeta        Resolve(FieldReference fieldRef)
        {
            string fieldRefName = fieldRef.Name;

            for (int i = 0, max = this.fields.Length; i < max; ++i)
            {
                FieldMeta field = this.fields[i];

                if (field.Name == fieldRefName)
                {
                    return(field);
                }
            }

            return(null);
        }
コード例 #2
0
        public void     ResolveReferences(ICollection <TypeReference> types, ICollection <FieldReference> fields, ICollection <MethodReference> methods)
        {
            int assembliesMetaLength = this.unityMeta.AssembliesMeta.Length;
            DynamicOrderedArray <AssemblyMeta> assemblies = new DynamicOrderedArray <AssemblyMeta>(this.unityMeta.AssembliesMeta);

            foreach (TypeReference typeRef in types)
            {
                TypeMeta meta = null;
                int      j    = 0;

                for (; j < assembliesMetaLength && meta == null; ++j)
                {
                    meta = assemblies.array[j].Resolve(typeRef);
                }

                if (meta != null)
                {
                    assemblies.BringToTop(j - 1);

                    if (meta.ErrorMessage != null)
                    {
                        this.foundTypes.Add(meta);
                    }
                }
                else
                {
                    // Type not found, maybe look into other types. Might be renamed.
                    TypeMeta lastFound        = null;
                    string   typeRefNamespace = typeRef.Namespace;
                    string   typeRefName      = typeRef.Name;

                    j = 0;

                    for (; j < assembliesMetaLength && lastFound == null; ++j)
                    {
                        for (int k = 0, max = assemblies.array[j].Types.Length; k < max; ++k)
                        {
                            TypeMeta typeMeta = assemblies.array[j].Types[k];

                            if (typeMeta.Name == typeRefName)
                            {
                                if (lastFound == null || this.GetLevenshteinDistance(lastFound.Namespace, typeRefNamespace) > this.GetLevenshteinDistance(typeMeta.Namespace, typeRefNamespace))
                                {
                                    lastFound = typeMeta;
                                    break;
                                }
                            }
                        }
                    }

                    if (lastFound != null)
                    {
                        this.missingTypes.Add(new TypeMeta(typeRef, "Type not found, but a similar Type has been found at \"" + lastFound.FullName + "\"."));
                    }
                    else
                    {
                        this.missingTypes.Add(new TypeMeta(typeRef));
                    }
                }
            }

            foreach (FieldReference fieldRef in fields)
            {
                FieldMeta meta = null;
                int       j    = 0;

                for (; j < assembliesMetaLength && meta == null; ++j)
                {
                    meta = assemblies.array[j].Resolve(fieldRef);
                }

                if (meta != null)
                {
                    assemblies.BringToTop(j - 1);

                    if (meta.ErrorMessage != null)
                    {
                        this.foundFields.Add(meta);
                    }
                }
                else
                {
                    this.missingFields.Add(new FieldMeta(fieldRef));
                }
            }

            foreach (MethodReference methodRef in methods)
            {
                MethodMeta meta = null;
                int        j    = 0;

                for (; j < assembliesMetaLength && meta == null; ++j)
                {
                    meta = assemblies.array[j].Resolve(methodRef);
                }

                if (meta != null)
                {
                    assemblies.BringToTop(j - 1);

                    if (meta.ErrorMessage != null)
                    {
                        this.foundMethods.Add(meta);
                    }
                }
                else
                {
                    this.missingMethods.Add(new MethodMeta(methodRef));
                }
            }
        }
コード例 #3
0
 public int      RegisterField(FieldMeta meta)
 {
     return(this.fieldTable.Register(meta));
 }