コード例 #1
0
 private object ResolveOperand(object operand, GenericArguments genericArgs)
 {
     if (operand is MemberRef)
     {
         var memberRef = (MemberRef)operand;
         if (memberRef.IsFieldRef)
         {
             var field = ResolveField(memberRef.FieldSig, genericArgs);
             memberRef = new MemberRefUser(memberRef.Module, memberRef.Name, field, memberRef.Class);
         }
         else
         {
             var method = ResolveMethod(memberRef.MethodSig, genericArgs);
             memberRef = new MemberRefUser(memberRef.Module, memberRef.Name, method, memberRef.Class);
         }
         return(memberRef);
     }
     if (operand is TypeSpec)
     {
         var sig = ((TypeSpec)operand).TypeSig;
         return(genericArgs.ResolveType(sig).ToTypeDefOrRef());
     }
     if (operand is MethodSpec)
     {
         var spec = (MethodSpec)operand;
         spec = new MethodSpecUser(spec.Method, ResolveInst(spec.GenericInstMethodSig, genericArgs));
         return(spec);
     }
     return(operand);
 }
コード例 #2
0
        private FieldSig ResolveField(FieldSig sig, GenericArguments genericArgs)
        {
            var newSig = sig.Clone();

            newSig.Type = genericArgs.ResolveType(newSig.Type);
            return(newSig);
        }
コード例 #3
0
        GenericInstMethodSig ResolveInst(GenericInstMethodSig sig, GenericArguments genericArgs)
        {
            var newSig = sig.Clone();

            for (int i = 0; i < newSig.GenericArguments.Count; i++)
            {
                newSig.GenericArguments[i] = genericArgs.ResolveType(newSig.GenericArguments[i]);
            }
            return(newSig);
        }
コード例 #4
0
        MethodSig ResolveMethod(MethodSig sig, GenericArguments genericArgs)
        {
            var newSig = sig.Clone();

            for (int i = 0; i < newSig.Params.Count; i++)
            {
                newSig.Params[i] = genericArgs.ResolveType(newSig.Params[i]);
            }

            if (newSig.ParamsAfterSentinel != null)
            {
                for (int i = 0; i < newSig.ParamsAfterSentinel.Count; i++)
                {
                    newSig.ParamsAfterSentinel[i] = genericArgs.ResolveType(newSig.ParamsAfterSentinel[i]);
                }
            }

            newSig.RetType = genericArgs.ResolveType(newSig.RetType);
            return(newSig);
        }
コード例 #5
0
        private static ASTType?InferVarPush(ILASTExpression expr)
        {
            var method = (IMethod)expr.Operand;

            if (method.MethodSig.RetType.ElementType == ElementType.Void)
            {
                return(null);
            }

            var genArgs = new GenericArguments();

            if (method is MethodSpec)
            {
                genArgs.PushMethodArgs(((MethodSpec)method).GenericInstMethodSig.GenericArguments);
            }
            if (method.DeclaringType.TryGetGenericInstSig() != null)
            {
                genArgs.PushTypeArgs(method.DeclaringType.TryGetGenericInstSig().GenericArguments);
            }


            return(TypeInference.ToASTType(genArgs.ResolveType(method.MethodSig.RetType)));
        }