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


C# AMethodDecl.Parent方法代码示例

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


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

示例1: MethodDescription

        public MethodDescription(AMethodDecl method)
        {
            Parser parser = new Parser(method);

            Start = parser.Start;
            End = parser.End;
            ReturnType = parser.ReturnType;
            Name = parser.Name;
            Formals = parser.Formals;
            Locals = parser.Locals;
            if (method.Parent() != null)
                method.Parent().RemoveChild(method);
            IsDelegate = method.GetDelegate() != null;
            //if (!IsDelegate)
                Decl = method;
            IsStatic = method.GetStatic() != null;
            Visibility = method.GetVisibilityModifier();
            realType = (PType)method.GetReturnType().Clone();
            Position = TextPoint.FromCompilerCoords(method.GetName());
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:20,代码来源:MethodDescription.cs

示例2: foreach

        /*public override void InAMethodDecl(AMethodDecl node)
        {
            AABlock block = (AABlock) node.GetBlock();
            if (block != null)
            {
                if (!data.Locals.ContainsKey(block))
                    data.Locals.Add(block, new List<AALocalDecl>());
                foreach (AALocalDecl formal in node.GetFormals())
                {
                    data.Locals[block].Add(formal);
                }
            }
        }

        public override void InAConstructorDecl(AConstructorDecl node)
        {
            AABlock block = (AABlock)node.GetBlock();
            if (block != null)
            {
                if (!data.Locals.ContainsKey(block))
                    data.Locals.Add(block, new List<AALocalDecl>());
                foreach (AALocalDecl formal in node.GetFormals())
                {
                    data.Locals[block].Add(formal);
                }
            }
        }*/
        public override void OutAMethodDecl(AMethodDecl node)
        {
            AStructDecl parentStruct = Util.GetAncestor<AStructDecl>(node);
            AEnrichmentDecl parentEnrichment = Util.GetAncestor<AEnrichmentDecl>(node);
            if (parentStruct != null)
            {
                //Struct method
                data.StructMethods[parentStruct].Add(node);
            }
            else if (parentEnrichment == null)
            {//Global method
                //Dont care about abstract methods - will add them later
                if (node.GetBlock() != null || node.GetNative() != null)
                {
                    data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(currentSourceFile, node));
                    data.UserMethods.Add(node);
                }
                else if (node.GetDelegate() != null)
                    data.Delegates.Add(new SharedData.DeclItem<AMethodDecl>(currentSourceFile, node));
                else
                {
                    node.Parent().RemoveChild(node);
                    return;
                }
            }
            base.OutAMethodDecl(node);
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:54,代码来源:EnviromentBuilding.cs

示例3: Disambiguate

        /*
        private PLvalue Disambiguate(PName name)
        {
            ASimpleName aName = (ASimpleName)name;
            AABlock block = Util.GetAncestor<AABlock>(aName);

            while (block != null || Util.HasAncestor<AConstructorDecl>(aName))
            {//We might reference a local
                if (block != null && !data.Locals.ContainsKey(block)) data.Locals.Add(block, new List<AALocalDecl>());
                List<AALocalDecl> locals = new List<AALocalDecl>();
                if (block != null)
                    locals = data.Locals[block];
                else
                {
                    foreach (AALocalDecl formal in Util.GetAncestor<AConstructorDecl>(aName).GetFormals())
                    {
                        locals.Add(formal);
                    }
                }

                foreach (AALocalDecl local in locals)
                {
                    if (aName.GetIdentifier().Text == local.GetName().Text)
                    {
                        //First, the local must not be used before it's declared
                        PStm currentStm = Util.GetAncestor<PStm>(name);
                        PStm targetStm = Util.GetAncestor<PStm>(local);
                        if (currentStm is ASwitchCaseStm)
                            currentStm = (PStm)currentStm.Parent();
                        if (targetStm is ASwitchCaseStm)
                            targetStm = (PStm)targetStm.Parent();
                        //If its a parameter, there will be no parent stm, and then there is no problem)
                        if (targetStm != null)
                        {
                            AABlock currentBlock = (AABlock) currentStm.Parent();
                            AABlock targetBlock = (AABlock)targetStm.Parent();
                            while (targetBlock != currentBlock)
                            {
                                if (Util.IsAncestor(targetStm, currentBlock))
                                {
                                    do
                                    {
                                        targetStm = Util.GetAncestor<PStm>(targetStm.Parent());
                                    } while (!(targetStm.Parent() is AABlock));
                                    targetBlock = (AABlock) targetStm.Parent();
                                    continue;
                                }
                                if (Util.IsAncestor(currentStm, targetBlock))
                                {
                                    do
                                    {
                                        currentStm = Util.GetAncestor<PStm>(currentStm.Parent());
                                    } while (!(currentStm.Parent() is AABlock));
                                    currentBlock = (AABlock)currentStm.Parent();
                                    continue;
                                }
                            }
                            if (currentBlock.GetStatements().IndexOf(currentStm) <= targetBlock.GetStatements().IndexOf(targetStm))
                            {
                                continue;
                            }
                        }

                        //We will replace with this, so might aswell add it to local_links
                        ALocalLvalue localLvalue = new ALocalLvalue(aName.GetIdentifier());
                        data.LocalLinks.Add(localLvalue, local);

                        return localLvalue;
                    }
                }
                if (block == null)
                    break;
                block = Util.GetAncestor<AABlock>(block.Parent());
            }

            //Look for struct fields if inside a struct
            bool matchedStatic = false;
            AStructDecl str = Util.GetAncestor<AStructDecl>(name);
            if (str != null)
            {
                foreach (AALocalDecl local in data.StructFields[str])
                {
                    if (aName.GetIdentifier().Text == local.GetName().Text)
                    {
                        //If it's an enherited private variable, you can't refer to it.
                        if (local.GetVisibilityModifier() is APrivateVisibilityModifier &&
                            data.EnheritanceLocalMap.ContainsKey(local))
                        {
                            continue;
                        }
                        if (local.GetStatic() != null)
                        {
                            //matchedStatic = true;
                            //continue;
                            ATypeLvalue typeLvalue = new ATypeLvalue(new TIdentifier(str.GetName().Text));
                            AStructLvalue structLvalue = new AStructLvalue(new ALvalueExp(typeLvalue), new ADotDotType(new TDot(".")), aName.GetIdentifier());
                            return structLvalue;
                        }

                        if (str.GetClassToken() == null && !Util.HasAncestor<AConstructorDecl>(name) && !Util.HasAncestor<ADeconstructorDecl>(name))
//.........这里部分代码省略.........
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:101,代码来源:TypeLinking.cs

示例4: CaseAMethodDecl

        //private List<ErrorCollection.Error> multipleEntryCandidates = new List<ErrorCollection.Error>();
        public override void CaseAMethodDecl(AMethodDecl node)
        {
            //Done in a previous iteration
            /*if (node.GetName().Text == "InitMap" && node.GetFormals().Count == 0)
            {
                if (finalTrans.multipleMainEntries)
                {
                    multipleEntryCandidates.Add(new ErrorCollection.Error(node.GetName(), Util.GetAncestor<AASourceFile>(node.GetName()), "Candidate"));
                }
                else if (finalTrans.mainEntry != null)
                {
                    multipleEntryCandidates.Add(new ErrorCollection.Error(finalTrans.mainEntry.GetName(), Util.GetAncestor<AASourceFile>(finalTrans.mainEntry.GetName()), "Candidate"));
                    multipleEntryCandidates.Add(new ErrorCollection.Error(node.GetName(), Util.GetAncestor<AASourceFile>(node.GetName()), "Candidate"));
                    //finalTrans.errors.Add(new ErrorCollection.Error(node.GetName(), Util.GetAncestor<AASourceFile>(node), "Found multiple candidates for a main entry", true));
                    finalTrans.multipleMainEntries = true;
                    finalTrans.mainEntry = null;
                }
                else
                    finalTrans.mainEntry = node;
            }*/

            AStructDecl str = Util.GetAncestor<AStructDecl>(node);
            if (str != null)
            {
                if (node.GetStatic() == null)
                    structMethods.Add(node);
                //Move the method outside the struct
                str.RemoveChild(node.Parent());
                AASourceFile file = (AASourceFile)str.Parent();
                int i = file.GetDecl().IndexOf(str);
                file.GetDecl().Insert(i/* + 1*/, node);
                node.GetName().Text = GetUniqueStructMethodName(str.GetName().Text + "_" + node.GetName().Text);

                if (node.GetStatic() == null)
                {
                    //Add the struct as a parameter
                    PType structType = new ANamedType(new TIdentifier(str.GetName().Text), null);
                    finalTrans.data.StructTypeLinks[(ANamedType) structType] = str;
                    if (str.GetClassToken() != null)
                    {
                        structType = new APointerType(new TStar("*"), structType);
                    }
                    structFormal = new AALocalDecl(new APublicVisibilityModifier(), null,
                                                   str.GetClassToken() == null ? new TRef("ref") : null, null, null,
                                                   structType,
                                                   new TIdentifier("currentStruct", node.GetName().Line,
                                                                   node.GetName().Pos), null);
                    node.GetFormals().Add(structFormal);
                    data.Locals[(AABlock) node.GetBlock()].Add(structFormal);
                }
                else
                    node.SetStatic(null);
                finalTrans.data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(file, node));
                if (node.GetStatic() == null)
                    OldParentStruct[node] = str;
                //Fix refferences to other struct stuff);
                base.CaseAMethodDecl(node);
                //Will visit later, since it's added after the struct
                //base.CaseAMethodDecl(node);
                //if (str.GetLocals().Count == 0)
                //    str.Parent().RemoveChild(str);
                return;
            }
            AEnrichmentDecl enrichment = Util.GetAncestor<AEnrichmentDecl>(node);
            if (enrichment != null)
            {
                if (node.GetStatic() == null)
                    structMethods.Add(node);
                //Move the method outside the struct
                enrichment.RemoveChild(node);
                AASourceFile file = (AASourceFile)enrichment.Parent();
                int i = file.GetDecl().IndexOf(enrichment);
                file.GetDecl().Insert(i/* + 1*/, node);
                node.GetName().Text = GetUniqueStructMethodName(Util.TypeToIdentifierString(enrichment.GetType()) + "_" + node.GetName().Text);

                if (node.GetStatic() == null)
                {
                    //Add the struct as a parameter
                    PType structType = Util.MakeClone(enrichment.GetType(), finalTrans.data);
                    structFormal = new AALocalDecl(new APublicVisibilityModifier(), null, new TRef("ref"), null, null,
                                                   structType,
                                                   new TIdentifier("currentEnrichment", node.GetName().Line,
                                                                   node.GetName().Pos), null);
                    node.GetFormals().Add(structFormal);
                }
                finalTrans.data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(file, node));
                //Fix refferences to other struct stuff);
                base.CaseAMethodDecl(node);
                //Will visit later, since it's added after the struct
                //base.CaseAMethodDecl(node);
                //if (str.GetLocals().Count == 0)
                //    str.Parent().RemoveChild(str);
                return;
            }
            //Build a list of overloads
            List<AMethodDecl> overloads = new List<AMethodDecl>();
            List<string> prefixMatches = new List<string>();

            foreach (SharedData.DeclItem<AMethodDecl> declItem in finalTrans.data.Methods)
