コード例 #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);
コード例 #2
0
ファイル: LocalSlotManager.cs プロジェクト: belav/roslyn
        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);
        }
コード例 #3
0
 public abstract LocalDefinition?GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbolInternal symbol,
     string?name,
     SynthesizedLocalKind kind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     ImmutableArray <bool> dynamicTransformFlags,
     ImmutableArray <string> tupleElementNames);
コード例 #4
0
 public abstract LocalDefinition GetPreviousLocal(
     Cci.ITypeReference type,
     ILocalSymbolInternal symbol,
     string nameOpt,
     SynthesizedLocalKind kind,
     LocalDebugId id,
     uint pdbAttributes,
     LocalSlotConstraints constraints,
     bool isDynamic,
     ImmutableArray <TypedConstant> dynamicTransformFlags);
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
 public LocalDefinition(
     ILocalSymbol?symbolOpt,
     string?nameOpt,
     Cci.ITypeReference type,
     int slot,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId id,
     LocalVariableAttributes pdbAttributes,
     LocalSlotConstraints constraints,
     ImmutableArray <bool> dynamicTransformFlags,
     ImmutableArray <string> tupleElementNames)
 {
     _symbolOpt             = symbolOpt;
     _nameOpt               = nameOpt;
     _type                  = type;
     _slot                  = slot;
     _slotInfo              = new LocalSlotDebugInfo(synthesizedKind, id);
     _pdbAttributes         = pdbAttributes;
     _dynamicTransformFlags = dynamicTransformFlags.NullToEmpty();
     _tupleElementNames     = tupleElementNames.NullToEmpty();
     _constraints           = constraints;
 }
コード例 #8
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;
 }
コード例 #9
0
 public LocalSlotDebugInfo(SynthesizedLocalKind synthesizedKind, LocalDebugId id)
 {
     this.SynthesizedKind = synthesizedKind;
     this.Id = id;
 }
コード例 #10
0
 /// <summary>
 /// Returns an index of a slot that stores specified hoisted local variable in the previous generation,
 /// or -1 if there is no such slot.
 /// </summary>
 public abstract int GetPreviousHoistedLocalSlotIndex(
     SyntaxNode currentDeclarator,
     Cci.ITypeReference currentType,
     SynthesizedLocalKind synthesizedKind,
     LocalDebugId currentId);