Esempio n. 1
0
        internal static PlaceholderLocalSymbol CreatePlaceholderLocal(
            TypeNameDecoder <PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            Alias alias)
        {
            var typeName = alias.Type;

            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);

            Debug.Assert((object)type != null);

            var dynamicFlagsInfo = alias.CustomTypeInfo.ToDynamicFlagsCustomTypeInfo();

            if (dynamicFlagsInfo.Any())
            {
                var flagsBuilder = ArrayBuilder <bool> .GetInstance();

                dynamicFlagsInfo.CopyTo(flagsBuilder);
                var dynamicType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(
                    type,
                    containingMethod.ContainingAssembly,
                    RefKind.None,
                    flagsBuilder.ToImmutableAndFree(),
                    checkLength: false);
                Debug.Assert(dynamicType != null);
                Debug.Assert(dynamicType != type);
                type = dynamicType;
            }

            var id = alias.FullName;

            switch (alias.Kind)
            {
            case AliasKind.Exception:
                return(new ExceptionLocalSymbol(containingMethod, id, type, ExpressionCompilerConstants.GetExceptionMethodName));

            case AliasKind.StowedException:
                return(new ExceptionLocalSymbol(containingMethod, id, type, ExpressionCompilerConstants.GetStowedExceptionMethodName));

            case AliasKind.ReturnValue:
            {
                int index;
                PseudoVariableUtilities.TryParseReturnValueIndex(id, out index);
                Debug.Assert(index >= 0);
                return(new ReturnValueLocalSymbol(containingMethod, id, type, index));
            }

            case AliasKind.ObjectId:
                return(new ObjectIdLocalSymbol(containingMethod, type, id, isWritable: false));

            case AliasKind.DeclaredLocal:
                return(new ObjectIdLocalSymbol(containingMethod, type, id, isWritable: true));

            default:
                throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }
        internal static LocalSymbol Create(
            TypeNameDecoder <PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            AssemblySymbol sourceAssembly,
            Alias alias)
        {
            var typeName = alias.Type;

            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);

            Debug.Assert((object)type != null);

            ReadOnlyCollection <byte>   dynamicFlags;
            ReadOnlyCollection <string> tupleElementNames;

            CustomTypeInfo.Decode(alias.CustomTypeInfoId, alias.CustomTypeInfo, out dynamicFlags, out tupleElementNames);

            if (dynamicFlags != null)
            {
                type = DecodeDynamicTypes(type, sourceAssembly, dynamicFlags);
            }

            if (tupleElementNames != null)
            {
                type = TupleTypeDecoder.DecodeTupleTypesIfApplicable(type, sourceAssembly, tupleElementNames.AsImmutable());
            }

            var name        = alias.FullName;
            var displayName = alias.Name;

            switch (alias.Kind)
            {
            case DkmClrAliasKind.Exception:
                return(new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetExceptionMethodName));

            case DkmClrAliasKind.StowedException:
                return(new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetStowedExceptionMethodName));

            case DkmClrAliasKind.ReturnValue:
            {
                int index;
                PseudoVariableUtilities.TryParseReturnValueIndex(name, out index);
                Debug.Assert(index >= 0);
                return(new ReturnValueLocalSymbol(containingMethod, name, displayName, type, index));
            }

            case DkmClrAliasKind.ObjectId:
                return(new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: false));

            case DkmClrAliasKind.Variable:
                return(new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: true));

            default:
                throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }
Esempio n. 3
0
 internal PlaceholderLocalBinder(
     InspectionContext inspectionContext,
     TypeNameDecoder <PEModuleSymbol, TypeSymbol> typeNameDecoder,
     CSharpSyntaxNode syntax,
     MethodSymbol containingMethod,
     Binder next) :
     base(next)
 {
     _inspectionContext = inspectionContext;
     _typeNameDecoder   = typeNameDecoder;
     _syntax            = syntax;
     _containingMethod  = containingMethod;
 }
 internal PlaceholderLocalBinder(
     InspectionContext inspectionContext,
     TypeNameDecoder<PEModuleSymbol, TypeSymbol> typeNameDecoder,
     CSharpSyntaxNode syntax,
     MethodSymbol containingMethod,
     Binder next) :
     base(next)
 {
     _inspectionContext = inspectionContext;
     _typeNameDecoder = typeNameDecoder;
     _syntax = syntax;
     _containingMethod = containingMethod;
 }
