Exemple #1
0
 static bool __IsNullableForTypeHelper(DmdType nullable, DmdType param)
 {
     if (!nullable.IsNullable)
     {
         return(false);
     }
     return(param.IsEquivalentTo(nullable.GetNullableElementType()));
 }
Exemple #2
0
        bool __CanCastParam(DmdType fromParam, DmdType toParam)
        {
            if (fromParam.IsEquivalentTo(toParam))
            {
                return(true);
            }

            var fromParamCorType = fromParam.__GetVerifierCorElementType();

            if (__IsObjRef(fromParamCorType))
            {
                return(fromParam.__CanCastTo(toParam));
            }
            else if (__IsGenericVariable(fromParamCorType))
            {
                if (!fromParam.__ConstrainedAsObjRef())
                {
                    return(false);
                }

                return(fromParam.__CanCastTo(toParam));
            }
            else if (__IsPrimitiveType(fromParamCorType))
            {
                var toParamCorType = toParam.__GetVerifierCorElementType();
                if (__IsPrimitiveType(toParamCorType))
                {
                    if (toParamCorType == fromParamCorType)
                    {
                        return(true);
                    }

                    if ((toParamCorType != DDN.ElementType.Boolean) &&
                        (fromParamCorType != DDN.ElementType.Boolean) &&
                        (toParamCorType != DDN.ElementType.Char) &&
                        (fromParamCorType != DDN.ElementType.Char))
                    {
                        if ((__Size(toParamCorType) == __Size(fromParamCorType)) &&
                            (__IsFloat(toParamCorType) == __IsFloat(fromParamCorType)))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }