/// <summary> /// Crawls the StarCraft 2 MPQs to grab the *.galaxy files inside. These files are parsed for (native) functions and constants. /// </summary> /// <returns>The functions and constants of StarCraft 2 in form of a LibraryData</returns> LibraryData loadLibraries() { // parse the files for functions and constants CrawlAndParseMpqs(); // convert the functions and constants to a LibraryData format LibraryData lib = new LibraryData(); // create the methods with from crawled info foreach (ParsedFunction function in functions) { AMethodDecl method = new AMethodDecl(); if (function.IsNative) { method.SetNative(new TNative("native")); } method.SetName(new TIdentifier(function.Name)); method.SetReturnType(new ANamedType(new TIdentifier(function.ReturnType), null)); // add function parameter foreach (var parameter in function.Parameters) { method.GetFormals().Add(new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, new ANamedType(new TIdentifier(parameter.Item1), null), new TIdentifier(parameter.Item2), null)); } lib.Methods.Add(method); } // create the constants from the crawled info foreach (ParsedConstant constant in constants) { AFieldDecl field = new AFieldDecl(new APublicVisibilityModifier(), null, new TConst("const"), new ANamedType(new TIdentifier(constant.Type), null), new TIdentifier(constant.Name), new AStringConstExp(new TStringLiteral(constant.Value))); lib.Fields.Add(field); } functions.Clear(); constants.Clear(); return(lib); }