Ejemplo n.º 1
0
        protected override LocalDefinition DeclareLocalInternal(
            Microsoft.Cci.ITypeReference type,
            object identity,
            string name,
            bool isCompilerGenerated,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray<TypedConstant> dynamicTransformFlags)
        {
            if (allLocals == null)
            {
                allLocals = ImmutableArray.CreateBuilder<LocalDefinition>(1);
            }

            var local = new LocalDefinition(
                identity: identity,
                name: name,
                type: type,
                slot: this.allLocals.Count,
                isCompilerGenerated: isCompilerGenerated,
                constraints: constraints,
                isDynamic: isDynamic,
                dynamicTransformFlags: dynamicTransformFlags);

            this.allLocals.Add(local);
            return local;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a local slot.
        /// </summary>
        internal LocalDefinition AllocateSlot(
            Cci.ITypeReference type,
            LocalSlotConstraints constraints,
            ImmutableArray <bool> dynamicTransformFlags = default,
            ImmutableArray <string> tupleElementNames   = default
            )
        {
            if (
                !FreeSlots.TryPop(new LocalSignature(type, constraints), out LocalDefinition? local)
                )
            {
                local = DeclareLocalImpl(
                    type: type,
                    symbol: null,
                    name: null,
                    kind: SynthesizedLocalKind.EmitterTemp,
                    id: LocalDebugId.None,
                    pdbAttributes: LocalVariableAttributes.DebuggerHidden,
                    constraints: constraints,
                    dynamicTransformFlags: dynamicTransformFlags,
                    tupleElementNames: tupleElementNames
                    );
            }

            return(local);
        }
        protected override LocalDefinition DeclareLocalInternal(
            Microsoft.Cci.ITypeReference type,
            object identity,
            string name,
            bool isCompilerGenerated,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            if (allLocals == null)
            {
                allLocals = ImmutableArray.CreateBuilder <LocalDefinition>(1);
            }

            var local = new LocalDefinition(
                identity: identity,
                name: name,
                type: type,
                slot: this.allLocals.Count,
                isCompilerGenerated: isCompilerGenerated,
                constraints: constraints,
                isDynamic: isDynamic,
                dynamicTransformFlags: dynamicTransformFlags);

            this.allLocals.Add(local);
            return(local);
        }
Ejemplo n.º 4
0
 public EncLocalInfo(LocalSlotDebugInfo slotInfo, Cci.ITypeReference type, LocalSlotConstraints constraints, byte[]? signature)
 {
     SlotInfo = slotInfo;
     Type = type;
     Constraints = constraints;
     Signature = signature;
     IsUnused = false;
 }
Ejemplo n.º 5
0
 protected abstract LocalDefinition DeclareLocalInternal(
     ITypeReference type,
     object identity,
     string name,
     bool isCompilerGenerated,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags);
Ejemplo n.º 6
0
        public EncLocalInfo(int offset, ITypeReference type, LocalSlotConstraints constraints, int tempKind)
        {
            Debug.Assert(type != null);

            this.Offset      = offset;
            this.Type        = type;
            this.Constraints = constraints;
            this.TempKind    = tempKind;
        }
Ejemplo n.º 7
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbol symbol,
     string nameOpt,
     CommonSynthesizedLocalKind synthesizedKind,
     uint pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags);
Ejemplo n.º 8
0
        private LocalDefinition DeclareLocalImpl(
            Cci.ITypeReference type,
            ILocalSymbolInternal?symbol,
            string?name,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            LocalVariableAttributes pdbAttributes,
            LocalSlotConstraints constraints,
            ImmutableArray <bool> dynamicTransformFlags,
            ImmutableArray <string> tupleElementNames
            )
        {
            if (_lazyAllLocals == null)
            {
                _lazyAllLocals = new ArrayBuilder <Cci.ILocalDefinition>(1);
            }

            LocalDefinition?local;

            if (symbol != null && _slotAllocator != null)
            {
                local = _slotAllocator.GetPreviousLocal(
                    type,
                    symbol,
                    name,
                    kind,
                    id,
                    pdbAttributes,
                    constraints,
                    dynamicTransformFlags: dynamicTransformFlags,
                    tupleElementNames: tupleElementNames
                    );

                if (local != null)
                {
                    int slot = local.SlotIndex;
                    _lazyAllLocals[slot] = local;
                    return(local);
                }
            }

            local = new LocalDefinition(
                symbolOpt: symbol,
                nameOpt: name,
                type: type,
                slot: _lazyAllLocals.Count,
                synthesizedKind: kind,
                id: id,
                pdbAttributes: pdbAttributes,
                constraints: constraints,
                dynamicTransformFlags: dynamicTransformFlags,
                tupleElementNames: tupleElementNames
                );

            _lazyAllLocals.Add(local);
            return(local);
        }
