当前位置: 首页>>代码示例>>C#>>正文


C# Node.Parent方法代码示例

本文整理汇总了C#中Galaxy_Editor_2.Compiler.Generated.node.Node.Parent方法的典型用法代码示例。如果您正苦于以下问题:C# Node.Parent方法的具体用法?C# Node.Parent怎么用?C# Node.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Galaxy_Editor_2.Compiler.Generated.node.Node的用法示例。


在下文中一共展示了Node.Parent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefaultOut

 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);
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:16,代码来源:MakeEnrichmentLinks.cs

示例2: ReplaceChild

        internal override void ReplaceChild(Node oldChild, Node newChild)
        {
            if (_token_ == oldChild)
            {
                SetToken((TSwitch)newChild);
                return;
            }
            if (_test_ == oldChild)
            {
                SetTest((PExp)newChild);
                return;
            }
            for (int i = 0; i < _cases_.Count; i++)
            {
                Node n = (Node)_cases_[i];
                if (n == oldChild)
                {
                    if (newChild != null)
                    {
                        _cases_[i] = newChild;
                        oldChild.Parent(null);
                        return;
                    }

                    _cases_.RemoveAt(i);
                    oldChild.Parent(null);
                    return;
                }
            }
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:30,代码来源:prods.cs

示例3: DefaultIn

            public override void DefaultIn(Node node)
            {
                //
                int index = 0;
                GetChildTypeIndex getChildTypeIndex = new GetChildTypeIndex() { Parent = node.Parent(), Child = node };
                node.Parent().Apply(getChildTypeIndex);
                index = getChildTypeIndex.Index;
                GetChildTypeByIndex getChildTypeByIndex = new GetChildTypeByIndex() { Child = node, Index = index, Parent = currentCloneNode };
                currentCloneNode.Apply(getChildTypeByIndex);
                currentCloneNode = getChildTypeByIndex.Child;

                //currentCloneNode should now be the clone corrosponding to node.
                /*finalTrans.data.ExpTypes
                finalTrans.data.FieldLinks
                finalTrans.data.LocalLinks
                finalTrans.data.Locals//Lets forget about this one
                finalTrans.data.LvalueTypes
                finalTrans.data.SimpleMethodLinks
                finalTrans.data.StructFieldLinks
                finalTrans.data.StructMethodLinks
                finalTrans.data.StructTypeLinks*/
                if (node is ANewExp && finalTrans.data.ConstructorLinks.ContainsKey((ANewExp)node))
                    finalTrans.data.ConstructorLinks[(ANewExp) currentCloneNode] = finalTrans.data.ConstructorLinks[(ANewExp) node];

                if (node is PExp)
                    finalTrans.data.ExpTypes[(PExp)currentCloneNode] = finalTrans.data.ExpTypes[(PExp)node];

                if (node is AStringConstExp && finalTrans.data.TriggerDeclarations.Any(p => p.Value.Contains(((AStringConstExp)node).GetStringLiteral())))
                    finalTrans.data.TriggerDeclarations.First(
                        p => p.Value.Contains(((AStringConstExp) node).GetStringLiteral())).Value.Add(
                            ((AStringConstExp) currentCloneNode).GetStringLiteral());
                if (node is AFieldLvalue)
                    finalTrans.data.FieldLinks[(AFieldLvalue)currentCloneNode] = finalTrans.data.FieldLinks[(AFieldLvalue)node];
                if (node is ALocalLvalue)
                {
                    AALocalDecl originalFormal = finalTrans.data.LocalLinks[(ALocalLvalue) node];

                    PLvalue replacer = Util.MakeClone(localMap[originalFormal],
                                                        finalTrans.data);
                    currentCloneNode.ReplaceBy(replacer);
                    currentCloneNode = replacer;

                    if (localExpMap.ContainsKey(originalFormal))
                    {
                        ReplaceUsAfter[replacer] = localExpMap[originalFormal];
                    }

                }
                if (node is AALocalDecl)
                {
                    ALocalLvalue replacer = new ALocalLvalue(new TIdentifier("IwillGetRenamedLater"));
                    finalTrans.data.LvalueTypes[replacer] = ((AALocalDecl) currentCloneNode).GetType();
                    finalTrans.data.LocalLinks[replacer] = (AALocalDecl)currentCloneNode;
                    localMap.Add((AALocalDecl)node, replacer);
                }
                if (node is PLvalue)
                    finalTrans.data.LvalueTypes[(PLvalue)currentCloneNode] = finalTrans.data.LvalueTypes[(PLvalue)node];
                if (node is ASimpleInvokeExp)
                    finalTrans.data.SimpleMethodLinks[(ASimpleInvokeExp)currentCloneNode] = finalTrans.data.SimpleMethodLinks[(ASimpleInvokeExp)node];
                if (node is AStructLvalue)
                    finalTrans.data.StructFieldLinks[(AStructLvalue)currentCloneNode] = finalTrans.data.StructFieldLinks[(AStructLvalue)node];
                if (node is ANonstaticInvokeExp)
                    finalTrans.data.StructMethodLinks[(ANonstaticInvokeExp)currentCloneNode] = finalTrans.data.StructMethodLinks[(ANonstaticInvokeExp)node];
                if (node is ANamedType && finalTrans.data.StructTypeLinks.Keys.Contains(node))
                    finalTrans.data.StructTypeLinks[(ANamedType)currentCloneNode] = finalTrans.data.StructTypeLinks[(ANamedType)node];
                if (node is ANamedType && finalTrans.data.DelegateTypeLinks.Keys.Contains(node))
                    finalTrans.data.DelegateTypeLinks[(ANamedType)currentCloneNode] = finalTrans.data.DelegateTypeLinks[(ANamedType)node];
                if (node is APropertyLvalue && finalTrans.data.PropertyLinks.ContainsKey((APropertyLvalue)node))
                    finalTrans.data.PropertyLinks[(APropertyLvalue) currentCloneNode] = finalTrans.data.PropertyLinks[(APropertyLvalue) node];
            }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:70,代码来源:FixInlineMethods.cs

示例4: DefaultIn

            public override void DefaultIn(Node node)
            {
                if (isFirst)
                    isFirst = false;
                else
                {
                    int index = 0;
                    CloneMethod.GetChildTypeIndex getChildTypeIndex = new CloneMethod.GetChildTypeIndex() { Parent = node.Parent(), Child = node };
                    node.Parent().Apply(getChildTypeIndex);
                    index = getChildTypeIndex.Index;
                    CloneMethod.GetChildTypeByIndex getChildTypeByIndex = new CloneMethod.GetChildTypeByIndex() { Child = node, Index = index, Parent = currentClone };
                    currentClone.Apply(getChildTypeByIndex);
                    currentClone = getChildTypeByIndex.Child;
                }

                if (node is ANamedType && data.GenericLinks.ContainsKey((ANamedType) node))
                {
                    TIdentifier name = data.GenericLinks[(ANamedType) node];
                    AStructDecl str = (AStructDecl) name.Parent();

                    PType type = types[str.GetGenericVars().IndexOf(name)];
                    replacer = Util.MakeClone(type, data);
                }
            }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:24,代码来源:FixGenerics.cs

示例5: DefaultIn

        public override void DefaultIn(Node node)
        {
            if (node is PExp)
            {
                PExp exp = (PExp) node;
                if (finalTrans.data.ExpTypes[exp] is ANamedType)
                {
                    ANamedType type = (ANamedType) finalTrans.data.ExpTypes[exp];
                    if (finalTrans.data.StructTypeLinks.ContainsKey(type))
                    {
                        AStructDecl strDecl = finalTrans.data.StructTypeLinks[type];
                        if (strDecl.GetLocals().Cast<PLocalDecl>().Select(decl => decl is AALocalDecl).Count() == 0)
                        {
                            if (node.Parent() is AAssignmentExp)
                                node = node.Parent().Parent();
                            MoveMethodDeclsOut mover = new MoveMethodDeclsOut("removedStructVar", finalTrans.data);
                            node.Apply(mover);
                            foreach (PStm pStm in mover.NewStatements)
                            {
                                pStm.Apply(this);
                            }
                            node.Parent().RemoveChild(node);

                            if (node.Parent() is ABinopExp)
                            {
                                ABinopExp parent = (ABinopExp) node.Parent();
                                ABooleanConstExp replacer;
                                if (parent.GetBinop() is ANeBinop || parent.GetBinop() is AGtBinop || parent.GetBinop() is ALtBinop)
                                    replacer = new ABooleanConstExp(new AFalseBool());
                                else
                                    replacer = new ABooleanConstExp(new ATrueBool());
                                finalTrans.data.ExpTypes[replacer] = new ANamedType(new TIdentifier("bool"), null);
                                parent.ReplaceBy(replacer);
                            }
                        }
                    }
                }
            }
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:39,代码来源:RemoveEmptyStructs.cs

示例6: DefaultIn

        public override void DefaultIn(Node node)
        {
            //
            int index = 0;
            GetChildTypeIndex getChildTypeIndex = new GetChildTypeIndex() { Parent = node.Parent(), Child = node };
            node.Parent().Apply(getChildTypeIndex);
            index = getChildTypeIndex.Index;
            GetChildTypeByIndex getChildTypeByIndex = new GetChildTypeByIndex() { Child = node, Index = index, Parent = currentCloneNode };
            currentCloneNode.Apply(getChildTypeByIndex);
            currentCloneNode = getChildTypeByIndex.Child;

            //currentCloneNode should now be the clone corrosponding to node.
            /*finalTrans.data.ExpTypes
            finalTrans.data.FieldLinks
            finalTrans.data.LocalLinks
            finalTrans.data.Locals//Lets not forget about this one
            finalTrans.data.LvalueTypes
            finalTrans.data.SimpleMethodLinks
            finalTrans.data.StructFieldLinks
            finalTrans.data.StructMethodLinks
            finalTrans.data.StructTypeLinks*/
            if (node is AABlock)
                data.Locals[(AABlock) currentCloneNode] = new List<AALocalDecl>();
            if (node is PExp)
                data.ExpTypes[(PExp)currentCloneNode] = data.ExpTypes[(PExp)node];
            if (node is AFieldLvalue)
                data.FieldLinks[(AFieldLvalue)currentCloneNode] = data.FieldLinks[(AFieldLvalue)node];
            if (node is ALocalLvalue)
            {
                PLvalue replacer = Util.MakeClone(localMap[data.LocalLinks[(ALocalLvalue)node]],
                                                  data);
                currentCloneNode.ReplaceBy(replacer);
                currentCloneNode = replacer;
            }
            if (node is AALocalDecl)
            {
                ALocalLvalue replacer = new ALocalLvalue(new TIdentifier("IwillGetRenamedLater"));
                data.LvalueTypes[replacer] = ((AALocalDecl)currentCloneNode).GetType();
                data.LocalLinks[replacer] = (AALocalDecl)currentCloneNode;
                AABlock pBlock = Util.GetAncestor<AABlock>(currentCloneNode) ??
                                 (AABlock) Util.GetAncestor<AMethodDecl>(currentCloneNode).GetBlock();
                data.Locals[Util.GetAncestor<AABlock>(currentCloneNode)].Add((AALocalDecl) currentCloneNode);
                localMap.Add((AALocalDecl)node, replacer);
            }
            if (node is PLvalue)
                data.LvalueTypes[(PLvalue)currentCloneNode] = data.LvalueTypes[(PLvalue)node];
            if (node is ASimpleInvokeExp)
                data.SimpleMethodLinks[(ASimpleInvokeExp)currentCloneNode] = data.SimpleMethodLinks[(ASimpleInvokeExp)node];
            if (node is AStructLvalue)
                data.StructFieldLinks[(AStructLvalue)currentCloneNode] = data.StructFieldLinks[(AStructLvalue)node];
            if (node is ANonstaticInvokeExp)
                data.StructMethodLinks[(ANonstaticInvokeExp)currentCloneNode] = data.StructMethodLinks[(ANonstaticInvokeExp)node];
            if (node is ANamedType && data.StructTypeLinks.Keys.Contains(node))
                data.StructTypeLinks[(ANamedType)currentCloneNode] = data.StructTypeLinks[(ANamedType)node];
            if (extraCheck != null)
                extraCheck(node, currentCloneNode);
            if (node is PType && data.EnrichmentTypeLinks.ContainsKey((PType) node))
                data.EnrichmentTypeLinks[(PType)currentCloneNode] = data.EnrichmentTypeLinks[(PType)node];
            if (node is AStringConstExp)
            {
                if (data.StringsDontJoinRight.Contains(node))
                    data.StringsDontJoinRight.Add((AStringConstExp) currentCloneNode);
            }
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:64,代码来源:CloneMethod.cs

示例7: DefaultIn

        public override void DefaultIn(Node node)
        {
            if (!canMerge)
                return;
            if (node is AMethodDecl)
            {
                //First node - no need to fetch
                if (((AMethodDecl)node).GetFormals().Count != ((AMethodDecl)otherNode).GetFormals().Count)
                {
                    canMerge = false;
                }
                return;
            }
            //Fetch corrosponding other node
            int index = 0;
            GetChildTypeIndex getChildTypeIndex = new GetChildTypeIndex() { Parent = node.Parent(), Child = node };
            node.Parent().Apply(getChildTypeIndex);
            index = getChildTypeIndex.Index;
            GetChildTypeByIndex getChildTypeByIndex = new GetChildTypeByIndex() { Child = node, Index = index, Parent = otherNode };
            otherNode.Apply(getChildTypeByIndex);
            otherNode = getChildTypeByIndex.Child;

            if (otherNode.GetType() != node.GetType())
            {
                canMerge = false;
                return;
            }

            if (node is AALocalDecl)
            {
                locals.Add((AALocalDecl) node);
                otherLocals.Add((AALocalDecl) otherNode);
                return;
            }

            if (node is ANamedType)
            {
                ANamedType aNode = (ANamedType) node;
                ANamedType aOther = (ANamedType) otherNode;
                if (data.StructTypeLinks.ContainsKey(aNode) != data.StructTypeLinks.ContainsKey(aOther))
                {
                    canMerge = false;
                    return;
                }
                if (data.StructTypeLinks.ContainsKey(aNode) && data.StructTypeLinks[aNode] != data.StructTypeLinks[aOther])
                {
                    canMerge = false;
                }
                if (!data.StructTypeLinks.ContainsKey(aNode) && aNode.IsSame(aOther, true))//aNode.GetName().Text != aOther.GetName().Text)
                    canMerge = false;
                if (aNode.IsPrimitive() && !aOther.IsPrimitive(aNode.AsIdentifierString()))
                    canMerge = false;
                return;
            }

            if (node is AABlock)
            {
                AABlock aNode = (AABlock)node;
                AABlock aOther = (AABlock)otherNode;
                if (aNode.GetStatements().Count != aOther.GetStatements().Count)
                    canMerge = false;
                return;
            }

            if (node is AIntConstExp)
            {
                AIntConstExp aNode = (AIntConstExp)node;
                AIntConstExp aOther = (AIntConstExp)otherNode;
                if (aNode.GetIntegerLiteral().Text != aOther.GetIntegerLiteral().Text)
                    canMerge = false;
                return;
            }

            if (node is AFixedConstExp)
            {
                AFixedConstExp aNode = (AFixedConstExp)node;
                AFixedConstExp aOther = (AFixedConstExp)otherNode;
                if (aNode.GetFixedLiteral().Text != aOther.GetFixedLiteral().Text)
                    canMerge = false;
                return;
            }

            if (node is AStringConstExp)
            {
                AStringConstExp aNode = (AStringConstExp)node;
                AStringConstExp aOther = (AStringConstExp)otherNode;
                if (aNode.GetStringLiteral().Text != aOther.GetStringLiteral().Text)
                    canMerge = false;
                return;
            }

            if (node is ACharConstExp)
            {
                ACharConstExp aNode = (ACharConstExp)node;
                ACharConstExp aOther = (ACharConstExp)otherNode;
                if (aNode.GetCharLiteral().Text != aOther.GetCharLiteral().Text)
                    canMerge = false;
                return;
            }

//.........这里部分代码省略.........
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:101,代码来源:MergeSameMethods.cs


注:本文中的Galaxy_Editor_2.Compiler.Generated.node.Node.Parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。