Exemplo 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);
            }
        }
Exemplo n.º 3
0
        private PlaceholderLocalSymbol LookupPlaceholder(string name)
        {
            if (name.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
            {
                var   valueText = name.Substring(2);
                ulong address;
                if (!ulong.TryParse(valueText, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out address))
                {
                    // Invalid value should have been caught by Lexer.
                    throw ExceptionUtilities.UnexpectedValue(valueText);
                }
                return(new ObjectAddressLocalSymbol(_containingMethod, name, this.Compilation.GetSpecialType(SpecialType.System_Object), address));
            }

            PseudoVariableKind kind;
            string             id;
            int index;

            if (!PseudoVariableUtilities.TryParseVariableName(name, caseSensitive: true, kind: out kind, id: out id, index: out index))
            {
                return(null);
            }

            var typeName = PseudoVariableUtilities.GetTypeName(_inspectionContext, kind, id, index);

            if (typeName == null)
            {
                return(null);
            }

            Debug.Assert(typeName.Length > 0);

            var type = _typeNameDecoder.GetTypeSymbolForSerializedType(typeName);

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

            switch (kind)
            {
            case PseudoVariableKind.Exception:
                return(new ExceptionLocalSymbol(_containingMethod, id, type, ExpressionCompilerConstants.GetExceptionMethodName));

            case PseudoVariableKind.StowedException:
                return(new ExceptionLocalSymbol(_containingMethod, id, type, ExpressionCompilerConstants.GetStowedExceptionMethodName));

            case PseudoVariableKind.ReturnValue:
                return(new ReturnValueLocalSymbol(_containingMethod, id, type, index));

            case PseudoVariableKind.ObjectId:
                return(new ObjectIdLocalSymbol(_containingMethod, type, id, isWritable: false));

            case PseudoVariableKind.DeclaredLocal:
                return(new ObjectIdLocalSymbol(_containingMethod, type, id, isWritable: true));

            default:
                throw ExceptionUtilities.UnexpectedValue(kind);
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo 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);

            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);
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 8
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);
            }
        }