public void GenerateIlCode(TACode code)
 {
     try
     {
         var trans = new TAcode2ILcodeTranslator();
         trans.Translate(code);
         _ilProgram = trans;
         GenerationCompleted(null, trans);
     }
     catch (Exception ex)
     {
         GenerationErrored(null, ex);
     }
 }
Beispiel #2
0
        public static void Main()
        {
            //TaCodeTest();
            //ASTTest();

            //Test Moving declarations
            //var Test = new DeclarationTest();
            //Test.DeclarationOptimizationTest();

            //Test subexpression tree
            //var sTest = new SubexprTest();
            //sTest.SubexpressionOptimizationTest();

            //APC
            //CFGReducibility_DominatorTree_PrettyPrinter_Demonstration();

            string fileName = @"..\..\sample.txt";

            astRoot = AST(fileName);
            if (astRoot == null)
            {
                return;
            }

            var tacodeVisitor = new TACodeVisitor();

            astRoot.Visit(tacodeVisitor);
            tacodeInstance = tacodeVisitor.Code;

            var allOpt = new AllOptimizations();

            tacodeInstance = allOpt.ApplyAllOptimizations(tacodeInstance);

            TAcode2ILcodeTranslator trans = new TAcode2ILcodeTranslator();

            Console.WriteLine(tacodeInstance.ToString());

            trans.Translate(tacodeInstance);
            var temp = trans.PrintCommands();

            trans.RunProgram();
        }