コード例 #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();
        }
コード例 #2
0
        public void TestFixtureSetUp()
        {
            CodeBase = new CodeBase(SupportedLanguage.Java);
            AstUtil = new AstUtil();

            CodeBase.Types.LibrariesFolder = @"../../../Translator/Libraries";
            CodeBase.Mappings = new Mappings();
            CodeBase.Mappings.Add("String", new TypeMapping("string"));
        }
コード例 #3
0
        public void TestFixtureSetup()
        {
            CodeBase = new CodeBase(SupportedLanguage.Java);
            CodeBase.Types.LibrariesFolder = @"../../../Translator/Libraries";

            AstUtil = new AstUtil();

            TypeResolver = new TypeResolver();
            TypeResolver.CodeBase = CodeBase;
            TypeResolver.AstUtil = AstUtil;
        }
コード例 #4
0
ファイル: Translator.cs プロジェクト: sourcewarehouse/janett
        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();
        }