Beispiel #1
0
        public AddedOrChangedMethodInfo MapTypes(SymbolMatcher map)
        {
            var mappedLocals            = ImmutableArray.CreateRange(this.Locals, MapLocalInfo, map);
            var mappedHoistedLocalSlots = StateMachineHoistedLocalSlotsOpt.IsDefault ? StateMachineHoistedLocalSlotsOpt : ImmutableArray.CreateRange(StateMachineHoistedLocalSlotsOpt, MapHoistedLocalSlot, map);
            var mappedAwaiterSlots      = StateMachineAwaiterSlotsOpt.IsDefault ? StateMachineAwaiterSlotsOpt : ImmutableArray.CreateRange(StateMachineAwaiterSlotsOpt, map.MapReference);

            return(new AddedOrChangedMethodInfo(this.MethodId, mappedLocals, LambdaDebugInfo, ClosureDebugInfo, StateMachineTypeNameOpt, mappedHoistedLocalSlots, mappedAwaiterSlots));
        }
Beispiel #2
0
        protected DefinitionMap(IEnumerable <SemanticEdit> edits, SymbolMatcher mapToMetadata, SymbolMatcher mapToPrevious)
        {
            Debug.Assert(edits != null);
            Debug.Assert(mapToMetadata != null);

            this.mappedMethods = GetMappedMethods(edits);
            this.mapToMetadata = mapToMetadata;
            this.mapToPrevious = mapToPrevious ?? mapToMetadata;
        }