Esempio n. 5
0
        internal static LocalSymbol Create(
            TypeNameDecoder<PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            AssemblySymbol sourceAssembly,
            Alias alias)
        {
            var typeName = alias.Type;
            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);
            Debug.Assert((object)type != null);

            var dynamicFlagsInfo = alias.CustomTypeInfo.ToDynamicFlagsCustomTypeInfo();
            if (dynamicFlagsInfo.Any())
            {
                var flagsBuilder = ArrayBuilder<bool>.GetInstance();
                dynamicFlagsInfo.CopyTo(flagsBuilder);
                var dynamicType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(
                    type,
                    sourceAssembly,
                    RefKind.None,
                    flagsBuilder.ToImmutableAndFree(),
                    checkLength: false);
                Debug.Assert(dynamicType != null);
                Debug.Assert(dynamicType != type);
                type = dynamicType;
            }

            var name = alias.FullName;
            var displayName = alias.Name;
            switch (alias.Kind)
            {
                case DkmClrAliasKind.Exception:
                    return new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetExceptionMethodName);
                case DkmClrAliasKind.StowedException:
                    return new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetStowedExceptionMethodName);
                case DkmClrAliasKind.ReturnValue:
                    {
                        int index;
                        PseudoVariableUtilities.TryParseReturnValueIndex(name, out index);
                        Debug.Assert(index >= 0);
                        return new ReturnValueLocalSymbol(containingMethod, name, displayName, type, index);
                    }
                case DkmClrAliasKind.ObjectId:
                    return new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: false);
                case DkmClrAliasKind.Variable:
                    return new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: true);
                default:
                    throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }
        internal static LocalSymbol Create(
            TypeNameDecoder<PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            AssemblySymbol sourceAssembly,
            Alias alias)
        {
            var typeName = alias.Type;
            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);
            Debug.Assert((object)type != null);

            ReadOnlyCollection<byte> dynamicFlags;
            ReadOnlyCollection<string> tupleElementNames;
            CustomTypeInfo.Decode(alias.CustomTypeInfoId, alias.CustomTypeInfo, out dynamicFlags, out tupleElementNames);

            if (dynamicFlags != null)
            {
                type = DecodeDynamicTypes(type, sourceAssembly, dynamicFlags);
            }

            if (tupleElementNames != null)
            {
                type = TupleTypeDecoder.DecodeTupleTypesIfApplicable(type, sourceAssembly, tupleElementNames.AsImmutable());
            }

            var name = alias.FullName;
            var displayName = alias.Name;
            switch (alias.Kind)
            {
                case DkmClrAliasKind.Exception:
                    return new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetExceptionMethodName);
                case DkmClrAliasKind.StowedException:
                    return new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetStowedExceptionMethodName);
                case DkmClrAliasKind.ReturnValue:
                    {
                        int index;
                        PseudoVariableUtilities.TryParseReturnValueIndex(name, out index);
                        Debug.Assert(index >= 0);
                        return new ReturnValueLocalSymbol(containingMethod, name, displayName, type, index);
                    }
                case DkmClrAliasKind.ObjectId:
                    return new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: false);
                case DkmClrAliasKind.Variable:
                    return new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: true);
                default:
                    throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }
