Resolve() public method

public Resolve ( FieldReference field ) : FieldReference
field Mono.Cecil.FieldReference
return Mono.Cecil.FieldReference
示例#1
0
        private static void CallBaseTypeFinalizer(MethodDefinition finalizer, CppCodeWriter writer, IRuntimeMetadataAccess metadataAccess)
        {
            MethodReference method = null;
            TypeDefinition  definition;

            Unity.IL2CPP.ILPreProcessor.TypeResolver resolver;
            for (TypeReference reference2 = finalizer.DeclaringType.BaseType; reference2 != null; reference2 = resolver.Resolve(definition.BaseType))
            {
                definition = reference2.Resolve();
                resolver   = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(reference2);
                foreach (MethodDefinition definition2 in definition.Methods)
                {
                    if (definition2.IsFinalizerMethod())
                    {
                        method = resolver.Resolve(definition2);
                        break;
                    }
                }
            }
            if (method != null)
            {
                List <string> argumentArray = new List <string>(2)
                {
                    Naming.ThisParameterName
                };
                if (MethodSignatureWriter.NeedsHiddenMethodInfo(method, MethodCallType.Normal, false))
                {
                    argumentArray.Add(metadataAccess.HiddenMethodInfo(method));
                }
                Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolverForMethodToCall = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(finalizer.DeclaringType);
                string block = MethodBodyWriter.GetMethodCallExpression(finalizer, typeResolverForMethodToCall.Resolve(method), method, typeResolverForMethodToCall, MethodCallType.Normal, metadataAccess, new VTableBuilder(), argumentArray, false, null);
                writer.WriteStatement(block);
            }
        }
        internal static string BuildMethodParameterList(MethodReference interopMethod, MethodReference interfaceMethod, Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolver, MarshalType marshalType, bool includeTypeNames)
        {
            List <string> elements = new List <string>();
            int           num      = 0;

            foreach (ParameterDefinition definition in interopMethod.Parameters)
            {
                MarshalInfo marshalInfo         = interfaceMethod.Parameters[num].MarshalInfo;
                DefaultMarshalInfoWriter writer = MarshalDataCollector.MarshalInfoWriterFor(typeResolver.Resolve(definition.ParameterType), marshalType, marshalInfo, true, false, false, null);
                foreach (MarshaledType type in writer.MarshaledTypes)
                {
                    elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0} {1}", type.DecoratedName, Naming.ForParameterName(definition) + type.VariableName));
                }
                num++;
            }
            TypeReference reference2 = typeResolver.Resolve(interopMethod.ReturnType);

            if (reference2.MetadataType != MetadataType.Void)
            {
                MarshalInfo     info2          = interfaceMethod.MethodReturnType.MarshalInfo;
                MarshaledType[] marshaledTypes = MarshalDataCollector.MarshalInfoWriterFor(reference2, marshalType, info2, true, false, false, null).MarshaledTypes;
                for (int i = 0; i < (marshaledTypes.Length - 1); i++)
                {
                    elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0}* {1}", marshaledTypes[i].DecoratedName, Naming.ForComInterfaceReturnParameterName() + marshaledTypes[i].VariableName));
                }
                elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0}* {1}", marshaledTypes[marshaledTypes.Length - 1].DecoratedName, Naming.ForComInterfaceReturnParameterName()));
            }
            return(elements.AggregateWithComma());
        }
        private void WriteForwardDeclarations(TypeReference type)
        {
            Unity.IL2CPP.ILPreProcessor.TypeResolver resolver = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(type);
            MarshalType marshalType = !type.Resolve().IsWindowsRuntime ? MarshalType.COM : MarshalType.WindowsRuntime;

            foreach (MethodDefinition definition in type.Resolve().Methods)
            {
                foreach (ParameterDefinition definition2 in definition.Parameters)
                {
                    MarshalDataCollector.MarshalInfoWriterFor(resolver.Resolve(definition2.ParameterType), marshalType, definition2.MarshalInfo, true, false, false, null).WriteMarshaledTypeForwardDeclaration(this._writer);
                }
                if (definition.ReturnType.MetadataType != MetadataType.Void)
                {
                    MarshalDataCollector.MarshalInfoWriterFor(resolver.Resolve(definition.ReturnType), marshalType, definition.MethodReturnType.MarshalInfo, true, false, false, null).WriteMarshaledTypeForwardDeclaration(this._writer);
                }
            }
        }
        public static string GetSharedMethodSignature(CppCodeWriter writer, MethodReference method)
        {
            Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolver = new Unity.IL2CPP.ILPreProcessor.TypeResolver(method.DeclaringType as GenericInstanceType, method as GenericInstanceMethod);
            TypeReference variableType = typeResolver.Resolve(Unity.IL2CPP.GenericParameterResolver.ResolveReturnTypeIfNeeded(method));

            RecordIncludes(writer, method, typeResolver);
            string attributes = BuildMethodAttributes(method);

            return(GetMethodSignature(Naming.ForMethodNameOnly(method) + "_gshared", Naming.ForVariable(variableType), FormatParameters(method, ParameterFormat.WithTypeAndName, false, true), "extern \"C\"", attributes));
        }
 private void CollectIncludes(CppCodeWriter writer, TypeReference type, TypeDefinition typeDefinition)
 {
     if (!type.HasGenericParameters)
     {
         if (type is ArrayType)
         {
             writer.AddIncludeForTypeDefinition(TypeProvider.Corlib.MainModule.GetType("System.Array"));
         }
         else
         {
             Unity.IL2CPP.ILPreProcessor.TypeResolver resolver = new Unity.IL2CPP.ILPreProcessor.TypeResolver(type as GenericInstanceType);
             TypeReference typeReference = resolver.Resolve(typeDefinition.BaseType);
             if (typeReference != null)
             {
                 writer.AddIncludeForTypeDefinition(typeReference);
             }
             foreach (FieldDefinition definition in typeDefinition.Fields)
             {
                 writer.AddIncludesForTypeReference(resolver.Resolve(definition.FieldType), false);
             }
             foreach (FieldDefinition definition2 in typeDefinition.Fields)
             {
                 PointerType fieldType = definition2.FieldType as PointerType;
                 if (fieldType != null)
                 {
                     writer.AddForwardDeclaration(resolver.Resolve(fieldType.ElementType));
                 }
             }
             foreach (TypeReference reference2 in type.GetAllFactoryTypes())
             {
                 writer.AddForwardDeclaration(reference2);
             }
             if (typeDefinition.IsDelegate())
             {
                 MethodDefinition[] definitionArray;
                 if (!typeDefinition.IsWindowsRuntime)
                 {
                     MethodDefinition[] definitionArray1 = new MethodDefinition[3];
                     if (< > f__am$cache2 == null)
                     {
        public void WriteComInterfaceFor(TypeReference type)
        {
            this._writer.WriteCommentedLine(type.FullName);
            this.WriteForwardDeclarations(type);
            string str = !type.Resolve().IsWindowsRuntime ? "Il2CppIUnknown" : "Il2CppIInspectable";

            object[] args = new object[] { Naming.ForTypeNameOnly(type), str };
            this._writer.WriteLine("struct NOVTABLE {0} : {1}", args);
            using (new BlockWriter(this._writer, true))
            {
                this._writer.WriteStatement("static const Il2CppGuid IID");
                Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolver = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(type);
                foreach (MethodDefinition definition in type.Resolve().Methods)
                {
                    MethodReference method = typeResolver.Resolve(definition);
                    this._writer.Write(GetSignature(method, method, typeResolver, null));
                    this._writer.WriteLine(" = 0;");
                }
            }
        }