Ejemplo n.º 9
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbolInternal symbol,
     string nameOpt,
     SynthesizedLocalKind kind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     ImmutableArray <string> tupleElementNames);
Ejemplo n.º 10
0
        public EncLocalInfo(byte[] signature)
        {
            Debug.Assert(signature.Length > 0);

            SlotInfo = new LocalSlotDebugInfo(SynthesizedLocalKind.EmitterTemp, LocalDebugId.None);
            Type = null;
            Constraints = LocalSlotConstraints.None;
            Signature = signature;
            IsUnused = true;
        }
Ejemplo n.º 11
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbolInternal symbol,
     string nameOpt,
     SynthesizedLocalKind kind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags);
Ejemplo n.º 12
0
        public EncLocalInfo(LocalSlotDebugInfo slotInfo, Cci.ITypeReference type, LocalSlotConstraints constraints, byte[] signature)
        {
            Debug.Assert(type != null);

            this.SlotInfo    = slotInfo;
            this.Type        = type;
            this.Constraints = constraints;
            this.Signature   = signature;
            this.isUnused    = false;
        }
Ejemplo n.º 13
0
        public EncLocalInfo(int offset, ITypeReference type, LocalSlotConstraints constraints, CommonSynthesizedLocalKind synthesizedKind, byte[] signature)
        {
            Debug.Assert(type != null);

            this.Offset          = offset;
            this.Type            = type;
            this.Constraints     = constraints;
            this.SynthesizedKind = synthesizedKind;
            this.Signature       = signature;
        }
Ejemplo n.º 14
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbolInternal symbol,
     string nameOpt,
     SynthesizedLocalKind kind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray<TypedConstant> dynamicTransformFlags);
Ejemplo n.º 15
0
        public EncLocalInfo(byte[] signature)
        {
            Debug.Assert(signature != null);
            Debug.Assert(signature.Length > 0);

            this.SlotInfo    = new LocalSlotDebugInfo(SynthesizedLocalKind.EmitterTemp, LocalDebugId.None);
            this.Type        = null;
            this.Constraints = default(LocalSlotConstraints);
            this.Signature   = signature;
            this.isUnused    = true;
        }
Ejemplo n.º 16
0
        public EncLocalInfo(byte[] signature)
        {
            Debug.Assert(signature != null);
            Debug.Assert(signature.Length > 0);

            this.Offset          = -1;
            this.Type            = null;
            this.Constraints     = default(LocalSlotConstraints);
            this.SynthesizedKind = 0;
            this.Signature       = signature;
        }
Ejemplo n.º 17
0
        public override LocalDefinition GetPreviousLocal(
            Cci.ITypeReference currentType,
            ILocalSymbolInternal currentLocalSymbol,
            string nameOpt,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            if (id.IsNone)
            {
                return(null);
            }

            LocalDebugId previousId;

            if (!TryGetPreviousLocalId(currentLocalSymbol.GetDeclaratorSyntax(), id, out previousId))
            {
                return(null);
            }

            var previousType = _symbolMap.MapReference(currentType);

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

            // TODO (bug #781309): Should report a warning if the type of the local has changed
            // and the previous value will be dropped.
            var localKey = new EncLocalInfo(new LocalSlotDebugInfo(kind, previousId), previousType, constraints, signature: null);

            int slot;

            if (!_previousLocalSlots.TryGetValue(localKey, out slot))
            {
                return(null);
            }

            return(new LocalDefinition(
                       currentLocalSymbol,
                       nameOpt,
                       currentType,
                       slot,
                       kind,
                       id,
                       pdbAttributes,
                       constraints,
                       isDynamic,
                       dynamicTransformFlags));
        }
