private void MergeWith(GameObjectResolver otherVisitor) { _functionDefinitions.MergeWith(otherVisitor._functionDefinitions); foreach (var filePath in otherVisitor.AlreadyLoadedFiles) //do not load the same files twice... { AlreadyLoadedFiles.Add(filePath); } _functionReferenceGraph.MergeWith(otherVisitor._functionReferenceGraph); _typeInheritanceGraph.MergeWith(otherVisitor._typeInheritanceGraph); _delegateDefinitions.MergeWith(otherVisitor._delegateDefinitions); _objectDefinitions.MergeWith(otherVisitor._objectDefinitions); _objectTypeDefinitions.MergeWith(otherVisitor._objectTypeDefinitions); //TODO: add here other stuff that the visitor parses }
private void ProcessIncludedLibraryAndMerge(string library) { if (library == null) { return; } var libraryPath = Path.Combine(QuestCoreLibrariesPath, library); if (File.Exists(libraryPath) == false) { //try languages folder //try current folder var alternativeLibraryPath = Path.Combine(QuestLanguageLibrariesPath, library); if (File.Exists(alternativeLibraryPath)) { return; //do not process language files - not relevant } alternativeLibraryPath = Path.Combine(_filePath, library); if (File.Exists(alternativeLibraryPath) == false) { throw new FileNotFoundException( $"Couldn't find referenced library '{library}'. Tried looking in paths '{libraryPath}' and '{alternativeLibraryPath}'."); } libraryPath = alternativeLibraryPath; } _recursionCount++; _currentFile.Push(libraryPath); var includeLibraryResolver = new GameObjectResolver(libraryPath, AlreadyLoadedFiles); foreach (var reference in includeLibraryResolver.IncludeReferences) { //since we are single threaded, its ok to mutate static int this way ProcessIncludedLibraryAndMerge(reference); } MergeWith(includeLibraryResolver); _currentFile.Pop(); _recursionCount--; }