Beispiel #3
0
        public AddedOrChangedMethodInfo MapTypes(SymbolMatcher map)
        {
            var mappedLocals = ImmutableArray.CreateRange(Locals, MapLocalInfo, map);

            var mappedHoistedLocalSlots = StateMachineHoistedLocalSlotsOpt.IsDefault ? default :
                                          ImmutableArray.CreateRange(StateMachineHoistedLocalSlotsOpt, MapHoistedLocalSlot, map);

                                          var mappedAwaiterSlots = StateMachineAwaiterSlotsOpt.IsDefault ? default :
                                                                   ImmutableArray.CreateRange(StateMachineAwaiterSlotsOpt, static (typeRef, map) => (typeRef is null) ? null : map.MapReference(typeRef), map);
        public EncVariableSlotAllocator(
            SymbolMatcher symbolMap,
            Func <SyntaxNode, SyntaxNode?>?syntaxMap,
            IMethodSymbolInternal previousTopLevelMethod,
            DebugId methodId,
            ImmutableArray <EncLocalInfo> previousLocals,
            IReadOnlyDictionary <int, KeyValuePair <DebugId, int> >?lambdaMap,
            IReadOnlyDictionary <int, DebugId>?closureMap,
            string?stateMachineTypeName,
            int hoistedLocalSlotCount,
            IReadOnlyDictionary <EncHoistedLocalInfo, int>?hoistedLocalSlots,
            int awaiterCount,
            IReadOnlyDictionary <Cci.ITypeReference, int>?awaiterMap,
            IReadOnlyDictionary <int, int>?stateMachineStateMap,
            int?firstUnusedIncreasingStateMachineState,
            int?firstUnusedDecreasingStateMachineState,
            LambdaSyntaxFacts lambdaSyntaxFacts)
        {
            Debug.Assert(!previousLocals.IsDefault);

            _symbolMap              = symbolMap;
            _syntaxMap              = syntaxMap;
            _previousLocals         = previousLocals;
            _previousTopLevelMethod = previousTopLevelMethod;
            _methodId              = methodId;
            _hoistedLocalSlots     = hoistedLocalSlots;
            _hoistedLocalSlotCount = hoistedLocalSlotCount;
            _stateMachineTypeName  = stateMachineTypeName;
            _awaiterCount          = awaiterCount;
            _awaiterMap            = awaiterMap;
            _stateMachineStateMap  = stateMachineStateMap;
            _lambdaMap             = lambdaMap;
            _closureMap            = closureMap;
            _lambdaSyntaxFacts     = lambdaSyntaxFacts;
            _firstUnusedIncreasingStateMachineState = firstUnusedIncreasingStateMachineState;
            _firstUnusedDecreasingStateMachineState = firstUnusedDecreasingStateMachineState;

            // Create a map from local info to slot.
            var previousLocalInfoToSlot = new Dictionary <EncLocalInfo, int>();

            for (int slot = 0; slot < previousLocals.Length; slot++)
            {
                var localInfo = previousLocals[slot];
                Debug.Assert(!localInfo.IsDefault);
                if (localInfo.IsUnused)
                {
                    // Unrecognized or deleted local.
                    continue;
                }

                previousLocalInfoToSlot.Add(localInfo, slot);
            }

            _previousLocalSlots = previousLocalInfoToSlot;
        }
Beispiel #5
0
        private static EncLocalInfo MapLocalInfo(EncLocalInfo info, SymbolMatcher map)
        {
            Debug.Assert(!info.IsDefault);
            if (info.IsUnused)
            {
                Debug.Assert(info.Signature != null);
                return(info);
            }

            return(new EncLocalInfo(info.SlotInfo, map.MapReference(info.Type), info.Constraints, info.Signature));
        }
        private readonly IReadOnlyDictionary <int, DebugId> _closureMapOpt;                     // SyntaxOffset -> Id

        public EncVariableSlotAllocator(
            CommonMessageProvider messageProvider,
            SymbolMatcher symbolMap,
            Func <SyntaxNode, SyntaxNode> syntaxMapOpt,
            IMethodSymbolInternal previousTopLevelMethod,
            DebugId methodId,
            ImmutableArray <EncLocalInfo> previousLocals,
            IReadOnlyDictionary <int, KeyValuePair <DebugId, int> > lambdaMapOpt,
            IReadOnlyDictionary <int, DebugId> closureMapOpt,
            string stateMachineTypeNameOpt,
            int hoistedLocalSlotCount,
            IReadOnlyDictionary <EncHoistedLocalInfo, int> hoistedLocalSlotsOpt,
            int awaiterCount,
            IReadOnlyDictionary <Cci.ITypeReference, int> awaiterMapOpt)
        {
            Debug.Assert(messageProvider != null);
            Debug.Assert(symbolMap != null);
            Debug.Assert(previousTopLevelMethod != null);
            Debug.Assert(!previousLocals.IsDefault);

            _messageProvider        = messageProvider;
            _symbolMap              = symbolMap;
            _syntaxMapOpt           = syntaxMapOpt;
            _previousLocals         = previousLocals;
            _previousTopLevelMethod = previousTopLevelMethod;
            _methodId                = methodId;
            _hoistedLocalSlotsOpt    = hoistedLocalSlotsOpt;
            _hoistedLocalSlotCount   = hoistedLocalSlotCount;
            _stateMachineTypeNameOpt = stateMachineTypeNameOpt;
            _awaiterCount            = awaiterCount;
            _awaiterMapOpt           = awaiterMapOpt;
            _lambdaMapOpt            = lambdaMapOpt;
            _closureMapOpt           = closureMapOpt;

            // Create a map from local info to slot.
            var previousLocalInfoToSlot = new Dictionary <EncLocalInfo, int>();

            for (int slot = 0; slot < previousLocals.Length; slot++)
            {
                var localInfo = previousLocals[slot];
                Debug.Assert(!localInfo.IsDefault);
                if (localInfo.IsUnused)
                {
                    // Unrecognized or deleted local.
                    continue;
                }

                previousLocalInfoToSlot.Add(localInfo, slot);
            }

            _previousLocalSlots = previousLocalInfoToSlot;
        }
Beispiel #7
0
        public AddedOrChangedMethodInfo MapTypes(SymbolMatcher map)
        {
            var mappedLocals = ImmutableArray.CreateRange(Locals, MapLocalInfo, map);

            var mappedHoistedLocalSlots = StateMachineHoistedLocalSlotsOpt.IsDefault
                ? default
                : ImmutableArray.CreateRange(
                StateMachineHoistedLocalSlotsOpt,
                MapHoistedLocalSlot,
                map
                );

            var mappedAwaiterSlots = StateMachineAwaiterSlotsOpt.IsDefault
                ? default
                : ImmutableArray.CreateRange(
                StateMachineAwaiterSlotsOpt,
        public EncVariableSlotAllocator(
            SymbolMatcher symbolMap,
            Func <SyntaxNode, SyntaxNode> syntaxMap,
            ImmutableArray <SyntaxNode> previousDeclarators,
            ImmutableArray <EncLocalInfo> previousLocals)
        {
            this.symbolMap      = symbolMap;
            this.syntaxMap      = syntaxMap;
            this.previousLocals = previousLocals;

            // Create a map from declarator to declarator offset.
            var previousDeclaratorToOffset = new Dictionary <SyntaxNode, int>();

            for (int offset = 0; offset < previousDeclarators.Length; offset++)
            {
                previousDeclaratorToOffset.Add(previousDeclarators[offset], offset);
            }

            this.previousDeclaratorToOffset = previousDeclaratorToOffset;

            // Create a map from local info to slot.
            var previousLocalInfoToSlot = new Dictionary <EncLocalInfo, int>();

            for (int slot = 0; slot < previousLocals.Length; slot++)
            {
                var localInfo = previousLocals[slot];
                Debug.Assert(!localInfo.IsDefault);
                if (localInfo.IsInvalid)
                {
                    // Unrecognized or deleted local.
                    continue;
                }

                previousLocalInfoToSlot.Add(localInfo, slot);
            }

            this.previousLocalInfoToSlot = previousLocalInfoToSlot;
        }
Beispiel #9
0
        private static EncHoistedLocalInfo MapHoistedLocalSlot(EncHoistedLocalInfo info, SymbolMatcher map)
        {
            if (info.IsUnused)
            {
                return(info);
            }

            return(new EncHoistedLocalInfo(info.SlotInfo, map.MapReference(info.Type)));
        }