/// <summary> /// Загрузка библиотеки /// </summary> public void LoadData(string LibraryPath) { if (IsLibraryCompiled == false) { compiler = new VHDL_LibraryCompiler(this, LibraryPath, LibraryConfigurationPath); compiler.Compile(); } parsedLibraries = LibraryInfo.LoadLibraries(logger, LibraryConfigurationPath); }
public void Compile() { libraryFiles = new List <LibraryFileInfo>(); compileQueue = new List <LibraryFileInfo>(); parsedLibraries = new List <LibraryInfo>(); foreach (string lib in LibraryPath) { AnalyzeFolder(lib); } SetDependencies(); CreateQueue(); CompileFiles(); LibraryInfo.SaveLibraries(LibraryConfigurationPath, parsedLibraries); }
/// <summary> /// Загрузка списка библиотек с XML файла /// </summary> /// <param name="path"></param> /// <returns></returns> public static List <LibraryInfo> LoadLibraries(Logger logger, string path) { logger.WriteLineFormat("Loading compiled libraries from file {0}", path); List <LibraryInfo> res = new List <LibraryInfo>(); XmlDocument _doc = new XmlDocument(); _doc.Load(path); XmlNodeList nodes = _doc.SelectNodes("/Libraries/Library"); foreach (XmlNode node in nodes) { string LibraryName = node.Attributes["LibraryName"].Value; LibraryInfo inf = new LibraryInfo(LibraryName); res.Add(inf); foreach (XmlNode package in node.ChildNodes) { string PackageName = package.Attributes["Name"].Value; string DeclarationPath = package.Attributes["DeclarationPath"].Value; string BodyPath = package.Attributes["BodyPath"].Value; string DeclarationLibPath = package.Attributes["DeclarationLibPath"].Value; string BodyLibPath = package.Attributes["BodyLibPath"].Value; PackageInfo pi = new PackageInfo(PackageName, LibraryName, DeclarationPath, BodyPath, DeclarationLibPath, BodyLibPath); inf.packages.Add(pi); logger.WriteLine("----------------------------------"); logger.WriteLineFormat("PackageName: {0}", PackageName); logger.WriteLineFormat("DeclarationPath: {0}", DeclarationPath); logger.WriteLineFormat("BodyPath: {0}", BodyPath); logger.WriteLineFormat("DeclarationLibPath: {0}", DeclarationLibPath); logger.WriteLineFormat("BodyLibPath: {0}", BodyLibPath); logger.WriteLine("----------------------------------"); } inf.UpdateLibraryScope(); } return(res); }
/// <summary> /// Скомпилироват библиотеку повторно /// </summary> public void RebuildData(string LibraryPath) { compiler = new VHDL_LibraryCompiler(this, LibraryPath, LibraryConfigurationPath); compiler.Compile(); parsedLibraries = LibraryInfo.LoadLibraries(logger, LibraryConfigurationPath); }
/// <summary> /// Компиляция файла /// </summary> /// <param name="file"></param> private void CompileFile(LibraryFileInfo file, VhdlParserSettings settings, RootDeclarativeRegion rootScope) { LibraryInfo currentLibrary = null; foreach (LibraryInfo inf in parsedLibraries) { if (inf.Name.EqualsIgnoreCase(file.LibraryName)) { currentLibrary = inf; break; } } if (currentLibrary == null) { currentLibrary = new LibraryInfo(file.LibraryName); parsedLibraries.Add(currentLibrary); rootScope.Libraries.Add(currentLibrary.LibraryScope); } try { Console.WriteLine("parsing file {0} ", file.Path); VhdlFile vhdfile = VhdlParserWrapper.parseFile(file.Path, settings, rootScope, currentLibrary.LibraryScope, libraryManager); foreach (LibraryUnit unit in vhdfile.Elements) { if (unit is PackageDeclaration) { PackageDeclaration pd = unit as PackageDeclaration; pd.Parent = null; bool foundPackage = false; foreach (PackageInfo inf in currentLibrary.Packages) { if (inf.Name.EqualsIdentifier(pd.Identifier)) { inf.DeclarationPath = file.Path; string path = FormCompilePath(file.Path, "decl"); inf.DeclarationLibPath = path; inf.Declaration = pd; foundPackage = true; break; } } if (foundPackage == false) { PackageInfo pi = new PackageInfo(pd.Identifier, currentLibrary.Name, file.Path); pi.DeclarationPath = file.Path; string path = FormCompilePath(file.Path, "decl"); pi.DeclarationLibPath = path; pi.BodyLibPath = path; pi.Declaration = pd; currentLibrary.Packages.Add(pi); } } if (unit is PackageBody) { PackageBody pb = unit as PackageBody; pb.Parent = null; bool foundPackage = false; foreach (PackageInfo inf in currentLibrary.Packages) { if (inf.Name.EqualsIdentifier(pb.Package.Identifier)) { inf.BodyPath = file.Path; string path = FormCompilePath(file.Path, "body"); inf.BodyLibPath = path; inf.Body = pb; foundPackage = true; break; } } if (foundPackage == false) { PackageInfo pi = new PackageInfo(pb.Package.Identifier, currentLibrary.Name, file.Path); pi.BodyPath = file.Path; string path = FormCompilePath(file.Path, "body"); pi.BodyLibPath = path; pi.Body = pb; currentLibrary.Packages.Add(pi); } } } } catch (Exception ex) { logger.WriteLineFormat("parsing {0} failed", file.Path); logger.WriteLine(ex.Message); logger.WriteLine(LoggerMessageVerbosity.Error, ex.Message); } }