예제 #1
0
            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);
                }
            }
예제 #2
0
        public override void InAStructDecl(AStructDecl node)
        {
            decls.Add(node);

            /*node.GetName().Text = nextName;
             * NextName();*/
        }
예제 #3
0
        /*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);
        }
예제 #4
0
        public override void OutADeconstructorDecl(ADeconstructorDecl node)
        {
            AStructDecl parentStruct = Util.GetAncestor <AStructDecl>(node);

            if (parentStruct != null)
            {
                if (data.StructDeconstructor.ContainsKey(parentStruct) && data.StructDeconstructor[parentStruct] != node)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(),
                                                         "You can only define one deconstructor in a " +
                                                         Util.GetTypeName(parentStruct) + ".", false,
                                                         new[]
                    {
                        new ErrorCollection.Error(
                            data.StructDeconstructor[parentStruct].GetName(),
                            "Other deconstructor")
                    }));
                }

                data.StructDeconstructor[parentStruct] = node;
                if (parentStruct.GetName().Text != node.GetName().Text)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile,
                                                         "Deconstructors must have same name as the enclosing struct."));
                }
            }
            base.OutADeconstructorDecl(node);
        }
예제 #5
0
        public override void OutAStructDecl(AStructDecl node)
        {
            //Insert init in each constructor
            AThisLvalue    thisLvalue    = new AThisLvalue(new TThis("this"));
            ALvalueExp     thisExp       = new ALvalueExp(thisLvalue);
            APointerLvalue pointerLvalue = new APointerLvalue(new TStar("*"), thisExp);

            ANamedType namedType = new ANamedType(new TIdentifier(node.GetName().Text), null);

            data.StructTypeLinks[namedType] = node;
            data.LvalueTypes[thisLvalue]    =
                data.ExpTypes[thisExp]      = new APointerType(new TStar("*"), namedType);
            data.LvalueTypes[pointerLvalue] = namedType;


            foreach (AConstructorDecl constructor in node.GetLocals().OfType <ADeclLocalDecl>().Select(decl => decl.GetDecl()).OfType <AConstructorDecl>())
            {
                AABlock block = new AABlock(new ArrayList(), new TRBrace("}"));
                MakeAssignments(block, namedType, pointerLvalue, false);

                ((AABlock)constructor.GetBlock()).GetStatements().Insert(0, new ABlockStm(new TLBrace("{"), block));
            }

            base.OutAStructDecl(node);
        }
        public override void CaseAStructFieldLvalue(AStructFieldLvalue node)
        {
            //replace strField1
            //with <structFormal>.strField1
            AStructDecl  str = finalTrans.data.StructTypeLinks[(ANamedType)structFormal.GetType()];
            ALocalLvalue parameterRefference = new ALocalLvalue(new TIdentifier("tempName"));

            finalTrans.data.LocalLinks[parameterRefference]  = structFormal;
            finalTrans.data.LvalueTypes[parameterRefference] = structFormal.GetType();
            ALvalueExp exp = new ALvalueExp(parameterRefference);

            finalTrans.data.ExpTypes[exp] = structFormal.GetType();
            AStructLvalue replacer = new AStructLvalue(exp, new ADotDotType(new TDot(".")), node.GetName());

            foreach (AALocalDecl structField in finalTrans.data.StructFields[str])
            {
                if (structField.GetName().Text == replacer.GetName().Text)
                {
                    finalTrans.data.StructFieldLinks[replacer] = structField;
                    finalTrans.data.LvalueTypes[replacer]      = structField.GetType();
                    break;
                }
            }
            foreach (APropertyDecl property in finalTrans.data.StructProperties[str])
            {
                if (property.GetName().Text == replacer.GetName().Text)
                {
                    finalTrans.data.StructPropertyLinks[replacer] = property;
                    finalTrans.data.LvalueTypes[replacer]         = property.GetType();
                    break;
                }
            }
            node.ReplaceBy(replacer);
        }
예제 #7
0
        public void Join(LibraryData other)
        {
            int count = Methods.Count;

            foreach (AMethodDecl method in other.Methods)
            {
                bool add = true;
                for (int i = 0; i < count; i++)
                {
                    if (Util.GetMethodSignature(Methods[i]) != Util.GetMethodSignature(method))
                    {
                        add = false;
                        break;
                    }
                }
                if (add)
                {
                    Methods.Add(method);
                }
            }

            count = Fields.Count;
            foreach (AFieldDecl field in other.Fields)
            {
                bool add = true;
                for (int i = 0; i < count; i++)
                {
                    if (Fields[i].GetName().Text != field.GetName().Text)
                    {
                        add = false;
                        break;
                    }
                }
                if (add)
                {
                    Fields.Add(field);
                }
            }

            count = Structs.Count;
            for (int j = 0; j < other.Structs.Count; j++)
            {
                bool        add = true;
                AStructDecl str = other.Structs[j];
                for (int i = 0; i < count; i++)
                {
                    if (Structs[i].GetName().Text != str.GetName().Text)
                    {
                        add = false;
                        break;
                    }
                }
                if (add)
                {
                    Structs.Add(str);
                    StructMethods.Add(str, other.StructMethods[str]);
                    StructFields.Add(str, other.StructFields[str]);
                }
            }
        }
예제 #8
0
        public override void OutADeconstructorDecl(ADeconstructorDecl node)
        {
            AStructDecl parentStruct = Util.GetAncestor <AStructDecl>(node);

            if (parentStruct != null)
            {
                if (data.StructDeconstructor.ContainsKey(parentStruct) && data.StructDeconstructor[parentStruct] != node)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(),
                                                         LocRM.GetString("ErrorText13") +
                                                         Util.GetTypeName(parentStruct) + ".", false,
                                                         new[]
                    {
                        new ErrorCollection.Error(
                            data.StructDeconstructor[parentStruct].GetName(),
                            LocRM.GetString("ErrorText15"))
                    }));
                }

                data.StructDeconstructor[parentStruct] = node;
                if (parentStruct.GetName().Text != node.GetName().Text)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile,
                                                         LocRM.GetString("ErrorText16")));
                }
            }
            base.OutADeconstructorDecl(node);
        }
 public override void OutAStructDecl(AStructDecl node)
 {
     if (node.GetClassToken() != null && node.GetIntDim() == null)
     {
         node.Parent().RemoveChild(node);
     }
     base.OutAStructDecl(node);
 }
예제 #10
0
 public override void InANamedType(ANamedType node)
 {
     if (!node.IsPrimitive())// !GalaxyKeywords.Primitives.words.Any(word => word == node.GetName().Text))
     {
         AStructDecl decl = finalTrans.data.StructTypeLinks[node];
         AddDepency(Util.GetAncestor <AASourceFile>(node), Util.GetAncestor <AASourceFile>(decl));
     }
 }
예제 #11
0
 public StructDecl(AStructDecl decl)
 {
     Decl = decl;
     if (Name.StartsWith("_"))
     {
         Name = "u" + Name;
     }
 }
예제 #12
0
        public override void CaseAALocalDecl(AALocalDecl node)
        {
            //It wont enter methods
            //Repeated fields in structs are syntax errors
            AStructDecl str = Util.GetAncestor <AStructDecl>(node);

            StructFields[str].Add(node);
            node.Parent().RemoveChild(node);
        }
예제 #13
0
            public static void Parse(AStructDecl str, AStructDecl clone, List <PType> types, SharedData data)
            {
                FixGenericLinks fixer = new FixGenericLinks(clone, types, data)
                {
                    original = str, clone = clone
                };

                str.Apply(fixer);
            }
예제 #14
0
        public override void OutAStructDecl(AStructDecl node)
        {
            if (node.GetGenericVars().Count > 0 && !Refferences.ContainsKey(node))
            {
                Refferences[node] = new List <AGenericType>();
            }

            base.OutAStructDecl(node);
        }
예제 #15
0
 public override void CaseAStructDecl(AStructDecl node)
 {
     Write("struct " + node.GetName().Text + "\n{\n");
     foreach (AALocalDecl local in node.GetLocals().OfType <AALocalDecl>())
     {
         local.Apply(this);
         Write(";\n");
     }
     Write("};\n");
 }
예제 #16
0
        public override void InAStructDecl(AStructDecl node)
        {
            data.Structs.Add(new SharedData.DeclItem <AStructDecl>(currentSourceFile, node));
            data.StructMethods.Add(node, new List <AMethodDecl>());
            data.StructFields.Add(node, new List <AALocalDecl>());
            data.StructConstructors.Add(node, new List <AConstructorDecl>());
            data.StructProperties.Add(node, new List <APropertyDecl>());

            base.InAStructDecl(node);
        }
예제 #17
0
 public override void CaseAStructDecl(AStructDecl node)
 {
     if (node.GetLocals().Count == 0)
     {
         node.Parent().RemoveChild(node);
     }
     else
     {
         base.CaseAStructDecl(node);
     }
 }
예제 #18
0
 public override void CaseAStructDecl(AStructDecl node)
 {
     if (Structs.Any(structDecl => structDecl.GetName().Text == node.GetName().Text))
     {
         return;
     }
     Structs.Add(node);
     StructMethods.Add(node, new List <AMethodDecl>());
     StructFields.Add(node, new List <AALocalDecl>());
     base.CaseAStructDecl(node);
     node.Parent().RemoveChild(node);
 }
 public override void CaseANamedType(ANamedType node)
 {
     if (processStructs)
     {
         AStructDecl structDecl = finalTrans.data.StructTypeLinks.ContainsKey(node)
                                      ? finalTrans.data.StructTypeLinks[node]
                                      : null;
         if (structDecl != null && !usedStructs.Contains(structDecl))
         {
             usedStructs.Add(structDecl);
         }
     }
     base.CaseANamedType(node);
 }
예제 #20
0
        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);
        }
예제 #21
0
        //Convert struct variables to a collection of local variables
        public override void CaseAALocalDecl(AALocalDecl node)
        {
            if (node.GetType() is ANamedType && data.StructTypeLinks.ContainsKey((ANamedType)node.GetType()) && Util.HasAncestor <PStm>(node))
            {
                //Can not have init - it would be bulk copy
                AStructDecl str = data.StructTypeLinks[(ANamedType)node.GetType()];
                Dictionary <AALocalDecl, AALocalDecl> variableMap = new Dictionary <AALocalDecl, AALocalDecl>();
                PStm    pStm   = (PStm)node.Parent();
                AABlock pBlock = (AABlock)pStm.Parent();
                foreach (AALocalDecl structLocal in str.GetLocals())
                {
                    AALocalDecl replacementLocal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                                   Util.MakeClone(structLocal.GetType(), data),
                                                                   new TIdentifier(node.GetName().Text + "_" +
                                                                                   structLocal.GetName().Text), null);
                    pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), new ALocalDeclStm(new TSemicolon(";"), replacementLocal));


                    AALocalDecl baseLocal = structLocal;
                    if (data.EnheritanceLocalMap.ContainsKey(baseLocal))
                    {
                        baseLocal = data.EnheritanceLocalMap[baseLocal];
                    }
                    List <AALocalDecl> localsToAdd = new List <AALocalDecl>();
                    localsToAdd.AddRange(data.EnheritanceLocalMap.Where(pair => pair.Value == baseLocal).Select(pair => pair.Key));
                    localsToAdd.Add(baseLocal);
                    foreach (AALocalDecl localDecl in localsToAdd)
                    {
                        variableMap[localDecl] = replacementLocal;
                    }
                }
                List <ALocalLvalue> uses = new List <ALocalLvalue>();
                uses.AddRange(data.LocalLinks.Where(k => k.Value == node && Util.GetAncestor <AAProgram>(k.Key) != null).Select(k => k.Key));
                foreach (ALocalLvalue lvalue in uses)
                {
                    AStructLvalue structLocalRef = (AStructLvalue)lvalue.Parent().Parent();

                    AALocalDecl  replacementLocal  = variableMap[data.StructFieldLinks[structLocalRef]];
                    ALocalLvalue replacementLvalue = new ALocalLvalue(new TIdentifier(replacementLocal.GetName().Text));
                    data.LocalLinks[replacementLvalue]  = replacementLocal;
                    data.LvalueTypes[replacementLvalue] = replacementLocal.GetType();
                    structLocalRef.ReplaceBy(replacementLvalue);
                }
                foreach (AALocalDecl replacementLocal in variableMap.Select(k => k.Value))
                {
                    replacementLocal.Apply(this);
                }
            }
            base.CaseAALocalDecl(node);
        }
예제 #22
0
 public override void OutAStructDecl(AStructDecl node)
 {
     //Insert parameterless constructor
     if (
         !node.GetLocals().OfType <ADeclLocalDecl>().Select(localDecl => localDecl.GetDecl()).OfType
         <AConstructorDecl>().Any(constructor => constructor.GetFormals().Count == 0))
     {
         node.GetLocals().Add(
             new ADeclLocalDecl(new AConstructorDecl(new APublicVisibilityModifier(),
                                                     new TIdentifier(node.GetName().Text), new ArrayList(),
                                                     new ArrayList(),
                                                     new AABlock(new ArrayList(), new TRBrace("}")))));
     }
 }
예제 #23
0
        private void MakeAssignments(AABlock block, PType type, PLvalue leftSide, bool onEnhritedFields)
        {
            if (type is ANamedType && data.StructTypeLinks.ContainsKey((ANamedType)type))
            {
                AStructDecl str = data.StructTypeLinks[(ANamedType)type];
                foreach (AALocalDecl field in str.GetLocals().OfType <AALocalDecl>())
                {
                    if (!onEnhritedFields && data.EnheritanceLocalMap.ContainsKey(field))
                    {
                        continue;
                    }

                    ALvalueExp lvalueExp = new ALvalueExp(Util.MakeClone(leftSide, data));
                    data.ExpTypes[lvalueExp] = data.LvalueTypes[leftSide];
                    AStructLvalue newLeftSide = new AStructLvalue(lvalueExp, new ADotDotType(new TDot(".")), new TIdentifier(field.GetName().Text));
                    data.StructFieldLinks[newLeftSide] = field;
                    data.LvalueTypes[newLeftSide]      = field.GetType();

                    if (field.GetInit() != null)
                    {
                        AAssignmentExp assignment = new AAssignmentExp(new TAssign("="), newLeftSide,
                                                                       Util.MakeClone(field.GetInit(), data));
                        data.ExpTypes[assignment] = data.LvalueTypes[newLeftSide];

                        block.GetStatements().Add(new AExpStm(new TSemicolon(";"),
                                                              assignment));
                    }
                    else
                    {
                        MakeAssignments(block, field.GetType(), newLeftSide, onEnhritedFields);
                    }
                }
            }
            else if (type is AArrayTempType)
            {
                AArrayTempType aType = (AArrayTempType)type;
                for (int i = 0; i < int.Parse(aType.GetIntDim().Text); i++)
                {
                    AIntConstExp index = new AIntConstExp(new TIntegerLiteral(i.ToString()));
                    data.ExpTypes[index] = new ANamedType(new TIdentifier("int"), null);

                    ALvalueExp lvalueExp = new ALvalueExp(Util.MakeClone(leftSide, data));
                    data.ExpTypes[lvalueExp] = data.LvalueTypes[leftSide];
                    AArrayLvalue newLeftSide = new AArrayLvalue(new TLBracket("["), lvalueExp, index);
                    data.LvalueTypes[newLeftSide] = aType.GetType();

                    MakeAssignments(block, aType.GetType(), newLeftSide, onEnhritedFields);
                }
            }
        }
예제 #24
0
        public override void OutAConstructorDecl(AConstructorDecl node)
        {
            AStructDecl parentStruct = Util.GetAncestor <AStructDecl>(node);

            if (parentStruct != null)
            {
                data.StructConstructors[parentStruct].Add(node);
                if (parentStruct.GetName().Text != node.GetName().Text)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile,
                                                         "Constructors must have same name as the enclosing struct."));
                }
            }
            base.OutAConstructorDecl(node);
        }
예제 #25
0
        public override void OutAConstructorDecl(AConstructorDecl node)
        {
            AStructDecl parentStruct = Util.GetAncestor <AStructDecl>(node);

            if (parentStruct != null)
            {
                data.StructConstructors[parentStruct].Add(node);
                if (parentStruct.GetName().Text != node.GetName().Text)
                {
                    errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile,
                                                         LocRM.GetString("ErrorText12")));
                }
            }
            base.OutAConstructorDecl(node);
        }
예제 #26
0
        public override void OutAGenericType(AGenericType node)
        {
            if (!(node.GetBase() is ANamedType))
            {
                errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText44")));
                return;
            }
            ANamedType Base = (ANamedType)node.GetBase();

            if (!data.StructTypeLinks.ContainsKey(Base))
            {
                errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText44")));
                return;
            }
            AStructDecl str = data.StructTypeLinks[Base];

            if (str.GetGenericVars().Count != node.GetGenericTypes().Count)
            {
                errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText45"),
                                                     false, new ErrorCollection.Error(str.GetName(), LocRM.GetString("ErrorText46") + Util.GetTypeName(str))));
                return;
            }
            LookForGenericVar finder = new LookForGenericVar();

            foreach (PType genericType in node.GetGenericTypes())
            {
                genericType.Apply(finder);
                if (finder.ContainsGenericVar || finder.ContainsNestedGenerics)
                {
                    //if (finder.ContainsGenericVar)
                    structsWithGenerics.Add(Util.GetAncestor <AStructDecl>(node));
                    if (finder.ContainsNestedGenerics)
                    {
                        if (!Util.HasAncestor <AStructDecl>(node) || Util.GetAncestor <AStructDecl>(node).GetGenericVars().Count == 0)
                        {
                            needAnotherPass = true;
                        }
                    }
                    return;
                }
            }
            if (!Refferences.ContainsKey(str))
            {
                Refferences[str] = new List <AGenericType>();
            }
            Refferences[str].Add(node);
            base.OutAGenericType(node);
        }
예제 #27
0
 public static bool Extends(AStructDecl baseType, AStructDecl cType, SharedData data)
 {
     if (cType == null)
     {
         return(false);
     }
     if (baseType == cType)
     {
         return(true);
     }
     if (cType.GetBase() == null)
     {
         return(false);
     }
     return(Extends(baseType, data.StructTypeLinks[(ANamedType)cType.GetBase()], data));
 }
예제 #28
0
        public override void OutAPropertyDecl(APropertyDecl node)
        {
            AStructDecl     pStruct     = Util.GetAncestor <AStructDecl>(node);
            AEnrichmentDecl pEnrichment = Util.GetAncestor <AEnrichmentDecl>(node);

            if (pStruct != null)
            {
                data.StructProperties[pStruct].Add(node);
            }
            else if (pEnrichment == null)
            {
                data.Properties.Add(new SharedData.DeclItem <APropertyDecl>(currentSourceFile, node));
            }

            base.OutAPropertyDecl(node);
        }
예제 #29
0
        public override void OutAEnumDecl(AEnumDecl node)
        {
            AStructDecl replacer = new AStructDecl(node.GetVisibilityModifier(), null, null, null, node.GetEndToken(),
                                                   node.GetName(), new ArrayList(), null, new ArrayList());



            int intVal = 0;

            //int min = int.MaxValue;
            //int max = int.MinValue;
            //List<TIdentifier> types = new List<TIdentifier>();
            foreach (AAEnumLocal value in node.GetValues())
            {
                AIntConstExp intConst;
                if (value.GetValue() != null)
                {
                    intConst = (AIntConstExp)value.GetValue();
                    intVal   = int.Parse(intConst.GetIntegerLiteral().Text) + 1;
                }
                else
                {
                    intConst = new AIntConstExp(new TIntegerLiteral(intVal.ToString(), value.GetName().Line, value.GetName().Pos));
                    intVal++;
                }
                //    min = Math.Min(intVal - 1, min);
                //    max = Math.Max(intVal - 1, max);
                TIdentifier typeIdentifier = new TIdentifier(replacer.GetName().Text, value.GetName().Line, value.GetName().Pos);
                // types.Add(typeIdentifier);
                AALocalDecl localDecl = new AALocalDecl(new APublicVisibilityModifier(),
                                                        new TStatic("static", value.GetName().Line, value.GetName().Pos),
                                                        null, null,
                                                        new TConst("const", value.GetName().Line, value.GetName().Pos),
                                                        new ANamedType(typeIdentifier, null), value.GetName(), intConst);
                replacer.GetLocals().Add(localDecl);
            }

            /*   if (min < 0 || max > 255)
             *     foreach (TIdentifier identifier in types)
             *     {
             *         identifier.Text = "int";
             *     }*/
            node.ReplaceBy(replacer);

            replacer.Apply(this);
            replacer.GetName().Text = "enum " + replacer.GetName().Text;
        }
예제 #30
0
 public override void CaseAStructDecl(AStructDecl node)
 {
     if (node.GetDimention() != null)
     {
         bool prevFolding = folding;
         int  prevValue   = value;
         bool wasANewExp  = isANewExp;
         folding = true;
         value   = 0;
         node.GetDimention().Apply(this);
         node.SetIntDim(new TIntegerLiteral(value.ToString()));
         folding   = prevFolding;
         value     = prevValue;
         isANewExp = wasANewExp;
     }
     base.CaseAStructDecl(node);
 }