Exemplo n.º 1
0
        private static Statement GetNextStatement(Statement stat)
        {
            Statement parent = stat.GetParent();

            switch (parent.type)
            {
            case Statement.Type_Root:
            {
                return(((RootStatement)parent).GetDummyExit());
            }

            case Statement.Type_Do:
            {
                return(parent);
            }

            case Statement.Type_Sequence:
            {
                SequenceStatement sequence = (SequenceStatement)parent;
                if (sequence.GetStats().GetLast() != stat)
                {
                    for (int i = sequence.GetStats().Count - 1; i >= 0; i--)
                    {
                        if (sequence.GetStats()[i] == stat)
                        {
                            return(sequence.GetStats()[i + 1]);
                        }
                    }
                }
                break;
            }
            }
            return(GetNextStatement(parent));
        }
        private static bool IsInlineable(SequenceStatement seq, int index)
        {
            Statement first = seq.GetStats()[index];
            Statement pre   = seq.GetStats()[index - 1];

            if (pre.HasBasicSuccEdge())
            {
                return(false);
            }
            List <StatEdge> lst = first.GetPredecessorEdges(StatEdge.Type_Break);

            if (lst.Count == 1)
            {
                StatEdge edge = lst[0];
                if (SameCatchRanges(edge))
                {
                    if (!edge.@explicit)
                    {
                        for (int i = index; i < seq.GetStats().Count; i++)
                        {
                            if (!NoExitLabels(seq.GetStats()[i], seq))
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                }
            }
            // FIXME: count labels properly
            return(false);
        }
        private static void InlineBlock(SequenceStatement seq, int index)
        {
            Statement first = seq.GetStats()[index];
            Statement pre   = seq.GetStats()[index - 1];

            pre.RemoveSuccessor(pre.GetAllSuccessorEdges()[0]);
            // single regular edge
            StatEdge  edge   = first.GetPredecessorEdges(StatEdge.Type_Break)[0];
            Statement source = edge.GetSource();
            Statement parent = source.GetParent();

            source.RemoveSuccessor(edge);
            List <Statement> lst = new List <Statement>();

            for (int i = seq.GetStats().Count - 1; i >= index; i--)
            {
                lst.Add(0, seq.GetStats().RemoveAtReturningValue(i));
            }
            if (parent.type == Statement.Type_If && ((IfStatement)parent).iftype == IfStatement
                .Iftype_If && source == parent.GetFirst())
            {
                IfStatement       ifparent = (IfStatement)parent;
                SequenceStatement block    = new SequenceStatement(lst);
                block.SetAllParent();
                StatEdge newedge = new StatEdge(StatEdge.Type_Regular, source, block);
                source.AddSuccessor(newedge);
                ifparent.SetIfEdge(newedge);
                ifparent.SetIfstat(block);
                ifparent.GetStats().AddWithKey(block, block.id);
                block.SetParent(ifparent);
            }
            else
            {
                lst.Add(0, source);
                SequenceStatement block = new SequenceStatement(lst);
                block.SetAllParent();
                parent.ReplaceStatement(source, block);
                // LabelHelper.lowContinueLabels not applicable because of forward continue edges
                // LabelHelper.lowContinueLabels(block, new HashSet<StatEdge>());
                // do it by hand
                foreach (StatEdge prededge in block.GetPredecessorEdges(StatEdge.Type_Continue))
                {
                    block.RemovePredecessor(prededge);
                    prededge.GetSource().ChangeEdgeNode(Statement.Direction_Forward, prededge, source
                                                        );
                    source.AddPredecessor(prededge);
                    source.AddLabeledEdge(prededge);
                }
                if (parent.type == Statement.Type_Switch)
                {
                    ((SwitchStatement)parent).SortEdgesAndNodes();
                }
                source.AddSuccessor(new StatEdge(StatEdge.Type_Regular, source, first));
            }
        }
Exemplo n.º 4
0
 private static void MergeFlatStatements(SequenceStatement sequence)
 {
     while (true)
     {
         Statement next;
         Statement current = null;
         bool      found   = false;
         for (int i = sequence.GetStats().Count - 1; i >= 0; i--)
         {
             next    = current;
             current = sequence.GetStats()[i];
             if (next != null && current.GetExprents() != null && !(current.GetExprents().Count == 0))
             {
                 if (next.GetExprents() != null)
                 {
                     next.GetExprents().InsertRange(0, current.GetExprents());
                     current.GetExprents().Clear();
                     found = true;
                 }
                 else
                 {
                     Statement first = GetFirstExprentlist(next);
                     if (first != null)
                     {
                         first.GetExprents().InsertRange(0, current.GetExprents());
                         current.GetExprents().Clear();
                         found = true;
                     }
                 }
             }
         }
         if (!found)
         {
             break;
         }
     }
 }
        private static bool InlineSingleBlocksRec(Statement stat)
        {
            bool res = false;

            foreach (Statement st in stat.GetStats())
            {
                res |= InlineSingleBlocksRec(st);
            }
            if (stat.type == Statement.Type_Sequence)
            {
                SequenceStatement seq = (SequenceStatement)stat;
                for (int i = 1; i < seq.GetStats().Count; i++)
                {
                    if (IsInlineable(seq, i))
                    {
                        InlineBlock(seq, i);
                        return(true);
                    }
                }
            }
            return(res);
        }
Exemplo n.º 6
0
        private static bool ReplaceAssertion(Statement parent, IfStatement stat, string classname
                                             , string key)
        {
            bool              throwInIf  = true;
            Statement         ifstat     = stat.GetIfstat();
            InvocationExprent throwError = IsAssertionError(ifstat);

            if (throwError == null)
            {
                //check else:
                Statement elsestat = stat.GetElsestat();
                throwError = IsAssertionError(elsestat);
                if (throwError == null)
                {
                    return(false);
                }
                else
                {
                    throwInIf = false;
                }
            }
            object[] exprres = GetAssertionExprent(stat.GetHeadexprent().GetCondition().Copy(
                                                       ), classname, key, throwInIf);
            if (!(bool)exprres[1])
            {
                return(false);
            }
            List <Exprent> lstParams = new List <Exprent>();
            Exprent        ascond    = null;
            Exprent        retcond   = null;

            if (throwInIf)
            {
                if (exprres[0] != null)
                {
                    ascond = new FunctionExprent(FunctionExprent.Function_Bool_Not, (Exprent)exprres[
                                                     0], throwError.bytecode);
                    retcond = SecondaryFunctionsHelper.PropagateBoolNot(ascond);
                }
            }
            else
            {
                ascond  = (Exprent)exprres[0];
                retcond = ascond;
            }
            lstParams.Add(retcond == null ? ascond : retcond);
            if (!(throwError.GetLstParameters().Count == 0))
            {
                lstParams.Add(throwError.GetLstParameters()[0]);
            }
            AssertExprent asexpr  = new AssertExprent(lstParams);
            Statement     newstat = new BasicBlockStatement(new BasicBlock(DecompilerContext.GetCounterContainer
                                                                               ().GetCounterAndIncrement(CounterContainer.Statement_Counter)));

            newstat.SetExprents(Sharpen.Arrays.AsList(new Exprent[] { asexpr }));
            Statement first = stat.GetFirst();

            if (stat.iftype == IfStatement.Iftype_Ifelse || (first.GetExprents() != null && !
                                                             (first.GetExprents().Count == 0)))
            {
                first.RemoveSuccessor(stat.GetIfEdge());
                first.RemoveSuccessor(stat.GetElseEdge());
                List <Statement> lstStatements = new List <Statement>();
                if (first.GetExprents() != null && !(first.GetExprents().Count == 0))
                {
                    lstStatements.Add(first);
                }
                lstStatements.Add(newstat);
                if (stat.iftype == IfStatement.Iftype_Ifelse)
                {
                    if (throwInIf)
                    {
                        lstStatements.Add(stat.GetElsestat());
                    }
                    else
                    {
                        lstStatements.Add(stat.GetIfstat());
                    }
                }
                SequenceStatement sequence = new SequenceStatement(lstStatements);
                sequence.SetAllParent();
                for (int i = 0; i < sequence.GetStats().Count - 1; i++)
                {
                    sequence.GetStats()[i].AddSuccessor(new StatEdge(StatEdge.Type_Regular, sequence.
                                                                     GetStats()[i], sequence.GetStats()[i + 1]));
                }
                if (stat.iftype == IfStatement.Iftype_Ifelse || !throwInIf)
                {
                    Statement stmts;
                    if (throwInIf)
                    {
                        stmts = stat.GetElsestat();
                    }
                    else
                    {
                        stmts = stat.GetIfstat();
                    }
                    List <StatEdge> lstSuccs = stmts.GetAllSuccessorEdges();
                    if (!(lstSuccs.Count == 0))
                    {
                        StatEdge endedge = lstSuccs[0];
                        if (endedge.closure == stat)
                        {
                            sequence.AddLabeledEdge(endedge);
                        }
                    }
                }
                newstat = sequence;
            }
            Sharpen.Collections.AddAll(newstat.GetVarDefinitions(), stat.GetVarDefinitions());
            parent.ReplaceStatement(stat, newstat);
            return(true);
        }
Exemplo n.º 7
0
        private static bool RemoveReturnCheck(Statement stat, StructMethod mt)
        {
            Statement parent = stat.GetParent();

            if (parent != null && parent.type == Statement.Type_If && stat.type == Statement.
                Type_Basicblock && stat.GetExprents().Count == 1)
            {
                Exprent exprent = stat.GetExprents()[0];
                if (exprent.type == Exprent.Exprent_Exit)
                {
                    ExitExprent exit_exprent = (ExitExprent)exprent;
                    if (exit_exprent.GetExitType() == ExitExprent.Exit_Return)
                    {
                        Exprent exprent_value = exit_exprent.GetValue();
                        //if(exprent_value.type == Exprent.EXPRENT_VAR) {
                        //	VarExprent var_value = (VarExprent)exprent_value;
                        IfStatement ifparent     = (IfStatement)parent;
                        Exprent     if_condition = ifparent.GetHeadexprent().GetCondition();
                        if (ifparent.GetElsestat() == stat && if_condition.type == Exprent.Exprent_Function &&
                            ((FunctionExprent)if_condition).GetFuncType() == FunctionExprent.Function_Eq)
                        {
                            // TODO: reversed order possible (in theory)
                            FunctionExprent func         = (FunctionExprent)if_condition;
                            Exprent         first_param  = func.GetLstOperands()[0];
                            Exprent         second_param = func.GetLstOperands()[1];
                            StatEdge        ifedge       = ifparent.GetIfEdge();
                            StatEdge        elseedge     = ifparent.GetElseEdge();
                            Statement       ifbranch     = ifparent.GetIfstat();
                            Statement       elsebranch   = ifparent.GetElsestat();
                            if (second_param.type == Exprent.Exprent_Const && second_param.GetExprType().type
                                == ICodeConstants.Type_Null)
                            {
                                // TODO: reversed parameter order
                                //if(first_param.type == Exprent.EXPRENT_VAR && ((VarExprent)first_param).getIndex() == var_value.getIndex()) {
                                if (first_param.Equals(exprent_value))
                                {
                                    // TODO: check for absence of side effects like method invocations etc.
                                    if (ifbranch.type == Statement.Type_Basicblock && ifbranch.GetExprents().Count ==
                                        1 && ifbranch.GetExprents()[0].type == Exprent.Exprent_Exit)
                                    {
                                        // TODO: special check for IllegalStateException
                                        ifparent.GetFirst().RemoveSuccessor(ifedge);
                                        ifparent.GetFirst().RemoveSuccessor(elseedge);
                                        ifparent.GetStats().RemoveWithKey(ifbranch.id);
                                        ifparent.GetStats().RemoveWithKey(elsebranch.id);
                                        if (!(ifbranch.GetAllSuccessorEdges().Count == 0))
                                        {
                                            ifbranch.RemoveSuccessor(ifbranch.GetAllSuccessorEdges()[0]);
                                        }
                                        if (!(ifparent.GetFirst().GetExprents().Count == 0))
                                        {
                                            elsebranch.GetExprents().InsertRange(0, ifparent.GetFirst().GetExprents());
                                        }
                                        ifparent.GetParent().ReplaceStatement(ifparent, elsebranch);
                                        ifparent.GetParent().SetAllParent();
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (parent != null && parent.type == Statement.Type_Sequence && stat.type ==
                     Statement.Type_Basicblock && stat.GetExprents().Count == 1)
            {
                //}
                Exprent exprent = stat.GetExprents()[0];
                if (exprent.type == Exprent.Exprent_Exit)
                {
                    ExitExprent exit_exprent = (ExitExprent)exprent;
                    if (exit_exprent.GetExitType() == ExitExprent.Exit_Return)
                    {
                        Exprent           exprent_value = exit_exprent.GetValue();
                        SequenceStatement sequence      = (SequenceStatement)parent;
                        int sequence_stats_number       = sequence.GetStats().Count;
                        if (sequence_stats_number > 1 && sequence.GetStats().GetLast() == stat && sequence
                            .GetStats()[sequence_stats_number - 2].type == Statement.Type_If)
                        {
                            IfStatement ifstat       = (IfStatement)sequence.GetStats()[sequence_stats_number - 2];
                            Exprent     if_condition = ifstat.GetHeadexprent().GetCondition();
                            if (ifstat.iftype == IfStatement.Iftype_If && if_condition.type == Exprent.Exprent_Function &&
                                ((FunctionExprent)if_condition).GetFuncType() == FunctionExprent.Function_Eq)
                            {
                                // TODO: reversed order possible (in theory)
                                FunctionExprent func         = (FunctionExprent)if_condition;
                                Exprent         first_param  = func.GetLstOperands()[0];
                                Exprent         second_param = func.GetLstOperands()[1];
                                Statement       ifbranch     = ifstat.GetIfstat();
                                if (second_param.type == Exprent.Exprent_Const && second_param.GetExprType().type
                                    == ICodeConstants.Type_Null)
                                {
                                    // TODO: reversed parameter order
                                    if (first_param.Equals(exprent_value))
                                    {
                                        // TODO: check for absence of side effects like method invocations etc.
                                        if (ifbranch.type == Statement.Type_Basicblock && ifbranch.GetExprents().Count ==
                                            1 && ifbranch.GetExprents()[0].type == Exprent.Exprent_Exit)
                                        {
                                            // TODO: special check for IllegalStateException
                                            ifstat.RemoveSuccessor(ifstat.GetAllSuccessorEdges()[0]);
                                            // remove 'else' edge
                                            if (!(ifstat.GetFirst().GetExprents().Count == 0))
                                            {
                                                stat.GetExprents().InsertRange(0, ifstat.GetFirst().GetExprents());
                                            }
                                            foreach (StatEdge edge in ifstat.GetAllPredecessorEdges())
                                            {
                                                ifstat.RemovePredecessor(edge);
                                                edge.GetSource().ChangeEdgeNode(Statement.Direction_Forward, edge, stat);
                                                stat.AddPredecessor(edge);
                                            }
                                            sequence.GetStats().RemoveWithKey(ifstat.id);
                                            sequence.SetFirst(sequence.GetStats()[0]);
                                            return(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            foreach (Statement st in stat.GetStats())
            {
                if (RemoveReturnCheck(st, mt))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
 private static void RemoveEmptyStatements(SequenceStatement sequence)
 {
     if (sequence.GetStats().Count <= 1)
     {
         return;
     }
     MergeFlatStatements(sequence);
     while (true)
     {
         bool found = false;
         foreach (Statement st in sequence.GetStats())
         {
             if (st.GetExprents() != null && (st.GetExprents().Count == 0))
             {
                 if ((st.GetAllSuccessorEdges().Count == 0))
                 {
                     List <StatEdge> lstBreaks = st.GetPredecessorEdges(StatEdge.Type_Break);
                     if ((lstBreaks.Count == 0))
                     {
                         foreach (StatEdge edge in st.GetAllPredecessorEdges())
                         {
                             edge.GetSource().RemoveSuccessor(edge);
                         }
                         found = true;
                     }
                 }
                 else
                 {
                     StatEdge sucedge = st.GetAllSuccessorEdges()[0];
                     if (sucedge.GetType() != StatEdge.Type_Finallyexit)
                     {
                         st.RemoveSuccessor(sucedge);
                         foreach (StatEdge edge in st.GetAllPredecessorEdges())
                         {
                             if (sucedge.GetType() != StatEdge.Type_Regular)
                             {
                                 edge.GetSource().ChangeEdgeType(Statement.Direction_Forward, edge, sucedge.GetType
                                                                     ());
                             }
                             st.RemovePredecessor(edge);
                             edge.GetSource().ChangeEdgeNode(Statement.Direction_Forward, edge, sucedge.GetDestination
                                                                 ());
                             sucedge.GetDestination().AddPredecessor(edge);
                             if (sucedge.closure != null)
                             {
                                 sucedge.closure.AddLabeledEdge(edge);
                             }
                         }
                         found = true;
                     }
                 }
                 if (found)
                 {
                     sequence.GetStats().RemoveWithKey(st.id);
                     break;
                 }
             }
         }
         if (!found)
         {
             break;
         }
     }
     sequence.SetFirst(sequence.GetStats()[0]);
 }
Exemplo n.º 9
0
        // FIXME: rewrite the entire method!!! keep in mind finally exits!!
        private static bool ReorderIf(IfStatement ifstat)
        {
            if (ifstat.iftype == IfStatement.Iftype_Ifelse)
            {
                return(false);
            }
            bool      ifdirect;
            bool      elsedirect;
            bool      noifstat = false;
            bool      noelsestat;
            bool      ifdirectpath   = false;
            bool      elsedirectpath = false;
            Statement parent         = ifstat.GetParent();
            Statement from           = parent.type == Statement.Type_Sequence ? parent : ifstat;
            Statement next           = GetNextStatement(from);

            if (ifstat.GetIfstat() == null)
            {
                noifstat = true;
                ifdirect = ifstat.GetIfEdge().GetType() == StatEdge.Type_Finallyexit || MergeHelper
                           .IsDirectPath(from, ifstat.GetIfEdge().GetDestination());
            }
            else
            {
                List <StatEdge> lstSuccs = ifstat.GetIfstat().GetAllSuccessorEdges();
                ifdirect = !(lstSuccs.Count == 0) && lstSuccs[0].GetType() == StatEdge.Type_Finallyexit ||
                           HasDirectEndEdge(ifstat.GetIfstat(), from);
            }
            Statement last = parent.type == Statement.Type_Sequence ? parent.GetStats().GetLast
                                 () : ifstat;

            noelsestat = (last == ifstat);
            elsedirect = !(last.GetAllSuccessorEdges().Count == 0) && last.GetAllSuccessorEdges
                             ()[0].GetType() == StatEdge.Type_Finallyexit || HasDirectEndEdge(last, from);
            if (!noelsestat && ExistsPath(ifstat, ifstat.GetAllSuccessorEdges()[0].GetDestination
                                              ()))
            {
                return(false);
            }
            if (!ifdirect && !noifstat)
            {
                ifdirectpath = ExistsPath(ifstat, next);
            }
            if (!elsedirect && !noelsestat)
            {
                SequenceStatement sequence = (SequenceStatement)parent;
                for (int i = sequence.GetStats().Count - 1; i >= 0; i--)
                {
                    Statement sttemp = sequence.GetStats()[i];
                    if (sttemp == ifstat)
                    {
                        break;
                    }
                    else if (elsedirectpath = ExistsPath(sttemp, next))
                    {
                        break;
                    }
                }
            }
            if ((ifdirect || ifdirectpath) && (elsedirect || elsedirectpath) && !noifstat &&
                !noelsestat)
            {
                // if - then - else
                SequenceStatement sequence = (SequenceStatement)parent;
                // build and cut the new else statement
                List <Statement> lst = new List <Statement>();
                for (int i = sequence.GetStats().Count - 1; i >= 0; i--)
                {
                    Statement sttemp = sequence.GetStats()[i];
                    if (sttemp == ifstat)
                    {
                        break;
                    }
                    else
                    {
                        lst.Add(0, sttemp);
                    }
                }
                Statement stelse;
                if (lst.Count == 1)
                {
                    stelse = lst[0];
                }
                else
                {
                    stelse = new SequenceStatement(lst);
                    stelse.SetAllParent();
                }
                ifstat.RemoveSuccessor(ifstat.GetAllSuccessorEdges()[0]);
                foreach (Statement st in lst)
                {
                    sequence.GetStats().RemoveWithKey(st.id);
                }
                StatEdge elseedge = new StatEdge(StatEdge.Type_Regular, ifstat.GetFirst(), stelse
                                                 );
                ifstat.GetFirst().AddSuccessor(elseedge);
                ifstat.SetElsestat(stelse);
                ifstat.SetElseEdge(elseedge);
                ifstat.GetStats().AddWithKey(stelse, stelse.id);
                stelse.SetParent(ifstat);
                //			if(next.type != Statement.TYPE_DUMMYEXIT && (ifdirect || elsedirect)) {
                //	            StatEdge breakedge = new StatEdge(StatEdge.TYPE_BREAK, ifstat, next);
                //				sequence.addLabeledEdge(breakedge);
                //				ifstat.addSuccessor(breakedge);
                //			}
                ifstat.iftype = IfStatement.Iftype_Ifelse;
            }
            else if (ifdirect && (!elsedirect || (noifstat && !noelsestat)))
            {
                // if - then
                // negate the if condition
                IfExprent statexpr = ifstat.GetHeadexprent();
                statexpr.SetCondition(new FunctionExprent(FunctionExprent.Function_Bool_Not, statexpr
                                                          .GetCondition(), null));
                if (noelsestat)
                {
                    StatEdge ifedge   = ifstat.GetIfEdge();
                    StatEdge elseedge = ifstat.GetAllSuccessorEdges()[0];
                    if (noifstat)
                    {
                        ifstat.GetFirst().RemoveSuccessor(ifedge);
                        ifstat.RemoveSuccessor(elseedge);
                        ifedge.SetSource(ifstat);
                        elseedge.SetSource(ifstat.GetFirst());
                        ifstat.AddSuccessor(ifedge);
                        ifstat.GetFirst().AddSuccessor(elseedge);
                        ifstat.SetIfEdge(elseedge);
                    }
                    else
                    {
                        Statement         ifbranch = ifstat.GetIfstat();
                        SequenceStatement newseq   = new SequenceStatement(Sharpen.Arrays.AsList(ifstat, ifbranch
                                                                                                 ));
                        ifstat.GetFirst().RemoveSuccessor(ifedge);
                        ifstat.GetStats().RemoveWithKey(ifbranch.id);
                        ifstat.SetIfstat(null);
                        ifstat.RemoveSuccessor(elseedge);
                        elseedge.SetSource(ifstat.GetFirst());
                        ifstat.GetFirst().AddSuccessor(elseedge);
                        ifstat.SetIfEdge(elseedge);
                        ifstat.GetParent().ReplaceStatement(ifstat, newseq);
                        newseq.SetAllParent();
                        ifstat.AddSuccessor(new StatEdge(StatEdge.Type_Regular, ifstat, ifbranch));
                    }
                }
                else
                {
                    SequenceStatement sequence = (SequenceStatement)parent;
                    // build and cut the new else statement
                    List <Statement> lst = new List <Statement>();
                    for (int i = sequence.GetStats().Count - 1; i >= 0; i--)
                    {
                        Statement sttemp = sequence.GetStats()[i];
                        if (sttemp == ifstat)
                        {
                            break;
                        }
                        else
                        {
                            lst.Add(0, sttemp);
                        }
                    }
                    Statement stelse;
                    if (lst.Count == 1)
                    {
                        stelse = lst[0];
                    }
                    else
                    {
                        stelse = new SequenceStatement(lst);
                        stelse.SetAllParent();
                    }
                    ifstat.RemoveSuccessor(ifstat.GetAllSuccessorEdges()[0]);
                    foreach (Statement st in lst)
                    {
                        sequence.GetStats().RemoveWithKey(st.id);
                    }
                    if (noifstat)
                    {
                        StatEdge ifedge = ifstat.GetIfEdge();
                        ifstat.GetFirst().RemoveSuccessor(ifedge);
                        ifedge.SetSource(ifstat);
                        ifstat.AddSuccessor(ifedge);
                    }
                    else
                    {
                        Statement ifbranch = ifstat.GetIfstat();
                        ifstat.GetFirst().RemoveSuccessor(ifstat.GetIfEdge());
                        ifstat.GetStats().RemoveWithKey(ifbranch.id);
                        ifstat.AddSuccessor(new StatEdge(StatEdge.Type_Regular, ifstat, ifbranch));
                        sequence.GetStats().AddWithKey(ifbranch, ifbranch.id);
                        ifbranch.SetParent(sequence);
                    }
                    StatEdge newifedge = new StatEdge(StatEdge.Type_Regular, ifstat.GetFirst(), stelse
                                                      );
                    ifstat.GetFirst().AddSuccessor(newifedge);
                    ifstat.SetIfstat(stelse);
                    ifstat.SetIfEdge(newifedge);
                    ifstat.GetStats().AddWithKey(stelse, stelse.id);
                    stelse.SetParent(ifstat);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }