Пример #1
0
 public static void MakeReservedNames
     (AdaDeclarations Declarations)
 {
     for (int j = 0; j < vs_lexer_pkg.tokensN.Length; j++)
     {
         string tName = TokenName(j).ToLower();
         Declarations.addDeclaration(tName.Substring(0, tName.Length - 2));
         if (tName == "xor_t")
         {
             break;               // xor_t is the last reserved keyword
         }
     }
 }
Пример #2
0
        private static void Lb_Insert(mcc.gnat_tools.xref.entity the_entity)
        {
            char[] Entity_Name = new char[the_entity.name_length];
            for (int j = 0; j < Entity_Name.Length; j++)
            {
                Entity_Name[j] = (char)the_entity.name[j];
            }

            if (new String(Entity_Name) != lastInserted)
            {
                lastInserted = new String(Entity_Name);
                Remember_Declarations.addDeclaration(lastInserted);
            }
        }
Пример #3
0
        public static void MakeNames
            (string Buffer, int Buffer_Last, AdaDeclarations Declarations)
        {
            int CurrentLoc = 0;

            vs_lexer.token_record Token;
            string Previous_Type = "DOT_T";

            while (CurrentLoc < Buffer_Last)
            {
                Token = vs_lexer_pkg.get_token(Buffer.ToCharArray(), 0, Buffer_Last, CurrentLoc);
                if ((TokenName(Token.kind) == "NAME_T") && (Previous_Type != "DOT_T"))
                {
                    string bob = Buffer.Substring(Token.start_index, Token.end_index - Token.start_index + 1);
                    Declarations.addDeclaration(bob);
                }
                Previous_Type = TokenName(Token.kind);
                CurrentLoc    = Token.end_index + 1;
            }
        }
Пример #4
0
 private static bool IsBasicName(string Name, AdaDeclarations Declarations)
 {
     if (Name.ToLower() == "ada")
     {
         Declarations.addDeclaration("Calendar");
         Declarations.addDeclaration("Characters");
         Declarations.addDeclaration("Command_Line");
         Declarations.addDeclaration("Complex_Text_IO");
         Declarations.addDeclaration("Containers");
         Declarations.addDeclaration("Decimal");
         Declarations.addDeclaration("Direct_IO");
         Declarations.addDeclaration("Directories");
         Declarations.addDeclaration("Environment_Variables");
         Declarations.addDeclaration("Exceptions");
         Declarations.addDeclaration("Finalization");
         Declarations.addDeclaration("Float_Text_IO");
         Declarations.addDeclaration("Float_Wide_Text_IO");
         Declarations.addDeclaration("Integer_Text_IO");
         Declarations.addDeclaration("Integer_Wide_Text_IO");
         Declarations.addDeclaration("Long_Float_Text_IO");
         Declarations.addDeclaration("Long_Float_Wide_Text_IO");
         Declarations.addDeclaration("Real_Time");
         Declarations.addDeclaration("Sequential_IO");
         Declarations.addDeclaration("Strings");
         Declarations.addDeclaration("Tags");
         Declarations.addDeclaration("Text_IO");
         Declarations.addDeclaration("Unchecked_Conversion");
         Declarations.addDeclaration("Unchecked_Deallocation");
         Declarations.addDeclaration("Wide_Text_IO");
         Declarations.addDeclaration("Wide_Characters");
         return(true);
     }
     else if (Name.ToLower() == "ada.characters")
     {
         Declarations.addDeclaration("Conversions");
         Declarations.addDeclaration("Handling");
         Declarations.addDeclaration("Latin_1");
         Declarations.addDeclaration("Wide_Latin_1");
         return(true);
     }
     else if (Name.ToLower() == "ada.containers")
     {
         Declarations.addDeclaration("Doubly_Linked_Lists");
         Declarations.addDeclaration("Hashed_Maps");
         Declarations.addDeclaration("Hashed_Sets");
         Declarations.addDeclaration("Hash_Tables");
         Declarations.addDeclaration("Indefinite_Doubly_Linked_Lists");
         Declarations.addDeclaration("Indefinite_Hashed_Maps");
         Declarations.addDeclaration("Indefinite_Hashed_Sets");
         Declarations.addDeclaration("Indefinite_Ordered_Maps");
         Declarations.addDeclaration("Indefinite_Ordered_Multisets");
         Declarations.addDeclaration("Indefinite_Ordered_Sets");
         Declarations.addDeclaration("Ordered_Maps");
         Declarations.addDeclaration("Ordered_Multisets");
         Declarations.addDeclaration("Ordered_Sets");
         Declarations.addDeclaration("Red_Black_Trees");
         Declarations.addDeclaration("Prime_Numbers");
         Declarations.addDeclaration("Vectors");
         return(true);
     }
     else if (Name.ToLower() == "ada.numerics")
     {
         Declarations.addDeclaration("Complex_Elementary_Functions");
         Declarations.addDeclaration("Complex_Types");
         Declarations.addDeclaration("Discrete_Random");
         Declarations.addDeclaration("Elementary_Functions");
         Declarations.addDeclaration("Float_Random");
         Declarations.addDeclaration("Long_Complex_Elementary_Functions");
         Declarations.addDeclaration("Long_Complex_Types");
         Declarations.addDeclaration("Long_Elementary_Functions");
         return(true);
     }
     else if (Name.ToLower() == "ada.strings")
     {
         Declarations.addDeclaration("Bounded");
         Declarations.addDeclaration("Fixed");
         Declarations.addDeclaration("Maps");
         Declarations.addDeclaration("Superbounded");
         Declarations.addDeclaration("Unbounded");
         Declarations.addDeclaration("Wide_Bounded");
         Declarations.addDeclaration("Wide_Fixed");
         Declarations.addDeclaration("Wide_Maps");
         Declarations.addDeclaration("Wide_Superbounded");
         Declarations.addDeclaration("Wide_Unbsounded");
         return(true);
     }
     else if (Name.ToLower() == "ada.strings.unbounded")
     {
         Declarations.addDeclaration("Text_IO");
         Declarations.addDeclaration("Unbounded_String");
         return(true);
     }
     else if (Name.ToLower() == "ada.text_io")
     {
         Declarations.addDeclaration("Create");
         Declarations.addDeclaration("Enumeration_IO");
         Declarations.addDeclaration("Get");
         Declarations.addDeclaration("Get_Line");
         Declarations.addDeclaration("Open");
         Declarations.addDeclaration("Put");
         Declarations.addDeclaration("Put_Line");
         Declarations.addDeclaration("Skip_Line");
         return(true);
     }
     else if (Name.ToLower() == "ada.wide_characters")
     {
         Declarations.addDeclaration("Unicode");
         return(true);
     }
     return(false);
 }
