Ejemplo n.º 1
0
        public virtual VerificationResult Mark(Label label)
        {
            // This is, effectively, "follows an unconditional branch & hasn't been seen before"
            if (MarkCreatesNewVerifier && UsesStrictBranchVerification && !ExpectedStacksAtLabels.ContainsKey(label))
            {
                MustBeEmptyWhenBranchedTo.Add(label);
            }

            if (CurrentlyInScope.Count > 0)
            {
                StacksAtLabels[label] = GetCurrentStack();

                var verify = CheckStackMatches(label);
                if (verify != null)
                {
                    return(verify);
                }
            }

            if (MarkCreatesNewVerifier)
            {
                var newVerifier = new VerifiableTracker(label, baseless: true);
                Add(newVerifier, new LinqStack <LinqList <TypeOnStack> >());
                MarkCreatesNewVerifier = false;
            }

            LinqList <VerifiableTracker> restore;

            if (RestoreOnMark.TryGetValue(label, out restore))
            {
                // don't copy, we want the *exact* same verifiers restore here
                AddRange(restore, RestoreStacksOnMark[label]);
                RestoreOnMark.Remove(label);
                RestoreStacksOnMark.Remove(label);
            }

            var based = CurrentlyInScope.FirstOrDefault(f => !f.IsBaseless);

            based = based ?? CurrentlyInScope.First();

            var fromLabel = new VerifiableTracker(label, based.IsBaseless, based);
            var fromStack = CurrentlyInScopeStacks[CurrentlyInScope.IndexOf(based)];

            Add(fromLabel, CopyStack(fromStack));

            if (!VerifyFromLabel.ContainsKey(label))
            {
                VerifyFromLabel[label] = new LinqList <VerifiableTracker>();
            }

            VerifyFromLabel[label].Add(fromLabel);

            RemoveUnnecessaryVerifiers();

            return(VerificationResult.Successful());
        }