public MethodBody(
            byte[] ilBits,
            ushort maxStack,
            Cci.IMethodDefinition parent,
            ImmutableArray<Cci.ILocalDefinition> locals,
            SequencePointList sequencePoints,
            DebugDocumentProvider debugDocumentProvider,
            ImmutableArray<Cci.ExceptionHandlerRegion> exceptionHandlers,
            ImmutableArray<Cci.LocalScope> localScopes,
            Cci.CustomDebugInfoKind customDebugInfoKind,
            bool hasDynamicLocalVariables,
            ImmutableArray<Cci.NamespaceScope> namespaceScopes = default(ImmutableArray<Cci.NamespaceScope>),
            string iteratorClassName = null,
            ImmutableArray<Cci.LocalScope> iteratorScopes = default(ImmutableArray<Cci.LocalScope>),
            Cci.AsyncMethodBodyDebugInfo asyncMethodDebugInfo = null)
        {
            Debug.Assert(!locals.IsDefault);
            Debug.Assert(!exceptionHandlers.IsDefault);
            Debug.Assert(!localScopes.IsDefault);

            this.ilBits = ilBits;
            this.asyncMethodDebugInfo = asyncMethodDebugInfo;
            this.maxStack = maxStack;
            this.parent = parent;
            this.locals = locals;
            this.sequencePoints = sequencePoints;
            this.debugDocumentProvider = debugDocumentProvider;
            this.exceptionHandlers = exceptionHandlers;
            this.localScopes = localScopes;
            this.customDebugInfoKind = customDebugInfoKind;
            this.hasDynamicLocalVariables = hasDynamicLocalVariables;
            this.namespaceScopes = namespaceScopes.IsDefault ? ImmutableArray<Cci.NamespaceScope>.Empty : namespaceScopes;
            this.iteratorClassName = iteratorClassName;
            this.iteratorScopes = iteratorScopes.IsDefault ? ImmutableArray<Cci.LocalScope>.Empty : iteratorScopes;
        }
        public void AddSynthesizedDefinition(TNamedTypeSymbol container, Cci.IMethodDefinition method)
        {
            Debug.Assert(method != null);

            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions(container);

            if (defs.Methods == null)
            {
                Interlocked.CompareExchange(ref defs.Methods, new ConcurrentQueue <Cci.IMethodDefinition>(), null);
            }

            defs.Methods.Enqueue(method);
        }
Exemple #3
0
        public MethodBody(
            ImmutableArray <byte> ilBits,
            ushort maxStack,
            Cci.IMethodDefinition parent,
            DebugId methodId,
            ImmutableArray <Cci.ILocalDefinition> locals,
            SequencePointList sequencePoints,
            DebugDocumentProvider debugDocumentProvider,
            ImmutableArray <Cci.ExceptionHandlerRegion> exceptionHandlers,
            bool areLocalsZeroed,
            bool hasStackalloc,
            ImmutableArray <Cci.LocalScope> localScopes,
            bool hasDynamicLocalVariables,
            Cci.IImportScope importScopeOpt,
            ImmutableArray <LambdaDebugInfo> lambdaDebugInfo,
            ImmutableArray <ClosureDebugInfo> closureDebugInfo,
            string stateMachineTypeNameOpt,
            ImmutableArray <StateMachineHoistedLocalScope> stateMachineHoistedLocalScopes,
            ImmutableArray <EncHoistedLocalInfo> stateMachineHoistedLocalSlots,
            ImmutableArray <Cci.ITypeReference?> stateMachineAwaiterSlots,
            StateMachineStatesDebugInfo stateMachineStatesDebugInfo,
            StateMachineMoveNextBodyDebugInfo stateMachineMoveNextDebugInfoOpt,
            DynamicAnalysisMethodBodyData dynamicAnalysisDataOpt)
        {
            Debug.Assert(!locals.IsDefault);
            Debug.Assert(!exceptionHandlers.IsDefault);
            Debug.Assert(!localScopes.IsDefault);

            _ilBits                           = ilBits;
            _maxStack                         = maxStack;
            _parent                           = parent;
            _methodId                         = methodId;
            _locals                           = locals;
            _exceptionHandlers                = exceptionHandlers;
            _areLocalsZeroed                  = areLocalsZeroed;
            HasStackalloc                     = hasStackalloc;
            _localScopes                      = localScopes;
            _hasDynamicLocalVariables         = hasDynamicLocalVariables;
            _importScopeOpt                   = importScopeOpt;
            _lambdaDebugInfo                  = lambdaDebugInfo;
            _closureDebugInfo                 = closureDebugInfo;
            _stateMachineTypeNameOpt          = stateMachineTypeNameOpt;
            _stateMachineHoistedLocalScopes   = stateMachineHoistedLocalScopes;
            _stateMachineHoistedLocalSlots    = stateMachineHoistedLocalSlots;
            _stateMachineAwaiterSlots         = stateMachineAwaiterSlots;
            _stateMachineStatesDebugInfo      = stateMachineStatesDebugInfo;
            _stateMachineMoveNextDebugInfoOpt = stateMachineMoveNextDebugInfoOpt;
            _dynamicAnalysisDataOpt           = dynamicAnalysisDataOpt;
            _sequencePoints                   = GetSequencePoints(sequencePoints, debugDocumentProvider);
        }