Ejemplo n.º 18
0
        public override LocalDefinition GetPreviousLocal(
            Cci.ITypeReference type,
            ILocalSymbol symbol,
            string nameOpt,
            CommonSynthesizedLocalKind synthesizedKind,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            var syntaxRefs = symbol.DeclaringSyntaxReferences;

            Debug.Assert(!syntaxRefs.IsDefault);

            if (!syntaxRefs.IsDefaultOrEmpty)
            {
                var currentSyntax  = syntaxRefs[0].GetSyntax();
                var previousSyntax = syntaxMap(currentSyntax);
                if (previousSyntax != null)
                {
                    int offset;
                    if (previousDeclaratorToOffset.TryGetValue(previousSyntax, out offset))
                    {
                        var previousType = symbolMap.MapReference(type);
                        if (previousType != null)
                        {
                            var localKey = new EncLocalInfo(offset, previousType, constraints, synthesizedKind, signature: null);
                            int slot;
                            // Should report a warning if the type of the local has changed
                            // and the previous value will be dropped. (Bug #781309.)
                            if (previousLocalInfoToSlot.TryGetValue(localKey, out slot))
                            {
                                return(new LocalDefinition(
                                           symbol,
                                           nameOpt,
                                           type,
                                           slot,
                                           synthesizedKind,
                                           pdbAttributes,
                                           constraints,
                                           isDynamic,
                                           dynamicTransformFlags));
                            }
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 19
0
        private LocalDefinition DeclareLocalImpl(
            Cci.ITypeReference type,
            ILocalSymbolInternal symbolOpt,
            string nameOpt,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            if (_lazyAllLocals == null)
            {
                _lazyAllLocals = new ArrayBuilder <Cci.ILocalDefinition>(1);
            }

            LocalDefinition local;

            if (symbolOpt != null && _slotAllocatorOpt != null)
            {
                local = _slotAllocatorOpt.GetPreviousLocal(type, symbolOpt, nameOpt, kind, id, pdbAttributes, constraints, isDynamic, dynamicTransformFlags);
                if (local != null)
                {
                    int slot = local.SlotIndex;
                    _lazyAllLocals[slot] = local;
                    return(local);
                }
            }

            local = new LocalDefinition(
                symbolOpt: symbolOpt,
                nameOpt: nameOpt,
                type: type,
                slot: _lazyAllLocals.Count,
                synthesizedKind: kind,
                id: id,
                pdbAttributes: pdbAttributes,
                constraints: constraints,
                isDynamic: isDynamic,
                dynamicTransformFlags: dynamicTransformFlags);

            _lazyAllLocals.Add(local);
            return(local);
        }
Ejemplo n.º 20
0
        protected override LocalDefinition DeclareLocalInternal(
            Microsoft.Cci.ITypeReference type,
            object identity,
            string name,
            bool isCompilerGenerated,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            LocalDefinition local;

            if (identity != null)
            {
                int slot = this.getPreviousLocalSlot(identity, type, constraints);
                if (slot >= 0)
                {
                    Debug.Assert(this.allLocals[slot].Identity == null);

                    local = new LocalDefinition(
                        identity: identity,
                        name: name,
                        type: type,
                        slot: slot,
                        isCompilerGenerated: isCompilerGenerated,
                        constraints: constraints,
                        isDynamic: isDynamic,
                        dynamicTransformFlags: dynamicTransformFlags);
                    this.allLocals[slot] = local;
                    return(local);
                }
            }

            local = new LocalDefinition(
                identity: identity,
                name: name,
                type: type,
                slot: this.allLocals.Count,
                isCompilerGenerated: isCompilerGenerated,
                constraints: constraints,
                isDynamic: isDynamic,
                dynamicTransformFlags: dynamicTransformFlags);
            this.allLocals.Add(local);
            return(local);
        }
Ejemplo n.º 21
0
        protected override LocalDefinition DeclareLocalInternal(
            Microsoft.Cci.ITypeReference type,
            object identity,
            string name,
            bool isCompilerGenerated,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray<TypedConstant> dynamicTransformFlags)
        {
            LocalDefinition local;

            if (identity != null)
            {
                int slot = this.getPreviousLocalSlot(identity, type, constraints);
                if (slot >= 0)
                {
                    Debug.Assert(this.allLocals[slot].Identity == null);

                    local = new LocalDefinition(
                        identity: identity,
                        name: name,
                        type: type,
                        slot: slot,
                        isCompilerGenerated: isCompilerGenerated,
                        constraints: constraints,
                        isDynamic: isDynamic,
                        dynamicTransformFlags: dynamicTransformFlags);
                    this.allLocals[slot] = local;
                    return local;
                }
            }

            local = new LocalDefinition(
                identity: identity,
                name: name,
                type: type,
                slot: this.allLocals.Count,
                isCompilerGenerated: isCompilerGenerated,
                constraints: constraints,
                isDynamic: isDynamic,
                dynamicTransformFlags: dynamicTransformFlags);
            this.allLocals.Add(local);
            return local;
        }
Ejemplo n.º 22
0
        internal LocalDefinition DeclareLocal(
            ITypeReference type,
            object identity,
            string name,
            bool isCompilerGenerated,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            LocalDefinition local;

            if ((name != null) || !FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalInternal(type, identity, name, isCompilerGenerated, constraints, isDynamic, dynamicTransformFlags);
            }

            LocalMap.Add(identity, local);
            return(local);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="identity">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="name">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="dynamicTransformFlags">Contains the synthesized dynamic attributes of the local</param>
 /// <param name="isCompilerGenerated">True if the local was not declared in source.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="isDynamic">Specifies if the type is Dynamic.</param>
 public LocalDefinition(
     object identity,
     string name,
     Microsoft.Cci.ITypeReference type,
     int slot,
     bool isCompilerGenerated,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray<TypedConstant> dynamicTransformFlags)
 {
     this.identity = identity;
     this.name = name;
     this.type = type;
     this.slot = slot;
     this.isCompilerGenerated = isCompilerGenerated;
     this.dynamicTransformFlags = dynamicTransformFlags;
     this.constraints = constraints;
     this.isDynamic = isDynamic;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="identity">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="name">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="dynamicTransformFlags">Contains the synthesized dynamic attributes of the local</param>
 /// <param name="isCompilerGenerated">True if the local was not declared in source.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="isDynamic">Specifies if the type is Dynamic.</param>
 public LocalDefinition(
     object identity,
     string name,
     Cci.ITypeReference type,
     int slot,
     bool isCompilerGenerated,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags)
 {
     this.identity              = identity;
     this.name                  = name;
     this.type                  = type;
     this.slot                  = slot;
     this.isCompilerGenerated   = isCompilerGenerated;
     this.dynamicTransformFlags = dynamicTransformFlags;
     this.constraints           = constraints;
     this.isDynamic             = isDynamic;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="nameOpt">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="synthesizedKind">Local kind.</param>
 /// <param name="id">Local id.</param>
 /// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="dynamicTransformFlags">The synthesized dynamic attributes of the local.</param>
 /// <param name="tupleElementNames">Tuple element names of the local.</param>
 public LocalDefinition(
     ILocalSymbol symbolOpt,
     string nameOpt,
     Cci.ITypeReference type,
     int slot,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     ImmutableArray <string> tupleElementNames)
 {
     _symbolOpt         = symbolOpt;
     _nameOpt           = nameOpt;
     _type              = type;
     _slot              = slot;
     _slotInfo          = new LocalSlotDebugInfo(synthesizedKind, id);
     _pdbAttributes     = pdbAttributes;
     _tupleElementNames = tupleElementNames.NullToEmpty();
     _constraints       = constraints;
 }
Ejemplo n.º 26
0
            public override LocalDefinition GetPreviousLocal(
                Cci.ITypeReference type,
                ILocalSymbolInternal symbol,
                string nameOpt,
                SynthesizedLocalKind synthesizedKind,
                LocalDebugId id,
                uint pdbAttributes,
                LocalSlotConstraints constraints,
                bool isDynamic,
                ImmutableArray <TypedConstant> dynamicTransformFlags)
            {
                var local = symbol as EELocalSymbol;

                if ((object)local == null)
                {
                    return(null);
                }

                return(_locals[local.Ordinal]);
            }
Ejemplo n.º 27
0
        internal LocalDefinition DeclareLocal(
            Cci.ITypeReference type,
            ILocalSymbolInternal symbol,
            string name,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            LocalVariableAttributes pdbAttributes,
            LocalSlotConstraints constraints,
            ImmutableArray <TypedConstant> dynamicTransformFlags,
            ImmutableArray <TypedConstant> tupleElementNames,
            bool isSlotReusable)
        {
            if (!isSlotReusable || !FreeSlots.TryPop(new LocalSignature(type, constraints), out LocalDefinition local))
            {
                local = this.DeclareLocalImpl(type, symbol, name, kind, id, pdbAttributes, constraints, dynamicTransformFlags, tupleElementNames);
            }

            LocalMap.Add(symbol, local);
            return(local);
        }
Ejemplo n.º 28
0
        internal LocalDefinition DeclareLocal(
            Cci.ITypeReference type,
            ILocalSymbol symbol,
            string name,
            CommonSynthesizedLocalKind synthesizedKind,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            LocalDefinition local;

            if ((name != null) || !FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalImpl(type, symbol, name, synthesizedKind, pdbAttributes, constraints, isDynamic, dynamicTransformFlags);
            }

            LocalMap.Add(symbol, local);
            return(local);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Gets a local slot.
        /// </summary>
        internal LocalDefinition AllocateSlot(
            ITypeReference type,
            LocalSlotConstraints constraints,
            ImmutableArray <TypedConstant> dynamicTransformFlags = default(ImmutableArray <TypedConstant>))
        {
            LocalDefinition local;

            if (!FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalInternal(
                    type: type,
                    identity: null,
                    name: null,
                    isCompilerGenerated: true,
                    constraints: constraints,
                    isDynamic: false,
                    dynamicTransformFlags: dynamicTransformFlags);
            }
            return(local);
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="nameOpt">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="dynamicTransformFlags">Contains the synthesized dynamic attributes of the local</param>
 /// <param name="synthesizedKind">Synthesized local kind.</param>
 /// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="isDynamic">Specifies if the type is Dynamic.</param>
 public LocalDefinition(
     ILocalSymbol symbolOpt,
     string nameOpt,
     Cci.ITypeReference type,
     int slot,
     CommonSynthesizedLocalKind synthesizedKind,
     uint pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags)
 {
     this.symbolOpt             = symbolOpt;
     this.nameOpt               = nameOpt;
     this.type                  = type;
     this.slot                  = slot;
     this.synthesizedKind       = synthesizedKind;
     this.pdbAttributes         = pdbAttributes;
     this.dynamicTransformFlags = dynamicTransformFlags;
     this.constraints           = constraints;
     this.isDynamic             = isDynamic;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="nameOpt">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="dynamicTransformFlags">Contains the synthesized dynamic attributes of the local</param>
 /// <param name="synthesizedKind">Local kind.</param>
 /// <param name="id">Local id.</param>
 /// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="isDynamic">Specifies if the type is Dynamic.</param>
 public LocalDefinition(
     ILocalSymbol symbolOpt,
     string nameOpt,
     Cci.ITypeReference type,
     int slot,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags)
 {
     _symbolOpt             = symbolOpt;
     _nameOpt               = nameOpt;
     _type                  = type;
     _slot                  = slot;
     _slotInfo              = new LocalSlotDebugInfo(synthesizedKind, id);
     _pdbAttributes         = pdbAttributes;
     _dynamicTransformFlags = dynamicTransformFlags;
     _constraints           = constraints;
     _isDynamic             = isDynamic;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Gets a local slot.
        /// </summary>
        internal LocalDefinition AllocateSlot(
            Cci.ITypeReference type,
            LocalSlotConstraints constraints,
            ImmutableArray <TypedConstant> dynamicTransformFlags = default(ImmutableArray <TypedConstant>))
        {
            LocalDefinition local;

            if (!FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalImpl(
                    type: type,
                    symbolOpt: null,
                    nameOpt: null,
                    synthesizedKind: CommonSynthesizedLocalKind.EmitterTemp,
                    pdbAttributes: Cci.PdbWriter.HiddenLocalAttributesValue,
                    constraints: constraints,
                    isDynamic: false,
                    dynamicTransformFlags: dynamicTransformFlags);
            }

            return(local);
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="nameOpt">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="synthesizedKind">Local kind.</param>
 /// <param name="id">Local id.</param>
 /// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="dynamicTransformFlags">The synthesized dynamic attributes of the local.</param>
 /// <param name="tupleElementNames">Tuple element names of the local.</param>
 public LocalDefinition(
     ILocalSymbol symbolOpt,
     string nameOpt,
     Cci.ITypeReference type,
     int slot,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     ImmutableArray<TypedConstant> dynamicTransformFlags,
     ImmutableArray<TypedConstant> tupleElementNames)
 {
     _symbolOpt = symbolOpt;
     _nameOpt = nameOpt;
     _type = type;
     _slot = slot;
     _slotInfo = new LocalSlotDebugInfo(synthesizedKind, id);
     _pdbAttributes = pdbAttributes;
     _dynamicTransformFlags = dynamicTransformFlags.NullToEmpty();
     _tupleElementNames = tupleElementNames.NullToEmpty();
     _constraints = constraints;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Creates a new LocalDefinition.
 /// </summary>
 /// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
 /// <param name="nameOpt">Name associated with the slot.</param>
 /// <param name="type">Type associated with the slot.</param>
 /// <param name="slot">Slot position in the signature.</param>
 /// <param name="dynamicTransformFlags">Contains the synthesized dynamic attributes of the local</param>
 /// <param name="synthesizedKind">Local kind.</param>
 /// <param name="id">Local id.</param>
 /// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
 /// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
 /// <param name="isDynamic">Specifies if the type is Dynamic.</param>
 public LocalDefinition(
     ILocalSymbol symbolOpt,
     string nameOpt,
     Cci.ITypeReference type,
     int slot,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId id,
     uint pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray<TypedConstant> dynamicTransformFlags)
 {
     _symbolOpt = symbolOpt;
     _nameOpt = nameOpt;
     _type = type;
     _slot = slot;
     _slotInfo = new LocalSlotDebugInfo(synthesizedKind, id);
     _pdbAttributes = pdbAttributes;
     _dynamicTransformFlags = dynamicTransformFlags;
     _constraints = constraints;
     _isDynamic = isDynamic;
 }
Ejemplo n.º 35
0
 internal LocalSignature(ITypeReference valType, LocalSlotConstraints constraints)
 {
     this.Constraints = constraints;
     this.Type        = valType;
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Allocates a temp without identity.
 /// </summary>
 private LocalDefinition AllocateTemp(TypeSymbol type, SyntaxNode syntaxNode, LocalSlotConstraints slotConstraints = LocalSlotConstraints.None)
 {
     return _builder.LocalSlotManager.AllocateSlot(
         _module.Translate(type, syntaxNode, _diagnostics),
         slotConstraints);
 }
Ejemplo n.º 37
0
 internal LocalSignature(Cci.ITypeReference valType, LocalSlotConstraints constraints)
 {
     _constraints = constraints;
     _type        = valType;
 }
        public override LocalDefinition GetPreviousLocal(
            Cci.ITypeReference currentType,
            ILocalSymbolInternal currentLocalSymbol,
            string nameOpt,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray<TypedConstant> dynamicTransformFlags)
        {
            if (id.IsNone)
            {
                return null;
            }

            LocalDebugId previousId;
            if (!TryGetPreviousLocalId(currentLocalSymbol.GetDeclaratorSyntax(), id, out previousId))
            {
                return null;
            }

            var previousType = _symbolMap.MapReference(currentType);
            if (previousType == null)
            {
                return null;
            }

            // TODO (bug #781309): Should report a warning if the type of the local has changed
            // and the previous value will be dropped.
            var localKey = new EncLocalInfo(new LocalSlotDebugInfo(kind, previousId), previousType, constraints, signature: null);

            int slot;
            if (!_previousLocalSlots.TryGetValue(localKey, out slot))
            {
                return null;
            }

            return new LocalDefinition(
                currentLocalSymbol,
                nameOpt,
                currentType,
                slot,
                kind,
                id,
                pdbAttributes,
                constraints,
                isDynamic,
                dynamicTransformFlags);
        }
Ejemplo n.º 39
0
            public override LocalDefinition GetPreviousLocal(
                Cci.ITypeReference type,
                ILocalSymbolInternal symbol,
                string nameOpt,
                SynthesizedLocalKind synthesizedKind,
                LocalDebugId id,
                uint pdbAttributes,
                LocalSlotConstraints constraints,
                bool isDynamic,
                ImmutableArray<TypedConstant> dynamicTransformFlags)
            {
                var local = symbol as EELocalSymbol;
                if ((object)local == null)
                {
                    return null;
                }

                return _locals[local.Ordinal];
            }