//Metodi statici public static FunctionSection ExtractSection(string RawCode, int LineNumber, LogManager lm) { Function f = Function.GetFunctionByCode(RawCode, lm, LineNumber); RawCode = CodeElaborator.RemoveFunctionSign(RawCode, lm); CodeLineCollection cc = CodeLineCollection.ExtractCollection(RawCode, LineNumber, lm); return(new FunctionSection(f, cc)); }
//Metodi statici public static SectionCollection ExtractCollection(string RawCode, LogManager lm) { SectionCollection sc = new SectionCollection(); CodeIndex[] ci = CodeElaborator.FindFunctionPosition(RawCode, lm); for (int i = 0; i < ci.Length; i++) { sc.Add(FunctionSection.ExtractSection(RawCode.Substring(ci[i].Index, ci[i].Lenght), RawCode.Substring(0, ci[i].Index).Split('\n').Length, lm)); } return(sc); }
//Metodo statico /// <summary> /// Crea un immagine del codice con tuttte le sezioni ripulite ed esplicitate /// </summary> /// <param name="RawCode">Codice da analizzare</param> /// <param name="PackageAdd">Pacchetti aggiunti nel sistema</param> /// <param name="Type">Tipo di codice</param> /// <param name="lm">Gestore di messaggi</param> /// <returns>Immagine del codice</returns> public static CodeImage CreateCodeImage(string RawCode, PackageCollection PackageAdd, CodeType Type, LogManager lm) { //Pachet name string[] packageName; SectionCollection sc; VariableCollection vc; //Costanti PackageCollection pc; //Pacchetti inclusi bool exactType = false; string PackName = null; //Pulizia RawCode = CodeCleaner.TextReturnUnified(RawCode, lm); vc = CodeElaborator.ExtractConstant(ref RawCode, lm); RawCode = CodeCleaner.CommentDelete(RawCode, lm); RawCode = CodeCleaner.RemoveSynonyms(RawCode, lm); RawCode = CodeCleaner.StartLineUnified(RawCode, 4, lm); RawCode = CodeCleaner.ReduceWitheSpaces(RawCode, lm); //Analisi Include packageName = CodeElaborator.IncludeFinder(RawCode, lm); RawCode = CodeElaborator.RemoveInclude(RawCode, lm); //Tipo exactType = CodeElaborator.CheckIfCorrectType(RawCode, Type, lm); if (!exactType) { lm.Add("The code is wrong for the current type of compilation"); } //Estrazione codice sc = SectionCollection.ExtractCollection(RawCode, lm); //Selezione pacchetti pc = PackageAdd.IncludedPackage(packageName, lm); //Creazione aggiunta per pacchetti if (Type == CodeType.Package) { PackName = CodeElaborator.PackegeNameExtractor(RawCode, lm); RawCode = CodeElaborator.RemovePackageName(RawCode, lm); } return((Type == CodeType.Program) ? new CodeImage(sc, pc, vc, Type) : new CodeImage(sc, pc, vc, Type, PackName)); }