Exemple #4
0
        internal override bool TryGetMethodHandle(
            Cci.IMethodDefinition def,
            out MethodDefinitionHandle handle
            )
        {
            if (_mapToMetadata.MapDefinition(def)?.GetInternalSymbol() is PEMethodSymbol other)
            {
                handle = other.Handle;
                return(true);
            }

            handle = default;
            return(false);
        }
Exemple #5
0
        internal override bool TryGetMethodHandle(Cci.IMethodDefinition def, out MethodDefinitionHandle handle)
        {
            var other = this.mapToMetadata.MapDefinition(def) as PEMethodSymbol;

            if ((object)other != null)
            {
                handle = other.Handle;
                return(true);
            }
            else
            {
                handle = default(MethodDefinitionHandle);
                return(false);
            }
        }
Exemple #6
0
        public AsyncMoveNextBodyDebugInfo(
            Cci.IMethodDefinition kickoffMethod,
            int catchHandlerOffset,
            ImmutableArray <int> yieldOffsets,
            ImmutableArray <int> resumeOffsets)
            : base(kickoffMethod)
        {
            Debug.Assert(!yieldOffsets.IsDefault);
            Debug.Assert(!resumeOffsets.IsDefault);
            Debug.Assert(yieldOffsets.Length == resumeOffsets.Length);

            CatchHandlerOffset = catchHandlerOffset;
            YieldOffsets       = yieldOffsets;
            ResumeOffsets      = resumeOffsets;
        }
        internal override ImmutableArray <EncLocalInfo> GetLocalInfo(
            Cci.IMethodDefinition methodDef,
            ImmutableArray <LocalDefinition> localDefs)
        {
            if (localDefs.IsEmpty)
            {
                return(ImmutableArray <EncLocalInfo> .Empty);
            }

            // Find declarators in current method syntax.
            var declarators = LocalVariableDeclaratorsCollector.GetDeclarators((MethodSymbol)methodDef);

            // Create a map from declarator to declarator index.
            var declaratorToIndex = CreateDeclaratorToIndexMap(declarators);

            return(localDefs.SelectAsArray(localDef => GetLocalInfo(declaratorToIndex, localDef)));
        }