//.........这里部分代码省略.........
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:101,代码来源:TransformMethodDecls.cs

示例5: CaseAMethodDecl

        public override void CaseAMethodDecl(AMethodDecl node)
        {
            if (node.GetNative() == null && node.GetBlock() == null)
                return;
            if (node.GetStatic() != null)
                return;

            string inputStr = "native " + TypeToString(node.GetReturnType()) + " " + node.GetName().Text +
                                 "(";
            bool first = true;
            foreach (AALocalDecl formal in node.GetFormals())
            {
                if (!first)
                    inputStr += ", ";
                inputStr += TypeToString(formal.GetType()) + " " + formal.GetName().Text;
                first = false;
            }
            inputStr += ");";

            writer.WriteLine(inputStr);

            AStructDecl str = Util.GetAncestor<AStructDecl>(node);
            List<AMethodDecl> methodList;
            if (str != null)
                methodList = StructMethods[str];
            else
                methodList = Methods;
            string sig = Util.GetMethodSignature(node);
            if (methodList.Any(otherMethod => Util.GetMethodSignature(otherMethod) == sig))
            {
                return;
            }

            methodList.Add(node);
            node.SetBlock(null);
            node.Parent().RemoveChild(node);
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:37,代码来源:LibraryData.cs

示例6: CaseAMethodDecl

 public override void CaseAMethodDecl(AMethodDecl node)
 {
     if (node.GetInline() != null)
     {
         bool canAlwaysInline = true;
         foreach (KeyValuePair<ASimpleInvokeExp, AMethodDecl> pair in data.SimpleMethodLinks)
         {
             if (pair.Value == node && !Util.HasAncestor<AABlock>(pair.Key))
             {
                 canAlwaysInline = false;
                 break;
             }
         }
         if (canAlwaysInline)
         {
             node.Parent().RemoveChild(node);
             if (finalTrans.data.Methods.Any(item => item.Decl == node))
                 finalTrans.data.Methods.Remove(finalTrans.data.Methods.First(item => item.Decl == node));
         }
     }
     else
         base.CaseAMethodDecl(node);
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:23,代码来源:FixInlineMethods.cs


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