Пример #1
0
        public override Object Visit(IfElseStatement node, Object obj)
        {
            Object aux = null;

            if ((aux = node.Condition.Accept(this, false)) is SingleIdentifierExpression)
            {
                node.Condition = (SingleIdentifierExpression)aux;
            }
            SSAMap map1 = this.map.Clone();

            this.map.SetScope();

            // * Updates the current if statatement body being analyzed
            IList <SingleIdentifierExpression> previousReferencesUsedInIfElseBody = this.referencesUsedInIfElseBody;

            this.referencesUsedInIfElseBody = node.ReferencesUsedInTrueBranch;
            node.TrueBranch.Accept(this, obj);

            this.addLocalVariable(this.map.ResetScope(), node.TrueBranch);
            SSAMap map2 = this.map.Clone();

            this.map.SetScope();
            this.referencesUsedInIfElseBody = node.ReferencesUsedInFalseBranch;
            node.FalseBranch.Accept(this, obj);
            // * Updates the previous if statatement being analyzed
            this.referencesUsedInIfElseBody = previousReferencesUsedInIfElseBody;

            this.addLocalVariable(this.map.ResetScope(), node.FalseBranch);
            // map3 = this.map

            List <MoveStatement> mvSt = map1.GetMoveStatementsForIf(map2, this.map, node.Location.FileName, node.Condition.Location.Line);

            if (mvSt.Count != 0)
            {
                node.AfterCondition = mvSt;
            }

            SSAInfo info = new SSAInfo(map2, this.map, null, null);

            node.TrueBranch.Accept(new VisitorSSA2(), info);

            info = new SSAInfo(this.map, this.map, map2, map1);
            node.FalseBranch.Accept(new VisitorSSA2(), info);

            List <ThetaStatement> thSt;

            if (node.HaveElseBlock())
            {
                thSt = map2.GetThetaStatements(ref this.map, map1, node.Location.FileName, node.FalseBranch.Location.Line);
            }
            else
            {
                thSt = map1.GetThetaStatements(ref this.map, node.Location.FileName, node.FalseBranch.Location.Line);
            }

            if (thSt.Count != 0)
            {
                node.ThetaStatements = thSt;
            }

            return(null);
        }