예제 #1
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbol symbol,
     string nameOpt,
     CommonSynthesizedLocalKind synthesizedKind,
     uint pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags);
예제 #2
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;
        }
예제 #3
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;
        }
예제 #4
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);
        }
예제 #5
0
        private LocalDefinition DeclareLocalImpl(
            Cci.ITypeReference type,
            ILocalSymbol symbolOpt,
            string nameOpt,
            CommonSynthesizedLocalKind synthesizedKind,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            if (this.lazyAllLocals == null)
            {
                this.lazyAllLocals = new ArrayBuilder <Cci.ILocalDefinition>(1);
            }

            LocalDefinition local;

            if (symbolOpt != null && slotAllocatorOpt != null)
            {
                local = this.slotAllocatorOpt.GetPreviousLocal(type, symbolOpt, nameOpt, synthesizedKind, pdbAttributes, constraints, isDynamic, dynamicTransformFlags);
                if (local != null)
                {
                    int slot = local.SlotIndex;
                    this.lazyAllLocals[slot] = local;
                    return(local);
                }
            }

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

            this.lazyAllLocals.Add(local);
            return(local);
        }
예제 #6
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);
        }
예제 #7
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;
 }