示例#1
0
        internal static (HashSet <Symbol> entry, HashSet <Symbol> exit) Analyze(
            CSharpCompilation compilation,
            Symbol member,
            BoundNode node,
            BoundNode firstInRegion,
            BoundNode lastInRegion
            )
        {
            var walker = new DefinitelyAssignedWalker(
                compilation,
                member,
                node,
                firstInRegion,
                lastInRegion
                );

            try
            {
                bool badRegion = false;
                walker.Analyze(ref badRegion, diagnostics: null);
                return(badRegion
                  ? (new HashSet <Symbol>(), new HashSet <Symbol>())
                  : (walker._definitelyAssignedOnEntry, walker._definitelyAssignedOnExit));
            }
            finally
            {
                walker.Free();
            }
        }
示例#2
0
        private (ImmutableArray <ISymbol> onEntry, ImmutableArray <ISymbol> onExit) ComputeDefinitelyAssignedValues()
        {
            // Check for _definitelyAssignedOnExit as that's the last thing we write to. If it's not
            // Default, then we'll have written to both variables and can safely read from either of
            // them.
            if (_definitelyAssignedOnExit.IsDefault)
            {
                var entryResult = ImmutableArray <ISymbol> .Empty;
                var exitResult  = ImmutableArray <ISymbol> .Empty;
                if (Succeeded)
                {
                    var(entry, exit) = DefinitelyAssignedWalker.Analyze(
                        _context.Compilation,
                        _context.Member,
                        _context.BoundNode,
                        _context.FirstInRegion,
                        _context.LastInRegion
                        );
                    entryResult = Normalize(entry);
                    exitResult  = Normalize(exit);
                }

                ImmutableInterlocked.InterlockedInitialize(
                    ref _definitelyAssignedOnEntry,
                    entryResult
                    );
                ImmutableInterlocked.InterlockedInitialize(
                    ref _definitelyAssignedOnExit,
                    exitResult
                    );
            }

            return(_definitelyAssignedOnEntry, _definitelyAssignedOnExit);
        }