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


C# PExp.Apply方法代码示例

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


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

示例1: ContainsNewExp

 bool ContainsNewExp(PExp exp)
 {
     if (exp == null) return false;
     NewExpFinder finder = new NewExpFinder();
     exp.Apply(finder);
     return finder.HasNew;
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:7,代码来源:StaticStructMembers.cs

示例2: GetLocalData

        public static ModifyData GetLocalData(PExp expression, SharedData data)
        {
            if (expression == null)
                return new ModifyData();

            AMethodDecl method = Util.GetAncestor<AMethodDecl>(expression);
            GetDependancies dependancies = new GetDependancies(data, method);
            expression.Apply(dependancies);
            ModifyData modifyData = new ModifyData();

            foreach (AFieldDecl fieldDecl in dependancies.ReadFields[method])
            {
                modifyData.Add(fieldDecl, true, false);
            }
            foreach (AFieldDecl fieldDecl in dependancies.WrittenFields[method])
            {
                modifyData.Add(fieldDecl, false, true);
            }
            foreach (AALocalDecl localDecl in dependancies.ReadLocals[method])
            {
                modifyData.Add(localDecl, true, false);
            }
            foreach (AALocalDecl localDecl in dependancies.WrittenLocals[method])
            {
                modifyData.Add(localDecl, false, true);
            }

            foreach (AMethodDecl usedMethod in dependancies.UsedMethods[method])
            {
                modifyData.Union(GetModifyData(usedMethod));
            }

            return modifyData;
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:34,代码来源:LocalChecker.cs

示例3: TurnDynamic

            private AALocalDecl TurnDynamic(PExp exp, AALocalDecl targetDecl, PType type, bool assignBefore = true, bool assignAfter = false, bool makeDelete = true)
            {
                exp.Apply(mover);
                //insert
                //<basetype>[]* bulkCopyVar = new <baseType>[<dim>]();
                //bulkCopyVar[0] = arg[0];
                //bulkCopyVar[1] = arg[1];
                //bulkCopyVar[2] = arg[2];
                //...
                //Invoke(..., bulkCopyVar, ...);

                //If we need to clean up after, move the exp to it's own statement.

                AALocalDecl newLocal;
                if (type is AArrayTempType)
                {
                    AArrayTempType aType = (AArrayTempType) type;
                    ANewExp newExp = new ANewExp(new TNew("new"), new AArrayTempType(
                                                                       new TLBracket("["),
                                                                       Util.MakeClone(aType.GetType(),
                                                                                      data),
                                                                       Util.MakeClone(aType.GetDimention(), data),
                                                                       (TIntegerLiteral)
                                                                       aType.GetIntDim().Clone()),
                                                 new ArrayList());
                    newLocal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                               new APointerType(new TStar("*"),
                                                                new ADynamicArrayType(
                                                                    new TLBracket("["),
                                                                    Util.MakeClone(aType.GetType(),
                                                                                   data))),
                                               new TIdentifier("bulkCopyVar"),
                                               newExp
                        );
                }
                else
                {
                    ANewExp newExp = new ANewExp(new TNew("new"), Util.MakeClone(type, data),
                                                 new ArrayList());
                    newLocal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                               new APointerType(new TStar("*"),
                                                                Util.MakeClone(type, data)),
                                               new TIdentifier("bulkCopyVar"),
                                               newExp
                        );
                }
                PStm pStm = Util.GetAncestor<PStm>(exp);
                AABlock pBlock = (AABlock) pStm.Parent();
                pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm),
                                                new ALocalDeclStm(new TSemicolon(";"), newLocal));
                PLvalue bulkCopyRef = new ALocalLvalue(new TIdentifier("bulkCopyVar"));
                data.LocalLinks[(ALocalLvalue) bulkCopyRef] = newLocal;
                data.LvalueTypes[bulkCopyRef] = newLocal.GetType();

                ALvalueExp bulkCopyRefExp;
                //if (!(type is AArrayTempType))
                {
                    bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
                    bulkCopyRef = new APointerLvalue(new TStar("*"), bulkCopyRefExp);
                    data.ExpTypes[bulkCopyRefExp] = newLocal.GetType();
                    data.LvalueTypes[bulkCopyRef] = type;
                }

                if (assignBefore)
                {
                    List<PStm> stms = MakeAssignments(bulkCopyRef, exp, new List<AALocalDecl>() {targetDecl});
                    foreach (PStm stm in stms)
                    {
                        pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), stm);
                    }
                }
                int addStms = 1;
                if (assignAfter)
                {
                    bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
                    data.ExpTypes[bulkCopyRefExp] = data.LvalueTypes[bulkCopyRef];
                    List<PStm> stms = MakeAssignments(((ALvalueExp)exp).GetLvalue(), bulkCopyRefExp, new List<AALocalDecl>() {targetDecl});
                    addStms += stms.Count;
                    foreach (PStm stm in stms)
                    {
                        pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm) + 1, stm);
                    }
                }

                bulkCopyRef = new ALocalLvalue(new TIdentifier("bulkCopyVar"));
                bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
                data.LocalLinks[(ALocalLvalue) bulkCopyRef] = newLocal;
                data.LvalueTypes[bulkCopyRef] = data.ExpTypes[bulkCopyRefExp] = newLocal.GetType();
                exp.ReplaceBy(bulkCopyRefExp);

                /*if (formal.GetRef() != null || formal.GetOut() != null)
                {
                    //Get args back
                }*/
                //Delete object

                if (makeDelete)
                {
                    bulkCopyRef = new ALocalLvalue(new TIdentifier("bulkCopyVar"));
                    bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
//.........这里部分代码省略.........
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:101,代码来源:Pointers.cs


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