コード例 #1
0
ファイル: MethodBuilder.cs プロジェクト: luozhiping1987/dot42
        /// <summary>
        /// Make minor fixes after the implementation phase.
        /// </summary>
        public void FixUp(DexTargetPackage targetPackage)
        {
            var iMethod = method.GetBaseInterfaceMethod();

            Mono.Cecil.TypeReference inheritedReturnType = null;
            //var iMethod = method.Overrides.Select(x => x.Resolve()).Where(x => x != null).FirstOrDefault(x => x.DeclaringType.IsInterface);
            if (iMethod != null)
            {
                inheritedReturnType = iMethod.ReturnType;
            }

            var baseMethod = method.GetBaseMethod();

            if (baseMethod != null)
            {
                inheritedReturnType = baseMethod.ReturnType;
            }


            if (inheritedReturnType != null)
            {
                var inheritedTargetReturnType = inheritedReturnType.GetReference(targetPackage, compiler.Module);
                if (inheritedTargetReturnType.Descriptor != dmethod.Prototype.ReturnType.Descriptor)
                {
                    dmethod.Prototype.Unfreeze();
                    dmethod.Prototype.ReturnType = inheritedTargetReturnType;
                    dmethod.Prototype.Freeze();
                    //// update the original method's return type as well,
                    //// to make sure the code generation later knows what it is handling.
                    //// TODO: this seems to be a hack. shouldn't this have been handled
                    ////       during the IL-conversion phase?
                    xMethod.SetInheritedReturnType(inheritedReturnType);
                }
            }
        }
コード例 #2
0
ファイル: MethodBuilder.cs プロジェクト: yuva2achieve/dot42
        /// <summary>
        /// Implement make minor fixes after the implementation phase.
        /// </summary>
        public void FixUp(DexTargetPackage targetPackage)
        {
            var iMethod = method.GetBaseInterfaceMethod();

            //var iMethod = method.Overrides.Select(x => x.Resolve()).Where(x => x != null).FirstOrDefault(x => x.DeclaringType.IsInterface);
            if (iMethod != null)
            {
                dmethod.Prototype.ReturnType = iMethod.ReturnType.GetReference(targetPackage, compiler.Module);
            }

            var baseMethod = method.GetBaseMethod();

            if (baseMethod != null)
            {
                dmethod.Prototype.ReturnType = baseMethod.ReturnType.GetReference(targetPackage, compiler.Module);
            }
        }