Ejemplo n.º 1
0
        private void AnalyzeReadWrite()
        {
            IEnumerable <Symbol> readInside, writtenInside, readOutside, writtenOutside, captured, unsafeAddressTaken, capturedInside, capturedOutside;

            if (Succeeded)
            {
                ReadWriteWalker.Analyze(_context.Compilation, _context.Member, _context.BoundNode, _context.FirstInRegion, _context.LastInRegion, UnassignedVariableAddressOfSyntaxes,
                                        readInside: out readInside, writtenInside: out writtenInside,
                                        readOutside: out readOutside, writtenOutside: out writtenOutside,
                                        captured: out captured, unsafeAddressTaken: out unsafeAddressTaken,
                                        capturedInside: out capturedInside, capturedOutside: out capturedOutside);
            }
            else
            {
                readInside = writtenInside = readOutside = writtenOutside = captured = unsafeAddressTaken = capturedInside = capturedOutside = Enumerable.Empty <Symbol>();
            }

            ImmutableInterlocked.InterlockedInitialize(ref _readInside, Normalize(readInside));
            ImmutableInterlocked.InterlockedInitialize(ref _writtenInside, Normalize(writtenInside));
            ImmutableInterlocked.InterlockedInitialize(ref _readOutside, Normalize(readOutside));
            ImmutableInterlocked.InterlockedInitialize(ref _writtenOutside, Normalize(writtenOutside));
            ImmutableInterlocked.InterlockedInitialize(ref _captured, Normalize(captured));
            ImmutableInterlocked.InterlockedInitialize(ref _capturedInside, Normalize(capturedInside));
            ImmutableInterlocked.InterlockedInitialize(ref _capturedOutside, Normalize(capturedOutside));
            ImmutableInterlocked.InterlockedInitialize(ref _unsafeAddressTaken, Normalize(unsafeAddressTaken));
        }
Ejemplo n.º 2
0
        internal static void Analyze(
            CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion, HashSet <PrefixUnaryExpressionSyntax> unassignedVariableAddressOfSyntaxes,
            out IEnumerable <Symbol> readInside,
            out IEnumerable <Symbol> writtenInside,
            out IEnumerable <Symbol> readOutside,
            out IEnumerable <Symbol> writtenOutside,
            out IEnumerable <Symbol> captured,
            out IEnumerable <Symbol> unsafeAddressTaken,
            out IEnumerable <Symbol> capturedInside,
            out IEnumerable <Symbol> capturedOutside)
        {
            var walker = new ReadWriteWalker(compilation, member, node, firstInRegion, lastInRegion, unassignedVariableAddressOfSyntaxes);

            try
            {
                bool badRegion = false;
                walker.Analyze(ref badRegion);
                if (badRegion)
                {
                    readInside = writtenInside = readOutside = writtenOutside = captured = unsafeAddressTaken = capturedInside = capturedOutside = Enumerable.Empty <Symbol>();
                }
                else
                {
                    readInside     = walker._readInside;
                    writtenInside  = walker._writtenInside;
                    readOutside    = walker._readOutside;
                    writtenOutside = walker._writtenOutside;

                    captured        = walker.GetCaptured();
                    capturedInside  = walker.GetCapturedInside();
                    capturedOutside = walker.GetCapturedOutside();

                    unsafeAddressTaken = walker.GetUnsafeAddressTaken();
                }
            }
            finally
            {
                walker.Free();
            }
        }