Esempio n. 7
0
        internal static PlaceholderLocalSymbol CreatePlaceholderLocal(
            TypeNameDecoder <PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            Alias alias)
        {
            var typeName = alias.Type;

            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);

            Debug.Assert((object)type != null);

            var id = alias.FullName;

            switch (alias.Kind)
            {
            case AliasKind.Exception:
                return(new ExceptionLocalSymbol(containingMethod, id, type, ExpressionCompilerConstants.GetExceptionMethodName));

            case AliasKind.StowedException:
                return(new ExceptionLocalSymbol(containingMethod, id, type, ExpressionCompilerConstants.GetStowedExceptionMethodName));

            case AliasKind.ReturnValue:
            {
                int index;
                PseudoVariableUtilities.TryParseReturnValueIndex(id, out index);
                Debug.Assert(index >= 0);
                return(new ReturnValueLocalSymbol(containingMethod, id, type, index));
            }

            case AliasKind.ObjectId:
                return(new ObjectIdLocalSymbol(containingMethod, type, id, isWritable: false));

            case AliasKind.DeclaredLocal:
                return(new ObjectIdLocalSymbol(containingMethod, type, id, isWritable: true));

            default:
                throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }
        internal static PlaceholderLocalSymbol CreatePlaceholderLocal(
            TypeNameDecoder<PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            Alias alias)
        {
            var typeName = alias.Type;
            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);
            Debug.Assert((object)type != null);

            var id = alias.FullName;
            switch (alias.Kind)
            {
                case AliasKind.Exception:
                    return new ExceptionLocalSymbol(containingMethod, id, type, ExpressionCompilerConstants.GetExceptionMethodName);
                case AliasKind.StowedException:
                    return new ExceptionLocalSymbol(containingMethod, id, type, ExpressionCompilerConstants.GetStowedExceptionMethodName);
                case AliasKind.ReturnValue:
                    {
                        int index;
                        PseudoVariableUtilities.TryParseReturnValueIndex(id, out index);
                        Debug.Assert(index >= 0);
                        return new ReturnValueLocalSymbol(containingMethod, id, type, index);
                    }
                case AliasKind.ObjectId:
                    return new ObjectIdLocalSymbol(containingMethod, type, id, isWritable: false);
                case AliasKind.DeclaredLocal:
                    return new ObjectIdLocalSymbol(containingMethod, type, id, isWritable: true);
                default:
                    throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }
 private EEMethodSymbol GetPseudoVariableMethod(
     TypeNameDecoder<PEModuleSymbol, TypeSymbol> typeNameDecoder,
     EENamedTypeSymbol container,
     string methodName,
     Alias alias)
 {
     var syntax = SyntaxFactory.IdentifierName(SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken));
     return this.CreateMethod(container, methodName, syntax, (method, diagnostics) =>
     {
         var local = PlaceholderLocalBinder.CreatePlaceholderLocal(typeNameDecoder, method, alias);
         var expression = new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type);
         return new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
     });
 }
Esempio n. 10
0
        internal static LocalSymbol Create(
            TypeNameDecoder <PEModuleSymbol, TypeSymbol> typeNameDecoder,
            MethodSymbol containingMethod,
            AssemblySymbol sourceAssembly,
            Alias alias)
        {
            var typeName = alias.Type;

            Debug.Assert(typeName.Length > 0);

            var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName);

            Debug.Assert((object)type != null);

            ReadOnlyCollection <byte>   dynamicFlags;
            ReadOnlyCollection <string> tupleElementNames;

            CustomTypeInfo.Decode(alias.CustomTypeInfoId, alias.CustomTypeInfo, out dynamicFlags, out tupleElementNames);

            // Preserve tuple element names. See https://github.com/dotnet/roslyn/issues/13589.
            if (dynamicFlags != null)
            {
                var flagsBuilder = ArrayBuilder <bool> .GetInstance();

                DynamicFlagsCustomTypeInfo.CopyTo(dynamicFlags, flagsBuilder);
                var dynamicType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(
                    type,
                    sourceAssembly,
                    RefKind.None,
                    flagsBuilder.ToImmutableAndFree(),
                    checkLength: false);
                Debug.Assert(dynamicType != null);
                Debug.Assert(dynamicType != type);
                type = dynamicType;
            }

            var name        = alias.FullName;
            var displayName = alias.Name;

            switch (alias.Kind)
            {
            case DkmClrAliasKind.Exception:
                return(new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetExceptionMethodName));

            case DkmClrAliasKind.StowedException:
                return(new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetStowedExceptionMethodName));

            case DkmClrAliasKind.ReturnValue:
            {
                int index;
                PseudoVariableUtilities.TryParseReturnValueIndex(name, out index);
                Debug.Assert(index >= 0);
                return(new ReturnValueLocalSymbol(containingMethod, name, displayName, type, index));
            }

            case DkmClrAliasKind.ObjectId:
                return(new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: false));

            case DkmClrAliasKind.Variable:
                return(new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: true));

            default:
                throw ExceptionUtilities.UnexpectedValue(alias.Kind);
            }
        }