Пример #5
0
        public static void MakeDeclarations
            (string TheFileName,
            string Buffer,
            string Line,
            int Column,
            AdaDeclarations Declarations)
        {
            int    Start    = 0;
            int    End      = Column;
            string FileName = TheFileName.ToLower();

            for (int j = Column; j >= 0; j--)
            {
                if (!Char.IsLetterOrDigit(Line[j]) && Line[j] != '.' && Line[j] != '_')
                {
                    Start = j + 1;
                    break;
                }
            }
            for (int j = Column; j > Start; j--)
            {
                if (Line[j] == '.')
                {
                    End = j - 1;
                    break;
                }
            }

            // maybe we've got something like 3 .
            if (Start > End)
            {
                return;
            }

            string Prefix;
            string FoundFilename;
            string FoundDirectory;

            char[] tmp = new char[End - Start + 1];
            for (int j = Start; j <= End; j++)
            {
                tmp[j - Start] = (char)Line[j];
            }
            Prefix = new String(tmp).ToLower();
            mcc.gnat_tools.xref.xref_file_list_package.node Xrefs = new mcc.gnat_tools.xref.xref_file_list_package.node();

            if (IsBasicName(Prefix, Declarations))
            {
                return;
            }

            {
                string tmpFilename = Dashify(Prefix);
                string FullPath    = DefaultLocation.Find_File(tmpFilename, "", System.IO.Directory.GetParent(FileName).FullName, true);
                if (FullPath.Length == 0)
                {
                    tmpFilename = Krunch(tmpFilename);
                    FullPath    = DefaultLocation.Find_File(tmpFilename, "", System.IO.Directory.GetParent(FileName).FullName, true);
                }
                if (FullPath.Length == 0)
                {
                    return;
                }

                FoundFilename  = tmpFilename + ".ads";
                FoundDirectory = DefaultLocation.Find_File(tmpFilename, "", System.IO.Directory.GetParent(FileName).FullName, false);
                FoundDirectory = System.IO.Directory.GetParent(FoundDirectory).FullName;

                mgnat.adalib.Acc Xrefs_Acc = new mgnat.adalib.Acc();
                byte[]           bFileName = new byte[FullPath.Length];
                for (int j = 0; j < FullPath.Length; j++)
                {
                    bFileName[j] = (byte)FullPath[j];
                }
                Xrefs_Acc.all = null;

                mcc.gnat_tools.xref_pkg.read_ali(bFileName, 0, bFileName.GetUpperBound(0), Xrefs_Acc);

                if (Xrefs_Acc.all != null)
                {
                    bFileName = new byte[FoundFilename.Length];
                    for (int j = 0; j < FoundFilename.Length; j++)
                    {
                        bFileName[j] = (byte)FoundFilename[j];
                    }
                    Xrefs                 = (mcc.gnat_tools.xref.xref_file_list_package.node)Xrefs_Acc.all;
                    lastInserted          = "";
                    Remember_Declarations = Declarations;

                    mcc.gnat_tools.xref_pkg.enumerate_public_entities
                        (bFileName, 0, bFileName.Length - 1, Xrefs, new mcc.gnat_tools.xref.public_callback_type(Lb_Insert));
                }
            }
            if (FoundDirectory.Length != 0)
            {
                string[] results = System.IO.Directory.GetFiles(FoundDirectory, Dashify(Prefix) + "-" + "*.ad*");
                for (int j = 0; j < results.Length; j++)
                {
                    string thisOne = System.IO.Path.GetFileNameWithoutExtension(results[j]);
                    string answer  = thisOne.Substring(Prefix.Length, thisOne.Length - Prefix.Length);
                    if (answer.IndexOf('-') == -1)
                    {
                        Declarations.addDeclaration(answer);
                    }
                }
            }
        }