コード例 #1
0
 public void ReplaceBy(Node node)
 {
     if(parent_node != null)
     {
     parent_node.ReplaceChild(this, node);
     }
 }
コード例 #2
0
 public CloneMethod(SharedData data, Dictionary<AALocalDecl, PLvalue> localMap, Node currentCloneNode, ExtraCheckDelegate extraCheck = null)
 {
     this.data = data;
     this.localMap = localMap;
     this.currentCloneNode = currentCloneNode;
     this.extraCheck = extraCheck;
 }
コード例 #3
0
 public override void DefaultIn(Node node)
 {
     if (node is PStm)
     {
         internalAssignments.Clear();
     }
     base.DefaultIn(node);
 }
コード例 #4
0
 private static PStm GetNext(PStm stm)
 {
     while (true)
     {
         AABlock pBlock = Util.GetAncestor <AABlock>(stm);
         if (pBlock == null)
         {
             return(null);
         }
         int index = pBlock.GetStatements().IndexOf(stm);
         while (index < pBlock.GetStatements().Count - 1)
         {
             stm = GetFirst((PStm)pBlock.GetStatements()[index + 1]);
             if (stm != null)
             {
                 return(stm);
             }
             index++;
         }
         ASTNode node = pBlock;
         stm = null;
         while (true)
         {
             if (node == null)
             {
                 return(null);
             }
             node = Util.GetNearestAncestor(node.Parent(), typeof(AABlock), typeof(PStm));
             if (node is PStm)
             {
                 stm = (PStm)node;
             }
             else if (stm == null)
             {
                 continue;
             }
             else
             {
                 break;
             }
         }
         //stm = Util.GetAncestor<PStm>(pBlock);
         if (stm == null)
         {
             return(null);
         }
     }
 }
コード例 #5
0
 public Node Insert(Node node, AExpStm newStm)
 {
     //Node must be a node for an AExpStm
     Node newNode = new Node(newStm);
     foreach (Node successor in node.Successors)
     {
         newNode.AddSucc(successor);
     }
     foreach (Node successor in newNode.Successors)
     {
         node.RemoveSucc(successor);
     }
     node.AddSucc(newNode);
     Nodes.Insert(Nodes.IndexOf(node) + 1, newNode);
     return newNode;
 }
コード例 #6
0
 public override void DefaultOut(Node node)
 {
     if (node is PType)
     {
         Link((PType) node, node);
     }
     else if (node is PExp)
     {
         Link(data.ExpTypes[(PExp) node], node);
     }
     else if (node is PLvalue && !(node.Parent() is ASyncInvokeExp || node.Parent() is AAsyncInvokeStm))
     {
         Link(data.LvalueTypes[(PLvalue)node], node);
     }
     base.DefaultOut(node);
 }
コード例 #7
0
 public void Remove(Node node)
 {
     Nodes.Remove(node);
     //Set succ/pred of succ/pred nodes
     foreach (Node predecessor in node.Predecessors)
     {
         foreach (Node successor in node.Successors)
         {
             predecessor.AddSucc(successor);
         }
     }
     //Remove node from succ/pred lists
     for (int i = node.Predecessors.Count - 1; i >= 0; i--)
     {
         Node predecessor = node.Predecessors[i];
         node.RemovePred(predecessor);
     }
     for (int i = node.Successors.Count - 1; i >= 0; i--)
     {
         Node successor = node.Successors[i];
         node.RemoveSucc(successor);
     }
 }
コード例 #8
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
 }
コード例 #9
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
 }
コード例 #10
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_integer_literal_ == oldChild)
     {
         SetIntegerLiteral((TIntegerLiteral)newChild);
         return;
     }
 }
コード例 #11
0
        internal override void ReplaceChild(Node oldChild, Node newChild)
        {
            if (_token_ == oldChild)
            {
                SetToken((TInitializer)newChild);
                return;
            }
            for (int i = 0; i < _initializer_param_.Count; i++)
            {
                Node n = (Node)_initializer_param_[i];
                if (n == oldChild)
                {
                    if (newChild != null)
                    {
                        _initializer_param_[i] = newChild;
                        oldChild.Parent(null);
                        return;
                    }

                    _initializer_param_.RemoveAt(i);
                    oldChild.Parent(null);
                    return;
                }
            }
            if (_body_ == oldChild)
            {
                SetBody((PBlock)newChild);
                return;
            }
        }
コード例 #12
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_token_ == oldChild)
     {
         SetToken((TInclude)newChild);
         return;
     }
     if (_name_ == oldChild)
     {
         SetName((TStringLiteral)newChild);
         return;
     }
 }
コード例 #13
0
 internal override void RemoveChild(Node child)
 {
     if (_lvalue_ == child)
     {
         _lvalue_ = null;
         return;
     }
     if (_inc_dec_op_ == child)
     {
         _inc_dec_op_ = null;
         return;
     }
 }
コード例 #14
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_condition_ == child)
     {
         _condition_ = null;
         return;
     }
     if (_body_ == child)
     {
         _body_ = null;
         return;
     }
 }
コード例 #15
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_fixed_literal_ == oldChild)
     {
         SetFixedLiteral((TFixedLiteral)newChild);
         return;
     }
 }
コード例 #16
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_token_ == oldChild)
     {
         SetToken((TQuestionmark)newChild);
         return;
     }
     if (_cond_ == oldChild)
     {
         SetCond((PExp)newChild);
         return;
     }
     if (_then_ == oldChild)
     {
         SetThen((PExp)newChild);
         return;
     }
     if (_else_ == oldChild)
     {
         SetElse((PExp)newChild);
         return;
     }
 }
