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


C# AMethodDecl.GetFormals方法代码示例

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


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

示例1: CaseAMethodDecl

        public override void CaseAMethodDecl(AMethodDecl node)
        {
            if (node.GetInline() == null)
                return;

            //Variables marked as out can be made into ref
            foreach (AALocalDecl formal in node.GetFormals())
            {
                if (formal.GetOut() != null)
                {
                    formal.SetRef(new TRef("ref"));
                    formal.SetOut(null);
                }
            }
            assignedToLocals.Clear();
            base.CaseAMethodDecl(node);

            foreach (AALocalDecl formal in node.GetFormals())
            {
                if (!assignedToLocals.Contains(formal))
                    formal.SetRef(new TRef("ref"));
            }
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:23,代码来源:AddUnneededRef.cs

示例2: CaseAMethodDecl

 public override void CaseAMethodDecl(AMethodDecl node)
 {
     if (parsedMethods.Contains(node) || methodChain.Contains(node))
         return;
     methodChain.Add(node);
     NeededRefs.Add(node, new List<AALocalDecl>());
     base.CaseAMethodDecl(node);
     methodChain.Remove(node);
     parsedMethods.Add(node);
     foreach (AALocalDecl formal in node.GetFormals())
     {
         if (formal.GetRef() != null && !NeededRefs[node].Contains(formal) && !Util.IsBulkCopy(formal.GetType()))
             formal.SetRef(null);
     }
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:15,代码来源:RemoveUnnededRef.cs

示例3: MethodDescription

        public MethodDescription(AConstructorDecl method, string type)
        {
            Parser parser = new Parser(method);

            Start = parser.Start;
            End = parser.End;
            ReturnType = type;
            Name = parser.Name;
            Formals = parser.Formals;
            Locals = parser.Locals;
            if (method.Parent() != null)
                method.Parent().RemoveChild(method);
            Decl = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null, new ANamedType(new TIdentifier(type), null),
                                   new TIdentifier(""), new ArrayList(), method.GetBlock());
            while (method.GetFormals().Count > 0)
                Decl.GetFormals().Add(method.GetFormals()[0]);
            Visibility = method.GetVisibilityModifier();
            Position = TextPoint.FromCompilerCoords(method.GetName());
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:19,代码来源:MethodDescription.cs

示例4: CaseAMethodDecl

 public override void CaseAMethodDecl(AMethodDecl node)
 {
     if (node.GetName().Text == "InitMap" && node.GetFormals().Count == 0)
     {
         if (finalTrans.multipleMainEntries)
         {
             multipleEntryCandidates.Add(new ErrorCollection.Error(node.GetName(), Util.GetAncestor<AASourceFile>(node.GetName()), LocRM.GetString("ErrorText63")));
         }
         else if (finalTrans.mainEntry != null)
         {
             multipleEntryCandidates.Add(new ErrorCollection.Error(finalTrans.mainEntry.GetName(), Util.GetAncestor<AASourceFile>(finalTrans.mainEntry.GetName()), LocRM.GetString("ErrorText63")));
             multipleEntryCandidates.Add(new ErrorCollection.Error(node.GetName(), Util.GetAncestor<AASourceFile>(node.GetName()), LocRM.GetString("ErrorText63")));
             //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;
     }
     base.CaseAMethodDecl(node);
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:21,代码来源:MainEntryFinder.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: CaseAOperatorDecl

        public override void CaseAOperatorDecl(AOperatorDecl node)
        {
            AMethodDecl replacer = new AMethodDecl(node.GetVisibilityModifier(), null, node.GetStatic(), null, null,
                                                   null, node.GetReturnType(),
                                                   new TIdentifier(""), new ArrayList(),
                                                   node.GetBlock());
            while (node.GetFormals().Count > 0)
                replacer.GetFormals().Add(node.GetFormals()[0]);

            node.ReplaceBy(replacer);
            replacer.Apply(this);
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:12,代码来源:SimpleTransformations.cs

示例7: CaseAMethodDecl

 public override void CaseAMethodDecl(AMethodDecl node)
 {
     InAMethodDecl(node);
     if (node.GetBlock() != null)
     {
         node.GetBlock().Apply(this);
     }
     {
         Object[] temp = new Object[node.GetFormals().Count];
         node.GetFormals().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PLocalDecl)temp[i]).Apply(this);
         }
     }
     if (node.GetName() != null)
     {
         node.GetName().Apply(this);
     }
     if (node.GetReturnType() != null)
     {
         node.GetReturnType().Apply(this);
     }
     if (node.GetDelegate() != null)
     {
         node.GetDelegate().Apply(this);
     }
     if (node.GetInline() != null)
     {
         node.GetInline().Apply(this);
     }
     if (node.GetNative() != null)
     {
         node.GetNative().Apply(this);
     }
     if (node.GetStatic() != null)
     {
         node.GetStatic().Apply(this);
     }
     if (node.GetTrigger() != null)
     {
         node.GetTrigger().Apply(this);
     }
     if (node.GetVisibilityModifier() != null)
     {
         node.GetVisibilityModifier().Apply(this);
     }
     OutAMethodDecl(node);
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:49,代码来源:analysis.cs

示例8: CaseAOperatorDecl

        public override void CaseAOperatorDecl(AOperatorDecl node)
        {
            if (node.GetFormals().Count != 2)
                errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText182")));
            Token token = null;
            if (node.GetOperator() is APlusBinop)
                token = ((APlusBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AMinusBinop)
                token = ((AMinusBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ADivideBinop)
                token = ((ADivideBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ATimesBinop)
                token = ((ATimesBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AModuloBinop)
                token = ((AModuloBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AEqBinop)
                token = ((AEqBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ANeBinop)
                token = ((ANeBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ALtBinop)
                token = ((ALtBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ALeBinop)
                token = ((ALeBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AGtBinop)
                token = ((AGtBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AGeBinop)
                token = ((AGeBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AGtBinop)
                token = ((AGtBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AAndBinop)
                token = ((AAndBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AOrBinop)
                token = ((AOrBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AXorBinop)
                token = ((AXorBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ALBitShiftBinop)
                token = ((ALBitShiftBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ARBitShiftBinop)
                token = ((ARBitShiftBinop)node.GetOperator()).GetToken();

            AMethodDecl replacer = new AMethodDecl(node.GetVisibilityModifier(), null, node.GetStatic(), null, null,
                                                   null, node.GetReturnType(),
                                                   new TIdentifier(token.Text, token.Line, token.Pos), new ArrayList(),
                                                   node.GetBlock());
            while (node.GetFormals().Count > 0)
                replacer.GetFormals().Add(node.GetFormals()[0]);

            node.ReplaceBy(replacer);
            replacer.Apply(this);
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:50,代码来源:Weeder.cs

示例9: CheckInvoke

        private void CheckInvoke(ASimpleInvokeExp node, AMethodDecl target)
        {
            if (target.GetInline() != null)
            {
                AMethodDecl pMethod = Util.GetAncestor<AMethodDecl>(node);
                AConstructorDecl pConstructor = Util.GetAncestor<AConstructorDecl>(node);
                ADeconstructorDecl pDeconstructor = Util.GetAncestor<ADeconstructorDecl>(node);
                if (pMethod == null && !Util.HasAncestor<AConstructorDecl>(node) &&
                    !Util.HasAncestor<ADeconstructorDecl>(node) && !Util.HasAncestor<APropertyDecl>(node))
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText131")));
                }
                else if (pMethod != null && !InlineMethodCalls[pMethod].Contains(target))
                    InlineMethodCalls[pMethod].Add(target);
            }

            //For each formal marked as ref or out, the argument must be a non-const variable
            for (int i = 0; i < node.GetArgs().Count; i++)
            {
                AALocalDecl formal = (AALocalDecl)target.GetFormals()[i];
                if (formal.GetRef() != null || formal.GetOut() != null)
                {
                    PExp exp = (PExp)node.GetArgs()[i];
                    while (true)
                    {
                        PLvalue lvalue;
                        if (exp is ALvalueExp)
                        {
                            lvalue = ((ALvalueExp)exp).GetLvalue();
                        }
                        else if (exp is AAssignmentExp)
                        {
                            lvalue = ((AAssignmentExp)exp).GetLvalue();
                        }
                        else
                        {
                            errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText129") + (i + 1) + LocRM.GetString("ErrorText130")));
                            break;
                        }
                        if (lvalue is ALocalLvalue)
                        {
                            if (data.LocalLinks[(ALocalLvalue)lvalue].GetConst() != null)
                                errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText129") + (i + 1) + LocRM.GetString("ErrorText132")));
                            break;
                        }
                        if (lvalue is AFieldLvalue)
                        {
                            if (data.FieldLinks[(AFieldLvalue)lvalue].GetConst() != null)
                                errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText129") + (i + 1) + LocRM.GetString("ErrorText132")));
                            break;
                        }
                        if (lvalue is AStructFieldLvalue)
                        {
                            if (data.StructMethodFieldLinks[(AStructFieldLvalue)lvalue].GetConst() != null)
                                errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText129") + (i + 1) + LocRM.GetString("ErrorText132")));
                            break;
                        }
                        if (lvalue is AThisLvalue)
                            break;
                        if (lvalue is AStructLvalue)
                        {
                            exp = ((AStructLvalue)lvalue).GetReceiver();
                            continue;
                        }
                        if (lvalue is AArrayLvalue)
                        {
                            exp = ((AArrayLvalue)lvalue).GetBase();
                            continue;
                        }
                        if (lvalue is APointerLvalue)
                        {
                            exp = ((APointerLvalue)lvalue).GetBase();
                            continue;
                        }
                        throw new Exception("Unexpected lvalue");
                    }
                }
            }
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:79,代码来源:TypeChecking.cs

示例10: OutAMethodDecl

        public override void OutAMethodDecl(AMethodDecl node)
        {
            if (node.GetTrigger() != null)
            {
                bool validSignature = IsBoolType(node.GetReturnType());
                validSignature &= node.GetFormals().Count == 2;
                foreach (AALocalDecl formal in node.GetFormals())
                {
                    validSignature &= IsBoolType(formal.GetType());
                    validSignature &= formal.GetRef() == null && formal.GetOut() == null;
                }
                if (!validSignature)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile,
                                                         LocRM.GetString("ErrorText156")));
                }
            }

            //Check that all code paths return a value
            if (!(node.GetReturnType() is AVoidType))
            {
                CheckReturns returnChecker = new CheckReturns();
                node.GetBlock().Apply(returnChecker);
                if (!returnChecker.Returned)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText157")));
                }
            }

            //If the return type or the type of any formals is a private struct, and the method is a public context, give an error
            {
                AStructDecl pStruct = Util.GetAncestor<AStructDecl>(node);
                //Is public context
                if (pStruct == null && node.GetVisibilityModifier() is APublicVisibilityModifier ||
                    pStruct != null && pStruct.GetVisibilityModifier() is APublicVisibilityModifier && !(node.GetVisibilityModifier() is APrivateVisibilityModifier))
                {
                    PType type = node.GetReturnType();
                    int i = 0;
                    FindPrivateTypes finder = new FindPrivateTypes(data);
                    while (true)
                    {
                        type.Apply(finder);

                        if (i == node.GetFormals().Count)
                            break;
                        AALocalDecl formal = (AALocalDecl) node.GetFormals()[i];
                        type = formal.GetType();
                        i++;
                    }

                    if (finder.PrivateTypes.Count > 0)
                    {
                        List<ErrorCollection.Error> subErrors = new List<ErrorCollection.Error>();
                        List<PDecl> usedDecls = new List<PDecl>();
                        foreach (ANamedType namedType in finder.PrivateTypes)
                        {
                            if (data.StructTypeLinks.ContainsKey(namedType))
                            {
                                AStructDecl decl = data.StructTypeLinks[namedType];
                                if (usedDecls.Contains(decl))
                                    continue;
                                usedDecls.Add(decl);
                                subErrors.Add(new ErrorCollection.Error(decl.GetName(), LocRM.GetString("ErrorText64")));
                            }
                            else if (data.DelegateTypeLinks.ContainsKey(namedType))
                            {
                                AMethodDecl decl = data.DelegateTypeLinks[namedType];
                                if (usedDecls.Contains(decl))
                                    continue;
                                usedDecls.Add(decl);
                                subErrors.Add(new ErrorCollection.Error(decl.GetName(), LocRM.GetString("ErrorText154")));
                            }
                        }

                        errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText155"), false, subErrors.ToArray()));
                    }
                }
            }

            base.OutAMethodDecl(node);
        }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:81,代码来源:TypeChecking.cs

示例11: CaseAMethodDecl

 public override void CaseAMethodDecl(AMethodDecl node)
 {
     Write("\n");
     if (node.GetStatic() != null) Write("static ");
     if (node.GetNative() != null) Write("native ");
     node.GetReturnType().Apply(this);
     Write(" " + node.GetName().Text + "(");
     bool first = true;
     foreach (AALocalDecl formal in node.GetFormals())
     {
         if (!first) Write(", ");
         formal.Apply(this);
         first = false;
     }
     if (node.GetBlock() != null)
     {
         Write(")\n");
         node.GetBlock().Apply(this);
     }
     else
         Write(");\n\n");
 }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:22,代码来源:CodeGeneration.cs

示例12: CaseAMethodDecl


//.........这里部分代码省略.........
                            ALocalLvalue lvalue = new ALocalLvalue((TIdentifier)replaced.GetName().Clone());
                            finalTrans.data.LvalueTypes[lvalue] = replaced.GetType();
                            AAssignmentExp exp = new AAssignmentExp(new TAssign("=", lvalue.GetName().Line, lvalue.GetName().Pos), lvalue, replaced.GetInit());
                            AExpStm expStm = new AExpStm(declStm.GetToken(), exp);
                            declStm.ReplaceBy(expStm);
                            finalTrans.data.LvalueTypes[lvalue] = replacement.GetType();
                            finalTrans.data.ExpTypes[exp] = replacement.GetType();
                            finalTrans.data.LocalLinks[lvalue] = replacement;
                        }
                    }
                }
            }

            //Unique names
            List<string> names = new List<string>();
            //Avoid clash with methods/fields/structs
            names.AddRange(finalTrans.data.Methods.Select(declItem => declItem.Decl.GetName().Text));
            names.AddRange(finalTrans.data.Fields.Select(declItem => declItem.Decl.GetName().Text));
            names.AddRange(finalTrans.data.Structs.Select(declItem => declItem.Decl.GetName().Text));
            foreach (AALocalDecl local in definedLocals)
            {
                string name = local.GetName().Text;
                int version = 1;
                while (names.Contains(name))
                {
                    version++;
                    name = local.GetName().Text + version;
                }
                local.GetName().Text = name;
                names.Add(name);
            }

            //Move defined locals to the start of the method
            foreach (AALocalDecl formal in node.GetFormals())
            {
                definedLocals.Remove(formal);
            }
            AABlock block = (AABlock)node.GetBlock();
            for (int i = 0; i < block.GetStatements().Count; i++)
            {
                ALocalDeclStm stm;
                if (block.GetStatements()[i] is ALocalDeclStm)
                {
                    stm = (ALocalDeclStm)block.GetStatements()[i];
                    definedLocals.Remove((AALocalDecl)stm.GetLocalDecl());
                    continue;
                }
                //Add the rest at i
                if (definedLocals.Count == 0)
                    break;
                AALocalDecl decl = definedLocals[0];
                definedLocals.RemoveAt(0);

                if (decl.GetInit() == null)
                {
                    ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier(decl.GetName().Text));
                    finalTrans.data.LocalLinks[lvalue] = decl;
                    finalTrans.data.LvalueTypes[lvalue] = decl.GetType();
                    List<PStm> statements = AssignDefault(lvalue);
                    PStm pStm = Util.GetAncestor<PStm>(decl);
                    AABlock pBlock = (AABlock) pStm.Parent();
                    foreach (PStm statement in statements)
                    {
                        pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), statement);
                    }
                    pBlock.RemoveChild(pStm);
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:67,代码来源:LivenessAnalysis.cs

示例13: InAMethodDecl

            public override void InAMethodDecl(AMethodDecl node)
            {
                //nullPointers.Clear();
                setPointers.Clear();
                exposedPointers.Clear();
                generatedPointers.Clear();

                //Paremeter pointers are exposed
                foreach (AALocalDecl formal in node.GetFormals())
                {
                    foreach (List<PointerType> pointer in GetAllPointerTypes(formal, formal.GetType()))
                    {
                        exposedPointers.Add(MakePointer(pointer));
                    }
                }
            }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:16,代码来源:Pointers.cs

示例14: CaseAMethodDecl

            public override void CaseAMethodDecl(AMethodDecl node)
            {
                if (processedMethods.Contains(node))
                    return;
                processedMethods.Add(node);
                //For each bulk copy param, make it a pointer type
                foreach (AALocalDecl formal in node.GetFormals())
                {
                    PType type = formal.GetType();
                    if (Util.IsBulkCopy(type) || formal.GetRef() != null || formal.GetOut() != null)
                    {
                        if (type is AArrayTempType)
                        {//make dynamic array
                            AArrayTempType aType = (AArrayTempType) type;
                            List<PExp> exps = new List<PExp>();
                            PType newType = new APointerType(new TStar("*"),
                                                             new ADynamicArrayType((TLBracket)aType.GetToken().Clone(),
                                                                         Util.MakeClone(aType.GetType(), data)));
                            /*exps.AddRange(data.ExpTypes.Where(k => k.Value == type).Select(k => k.Key));
                            foreach (PExp exp in exps)
                            {
                                data.ExpTypes[exp] = newType;
                            }*/
                            formal.SetType(newType);
                            foreach (KeyValuePair<ALocalLvalue, AALocalDecl> pair in data.LocalLinks)
                            {
                                if (pair.Value == formal)
                                {//Replace with *lvalue
                                    ALvalueExp innerExp = new ALvalueExp();
                                    APointerLvalue replacement = new APointerLvalue(new TStar("*"), innerExp);
                                    pair.Key.ReplaceBy(replacement);
                                    innerExp.SetLvalue(pair.Key);
                                    data.ExpTypes[innerExp] = data.LvalueTypes[pair.Key] = formal.GetType();
                                    data.LvalueTypes[replacement] = ((APointerType)newType).GetType();

                                    //if (replacement.Parent() is ALvalueExp)
                                    //    data.ExpTypes[(PExp)replacement.Parent()] = data.LvalueTypes[replacement];
                                }
                            }
                        }
                        else
                        {//Make pointer
                            formal.SetType(new APointerType(new TStar("*"), type));
                            foreach (KeyValuePair<ALocalLvalue, AALocalDecl> pair in data.LocalLinks)
                            {
                                if (pair.Value == formal)
                                {//Replace with *lvalue
                                    ALvalueExp innerExp = new ALvalueExp();
                                    APointerLvalue replacement = new APointerLvalue(new TStar("*"), innerExp);
                                    pair.Key.ReplaceBy(replacement);
                                    innerExp.SetLvalue(pair.Key);
                                    data.ExpTypes[innerExp] = data.LvalueTypes[pair.Key] = formal.GetType();
                                    data.LvalueTypes[replacement] = type;
                                }
                            }
                        }
                    }
                }
                if (Util.IsBulkCopy(node.GetReturnType()))
                {
                    PType oldType = node.GetReturnType();
                    PType newType;
                    if (node.GetReturnType() is AArrayTempType)
                    {//make dynamic array
                        AArrayTempType aType = (AArrayTempType) node.GetReturnType();
                        newType = new APointerType(new TStar("*"),
                                                   new ADynamicArrayType((TLBracket) aType.GetToken().Clone(),
                                                                         Util.MakeClone(aType.GetType(), data)));
                        node.SetReturnType(newType);
                    }
                    else
                    {//Make pointer
                        newType = new APointerType(new TStar("*"), node.GetReturnType());
                        node.SetReturnType(newType);
                    }
                    /*List<PExp> exps = new List<PExp>();
                    exps.AddRange(data.ExpTypes.Where(k => k.Value == oldType).Select(k => k.Key));
                    foreach (PExp exp in exps)
                    {
                        data.ExpTypes[exp] = newType;
                    }
                    List<PLvalue> lvalues = new List<PLvalue>();
                    lvalues.AddRange(data.LvalueTypes.Where(k => k.Value == oldType).Select(k => k.Key));
                    foreach (PLvalue lvalue in lvalues)
                    {
                        data.LvalueTypes[lvalue] = newType;
                    }*/
                }
                 	            base.CaseAMethodDecl(node);
            }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:90,代码来源:Pointers.cs

示例15: Apply


//.........这里部分代码省略.........
                        {
                            if (includeItem.Parent == null)
                                break;
                            i++;
                            continue;
                        }
                        i = 0;
                        //Put all children into this
                        while (includeItem.Children.Count > 0)
                        {
                            int childNr = includeItem.Children.Count - 1;
                            allItems.Remove(includeItem.Children[childNr]);
                            if (includeItem.Children[childNr] is FieldItem)
                            {
                                FieldItem aItem = (FieldItem)includeItem.Children[childNr];
                                Node node = aItem.FieldDecl;
                                node.Parent().RemoveChild(node);
                                includeItem.Current.GetDecl().Insert(0, node);
                            }
                            else if (includeItem.Children[childNr] is StructItem)
                            {
                                StructItem aItem = (StructItem)includeItem.Children[childNr];
                                Node node = aItem.StructDecl;
                                node.Parent().RemoveChild(node);
                                includeItem.Current.GetDecl().Insert(0, node);
                            }
                            else if (includeItem.Children[childNr] is MethodDeclItem)
                            {
                                MethodDeclItem aItem = (MethodDeclItem)includeItem.Children[childNr];
                                AMethodDecl aNode = new AMethodDecl();
                                if (aItem.RealDecl.GetStatic() != null) aNode.SetStatic(new TStatic("static"));
                                aNode.SetReturnType(Util.MakeClone(aItem.RealDecl.GetReturnType(), finalTrans.data));
                                aNode.SetName(new TIdentifier(aItem.RealDecl.GetName().Text));
                                foreach (AALocalDecl formal in aItem.RealDecl.GetFormals())
                                {
                                    AALocalDecl clone = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, Util.MakeClone(formal.GetType(), finalTrans.data), new TIdentifier(formal.GetName().Text), null);
                                    aNode.GetFormals().Add(clone);
                                }
                                includeItem.Current.GetDecl().Insert(0, aNode);
                            }
                            else if (includeItem.Children[childNr] is IncludeItem)
                            {
                                IncludeItem aChild = (IncludeItem)includeItem.Children[childNr];
                                if (aChild.Current == null)
                                {
                                    AIncludeDecl node = new AIncludeDecl(new TInclude("include"),
                                                        new TStringLiteral("\"TriggerLibs/NativeLib\""));
                                    includeItem.Current.GetDecl().Insert(0, node);
                                }
                                else
                                {
                                    PDecl[] decls = new PDecl[aChild.Current.GetDecl().Count];
                                    aChild.Current.GetDecl().CopyTo(decls, 0);
                                    for (int k = decls.Length - 1; k >= 0; k--)
                                    {
                                        includeItem.Current.GetDecl().Insert(0, decls[k]);
                                    }
                                    aChild.Current.Parent().RemoveChild(aChild.Current);
                                    //i = -1;
                                }
                            }
                            includeItem.Children.RemoveAt(childNr);
                        }
                    }
                }
            }
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:67,代码来源:FixIncludes.cs


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