Beispiel #1
0
 /// <summary>
 /// Returns an index of a slot that stores specified hoisted local variable in the previous generation.
 /// </summary>
 public abstract bool TryGetPreviousHoistedLocalSlotIndex(
     SyntaxNode currentDeclarator,
     Cci.ITypeReference currentType,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId currentId,
     DiagnosticBag diagnostics,
     out int slotIndex);
Beispiel #2
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbolInternal symbol,
     string nameOpt,
     SynthesizedLocalKind kind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     ImmutableArray <string> tupleElementNames);
Beispiel #3
0
        private LocalDefinition DeclareLocalImpl(
            Cci.ITypeReference type,
            ILocalSymbolInternal symbolOpt,
            string nameOpt,
            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 (symbolOpt != null && _slotAllocatorOpt != null)
            {
                local = _slotAllocatorOpt.GetPreviousLocal(
                    type,
                    symbolOpt,
                    nameOpt,
                    kind,
                    id,
                    pdbAttributes,
                    constraints,
                    dynamicTransformFlags: dynamicTransformFlags,
                    tupleElementNames: tupleElementNames);
                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,
                dynamicTransformFlags: dynamicTransformFlags,
                tupleElementNames: tupleElementNames);

            _lazyAllLocals.Add(local);
            return(local);
        }
Beispiel #4
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;
 }
Beispiel #5
0
        internal LocalDefinition DeclareLocal(
            Cci.ITypeReference type,
            ILocalSymbolInternal symbol,
            string name,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            LocalVariableAttributes pdbAttributes,
            LocalSlotConstraints constraints,
            ImmutableArray <string> tupleElementNames,
            bool isSlotReusable)
        {
            LocalDefinition local;

            if (!isSlotReusable || !FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalImpl(type, symbol, name, kind, id, pdbAttributes, constraints, tupleElementNames);
            }

            LocalMap.Add(symbol, local);
            return(local);
        }
Beispiel #6
0
 public LocalSlotDebugInfo(SynthesizedLocalKind synthesizedKind, LocalDebugId id)
 {
     this.SynthesizedKind = synthesizedKind;
     this.Id = id;
 }