コード例 #17
0
 internal override void RemoveChild(Node child)
 {
     if (_visibility_modifier_ == child)
     {
         _visibility_modifier_ = null;
         return;
     }
     if (_static_ == child)
     {
         _static_ = null;
         return;
     }
     if (_ref_ == child)
     {
         _ref_ = null;
         return;
     }
     if (_out_ == child)
     {
         _out_ = null;
         return;
     }
     if (_const_ == child)
     {
         _const_ = null;
         return;
     }
     if (_type_ == child)
     {
         _type_ = null;
         return;
     }
     if (_name_ == child)
     {
         _name_ = null;
         return;
     }
     if (_init_ == child)
     {
         _init_ = null;
         return;
     }
 }
コード例 #18
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_token_ == oldChild)
     {
         SetToken((TLParen)newChild);
         return;
     }
     if (_condition_ == oldChild)
     {
         SetCondition((PExp)newChild);
         return;
     }
     if (_body_ == oldChild)
     {
         SetBody((PStm)newChild);
         return;
     }
 }
コード例 #19
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_init_ == child)
     {
         _init_ = null;
         return;
     }
     if (_cond_ == child)
     {
         _cond_ = null;
         return;
     }
     if (_update_ == child)
     {
         _update_ = null;
         return;
     }
     if (_body_ == child)
     {
         _body_ = null;
         return;
     }
 }
コード例 #20
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_lvalue_ == oldChild)
     {
         SetLvalue((PLvalue)newChild);
         return;
     }
     if (_inc_dec_op_ == oldChild)
     {
         SetIncDecOp((PIncDecOp)newChild);
         return;
     }
 }
コード例 #21
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_token_ == oldChild)
     {
         SetToken((TLParen)newChild);
         return;
     }
     if (_init_ == oldChild)
     {
         SetInit((PStm)newChild);
         return;
     }
     if (_cond_ == oldChild)
     {
         SetCond((PExp)newChild);
         return;
     }
     if (_update_ == oldChild)
     {
         SetUpdate((PStm)newChild);
         return;
     }
     if (_body_ == oldChild)
     {
         SetBody((PStm)newChild);
         return;
     }
 }
コード例 #22
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_initializer_param_.Contains(child))
     {
         _initializer_param_.Remove(child);
         return;
     }
     if (_body_ == child)
     {
         _body_ = null;
         return;
     }
 }
コード例 #23
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_base_ == child)
     {
         _base_ = null;
         return;
     }
     if (_generic_types_.Contains(child))
     {
         _generic_types_.Remove(child);
         return;
     }
 }
コード例 #24
0
 internal override void RemoveChild(Node child)
 {
     if (_integer_literal_ == child)
     {
         _integer_literal_ = null;
         return;
     }
 }
コード例 #25
0
        internal override void ReplaceChild(Node oldChild, Node newChild)
        {
            if (_token_ == oldChild)
            {
                SetToken((TLt)newChild);
                return;
            }
            if (_base_ == oldChild)
            {
                SetBase((PType)newChild);
                return;
            }
            for (int i = 0; i < _generic_types_.Count; i++)
            {
                Node n = (Node)_generic_types_[i];
                if (n == oldChild)
                {
                    if (newChild != null)
                    {
                        _generic_types_[i] = newChild;
                        oldChild.Parent(null);
                        return;
                    }

                    _generic_types_.RemoveAt(i);
                    oldChild.Parent(null);
                    return;
                }
            }
        }
コード例 #26
0
 internal override void RemoveChild(Node child)
 {
 }
コード例 #27
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_visibility_modifier_ == oldChild)
     {
         SetVisibilityModifier((PVisibilityModifier)newChild);
         return;
     }
     if (_static_ == oldChild)
     {
         SetStatic((TStatic)newChild);
         return;
     }
     if (_ref_ == oldChild)
     {
         SetRef((TRef)newChild);
         return;
     }
     if (_out_ == oldChild)
     {
         SetOut((TOut)newChild);
         return;
     }
     if (_const_ == oldChild)
     {
         SetConst((TConst)newChild);
         return;
     }
     if (_type_ == oldChild)
     {
         SetType((PType)newChild);
         return;
     }
     if (_name_ == oldChild)
     {
         SetName((TIdentifier)newChild);
         return;
     }
     if (_init_ == oldChild)
     {
         SetInit((PExp)newChild);
         return;
     }
 }
コード例 #28
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_token_ == oldChild)
     {
         SetToken((TOrOr)newChild);
         return;
     }
 }
コード例 #29
0
 internal override void ReplaceChild(Node oldChild, Node newChild)
 {
     if (_hex_literal_ == oldChild)
     {
         SetHexLiteral((THexLiteral)newChild);
         return;
     }
 }
コード例 #30
0
 public override void DefaultIn(Node node)
 {
     if (node is PStm)
     {
         safeVariables = new List<VariableDecl>();
         PStm prev = GetPrevious((PStm) node);
         if (prev != null)
         {
             safeVariables.AddRange(safeVariablesAfterStatement[prev]);
         }
         unsafeVariables = new List<VariableDecl>();
     }
     base.DefaultIn(node);
 }
コード例 #31
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_cond_ == child)
     {
         _cond_ = null;
         return;
     }
     if (_then_ == child)
     {
         _then_ = null;
         return;
     }
     if (_else_ == child)
     {
         _else_ = null;
         return;
     }
 }