Esempio n. 1
0
        private void Translate()
        {
            codeBase = new CodeBase(GetLanguage());
            codeBase.Types.LibrariesFolder = Libraries;
            codeBase.Types.HelpersFolder   = HelperDirectory;

            codeBase.Mappings = new Mappings(Mappings);

            parentVisitor = new ParentVisitor();

            typesVisitor          = new TypesVisitor();
            typesVisitor.CodeBase = codeBase;

            projectTypeReferenceCorrector          = new TypeReferenceCorrector(true);
            projectTypeReferenceCorrector.CodeBase = codeBase;

            LoadFiles();

            codeBase.Types.Visitors.Add(parentVisitor);

            BeforeParse();
            progress.SetCount("Parsing", sourceFileCount);
            ParseAndPreVisit();

            BeforeTransformation();

            InheritedTypesExcludeTransformer inheritedTypesExcludeTransformer = new InheritedTypesExcludeTransformer();

            inheritedTypesExcludeTransformer.ParentTypes = baseTypeToExcludeMethod;
            CallVisitor(inheritedTypesExcludeTransformer, null);

            IDictionary visitors = GetVisitors(typeof(AbstractAstVisitor));

            visitors.Add(typeof(InheritorsVisitor).FullName, typeof(InheritorsVisitor));
            IDictionary transformers = GetVisitors(typeof(AbstractAstTransformer));

            transformers.Add(typeof(RenameRepeatedVariableTransformer).Name, typeof(RenameRepeatedVariableTransformer));
            progress.SetCount("Transformation", (visitors.Count + transformers.Count) * sourceFileCount);
            CallVisitors(visitors, "Transformation");
            CallVisitors(transformers, "Transformation");
            AfterTransformation();
            Diagnostics.Set("Phase", "Transformation");
            progress.SetCount("References", sourceFileCount);
            CallVisitor(typeof(ReferenceTransformer), "References");

            progress.SetCount("Mapping", 2 * sourceFileCount);
            CallVisitor(typeof(MemberMapper), "Mapping");
            CallVisitor(typeof(TypeMapper), "Mapping");

            BeforeRefactoring();

            int count = 6;

            if (Mode == "IKVM")
            {
                count++;
            }
            if (Namespace != null)
            {
                count++;
            }
            progress.SetCount("Refactoring", sourceFileCount * count);

            Refactor();

            CallVisitor(typeof(RemoveEmptyBlocksTransformer), null);

            OptimizeUsings();

            GenerateCode();

            SaveFiles();
        }