IsBaseClassOfClass() 공개 메소드

public IsBaseClassOfClass ( CType pDerived, CType pBase ) : bool
pDerived CType
pBase CType
리턴 bool
예제 #1
0
        protected override Expr VisitCAST(ExprCast pExpr)
        {
            Debug.Assert(pExpr != null);

            Expr pArgument = pExpr.Argument;

            // If we have generated an identity cast or reference cast to a base class
            // we can omit the cast.
            if (pArgument.Type == pExpr.Type ||
                SymbolLoader.IsBaseClassOfClass(pArgument.Type, pExpr.Type) ||
                CConversions.FImpRefConv(GetSymbolLoader(), pArgument.Type, pExpr.Type))
            {
                return(Visit(pArgument));
            }

            // If we have a cast to PredefinedType.PT_G_EXPRESSION and the thing that we're casting is
            // a EXPRBOUNDLAMBDA that is an expression tree, then just visit the expression tree.
            if (pExpr.Type != null &&
                pExpr.Type.isPredefType(PredefinedType.PT_G_EXPRESSION) &&
                pArgument is ExprBoundLambda)
            {
                return(Visit(pArgument));
            }

            Expr result = GenerateConversion(pArgument, pExpr.Type, pExpr.isChecked());

            if ((pExpr.Flags & EXPRFLAG.EXF_UNBOXRUNTIME) != 0)
            {
                // Propagate the unbox flag to the call for the ExpressionTreeCallRewriter.
                result.Flags |= EXPRFLAG.EXF_UNBOXRUNTIME;
            }
            return(result);
        }