public override void OutAIfThenElseStm(AIfThenElseStm node)
 {
     bool value;
     if (IsConst(node.GetCondition(), out value))
     {
         if (value)
         {
             node.ReplaceBy(node.GetThenBody());
         }
         else
         {
             node.ReplaceBy(node.GetElseBody());
         }
         changedSomething = true;
     }
 }
            public override void CaseAIfThenElseStm(AIfThenElseStm node)
            {
                //Create graph node
                Node graphNode = GetNode(node);
                //Process inner if
                node.GetThenBody().Apply(this);
                node.GetElseBody().Apply(this);
                //Add successor and predessors
                PStm stm = GetFirst(node.GetThenBody());
                if (stm != null)
                    graphNode.AddSucc(GetNode(stm));
                stm = GetFirst(node.GetElseBody());
                if (stm != null)
                    graphNode.AddSucc(GetNode(stm));

                stm = GetNext(node);
                if (stm != null)
                {
                    Node nextGraphNode = GetNode(stm);

                    List<PStm> stms = GetLast(node.GetThenBody());
                    if (stms.Count > 0)
                        foreach (PStm pStm in stms)
                        {
                            nextGraphNode.AddPred(GetNode(pStm));
                        }
                    else
                        graphNode.AddSucc(nextGraphNode);

                    stms = GetLast(node.GetElseBody());
                    if (stms.Count > 0)
                        foreach (PStm pStm in stms)
                        {
                            nextGraphNode.AddPred(GetNode(pStm));
                        }
                    else
                        graphNode.AddSucc(nextGraphNode);
                }
            }
Exemplo n.º 3
0
 public override void CaseAIfThenElseStm(AIfThenElseStm node)
 {
     InAIfThenElseStm(node);
     if (node.GetElseBody() != null)
     {
         node.GetElseBody().Apply(this);
     }
     if (node.GetThenBody() != null)
     {
         node.GetThenBody().Apply(this);
     }
     if (node.GetCondition() != null)
     {
         node.GetCondition().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutAIfThenElseStm(node);
 }
 public override void CaseAIfThenElseStm(AIfThenElseStm node)
 {
     node.GetThenBody().Apply(this);
     node.GetElseBody().Apply(this);
 }
 public override void CaseAIfThenElseStm(AIfThenElseStm node)
 {
     if (Returned) return;
     node.GetThenBody().Apply(this);
     bool returned = Returned;
     Returned = false;
     node.GetElseBody().Apply(this);
     Returned &= returned;
 }
 public override void CaseAIfThenElseStm(AIfThenElseStm node)
 {
     Write("if(");
     node.GetCondition().Apply(this);
     Write(")\n");
     node.GetThenBody().Apply(this);
     Write("else\n");
     node.GetElseBody().Apply(this);
 }