Exemple #8
0
        public MethodBody(
            ImmutableArray<byte> ilBits,
            ushort maxStack,
            Cci.IMethodDefinition parent,
            DebugId methodId,
            ImmutableArray<Cci.ILocalDefinition> locals,
            SequencePointList sequencePoints,
            DebugDocumentProvider debugDocumentProvider,
            ImmutableArray<Cci.ExceptionHandlerRegion> exceptionHandlers,
            ImmutableArray<Cci.LocalScope> localScopes,
            bool hasDynamicLocalVariables,
            Cci.IImportScope importScopeOpt,
            ImmutableArray<LambdaDebugInfo> lambdaDebugInfo,
            ImmutableArray<ClosureDebugInfo> closureDebugInfo,
            string stateMachineTypeNameOpt,
            ImmutableArray<Cci.StateMachineHoistedLocalScope> stateMachineHoistedLocalScopes,
            ImmutableArray<EncHoistedLocalInfo> stateMachineHoistedLocalSlots,
            ImmutableArray<Cci.ITypeReference> stateMachineAwaiterSlots,
            Cci.AsyncMethodBodyDebugInfo asyncMethodDebugInfo,
            DynamicAnalysisMethodBodyData dynamicAnalysisDataOpt)
        {
            Debug.Assert(!locals.IsDefault);
            Debug.Assert(!exceptionHandlers.IsDefault);
            Debug.Assert(!localScopes.IsDefault);

            _ilBits = ilBits;
            _asyncMethodDebugInfo = asyncMethodDebugInfo;
            _maxStack = maxStack;
            _parent = parent;
            _methodId = methodId;
            _locals = locals;
            _sequencePoints = sequencePoints;
            _debugDocumentProvider = debugDocumentProvider;
            _exceptionHandlers = exceptionHandlers;
            _localScopes = localScopes;
            _hasDynamicLocalVariables = hasDynamicLocalVariables;
            _importScopeOpt = importScopeOpt;
            _lambdaDebugInfo = lambdaDebugInfo;
            _closureDebugInfo = closureDebugInfo;
            _stateMachineTypeNameOpt = stateMachineTypeNameOpt;
            _stateMachineHoistedLocalScopes = stateMachineHoistedLocalScopes;
            _stateMachineHoistedLocalSlots = stateMachineHoistedLocalSlots;
            _stateMachineAwaiterSlots = stateMachineAwaiterSlots;
            _dynamicAnalysisDataOpt = dynamicAnalysisDataOpt;
        }
Exemple #9
0
        public MethodBody(
            byte[] ilBits,
            ushort maxStack,
            Cci.IMethodDefinition parent,
            int methodOrdinal,
            ImmutableArray <Cci.ILocalDefinition> locals,
            SequencePointList sequencePoints,
            DebugDocumentProvider debugDocumentProvider,
            ImmutableArray <Cci.ExceptionHandlerRegion> exceptionHandlers,
            ImmutableArray <Cci.LocalScope> localScopes,
            bool hasDynamicLocalVariables,
            ImmutableArray <Cci.NamespaceScope> namespaceScopes,
            Cci.NamespaceScopeEncoding namespaceScopeEncoding,
            ImmutableArray <LambdaDebugInfo> lambdaDebugInfo,
            ImmutableArray <ClosureDebugInfo> closureDebugInfo,
            string stateMachineTypeNameOpt,
            ImmutableArray <Cci.StateMachineHoistedLocalScope> stateMachineHoistedLocalScopes,
            ImmutableArray <EncHoistedLocalInfo> stateMachineHoistedLocalSlots,
            ImmutableArray <Cci.ITypeReference> stateMachineAwaiterSlots,
            Cci.AsyncMethodBodyDebugInfo asyncMethodDebugInfo)
        {
            Debug.Assert(!locals.IsDefault);
            Debug.Assert(!exceptionHandlers.IsDefault);
            Debug.Assert(!localScopes.IsDefault);

            _ilBits = ilBits;
            _asyncMethodDebugInfo = asyncMethodDebugInfo;
            _maxStack             = maxStack;
            _parent                         = parent;
            _methodOrdinal                  = methodOrdinal;
            _locals                         = locals;
            _sequencePoints                 = sequencePoints;
            _debugDocumentProvider          = debugDocumentProvider;
            _exceptionHandlers              = exceptionHandlers;
            _localScopes                    = localScopes;
            _namespaceScopeEncoding         = namespaceScopeEncoding;
            _hasDynamicLocalVariables       = hasDynamicLocalVariables;
            _namespaceScopes                = namespaceScopes.IsDefault ? ImmutableArray <Cci.NamespaceScope> .Empty : namespaceScopes;
            _lambdaDebugInfo                = lambdaDebugInfo;
            _closureDebugInfo               = closureDebugInfo;
            _stateMachineTypeNameOpt        = stateMachineTypeNameOpt;
            _stateMachineHoistedLocalScopes = stateMachineHoistedLocalScopes;
            _stateMachineHoistedLocalSlots  = stateMachineHoistedLocalSlots;
            _stateMachineAwaiterSlots       = stateMachineAwaiterSlots;
        }
