public string TranslateIff(IffFile file) { Context.Filename = CSTranslationContext.FormatName(file.Filename.Replace(".iff", "")); Context.ModuleName = Context.Filename + "Module"; Context.NamespaceName = "FSO.Scripts." + Context.Filename; Context.CurrentFile = file; var bhavs = file.List <BHAV>() ?? new List <BHAV>(); foreach (var bhav in bhavs) { Context.CurrentBHAV = bhav; var sbhav = new StructuredBHAV(bhav); sbhav.Analyse(Context); Context.BHAVInfo[bhav.ChunkID] = sbhav; } foreach (var bhav in Context.BHAVInfo.Values) { PropagateYieldFromCalls(bhav); } foreach (var bhav in Context.BHAVInfo.Values) { foreach (var inst in bhav.Instructions.Values) { (inst.Translator as CSSubroutinePrimitive)?.InitInfo(Context); } } foreach (var bhav in Context.BHAVInfo.Values) { bhav.BuildStructure(); } foreach (var bhav in Context.BHAVInfo.Values) { Context.AllClasses.Add(TranslateBHAV(bhav)); } return(BuildCSFile()); }