コード例 #1
0
ファイル: ConstantValues.cs プロジェクト: keremkusmezer/ILSpy
        public IType GetValueType(ITypeResolveContext context)
        {
            CSharpResolver resolver = CreateResolver(context);
            IType          type     = expression.Resolve(resolver).Type;

            if (resolver.Context != context)
            {
                // Retrieve the equivalent type in the new resolve context.
                // E.g. if the constant is defined in a .NET 2.0 project, type might be Int32 from mscorlib 2.0.
                // However, the calling project might be a .NET 4.0 project, so we need to return Int32 from mscorlib 4.0.
                return(type.AcceptVisitor(new MapTypeIntoNewContext(context)));
            }
            return(type);
        }
コード例 #2
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
        public override ResolveResult Resolve(CSharpResolver resolver)
        {
            ResolveResult lhs = left.Resolve(resolver);
            ResolveResult rhs = right.Resolve(resolver);

            return(resolver.ResolveBinaryOperator(operatorType, lhs, rhs));
        }
コード例 #3
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
        public ResolveResult Resolve(ITypeResolveContext context)
        {
            CacheManager cache = context.CacheManager;

            if (cache != null)
            {
                ResolveResult cachedResult = cache.GetShared(this) as ResolveResult;
                if (cachedResult != null)
                {
                    return(cachedResult);
                }
            }
            CSharpResolver resolver = CreateResolver(context);
            ResolveResult  rr       = expression.Resolve(resolver);

            // Retrieve the equivalent type in the new resolve context.
            // E.g. if the constant is defined in a .NET 2.0 project, type might be Int32 from mscorlib 2.0.
            // However, the calling project might be a .NET 4.0 project, so we need to return Int32 from mscorlib 4.0.
            rr = MapToNewContext(rr, new MapTypeIntoNewContext(context));
            if (cache != null)
            {
                cache.SetShared(this, rr);
            }
            return(rr);
        }
コード例 #4
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
 public override ResolveResult Resolve(CSharpResolver resolver)
 {
     return(resolver.ResolveConditional(
                condition.Resolve(resolver),
                trueExpr.Resolve(resolver),
                falseExpr.Resolve(resolver)
                ));
 }
コード例 #5
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
        public override ResolveResult Resolve(CSharpResolver resolver)
        {
            bool oldCheckForOverflow = resolver.CheckForOverflow;

            try {
                resolver.CheckForOverflow = this.checkForOverflow;
                return(expression.Resolve(resolver));
            } finally {
                resolver.CheckForOverflow = oldCheckForOverflow;
            }
        }
コード例 #6
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
        public override ResolveResult Resolve(CSharpResolver resolver)
        {
            ResolveResult rr;

            if (targetType != null)
            {
                rr = new TypeResolveResult(targetType.Resolve(resolver.Context));
            }
            else
            {
                rr = targetExpression.Resolve(resolver);
            }
            return(resolver.ResolveMemberAccess(rr, memberName, ConstantIdentifierReference.ResolveTypes(resolver, typeArguments)));
        }
コード例 #7
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
 public override ResolveResult Resolve(CSharpResolver resolver)
 {
     return(resolver.ResolveUnaryOperator(operatorType, expression.Resolve(resolver)));
 }
コード例 #8
0
ファイル: ConstantValues.cs プロジェクト: shalang/ILSpy
 public override ResolveResult Resolve(CSharpResolver resolver)
 {
     return(resolver.ResolveCast(targetType.Resolve(resolver.Context), expression.Resolve(resolver)));
 }