Exemple #10
0
        private bool TryGetMethodHandle(EmitBaseline baseline, Cci.IMethodDefinition def, out MethodDefinitionHandle handle)
        {
            if (this.TryGetMethodHandle(def, out handle))
            {
                return(true);
            }

            var mappedDef = (Cci.IMethodDefinition?)MapToPreviousSymbolMatcher.MapDefinition(def);

            if (mappedDef != null && baseline.MethodsAdded.TryGetValue(mappedDef, out int methodIndex))
            {
                handle = MetadataTokens.MethodDefinitionHandle(methodIndex);
                return(true);
            }

            handle = default;
            return(false);
        }
Exemple #11
0
        private bool TryGetMethodHandle(EmitBaseline baseline, Cci.IMethodDefinition def, out MethodDefinitionHandle handle)
        {
            if (this.TryGetMethodHandle(def, out handle))
            {
                return(true);
            }

            def = (Cci.IMethodDefinition) this.mapToPrevious.MapDefinition(def);
            if (def != null)
            {
                int methodIndex;
                if (baseline.MethodsAdded.TryGetValue(def, out methodIndex))
                {
                    handle = MetadataTokens.MethodDefinitionHandle(methodIndex);
                    return(true);
                }
            }

            handle = default(MethodDefinitionHandle);
            return(false);
        }
 public StateMachineMoveNextBodyDebugInfo(Cci.IMethodDefinition kickoffMethod)
 {
     Debug.Assert(kickoffMethod != null);
     KickoffMethod = kickoffMethod;
 }
Exemple #13
0
 internal abstract bool TryGetMethodHandle(Cci.IMethodDefinition def, out MethodDefinitionHandle handle);
Exemple #14
0
 public IteratorMoveNextBodyDebugInfo(Cci.IMethodDefinition kickoffMethod)
     : base(kickoffMethod)
 {
 }
        // Add a new synthesized method indexed by its name if the method isn't already present.
        internal bool TryAddSynthesizedMethod(Cci.IMethodDefinition method)
        {
            Debug.Assert(!IsFrozen);
#nullable disable // Can 'method.Name' be null? https://github.com/dotnet/roslyn/issues/39166
            return(_synthesizedMethods.TryAdd(method.Name, method));
Exemple #16
0
 internal abstract ImmutableArray <EncLocalInfo> GetLocalInfo(
     Cci.IMethodDefinition def,
     ImmutableArray <Cci.ILocalDefinition> localDefs,
     ImmutableArray <byte[]> signatures);
Exemple #17
0
 public MethodImplementation(Cci.IMethodDefinition ImplementingMethod, Cci.IMethodReference ImplementedMethod)
 {
     this.ImplementingMethod = ImplementingMethod;
     this.ImplementedMethod = ImplementedMethod;
 }
Exemple #18
0
 // Add a new synthesized method indexed by it's name if the method isn't already present.
 internal bool TryAddSynthesizedMethod(Cci.IMethodDefinition method)
 {
     Debug.Assert(!IsFrozen);
     return(_synthesizedMethods.TryAdd(method.Name, method));
 }
Exemple #19
0
        public MethodImplementation(Cci.IMethodDefinition ImplementingMethod, Cci.IMethodReference ImplementedMethod)
        {
            this.ImplementingMethod = ImplementingMethod;

            this.ImplementedMethod = ImplementedMethod;
        }
Exemple #20
0
 internal abstract ImmutableArray <EncLocalInfo> GetLocalInfo(
     Cci.IMethodDefinition def,
     ImmutableArray <LocalDefinition> localDefs);